From f470edeff3ea5fd75e7ff3ef4d8326a71e8c4fc9 Mon Sep 17 00:00:00 2001 From: Hall Liu Date: Mon, 13 Jul 2020 12:42:36 -0700 Subject: Skip carrier priv check for trusted UIDs Checking carrier privileges for UIDs with lots of shared apps can incur a significant performance hit. For UIDs that are fixed and trusted (system and phone), skip the permission check and always allow. Bug: 160971853 Test: manual verification -- observed lower rate of cache misses for getPackageInfo from com.android.phone. Change-Id: I1399cab579308479d7cf191b8795441cbcd3ff65 Merged-In: I1399cab579308479d7cf191b8795441cbcd3ff65 --- .../common/com/android/internal/telephony/TelephonyPermissions.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'telephony/common') diff --git a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java index fff6696604dc..a1398e3b6207 100644 --- a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java +++ b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java @@ -659,6 +659,10 @@ public final class TelephonyPermissions { } private static int getCarrierPrivilegeStatus(Context context, int subId, int uid) { + if (uid == Process.SYSTEM_UID || uid == Process.PHONE_UID) { + // Skip the check if it's one of these special uids + return TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS; + } final long identity = Binder.clearCallingIdentity(); try { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService( -- cgit v1.2.3