失效链接处理 |
Android CarrierConfig介绍 PDF 下载
本站整理下载:
提取码:6afv
相关截图:
主要内容:
通常我们做公开市场的项目,终端用户买了手机后可能插入任何运营商的卡,而不同的运营商对手机上一些默认配置 的要求不一样,比如短信/彩信网络设置、通话设置、漫游非漫游设置、IMS支持情况设置等等。AOSP提供了一种机制, 同一版本软件,针对不同运营商可以配置不同的参数(以mcc/mnc区分),从而实现这些需求的客制化。 CarrierConfigManager.java里面可以查看可配置的功能非常多,例如: //SMS text length threshold (in bytes) to turn into MMS public static final String KEY_MMS_SMS_TO_MMS_TEXT_LENGTH_THRESHOLD_INT = "smsToMmsTextLengthThreshold"; /*** Boolean indicating if the "Call forwarding" item is visible in the Call Settings menu. * true means visible. false means gone. * @hide */ public static final String KEY_CALL_FORWARDING_VISIBILITY_BOOL = "call_forwarding_visibility_bool"; /** * List of operators considered non-roaming which won't show roaming icon. * <p> * Can use mcc or mcc+mnc as item. For example, 302 or 21407. * If operators, 21404 and 21407, make roaming agreements, users of 21404 should not see * the roaming icon as using 21407 network. * @hide */ public static final String KEY_NON_ROAMING_OPERATOR_STRING_ARRAY = "non_roaming_operator_string_array"; /*** Default value for {@link Settings.Global#DATA_ROAMING} * @hide */ public static final String KEY_CARRIER_DEFAULT_DATA_ROAMING_ENABLED_BOOL = "carrier_default_data_roaming_enabled_bool"; /*** Flag specifying whether VoLTE should be available for carrier, independent of carrier * provisioning. If false: hard disabled. If true: then depends on carrier provisioning, * availability, etc. */ public static final String KEY_CARRIER_VOLTE_AVAILABLE_BOOL = "carrier_volte_available_bool"; /*** Flag specifying whether video telephony is available for carrier. If false: hard disabled. * If true: then depends on carrier provisioning, availability, etc. */ public static final String KEY_CARRIER_VT_AVAILABLE_BOOL = "carrier_vt_available_bool"; /*** Flag specifying whether WFC over IMS should be available for carrier: independent of * carrier provisioning. If false: hard disabled. If true: then depends on carrier * provisioning, availability etc. */ public static final String KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL = "carrier_wfc_ims_available_bool";
二. CarrierConfig的获取方式 二以平台通过Carrier Config判断是否支持VoLTE流程为例: //通过ServiceManager访问carrier_config mConfigManager = (CarrierConfigManager) context.getSystemService( Context.CARRIER_CONFIG_SERVICE); /*** Returns a platform configuration for VoLTE which may override the user setting on a per Slot * basis. */ public boolean isVolteEnabledByPlatform() { // We first read the per slot value. If doesn't exist, we read the general value. If still // doesn't exist, we use the hardcoded default value. if (SystemProperties.getInt( PROPERTY_DBG_VOLTE_AVAIL_OVERRIDE + Integer.toString(mPhoneId), SYSTEM_PROPERTY_NOT_SET) == 1 || SystemProperties.getInt(PROPERTY_DBG_VOLTE_AVAIL_OVERRIDE, SYSTEM_PROPERTY_NOT_SET) == 1) { return true; }return mContext.getResources().getBoolean( com.android.internal.R.bool.config_device_volte_available) && getBooleanCarrierConfig(CarrierConfigManager.KEY_CARRIER_VOLTE_AVAILABLE_BOOL) && isGbaValid(); }/** * Get the boolean config from carrier config manager. ** @param key config key defined in CarrierConfigManager * @return boolean value of corresponding key. */ private boolean getBooleanCarrierConfig(String key) { int[] subIds = SubscriptionManager.getSubId(mPhoneId); int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; if (subIds != null && subIds.length >= 1) {
subId = subIds[0]; }PersistableBundle b = null; if (mConfigManager != null) { // If an invalid subId is used, this bundle will contain default values. b = mConfigManager.getConfigForSubId(subId); }if (b != null) { return b.getBoolean(key); } else { // Return static default defined in CarrierConfigManager. return CarrierConfigManager.getDefaultConfig().getBoolean(key); } }//重点看getConfigForSubId函数config从哪里获取 PersistableBundle getConfigForSubId(int subId) { ... int phoneId = SubscriptionManager.getPhoneId(subId); //获取系统默认值 PersistableBundle retConfig = CarrierConfigManager.getDefaultConfig(); if (SubscriptionManager.isValidPhoneId(phoneId)) { //获取AOSP默认CarrierConfig app配置的值 PersistableBundle config = mConfigFromDefaultApp[phoneId]; if (config != null) { retConfig.putAll(config); retConfig.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, true); }//获取其他APP值 config = mConfigFromCarrierApp[phoneId]; if (config != null) { retConfig.putAll(config); retConfig.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, true); } }return retConfig; } 从上面流程看,Config的获取有3中途径: 1). 系统初始化CarrierConfigManager中的默认值. 2). AOSP CarrierConfig app配置的值 3). 获取其他Carrier APP的值 PS: 对于系统开发,我们重点关注前面2点,第3点是google做的扩展功能,暂时没有额外开发第三方Carrier APP。 三. CarrierConfig的配置 三
|