Merge "Add test API to override carrier config"

This commit is contained in:
Hall Liu
2018-10-24 00:00:22 +00:00
committed by Gerrit Code Review
4 changed files with 46 additions and 3 deletions

View File

@@ -5086,6 +5086,7 @@ package android.telephony {
public class CarrierConfigManager {
method public static android.os.PersistableBundle getDefaultConfig();
method public void overrideConfig(int, android.os.PersistableBundle);
method public void updateConfigForPhoneId(int, java.lang.String);
field public static final java.lang.String KEY_CONFIG_PLANS_PACKAGE_OVERRIDE_STRING = "config_plans_package_override_string";
}

View File

@@ -962,6 +962,10 @@ package android.telecom {
package android.telephony {
public class CarrierConfigManager {
method public void overrideConfig(int, android.os.PersistableBundle);
}
public class MbmsDownloadSession implements java.lang.AutoCloseable {
field public static final java.lang.String MBMS_DOWNLOAD_SERVICE_OVERRIDE_METADATA = "mbms-download-service-override";
}

View File

@@ -16,12 +16,14 @@
package android.telephony;
import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.os.PersistableBundle;
@@ -1222,8 +1224,8 @@ public class CarrierConfigManager {
public static final String KEY_SHOW_PRECISE_FAILED_CAUSE_BOOL =
"show_precise_failed_cause_bool";
// These variables are used by the MMS service and exposed through another API, {@link
// SmsManager}. The variable names and string values are copied from there.
// These variables are used by the MMS service and exposed through another API,
// SmsManager. The variable names and string values are copied from there.
public static final String KEY_MMS_ALIAS_ENABLED_BOOL = "aliasEnabled";
public static final String KEY_MMS_ALLOW_ATTACH_AUDIO_BOOL = "allowAttachAudio";
public static final String KEY_MMS_APPEND_TRANSACTION_ID_BOOL = "enabledTransID";
@@ -1271,7 +1273,7 @@ public class CarrierConfigManager {
* network as part of the Setup Wizard flow.
* @hide
*/
public static final String KEY_CARRIER_SETUP_APP_STRING = "carrier_setup_app_string";
public static final String KEY_CARRIER_SETUP_APP_STRING = "carrier_setup_app_string";
/**
* Defines carrier-specific actions which act upon
@@ -2611,6 +2613,40 @@ public class CarrierConfigManager {
return null;
}
/**
* 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 overriden values after this method returns. The overrides are effective for the lifetime
* of the phone process.
*
* May throw an {@link IllegalArgumentException} if {@code overrideValues} contains invalid
* values for the specified config keys.
*
* @param subscriptionId The subscription ID for which the override should be done.
* @param overrideValues Key-value pairs of the values that are to be overriden. If null,
* all previous overrides will be disabled and the config reset back to
* its initial state.
* @hide
*/
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
@SystemApi
@TestApi
public void overrideConfig(int subscriptionId, @Nullable PersistableBundle overrideValues) {
try {
ICarrierConfigLoader loader = getICarrierConfigLoader();
if (loader == null) {
Rlog.w(TAG, "Error setting config for subId " + subscriptionId
+ " ICarrierConfigLoader is null");
return;
}
loader.overrideConfig(subscriptionId, overrideValues);
} catch (RemoteException ex) {
Rlog.e(TAG, "Error setting config for subId " + subscriptionId + ": "
+ ex.toString());
}
}
/**
* Gets the configuration values for the default subscription. After using this method to get
* the configuration bundle, {@link #isConfigForIdentifiedCarrier(PersistableBundle)} should be

View File

@@ -25,6 +25,8 @@ interface ICarrierConfigLoader {
PersistableBundle getConfigForSubId(int subId, String callingPackage);
void overrideConfig(int subId, in PersistableBundle overrides);
void notifyConfigChangedForSubId(int subId);
void updateConfigForPhoneId(int phoneId, String simState);