Make some declaration accesses weaker

As suggested by Android Studio.
This commit is contained in:
Daniel Martí 2016-02-28 14:19:02 +00:00
parent 982bf42a4b
commit 9c86655af0
20 changed files with 61 additions and 58 deletions

View File

@ -1043,7 +1043,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
public static class AppDetailsSummaryFragment extends Fragment { public static class AppDetailsSummaryFragment extends Fragment {
protected final Preferences prefs; final Preferences prefs;
private AppDetailsData data; private AppDetailsData data;
private static final int MAX_LINES = 5; private static final int MAX_LINES = 5;
private static boolean viewAllDescription; private static boolean viewAllDescription;
@ -1076,11 +1076,11 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
data = (AppDetailsData) activity; data = (AppDetailsData) activity;
} }
protected App getApp() { App getApp() {
return data.getApp(); return data.getApp();
} }
protected ApkListAdapter getApks() { ApkListAdapter getApks() {
return data.getApks(); return data.getApks();
} }
@ -1436,7 +1436,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
private TextView progressSize; private TextView progressSize;
private TextView progressPercent; private TextView progressPercent;
private ImageButton cancelButton; private ImageButton cancelButton;
protected final DisplayImageOptions displayImageOptions; final DisplayImageOptions displayImageOptions;
public static boolean installed; public static boolean installed;
public static boolean updateWanted; public static boolean updateWanted;
@ -1678,19 +1678,19 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
installListener = (AppInstallListener) activity; installListener = (AppInstallListener) activity;
} }
protected void install(final Apk apk) { void install(final Apk apk) {
installListener.install(apk); installListener.install(apk);
} }
protected void remove() { void remove() {
installListener.removeApk(getApp().packageName); installListener.removeApk(getApp().packageName);
} }
protected App getApp() { App getApp() {
return data.getApp(); return data.getApp();
} }
protected ApkListAdapter getApks() { ApkListAdapter getApks() {
return data.getApks(); return data.getApks();
} }

View File

@ -362,7 +362,7 @@ public class FDroidApp extends Application {
/** /**
* Set the proxy settings based on whether Tor should be enabled or not. * Set the proxy settings based on whether Tor should be enabled or not.
*/ */
public static void configureTor(boolean enabled) { private static void configureTor(boolean enabled) {
useTor = enabled; useTor = enabled;
if (useTor) { if (useTor) {
NetCipher.useTor(); NetCipher.useTor();

View File

@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class FDroidCertPins { class FDroidCertPins {
private static final String[] DEFAULT_PINS = { private static final String[] DEFAULT_PINS = {
// OU=PositiveSSL, CN=f-droid.org // OU=PositiveSSL, CN=f-droid.org

View File

@ -77,7 +77,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
public static final String DEFAULT_THEME = "light"; public static final String DEFAULT_THEME = "light";
public static final String DEFAULT_PROXY_HOST = "127.0.0.1"; public static final String DEFAULT_PROXY_HOST = "127.0.0.1";
public static final int DEFAULT_PROXY_PORT = 8118; public static final int DEFAULT_PROXY_PORT = 8118;
public static final boolean DEFAULT_SHOW_NFC_DURING_SWAP = true; private static final boolean DEFAULT_SHOW_NFC_DURING_SWAP = true;
private static final boolean DEFAULT_FIRST_TIME = true; private static final boolean DEFAULT_FIRST_TIME = true;
private static final boolean DEFAULT_POST_PRIVILEGED_INSTALL = false; private static final boolean DEFAULT_POST_PRIVILEGED_INSTALL = false;

View File

@ -54,10 +54,13 @@ public class RepoUpdater {
public static final String PROGRESS_COMMITTING = "committing"; public static final String PROGRESS_COMMITTING = "committing";
public static final String PROGRESS_DATA_REPO_ADDRESS = "repoAddress"; public static final String PROGRESS_DATA_REPO_ADDRESS = "repoAddress";
@NonNull protected final Context context; @NonNull
@NonNull protected final Repo repo; private final Context context;
protected boolean hasChanged; @NonNull
@Nullable protected ProgressListener progressListener; private final Repo repo;
private boolean hasChanged;
@Nullable
private ProgressListener progressListener;
private String cacheTag; private String cacheTag;
private X509Certificate signingCertFromJar; private X509Certificate signingCertFromJar;
@ -82,7 +85,7 @@ public class RepoUpdater {
return hasChanged; return hasChanged;
} }
protected URL getIndexAddress() throws MalformedURLException { private URL getIndexAddress() throws MalformedURLException {
String urlString = repo.address + "/index.jar"; String urlString = repo.address + "/index.jar";
String versionName = Utils.getVersionName(context); String versionName = Utils.getVersionName(context);
if (versionName != null) { if (versionName != null) {
@ -91,7 +94,7 @@ public class RepoUpdater {
return new URL(urlString); return new URL(urlString);
} }
Downloader downloadIndex() throws UpdateException { private Downloader downloadIndex() throws UpdateException {
Downloader downloader = null; Downloader downloader = null;
try { try {
downloader = DownloaderFactory.create(context, downloader = DownloaderFactory.create(context,

View File

@ -35,11 +35,11 @@ public class TabManager {
this.pager = pager; this.pager = pager;
} }
protected CharSequence getLabel(int index) { private CharSequence getLabel(int index) {
return pager.getAdapter().getPageTitle(index); return pager.getAdapter().getPageTitle(index);
} }
public void removeNotification(int id) { private void removeNotification(int id) {
parent.removeNotification(id); parent.removeNotification(id);
} }

View File

@ -13,7 +13,7 @@ import org.fdroid.fdroid.Utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class DBHelper extends SQLiteOpenHelper { class DBHelper extends SQLiteOpenHelper {
private static final String TAG = "DBHelper"; private static final String TAG = "DBHelper";

View File

@ -32,7 +32,7 @@ public class InstalledAppCacheUpdater {
private final List<PackageInfo> toInsert = new ArrayList<>(); private final List<PackageInfo> toInsert = new ArrayList<>();
private final List<String> toDelete = new ArrayList<>(); private final List<String> toDelete = new ArrayList<>();
protected InstalledAppCacheUpdater(Context context) { private InstalledAppCacheUpdater(Context context) {
this.context = context; this.context = context;
} }
@ -59,7 +59,7 @@ public class InstalledAppCacheUpdater {
updater.startBackgroundWorker(); updater.startBackgroundWorker();
} }
protected boolean update() { private boolean update() {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
@ -72,13 +72,13 @@ public class InstalledAppCacheUpdater {
return hasChanged(); return hasChanged();
} }
protected void notifyProviders() { private void notifyProviders() {
Utils.debugLog(TAG, "Installed app cache has changed, notifying content providers (so they can update the relevant views)."); Utils.debugLog(TAG, "Installed app cache has changed, notifying content providers (so they can update the relevant views).");
context.getContentResolver().notifyChange(AppProvider.getContentUri(), null); context.getContentResolver().notifyChange(AppProvider.getContentUri(), null);
context.getContentResolver().notifyChange(ApkProvider.getContentUri(), null); context.getContentResolver().notifyChange(ApkProvider.getContentUri(), null);
} }
protected void startBackgroundWorker() { private void startBackgroundWorker() {
new PostponedWorker().execute(); new PostponedWorker().execute();
} }

View File

@ -4,7 +4,7 @@ import android.database.Cursor;
class ValueObject { class ValueObject {
protected void checkCursorPosition(Cursor cursor) throws IllegalArgumentException { void checkCursorPosition(Cursor cursor) throws IllegalArgumentException {
if (cursor.getPosition() == -1) { if (cursor.getPosition() == -1) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Cursor position is -1. " + "Cursor position is -1. " +

View File

@ -37,9 +37,9 @@ import java.util.List;
* instantiate a working Installer based on F-Droids granted permissions. * instantiate a working Installer based on F-Droids granted permissions.
*/ */
public abstract class Installer { public abstract class Installer {
protected final Context mContext; final Context mContext;
protected final PackageManager mPm; final PackageManager mPm;
protected final InstallerCallback mCallback; final InstallerCallback mCallback;
private static final String TAG = "Installer"; private static final String TAG = "Installer";
@ -88,7 +88,7 @@ public abstract class Installer {
void onError(int operation, int errorCode); void onError(int operation, int errorCode);
} }
public Installer(Context context, PackageManager pm, InstallerCallback callback) Installer(Context context, PackageManager pm, InstallerCallback callback)
throws AndroidNotCompatibleException { throws AndroidNotCompatibleException {
this.mContext = context; this.mContext = context;
this.mPm = pm; this.mPm = pm;

View File

@ -104,7 +104,7 @@ class BluetoothFinder extends PeerFinder {
} }
public void cancel() { private void cancel() {
if (adapter != null) { if (adapter != null) {
Utils.debugLog(TAG, "Stopping bluetooth discovery."); Utils.debugLog(TAG, "Stopping bluetooth discovery.");
adapter.cancelDiscovery(); adapter.cancelDiscovery();

View File

@ -59,7 +59,7 @@ public class BonjourPeer extends WifiPeer {
dest.writeParcelable(serviceInfo, flags); dest.writeParcelable(serviceInfo, flags);
} }
protected BonjourPeer(Parcel in) { private BonjourPeer(Parcel in) {
this((ServiceInfo) in.readParcelable(FDroidServiceInfo.class.getClassLoader())); this((ServiceInfo) in.readParcelable(FDroidServiceInfo.class.getClassLoader()));
} }

View File

@ -103,7 +103,7 @@ public class BonjourBroadcast extends SwapType {
if (FDroidApp.ipAddressString != null) { if (FDroidApp.ipAddressString != null) {
try { try {
return InetAddress.getByName(FDroidApp.ipAddressString); return InetAddress.getByName(FDroidApp.ipAddressString);
} catch (UnknownHostException e) { } } catch (UnknownHostException ignored) { }
} }
return null; return null;

View File

@ -191,7 +191,7 @@ public class AsyncDownloaderFromAndroid implements AsyncDownloader {
return 0; return 0;
} }
protected void sendProgress(int bytesRead, int totalBytes) { private void sendProgress(int bytesRead, int totalBytes) {
Intent intent = new Intent(Downloader.LOCAL_ACTION_PROGRESS); Intent intent = new Intent(Downloader.LOCAL_ACTION_PROGRESS);
intent.putExtra(Downloader.EXTRA_ADDRESS, remoteAddress); intent.putExtra(Downloader.EXTRA_ADDRESS, remoteAddress);
intent.putExtra(Downloader.EXTRA_BYTES_READ, bytesRead); intent.putExtra(Downloader.EXTRA_BYTES_READ, bytesRead);
@ -321,7 +321,7 @@ public class AsyncDownloaderFromAndroid implements AsyncDownloader {
* Check if a specific download is complete. * Check if a specific download is complete.
* @return -1 if download is not complete, otherwise the download id * @return -1 if download is not complete, otherwise the download id
*/ */
public static long isDownloadComplete(Context context, String uniqueDownloadId) { private static long isDownloadComplete(Context context, String uniqueDownloadId) {
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Query query = new DownloadManager.Query(); DownloadManager.Query query = new DownloadManager.Query();
query.setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL); query.setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL);

View File

@ -33,8 +33,8 @@ public abstract class Downloader {
protected final URL sourceUrl; protected final URL sourceUrl;
protected String cacheTag; protected String cacheTag;
protected int bytesRead; private int bytesRead;
protected int totalBytes; private int totalBytes;
protected abstract InputStream getDownloadersInputStream() throws IOException; protected abstract InputStream getDownloadersInputStream() throws IOException;
@ -84,7 +84,7 @@ public abstract class Downloader {
public abstract boolean hasChanged(); public abstract boolean hasChanged();
public abstract int totalDownloadSize(); protected abstract int totalDownloadSize();
/** /**
* Helper function for synchronous downloads (i.e. those *not* using AsyncDownloadWrapper), * Helper function for synchronous downloads (i.e. those *not* using AsyncDownloadWrapper),
@ -149,7 +149,7 @@ public abstract class Downloader {
* keeping track of the number of bytes that have flowed through for the * keeping track of the number of bytes that have flowed through for the
* progress counter. * progress counter.
*/ */
protected void copyInputToOutputStream(InputStream input, int bufferSize) throws IOException, InterruptedException { private void copyInputToOutputStream(InputStream input, int bufferSize) throws IOException, InterruptedException {
int bytesRead = 0; int bytesRead = 0;
this.totalBytes = totalDownloadSize(); this.totalBytes = totalDownloadSize();
@ -186,7 +186,7 @@ public abstract class Downloader {
outputStream.close(); outputStream.close();
} }
protected void sendProgress(int bytesRead, int totalBytes) { private void sendProgress(int bytesRead, int totalBytes) {
this.bytesRead = bytesRead; this.bytesRead = bytesRead;
Intent intent = new Intent(LOCAL_ACTION_PROGRESS); Intent intent = new Intent(LOCAL_ACTION_PROGRESS);
intent.putExtra(EXTRA_ADDRESS, sourceUrl.toString()); intent.putExtra(EXTRA_ADDRESS, sourceUrl.toString());

View File

@ -216,7 +216,7 @@ public class LocalHTTPD extends NanoHTTPD {
* Serves file from homeDir and its' subdirectories (only). Uses only URI, * Serves file from homeDir and its' subdirectories (only). Uses only URI,
* ignores all headers and HTTP parameters. * ignores all headers and HTTP parameters.
*/ */
Response serveFile(String uri, Map<String, String> header, File file, String mime) { private Response serveFile(String uri, Map<String, String> header, File file, String mime) {
Response res; Response res;
try { try {
// Calculate etag // Calculate etag
@ -306,7 +306,7 @@ public class LocalHTTPD extends NanoHTTPD {
return res; return res;
} }
public static String getMimeTypeForFile(String uri) { private static String getMimeTypeForFile(String uri) {
String type = null; String type = null;
String extension = MimeTypeMap.getFileExtensionFromUrl(uri); String extension = MimeTypeMap.getFileExtensionFromUrl(uri);
if (extension != null) { if (extension != null) {

View File

@ -197,7 +197,7 @@ public class WifiStateChangeService extends Service {
} }
@TargetApi(9) @TargetApi(9)
public void setIpInfoFromNetworkInterface() { private void setIpInfoFromNetworkInterface() {
try { try {
for (Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); networkInterfaces.hasMoreElements();) { for (Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); networkInterfaces.hasMoreElements();) {
NetworkInterface netIf = networkInterfaces.nextElement(); NetworkInterface netIf = networkInterfaces.nextElement();

View File

@ -38,7 +38,7 @@ import eu.chainfire.libsuperuser.Shell;
*/ */
abstract class InstallExtension { abstract class InstallExtension {
protected final Context context; final Context context;
private static final String APK_FILE_NAME = "FDroidPrivileged.apk"; private static final String APK_FILE_NAME = "FDroidPrivileged.apk";
@ -67,7 +67,7 @@ abstract class InstallExtension {
protected abstract String getSystemFolder(); protected abstract String getSystemFolder();
protected void onPreInstall() { void onPreInstall() {
// To be overridden by relevant base class[es] // To be overridden by relevant base class[es]
} }
@ -79,7 +79,7 @@ abstract class InstallExtension {
return context.getString(R.string.system_install_installing); return context.getString(R.string.system_install_installing);
} }
protected String getInstallPath() { String getInstallPath() {
return getSystemFolder() + APK_FILE_NAME; return getSystemFolder() + APK_FILE_NAME;
} }
@ -95,14 +95,14 @@ abstract class InstallExtension {
return commands; return commands;
} }
protected List<String> getCopyToSystemCommands(String apkPath) { List<String> getCopyToSystemCommands(String apkPath) {
final List<String> commands = new ArrayList<>(2); final List<String> commands = new ArrayList<>(2);
commands.add("cat " + apkPath + " > " + getInstallPath() + ".tmp"); commands.add("cat " + apkPath + " > " + getInstallPath() + ".tmp");
commands.add("chmod 644 " + getInstallPath() + ".tmp"); commands.add("chmod 644 " + getInstallPath() + ".tmp");
return commands; return commands;
} }
protected List<String> getPostInstallCommands() { List<String> getPostInstallCommands() {
final List<String> commands = new ArrayList<>(1); final List<String> commands = new ArrayList<>(1);
commands.add("am start -n org.fdroid.fdroid/.privileged.install.InstallExtensionDialogActivity --ez " commands.add("am start -n org.fdroid.fdroid/.privileged.install.InstallExtensionDialogActivity --ez "
+ InstallExtensionDialogActivity.ACTION_POST_INSTALL + " true"); + InstallExtensionDialogActivity.ACTION_POST_INSTALL + " true");
@ -121,13 +121,13 @@ abstract class InstallExtension {
return commands; return commands;
} }
protected List<String> getCleanUninstallCommands() { List<String> getCleanUninstallCommands() {
final List<String> commands = new ArrayList<>(1); final List<String> commands = new ArrayList<>(1);
commands.add("rm -f " + getInstallPath()); commands.add("rm -f " + getInstallPath());
return commands; return commands;
} }
protected List<String> getPostUninstallCommands() { List<String> getPostUninstallCommands() {
return new ArrayList<>(0); return new ArrayList<>(0);
} }

View File

@ -59,7 +59,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
public static final String ACTION_POST_INSTALL = "post_install"; public static final String ACTION_POST_INSTALL = "post_install";
public static final String ACTION_FIRST_TIME = "first_time"; public static final String ACTION_FIRST_TIME = "first_time";
String apkFile; private String apkFile;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -113,7 +113,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
} }
} }
public static void runFirstTime(final Context context) { private static void runFirstTime(final Context context) {
// don't do a "real" root access, just look up if "su" is present and has a version! // don't do a "real" root access, just look up if "su" is present and has a version!
// a real check would annoy the user // a real check would annoy the user
AsyncTask<Void, Void, Boolean> checkRoot = new AsyncTask<Void, Void, Boolean>() { AsyncTask<Void, Void, Boolean> checkRoot = new AsyncTask<Void, Void, Boolean>() {
@ -202,7 +202,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
builder.create().show(); builder.create().show();
} }
public void askBeforeInstall() { private void askBeforeInstall() {
// hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId()); ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());
@ -229,7 +229,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
/** /**
* 1. Check for root access * 1. Check for root access
*/ */
public final AsyncTask<Void, Void, Boolean> checkRootTask = new AsyncTask<Void, Void, Boolean>() { private final AsyncTask<Void, Void, Boolean> checkRootTask = new AsyncTask<Void, Void, Boolean>() {
ProgressDialog mProgressDialog; ProgressDialog mProgressDialog;
@Override @Override
@ -299,7 +299,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
/** /**
* 2. Install into system * 2. Install into system
*/ */
final AsyncTask<Void, Void, Void> installTask = new AsyncTask<Void, Void, Void>() { private final AsyncTask<Void, Void, Void> installTask = new AsyncTask<Void, Void, Void>() {
ProgressDialog mProgressDialog; ProgressDialog mProgressDialog;
@Override @Override
@ -413,7 +413,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
} }
} }
final AsyncTask<Void, Void, Void> uninstallTask = new AsyncTask<Void, Void, Void>() { private final AsyncTask<Void, Void, Void> uninstallTask = new AsyncTask<Void, Void, Void>() {
ProgressDialog mProgressDialog; ProgressDialog mProgressDialog;
@Override @Override

View File

@ -119,7 +119,7 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
* When peers are emitted by the peer finder, add them to the adapter * When peers are emitted by the peer finder, add them to the adapter
* so that they will show up in the list of peers. * so that they will show up in the list of peers.
*/ */
private Subscriber<Peer> onPeerFound = new Subscriber<Peer>() { private final Subscriber<Peer> onPeerFound = new Subscriber<Peer>() {
@Override @Override
public void onCompleted() { public void onCompleted() {
@ -185,7 +185,7 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
onWifiNetworkChanged, new IntentFilter(WifiStateChangeService.BROADCAST)); onWifiNetworkChanged, new IntentFilter(WifiStateChangeService.BROADCAST));
} }
private BroadcastReceiver onWifiNetworkChanged = new BroadcastReceiver() { private final BroadcastReceiver onWifiNetworkChanged = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
uiUpdateWifiNetwork(); uiUpdateWifiNetwork();
@ -271,7 +271,7 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
/** /**
* @see StartSwapView#onWifiSwapStateChanged * @see StartSwapView#onWifiSwapStateChanged
*/ */
private BroadcastReceiver onBluetoothSwapStateChanged = new BroadcastReceiver() { private final BroadcastReceiver onBluetoothSwapStateChanged = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (intent.hasExtra(SwapService.EXTRA_STARTING)) { if (intent.hasExtra(SwapService.EXTRA_STARTING)) {