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

Commit 64ad8837 authored by Aishwarya Mallampati's avatar Aishwarya Mallampati Committed by Android (Google) Code Review
Browse files

Merge "Skip subscription-user association check for emergency sms." into udc-dev

parents 34be1669 f9811910
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ public class SmsController extends ISmsImplBase {

        // Check if user is associated with the subscription
        if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(mContext, subId,
                Binder.getCallingUserHandle())) {
                Binder.getCallingUserHandle(), destAddr)) {
            TelephonyUtils.showSwitchToManagedProfileDialogIfAppropriate(mContext, subId,
                    Binder.getCallingUid(), callingPackage);
            sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_USER_NOT_ALLOWED);
@@ -261,7 +261,7 @@ public class SmsController extends ISmsImplBase {

        // Check if user is associated with the subscription
        if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(mContext, subId,
                Binder.getCallingUserHandle())) {
                Binder.getCallingUserHandle(), destAddr)) {
            TelephonyUtils.showSwitchToManagedProfileDialogIfAppropriate(mContext, subId,
                    Binder.getCallingUid(), callingPackage);
            sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_USER_NOT_ALLOWED);
@@ -345,7 +345,7 @@ public class SmsController extends ISmsImplBase {

        // Check if user is associated with the subscription
        if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(mContext, subId,
                Binder.getCallingUserHandle())) {
                Binder.getCallingUserHandle(), destAddr)) {
            TelephonyUtils.showSwitchToManagedProfileDialogIfAppropriate(mContext, subId,
                    Binder.getCallingUid(), callingPackage);
            sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_USER_NOT_ALLOWED);
@@ -384,7 +384,7 @@ public class SmsController extends ISmsImplBase {

        // Check if user is associated with the subscription
        if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(mContext, subId,
                Binder.getCallingUserHandle())) {
                Binder.getCallingUserHandle(), destAddr)) {
            TelephonyUtils.showSwitchToManagedProfileDialogIfAppropriate(mContext, subId,
                    Binder.getCallingUid(), callingPackage);
            sendErrorInPendingIntents(sentIntents, SmsManager.RESULT_USER_NOT_ALLOWED);
@@ -421,7 +421,7 @@ public class SmsController extends ISmsImplBase {

        // Check if user is associated with the subscription
        if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(mContext, subId,
                Binder.getCallingUserHandle())) {
                Binder.getCallingUserHandle(), destAddr)) {
            TelephonyUtils.showSwitchToManagedProfileDialogIfAppropriate(mContext, subId,
                    Binder.getCallingUid(), callingPackage);
            sendErrorInPendingIntents(sentIntents, SmsManager.RESULT_USER_NOT_ALLOWED);
@@ -928,7 +928,7 @@ public class SmsController extends ISmsImplBase {

        // Check if user is associated with the subscription
        if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(mContext, subId,
                Binder.getCallingUserHandle())) {
                Binder.getCallingUserHandle(), number)) {
            TelephonyUtils.showSwitchToManagedProfileDialogIfAppropriate(mContext, subId,
                    Binder.getCallingUid(), callingPackage);
            sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_USER_NOT_ALLOWED);
+1 −0
Original line number Diff line number Diff line
@@ -3559,6 +3559,7 @@ public class SubscriptionManagerService extends ISub.Stub {
            }

            UserHandle userHandle = UserHandle.of(subInfo.getUserId());
            log("getSubscriptionUserHandle subId = " + subId + " userHandle = " + userHandle);
            if (userHandle.getIdentifier() == UserHandle.USER_NULL) {
                return null;
            }
+10 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -37,6 +38,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.permission.LegacyPermissionManager;
import android.provider.DeviceConfig;
import android.provider.Settings;
@@ -530,6 +532,14 @@ public class TelephonyPermissionsTest {
        }
    }

    @Test
    public void testCheckSubscriptionAssociatedWithUser_emergencyNumber() {
        doReturn(true).when(mTelephonyManagerMock).isEmergencyNumber(anyString());

        assertTrue(TelephonyPermissions.checkSubscriptionAssociatedWithUser(mMockContext, SUB_ID,
                UserHandle.SYSTEM, "911"));
    }

    // Put mMockTelephony into service cache so that TELEPHONY_SUPPLIER will get it.
    private void setTelephonyMockAsService() throws Exception {
        when(mMockTelephonyBinder.queryLocalInterface(anyString())).thenReturn(mMockTelephony);