From 5dc24d6aebdc28cc8a025280287a6a9026f0da7b Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Tue, 18 Jul 2017 16:14:26 -0700 Subject: [PATCH] Cache the build serial instead of querying every time. Also only return the original serial number if the targetSandboxVersion is less than 2, not just != 2. Change-Id: Ie17666798922bdac10a79bbc00934b311b816818 Fixes: 63808327 Test: run cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.EphemeralTest#testBuildSerialUnknown --- .../com/android/server/am/ActivityManagerService.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 97be5081415d..9e0a6454e180 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -1732,6 +1732,8 @@ public class ActivityManagerService extends IActivityManager.Stub final boolean mPermissionReviewRequired; + private static String sTheRealBuildSerial = Build.UNKNOWN; + /** * Current global configuration information. Contains general settings for the entire system, * also corresponds to the merged configuration of the default display. @@ -6990,12 +6992,8 @@ public class ActivityManagerService extends IActivityManager.Stub // We deprecated Build.SERIAL and it is not accessible to // apps that target the v2 security sandbox. Since access to // the serial is now behind a permission we push down the value. - String buildSerial = Build.UNKNOWN; - if (appInfo.targetSandboxVersion != 2) { - buildSerial = IDeviceIdentifiersPolicyService.Stub.asInterface( - ServiceManager.getService(Context.DEVICE_IDENTIFIERS_SERVICE)) - .getSerial(); - } + String buildSerial = appInfo.targetSandboxVersion < 2 + ? sTheRealBuildSerial : Build.UNKNOWN; // Check if this is a secondary process that should be incorporated into some // currently active instrumentation. (Note we do this AFTER all of the profiling @@ -14118,6 +14116,12 @@ public class ActivityManagerService extends IActivityManager.Stub mSystemReady = true; } + try { + sTheRealBuildSerial = IDeviceIdentifiersPolicyService.Stub.asInterface( + ServiceManager.getService(Context.DEVICE_IDENTIFIERS_SERVICE)) + .getSerial(); + } catch (RemoteException e) {} + ArrayList procsToKill = null; synchronized(mPidsSelfLocked) { for (int i=mPidsSelfLocked.size()-1; i>=0; i--) { -- 2.11.0