Merge "CarrierConfigManager: Adds API for persistent override of values"

This commit is contained in:
Jack Yu
2019-12-10 17:35:20 +00:00
committed by Gerrit Code Review
2 changed files with 30 additions and 2 deletions

View File

@@ -3810,6 +3810,34 @@ public class CarrierConfigManager {
@SystemApi
@TestApi
public void overrideConfig(int subscriptionId, @Nullable PersistableBundle overrideValues) {
overrideConfig(subscriptionId, overrideValues, false);
}
/**
* Overrides the carrier config of the provided subscription ID with the provided values.
*
* Any further queries to carrier config from any process will return the overridden values
* after this method returns. The overrides are effective until the user passes in {@code null}
* for {@code overrideValues}. This removes all previous overrides and sets the carrier config
* back to production values.
*
* The overrides is stored persistently and will survive a reboot if {@code persistent} is true.
*
* May throw an {@link IllegalArgumentException} if {@code overrideValues} contains invalid
* values for the specified config keys.
*
* NOTE: This API is meant for testing purposes only.
*
* @param subscriptionId The subscription ID for which the override should be done.
* @param overrideValues Key-value pairs of the values that are to be overridden. If set to
* {@code null}, this will remove all previous overrides and set the
* carrier configuration back to production values.
* @param persistent Determines whether the override should be persistent.
* @hide
*/
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
public void overrideConfig(int subscriptionId, @Nullable PersistableBundle overrideValues,
boolean persistent) {
try {
ICarrierConfigLoader loader = getICarrierConfigLoader();
if (loader == null) {
@@ -3817,7 +3845,7 @@ public class CarrierConfigManager {
+ " ICarrierConfigLoader is null");
return;
}
loader.overrideConfig(subscriptionId, overrideValues);
loader.overrideConfig(subscriptionId, overrideValues, persistent);
} catch (RemoteException ex) {
Rlog.e(TAG, "Error setting config for subId " + subscriptionId + ": "
+ ex.toString());

View File

@@ -26,7 +26,7 @@ interface ICarrierConfigLoader {
@UnsupportedAppUsage
PersistableBundle getConfigForSubId(int subId, String callingPackage);
void overrideConfig(int subId, in PersistableBundle overrides);
void overrideConfig(int subId, in PersistableBundle overrides, boolean persistent);
void notifyConfigChangedForSubId(int subId);