Loading core/java/android/os/GraphicsEnvironment.java +51 −36 Original line number Original line Diff line number Diff line Loading @@ -163,6 +163,43 @@ public class GraphicsEnvironment { return true; return true; } } /** * Query to determine if ANGLE should be used */ public static boolean shouldUseAngle(Context context, Bundle coreSettings, String packageName) { if (packageName.isEmpty()) { Log.v(TAG, "No package name available yet, ANGLE should not be used"); return false; } final String devOptIn = getDriverForPkg(context, coreSettings, packageName); if (DEBUG) { Log.v(TAG, "ANGLE Developer option for '" + packageName + "' " + "set to: '" + devOptIn + "'"); } // We only want to use ANGLE if the app is whitelisted or the developer has // explicitly chosen something other than default driver. // The whitelist will be generated by the ANGLE APK at both boot time and // ANGLE update time. It will only include apps mentioned in the rules file. final boolean whitelisted = checkAngleWhitelist(context, coreSettings, packageName); final boolean requested = devOptIn.equals(sDriverMap.get(OpenGlDriverChoice.ANGLE)); final boolean useAngle = (whitelisted || requested); if (!useAngle) { return false; } if (whitelisted) { Log.v(TAG, "ANGLE whitelist includes " + packageName); } if (requested) { Log.v(TAG, "ANGLE developer option for " + packageName + ": " + devOptIn); } return true; } /** /** * Check whether application is debuggable * Check whether application is debuggable */ */ Loading Loading @@ -543,6 +580,8 @@ public class GraphicsEnvironment { getGlobalSettingsString(contentResolver, bundle, getGlobalSettingsString(contentResolver, bundle, Settings.Global.GLOBAL_SETTINGS_ANGLE_WHITELIST); Settings.Global.GLOBAL_SETTINGS_ANGLE_WHITELIST); if (DEBUG) Log.v(TAG, "ANGLE whitelist: " + angleWhitelist); return angleWhitelist.contains(packageName); return angleWhitelist.contains(packageName); } } Loading @@ -557,43 +596,11 @@ public class GraphicsEnvironment { */ */ public boolean setupAngle(Context context, Bundle bundle, PackageManager pm, public boolean setupAngle(Context context, Bundle bundle, PackageManager pm, String packageName) { String packageName) { if (packageName.isEmpty()) { Log.v(TAG, "No package name available yet, skipping ANGLE setup"); return false; } final String devOptIn = getDriverForPkg(context, bundle, packageName); if (DEBUG) { Log.v(TAG, "ANGLE Developer option for '" + packageName + "' " + "set to: '" + devOptIn + "'"); } // We only need to check rules if the app is whitelisted or the developer has if (!shouldUseAngle(context, bundle, packageName)) { // explicitly chosen something other than default driver. // // The whitelist will be generated by the ANGLE APK at both boot time and // ANGLE update time. It will only include apps mentioned in the rules file. // // If the user has set the developer option to something other than default, // we need to call setupAngleRulesApk() with the package name and the developer // option value (native/angle/other). Then later when we are actually trying to // load a driver, GraphicsEnv::shouldUseAngle() has seen the package name before // and can confidently answer yes/no based on the previously set developer // option value. final boolean whitelisted = checkAngleWhitelist(context, bundle, packageName); final boolean defaulted = devOptIn.equals(sDriverMap.get(OpenGlDriverChoice.DEFAULT)); final boolean rulesCheck = (whitelisted || !defaulted); if (!rulesCheck) { return false; return false; } } if (whitelisted) { Log.v(TAG, "ANGLE whitelist includes " + packageName); } if (!defaulted) { Log.v(TAG, "ANGLE developer option for " + packageName + ": " + devOptIn); } final String anglePkgName = getAnglePackageName(pm); final String anglePkgName = getAnglePackageName(pm); if (anglePkgName.isEmpty()) { if (anglePkgName.isEmpty()) { Log.e(TAG, "Failed to find ANGLE package."); Log.e(TAG, "Failed to find ANGLE package."); Loading Loading @@ -631,6 +638,14 @@ public class GraphicsEnvironment { if (DEBUG) Log.v(TAG, "ANGLE package libs: " + paths); if (DEBUG) Log.v(TAG, "ANGLE package libs: " + paths); // If the user has set the developer option to something other than default, // we need to call setupAngleRulesApk() with the package name and the developer // option value (native/angle/other). Then later when we are actually trying to // load a driver, GraphicsEnv::getShouldUseAngle() has seen the package name before // and can confidently answer yes/no based on the previously set developer // option value. final String devOptIn = getDriverForPkg(context, bundle, packageName); if (setupAngleWithTempRulesFile(context, packageName, paths, devOptIn)) { if (setupAngleWithTempRulesFile(context, packageName, paths, devOptIn)) { // We setup ANGLE with a temp rules file, so we're done here. // We setup ANGLE with a temp rules file, so we're done here. return true; return true; Loading Loading @@ -663,9 +678,9 @@ public class GraphicsEnvironment { } } /** /** * Determine if ANGLE should be used. * Determine if ANGLE will be used and setup the environment */ */ private boolean shouldUseAngle(Context context, String packageName) { private boolean setupAndUseAngle(Context context, String packageName) { // Need to make sure we are evaluating ANGLE usage for the correct circumstances // Need to make sure we are evaluating ANGLE usage for the correct circumstances if (!setupAngle(context, null, context.getPackageManager(), packageName)) { if (!setupAngle(context, null, context.getPackageManager(), packageName)) { Log.v(TAG, "Package '" + packageName + "' should use not ANGLE"); Log.v(TAG, "Package '" + packageName + "' should use not ANGLE"); Loading @@ -685,7 +700,7 @@ public class GraphicsEnvironment { public void showAngleInUseDialogBox(Context context) { public void showAngleInUseDialogBox(Context context) { final String packageName = context.getPackageName(); final String packageName = context.getPackageName(); if (shouldShowAngleInUseDialogBox(context) && shouldUseAngle(context, packageName)) { if (shouldShowAngleInUseDialogBox(context) && setupAndUseAngle(context, packageName)) { final Intent intent = new Intent(ACTION_ANGLE_FOR_ANDROID_TOAST_MESSAGE); final Intent intent = new Intent(ACTION_ANGLE_FOR_ANDROID_TOAST_MESSAGE); String anglePkg = getAnglePackageName(context.getPackageManager()); String anglePkg = getAnglePackageName(context.getPackageManager()); intent.setPackage(anglePkg); intent.setPackage(anglePkg); Loading services/core/java/com/android/server/am/ProcessList.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -709,7 +709,10 @@ public final class ProcessList { ApplicationInfo applicationInfo) { ApplicationInfo applicationInfo) { final boolean shouldUseGameDriver = final boolean shouldUseGameDriver = GraphicsEnvironment.shouldUseGameDriver(context, coreSettings, applicationInfo); GraphicsEnvironment.shouldUseGameDriver(context, coreSettings, applicationInfo); return !shouldUseGameDriver; final boolean shouldUseAngle = GraphicsEnvironment.shouldUseAngle(context, coreSettings, applicationInfo.packageName); return !shouldUseGameDriver && !shouldUseAngle; } } public static String makeOomAdjString(int setAdj, boolean compact) { public static String makeOomAdjString(int setAdj, boolean compact) { Loading Loading
core/java/android/os/GraphicsEnvironment.java +51 −36 Original line number Original line Diff line number Diff line Loading @@ -163,6 +163,43 @@ public class GraphicsEnvironment { return true; return true; } } /** * Query to determine if ANGLE should be used */ public static boolean shouldUseAngle(Context context, Bundle coreSettings, String packageName) { if (packageName.isEmpty()) { Log.v(TAG, "No package name available yet, ANGLE should not be used"); return false; } final String devOptIn = getDriverForPkg(context, coreSettings, packageName); if (DEBUG) { Log.v(TAG, "ANGLE Developer option for '" + packageName + "' " + "set to: '" + devOptIn + "'"); } // We only want to use ANGLE if the app is whitelisted or the developer has // explicitly chosen something other than default driver. // The whitelist will be generated by the ANGLE APK at both boot time and // ANGLE update time. It will only include apps mentioned in the rules file. final boolean whitelisted = checkAngleWhitelist(context, coreSettings, packageName); final boolean requested = devOptIn.equals(sDriverMap.get(OpenGlDriverChoice.ANGLE)); final boolean useAngle = (whitelisted || requested); if (!useAngle) { return false; } if (whitelisted) { Log.v(TAG, "ANGLE whitelist includes " + packageName); } if (requested) { Log.v(TAG, "ANGLE developer option for " + packageName + ": " + devOptIn); } return true; } /** /** * Check whether application is debuggable * Check whether application is debuggable */ */ Loading Loading @@ -543,6 +580,8 @@ public class GraphicsEnvironment { getGlobalSettingsString(contentResolver, bundle, getGlobalSettingsString(contentResolver, bundle, Settings.Global.GLOBAL_SETTINGS_ANGLE_WHITELIST); Settings.Global.GLOBAL_SETTINGS_ANGLE_WHITELIST); if (DEBUG) Log.v(TAG, "ANGLE whitelist: " + angleWhitelist); return angleWhitelist.contains(packageName); return angleWhitelist.contains(packageName); } } Loading @@ -557,43 +596,11 @@ public class GraphicsEnvironment { */ */ public boolean setupAngle(Context context, Bundle bundle, PackageManager pm, public boolean setupAngle(Context context, Bundle bundle, PackageManager pm, String packageName) { String packageName) { if (packageName.isEmpty()) { Log.v(TAG, "No package name available yet, skipping ANGLE setup"); return false; } final String devOptIn = getDriverForPkg(context, bundle, packageName); if (DEBUG) { Log.v(TAG, "ANGLE Developer option for '" + packageName + "' " + "set to: '" + devOptIn + "'"); } // We only need to check rules if the app is whitelisted or the developer has if (!shouldUseAngle(context, bundle, packageName)) { // explicitly chosen something other than default driver. // // The whitelist will be generated by the ANGLE APK at both boot time and // ANGLE update time. It will only include apps mentioned in the rules file. // // If the user has set the developer option to something other than default, // we need to call setupAngleRulesApk() with the package name and the developer // option value (native/angle/other). Then later when we are actually trying to // load a driver, GraphicsEnv::shouldUseAngle() has seen the package name before // and can confidently answer yes/no based on the previously set developer // option value. final boolean whitelisted = checkAngleWhitelist(context, bundle, packageName); final boolean defaulted = devOptIn.equals(sDriverMap.get(OpenGlDriverChoice.DEFAULT)); final boolean rulesCheck = (whitelisted || !defaulted); if (!rulesCheck) { return false; return false; } } if (whitelisted) { Log.v(TAG, "ANGLE whitelist includes " + packageName); } if (!defaulted) { Log.v(TAG, "ANGLE developer option for " + packageName + ": " + devOptIn); } final String anglePkgName = getAnglePackageName(pm); final String anglePkgName = getAnglePackageName(pm); if (anglePkgName.isEmpty()) { if (anglePkgName.isEmpty()) { Log.e(TAG, "Failed to find ANGLE package."); Log.e(TAG, "Failed to find ANGLE package."); Loading Loading @@ -631,6 +638,14 @@ public class GraphicsEnvironment { if (DEBUG) Log.v(TAG, "ANGLE package libs: " + paths); if (DEBUG) Log.v(TAG, "ANGLE package libs: " + paths); // If the user has set the developer option to something other than default, // we need to call setupAngleRulesApk() with the package name and the developer // option value (native/angle/other). Then later when we are actually trying to // load a driver, GraphicsEnv::getShouldUseAngle() has seen the package name before // and can confidently answer yes/no based on the previously set developer // option value. final String devOptIn = getDriverForPkg(context, bundle, packageName); if (setupAngleWithTempRulesFile(context, packageName, paths, devOptIn)) { if (setupAngleWithTempRulesFile(context, packageName, paths, devOptIn)) { // We setup ANGLE with a temp rules file, so we're done here. // We setup ANGLE with a temp rules file, so we're done here. return true; return true; Loading Loading @@ -663,9 +678,9 @@ public class GraphicsEnvironment { } } /** /** * Determine if ANGLE should be used. * Determine if ANGLE will be used and setup the environment */ */ private boolean shouldUseAngle(Context context, String packageName) { private boolean setupAndUseAngle(Context context, String packageName) { // Need to make sure we are evaluating ANGLE usage for the correct circumstances // Need to make sure we are evaluating ANGLE usage for the correct circumstances if (!setupAngle(context, null, context.getPackageManager(), packageName)) { if (!setupAngle(context, null, context.getPackageManager(), packageName)) { Log.v(TAG, "Package '" + packageName + "' should use not ANGLE"); Log.v(TAG, "Package '" + packageName + "' should use not ANGLE"); Loading @@ -685,7 +700,7 @@ public class GraphicsEnvironment { public void showAngleInUseDialogBox(Context context) { public void showAngleInUseDialogBox(Context context) { final String packageName = context.getPackageName(); final String packageName = context.getPackageName(); if (shouldShowAngleInUseDialogBox(context) && shouldUseAngle(context, packageName)) { if (shouldShowAngleInUseDialogBox(context) && setupAndUseAngle(context, packageName)) { final Intent intent = new Intent(ACTION_ANGLE_FOR_ANDROID_TOAST_MESSAGE); final Intent intent = new Intent(ACTION_ANGLE_FOR_ANDROID_TOAST_MESSAGE); String anglePkg = getAnglePackageName(context.getPackageManager()); String anglePkg = getAnglePackageName(context.getPackageManager()); intent.setPackage(anglePkg); intent.setPackage(anglePkg); Loading
services/core/java/com/android/server/am/ProcessList.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -709,7 +709,10 @@ public final class ProcessList { ApplicationInfo applicationInfo) { ApplicationInfo applicationInfo) { final boolean shouldUseGameDriver = final boolean shouldUseGameDriver = GraphicsEnvironment.shouldUseGameDriver(context, coreSettings, applicationInfo); GraphicsEnvironment.shouldUseGameDriver(context, coreSettings, applicationInfo); return !shouldUseGameDriver; final boolean shouldUseAngle = GraphicsEnvironment.shouldUseAngle(context, coreSettings, applicationInfo.packageName); return !shouldUseGameDriver && !shouldUseAngle; } } public static String makeOomAdjString(int setAdj, boolean compact) { public static String makeOomAdjString(int setAdj, boolean compact) { Loading