Loading telephony/common/com/android/internal/telephony/TelephonyPermissions.java +30 −2 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.telephony.TelephonyManager; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.flags.Flags; import java.util.HashMap; import java.util.HashSet; Loading Loading @@ -716,10 +717,11 @@ public final class TelephonyPermissions { } private static int getCarrierPrivilegeStatus(Context context, int subId, int uid) { if (uid == Process.SYSTEM_UID || uid == Process.PHONE_UID) { if (isSystemOrPhone(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( Loading Loading @@ -926,4 +928,30 @@ public final class TelephonyPermissions { || checkCallingOrSelfReadPhoneNumber(context, subId, callingPackage, callingFeatureId, message)); } /** * @return true if the specified {@code uid} is for a system or phone process, no matter if runs * as system user or not. */ public static boolean isSystemOrPhone(int uid) { if (Flags.supportPhoneUidCheckForMultiuser()) { return UserHandle.isSameApp(uid, Process.SYSTEM_UID) || UserHandle.isSameApp(uid, Process.PHONE_UID); } else { return uid == Process.SYSTEM_UID || uid == Process.PHONE_UID; } } /** * @return true if the specified {@code uid} is for a ROOT or SHELL process, no matter if runs * as system user or not. */ public static boolean isRootOrShell(int uid) { if (Flags.supportPhoneUidCheckForMultiuser()) { return UserHandle.isSameApp(uid, Process.ROOT_UID) || UserHandle.isSameApp(uid, Process.SHELL_UID); } else { return uid == Process.ROOT_UID || uid == Process.SHELL_UID; } } } Loading
telephony/common/com/android/internal/telephony/TelephonyPermissions.java +30 −2 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.telephony.TelephonyManager; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.flags.Flags; import java.util.HashMap; import java.util.HashSet; Loading Loading @@ -716,10 +717,11 @@ public final class TelephonyPermissions { } private static int getCarrierPrivilegeStatus(Context context, int subId, int uid) { if (uid == Process.SYSTEM_UID || uid == Process.PHONE_UID) { if (isSystemOrPhone(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( Loading Loading @@ -926,4 +928,30 @@ public final class TelephonyPermissions { || checkCallingOrSelfReadPhoneNumber(context, subId, callingPackage, callingFeatureId, message)); } /** * @return true if the specified {@code uid} is for a system or phone process, no matter if runs * as system user or not. */ public static boolean isSystemOrPhone(int uid) { if (Flags.supportPhoneUidCheckForMultiuser()) { return UserHandle.isSameApp(uid, Process.SYSTEM_UID) || UserHandle.isSameApp(uid, Process.PHONE_UID); } else { return uid == Process.SYSTEM_UID || uid == Process.PHONE_UID; } } /** * @return true if the specified {@code uid} is for a ROOT or SHELL process, no matter if runs * as system user or not. */ public static boolean isRootOrShell(int uid) { if (Flags.supportPhoneUidCheckForMultiuser()) { return UserHandle.isSameApp(uid, Process.ROOT_UID) || UserHandle.isSameApp(uid, Process.SHELL_UID); } else { return uid == Process.ROOT_UID || uid == Process.SHELL_UID; } } }