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

Commit d0c6c899 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Correctly support restoring SIM specific settings" into main am: 98811d90

parents 5e4a01c4 98811d90
Loading
Loading
Loading
Loading
+20 −37
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ public class SubscriptionManager {
    /**
     * Key to the backup & restore data byte array in the Bundle that is returned by {@link
     * #getAllSimSpecificSettingsForBackup()} or to be pass in to {@link
     * #restoreAllSimSpecificSettings()}.
     * #restoreAllSimSpecificSettingsFromBackup(byte[])}.
     *
     * @hide
     */
@@ -4026,40 +4026,17 @@ public class SubscriptionManager {
        return bundle.getByteArray(SubscriptionManager.KEY_SIM_SPECIFIC_SETTINGS_DATA);
    }

    /**
     * Called to attempt to restore the backed up sim-specific configs to device for specific sim.
     * This will try to restore the data that was stored internally when {@link
     * #restoreAllSimSpecificSettingsFromBackup(byte[] data)} was called during setup wizard.
     * End result is SimInfoDB is modified to match any backed up configs for the requested
     * inserted sim.
     *
     * <p>
     * The {@link Uri} {@link #SIM_INFO_BACKUP_AND_RESTORE_CONTENT_URI} is notified if any SimInfoDB
     * entry is updated as the result of this method call.
     *
     * @param iccId of the sim that a restore is requested for.
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
    public void restoreSimSpecificSettingsForIccIdFromBackup(@NonNull String iccId) {
        mContext.getContentResolver().call(
                SIM_INFO_BACKUP_AND_RESTORE_CONTENT_URI,
                RESTORE_SIM_SPECIFIC_SETTINGS_METHOD_NAME,
                iccId, null);
    }

    /**
     * Called during setup wizard restore flow to attempt to restore the backed up sim-specific
     * configs to device for all existing SIMs in SimInfoDB. Internally, it will store the backup
     * data in an internal file. This file will persist on device for device's lifetime and will be
     * used later on when a SIM is inserted to restore that specific SIM's settings by calling
     * {@link #restoreSimSpecificSettingsForIccIdFromBackup(String iccId)}. End result is
     * SimInfoDB is modified to match any backed up configs for the appropriate inserted SIMs.
     * configs to device for all existing SIMs in the subscription database {@link SimInfo}.
     * Internally, it will store the backup data in an internal file. This file will persist on
     * device for device's lifetime and will be used later on when a SIM is inserted to restore that
     * specific SIM's settings. End result is subscription database is modified to match any backed
     * up configs for the appropriate inserted SIMs.
     *
     * <p>
     * The {@link Uri} {@link #SIM_INFO_BACKUP_AND_RESTORE_CONTENT_URI} is notified if any SimInfoDB
     * entry is updated as the result of this method call.
     * The {@link Uri} {@link #SIM_INFO_BACKUP_AND_RESTORE_CONTENT_URI} is notified if any
     * {@link SimInfo} entry is updated as the result of this method call.
     *
     * @param data with the sim specific configs to be backed up.
     *
@@ -4068,12 +4045,18 @@ public class SubscriptionManager {
    @SystemApi
    @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
    public void restoreAllSimSpecificSettingsFromBackup(@NonNull byte[] data) {
        Bundle bundle = new Bundle();
        bundle.putByteArray(KEY_SIM_SPECIFIC_SETTINGS_DATA, data);
        mContext.getContentResolver().call(
                SIM_INFO_BACKUP_AND_RESTORE_CONTENT_URI,
                RESTORE_SIM_SPECIFIC_SETTINGS_METHOD_NAME,
                null, bundle);
        try {
            ISub iSub = TelephonyManager.getSubscriptionService();
            if (iSub != null) {
                iSub.restoreAllSimSpecificSettingsFromBackup(data);
            } else {
                throw new IllegalStateException("subscription service unavailable.");
            }
        } catch (RemoteException ex) {
            if (!isSystemProcess()) {
                ex.rethrowAsRuntimeException();
            }
        }
    }

    /**
+16 −0
Original line number Diff line number Diff line
@@ -363,4 +363,20 @@ interface ISub {
        */
       //TODO: Removed before U AOSP public release.
       boolean isSubscriptionManagerServiceEnabled();

      /**
       * Called during setup wizard restore flow to attempt to restore the backed up sim-specific
       * configs to device for all existing SIMs in the subscription database
       * {@link Telephony.SimInfo}. Internally, it will store the backup data in an internal file.
       * This file will persist on device for device's lifetime and will be used later on when a SIM
       * is inserted to restore that specific SIM's settings. End result is subscription database is
       * modified to match any backed up configs for the appropriate inserted SIMs.
       *
       * <p>
       * The {@link Uri} {@link #SIM_INFO_BACKUP_AND_RESTORE_CONTENT_URI} is notified if any
       * {@link Telephony.SimInfo} entry is updated as the result of this method call.
       *
       * @param data with the sim specific configs to be backed up.
       */
       void restoreAllSimSpecificSettingsFromBackup(in byte[] data);
}