merge in lmp-mr1-release history after reset to lmp-mr1-dev
diff --git a/src/java/com/android/internal/telephony/MccTable.java b/src/java/com/android/internal/telephony/MccTable.java
index 95f9943..91355ae 100644
--- a/src/java/com/android/internal/telephony/MccTable.java
+++ b/src/java/com/android/internal/telephony/MccTable.java
@@ -24,6 +24,7 @@
import android.os.Build;
import android.os.RemoteException;
import android.os.SystemProperties;
+import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Slog;
@@ -223,6 +224,29 @@
}
}
+ // Bug 19232829: It is possible to get through provisioning without setting up a persistent
+ // locale value. We don't modify the locale if the device has completed "provisioning" because
+ // we don't want to change the locale if the user inserts a new SIM or a new version of Android
+ // is better at recognizing MCC values than an older version.
+ private static boolean canUpdateLocale(Context context) {
+ return !(userHasPersistedLocale() || isDeviceProvisioned(context));
+ }
+
+ private static boolean userHasPersistedLocale() {
+ String persistSysLanguage = SystemProperties.get("persist.sys.language", "");
+ String persistSysCountry = SystemProperties.get("persist.sys.country", "");
+ return !(persistSysLanguage.isEmpty() && persistSysCountry.isEmpty());
+ }
+
+ private static boolean isDeviceProvisioned(Context context) {
+ try {
+ return Settings.Global.getInt(
+ context.getContentResolver(), Settings.Global.DEVICE_PROVISIONED) != 0;
+ } catch (Settings.SettingNotFoundException e) {
+ return false;
+ }
+ }
+
/**
* Return Locale for the language and country or null if no good match.
*
@@ -243,22 +267,12 @@
}
// Check whether a developer is trying to test an arbitrary MCC.
- boolean debuggingMccOverride = false;
- if (Build.IS_DEBUGGABLE) {
- String overrideMcc = SystemProperties.get("persist.sys.override_mcc", "");
- if (!overrideMcc.isEmpty()) {
- debuggingMccOverride = true;
- }
- }
+ boolean debuggingMccOverride = isDebuggingMccOverride();
// If this is a regular user and they already have a persisted locale, we're done.
- if (!debuggingMccOverride) {
- String persistSysLanguage = SystemProperties.get("persist.sys.language", "");
- String persistSysCountry = SystemProperties.get("persist.sys.country", "");
- if (!(persistSysLanguage.isEmpty() && persistSysCountry.isEmpty())) {
- Slog.d(LOG_TAG, "getLocaleForLanguageCountry: skipping already persisted");
- return null;
- }
+ if (!(debuggingMccOverride || canUpdateLocale(context))) {
+ Slog.d(LOG_TAG, "getLocaleForLanguageCountry: not permitted to update locale");
+ return null;
}
// Find the best match we actually have a localization for.
@@ -315,6 +329,16 @@
return null;
}
+ private static boolean isDebuggingMccOverride() {
+ if (Build.IS_DEBUGGABLE) {
+ String overrideMcc = SystemProperties.get("persist.sys.override_mcc", "");
+ if (!overrideMcc.isEmpty()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Utility code to set the system locale if it's not set already
* @param context Context to act on.
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java
index 562f22b..57172bb 100644
--- a/src/java/com/android/internal/telephony/SubscriptionController.java
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java
@@ -590,8 +590,6 @@
}
String nameToSet;
- String CarrierName = mTelephonyManager.getSimOperatorNumericForSubscription(subIds[0]);
- if (DBG) logdl("[addSubInfoRecord] CarrierName = " + CarrierName);
String simCarrierName = mTelephonyManager.getSimOperatorNameForSubscription(subIds[0]);
if (!TextUtils.isEmpty(simCarrierName)) {
@@ -618,9 +616,7 @@
value.put(SubscriptionManager.COLOR, color);
value.put(SubscriptionManager.SIM_SLOT_INDEX, slotId);
value.put(SubscriptionManager.DISPLAY_NAME, nameToSet);
- value.put(SubscriptionManager.CARRIER_NAME,
- !TextUtils.isEmpty(simCarrierName) ? simCarrierName :
- mContext.getString(com.android.internal.R.string.unknownName));
+ value.put(SubscriptionManager.CARRIER_NAME, "");
Uri uri = resolver.insert(SubscriptionManager.CONTENT_URI, value);
if (DBG) logdl("[addSubInfoRecord] New record created: " + uri);
} else {
@@ -637,10 +633,6 @@
value.put(SubscriptionManager.DISPLAY_NAME, nameToSet);
}
- if (!TextUtils.isEmpty(simCarrierName)) {
- value.put(SubscriptionManager.CARRIER_NAME, simCarrierName);
- }
-
if (value.size() > 0) {
resolver.update(SubscriptionManager.CONTENT_URI, value,
SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID +
@@ -736,9 +728,12 @@
SubscriptionManager.CONTENT_URI.getAuthority(), 0) == null ||
subIds == null ||
!SubscriptionManager.isValidSubscriptionId(subIds[0])) {
- // No place to store this info, we are done.
+ // No place to store this info. Notify registrants of the change anyway as they
+ // might retrieve the SPN/PLMN text from the SST sticky broadcast.
// TODO: This can be removed once SubscriptionController is not running on devices
// that don't need it, such as TVs.
+ if (DBG) logd("[setPlmnSpn] No valid subscription to store info");
+ notifySubscriptionInfoChanged();
return false;
}
String carrierText = "";
diff --git a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java
index 7adf209..736cf7c 100644
--- a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java
+++ b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java
@@ -328,8 +328,6 @@
SubscriptionInfo subInfo = mSubscriptionManager.getActiveSubscriptionInfo(subId);
String nameToSet;
- String CarrierName = tm.getSimOperatorNumericForSubscription(subId);
- logd("CarrierName = " + CarrierName);
String simCarrierName = tm.getSimOperatorNameForSubscription(subId);
ContentValues name = new ContentValues(1);
@@ -342,14 +340,10 @@
}
name.put(SubscriptionManager.DISPLAY_NAME, nameToSet);
logd("sim name = " + nameToSet);
+ contentResolver.update(SubscriptionManager.CONTENT_URI, name,
+ SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID
+ + "=" + Long.toString(subId), null);
}
- name.put(SubscriptionManager.CARRIER_NAME,
- !TextUtils.isEmpty(simCarrierName) ? simCarrierName :
- mContext.getString(com.android.internal.R.string.unknownName));
- contentResolver.update(SubscriptionManager.CONTENT_URI, name,
- SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID
- + "=" + Long.toString(subId), null);
- logd("carrier name = " + simCarrierName);
/* Update preferred network type and network selection mode on SIM change.
* Storing last subId in SharedPreference for now to detect SIM change. */