Loading src/java/com/android/internal/telephony/SubscriptionController.java +8 −9 Original line number Diff line number Diff line Loading @@ -4831,16 +4831,14 @@ public class SubscriptionController extends ISub.Stub { * @param userHandle the userHandle associated with the subscription * Pass {@code null} user handle to clear the association * @param subId the unique SubscriptionInfo index in database * @param callingPackage the package making the IPC * @return the number of records updated. * * @throws SecurityException if doesn't have required permission. * @throws IllegalArgumentException if subId is invalid. */ @Override public int setUserHandle(@Nullable UserHandle userHandle, int subId, @NonNull String callingPackage) { enforceManageSubscriptionUserAssociation("setUserHandle"); public int setSubscriptionUserHandle(@Nullable UserHandle userHandle, int subId) { enforceManageSubscriptionUserAssociation("setSubscriptionUserHandle"); if (userHandle == null) { userHandle = UserHandle.of(UserHandle.USER_NULL); Loading @@ -4854,7 +4852,8 @@ public class SubscriptionController extends ISub.Stub { if (ret != 0) { notifySubscriptionInfoChanged(); } else { throw new IllegalArgumentException("[setUserHandle]: Invalid subId: " + subId); throw new IllegalArgumentException("[setSubscriptionUserHandle]: Invalid subId: " + subId); } return ret; } finally { Loading @@ -4866,7 +4865,6 @@ public class SubscriptionController extends ISub.Stub { * Get UserHandle of this subscription. * * @param subId the unique SubscriptionInfo index in database * @param callingPackage the package making the IPC * @return userHandle associated with this subscription * or {@code null} if subscription is not associated with any user. * Loading @@ -4874,14 +4872,15 @@ public class SubscriptionController extends ISub.Stub { * @throws IllegalArgumentException if subId is invalid. */ @Override public UserHandle getUserHandle(int subId, @NonNull String callingPackage) { enforceManageSubscriptionUserAssociation("getUserHandle"); public UserHandle getSubscriptionUserHandle(int subId) { enforceManageSubscriptionUserAssociation("getSubscriptionUserHandle"); long token = Binder.clearCallingIdentity(); try { String userHandleStr = getSubscriptionProperty(subId, SubscriptionManager.USER_HANDLE); if (userHandleStr == null) { throw new IllegalArgumentException("[getUserHandle]: Invalid subId: " + subId); throw new IllegalArgumentException("[getSubscriptionUserHandle]: Invalid subId: " + subId); } UserHandle userHandle = UserHandle.of(Integer.parseInt(userHandleStr)); if (userHandle.getIdentifier() == UserHandle.USER_NULL) { Loading src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java +2 −5 Original line number Diff line number Diff line Loading @@ -559,15 +559,13 @@ public class SubscriptionManagerService extends ISub.Stub { * @param userHandle the userHandle associated with the subscription * Pass {@code null} user handle to clear the association * @param subId the unique SubscriptionInfo index in database * @param callingPackage the package making the IPC * @return the number of records updated. * * @throws SecurityException if doesn't have required permission. * @throws IllegalArgumentException if subId is invalid. */ @Override public int setUserHandle(@Nullable UserHandle userHandle, int subId, @NonNull String callingPackage) { public int setSubscriptionUserHandle(@Nullable UserHandle userHandle, int subId) { return 0; } Loading @@ -575,7 +573,6 @@ public class SubscriptionManagerService extends ISub.Stub { * Get UserHandle of this subscription. * * @param subId the unique SubscriptionInfo index in database * @param callingPackage the package making the IPC * @return userHandle associated with this subscription * or {@code null} if subscription is not associated with any user. * Loading @@ -583,7 +580,7 @@ public class SubscriptionManagerService extends ISub.Stub { * @throws IllegalArgumentException if subId is invalid. */ @Override public UserHandle getUserHandle(int subId, @NonNull String callingPackage) { public UserHandle getSubscriptionUserHandle(int subId) { return null; } Loading tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java +19 −18 Original line number Diff line number Diff line Loading @@ -2111,7 +2111,7 @@ public class SubscriptionControllerTest extends TelephonyTest { } @Test public void setUserHandle_withoutPermission() { public void setSubscriptionUserHandle_withoutPermission() { testInsertSim(); /* Get SUB ID */ int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); Loading @@ -2120,48 +2120,49 @@ public class SubscriptionControllerTest extends TelephonyTest { mContextFixture.removeCallingOrSelfPermission(ContextFixture.PERMISSION_ENABLE_ALL); assertThrows(SecurityException.class, () -> mSubscriptionControllerUT.setUserHandle(UserHandle.of(UserHandle.USER_SYSTEM), subId, mCallingPackage)); () -> mSubscriptionControllerUT.setSubscriptionUserHandle( UserHandle.of(UserHandle.USER_SYSTEM), subId)); } @Test public void setGetUserHandle_userHandleNull() { public void setGetSubscriptionUserHandle_userHandleNull() { testInsertSim(); /* Get SUB ID */ int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIds != null && subIds.length != 0); final int subId = subIds[0]; mSubscriptionControllerUT.setUserHandle(null, subId, mCallingPackage); mSubscriptionControllerUT.setSubscriptionUserHandle(null, subId); assertThat(mSubscriptionControllerUT.getUserHandle(subId, mCallingPackage)) assertThat(mSubscriptionControllerUT.getSubscriptionUserHandle(subId)) .isEqualTo(null); } @Test public void setUserHandle_invalidSubId() { public void setSubscriptionUserHandle_invalidSubId() { assertThrows(IllegalArgumentException.class, () -> mSubscriptionControllerUT.setUserHandle(UserHandle.of(UserHandle.USER_SYSTEM), SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, mCallingPackage)); () -> mSubscriptionControllerUT.setSubscriptionUserHandle( UserHandle.of(UserHandle.USER_SYSTEM), SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)); } @Test public void setGetUserHandle_withValidUserHandleAndSubId() { public void setGetSubscriptionUserHandle_withValidUserHandleAndSubId() { testInsertSim(); /* Get SUB ID */ int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIds != null && subIds.length != 0); final int subId = subIds[0]; mSubscriptionControllerUT.setUserHandle(UserHandle.of(UserHandle.USER_SYSTEM), subId, mCallingPackage); mSubscriptionControllerUT.setSubscriptionUserHandle( UserHandle.of(UserHandle.USER_SYSTEM), subId); assertThat(mSubscriptionControllerUT.getUserHandle(subId, mCallingPackage)) assertThat(mSubscriptionControllerUT.getSubscriptionUserHandle(subId)) .isEqualTo(UserHandle.of(UserHandle.USER_SYSTEM)); } @Test public void getUserHandle_withoutPermission() { public void getSubscriptionUserHandle_withoutPermission() { testInsertSim(); /* Get SUB ID */ int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); Loading @@ -2170,13 +2171,13 @@ public class SubscriptionControllerTest extends TelephonyTest { mContextFixture.removeCallingOrSelfPermission(ContextFixture.PERMISSION_ENABLE_ALL); assertThrows(SecurityException.class, () -> mSubscriptionControllerUT.getUserHandle(subId, mCallingPackage)); () -> mSubscriptionControllerUT.getSubscriptionUserHandle(subId)); } @Test public void getUserHandle_invalidSubId() { public void getSubscriptionUserHandle_invalidSubId() { assertThrows(IllegalArgumentException.class, () -> mSubscriptionControllerUT.getUserHandle( SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, mCallingPackage)); () -> mSubscriptionControllerUT.getSubscriptionUserHandle( SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)); } } No newline at end of file Loading
src/java/com/android/internal/telephony/SubscriptionController.java +8 −9 Original line number Diff line number Diff line Loading @@ -4831,16 +4831,14 @@ public class SubscriptionController extends ISub.Stub { * @param userHandle the userHandle associated with the subscription * Pass {@code null} user handle to clear the association * @param subId the unique SubscriptionInfo index in database * @param callingPackage the package making the IPC * @return the number of records updated. * * @throws SecurityException if doesn't have required permission. * @throws IllegalArgumentException if subId is invalid. */ @Override public int setUserHandle(@Nullable UserHandle userHandle, int subId, @NonNull String callingPackage) { enforceManageSubscriptionUserAssociation("setUserHandle"); public int setSubscriptionUserHandle(@Nullable UserHandle userHandle, int subId) { enforceManageSubscriptionUserAssociation("setSubscriptionUserHandle"); if (userHandle == null) { userHandle = UserHandle.of(UserHandle.USER_NULL); Loading @@ -4854,7 +4852,8 @@ public class SubscriptionController extends ISub.Stub { if (ret != 0) { notifySubscriptionInfoChanged(); } else { throw new IllegalArgumentException("[setUserHandle]: Invalid subId: " + subId); throw new IllegalArgumentException("[setSubscriptionUserHandle]: Invalid subId: " + subId); } return ret; } finally { Loading @@ -4866,7 +4865,6 @@ public class SubscriptionController extends ISub.Stub { * Get UserHandle of this subscription. * * @param subId the unique SubscriptionInfo index in database * @param callingPackage the package making the IPC * @return userHandle associated with this subscription * or {@code null} if subscription is not associated with any user. * Loading @@ -4874,14 +4872,15 @@ public class SubscriptionController extends ISub.Stub { * @throws IllegalArgumentException if subId is invalid. */ @Override public UserHandle getUserHandle(int subId, @NonNull String callingPackage) { enforceManageSubscriptionUserAssociation("getUserHandle"); public UserHandle getSubscriptionUserHandle(int subId) { enforceManageSubscriptionUserAssociation("getSubscriptionUserHandle"); long token = Binder.clearCallingIdentity(); try { String userHandleStr = getSubscriptionProperty(subId, SubscriptionManager.USER_HANDLE); if (userHandleStr == null) { throw new IllegalArgumentException("[getUserHandle]: Invalid subId: " + subId); throw new IllegalArgumentException("[getSubscriptionUserHandle]: Invalid subId: " + subId); } UserHandle userHandle = UserHandle.of(Integer.parseInt(userHandleStr)); if (userHandle.getIdentifier() == UserHandle.USER_NULL) { Loading
src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java +2 −5 Original line number Diff line number Diff line Loading @@ -559,15 +559,13 @@ public class SubscriptionManagerService extends ISub.Stub { * @param userHandle the userHandle associated with the subscription * Pass {@code null} user handle to clear the association * @param subId the unique SubscriptionInfo index in database * @param callingPackage the package making the IPC * @return the number of records updated. * * @throws SecurityException if doesn't have required permission. * @throws IllegalArgumentException if subId is invalid. */ @Override public int setUserHandle(@Nullable UserHandle userHandle, int subId, @NonNull String callingPackage) { public int setSubscriptionUserHandle(@Nullable UserHandle userHandle, int subId) { return 0; } Loading @@ -575,7 +573,6 @@ public class SubscriptionManagerService extends ISub.Stub { * Get UserHandle of this subscription. * * @param subId the unique SubscriptionInfo index in database * @param callingPackage the package making the IPC * @return userHandle associated with this subscription * or {@code null} if subscription is not associated with any user. * Loading @@ -583,7 +580,7 @@ public class SubscriptionManagerService extends ISub.Stub { * @throws IllegalArgumentException if subId is invalid. */ @Override public UserHandle getUserHandle(int subId, @NonNull String callingPackage) { public UserHandle getSubscriptionUserHandle(int subId) { return null; } Loading
tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java +19 −18 Original line number Diff line number Diff line Loading @@ -2111,7 +2111,7 @@ public class SubscriptionControllerTest extends TelephonyTest { } @Test public void setUserHandle_withoutPermission() { public void setSubscriptionUserHandle_withoutPermission() { testInsertSim(); /* Get SUB ID */ int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); Loading @@ -2120,48 +2120,49 @@ public class SubscriptionControllerTest extends TelephonyTest { mContextFixture.removeCallingOrSelfPermission(ContextFixture.PERMISSION_ENABLE_ALL); assertThrows(SecurityException.class, () -> mSubscriptionControllerUT.setUserHandle(UserHandle.of(UserHandle.USER_SYSTEM), subId, mCallingPackage)); () -> mSubscriptionControllerUT.setSubscriptionUserHandle( UserHandle.of(UserHandle.USER_SYSTEM), subId)); } @Test public void setGetUserHandle_userHandleNull() { public void setGetSubscriptionUserHandle_userHandleNull() { testInsertSim(); /* Get SUB ID */ int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIds != null && subIds.length != 0); final int subId = subIds[0]; mSubscriptionControllerUT.setUserHandle(null, subId, mCallingPackage); mSubscriptionControllerUT.setSubscriptionUserHandle(null, subId); assertThat(mSubscriptionControllerUT.getUserHandle(subId, mCallingPackage)) assertThat(mSubscriptionControllerUT.getSubscriptionUserHandle(subId)) .isEqualTo(null); } @Test public void setUserHandle_invalidSubId() { public void setSubscriptionUserHandle_invalidSubId() { assertThrows(IllegalArgumentException.class, () -> mSubscriptionControllerUT.setUserHandle(UserHandle.of(UserHandle.USER_SYSTEM), SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, mCallingPackage)); () -> mSubscriptionControllerUT.setSubscriptionUserHandle( UserHandle.of(UserHandle.USER_SYSTEM), SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)); } @Test public void setGetUserHandle_withValidUserHandleAndSubId() { public void setGetSubscriptionUserHandle_withValidUserHandleAndSubId() { testInsertSim(); /* Get SUB ID */ int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIds != null && subIds.length != 0); final int subId = subIds[0]; mSubscriptionControllerUT.setUserHandle(UserHandle.of(UserHandle.USER_SYSTEM), subId, mCallingPackage); mSubscriptionControllerUT.setSubscriptionUserHandle( UserHandle.of(UserHandle.USER_SYSTEM), subId); assertThat(mSubscriptionControllerUT.getUserHandle(subId, mCallingPackage)) assertThat(mSubscriptionControllerUT.getSubscriptionUserHandle(subId)) .isEqualTo(UserHandle.of(UserHandle.USER_SYSTEM)); } @Test public void getUserHandle_withoutPermission() { public void getSubscriptionUserHandle_withoutPermission() { testInsertSim(); /* Get SUB ID */ int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); Loading @@ -2170,13 +2171,13 @@ public class SubscriptionControllerTest extends TelephonyTest { mContextFixture.removeCallingOrSelfPermission(ContextFixture.PERMISSION_ENABLE_ALL); assertThrows(SecurityException.class, () -> mSubscriptionControllerUT.getUserHandle(subId, mCallingPackage)); () -> mSubscriptionControllerUT.getSubscriptionUserHandle(subId)); } @Test public void getUserHandle_invalidSubId() { public void getSubscriptionUserHandle_invalidSubId() { assertThrows(IllegalArgumentException.class, () -> mSubscriptionControllerUT.getUserHandle( SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, mCallingPackage)); () -> mSubscriptionControllerUT.getSubscriptionUserHandle( SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)); } } No newline at end of file