From 6c47ade3794f819308a3b2c741b7036d4102dc93 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 14 Apr 2016 17:02:44 -0400 Subject: [PATCH] move init sequence comments to javadoc comments By putting these comments into javadoc, they are directly describing the code where it is, and there are many tools in IDEs for searching, viewing, sorting, etc. javadoc comments. Plain comments do not have those tools. --- .../java/org/fdroid/fdroid/FDroidApp.java | 26 +++++-------------- .../java/org/fdroid/fdroid/Preferences.java | 3 +++ .../java/org/fdroid/fdroid/UpdateService.java | 8 +++--- .../fdroid/data/InstalledAppCacheUpdater.java | 9 +++++-- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/FDroidApp.java b/app/src/main/java/org/fdroid/fdroid/FDroidApp.java index d086d8e3f..6ec2355b8 100644 --- a/app/src/main/java/org/fdroid/fdroid/FDroidApp.java +++ b/app/src/main/java/org/fdroid/fdroid/FDroidApp.java @@ -136,6 +136,9 @@ public class FDroidApp extends Application { } } + /** + * Initialize the settings needed to run a local swap repo. + */ public static void initWifiSettings() { port = 8888; ipAddressString = null; @@ -182,26 +185,14 @@ public class FDroidApp extends Application { updateLanguage(); ACRA.init(this); - // Needs to be setup before anything else tries to access it. - // Perhaps the constructor is a better place, but then again, - // it is more deterministic as to when this gets called... - Preferences.setup(this); - curTheme = Preferences.get().getTheme(); - - // Apply the Google PRNG fixes to properly seed SecureRandom PRNGFixes.apply(); - // Check that the installed app cache hasn't gotten out of sync somehow. - // e.g. if we crashed/ran out of battery half way through responding - // to a package installed intent. It doesn't really matter where - // we put this in the bootstrap process, because it runs on a different - // thread, which will be delayed by some seconds to avoid an error where - // the database is locked due to the database updater. - InstalledAppCacheUpdater.updateInBackground(getApplicationContext()); - - // make sure the current proxy stuff is configured + Preferences.setup(this); + curTheme = Preferences.get().getTheme(); Preferences.get().configureProxy(); + InstalledAppCacheUpdater.updateInBackground(getApplicationContext()); + // If the user changes the preference to do with filtering rooted apps, // it is easier to just notify a change in the app provider, // so that the newly updated list will correctly filter relevant apps. @@ -278,9 +269,6 @@ public class FDroidApp extends Application { .build(); ImageLoader.getInstance().init(config); - // TODO reintroduce PinningTrustManager and MemorizingTrustManager - - // initialized the local repo information FDroidApp.initWifiSettings(); startService(new Intent(this, WifiStateChangeService.class)); // if the HTTPS pref changes, then update all affected things diff --git a/app/src/main/java/org/fdroid/fdroid/Preferences.java b/app/src/main/java/org/fdroid/fdroid/Preferences.java index aed547b90..326ac2107 100644 --- a/app/src/main/java/org/fdroid/fdroid/Preferences.java +++ b/app/src/main/java/org/fdroid/fdroid/Preferences.java @@ -347,6 +347,9 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh private static Preferences instance; + /** + * Needs to be setup before anything else tries to access it. + */ public static void setup(Context context) { if (instance != null) { final String error = "Attempted to reinitialize preferences after it " + diff --git a/app/src/main/java/org/fdroid/fdroid/UpdateService.java b/app/src/main/java/org/fdroid/fdroid/UpdateService.java index 860b6b198..c3cadf50b 100644 --- a/app/src/main/java/org/fdroid/fdroid/UpdateService.java +++ b/app/src/main/java/org/fdroid/fdroid/UpdateService.java @@ -101,9 +101,11 @@ public class UpdateService extends IntentService implements ProgressListener { context.startService(intent); } - // Schedule (or cancel schedule for) this service, according to the - // current preferences. Should be called a) at boot, b) if the preference - // is changed, or c) on startup, in case we get upgraded. + /** + * Schedule or cancel this service to update the app index, according to the + * current preferences. Should be called a) at boot, b) if the preference + * is changed, or c) on startup, in case we get upgraded. + */ public static void schedule(Context ctx) { SharedPreferences prefs = PreferenceManager diff --git a/app/src/main/java/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java b/app/src/main/java/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java index 137921cf7..1e86bc8c9 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java +++ b/app/src/main/java/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java @@ -51,8 +51,13 @@ public final class InstalledAppCacheUpdater { /** * Ensure our database of installed apps is in sync with what the PackageManager tells us is installed. - * Once completed, the relevant ContentProviders will be notified of any changes to installed statuses. - * This method returns immediately, and will continue to work in an AsyncTask. + * The installed app cache hasn't gotten out of sync somehow, e.g. if we crashed/ran out of battery + * half way through responding to a package installed {@link android.content.Intent}. Once completed, + * the relevant {@link android.content.ContentProvider}s will be notified of any changes to installed + * statuses. This method returns immediately, and will continue to work in an AsyncTask. It doesn't + * really matter where we put this in the bootstrap process, because it runs on a different thread, + * which will be delayed by some seconds to avoid an error where the database is locked due to the + * database updater. */ public static void updateInBackground(Context context) { InstalledAppCacheUpdater updater = new InstalledAppCacheUpdater(context);