Removed unused code from FDroidApp.

From before content providers, where we rolled our own update notification
system for when data changed in the database. I also removed the property
"ctx", because it is availble in getApplicationContext(). As a general rule,
it is usually safer to not use a member field if not neccesary. That way,
there doesn't need to be any assumptions about when it is set and what value
it has. In this case, it was only set half way through onCreate, and therefore
usage before then would break.
This commit is contained in:
Peter Serwylo 2014-02-23 09:54:21 +11:00
parent 3bfd5cbf0d
commit bfdfb6d5ef
4 changed files with 5 additions and 40 deletions

View File

@ -281,10 +281,6 @@ public class FDroid extends FragmentActivity {
// check if the particular setting has actually been changed.
UpdateService.schedule(getBaseContext());
if ((resultCode & PreferencesActivity.RESULT_RELOAD) != 0) {
((FDroidApp) getApplication()).invalidateAllApps();
}
if ((resultCode & PreferencesActivity.RESULT_RESTART) != 0) {
((FDroidApp) getApplication()).reloadTheme();
final Intent intent = getIntent();

View File

@ -129,13 +129,11 @@ public class FDroidApp extends Application {
}
}
invalidApps = new ArrayList<String>();
ctx = getApplicationContext();
UpdateService.schedule(ctx);
UpdateService.schedule(getApplicationContext());
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(ctx)
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.discCache(new LimitedAgeDiscCache(
new File(StorageUtils.getCacheDirectory(ctx, true),
new File(StorageUtils.getCacheDirectory(getApplicationContext(), true),
"icons"),
new FileNameGenerator() {
@Override
@ -170,8 +168,8 @@ public class FDroidApp extends Application {
* compose a chain of trust managers as follows:
* MemorizingTrustManager -> Pinning Trust Manager -> System Trust Manager
*/
PinningTrustManager pinMgr = new PinningTrustManager(SystemKeyStore.getInstance(ctx),FDroidCertPins.getPinList(), 0);
MemorizingTrustManager memMgr = new MemorizingTrustManager(ctx, pinMgr, defaultTrustManager);
PinningTrustManager pinMgr = new PinningTrustManager(SystemKeyStore.getInstance(getApplicationContext()),FDroidCertPins.getPinList(), 0);
MemorizingTrustManager memMgr = new MemorizingTrustManager(getApplicationContext(), pinMgr, defaultTrustManager);
/*
* initialize a SSLContext with the outermost trust manager, use this
@ -189,29 +187,4 @@ public class FDroidApp extends Application {
}
}
private Context ctx;
// Set when something has changed (database or installed apps) so we know
// we should invalidate the apps.
private Semaphore appsInvalidLock = new Semaphore(1, false);
private List<String> invalidApps;
// Set apps invalid. Call this when the database has been updated with
// new app information, or when the installed packages have changed.
public void invalidateAllApps() {
try {
appsInvalidLock.acquire();
} catch (InterruptedException e) {
// Don't care
} finally {
appsInvalidLock.release();
}
}
// Invalidate a single app
public void invalidateApp(String id) {
Log.d("FDroid", "Invalidating "+id);
invalidApps.add(id);
}
}

View File

@ -36,7 +36,6 @@ import org.fdroid.fdroid.compat.ActionBarCompat;
public class PreferencesActivity extends PreferenceActivity implements
OnSharedPreferenceChangeListener {
public static final int RESULT_RELOAD = 1;
public static final int RESULT_RESTART = 4;
private int result = 0;
@ -184,7 +183,6 @@ public class PreferencesActivity extends PreferenceActivity implements
@Override
public void onSharedPreferenceChanged(
SharedPreferences sharedPreferences, String key) {
updateSummary(key, true);
}

View File

@ -169,8 +169,6 @@ public class RepoProvider extends FDroidProvider {
Uri appUri = AppProvider.getNoApksUri();
int appCount = resolver.delete(appUri, null, null);
Log.d("Log", "Removed " + appCount + " apps with no apks.");
app.invalidateAllApps();
}
public static int countAppsForRepo(Context context, long repoId) {