Remove the deprecated carrier config
Change the VoLTE slice behavior to align with VoLTE setting UI entry(Enhanced4gBasePreferenceController) and remove KEY_ENHANCED_4G_LTE_TITLE_VARIANT_BOOL carrirt conifg. Bug: 159921798 Test: Fake some codes to verify VoLTE slice UI Change-Id: I2a1852feb74fb411a44483bcdab2f52b03d1eaa7
This commit is contained in:
@@ -23,8 +23,6 @@ import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
|
|||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
import android.telephony.CarrierConfigManager;
|
import android.telephony.CarrierConfigManager;
|
||||||
@@ -84,6 +82,10 @@ public class Enhanced4gLteSliceHelper {
|
|||||||
private static final String RESOURCE_ENHANCED_4G_LTE_MODE_TITLE_VARIANT =
|
private static final String RESOURCE_ENHANCED_4G_LTE_MODE_TITLE_VARIANT =
|
||||||
"enhanced_4g_lte_mode_title_variant";
|
"enhanced_4g_lte_mode_title_variant";
|
||||||
|
|
||||||
|
private static final int MODE_VOLTE = 0;
|
||||||
|
private static final int MODE_ADVANCED_CALL = 1;
|
||||||
|
private static final int MODE_4G_CALLING = 2;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public Enhanced4gLteSliceHelper(Context context) {
|
public Enhanced4gLteSliceHelper(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
@@ -217,40 +219,47 @@ public class Enhanced4gLteSliceHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CharSequence getEnhanced4glteModeTitle(int subId) {
|
private CharSequence getEnhanced4glteModeTitle(int subId) {
|
||||||
CharSequence ret = mContext.getText(R.string.enhanced_4g_lte_mode_title);
|
final int variant4gLteTitleIndex = getCarrierConfigManagerKeyValue(
|
||||||
try {
|
CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT, subId, 0);
|
||||||
if (isCarrierConfigManagerKeyEnabled(
|
final boolean show4GForLTE = isCarrierConfigManagerKeyEnabled(
|
||||||
CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_BOOL,
|
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL, subId, false);
|
||||||
subId,
|
final CharSequence[] variantTitles = mContext.getResources()
|
||||||
false)) {
|
.getTextArray(R.array.enhanced_4g_lte_mode_title_variant);
|
||||||
final PackageManager manager = mContext.getPackageManager();
|
int index = MODE_ADVANCED_CALL;
|
||||||
final Resources resources = manager.getResourcesForApplication(
|
if (variant4gLteTitleIndex != MODE_ADVANCED_CALL) {
|
||||||
PACKAGE_PHONE);
|
index = show4GForLTE ? MODE_4G_CALLING : MODE_VOLTE;
|
||||||
final int resId = resources.getIdentifier(
|
|
||||||
RESOURCE_ENHANCED_4G_LTE_MODE_TITLE_VARIANT,
|
|
||||||
RESOURCE_TYPE_STRING, PACKAGE_PHONE);
|
|
||||||
ret = resources.getText(resId);
|
|
||||||
}
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
Log.e(TAG, "package name not found");
|
|
||||||
}
|
}
|
||||||
return ret;
|
return variantTitles[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code true} when the key is enabled for the carrier, and {@code false} otherwise.
|
* Returns {@code true} when the key is enabled for the carrier, and {@code false} otherwise.
|
||||||
*/
|
*/
|
||||||
private boolean isCarrierConfigManagerKeyEnabled(String key,
|
private boolean isCarrierConfigManagerKeyEnabled(String key, int subId, boolean defaultValue) {
|
||||||
int subId, boolean defaultValue) {
|
boolean result = defaultValue;
|
||||||
final CarrierConfigManager configManager = getCarrierConfigManager();
|
final PersistableBundle carrierConfig = getCarrierConfig(subId);
|
||||||
boolean ret = defaultValue;
|
if (carrierConfig != null) {
|
||||||
if (configManager != null) {
|
result = carrierConfig.getBoolean(key, defaultValue);
|
||||||
final PersistableBundle bundle = configManager.getConfigForSubId(subId);
|
|
||||||
if (bundle != null) {
|
|
||||||
ret = bundle.getBoolean(key, defaultValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getCarrierConfigManagerKeyValue(String key, int subId, int defaultValue) {
|
||||||
|
int result = defaultValue;
|
||||||
|
final PersistableBundle carrierConfig = getCarrierConfig(subId);
|
||||||
|
if (carrierConfig != null) {
|
||||||
|
result = carrierConfig.getInt(key, defaultValue);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PersistableBundle getCarrierConfig(int subId) {
|
||||||
|
final CarrierConfigManager configManager = getCarrierConfigManager();
|
||||||
|
PersistableBundle bundle = null;
|
||||||
|
if (configManager != null) {
|
||||||
|
bundle = configManager.getConfigForSubId(subId);
|
||||||
|
}
|
||||||
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CarrierConfigManager getCarrierConfigManager() {
|
protected CarrierConfigManager getCarrierConfigManager() {
|
||||||
|
Reference in New Issue
Block a user