Loading src/com/android/server/telecom/TelecomServiceImpl.java +26 −4 Original line number Original line Diff line number Diff line Loading @@ -1007,6 +1007,17 @@ public class TelecomServiceImpl { public int getCallStateUsingPackage(String callingPackage, String callingFeatureId) { public int getCallStateUsingPackage(String callingPackage, String callingFeatureId) { try { try { Log.startSession("TSI.getCallStateUsingPackage"); Log.startSession("TSI.getCallStateUsingPackage"); boolean privilegedUid = ((Binder.getCallingUid() == Process.ROOT_UID) || (Binder.getCallingUid() == Process.SHELL_UID)); // enforceCallingPackage but allow SHELL_UID if (!privilegedUid && !callingUidMatchesPackageManagerRecords(callingPackage)) { EventLog.writeEvent(0x534e4554, "236813210", Binder.getCallingUid(), "getCallStateUsingPackage"); throw new SecurityException("getCallStateUsingPackage: enforceCallingPackage"); } if (CompatChanges.isChangeEnabled( if (CompatChanges.isChangeEnabled( TelecomManager.ENABLE_GET_CALL_STATE_PERMISSION_PROTECTION, callingPackage, TelecomManager.ENABLE_GET_CALL_STATE_PERMISSION_PROTECTION, callingPackage, Binder.getCallingUserHandle())) { Binder.getCallingUserHandle())) { Loading Loading @@ -2388,6 +2399,20 @@ public class TelecomServiceImpl { } } private void enforceCallingPackage(String packageName, String message) { private void enforceCallingPackage(String packageName, String message) { int callingUid = Binder.getCallingUid(); if (callingUid != Process.ROOT_UID && !callingUidMatchesPackageManagerRecords(packageName)) { throw new SecurityException(message + ": Package " + packageName + " does not belong to " + callingUid); } } /** * helper method that determines whether the passed packageName uid matches the * Binder.callingUid */ private boolean callingUidMatchesPackageManagerRecords(String packageName) { int packageUid = -1; int packageUid = -1; int callingUid = Binder.getCallingUid(); int callingUid = Binder.getCallingUid(); PackageManager pm = mContext.createContextAsUser( PackageManager pm = mContext.createContextAsUser( Loading @@ -2399,10 +2424,7 @@ public class TelecomServiceImpl { // packageUid is -1 // packageUid is -1 } } } } if (packageUid != callingUid && callingUid != Process.ROOT_UID) { return packageUid == callingUid; throw new SecurityException(message + ": Package " + packageName + " does not belong to " + callingUid); } } } private void enforceTelecomFeature() { private void enforceTelecomFeature() { Loading Loading
src/com/android/server/telecom/TelecomServiceImpl.java +26 −4 Original line number Original line Diff line number Diff line Loading @@ -1007,6 +1007,17 @@ public class TelecomServiceImpl { public int getCallStateUsingPackage(String callingPackage, String callingFeatureId) { public int getCallStateUsingPackage(String callingPackage, String callingFeatureId) { try { try { Log.startSession("TSI.getCallStateUsingPackage"); Log.startSession("TSI.getCallStateUsingPackage"); boolean privilegedUid = ((Binder.getCallingUid() == Process.ROOT_UID) || (Binder.getCallingUid() == Process.SHELL_UID)); // enforceCallingPackage but allow SHELL_UID if (!privilegedUid && !callingUidMatchesPackageManagerRecords(callingPackage)) { EventLog.writeEvent(0x534e4554, "236813210", Binder.getCallingUid(), "getCallStateUsingPackage"); throw new SecurityException("getCallStateUsingPackage: enforceCallingPackage"); } if (CompatChanges.isChangeEnabled( if (CompatChanges.isChangeEnabled( TelecomManager.ENABLE_GET_CALL_STATE_PERMISSION_PROTECTION, callingPackage, TelecomManager.ENABLE_GET_CALL_STATE_PERMISSION_PROTECTION, callingPackage, Binder.getCallingUserHandle())) { Binder.getCallingUserHandle())) { Loading Loading @@ -2388,6 +2399,20 @@ public class TelecomServiceImpl { } } private void enforceCallingPackage(String packageName, String message) { private void enforceCallingPackage(String packageName, String message) { int callingUid = Binder.getCallingUid(); if (callingUid != Process.ROOT_UID && !callingUidMatchesPackageManagerRecords(packageName)) { throw new SecurityException(message + ": Package " + packageName + " does not belong to " + callingUid); } } /** * helper method that determines whether the passed packageName uid matches the * Binder.callingUid */ private boolean callingUidMatchesPackageManagerRecords(String packageName) { int packageUid = -1; int packageUid = -1; int callingUid = Binder.getCallingUid(); int callingUid = Binder.getCallingUid(); PackageManager pm = mContext.createContextAsUser( PackageManager pm = mContext.createContextAsUser( Loading @@ -2399,10 +2424,7 @@ public class TelecomServiceImpl { // packageUid is -1 // packageUid is -1 } } } } if (packageUid != callingUid && callingUid != Process.ROOT_UID) { return packageUid == callingUid; throw new SecurityException(message + ": Package " + packageName + " does not belong to " + callingUid); } } } private void enforceTelecomFeature() { private void enforceTelecomFeature() { Loading