Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +16 −1 Original line number Diff line number Diff line Loading @@ -3935,7 +3935,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (policy.mPasswordOwner == oldAdminUid) { policy.mPasswordOwner = adminToTransfer.getUid(); } transferSubscriptionOwnership(outgoingReceiver, incomingReceiver); saveSettingsLocked(userHandle); sendAdminCommandLocked(adminToTransfer, DeviceAdminReceiver.ACTION_DEVICE_ADMIN_ENABLED, null, null); Loading Loading @@ -19471,6 +19471,21 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { .write(); } private void transferSubscriptionOwnership(ComponentName admin, ComponentName target) { if (Flags.esimManagementEnabled()) { SubscriptionManager subscriptionManager = mContext.getSystemService( SubscriptionManager.class); for (int subId : getSubscriptionIdsInternal(admin.getPackageName()).toArray()) { try { subscriptionManager.setGroupOwner(subId, target.getPackageName()); } catch (Exception e) { // Shouldn't happen. Slogf.e(LOG_TAG, e, "Error setting group owner for subId: " + subId); } } } } private void prepareTransfer(ComponentName admin, ComponentName target, PersistableBundle bundle, int callingUserId, String adminType) { saveTransferOwnershipBundleLocked(bundle, callingUserId); telephony/java/android/telephony/SubscriptionManager.java +25 −0 Original line number Diff line number Diff line Loading @@ -4613,6 +4613,31 @@ public class SubscriptionManager { } } /** * Set owner for this subscription. * * @param subscriptionId the subId of the subscription. * @param groupOwner The group owner to assign to the subscription * * @throws SecurityException if caller is not authorized. * * @hide */ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setGroupOwner(int subscriptionId, @NonNull String groupOwner) { try { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { iSub.setGroupOwner(subscriptionId, groupOwner); } else { throw new IllegalStateException("[setGroupOwner]: " + "subscription service unavailable"); } } catch (RemoteException ex) { ex.rethrowAsRuntimeException(); } } /** * Set userHandle for a subscription. * Loading telephony/java/com/android/internal/telephony/ISub.aidl +12 −0 Original line number Diff line number Diff line Loading @@ -309,6 +309,18 @@ interface ISub { */ int setUsageSetting(int usageSetting, int subId, String callingPackage); /** * Set owner for this subscription. * * @param subId the unique SubscriptionInfo index in database * @param groupOwner The group owner to assign to the subscription * * @throws SecurityException if caller is not authorized. * * @hide */ void setGroupOwner(int subId, String groupOwner); /** * Set userHandle for this subscription. * Loading Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +16 −1 Original line number Diff line number Diff line Loading @@ -3935,7 +3935,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (policy.mPasswordOwner == oldAdminUid) { policy.mPasswordOwner = adminToTransfer.getUid(); } transferSubscriptionOwnership(outgoingReceiver, incomingReceiver); saveSettingsLocked(userHandle); sendAdminCommandLocked(adminToTransfer, DeviceAdminReceiver.ACTION_DEVICE_ADMIN_ENABLED, null, null); Loading Loading @@ -19471,6 +19471,21 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { .write(); } private void transferSubscriptionOwnership(ComponentName admin, ComponentName target) { if (Flags.esimManagementEnabled()) { SubscriptionManager subscriptionManager = mContext.getSystemService( SubscriptionManager.class); for (int subId : getSubscriptionIdsInternal(admin.getPackageName()).toArray()) { try { subscriptionManager.setGroupOwner(subId, target.getPackageName()); } catch (Exception e) { // Shouldn't happen. Slogf.e(LOG_TAG, e, "Error setting group owner for subId: " + subId); } } } } private void prepareTransfer(ComponentName admin, ComponentName target, PersistableBundle bundle, int callingUserId, String adminType) { saveTransferOwnershipBundleLocked(bundle, callingUserId);
telephony/java/android/telephony/SubscriptionManager.java +25 −0 Original line number Diff line number Diff line Loading @@ -4613,6 +4613,31 @@ public class SubscriptionManager { } } /** * Set owner for this subscription. * * @param subscriptionId the subId of the subscription. * @param groupOwner The group owner to assign to the subscription * * @throws SecurityException if caller is not authorized. * * @hide */ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setGroupOwner(int subscriptionId, @NonNull String groupOwner) { try { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { iSub.setGroupOwner(subscriptionId, groupOwner); } else { throw new IllegalStateException("[setGroupOwner]: " + "subscription service unavailable"); } } catch (RemoteException ex) { ex.rethrowAsRuntimeException(); } } /** * Set userHandle for a subscription. * Loading
telephony/java/com/android/internal/telephony/ISub.aidl +12 −0 Original line number Diff line number Diff line Loading @@ -309,6 +309,18 @@ interface ISub { */ int setUsageSetting(int usageSetting, int subId, String callingPackage); /** * Set owner for this subscription. * * @param subId the unique SubscriptionInfo index in database * @param groupOwner The group owner to assign to the subscription * * @throws SecurityException if caller is not authorized. * * @hide */ void setGroupOwner(int subId, String groupOwner); /** * Set userHandle for this subscription. * Loading