From 41149c3031438ab801892ebb7100336ef614ba77 Mon Sep 17 00:00:00 2001 From: Cody Northrop Date: Mon, 6 May 2019 11:36:40 -0600 Subject: [PATCH] ANGLE: Reorder debug package check As originally coded, debug ANGLE packages could only be used if ANGLE was properly installed, such that a single answer was received from ANGLE_FOR_ANDROID. Since ANGLE is only required on new Q devices, debug packages could not be loaded on devices that upgraded from P. This CL changes the ordering such that debug packages are detected before checking for propertly installed ANGLE package. Bug: 132076614 Test: Manually test app with and without debug package Test: atest CtsAngleIntegrationHostTestCases Change-Id: I88f0417c7e74c2c20d087f2137eeb78879143ce5 --- core/java/android/os/GraphicsEnvironment.java | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java index 232869d7aefc8..31b5c0f76a575 100644 --- a/core/java/android/os/GraphicsEnvironment.java +++ b/core/java/android/os/GraphicsEnvironment.java @@ -601,28 +601,36 @@ public class GraphicsEnvironment { return false; } - final String anglePkgName = getAnglePackageName(pm); - if (anglePkgName.isEmpty()) { - Log.e(TAG, "Failed to find ANGLE package."); - return false; - } + ApplicationInfo angleInfo = null; - final ApplicationInfo angleInfo; - String angleDebugPackage = getAngleDebugPackage(context, bundle); - if (!angleDebugPackage.isEmpty()) { - Log.i(TAG, "ANGLE debug package enabled: " + angleDebugPackage); + // If the developer has specified a debug package over ADB, attempt to find it + String anglePkgName = getAngleDebugPackage(context, bundle); + if (!anglePkgName.isEmpty()) { + Log.i(TAG, "ANGLE debug package enabled: " + anglePkgName); try { // Note the debug package does not have to be pre-installed - angleInfo = pm.getApplicationInfo(angleDebugPackage, 0); + angleInfo = pm.getApplicationInfo(anglePkgName, 0); } catch (PackageManager.NameNotFoundException e) { - Log.w(TAG, "ANGLE debug package '" + angleDebugPackage + "' not installed"); + Log.w(TAG, "ANGLE debug package '" + anglePkgName + "' 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"); + } + + // Otherwise, check to see if ANGLE is properly installed + if (angleInfo == null) { + anglePkgName = getAnglePackageName(pm); + if (!anglePkgName.isEmpty()) { + Log.i(TAG, "ANGLE package enabled: " + anglePkgName); + try { + // Production ANGLE libraries must be pre-installed as a system app + angleInfo = pm.getApplicationInfo(anglePkgName, + PackageManager.MATCH_SYSTEM_ONLY); + } catch (PackageManager.NameNotFoundException e) { + Log.w(TAG, "ANGLE package '" + anglePkgName + "' not installed"); + return false; + } + } else { + Log.e(TAG, "Failed to find ANGLE package."); return false; } } @@ -683,7 +691,7 @@ public class GraphicsEnvironment { private boolean setupAndUseAngle(Context context, String packageName) { // Need to make sure we are evaluating ANGLE usage for the correct circumstances if (!setupAngle(context, null, context.getPackageManager(), packageName)) { - Log.v(TAG, "Package '" + packageName + "' should use not ANGLE"); + Log.v(TAG, "Package '" + packageName + "' should not use ANGLE"); return false; }