save result of Preferences.get() to speed up start up times
The initial start time is getting pretty slow, so hopefully this will save a little bit. It also makes it consistent with other places in the code, like UpdateService.
This commit is contained in:
		
							parent
							
								
									8503a625b5
								
							
						
					
					
						commit
						e44ca193dd
					
				@ -349,8 +349,9 @@ public class FDroidApp extends Application {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        Preferences.setup(this);
 | 
					        Preferences.setup(this);
 | 
				
			||||||
        Languages.setLanguage(this);
 | 
					        Languages.setLanguage(this);
 | 
				
			||||||
 | 
					        Preferences preferences = Preferences.get();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (Preferences.get().promptToSendCrashReports()) {
 | 
					        if (preferences.promptToSendCrashReports()) {
 | 
				
			||||||
            ACRA.init(this);
 | 
					            ACRA.init(this);
 | 
				
			||||||
            if (isAcraProcess() || HidingManager.isHidden(this)) {
 | 
					            if (isAcraProcess() || HidingManager.isHidden(this)) {
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
@ -359,16 +360,15 @@ public class FDroidApp extends Application {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        PRNGFixes.apply();
 | 
					        PRNGFixes.apply();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        curTheme = Preferences.get().getTheme();
 | 
					        curTheme = preferences.getTheme();
 | 
				
			||||||
        Preferences.get().configureProxy();
 | 
					        preferences.configureProxy();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // bug specific to exactly 5.0 makes it only work with the old index
 | 
					        // bug specific to exactly 5.0 makes it only work with the old index
 | 
				
			||||||
        // which includes an ugly, hacky workaround
 | 
					        // which includes an ugly, hacky workaround
 | 
				
			||||||
        // https://gitlab.com/fdroid/fdroidclient/issues/1014
 | 
					        // https://gitlab.com/fdroid/fdroidclient/issues/1014
 | 
				
			||||||
        if (Build.VERSION.SDK_INT == 21) {
 | 
					        if (Build.VERSION.SDK_INT == 21) {
 | 
				
			||||||
            Preferences p = Preferences.get();
 | 
					            preferences.setExpertMode(true);
 | 
				
			||||||
            p.setExpertMode(true);
 | 
					            preferences.setForceOldIndex(true);
 | 
				
			||||||
            p.setForceOldIndex(true);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        InstalledAppProviderService.compareToPackageManager(this);
 | 
					        InstalledAppProviderService.compareToPackageManager(this);
 | 
				
			||||||
@ -376,7 +376,7 @@ public class FDroidApp extends Application {
 | 
				
			|||||||
        // If the user changes the preference to do with filtering rooted apps,
 | 
					        // If the user changes the preference to do with filtering rooted apps,
 | 
				
			||||||
        // it is easier to just notify a change in the app provider,
 | 
					        // it is easier to just notify a change in the app provider,
 | 
				
			||||||
        // so that the newly updated list will correctly filter relevant apps.
 | 
					        // so that the newly updated list will correctly filter relevant apps.
 | 
				
			||||||
        Preferences.get().registerAppsRequiringRootChangeListener(new Preferences.ChangeListener() {
 | 
					        preferences.registerAppsRequiringRootChangeListener(new Preferences.ChangeListener() {
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void onPreferenceChange() {
 | 
					            public void onPreferenceChange() {
 | 
				
			||||||
                getContentResolver().notifyChange(AppProvider.getContentUri(), null);
 | 
					                getContentResolver().notifyChange(AppProvider.getContentUri(), null);
 | 
				
			||||||
@ -386,14 +386,14 @@ public class FDroidApp extends Application {
 | 
				
			|||||||
        // If the user changes the preference to do with filtering anti-feature apps,
 | 
					        // If the user changes the preference to do with filtering anti-feature apps,
 | 
				
			||||||
        // it is easier to just notify a change in the app provider,
 | 
					        // it is easier to just notify a change in the app provider,
 | 
				
			||||||
        // so that the newly updated list will correctly filter relevant apps.
 | 
					        // so that the newly updated list will correctly filter relevant apps.
 | 
				
			||||||
        Preferences.get().registerAppsRequiringAntiFeaturesChangeListener(new Preferences.ChangeListener() {
 | 
					        preferences.registerAppsRequiringAntiFeaturesChangeListener(new Preferences.ChangeListener() {
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void onPreferenceChange() {
 | 
					            public void onPreferenceChange() {
 | 
				
			||||||
                getContentResolver().notifyChange(AppProvider.getContentUri(), null);
 | 
					                getContentResolver().notifyChange(AppProvider.getContentUri(), null);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Preferences.get().registerUnstableUpdatesChangeListener(new Preferences.ChangeListener() {
 | 
					        preferences.registerUnstableUpdatesChangeListener(new Preferences.ChangeListener() {
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void onPreferenceChange() {
 | 
					            public void onPreferenceChange() {
 | 
				
			||||||
                AppProvider.Helper.calcSuggestedApks(FDroidApp.this);
 | 
					                AppProvider.Helper.calcSuggestedApks(FDroidApp.this);
 | 
				
			||||||
@ -457,16 +457,16 @@ public class FDroidApp extends Application {
 | 
				
			|||||||
        FDroidApp.initWifiSettings();
 | 
					        FDroidApp.initWifiSettings();
 | 
				
			||||||
        WifiStateChangeService.start(this, null);
 | 
					        WifiStateChangeService.start(this, null);
 | 
				
			||||||
        // if the HTTPS pref changes, then update all affected things
 | 
					        // if the HTTPS pref changes, then update all affected things
 | 
				
			||||||
        Preferences.get().registerLocalRepoHttpsListeners(new ChangeListener() {
 | 
					        preferences.registerLocalRepoHttpsListeners(new ChangeListener() {
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void onPreferenceChange() {
 | 
					            public void onPreferenceChange() {
 | 
				
			||||||
                WifiStateChangeService.start(getApplicationContext(), null);
 | 
					                WifiStateChangeService.start(getApplicationContext(), null);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        configureTor(Preferences.get().isTorEnabled());
 | 
					        configureTor(preferences.isTorEnabled());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (Preferences.get().isKeepingInstallHistory()) {
 | 
					        if (preferences.isKeepingInstallHistory()) {
 | 
				
			||||||
            InstallHistoryService.register(this);
 | 
					            InstallHistoryService.register(this);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -492,7 +492,7 @@ public class FDroidApp extends Application {
 | 
				
			|||||||
        atStartTime.edit().putInt("build-version", Build.VERSION.SDK_INT).apply();
 | 
					        atStartTime.edit().putInt("build-version", Build.VERSION.SDK_INT).apply();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        final String queryStringKey = "http-downloader-query-string";
 | 
					        final String queryStringKey = "http-downloader-query-string";
 | 
				
			||||||
        if (Preferences.get().sendVersionAndUUIDToServers()) {
 | 
					        if (preferences.sendVersionAndUUIDToServers()) {
 | 
				
			||||||
            HttpDownloader.queryString = atStartTime.getString(queryStringKey, null);
 | 
					            HttpDownloader.queryString = atStartTime.getString(queryStringKey, null);
 | 
				
			||||||
            if (HttpDownloader.queryString == null) {
 | 
					            if (HttpDownloader.queryString == null) {
 | 
				
			||||||
                UUID uuid = UUID.randomUUID();
 | 
					                UUID uuid = UUID.randomUUID();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user