Skip to content
Snippets Groups Projects
Commit 17c03e01 authored by Jack Yu's avatar Jack Yu
Browse files

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
parent eca99eca
No related branches found
No related tags found
No related merge requests found
...@@ -174,7 +174,7 @@ public class SubscriptionManager { ...@@ -174,7 +174,7 @@ public class SubscriptionManager {
/** /**
* Key to the backup & restore data byte array in the Bundle that is returned by {@link * Key to the backup & restore data byte array in the Bundle that is returned by {@link
* #getAllSimSpecificSettingsForBackup()} or to be pass in to {@link * #getAllSimSpecificSettingsForBackup()} or to be pass in to {@link
* #restoreAllSimSpecificSettings()}. * #restoreAllSimSpecificSettingsFromBackup(byte[])}.
* *
* @hide * @hide
*/ */
...@@ -4026,40 +4026,17 @@ public class SubscriptionManager { ...@@ -4026,40 +4026,17 @@ public class SubscriptionManager {
return bundle.getByteArray(SubscriptionManager.KEY_SIM_SPECIFIC_SETTINGS_DATA); 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 * 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 * configs to device for all existing SIMs in the subscription database {@link SimInfo}.
* data in an internal file. This file will persist on device for device's lifetime and will be * Internally, it will store the backup data in an internal file. This file will persist on
* used later on when a SIM is inserted to restore that specific SIM's settings by calling * device for device's lifetime and will be used later on when a SIM is inserted to restore that
* {@link #restoreSimSpecificSettingsForIccIdFromBackup(String iccId)}. End result is * specific SIM's settings. End result is subscription database is modified to match any backed
* SimInfoDB is modified to match any backed up configs for the appropriate inserted SIMs. * up configs for the appropriate inserted SIMs.
* *
* <p> * <p>
* The {@link Uri} {@link #SIM_INFO_BACKUP_AND_RESTORE_CONTENT_URI} is notified if any SimInfoDB * The {@link Uri} {@link #SIM_INFO_BACKUP_AND_RESTORE_CONTENT_URI} is notified if any
* entry is updated as the result of this method call. * {@link SimInfo} entry is updated as the result of this method call.
* *
* @param data with the sim specific configs to be backed up. * @param data with the sim specific configs to be backed up.
* *
...@@ -4068,12 +4045,18 @@ public class SubscriptionManager { ...@@ -4068,12 +4045,18 @@ public class SubscriptionManager {
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
public void restoreAllSimSpecificSettingsFromBackup(@NonNull byte[] data) { public void restoreAllSimSpecificSettingsFromBackup(@NonNull byte[] data) {
Bundle bundle = new Bundle(); try {
bundle.putByteArray(KEY_SIM_SPECIFIC_SETTINGS_DATA, data); ISub iSub = TelephonyManager.getSubscriptionService();
mContext.getContentResolver().call( if (iSub != null) {
SIM_INFO_BACKUP_AND_RESTORE_CONTENT_URI, iSub.restoreAllSimSpecificSettingsFromBackup(data);
RESTORE_SIM_SPECIFIC_SETTINGS_METHOD_NAME, } else {
null, bundle); throw new IllegalStateException("subscription service unavailable.");
}
} catch (RemoteException ex) {
if (!isSystemProcess()) {
ex.rethrowAsRuntimeException();
}
}
} }
/** /**
......
...@@ -363,4 +363,20 @@ interface ISub { ...@@ -363,4 +363,20 @@ interface ISub {
*/ */
//TODO: Removed before U AOSP public release. //TODO: Removed before U AOSP public release.
boolean isSubscriptionManagerServiceEnabled(); 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);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment