From 5973ec96780bbe39dadabd5d0dbd9922128ccc4a Mon Sep 17 00:00:00 2001 From: Tim Van Patten Date: Mon, 8 Apr 2019 17:30:17 -0600 Subject: [PATCH] Verify Bundle is not null before using it It's possible the Bundle has not been initialized when determining if the ANGLE dialog box should be shown, due to how early that check is performed. This change will verify the Bundle is not null before using it and fall back to using the Context if it is. Bug: 130185493 Test: atest CtsAngleIntegrationHostTestCases Test: Enable Toast Message and then atest CtsAngleIntegrationHostTestCases Change-Id: I39f48bdf20616298c66b2bb36082149cb24e908c (cherry picked from commit 5da6a95eab7e80c510cd211e0117d5327ebae55a) --- core/java/android/os/GraphicsEnvironment.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java index a51a871e77804..232869d7aefc8 100644 --- a/core/java/android/os/GraphicsEnvironment.java +++ b/core/java/android/os/GraphicsEnvironment.java @@ -453,14 +453,22 @@ public class GraphicsEnvironment { final boolean appIsProfileable = isProfileable(context); final boolean deviceIsDebuggable = getCanLoadSystemLibraries() == 1; if (appIsDebuggable || appIsProfileable || deviceIsDebuggable) { + String debugPackage; - String debugPackage = - coreSettings.getString(Settings.Global.GLOBAL_SETTINGS_ANGLE_DEBUG_PACKAGE); + if (coreSettings != null) { + debugPackage = + coreSettings.getString(Settings.Global.GLOBAL_SETTINGS_ANGLE_DEBUG_PACKAGE); + } else { + ContentResolver contentResolver = context.getContentResolver(); + debugPackage = Settings.Global.getString(contentResolver, + Settings.Global.GLOBAL_SETTINGS_ANGLE_DEBUG_PACKAGE); + } if ((debugPackage != null) && (!debugPackage.isEmpty())) { return debugPackage; } } + return ""; }