DO NOT MERGE - Merge qt-qpr1-dev-plus-aosp-without-vendor (6129114) into stage-aosp-master
Bug: 146167222 Change-Id: I77344517b74a2192af49a3f8956d8756b81741d9
This commit is contained in:
@@ -22,11 +22,8 @@ import android.os.Looper;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.data.ApnSetting;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.network.MobileDataContentObserver;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
@@ -41,14 +38,14 @@ public class MmsMessagePreferenceController extends TelephonyTogglePreferenceCon
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private MobileDataContentObserver mMobileDataContentObserver;
|
||||
private SwitchPreference mPreference;
|
||||
private PreferenceScreen mScreen;
|
||||
|
||||
public MmsMessagePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
||||
mMobileDataContentObserver = new MobileDataContentObserver(
|
||||
new Handler(Looper.getMainLooper()));
|
||||
mMobileDataContentObserver.setOnMobileDataChangedListener(()->updateState(mPreference));
|
||||
mMobileDataContentObserver.setOnMobileDataChangedListener(()->refreshPreference());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,15 +76,9 @@ public class MmsMessagePreferenceController extends TelephonyTogglePreferenceCon
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
mScreen = screen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
preference.setVisible(isAvailable());
|
||||
((SwitchPreference) preference).setChecked(isChecked());
|
||||
}
|
||||
|
||||
public void init(int subId) {
|
||||
mSubId = subId;
|
||||
@@ -104,4 +95,10 @@ public class MmsMessagePreferenceController extends TelephonyTogglePreferenceCon
|
||||
public boolean isChecked() {
|
||||
return mTelephonyManager.isDataEnabledForApn(ApnSetting.TYPE_MMS);
|
||||
}
|
||||
|
||||
private void refreshPreference() {
|
||||
if (mScreen != null) {
|
||||
super.displayPreference(mScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,16 +228,23 @@ public class MobileNetworkUtils {
|
||||
final String currentCountry = tm.getNetworkCountryIso().toLowerCase();
|
||||
final String supportedCountries =
|
||||
Settings.Global.getString(cr, Settings.Global.EUICC_SUPPORTED_COUNTRIES);
|
||||
final String unsupportedCountries =
|
||||
Settings.Global.getString(cr, Settings.Global.EUICC_UNSUPPORTED_COUNTRIES);
|
||||
|
||||
boolean inEsimSupportedCountries = false;
|
||||
if (TextUtils.isEmpty(currentCountry)) {
|
||||
inEsimSupportedCountries = true;
|
||||
} else if (!TextUtils.isEmpty(supportedCountries)) {
|
||||
final List<String> supportedCountryList =
|
||||
Arrays.asList(TextUtils.split(supportedCountries.toLowerCase(), ","));
|
||||
if (supportedCountryList.contains(currentCountry)) {
|
||||
inEsimSupportedCountries = true;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(supportedCountries)) {
|
||||
// White list is empty, use blacklist.
|
||||
Log.d(TAG, "Using blacklist unsupportedCountries=" + unsupportedCountries);
|
||||
inEsimSupportedCountries = !isEsimUnsupportedCountry(currentCountry,
|
||||
unsupportedCountries);
|
||||
} else {
|
||||
Log.d(TAG, "Using whitelist supportedCountries=" + supportedCountries);
|
||||
inEsimSupportedCountries = isEsimSupportedCountry(currentCountry, supportedCountries);
|
||||
}
|
||||
|
||||
Log.d(TAG, "inEsimSupportedCountries=" + inEsimSupportedCountries);
|
||||
|
||||
final boolean esimIgnoredDevice =
|
||||
Arrays.asList(TextUtils.split(SystemProperties.get(KEY_ESIM_CID_IGNORE, ""), ","))
|
||||
.contains(SystemProperties.get(KEY_CID, null));
|
||||
@@ -613,4 +620,24 @@ public class MobileNetworkUtils {
|
||||
}
|
||||
return tm.getNetworkOperatorName();
|
||||
}
|
||||
|
||||
private static boolean isEsimSupportedCountry(String country, String countriesListString) {
|
||||
if (TextUtils.isEmpty(country)) {
|
||||
return true;
|
||||
} else if (TextUtils.isEmpty(countriesListString)) {
|
||||
return false;
|
||||
}
|
||||
final List<String> supportedCountries =
|
||||
Arrays.asList(TextUtils.split(countriesListString.toLowerCase(), ","));
|
||||
return supportedCountries.contains(country);
|
||||
}
|
||||
|
||||
private static boolean isEsimUnsupportedCountry(String country, String countriesListString) {
|
||||
if (TextUtils.isEmpty(country) || TextUtils.isEmpty(countriesListString)) {
|
||||
return false;
|
||||
}
|
||||
final List<String> unsupportedCountries =
|
||||
Arrays.asList(TextUtils.split(countriesListString.toLowerCase(), ","));
|
||||
return unsupportedCountries.contains(country);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user