diff --git a/api/current.txt b/api/current.txt index 8b1cf2023a9f6..10b36288f1eb0 100644 --- a/api/current.txt +++ b/api/current.txt @@ -39753,6 +39753,7 @@ package android.telephony { public class CarrierConfigManager { method public android.os.PersistableBundle getConfig(); method public android.os.PersistableBundle getConfigForSubId(int); + method public static boolean isConfigForIdentifiedCarrier(android.os.PersistableBundle); method public void notifyConfigChangedForSubId(int); field public static final java.lang.String ACTION_CARRIER_CONFIG_CHANGED = "android.telephony.action.CARRIER_CONFIG_CHANGED"; field public static final int DATA_CYCLE_THRESHOLD_DISABLED = -2; // 0xfffffffe diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index d80ad3654389f..514222dcdbaba 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -1712,6 +1712,13 @@ public class CarrierConfigManager { public static final String KEY_SPN_DISPLAY_RULE_USE_ROAMING_FROM_SERVICE_STATE_BOOL = "spn_display_rule_use_roaming_from_service_state_bool"; + /** + * Determines whether any carrier has been identified and its specific config has been applied, + * default to false. + * @hide + */ + public static final String KEY_CARRIER_CONFIG_APPLIED_BOOL = "carrier_config_applied_bool"; + /** The default value for every variable. */ private final static PersistableBundle sDefaults; @@ -1995,6 +2002,7 @@ public class CarrierConfigManager { sDefaults.putBoolean(KEY_IDENTIFY_HIGH_DEFINITION_CALLS_IN_CALL_LOG_BOOL, false); sDefaults.putBoolean(KEY_SPN_DISPLAY_RULE_USE_ROAMING_FROM_SERVICE_STATE_BOOL, false); sDefaults.putBoolean(KEY_ALWAYS_SHOW_DATA_RAT_ICON_BOOL, false); + sDefaults.putBoolean(KEY_CARRIER_CONFIG_APPLIED_BOOL, false); } /** @@ -2039,6 +2047,33 @@ public class CarrierConfigManager { return getConfigForSubId(SubscriptionManager.getDefaultSubscriptionId()); } + /** + * Determines whether a configuration {@link PersistableBundle} obtained from + * {@link #getConfig()} or {@link #getConfigForSubId(int)} corresponds to an identified carrier. + *
+ * When an app receives the {@link CarrierConfigManager#ACTION_CARRIER_CONFIG_CHANGED} + * broadcast which informs it that the carrier configuration has changed, it is possible + * that another reload of the carrier configuration has begun since the intent was sent. + * In this case, the carrier configuration the app fetches (e.g. via {@link #getConfig()}) + * may not represent the configuration for the current carrier. It should be noted that it + * does not necessarily mean the configuration belongs to current carrier when this function + * return true because it may belong to another previous identified carrier. Users should + * always call {@link #getConfig()} or {@link #getConfigForSubId(int)} after receiving the + * broadcast {@link #ACTION_CARRIER_CONFIG_CHANGED}. + *
+ *+ * After using {@link #getConfig()} or {@link #getConfigForSubId(int)} an app should always + * use this method to confirm whether any carrier specific configuration has been applied. + *
+ * + * @param bundle the configuration bundle to be checked. + * @return boolean true if any carrier specific configuration bundle has been applied, false + * otherwise or the bundle is null. + */ + public static boolean isConfigForIdentifiedCarrier(PersistableBundle bundle) { + return bundle != null && bundle.getBoolean(KEY_CARRIER_CONFIG_APPLIED_BOOL); + } + /** * Calling this method triggers telephony services to fetch the current carrier configuration. *