Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff9476be authored by Tim Van Patten's avatar Tim Van Patten
Browse files

Use Bundle to access Global.Settings values

While making the Developer Options changes, the app startup time was
increased due to reading the Global.Settings values incorrectly. As Cody
had already determined, we need to use the Bundle.getString() values,
rather than reading them from the Context. This change re-introduces
that fix.

Based on b/120784945, I'm looking at the 'bindApplication' values that's
output from the following test:

$ atest -it google/perf/app-startup/benchmark-app-hermetic/cold-dropcache-test --verbose

Without this fix:
  bindApplication: 22.67
  bindApplication: 21.47
  bindApplication: 19.40

With this fix:
  bindApplication: 16.67
  bindApplication: 16.33
  bindApplication: 16.67

Based on the above values, this appears to recover the missing time.

Bug: 120784945
Test: Verify app startup time is reduced.
Test: Verify ANGLE can still be enabled/disabled with the
Global.Settings values.
Test: Verify CtsAngleIntegrationHostTestCases passes.

Change-Id: I0435702c3708c8566e94673dd3a2a40eb8253052
parent df3de730
Loading
Loading
Loading
Loading
+12 −19
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.os;

import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -71,7 +70,7 @@ public class GraphicsEnvironment {
     */
    public void setup(Context context, Bundle coreSettings) {
        setupGpuLayers(context, coreSettings);
        setupAngle(context, context.getPackageName());
        setupAngle(context, coreSettings, context.getPackageName());
        chooseDriver(context, coreSettings);
    }

@@ -213,10 +212,9 @@ public class GraphicsEnvironment {
    }


    private static List<String> getGlobalSettingsString(Context context, String globalSetting) {
    private static List<String> getGlobalSettingsString(Bundle bundle, String globalSetting) {
        List<String> valueList = null;
        ContentResolver contentResolver = context.getContentResolver();
        String settingsValue = Settings.Global.getString(contentResolver, globalSetting);
        String settingsValue = bundle.getString(globalSetting);

        if (settingsValue != null) {
            valueList = new ArrayList<>(Arrays.asList(settingsValue.split(",")));
@@ -238,23 +236,18 @@ public class GraphicsEnvironment {
        return -1;
    }

    private static String getDriverForPkg(Context context, String packageName) {
        try {
            ContentResolver contentResolver = context.getContentResolver();
            int allUseAngle = Settings.Global.getInt(contentResolver,
                    Settings.Global.GLOBAL_SETTINGS_ANGLE_GL_DRIVER_ALL_ANGLE);
            if (allUseAngle == 1) {
    private static String getDriverForPkg(Bundle bundle, String packageName) {
        String allUseAngle =
                bundle.getString(Settings.Global.GLOBAL_SETTINGS_ANGLE_GL_DRIVER_ALL_ANGLE);
        if ((allUseAngle != null) && allUseAngle.equals("1")) {
            return sDriverMap.get(OpenGlDriverChoice.ANGLE);
        }
        } catch (Settings.SettingNotFoundException e) {
            // Do nothing and move on
        }

        List<String> globalSettingsDriverPkgs =
                getGlobalSettingsString(context,
                getGlobalSettingsString(bundle,
                        Settings.Global.GLOBAL_SETTINGS_ANGLE_GL_DRIVER_SELECTION_PKGS);
        List<String> globalSettingsDriverValues =
                getGlobalSettingsString(context,
                getGlobalSettingsString(bundle,
                        Settings.Global.GLOBAL_SETTINGS_ANGLE_GL_DRIVER_SELECTION_VALUES);

        // Make sure we have a good package name
@@ -285,8 +278,8 @@ public class GraphicsEnvironment {
    /**
     * Pass ANGLE details down to trigger enable logic
     */
    private void setupAngle(Context context, String packageName) {
        String devOptIn = getDriverForPkg(context, packageName);
    private void setupAngle(Context context, Bundle bundle, String packageName) {
        String devOptIn = getDriverForPkg(bundle, packageName);

        if (DEBUG) {
            Log.v(TAG, "ANGLE Developer option for '" + packageName + "' "