From 17c03e012a47259dd6f2b29ee7ada5b2f10d2c15 Mon Sep 17 00:00:00 2001 From: Jack Yu Date: Sun, 12 Feb 2023 23:35:26 -0800 Subject: Correctly support restoring SIM specific settings After restoring the data, we need to update the subscription database cache. Fix: 269062965 Test: atest android.telephony.cts.SubscriptionManagerTest#testRestoreAllSimSpecificSettingsFromBackup Test: Boot up + Basic phone functionality tests Merged-In: I2f8cb6418ee661a3cd8c02e3db6733cb12817d01 Change-Id: I2f8cb6418ee661a3cd8c02e3db6733cb12817d01 --- .../android/telephony/SubscriptionManager.java | 57 ++++++++-------------- .../java/com/android/internal/telephony/ISub.aidl | 16 ++++++ 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 45c092e1fb0d..81eb8365d7e0 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -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. - * - *

- * 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. * *

- * 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(); + } + } } /** diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl index defa046da503..af4edc443151 100644 --- a/telephony/java/com/android/internal/telephony/ISub.aidl +++ b/telephony/java/com/android/internal/telephony/ISub.aidl @@ -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. + * + *

+ * 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); } -- cgit v1.2.3-59-g8ed1b