Loading src/java/com/android/internal/telephony/SmsController.java +6 −6 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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); Loading src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java +1 −0 Original line number Diff line number Diff line Loading @@ -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; } Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyPermissionsTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); Loading Loading
src/java/com/android/internal/telephony/SmsController.java +6 −6 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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); Loading
src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java +1 −0 Original line number Diff line number Diff line Loading @@ -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; } Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyPermissionsTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); Loading