Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 656c1eef authored by Aishwarya Mallampati's avatar Aishwarya Mallampati Committed by Automerger Merge Worker
Browse files

Merge "Skip subscription-user association check for emergency sms." into udc-dev am: 8371ad4c

parents 32e74f18 8371ad4c
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -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