Merge "[Mainline] Use the @SystemApi setAlwaysAllowMmsData in TelephonyManager for mainline"
diff --git a/Android.bp b/Android.bp
index fb1a802..ce6a1b4 100644
--- a/Android.bp
+++ b/Android.bp
@@ -49,7 +49,7 @@
name: "Settings",
platform_apis: true,
certificate: "platform",
- product_specific: true,
+ system_ext_specific: true,
privileged: true,
required: ["privapp_whitelist_com.android.settings"],
static_libs: ["Settings-core"],
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 93445f9..dd61019 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -47,6 +47,8 @@
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Settings_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Settings_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/Settings)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/product/priv-app/Settings)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/product/priv-app/Settings)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 68ad98c..9424807 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -912,6 +912,9 @@
<item>IPSec Xauth PSK</item>
<item>IPSec Xauth RSA</item>
<item>IPSec Hybrid RSA</item>
+ <item>IKEv2/IPSec MSCHAPv2</item>
+ <item>IKEv2/IPSec PSK</item>
+ <item>IKEv2/IPSec RSA</item>
</string-array>
<!-- Match this with the constants in VpnProfile. --> <skip />
@@ -923,6 +926,9 @@
<item>IPSec VPN with pre-shared keys and Xauth authentication</item>
<item>IPSec VPN with certificates and Xauth authentication</item>
<item>IPSec VPN with certificates and hybrid authentication</item>
+ <item>IKEv2/IPSec VPN with certificates and username/password authentication</item>
+ <item>IKEv2/IPSec VPN with pre-shared keys</item>
+ <item>IKEv2/IPSec VPN with certificates</item>
</string-array>
<!-- VPN proxy settings. -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d7f7862..4ae16d6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -10555,13 +10555,15 @@
<!-- Title for App Compatibility Changes dashboard where developers can configure per-app overrides for compatibility changes [CHAR LIMIT=50] -->
<string name="platform_compat_dashboard_title">App Compatibility Changes</string>
<!-- Summary for App Compatibility Changes dashboard [CHAR LIMIT=NONE] -->
- <string name="platform_compat_dashboard_summary">Modify app compatibility change overrides</string>
+ <string name="platform_compat_dashboard_summary">Toggle app compatibility changes</string>
+ <!-- Summary for selected app [DO NOT TRANSLATE] -->
+ <string name="platform_compat_selected_app_summary" translatable="false"><xliff:g id="app_name" example="com.google.android.chrome">%1$s</xliff:g> targetSdkVersion <xliff:g id="number" example="29">%2$d</xliff:g></string>
<!-- Title for default enabled app compat changes category [CHAR LIMIT=50] -->
<string name="platform_compat_default_enabled_title">Default enabled changes</string>
<!-- Title for default disabled app compat changes category [CHAR LIMIT=50] -->
<string name="platform_compat_default_disabled_title">Default disabled changes</string>
- <!-- Title for target SDK gated app compat changes category [CHAR LIMIT=50] -->
- <string name="platform_compat_target_sdk_title">Enabled after SDK <xliff:g id="number" example="29">%d</xliff:g></string>
+ <!-- Title for target SDK gated app compat changes category (do not translate 'targetSdkVersion') [CHAR LIMIT=50] -->
+ <string name="platform_compat_target_sdk_title">Enabled for targetSdkVersion > <xliff:g id="number" example="29">%d</xliff:g></string>
<!-- Slices Strings -->
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index d3911ce..d97fa86 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -297,6 +297,13 @@
android:entryValues="@array/bluetooth_avrcp_version_values" />
<ListPreference
+ android:key="bluetooth_select_map_version"
+ android:title="@string/bluetooth_select_map_version_string"
+ android:dialogTitle="@string/bluetooth_select_map_version_dialog_title"
+ android:entries="@array/bluetooth_map_versions"
+ android:entryValues="@array/bluetooth_map_version_values" />
+
+ <ListPreference
android:key="bluetooth_select_a2dp_codec"
android:title="@string/bluetooth_select_a2dp_codec_type"
android:dialogTitle="@string/bluetooth_select_a2dp_codec_type_dialog_title"
diff --git a/src/com/android/settings/ResetNetworkConfirm.java b/src/com/android/settings/ResetNetworkConfirm.java
index 609a2d6..c4e4baf 100644
--- a/src/com/android/settings/ResetNetworkConfirm.java
+++ b/src/com/android/settings/ResetNetworkConfirm.java
@@ -47,7 +47,6 @@
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
-import com.android.ims.ImsManager;
import com.android.internal.telephony.PhoneConstants;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
@@ -126,8 +125,6 @@
}
}
- ImsManager.getInstance(mContext,
- SubscriptionManager.getPhoneId(mSubId)).factoryReset();
restoreDefaultApn(mContext);
if (mEraseEsim) {
return RecoverySystem.wipeEuiccData(mContext, mPackageName);
diff --git a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
index 9c344df..ce81f43 100644
--- a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
+++ b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
@@ -95,6 +95,17 @@
private final List<Preference> mPreferenceList = new ArrayList<>();
+ private final View.OnLayoutChangeListener mLayoutChangeListener =
+ new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom,
+ int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ // Remove the listener once the callback is triggered.
+ mPreviewViewport.removeOnLayoutChangeListener(this);
+ refreshPreviewText();
+ }
+ };
+
@Override
public int getMetricsCategory() {
return SettingsEnums.ACCESSIBILITY_CAPTION_PROPERTIES;
@@ -192,9 +203,7 @@
mPreviewWindow = captionPreview.findViewById(R.id.preview_window);
mPreviewViewport = captionPreview.findViewById(R.id.preview_viewport);
- mPreviewViewport.addOnLayoutChangeListener(
- (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom)
- -> refreshPreviewText());
+ mPreviewViewport.addOnLayoutChangeListener(mLayoutChangeListener);
final Resources res = getResources();
final int[] presetValues = res.getIntArray(R.array.captioning_preset_selector_values);
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsButtonsController.java b/src/com/android/settings/bluetooth/BluetoothDetailsButtonsController.java
index a7fae14..c807893 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsButtonsController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsButtonsController.java
@@ -79,7 +79,7 @@
.setButton2Text(R.string.bluetooth_device_context_connect)
.setButton2Icon(R.drawable.ic_add_24dp)
.setButton2OnClickListener(
- view -> mCachedDevice.connect(true /* connectAllProfiles */));
+ view -> mCachedDevice.connect());
mConnectButtonInitialized = true;
}
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
index 74d3b6a..919dc5b 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
@@ -218,7 +218,7 @@
} else if (bondState == BluetoothDevice.BOND_BONDED) {
metricsFeatureProvider.action(context,
SettingsEnums.ACTION_SETTINGS_BLUETOOTH_CONNECT);
- mCachedDevice.connect(true);
+ mCachedDevice.connect();
} else if (bondState == BluetoothDevice.BOND_NONE) {
metricsFeatureProvider.action(context,
SettingsEnums.ACTION_SETTINGS_BLUETOOTH_PAIR);
diff --git a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
index 6381b84..bcaf385 100644
--- a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
@@ -53,7 +53,7 @@
public boolean onPreferenceClick(Preference preference) {
final CachedBluetoothDevice device = ((BluetoothDevicePreference) preference)
.getBluetoothDevice();
- device.connect(true);
+ device.connect();
return true;
}
}
diff --git a/src/com/android/settings/datausage/DataSaverBackend.java b/src/com/android/settings/datausage/DataSaverBackend.java
index de28b07..92b2ef9 100644
--- a/src/com/android/settings/datausage/DataSaverBackend.java
+++ b/src/com/android/settings/datausage/DataSaverBackend.java
@@ -23,6 +23,7 @@
import android.net.INetworkPolicyListener;
import android.net.NetworkPolicyManager;
import android.os.RemoteException;
+import android.telephony.SubscriptionPlan;
import android.util.SparseIntArray;
import com.android.settings.overlay.FeatureFactory;
@@ -201,6 +202,10 @@
@Override
public void onSubscriptionOverride(int subId, int overrideMask, int overrideValue) {
}
+
+ @Override
+ public void onSubscriptionPlansChanged(int subId, SubscriptionPlan[] plans) {
+ }
};
public interface Listener {
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
index 600b9e8..a26e359 100644
--- a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
@@ -19,8 +19,11 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.net.INetworkPolicyManager;
import android.net.NetworkPolicyManager;
import android.net.NetworkTemplate;
+import android.os.ServiceManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionPlan;
@@ -296,12 +299,51 @@
mSnapshotTime = primaryPlan.getDataUsageTime();
}
}
- mManageSubscriptionIntent =
- mSubscriptionManager.createManageSubscriptionIntent(mSubscriptionId);
+ mManageSubscriptionIntent = createManageSubscriptionIntent(mSubscriptionId);
Log.i(TAG, "Have " + mDataplanCount + " plans, dflt sub-id " + mSubscriptionId
+ ", intent " + mManageSubscriptionIntent);
}
+ /**
+ * Create an {@link Intent} that can be launched towards the carrier app
+ * that is currently defining the billing relationship plan through
+ * {@link INetworkPolicyManager#setSubscriptionPlans(int, SubscriptionPlan [], String)}.
+ *
+ * @return ready to launch Intent targeted towards the carrier app, or
+ * {@code null} if no carrier app is defined, or if the defined
+ * carrier app provides no management activity.
+ */
+ private Intent createManageSubscriptionIntent(int subId) {
+ final INetworkPolicyManager iNetPolicyManager = INetworkPolicyManager.Stub.asInterface(
+ ServiceManager.getService(Context.NETWORK_POLICY_SERVICE));
+ String owner = "";
+ try {
+ owner = iNetPolicyManager.getSubscriptionPlansOwner(subId);
+ } catch (Exception ex) {
+ Log.w(TAG, "Fail to get subscription plan owner for subId " + subId, ex);
+ }
+
+ if (TextUtils.isEmpty(owner)) {
+ return null;
+ }
+
+ final List<SubscriptionPlan> plans = mSubscriptionManager.getSubscriptionPlans(subId);
+ if (plans.isEmpty()) {
+ return null;
+ }
+
+ final Intent intent = new Intent(SubscriptionManager.ACTION_MANAGE_SUBSCRIPTION_PLANS);
+ intent.setPackage(owner);
+ intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
+
+ if (mActivity.getPackageManager().queryIntentActivities(intent,
+ PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) {
+ return null;
+ }
+
+ return intent;
+ }
+
public static SubscriptionPlan getPrimaryPlan(SubscriptionManager subManager, int primaryId) {
List<SubscriptionPlan> plans = subManager.getSubscriptionPlans(primaryId);
if (CollectionUtils.isEmpty(plans)) {
diff --git a/src/com/android/settings/datausage/DataUsageUtils.java b/src/com/android/settings/datausage/DataUsageUtils.java
index ef3e7b6..433d1ed 100644
--- a/src/com/android/settings/datausage/DataUsageUtils.java
+++ b/src/com/android/settings/datausage/DataUsageUtils.java
@@ -66,7 +66,7 @@
return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains(ETHERNET);
}
- final ConnectivityManager conn = ConnectivityManager.from(context);
+ final ConnectivityManager conn = context.getSystemService(ConnectivityManager.class);
if (!conn.isNetworkSupported(ConnectivityManager.TYPE_ETHERNET)) {
return false;
}
@@ -93,7 +93,8 @@
* TODO: This is the opposite to Utils.isWifiOnly(), it should be refactored into 1 method.
*/
public static boolean hasMobileData(Context context) {
- ConnectivityManager connectivityManager = ConnectivityManager.from(context);
+ final ConnectivityManager connectivityManager =
+ context.getSystemService(ConnectivityManager.class);
return connectivityManager != null && connectivityManager
.isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
}
@@ -106,7 +107,8 @@
return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile");
}
final List<SubscriptionInfo> subInfoList =
- SubscriptionManager.from(context).getActiveSubscriptionInfoList();
+ context.getSystemService(SubscriptionManager.class)
+ .getActiveSubscriptionInfoList();
// No activated Subscriptions
if (subInfoList == null) {
if (LOGD) {
@@ -123,7 +125,7 @@
Log.d(TAG, "hasReadyMobileRadio: subInfo=" + subInfo);
}
}
- final ConnectivityManager conn = ConnectivityManager.from(context);
+ final ConnectivityManager conn = context.getSystemService(ConnectivityManager.class);
final boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady;
if (LOGD) {
Log.d(TAG, "hasReadyMobileRadio:"
@@ -142,7 +144,8 @@
return SystemProperties.get(TEST_RADIOS_PROP).contains("wifi");
}
- final ConnectivityManager connectivityManager = ConnectivityManager.from(context);
+ final ConnectivityManager connectivityManager =
+ context.getSystemService(ConnectivityManager.class);
return connectivityManager != null && connectivityManager.isNetworkSupported(TYPE_WIFI);
}
@@ -159,19 +162,25 @@
* SubscriptionManager#INVALID_SUBSCRIPTION_ID
*/
public static int getDefaultSubscriptionId(Context context) {
- SubscriptionManager subManager = SubscriptionManager.from(context);
- if (subManager == null) {
+ final SubscriptionManager subscriptionMgr =
+ context.getSystemService(SubscriptionManager.class);
+
+ // default data subscription is first choice
+ final int dataSubId = subscriptionMgr.getDefaultDataSubscriptionId();
+ if (SubscriptionManager.isValidSubscriptionId(dataSubId)) {
+ return dataSubId;
+ }
+
+ // any active subscription is second choice
+ List<SubscriptionInfo> subList = subscriptionMgr.getActiveSubscriptionInfoList();
+ if ((subList == null) || (subList.size() <= 0)) {
+ // any subscription is third choice
+ subList = subscriptionMgr.getAvailableSubscriptionInfoList();
+ }
+ if ((subList == null) || (subList.size() <= 0)) {
return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
}
- SubscriptionInfo subscriptionInfo = subManager.getDefaultDataSubscriptionInfo();
- if (subscriptionInfo == null) {
- List<SubscriptionInfo> list = subManager.getAllSubscriptionInfoList();
- if (list.size() == 0) {
- return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
- }
- subscriptionInfo = list.get(0);
- }
- return subscriptionInfo.getSubscriptionId();
+ return subList.get(0).getSubscriptionId();
}
/**
@@ -179,7 +188,7 @@
* ethernet template if both mobile data and Wifi are not available.
*/
public static NetworkTemplate getDefaultTemplate(Context context, int defaultSubId) {
- if (hasMobileData(context) && defaultSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ if (SubscriptionManager.isValidSubscriptionId(defaultSubId) && hasMobileData(context)) {
return getMobileTemplate(context, defaultSubId);
} else if (hasWifiRadio(context)) {
return NetworkTemplate.buildTemplateWifiWildcard();
diff --git a/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java b/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java
index d7fcb2f..92e9e96 100644
--- a/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java
+++ b/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java
@@ -48,9 +48,10 @@
mCountryTimeZones = countryTimeZones;
List<String> timeZoneIds = countryTimeZones.getTimeZoneMappings().stream()
.filter(timeZoneMapping ->
- timeZoneMapping.showInPicker && (timeZoneMapping.notUsedAfter == null
- || timeZoneMapping.notUsedAfter >= MIN_USE_DATE_OF_TIMEZONE))
- .map(timeZoneMapping -> timeZoneMapping.timeZoneId)
+ timeZoneMapping.isShownInPicker()
+ && (timeZoneMapping.getNotUsedAfter() == null
+ || timeZoneMapping.getNotUsedAfter() >= MIN_USE_DATE_OF_TIMEZONE))
+ .map(timeZoneMapping -> timeZoneMapping.getTimeZoneId())
.collect(Collectors.toList());
mTimeZoneIds = Collections.unmodifiableList(timeZoneIds);
}
diff --git a/src/com/android/settings/development/BluetoothMapVersionPreferenceController.java b/src/com/android/settings/development/BluetoothMapVersionPreferenceController.java
new file mode 100644
index 0000000..e553e49
--- /dev/null
+++ b/src/com/android/settings/development/BluetoothMapVersionPreferenceController.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import android.content.Context;
+import android.os.SystemProperties;
+import android.text.TextUtils;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+public class BluetoothMapVersionPreferenceController extends DeveloperOptionsPreferenceController
+ implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
+
+ private static final String BLUETOOTH_SELECT_MAP_VERSION_KEY =
+ "bluetooth_select_map_version";
+
+ @VisibleForTesting
+ static final String BLUETOOTH_MAP_VERSION_PROPERTY = "persist.bluetooth.mapversion";
+
+ private final String[] mListValues;
+ private final String[] mListSummaries;
+
+ public BluetoothMapVersionPreferenceController(Context context) {
+ super(context);
+
+ mListValues = context.getResources().getStringArray(R.array.bluetooth_map_version_values);
+ mListSummaries = context.getResources().getStringArray(R.array.bluetooth_map_versions);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return BLUETOOTH_SELECT_MAP_VERSION_KEY;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ SystemProperties.set(BLUETOOTH_MAP_VERSION_PROPERTY, newValue.toString());
+ updateState(mPreference);
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ final ListPreference listPreference = (ListPreference) preference;
+ final String currentValue = SystemProperties.get(BLUETOOTH_MAP_VERSION_PROPERTY);
+ int index = 0; // Defaults to MAP 1.2
+ for (int i = 0; i < mListValues.length; i++) {
+ if (TextUtils.equals(currentValue, mListValues[i])) {
+ index = i;
+ break;
+ }
+ }
+ listPreference.setValue(mListValues[index]);
+ listPreference.setSummary(mListSummaries[index]);
+ }
+}
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index f384d85..88d80d1 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -438,6 +438,7 @@
controllers.add(new BluetoothDeviceNoNamePreferenceController(context));
controllers.add(new BluetoothAbsoluteVolumePreferenceController(context));
controllers.add(new BluetoothAvrcpVersionPreferenceController(context));
+ controllers.add(new BluetoothMapVersionPreferenceController(context));
controllers.add(new BluetoothA2dpHwOffloadPreferenceController(context, fragment));
controllers.add(new BluetoothAudioCodecPreferenceController(context, lifecycle,
bluetoothA2dpConfigStore));
diff --git a/src/com/android/settings/development/compat/PlatformCompatDashboard.java b/src/com/android/settings/development/compat/PlatformCompatDashboard.java
index dab45f2..2932f7b 100644
--- a/src/com/android/settings/development/compat/PlatformCompatDashboard.java
+++ b/src/com/android/settings/development/compat/PlatformCompatDashboard.java
@@ -16,7 +16,9 @@
package com.android.settings.development.compat;
+import static com.android.settings.development.AppPicker.EXTRA_DEBUGGABLE;
import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes.REQUEST_COMPAT_CHANGE_APP;
+import static com.android.internal.compat.OverrideAllowedState.ALLOWED;
import android.app.Activity;
import android.app.settings.SettingsEnums;
@@ -25,7 +27,9 @@
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -37,9 +41,12 @@
import androidx.preference.PreferenceCategory;
import androidx.preference.SwitchPreference;
+import com.android.internal.compat.AndroidBuildClassifier;
import com.android.internal.compat.CompatibilityChangeConfig;
import com.android.internal.compat.CompatibilityChangeInfo;
import com.android.internal.compat.IPlatformCompat;
+import com.android.internal.compat.IOverrideValidator;
+import com.android.internal.compat.OverrideAllowedState;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.development.AppPicker;
@@ -61,6 +68,8 @@
private CompatibilityChangeInfo[] mChanges;
+ private AndroidBuildClassifier mAndroidBuildClassifier = new AndroidBuildClassifier();
+
@VisibleForTesting
String mSelectedApp;
@@ -114,17 +123,21 @@
if (requestCode == REQUEST_COMPAT_CHANGE_APP) {
if (resultCode == Activity.RESULT_OK) {
mSelectedApp = data.getAction();
- addPreferences();
+ try {
+ final ApplicationInfo applicationInfo = getApplicationInfo();
+ addPreferences(applicationInfo);
+ } catch (PackageManager.NameNotFoundException e) {
+ startAppPicker();
+ }
}
return;
}
super.onActivityResult(requestCode, resultCode, data);
}
- private void addPreferences() {
+ private void addPreferences(ApplicationInfo applicationInfo) {
getPreferenceScreen().removeAll();
- getPreferenceScreen().addPreference(
- createAppPreference(getApplicationInfo().loadIcon(getPackageManager())));
+ getPreferenceScreen().addPreference(createAppPreference(applicationInfo));
// Differentiate compatibility changes into default enabled, default disabled and enabled
// after target sdk.
final CompatibilityChangeConfig configMappings = getAppChangeMappings();
@@ -161,7 +174,7 @@
try {
final ApplicationInfo applicationInfo = getApplicationInfo();
return getPlatformCompat().getAppConfig(applicationInfo);
- } catch (RemoteException e) {
+ } catch (RemoteException | PackageManager.NameNotFoundException e) {
throw new RuntimeException("Could not get app config!", e);
}
}
@@ -180,7 +193,15 @@
change.getName() != null ? change.getName() : "Change_" + change.getId();
item.setSummary(changeName);
item.setKey(changeName);
- item.setEnabled(true);
+ boolean shouldEnable = true;
+ try {
+ shouldEnable = getPlatformCompat().getOverrideValidator()
+ .getOverrideAllowedState(change.getId(), mSelectedApp)
+ .state == ALLOWED;
+ } catch (RemoteException e) {
+ throw new RuntimeException("Could not check if change can be overridden for app.", e);
+ }
+ item.setEnabled(shouldEnable);
item.setChecked(currentValue);
item.setOnPreferenceChangeListener(
new CompatChangePreferenceChangeListener(change.getId()));
@@ -192,12 +213,8 @@
*
* @return an {@link ApplicationInfo} instance.
*/
- ApplicationInfo getApplicationInfo() {
- try {
- return getPackageManager().getApplicationInfo(mSelectedApp, 0);
- } catch (PackageManager.NameNotFoundException e) {
- throw new RuntimeException("Could not get ApplicationInfo for selected app!", e);
- }
+ ApplicationInfo getApplicationInfo() throws PackageManager.NameNotFoundException {
+ return getPackageManager().getApplicationInfo(mSelectedApp, 0);
}
/**
@@ -206,13 +223,13 @@
* <p>The {@link Preference} contains the icon, package name and target SDK for the selected
* app. Selecting this preference will also re-trigger the app selection dialog.</p>
*/
- Preference createAppPreference(Drawable icon) {
- final ApplicationInfo applicationInfo = getApplicationInfo();
- final Preference appPreference = new Preference(getPreferenceScreen().getContext());
+ Preference createAppPreference(ApplicationInfo applicationInfo) {
+ final Context context = getPreferenceScreen().getContext();
+ final Drawable icon = applicationInfo.loadIcon(context.getPackageManager());
+ final Preference appPreference = new Preference(context);
appPreference.setIcon(icon);
- appPreference.setSummary(mSelectedApp
- + " SDK "
- + applicationInfo.targetSdkVersion);
+ appPreference.setSummary(getString(R.string.platform_compat_selected_app_summary,
+ mSelectedApp, applicationInfo.targetSdkVersion));
appPreference.setKey(mSelectedApp);
appPreference.setOnPreferenceClickListener(
preference -> {
@@ -243,6 +260,11 @@
private void startAppPicker() {
final Intent intent = new Intent(getContext(), AppPicker.class);
+ // If build is neither userdebug nor eng, only include debuggable apps
+ final boolean debuggableBuild = mAndroidBuildClassifier.isDebuggableBuild();
+ if (!debuggableBuild) {
+ intent.putExtra(AppPicker.EXTRA_DEBUGGABLE, true /* value */);
+ }
startActivityForResult(intent, REQUEST_COMPAT_CHANGE_APP);
}
diff --git a/src/com/android/settings/deviceinfo/ImsStatusPreferenceController.java b/src/com/android/settings/deviceinfo/ImsStatusPreferenceController.java
deleted file mode 100644
index 07bd4a6..0000000
--- a/src/com/android/settings/deviceinfo/ImsStatusPreferenceController.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.deviceinfo;
-
-import android.content.Context;
-
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.deviceinfo.AbstractImsStatusPreferenceController;
-
-/**
- * Concrete subclass of IMS status preference controller
- */
-public class ImsStatusPreferenceController extends AbstractImsStatusPreferenceController
- implements PreferenceControllerMixin {
- public ImsStatusPreferenceController(Context context,
- Lifecycle lifecycle) {
- super(context, lifecycle);
- }
-
- // This space intentionally left blank
-}
diff --git a/src/com/android/settings/network/ApnEditor.java b/src/com/android/settings/network/ApnEditor.java
index 84e6b1d..326d44b 100644
--- a/src/com/android/settings/network/ApnEditor.java
+++ b/src/com/android/settings/network/ApnEditor.java
@@ -48,7 +48,6 @@
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.SwitchPreference;
-import com.android.internal.telephony.PhoneConstants;
import com.android.internal.util.ArrayUtils;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
@@ -143,6 +142,55 @@
private Uri mCarrierUri;
/**
+ * APN types for data connections. These are usage categories for an APN
+ * entry. One APN entry may support multiple APN types, eg, a single APN
+ * may service regular internet traffic ("default") as well as MMS-specific
+ * connections.<br/>
+ * APN_TYPE_ALL is a special type to indicate that this APN entry can
+ * service all data connections.
+ */
+ public static final String APN_TYPE_ALL = "*";
+ /** APN type for default data traffic */
+ public static final String APN_TYPE_DEFAULT = "default";
+ /** APN type for MMS traffic */
+ public static final String APN_TYPE_MMS = "mms";
+ /** APN type for SUPL assisted GPS */
+ public static final String APN_TYPE_SUPL = "supl";
+ /** APN type for DUN traffic */
+ public static final String APN_TYPE_DUN = "dun";
+ /** APN type for HiPri traffic */
+ public static final String APN_TYPE_HIPRI = "hipri";
+ /** APN type for FOTA */
+ public static final String APN_TYPE_FOTA = "fota";
+ /** APN type for IMS */
+ public static final String APN_TYPE_IMS = "ims";
+ /** APN type for CBS */
+ public static final String APN_TYPE_CBS = "cbs";
+ /** APN type for IA Initial Attach APN */
+ public static final String APN_TYPE_IA = "ia";
+ /** APN type for Emergency PDN. This is not an IA apn, but is used
+ * for access to carrier services in an emergency call situation. */
+ public static final String APN_TYPE_EMERGENCY = "emergency";
+ /** APN type for Mission Critical Services */
+ public static final String APN_TYPE_MCX = "mcx";
+ /** APN type for XCAP */
+ public static final String APN_TYPE_XCAP = "xcap";
+ /** Array of all APN types */
+ public static final String[] APN_TYPES = {APN_TYPE_DEFAULT,
+ APN_TYPE_MMS,
+ APN_TYPE_SUPL,
+ APN_TYPE_DUN,
+ APN_TYPE_HIPRI,
+ APN_TYPE_FOTA,
+ APN_TYPE_IMS,
+ APN_TYPE_CBS,
+ APN_TYPE_IA,
+ APN_TYPE_EMERGENCY,
+ APN_TYPE_MCX,
+ APN_TYPE_XCAP,
+ };
+
+ /**
* Standard projection for the interesting columns of a normal note.
*/
private static final String[] sProjection = new String[] {
@@ -356,11 +404,11 @@
}
final List apnList = Arrays.asList(apnTypes);
- if (apnList.contains(PhoneConstants.APN_TYPE_ALL)) {
- Log.d(TAG, "hasAllApns: true because apnList.contains(PhoneConstants.APN_TYPE_ALL)");
+ if (apnList.contains(APN_TYPE_ALL)) {
+ Log.d(TAG, "hasAllApns: true because apnList.contains(APN_TYPE_ALL)");
return true;
}
- for (String apn : PhoneConstants.APN_TYPES) {
+ for (String apn : APN_TYPES) {
if (!apnList.contains(apn)) {
return false;
}
@@ -516,7 +564,7 @@
mApnType.setText(mApnData.getString(TYPE_INDEX));
if (mNewApn) {
final SubscriptionInfo subInfo =
- mProxySubscriptionMgr.getActiveSubscriptionInfo(mSubId);
+ mProxySubscriptionMgr.getAccessibleSubscriptionInfo(mSubId);
// Country code
final String mcc = (subInfo == null) ? null : subInfo.getMccString();
@@ -1190,9 +1238,9 @@
String userEnteredApnType = mApnType.getText();
if (userEnteredApnType != null) userEnteredApnType = userEnteredApnType.trim();
if ((TextUtils.isEmpty(userEnteredApnType)
- || PhoneConstants.APN_TYPE_ALL.equals(userEnteredApnType))
+ || APN_TYPE_ALL.equals(userEnteredApnType))
&& !ArrayUtils.isEmpty(mReadOnlyApnTypes)) {
- String[] apnTypeList = PhoneConstants.APN_TYPES;
+ String[] apnTypeList = APN_TYPES;
if (TextUtils.isEmpty(userEnteredApnType) && !ArrayUtils.isEmpty(mDefaultApnTypes)) {
apnTypeList = mDefaultApnTypes;
}
@@ -1203,9 +1251,9 @@
for (String apnType : apnTypeList) {
// add APN type if it is not read-only and is not wild-cardable
if (!readOnlyApnTypes.contains(apnType)
- && !apnType.equals(PhoneConstants.APN_TYPE_IA)
- && !apnType.equals(PhoneConstants.APN_TYPE_EMERGENCY)
- && !apnType.equals(PhoneConstants.APN_TYPE_MCX)) {
+ && !apnType.equals(APN_TYPE_IA)
+ && !apnType.equals(APN_TYPE_EMERGENCY)
+ && !apnType.equals(APN_TYPE_MCX)) {
if (first) {
first = false;
} else {
diff --git a/src/com/android/settings/network/ApnSettings.java b/src/com/android/settings/network/ApnSettings.java
index 94d7bca..eb6c9b1 100755
--- a/src/com/android/settings/network/ApnSettings.java
+++ b/src/com/android/settings/network/ApnSettings.java
@@ -38,6 +38,8 @@
import android.os.UserManager;
import android.provider.Telephony;
import android.telephony.CarrierConfigManager;
+import android.telephony.PhoneStateListener;
+import android.telephony.PreciseDataConnectionState;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -52,8 +54,6 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
-import com.android.internal.telephony.PhoneConstants;
-import com.android.internal.telephony.TelephonyIntents;
import com.android.settings.R;
import com.android.settings.RestrictedSettingsFragment;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
@@ -107,6 +107,7 @@
private static boolean mRestoreDefaultApnMode;
private UserManager mUserManager;
+ private TelephonyManager mTelephonyManager;
private RestoreApnUiHandler mRestoreApnUiHandler;
private RestoreApnProcessHandler mRestoreApnProcessHandler;
private HandlerThread mRestoreDefaultApnThread;
@@ -130,32 +131,35 @@
super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
}
+ private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
+ @Override
+ public void onPreciseDataConnectionStateChanged(
+ PreciseDataConnectionState dataConnectionState) {
+ if (dataConnectionState.getState() == TelephonyManager.DATA_CONNECTED) {
+ if (!mRestoreDefaultApnMode) {
+ fillList();
+ } else {
+ showDialog(DIALOG_RESTORE_DEFAULTAPN);
+ }
+ }
+ }
+ };
+
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(
- TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
- PhoneConstants.DataState state = getMobileDataState(intent);
- switch (state) {
- case CONNECTED:
- if (!mRestoreDefaultApnMode) {
- fillList();
- } else {
- showDialog(DIALOG_RESTORE_DEFAULTAPN);
- }
- break;
- }
- } else if(intent.getAction().equals(
TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED)) {
if (!mRestoreDefaultApnMode) {
int extraSubId = intent.getIntExtra(TelephonyManager.EXTRA_SUBSCRIPTION_ID,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
- if (SubscriptionManager.isValidSubscriptionId(extraSubId) &&
- mPhoneId == SubscriptionManager.getPhoneId(extraSubId) &&
- extraSubId != mSubId) {
+ if (SubscriptionManager.isValidSubscriptionId(extraSubId)
+ && mPhoneId == SubscriptionUtil.getPhoneId(context, extraSubId)
+ && extraSubId != mSubId) {
// subscription has changed
mSubId = extraSubId;
mSubscriptionInfo = getSubscriptionInfo(mSubId);
+ restartPhoneStateListener(mSubId);
}
fillList();
}
@@ -163,13 +167,22 @@
}
};
- private static PhoneConstants.DataState getMobileDataState(Intent intent) {
- String str = intent.getStringExtra(PhoneConstants.STATE_KEY);
- if (str != null) {
- return Enum.valueOf(PhoneConstants.DataState.class, str);
- } else {
- return PhoneConstants.DataState.DISCONNECTED;
+ private void restartPhoneStateListener(int subId) {
+ if (mRestoreDefaultApnMode) {
+ return;
}
+
+ final TelephonyManager updatedTelephonyManager =
+ mTelephonyManager.createForSubscriptionId(subId);
+
+ // restart monitoring when subscription has been changed
+ mTelephonyManager.listen(mPhoneStateListener,
+ PhoneStateListener.LISTEN_NONE);
+
+ mTelephonyManager = updatedTelephonyManager;
+
+ mTelephonyManager.listen(mPhoneStateListener,
+ PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE);
}
@Override
@@ -183,14 +196,14 @@
final Activity activity = getActivity();
mSubId = activity.getIntent().getIntExtra(SUB_ID,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
- mPhoneId = SubscriptionManager.getPhoneId(mSubId);
+ mPhoneId = SubscriptionUtil.getPhoneId(activity, mSubId);
mIntentFilter = new IntentFilter(
- TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
- mIntentFilter.addAction(TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED);
+ TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED);
setIfOnlyAvailableForAdmins(true);
mSubscriptionInfo = getSubscriptionInfo(mSubId);
+ mTelephonyManager = activity.getSystemService(TelephonyManager.class);
CarrierConfigManager configManager = (CarrierConfigManager)
getSystemService(Context.CARRIER_CONFIG_SERVICE);
@@ -235,6 +248,8 @@
getActivity().registerReceiver(mReceiver, mIntentFilter);
+ restartPhoneStateListener(mSubId);
+
if (!mRestoreDefaultApnMode) {
fillList();
}
@@ -249,6 +264,9 @@
}
getActivity().unregisterReceiver(mReceiver);
+
+ mTelephonyManager.listen(mPhoneStateListener,
+ PhoneStateListener.LISTEN_NONE);
}
@Override
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index 9007c0b..f0c1583 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -16,15 +16,18 @@
package com.android.settings.network;
+import static android.telephony.SubscriptionManager.INVALID_SIM_SLOT_INDEX;
import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT;
import static com.android.internal.util.CollectionUtils.emptyIfNull;
import android.content.Context;
+import android.os.ParcelUuid;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.UiccSlotInfo;
+import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
@@ -66,6 +69,12 @@
slotInfo.getCardStateInfo() == CARD_STATE_INFO_PRESENT;
}
+ /**
+ * Get all of the subscriptions which is available to display to the user.
+ *
+ * @param context {@code Context}
+ * @return list of {@code SubscriptionInfo}
+ */
public static List<SubscriptionInfo> getAvailableSubscriptions(Context context) {
if (sAvailableResultsForTesting != null) {
return sAvailableResultsForTesting;
@@ -73,12 +82,12 @@
final SubscriptionManager subMgr = context.getSystemService(SubscriptionManager.class);
final TelephonyManager telMgr = context.getSystemService(TelephonyManager.class);
- List<SubscriptionInfo> subscriptions =
+ final List<SubscriptionInfo> subscriptions =
new ArrayList<>(emptyIfNull(subMgr.getSelectableSubscriptionInfoList()));
// Look for inactive but present physical SIMs that are missing from the selectable list.
final List<UiccSlotInfo> missing = new ArrayList<>();
- UiccSlotInfo[] slotsInfo = telMgr.getUiccSlotsInfo();
+ final UiccSlotInfo[] slotsInfo = telMgr.getUiccSlotsInfo();
for (int i = 0; slotsInfo != null && i < slotsInfo.length; i++) {
final UiccSlotInfo slotInfo = slotsInfo[i];
if (isInactiveInsertedPSim(slotInfo)) {
@@ -92,20 +101,164 @@
}
}
}
- if (!missing.isEmpty()) {
- for (SubscriptionInfo info : subMgr.getAllSubscriptionInfoList()) {
- for (UiccSlotInfo slotInfo : missing) {
- if (info.getSimSlotIndex() == slotInfo.getLogicalSlotIdx() &&
- info.getCardString().equals(slotInfo.getCardId())) {
- subscriptions.add(info);
- break;
- }
+ if (missing.isEmpty()) {
+ return subscriptions;
+ }
+ for (SubscriptionInfo info : subMgr.getAllSubscriptionInfoList()) {
+ for (UiccSlotInfo slotInfo : missing) {
+ if (info.getSimSlotIndex() == slotInfo.getLogicalSlotIdx()
+ && info.getCardString().equals(slotInfo.getCardId())) {
+ subscriptions.add(info);
+ break;
}
}
}
return subscriptions;
}
+ /**
+ * Get subscription which is available to be displayed to the user
+ * per subscription id.
+ *
+ * @param context {@code Context}
+ * @param subscriptionManager The ProxySubscriptionManager for accessing subcription
+ * information
+ * @param subId The id of subscription to be retrieved
+ * @return {@code SubscriptionInfo} based on the given subscription id. Null of subscription
+ * is invalid or not allowed to be displayed to the user.
+ */
+ public static SubscriptionInfo getAvailableSubscription(Context context,
+ ProxySubscriptionManager subscriptionManager, int subId) {
+ final SubscriptionInfo subInfo = subscriptionManager.getAccessibleSubscriptionInfo(subId);
+ if (subInfo == null) {
+ return null;
+ }
+
+ final ParcelUuid groupUuid = subInfo.getGroupUuid();
+
+ if (groupUuid != null) {
+ if (isPrimarySubscriptionWithinSameUuid(getUiccSlotsInfo(context), groupUuid,
+ subscriptionManager.getAccessibleSubscriptionsInfo(), subId)) {
+ return subInfo;
+ }
+ return null;
+ }
+
+ if (subInfo.isEmbedded()) {
+ return subInfo;
+ }
+
+ // Look for physical SIM which presented in slots no mater active or not.
+ final UiccSlotInfo[] slotsInfo = getUiccSlotsInfo(context);
+ if (slotsInfo == null) {
+ return null;
+ }
+ for (UiccSlotInfo slotInfo : slotsInfo) {
+ if ((!slotInfo.getIsEuicc())
+ && (slotInfo.getCardStateInfo() == CARD_STATE_INFO_PRESENT)
+ && (slotInfo.getLogicalSlotIdx() == subInfo.getSimSlotIndex())
+ && TextUtils.equals(slotInfo.getCardId(), subInfo.getCardString())) {
+ return subInfo;
+ }
+ }
+ return null;
+ }
+
+ private static UiccSlotInfo [] getUiccSlotsInfo(Context context) {
+ final TelephonyManager telMgr = context.getSystemService(TelephonyManager.class);
+ return telMgr.getUiccSlotsInfo();
+ }
+
+ private static boolean isPrimarySubscriptionWithinSameUuid(UiccSlotInfo[] slotsInfo,
+ ParcelUuid groupUuid, List<SubscriptionInfo> subscriptions, int subId) {
+ // only interested in subscriptions with this group UUID
+ final ArrayList<SubscriptionInfo> physicalSubInfoList =
+ new ArrayList<SubscriptionInfo>();
+ final ArrayList<SubscriptionInfo> nonOpportunisticSubInfoList =
+ new ArrayList<SubscriptionInfo>();
+ final ArrayList<SubscriptionInfo> activeSlotSubInfoList =
+ new ArrayList<SubscriptionInfo>();
+ final ArrayList<SubscriptionInfo> inactiveSlotSubInfoList =
+ new ArrayList<SubscriptionInfo>();
+ for (SubscriptionInfo subInfo : subscriptions) {
+ if (groupUuid.equals(subInfo.getGroupUuid())) {
+ if (!subInfo.isEmbedded()) {
+ physicalSubInfoList.add(subInfo);
+ } else {
+ if (!subInfo.isOpportunistic()) {
+ nonOpportunisticSubInfoList.add(subInfo);
+ }
+ if (subInfo.getSimSlotIndex()
+ != SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
+ activeSlotSubInfoList.add(subInfo);
+ } else {
+ inactiveSlotSubInfoList.add(subInfo);
+ }
+ }
+ }
+ }
+
+ // find any physical SIM which is currently inserted within logical slot
+ // and which is our target subscription
+ if ((slotsInfo != null) && (physicalSubInfoList.size() > 0)) {
+ final SubscriptionInfo subInfo = searchForSubscriptionId(physicalSubInfoList, subId);
+ if (subInfo == null) {
+ return false;
+ }
+ // verify if subscription is inserted within slot
+ for (UiccSlotInfo slotInfo : slotsInfo) {
+ if ((slotInfo != null) && (!slotInfo.getIsEuicc())
+ && (slotInfo.getCardStateInfo() == CARD_STATE_INFO_PRESENT)
+ && (slotInfo.getLogicalSlotIdx() == subInfo.getSimSlotIndex())
+ && TextUtils.equals(slotInfo.getCardId(), subInfo.getCardString())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // When all of the eSIM profiles are opprtunistic and no physical SIM,
+ // first opportunistic subscriptions with same group UUID can be primary.
+ if (nonOpportunisticSubInfoList.size() <= 0) {
+ if (physicalSubInfoList.size() > 0) {
+ return false;
+ }
+ if (activeSlotSubInfoList.size() > 0) {
+ return (activeSlotSubInfoList.get(0).getSubscriptionId() == subId);
+ }
+ return (inactiveSlotSubInfoList.get(0).getSubscriptionId() == subId);
+ }
+
+ // Allow non-opportunistic + active eSIM subscription as primary
+ int numberOfActiveNonOpportunisticSubs = 0;
+ boolean isTargetNonOpportunistic = false;
+ for (SubscriptionInfo subInfo : nonOpportunisticSubInfoList) {
+ final boolean isTargetSubInfo = (subInfo.getSubscriptionId() == subId);
+ if (subInfo.getSimSlotIndex() != SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
+ if (isTargetSubInfo) {
+ return true;
+ }
+ numberOfActiveNonOpportunisticSubs++;
+ } else {
+ isTargetNonOpportunistic |= isTargetSubInfo;
+ }
+ }
+ if (numberOfActiveNonOpportunisticSubs > 0) {
+ return false;
+ }
+ return isTargetNonOpportunistic;
+ }
+
+ private static SubscriptionInfo searchForSubscriptionId(List<SubscriptionInfo> subInfoList,
+ int subscriptionId) {
+ for (SubscriptionInfo subInfo : subInfoList) {
+ if (subInfo.getSubscriptionId() == subscriptionId) {
+ return subInfo;
+ }
+ }
+ return null;
+ }
+
public static String getDisplayName(SubscriptionInfo info) {
final CharSequence name = info.getDisplayName();
if (name != null) {
@@ -113,4 +266,26 @@
}
return "";
}
+
+ /**
+ * Whether Settings should show a "Use SIM" toggle in pSIM detailed page.
+ */
+ public static boolean showToggleForPhysicalSim(SubscriptionManager subMgr) {
+ return subMgr.canDisablePhysicalSubscription();
+ }
+
+ /**
+ * Get phoneId or logical slot index for a subId if active, or INVALID_PHONE_INDEX if inactive.
+ */
+ public static int getPhoneId(Context context, int subId) {
+ final SubscriptionManager subManager = context.getSystemService(SubscriptionManager.class);
+ if (subManager == null) {
+ return INVALID_SIM_SLOT_INDEX;
+ }
+ final SubscriptionInfo info = subManager.getActiveSubscriptionInfo(subId);
+ if (info == null) {
+ return INVALID_SIM_SLOT_INDEX;
+ }
+ return info.getSimSlotIndex();
+ }
}
diff --git a/src/com/android/settings/network/telephony/CellInfoUtil.java b/src/com/android/settings/network/telephony/CellInfoUtil.java
index def81a1..7ea2ae4 100644
--- a/src/com/android/settings/network/telephony/CellInfoUtil.java
+++ b/src/com/android/settings/network/telephony/CellInfoUtil.java
@@ -33,6 +33,7 @@
import com.android.internal.telephony.OperatorInfo;
+import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -150,7 +151,7 @@
mcc,
mnc,
operatorInfo.getOperatorAlphaLong(),
- operatorInfo.getOperatorAlphaShort());
+ operatorInfo.getOperatorAlphaShort(), Collections.emptyList());
CellInfoGsm ci = new CellInfoGsm();
ci.setCellIdentity(cig);
diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index 675a1ba..f7ed1d0 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -26,12 +26,12 @@
import android.os.PersistableBundle;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
-import android.telephony.RadioAccessFamily;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
+
import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
@@ -42,6 +42,7 @@
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
+import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
import com.android.settings.R;
import java.util.ArrayList;
@@ -194,18 +195,18 @@
R.array.enabled_networks_cdma_values);
} else {
switch (settingsNetworkMode) {
- case TelephonyManager.NETWORK_MODE_CDMA_EVDO:
- case TelephonyManager.NETWORK_MODE_CDMA_NO_EVDO:
- case TelephonyManager.NETWORK_MODE_EVDO_NO_CDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_CDMA_EVDO:
+ case TelephonyManagerConstants.NETWORK_MODE_CDMA_NO_EVDO:
+ case TelephonyManagerConstants.NETWORK_MODE_EVDO_NO_CDMA:
preference.setEntries(
R.array.enabled_networks_cdma_no_lte_choices);
preference.setEntryValues(
R.array.enabled_networks_cdma_no_lte_values);
break;
- case TelephonyManager.NETWORK_MODE_GLOBAL:
- case TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO:
- case TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA:
- case TelephonyManager.NETWORK_MODE_LTE_ONLY:
+ case TelephonyManagerConstants.NETWORK_MODE_GLOBAL:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_ONLY:
preference.setEntries(
R.array.enabled_networks_cdma_only_lte_choices);
preference.setEntryValues(
@@ -279,7 +280,7 @@
}
/***
- * Preferred network list add 5G item.
+ * Generate preferred network choices list for 5G
*
* @string/enabled_networks_cdma_choices
* Before | After
@@ -364,9 +365,9 @@
new5gEntryValue = transformLteEntryValueTo5gEntryValue(oldEntryValue);
} else if (mContext.getString(R.string.network_global).equals(oldEntry)) {
//oldEntry: network_global
- //oldEntryValue: TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA
+ //oldEntryValue: TelephonyManagerConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA
oldEntryValue = Integer.toString(
- TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
}
if (!TextUtils.isEmpty(new5gEntry)) {
@@ -382,124 +383,151 @@
}
/**
- * LTE network mode transform to 5G network mode.
+ * transform LTE network mode to 5G network mode.
*
- * @param networkMode this is LTE network mode.
- * @return 5G network mode.
+ * @param networkMode an LTE network mode without 5G.
+ * @return the corresponding network mode with 5G.
*/
private CharSequence transformLteEntryValueTo5gEntryValue(CharSequence networkMode) {
int networkModeInt = Integer.valueOf(networkMode.toString());
- return Integer.toString(addNrToNetworkType(networkModeInt));
+ return Integer.toString(addNrToLteNetworkType(networkModeInt));
+ }
+ private int addNrToLteNetworkType(int networkType) {
+ switch(networkType) {
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_ONLY:
+ return TelephonyManagerConstants.NETWORK_MODE_NR_LTE;
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO:
+ return TelephonyManagerConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO;
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA:
+ return TelephonyManagerConstants.NETWORK_MODE_NR_LTE_GSM_WCDMA;
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA:
+ return TelephonyManagerConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA;
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_WCDMA:
+ return TelephonyManagerConstants.NETWORK_MODE_NR_LTE_WCDMA;
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA:
+ return TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA;
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_GSM:
+ return TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM;
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_WCDMA:
+ return TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA;
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA:
+ return TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA;
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA:
+ return TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA;
+ default:
+ return networkType; // not LTE
+ }
}
- private int addNrToNetworkType(int networkType) {
- long networkTypeBitmasks = RadioAccessFamily.getRafFromNetworkType(networkType);
- networkTypeBitmasks |= mTelephonyManager.NETWORK_TYPE_BITMASK_NR;
- return RadioAccessFamily.getNetworkTypeFromRaf((int) networkTypeBitmasks);
- }
-
+ /**
+ * Sets the display string for the network mode choice and selects the corresponding item
+ *
+ * @param preference ListPreference for selecting the preferred network mode.
+ * @param networkMode the current network mode. The current mode might not be an option in the
+ * choice list. The nearest choice is selected instead
+ */
private void updatePreferenceValueAndSummary(ListPreference preference, int networkMode) {
preference.setValue(Integer.toString(networkMode));
switch (networkMode) {
- case TelephonyManager.NETWORK_MODE_TDSCDMA_WCDMA:
- case TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA:
- case TelephonyManager.NETWORK_MODE_TDSCDMA_GSM:
+ case TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM:
preference.setValue(
- Integer.toString(TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA));
+ Integer.toString(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA));
preference.setSummary(R.string.network_3G);
break;
- case TelephonyManager.NETWORK_MODE_WCDMA_ONLY:
- case TelephonyManager.NETWORK_MODE_GSM_UMTS:
- case TelephonyManager.NETWORK_MODE_WCDMA_PREF:
+ case TelephonyManagerConstants.NETWORK_MODE_WCDMA_ONLY:
+ case TelephonyManagerConstants.NETWORK_MODE_GSM_UMTS:
+ case TelephonyManagerConstants.NETWORK_MODE_WCDMA_PREF:
if (!mIsGlobalCdma) {
- preference.setValue(Integer.toString(TelephonyManager.NETWORK_MODE_WCDMA_PREF));
+ preference.setValue(Integer.toString(TelephonyManagerConstants.NETWORK_MODE_WCDMA_PREF));
preference.setSummary(R.string.network_3G);
} else {
- preference.setValue(Integer.toString(TelephonyManager
+ preference.setValue(Integer.toString(TelephonyManagerConstants
.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA));
preference.setSummary(R.string.network_global);
}
break;
- case TelephonyManager.NETWORK_MODE_GSM_ONLY:
+ case TelephonyManagerConstants.NETWORK_MODE_GSM_ONLY:
if (!mIsGlobalCdma) {
preference.setValue(
- Integer.toString(TelephonyManager.NETWORK_MODE_GSM_ONLY));
+ Integer.toString(TelephonyManagerConstants.NETWORK_MODE_GSM_ONLY));
preference.setSummary(R.string.network_2G);
} else {
preference.setValue(
- Integer.toString(TelephonyManager
+ Integer.toString(TelephonyManagerConstants
.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA));
preference.setSummary(R.string.network_global);
}
break;
- case TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA:
if (MobileNetworkUtils.isWorldMode(mContext, mSubId)) {
preference.setSummary(
R.string.preferred_network_mode_lte_gsm_umts_summary);
break;
}
- case TelephonyManager.NETWORK_MODE_LTE_ONLY:
- case TelephonyManager.NETWORK_MODE_LTE_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_ONLY:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_WCDMA:
if (!mIsGlobalCdma) {
preference.setValue(
- Integer.toString(TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA));
+ Integer.toString(TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA));
preference.setSummary(
mShow4GForLTE ? R.string.network_4G : R.string.network_lte);
} else {
preference.setValue(
- Integer.toString(TelephonyManager
+ Integer.toString(TelephonyManagerConstants
.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA));
preference.setSummary(R.string.network_global);
}
break;
- case TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO:
if (MobileNetworkUtils.isWorldMode(mContext, mSubId)) {
preference.setSummary(
R.string.preferred_network_mode_lte_cdma_summary);
} else {
preference.setValue(
- Integer.toString(TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO));
+ Integer.toString(TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO));
preference.setSummary(
mDisplay5gList ? R.string.network_lte_pure : R.string.network_lte);
}
break;
- case TelephonyManager.NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA:
- preference.setValue(Integer.toString(TelephonyManager
+ case TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA:
+ preference.setValue(Integer.toString(TelephonyManagerConstants
.NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA));
preference.setSummary(R.string.network_3G);
break;
- case TelephonyManager.NETWORK_MODE_CDMA_EVDO:
- case TelephonyManager.NETWORK_MODE_EVDO_NO_CDMA:
- case TelephonyManager.NETWORK_MODE_GLOBAL:
+ case TelephonyManagerConstants.NETWORK_MODE_CDMA_EVDO:
+ case TelephonyManagerConstants.NETWORK_MODE_EVDO_NO_CDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_GLOBAL:
preference.setValue(
- Integer.toString(TelephonyManager.NETWORK_MODE_CDMA_EVDO));
+ Integer.toString(TelephonyManagerConstants.NETWORK_MODE_CDMA_EVDO));
preference.setSummary(R.string.network_3G);
break;
- case TelephonyManager.NETWORK_MODE_CDMA_NO_EVDO:
+ case TelephonyManagerConstants.NETWORK_MODE_CDMA_NO_EVDO:
preference.setValue(
- Integer.toString(TelephonyManager.NETWORK_MODE_CDMA_NO_EVDO));
+ Integer.toString(TelephonyManagerConstants.NETWORK_MODE_CDMA_NO_EVDO));
preference.setSummary(R.string.network_1x);
break;
- case TelephonyManager.NETWORK_MODE_TDSCDMA_ONLY:
+ case TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_ONLY:
preference.setValue(
- Integer.toString(TelephonyManager.NETWORK_MODE_TDSCDMA_ONLY));
+ Integer.toString(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_ONLY));
preference.setSummary(R.string.network_3G);
break;
- case TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM:
- case TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA:
- case TelephonyManager.NETWORK_MODE_LTE_TDSCDMA:
- case TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_WCDMA:
- case TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA:
- case TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_GSM:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA:
if (MobileNetworkUtils.isTdscdmaSupported(mContext, mSubId)) {
preference.setValue(
- Integer.toString(TelephonyManager
+ Integer.toString(TelephonyManagerConstants
.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA));
preference.setSummary(
mDisplay5gList ? R.string.network_lte_pure : R.string.network_lte);
} else {
preference.setValue(
- Integer.toString(TelephonyManager
+ Integer.toString(TelephonyManagerConstants
.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA));
if (mTelephonyManager.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA
|| mIsGlobalCdma
@@ -516,15 +544,15 @@
}
}
break;
- case TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO:
- case TelephonyManager.NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO:
+ case TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA:
preference.setValue(Integer.toString(networkMode));
preference.setSummary(mContext.getString(R.string.network_5G)
+ mContext.getString(R.string.network_recommended));
break;
- case TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA:
preference.setValue(
- Integer.toString(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA));
+ Integer.toString(TelephonyManagerConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA));
if (mTelephonyManager.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA
|| mIsGlobalCdma
|| MobileNetworkUtils.isWorldMode(mContext, mSubId)) {
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 73d964a..a4fa845 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -56,6 +56,7 @@
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
import com.android.settingslib.development.DevelopmentSettingsEnabler;
import com.android.settingslib.graph.SignalDrawable;
@@ -305,8 +306,8 @@
context.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
Phone.PREFERRED_NT_MODE);
- if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA
- || settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO) {
+ if (settingsNetworkMode == TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA
+ || settingsNetworkMode == TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO) {
return true;
}
@@ -333,8 +334,8 @@
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
Phone.PREFERRED_NT_MODE);
if (isWorldMode(context, subId)) {
- if (networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
- || networkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
+ if (networkMode == TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO
+ || networkMode == TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA) {
return true;
} else if (shouldSpeciallyUpdateGsmCdma(context, subId)) {
return true;
@@ -397,7 +398,7 @@
context.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
Phone.PREFERRED_NT_MODE);
- if (networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
+ if (networkMode == TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO
&& isWorldMode(context, subId)) {
return false;
}
@@ -410,7 +411,7 @@
}
if (isWorldMode(context, subId)) {
- if (networkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
+ if (networkMode == TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA) {
return true;
}
}
@@ -515,12 +516,12 @@
context.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
Phone.PREFERRED_NT_MODE);
- if (networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM
- || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA
- || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA
- || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_WCDMA
- || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA
- || networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA) {
+ if (networkMode == TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_GSM
+ || networkMode == TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA
+ || networkMode == TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA
+ || networkMode == TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_WCDMA
+ || networkMode == TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA
+ || networkMode == TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA) {
if (!isTdscdmaSupported(context, subId) && isWorldMode(context, subId)) {
return true;
}
diff --git a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
index 89e2d5b8..72be4f4 100644
--- a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
@@ -29,6 +29,7 @@
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.settings.R;
+import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
/**
* Preference controller for "Preferred network mode"
@@ -113,48 +114,48 @@
private int getPreferredNetworkModeSummaryResId(int NetworkMode) {
switch (NetworkMode) {
- case TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA:
return R.string.preferred_network_mode_tdscdma_gsm_wcdma_summary;
- case TelephonyManager.NETWORK_MODE_TDSCDMA_GSM:
+ case TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM:
return R.string.preferred_network_mode_tdscdma_gsm_summary;
- case TelephonyManager.NETWORK_MODE_WCDMA_PREF:
+ case TelephonyManagerConstants.NETWORK_MODE_WCDMA_PREF:
return R.string.preferred_network_mode_wcdma_perf_summary;
- case TelephonyManager.NETWORK_MODE_GSM_ONLY:
+ case TelephonyManagerConstants.NETWORK_MODE_GSM_ONLY:
return R.string.preferred_network_mode_gsm_only_summary;
- case TelephonyManager.NETWORK_MODE_TDSCDMA_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_WCDMA:
return R.string.preferred_network_mode_tdscdma_wcdma_summary;
- case TelephonyManager.NETWORK_MODE_WCDMA_ONLY:
+ case TelephonyManagerConstants.NETWORK_MODE_WCDMA_ONLY:
return R.string.preferred_network_mode_wcdma_only_summary;
- case TelephonyManager.NETWORK_MODE_GSM_UMTS:
+ case TelephonyManagerConstants.NETWORK_MODE_GSM_UMTS:
return R.string.preferred_network_mode_gsm_wcdma_summary;
- case TelephonyManager.NETWORK_MODE_CDMA_EVDO:
+ case TelephonyManagerConstants.NETWORK_MODE_CDMA_EVDO:
switch (mTelephonyManager.getLteOnCdmaMode()) {
case PhoneConstants.LTE_ON_CDMA_TRUE:
return R.string.preferred_network_mode_cdma_summary;
default:
return R.string.preferred_network_mode_cdma_evdo_summary;
}
- case TelephonyManager.NETWORK_MODE_CDMA_NO_EVDO:
+ case TelephonyManagerConstants.NETWORK_MODE_CDMA_NO_EVDO:
return R.string.preferred_network_mode_cdma_only_summary;
- case TelephonyManager.NETWORK_MODE_EVDO_NO_CDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_EVDO_NO_CDMA:
return R.string.preferred_network_mode_evdo_only_summary;
- case TelephonyManager.NETWORK_MODE_LTE_TDSCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA:
return R.string.preferred_network_mode_lte_tdscdma_summary;
- case TelephonyManager.NETWORK_MODE_LTE_ONLY:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_ONLY:
return R.string.preferred_network_mode_lte_summary;
- case TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_GSM:
return R.string.preferred_network_mode_lte_tdscdma_gsm_summary;
- case TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA:
return R.string.preferred_network_mode_lte_tdscdma_gsm_wcdma_summary;
- case TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA:
return R.string.preferred_network_mode_lte_gsm_wcdma_summary;
- case TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO:
return R.string.preferred_network_mode_lte_cdma_evdo_summary;
- case TelephonyManager.NETWORK_MODE_TDSCDMA_ONLY:
+ case TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_ONLY:
return R.string.preferred_network_mode_tdscdma_summary;
- case TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA:
return R.string.preferred_network_mode_lte_tdscdma_cdma_evdo_gsm_wcdma_summary;
- case TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA:
if (mTelephonyManager.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA
|| mIsGlobalCdma
|| MobileNetworkUtils.isWorldMode(mContext, mSubId)) {
@@ -162,13 +163,13 @@
} else {
return R.string.preferred_network_mode_lte_summary;
}
- case TelephonyManager.NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA:
return R.string.preferred_network_mode_tdscdma_cdma_evdo_gsm_wcdma_summary;
- case TelephonyManager.NETWORK_MODE_GLOBAL:
+ case TelephonyManagerConstants.NETWORK_MODE_GLOBAL:
return R.string.preferred_network_mode_cdma_evdo_gsm_wcdma_summary;
- case TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_WCDMA:
return R.string.preferred_network_mode_lte_tdscdma_wcdma_summary;
- case TelephonyManager.NETWORK_MODE_LTE_WCDMA:
+ case TelephonyManagerConstants.NETWORK_MODE_LTE_WCDMA:
return R.string.preferred_network_mode_lte_wcdma_summary;
default:
return R.string.preferred_network_mode_global_summary;
diff --git a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
index a0c9859..38db43e 100644
--- a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
+++ b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
@@ -200,7 +200,7 @@
private Color[] getColors() {
final Resources res = getContext().getResources();
- final int[] colorInts = res.getIntArray(com.android.internal.R.array.sim_colors);
+ final int[] colorInts = res.getIntArray(android.R.array.simColors);
final String[] colorStrings = res.getStringArray(R.array.color_picker);
final int iconSize = res.getDimensionPixelSize(R.dimen.color_swatch_size);
final int strokeWidth = res.getDimensionPixelSize(R.dimen.color_swatch_stroke_width);
diff --git a/src/com/android/settings/network/telephony/TelephonyConstants.java b/src/com/android/settings/network/telephony/TelephonyConstants.java
new file mode 100644
index 0000000..cfae572
--- /dev/null
+++ b/src/com/android/settings/network/telephony/TelephonyConstants.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.network.telephony;
+
+
+/**
+ * Contains hidden constants copied from the platform.
+ */
+public class TelephonyConstants {
+
+ /**
+ * Copied from {@link android.telephony.TelephonyManager}
+ */
+ public static class TelephonyManagerConstants {
+
+ // Network modes are in turn copied from RILConstants
+ // with one difference: NETWORK_MODE_CDMA is named NETWORK_MODE_CDMA_EVDO
+
+ /** GSM, WCDMA (WCDMA preferred) */
+ public static final int NETWORK_MODE_WCDMA_PREF = 0;
+
+ /** GSM only */
+ public static final int NETWORK_MODE_GSM_ONLY = 1;
+
+ /** WCDMA only */
+ public static final int NETWORK_MODE_WCDMA_ONLY = 2;
+
+ /** GSM, WCDMA (auto mode, according to PRL) */
+ public static final int NETWORK_MODE_GSM_UMTS = 3;
+
+ /** CDMA and EvDo (auto mode, according to PRL)
+ * this is NETWORK_MODE_CDMA in RILConstants.java
+ */
+ public static final int NETWORK_MODE_CDMA_EVDO = 4;
+
+ /** CDMA only */
+ public static final int NETWORK_MODE_CDMA_NO_EVDO = 5;
+
+ /** EvDo only */
+ public static final int NETWORK_MODE_EVDO_NO_CDMA = 6;
+
+ /** GSM, WCDMA, CDMA, and EvDo (auto mode, according to PRL) */
+ public static final int NETWORK_MODE_GLOBAL = 7;
+
+ /** LTE, CDMA and EvDo */
+ public static final int NETWORK_MODE_LTE_CDMA_EVDO = 8;
+
+ /** LTE, GSM and WCDMA */
+ public static final int NETWORK_MODE_LTE_GSM_WCDMA = 9;
+
+ /** LTE, CDMA, EvDo, GSM, and WCDMA */
+ public static final int NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA = 10;
+
+ /** LTE only mode. */
+ public static final int NETWORK_MODE_LTE_ONLY = 11;
+
+ /** LTE and WCDMA */
+ public static final int NETWORK_MODE_LTE_WCDMA = 12;
+
+ /** TD-SCDMA only */
+ public static final int NETWORK_MODE_TDSCDMA_ONLY = 13;
+
+ /** TD-SCDMA and WCDMA */
+ public static final int NETWORK_MODE_TDSCDMA_WCDMA = 14;
+
+ /** LTE and TD-SCDMA*/
+ public static final int NETWORK_MODE_LTE_TDSCDMA = 15;
+
+ /** TD-SCDMA and GSM */
+ public static final int NETWORK_MODE_TDSCDMA_GSM = 16;
+
+ /** TD-SCDMA, GSM and LTE */
+ public static final int NETWORK_MODE_LTE_TDSCDMA_GSM = 17;
+
+ /** TD-SCDMA, GSM and WCDMA */
+ public static final int NETWORK_MODE_TDSCDMA_GSM_WCDMA = 18;
+
+ /** LTE, TD-SCDMA and WCDMA */
+ public static final int NETWORK_MODE_LTE_TDSCDMA_WCDMA = 19;
+
+ /** LTE, TD-SCDMA, GSM, and WCDMA */
+ public static final int NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA = 20;
+
+ /** TD-SCDMA, CDMA, EVDO, GSM and WCDMA */
+ public static final int NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA = 21;
+
+ /** LTE, TDCSDMA, CDMA, EVDO, GSM and WCDMA */
+ public static final int NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA = 22;
+
+ /** NR 5G only mode */
+ public static final int NETWORK_MODE_NR_ONLY = 23;
+
+ /** NR 5G, LTE */
+ public static final int NETWORK_MODE_NR_LTE = 24;
+
+ /** NR 5G, LTE, CDMA and EvDo */
+ public static final int NETWORK_MODE_NR_LTE_CDMA_EVDO = 25;
+
+ /** NR 5G, LTE, GSM and WCDMA */
+ public static final int NETWORK_MODE_NR_LTE_GSM_WCDMA = 26;
+
+ /** NR 5G, LTE, CDMA, EvDo, GSM and WCDMA */
+ public static final int NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA = 27;
+
+ /** NR 5G, LTE and WCDMA */
+ public static final int NETWORK_MODE_NR_LTE_WCDMA = 28;
+
+ /** NR 5G, LTE and TDSCDMA */
+ public static final int NETWORK_MODE_NR_LTE_TDSCDMA = 29;
+
+ /** NR 5G, LTE, TD-SCDMA and GSM */
+ public static final int NETWORK_MODE_NR_LTE_TDSCDMA_GSM = 30;
+
+ /** NR 5G, LTE, TD-SCDMA, WCDMA */
+ public static final int NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA = 31;
+
+ /** NR 5G, LTE, TD-SCDMA, GSM and WCDMA */
+ public static final int NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA = 32;
+
+ /** NR 5G, LTE, TD-SCDMA, CDMA, EVDO, GSM and WCDMA */
+ public static final int NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA = 33;
+ }
+
+
+}
diff --git a/src/com/android/settings/network/telephony/cdma/CdmaSystemSelectPreferenceController.java b/src/com/android/settings/network/telephony/cdma/CdmaSystemSelectPreferenceController.java
index 5f259f8..c988bf8 100644
--- a/src/com/android/settings/network/telephony/cdma/CdmaSystemSelectPreferenceController.java
+++ b/src/com/android/settings/network/telephony/cdma/CdmaSystemSelectPreferenceController.java
@@ -24,6 +24,7 @@
import androidx.preference.Preference;
import com.android.internal.telephony.Phone;
+import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
/**
* Preference controller for "System Select"
@@ -54,7 +55,7 @@
Settings.Global.PREFERRED_NETWORK_MODE + mSubId,
Phone.PREFERRED_NT_MODE);
listPreference.setEnabled(
- settingsNetworkMode != TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
+ settingsNetworkMode != TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
}
@Override
diff --git a/src/com/android/settings/sim/SimPreferenceDialog.java b/src/com/android/settings/sim/SimPreferenceDialog.java
index 0f22d2b..1ed48c0 100644
--- a/src/com/android/settings/sim/SimPreferenceDialog.java
+++ b/src/com/android/settings/sim/SimPreferenceDialog.java
@@ -65,7 +65,7 @@
mSlotId = extras.getInt(SimSettings.EXTRA_SLOT_ID, -1);
mSubscriptionManager = SubscriptionManager.from(mContext);
mSubInfoRecord = mSubscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(mSlotId);
- mTintArr = mContext.getResources().getIntArray(com.android.internal.R.array.sim_colors);
+ mTintArr = mContext.getResources().getIntArray(android.R.array.simColors);
mColorStrings = mContext.getResources().getStringArray(R.array.color_picker);
mTintSelectorPos = 0;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsButtonsControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsButtonsControllerTest.java
index eaa4c3c..f52685c 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsButtonsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsButtonsControllerTest.java
@@ -22,7 +22,6 @@
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -103,7 +102,7 @@
verify(mButtonsPref).setButton2Text(R.string.bluetooth_device_context_connect);
mConnectButton.callOnClick();
- verify(mCachedDevice).connect(eq(true));
+ verify(mCachedDevice).connect();
}
@Test
@@ -119,7 +118,7 @@
// Click the button and make sure that connect (not disconnect) gets called.
mConnectButton.callOnClick();
- verify(mCachedDevice).connect(eq(true));
+ verify(mCachedDevice).connect();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
index ac7692d..89604a9 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
@@ -121,6 +121,6 @@
public void onClick_Preference_setConnect() {
mBluetoothDeviceUpdater.onPreferenceClick(mPreference);
- verify(mCachedBluetoothDevice).connect(true);
+ verify(mCachedBluetoothDevice).connect();
}
}
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothMapVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothMapVersionPreferenceControllerTest.java
new file mode 100644
index 0000000..0a7d6e8
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/BluetoothMapVersionPreferenceControllerTest.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import static com.android.settings.development.BluetoothMapVersionPreferenceController
+ .BLUETOOTH_MAP_VERSION_PROPERTY;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.os.SystemProperties;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class BluetoothMapVersionPreferenceControllerTest {
+
+ @Mock
+ private ListPreference mPreference;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+
+ private Context mContext;
+ private BluetoothMapVersionPreferenceController mController;
+
+ /**
+ * 0: MAP 1.2 (Default)
+ * 1: MAP 1.3
+ * 2: MAP 1.4
+ */
+ private String[] mListValues;
+ private String[] mListSummaries;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ final Resources resources = mContext.getResources();
+ mListValues = resources.getStringArray(R.array.bluetooth_map_version_values);
+ mListSummaries = resources.getStringArray(R.array.bluetooth_map_versions);
+ mController = new BluetoothMapVersionPreferenceController(mContext);
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void onPreferenceChange_setMap13_shouldEnableMap13() {
+ mController.onPreferenceChange(mPreference, mListValues[1]);
+
+ final String currentValue = SystemProperties.get(BLUETOOTH_MAP_VERSION_PROPERTY);
+
+ assertThat(currentValue).isEqualTo(mListValues[1]);
+ }
+
+ @Test
+ public void onPreferenceChange_setMap14_shouldEnableMap14() {
+ mController.onPreferenceChange(mPreference, mListValues[2]);
+
+ final String currentValue = SystemProperties.get(BLUETOOTH_MAP_VERSION_PROPERTY);
+
+ assertThat(currentValue).isEqualTo(mListValues[2]);
+ }
+
+
+ @Test
+ public void updateState_setMap13_shouldSetPreferenceToMap13() {
+ SystemProperties.set(BLUETOOTH_MAP_VERSION_PROPERTY, mListValues[1]);
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setValue(mListValues[1]);
+ verify(mPreference).setSummary(mListSummaries[1]);
+ }
+
+ @Test
+ public void updateState_setMap14_shouldSetPreferenceToMap14() {
+ SystemProperties.set(BLUETOOTH_MAP_VERSION_PROPERTY, mListValues[2]);
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setValue(mListValues[2]);
+ verify(mPreference).setSummary(mListSummaries[2]);
+ }
+
+ @Test
+ public void updateState_noValueSet_shouldSetDefaultToMap12() {
+ mController.updateState(mPreference);
+
+ verify(mPreference).setValue(mListValues[0]);
+ verify(mPreference).setSummary(mListSummaries[0]);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
index 693ed45..e558d62 100644
--- a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
+++ b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
@@ -16,16 +16,23 @@
package com.android.settings.development.compat;
+import static com.android.internal.compat.OverrideAllowedState.ALLOWED;
+import static com.android.internal.compat.OverrideAllowedState.DISABLED_NOT_DEBUGGABLE;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import android.compat.Compatibility.ChangeConfig;
import android.content.Context;
import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.drawable.Drawable;
import android.os.RemoteException;
@@ -38,7 +45,9 @@
import com.android.internal.compat.CompatibilityChangeConfig;
import com.android.internal.compat.CompatibilityChangeInfo;
+import com.android.internal.compat.IOverrideValidator;
import com.android.internal.compat.IPlatformCompat;
+import com.android.internal.compat.OverrideAllowedState;
import com.android.settings.R;
import org.junit.Before;
@@ -66,6 +75,10 @@
private ApplicationInfo mApplicationInfo;
@Mock
private PreferenceManager mPreferenceManager;
+ @Mock
+ private IOverrideValidator mOverrideValidator;
+ @Mock
+ private PackageManager mPackageManager;
private Context mContext;
private CompatibilityChangeInfo[] mChanges;
@@ -81,16 +94,22 @@
mChanges[3] = new CompatibilityChangeInfo(4L, "Enabled_After_SDK_1_2", 1, false, "");
mChanges[4] = new CompatibilityChangeInfo(5L, "Enabled_After_SDK_2", 2, false, "");
when(mPlatformCompat.listAllChanges()).thenReturn(mChanges);
- mContext = RuntimeEnvironment.application;
+ when(mPlatformCompat.getOverrideValidator()).thenReturn(mOverrideValidator);
+ // By default, allow any change
+ when(mOverrideValidator.getOverrideAllowedState(anyLong(),anyString()))
+ .thenReturn(new OverrideAllowedState(ALLOWED, -1, -1));
+ mContext = spy(RuntimeEnvironment.application);
mPreferenceManager = new PreferenceManager(mContext);
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
mApplicationInfo.packageName = APP_NAME;
mDashboard = spy(new PlatformCompatDashboard());
mDashboard.mSelectedApp = APP_NAME;
doReturn(mApplicationInfo).when(mDashboard).getApplicationInfo();
+ doReturn(mContext).when(mDashboard).getContext();
doReturn(mPlatformCompat).when(mDashboard).getPlatformCompat();
doReturn(mPreferenceScreen).when(mDashboard).getPreferenceScreen();
doReturn(mPreferenceManager).when(mDashboard).getPreferenceManager();
+ doReturn(mPackageManager).when(mContext).getPackageManager();
}
@Test
@@ -107,10 +126,13 @@
@Test
public void createAppPreference_targetSdkEquals1_summaryReturnsAppNameAndTargetSdk() {
mApplicationInfo.targetSdkVersion = 1;
+ Drawable icon = mock(Drawable.class);
+ when(mApplicationInfo.loadIcon(any(PackageManager.class))).thenReturn(icon);
- Preference appPreference = mDashboard.createAppPreference(any(Drawable.class));
+ Preference appPreference = mDashboard.createAppPreference(mApplicationInfo);
- assertThat(appPreference.getSummary()).isEqualTo(APP_NAME + " SDK 1");
+ assertThat(appPreference.getSummary()).isEqualTo(mContext.getResources().getString(
+ R.string.platform_compat_selected_app_summary, APP_NAME, 1));
}
@Test
@@ -128,6 +150,7 @@
assertThat(enabledPreference.getSummary()).isEqualTo(mChanges[0].getName());
assertThat(enabledPreference instanceof SwitchPreference).isTrue();
assertThat(enabledSwitchPreference.isChecked()).isTrue();
+ assertThat(enabledSwitchPreference.isEnabled()).isTrue();
}
@Test
@@ -139,10 +162,32 @@
Preference disabledPreference = mDashboard.createPreferenceForChange(mContext,
disabledChange, config);
-
+
assertThat(disabledPreference.getSummary()).isEqualTo(mChanges[1].getName());
SwitchPreference disabledSwitchPreference = (SwitchPreference) disabledPreference;
assertThat(disabledSwitchPreference.isChecked()).isFalse();
+ assertThat(disabledSwitchPreference.isEnabled()).isTrue();
+ }
+
+ @Test
+ public void createPreferenceForChange_cannotOverride_createDisabledEntry()
+ throws RemoteException {
+ CompatibilityChangeInfo enabledChange = mChanges[0];
+ CompatibilityChangeConfig config = new CompatibilityChangeConfig(
+ new ChangeConfig(new HashSet<Long>(Arrays.asList(enabledChange.getId())),
+ new HashSet<Long>()));
+ when(mOverrideValidator.getOverrideAllowedState(anyLong(),anyString()))
+ .thenReturn(new OverrideAllowedState(DISABLED_NOT_DEBUGGABLE, -1, -1));
+
+ Preference preference = mDashboard.createPreferenceForChange(mContext, enabledChange,
+ config);
+
+ SwitchPreference switchPreference = (SwitchPreference) preference;
+
+ assertThat(preference.getSummary()).isEqualTo(mChanges[0].getName());
+ assertThat(preference instanceof SwitchPreference).isTrue();
+ assertThat(switchPreference.isChecked()).isTrue();
+ assertThat(switchPreference.isEnabled()).isFalse();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
index 782fb25..cc59f29 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
@@ -246,7 +246,8 @@
@Ignore
public void initialize_updateVoiceDataOutOfService_shouldUpdateSettingAndResetSignalStrength() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
- when(mServiceState.getDataRegState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
+ when(mServiceState.getDataRegistrationState()).thenReturn(
+ ServiceState.STATE_OUT_OF_SERVICE);
when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
@@ -261,7 +262,7 @@
@Ignore
public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateTextToBeInService() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
- when(mServiceState.getDataRegState()).thenReturn(ServiceState.STATE_IN_SERVICE);
+ when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE);
when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
@@ -311,7 +312,7 @@
@Ignore
public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateSignalStrengthTo50() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
- when(mServiceState.getDataRegState()).thenReturn(ServiceState.STATE_IN_SERVICE);
+ when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE);
when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java
index 773041d..ea96e29 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java
@@ -25,7 +25,6 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -45,6 +44,7 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
@@ -115,11 +115,12 @@
true);
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
- when(mServiceState.getDataRegState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
+ when(mServiceState.getDataRegistrationState()).thenReturn(
+ ServiceState.STATE_OUT_OF_SERVICE);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
- when(mServiceState.getDataRegState()).thenReturn(ServiceState.STATE_IN_SERVICE);
+ when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE);
when(mServiceState.getRoaming()).thenReturn(false);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
@@ -171,12 +172,12 @@
public void updateState_updateByNetworkMode() {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
- TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
mController.updateState(mPreference);
assertThat(mPreference.getValue()).isEqualTo(
- String.valueOf(TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA));
+ String.valueOf(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA));
assertThat(mPreference.getSummary()).isEqualTo("3G");
}
@@ -184,12 +185,12 @@
public void updateState_updateByNetworkMode_useDefaultValue() {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
- TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
mController.updateState(mPreference);
assertThat(mPreference.getValue()).isEqualTo(
- String.valueOf(TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA));
+ String.valueOf(TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA));
}
/**
@@ -392,27 +393,27 @@
@Test
public void onPreferenceChange_updateSuccess() {
doReturn(true).when(mTelephonyManager).setPreferredNetworkType(SUB_ID,
- TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
mController.onPreferenceChange(mPreference,
- String.valueOf(TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA));
+ String.valueOf(TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA));
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID, 0)).isEqualTo(
- TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
}
@Test
public void onPreferenceChange_updateFail() {
doReturn(false).when(mTelephonyManager).setPreferredNetworkType(SUB_ID,
- TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
mController.onPreferenceChange(mPreference,
- String.valueOf(TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA));
+ String.valueOf(TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA));
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID, 0)).isNotEqualTo(
- TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
}
@Test
@@ -421,24 +422,24 @@
doReturn(mPreference).when(screen).findPreference(KEY);
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
- TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
mController.displayPreference(screen);
mController.updateState(mPreference);
mLifecycle.handleLifecycleEvent(ON_START);
assertThat(Integer.parseInt(mPreference.getValue())).isEqualTo(
- TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
assertThat(mPreference.getSummary()).isEqualTo("3G");
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
- TelephonyManager.NETWORK_MODE_GSM_ONLY);
+ TelephonyManagerConstants.NETWORK_MODE_GSM_ONLY);
final Uri uri = Settings.Global.getUriFor(Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID);
mContext.getContentResolver().notifyChange(uri, null);
assertThat(Integer.parseInt(mPreference.getValue())).isEqualTo(
- TelephonyManager.NETWORK_MODE_GSM_ONLY);
+ TelephonyManagerConstants.NETWORK_MODE_GSM_ONLY);
assertThat(mPreference.getSummary()).isEqualTo("2G");
}
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
index bf1ee8a..b1ef202 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
@@ -41,6 +41,7 @@
import android.telephony.TelephonyManager;
import com.android.internal.telephony.PhoneConstants;
+import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
import org.junit.Before;
import org.junit.Test;
@@ -181,7 +182,7 @@
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
- TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
assertThat(MobileNetworkUtils.isCdmaOptions(mContext, SUB_ID_1)).isTrue();
}
@@ -255,7 +256,7 @@
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
- TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_GSM);
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
}
@@ -266,7 +267,7 @@
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
- TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA);
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
}
@@ -277,7 +278,7 @@
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
- TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA);
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
}
@@ -288,7 +289,7 @@
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
- TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_WCDMA);
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
}
@@ -299,7 +300,7 @@
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
- TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA);
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
}
@@ -310,7 +311,7 @@
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
- TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceControllerTest.java
index 9c03389..0d50e9e 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceControllerTest.java
@@ -33,10 +33,10 @@
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
-import androidx.fragment.app.FragmentManager;
import androidx.preference.ListPreference;
import com.android.settings.R;
+import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
import org.junit.Before;
import org.junit.Test;
@@ -110,11 +110,12 @@
true);
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
- when(mServiceState.getDataRegState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
+ when(mServiceState.getDataRegistrationState()).thenReturn(
+ ServiceState.STATE_OUT_OF_SERVICE);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
- when(mServiceState.getDataRegState()).thenReturn(ServiceState.STATE_IN_SERVICE);
+ when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE);
when(mServiceState.getRoaming()).thenReturn(false);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
@@ -127,12 +128,12 @@
public void updateState_updateByNetworkMode() {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
- TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
mController.updateState(mPreference);
assertThat(mPreference.getValue()).isEqualTo(
- String.valueOf(TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA));
+ String.valueOf(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA));
assertThat(mPreference.getSummary()).isEqualTo(
mContext.getString(R.string.preferred_network_mode_tdscdma_gsm_wcdma_summary));
}
@@ -140,26 +141,26 @@
@Test
public void onPreferenceChange_updateSuccess() {
doReturn(true).when(mTelephonyManager).setPreferredNetworkType(SUB_ID,
- TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA);
mController.onPreferenceChange(mPreference,
- String.valueOf(TelephonyManager.NETWORK_MODE_LTE_TDSCDMA));
+ String.valueOf(TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA));
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID, 0)).isEqualTo(
- TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA);
}
@Test
public void onPreferenceChange_updateFail() {
doReturn(false).when(mTelephonyManager).setPreferredNetworkType(SUB_ID,
- TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA);
mController.onPreferenceChange(mPreference,
- String.valueOf(TelephonyManager.NETWORK_MODE_LTE_TDSCDMA));
+ String.valueOf(TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA));
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID, 0)).isNotEqualTo(
- TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA);
}
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/cdma/CdmaSystemSelectPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/cdma/CdmaSystemSelectPreferenceControllerTest.java
index fee6099..1a7fd86 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/cdma/CdmaSystemSelectPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/cdma/CdmaSystemSelectPreferenceControllerTest.java
@@ -33,6 +33,8 @@
import androidx.preference.ListPreference;
import androidx.preference.PreferenceManager;
+import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -118,7 +120,7 @@
mTelephonyManager).getCdmaRoamingMode();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
- TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
+ TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
mController.updateState(mPreference);
diff --git a/tests/unit/src/com/android/settings/wifi/WifiCallingSettingUiTest.java b/tests/unit/src/com/android/settings/wifi/WifiCallingSettingUiTest.java
index 3198914..c3b63e8 100644
--- a/tests/unit/src/com/android/settings/wifi/WifiCallingSettingUiTest.java
+++ b/tests/unit/src/com/android/settings/wifi/WifiCallingSettingUiTest.java
@@ -30,6 +30,7 @@
import static org.junit.matchers.JUnitMatchers.containsString;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.doReturn;
import android.app.Activity;
@@ -106,7 +107,8 @@
.when(mSubscriptionController).queryLocalInterface(anyString());
mImsManagerInstances.put(0, mImsManager0);
mImsManagerInstances.put(1, mImsManager1);
- doReturn(mSils).when(mSubscriptionController).getActiveSubscriptionInfoList(anyString());
+ doReturn(mSils).when(mSubscriptionController).getActiveSubscriptionInfoList(anyString(),
+ nullable(String.class));
doReturn(0).when(mSubscriptionController).getPhoneId(0);
doReturn(1).when(mSubscriptionController).getPhoneId(1);
doReturn(0).when(mSubscriptionInfo0).getSubscriptionId();