summaryrefslogtreecommitdiff
path: root/core/java/android/os/GraphicsEnvironment.java
diff options
context:
space:
mode:
authorCody Northrop <cnorthrop@google.com>2019-03-28 19:27:19 -0600
committerCody Northrop <cnorthrop@google.com>2019-03-29 15:50:06 -0600
commitdc2fd94628e9f3a6a2b0771e0595c9a4730f648c (patch)
tree80d921956f7dccb38160e2f734ee60b04e5df0d9 /core/java/android/os/GraphicsEnvironment.java
parent38d503fe46436e6a92488d88088f2a43dab159f6 (diff)
ANGLE: Allow libs from debug package
Add a new setting that allows a developer to specify where to load ANGLE libraries from, rather than the default location. This is only allowed for apps that are dumpable, i.e. can have libraries injected. That includes debuggable, profileable, and root. To use the new setting: adb shell settings put global angle_debug_package <package> This allows a developer to build an APK directly from Chromium and use it with a production build of Android. It will override pre-installed system packages and updates. Note: Use of ANGLE Developer Options UI will cease to function until the debug package is uninstalled. Bug: 80239516 Test: Apply setting, see new ANGLE used Test: cts-tradefed run singleCommand cts -m CtsAngleIntegrationHostTestCases Change-Id: Ib3b1fb52c0eb669e7ea931959a73aba2bd15bedf
Diffstat (limited to 'core/java/android/os/GraphicsEnvironment.java')
-rw-r--r--core/java/android/os/GraphicsEnvironment.java41
1 files changed, 36 insertions, 5 deletions
diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java
index 43ac5749fecb..53503f47ca74 100644
--- a/core/java/android/os/GraphicsEnvironment.java
+++ b/core/java/android/os/GraphicsEnvironment.java
@@ -337,6 +337,25 @@ public class GraphicsEnvironment {
}
/**
+ * Check for ANGLE debug package, but only for apps that can load them (dumpable)
+ */
+ private String getAngleDebugPackage(Context context, Bundle coreSettings) {
+ final boolean appIsDebuggable = isDebuggable(context);
+ final boolean appIsProfileable = isProfileable(context);
+ final boolean deviceIsDebuggable = getCanLoadSystemLibraries() == 1;
+ if (appIsDebuggable || appIsProfileable || deviceIsDebuggable) {
+
+ String debugPackage =
+ coreSettings.getString(Settings.Global.GLOBAL_SETTINGS_ANGLE_DEBUG_PACKAGE);
+
+ if ((debugPackage != null) && (!debugPackage.isEmpty())) {
+ return debugPackage;
+ }
+ }
+ return "";
+ }
+
+ /**
* Attempt to setup ANGLE with a temporary rules file.
* True: Temporary rules file was loaded.
* False: Temporary rules file was *not* loaded.
@@ -502,11 +521,23 @@ public class GraphicsEnvironment {
}
final ApplicationInfo angleInfo;
- try {
- angleInfo = pm.getApplicationInfo(anglePkgName, PackageManager.MATCH_SYSTEM_ONLY);
- } catch (PackageManager.NameNotFoundException e) {
- Log.w(TAG, "ANGLE package '" + anglePkgName + "' not installed");
- return false;
+ String angleDebugPackage = getAngleDebugPackage(context, bundle);
+ if (!angleDebugPackage.isEmpty()) {
+ Log.i(TAG, "ANGLE debug package enabled: " + angleDebugPackage);
+ try {
+ // Note the debug package does not have to be pre-installed
+ angleInfo = pm.getApplicationInfo(angleDebugPackage, 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.w(TAG, "ANGLE debug package '" + angleDebugPackage + "' not installed");
+ return false;
+ }
+ } else {
+ try {
+ angleInfo = pm.getApplicationInfo(anglePkgName, PackageManager.MATCH_SYSTEM_ONLY);
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.w(TAG, "ANGLE package '" + anglePkgName + "' not installed");
+ return false;
+ }
}
final String abi = chooseAbi(angleInfo);