Loading telephony/common/com/android/internal/telephony/TelephonyPermissions.java +28 −0 Original line number Diff line number Diff line Loading @@ -840,6 +840,34 @@ public final class TelephonyPermissions { return Integer.MAX_VALUE; } /** * Check if calling user is associated with the given subscription. * Subscription-user association check is skipped if destination address is an emergency number. * * @param context Context * @param subId subscription ID * @param callerUserHandle caller user handle * @param destAddr destination address of the message * @return true if destAddr is an emergency number * and return false if user is not associated with the subscription. */ public static boolean checkSubscriptionAssociatedWithUser(@NonNull Context context, int subId, @NonNull UserHandle callerUserHandle, @NonNull String destAddr) { // Skip subscription-user association check for emergency numbers TelephonyManager tm = context.getSystemService(TelephonyManager.class); final long token = Binder.clearCallingIdentity(); try { if (tm != null && tm.isEmergencyNumber(destAddr)) { Log.d(LOG_TAG, "checkSubscriptionAssociatedWithUser:" + " destAddr is emergency number"); return true; } } finally { Binder.restoreCallingIdentity(token); } return checkSubscriptionAssociatedWithUser(context, subId, callerUserHandle); } /** * Check if calling user is associated with the given subscription. * @param context Context Loading Loading
telephony/common/com/android/internal/telephony/TelephonyPermissions.java +28 −0 Original line number Diff line number Diff line Loading @@ -840,6 +840,34 @@ public final class TelephonyPermissions { return Integer.MAX_VALUE; } /** * Check if calling user is associated with the given subscription. * Subscription-user association check is skipped if destination address is an emergency number. * * @param context Context * @param subId subscription ID * @param callerUserHandle caller user handle * @param destAddr destination address of the message * @return true if destAddr is an emergency number * and return false if user is not associated with the subscription. */ public static boolean checkSubscriptionAssociatedWithUser(@NonNull Context context, int subId, @NonNull UserHandle callerUserHandle, @NonNull String destAddr) { // Skip subscription-user association check for emergency numbers TelephonyManager tm = context.getSystemService(TelephonyManager.class); final long token = Binder.clearCallingIdentity(); try { if (tm != null && tm.isEmergencyNumber(destAddr)) { Log.d(LOG_TAG, "checkSubscriptionAssociatedWithUser:" + " destAddr is emergency number"); return true; } } finally { Binder.restoreCallingIdentity(token); } return checkSubscriptionAssociatedWithUser(context, subId, callerUserHandle); } /** * Check if calling user is associated with the given subscription. * @param context Context Loading