Merge "[Settings] Code refactor"
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index a258cc6..75f46e5 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -1417,6 +1417,262 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_color_red">#d93025</color> <!-- Material Red 600 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="154"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_color_orange">#e8710a</color> <!-- Material Orange 600 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="155"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_color_yellow">#f9ab00</color> <!-- Material Yellow 600 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="156"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_color_green">#1e8e3e</color> <!-- Material Green 600 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="157"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_color_cyan">#12b5cb</color> <!-- Material Cyan 600 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="158"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_color_blue">#1a73e8</color> <!-- Material Blue 600 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="159"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_color_purple">#9334e6</color> <!-- Material Purple 600 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="160"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_color_pink">#e52592</color> <!-- Material Pink 600 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="161"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_dark_mode_color_red">#f28b82</color> <!-- Material Red 300 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="164"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_dark_mode_color_orange">#fcad70</color> <!-- Material Orange 300 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="165"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_dark_mode_color_yellow">#fdd663</color> <!-- Material Yellow 300 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="166"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_dark_mode_color_green">#81c995</color> <!-- Material Green 300 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="167"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_dark_mode_color_cyan">#78d9ec</color> <!-- Material Cyan 300 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="168"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_dark_mode_color_blue">#8AB4F8</color> <!-- Material Blue 300 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="169"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_dark_mode_color_purple">#c58af9</color> <!-- Material Purple 300 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="170"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="palette_list_dark_mode_color_pink">#ff8bcb</color> <!-- Material Pink 300 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="171"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" android:background="@color/lock_pattern_background" />"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -2621,7 +2877,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rAU/strings.xml"
- line="2663"
+ line="2689"
column="64"/>
</issue>
@@ -2637,7 +2893,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rCA/strings.xml"
- line="2663"
+ line="2689"
column="64"/>
</issue>
@@ -2653,7 +2909,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rGB/strings.xml"
- line="2663"
+ line="2689"
column="64"/>
</issue>
@@ -2669,7 +2925,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rIN/strings.xml"
- line="2663"
+ line="2689"
column="64"/>
</issue>
@@ -2685,7 +2941,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rXC/strings.xml"
- line="2663"
+ line="2689"
column="170"/>
</issue>
@@ -2701,7 +2957,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/strings.xml"
- line="6183"
+ line="6228"
column="36"/>
</issue>
diff --git a/res/drawable/signal_strength_5g.xml b/res/drawable/signal_strength_5g.xml
index fdaea7e..dc89f9a 100644
--- a/res/drawable/signal_strength_5g.xml
+++ b/res/drawable/signal_strength_5g.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2018 The Android Open Source Project
+ 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.
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index aca64fb..b8afd60 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -398,7 +398,8 @@
<dimen name="two_target_min_width">80dp</dimen>
<!-- Maximum height for SliceView, override on slices/view/src/main/res/values/dimens.xml -->
- <dimen name="abc_slice_large_height">480dp</dimen>
+ <!-- A single Row Slice height is 60dp -->
+ <dimen name="abc_slice_large_height">1200dp</dimen>
<!-- System navigation settings illustration height -->
<dimen name="system_navigation_illustration_height">320dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6589023..e68feb8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6968,6 +6968,8 @@
<string name="help_uri_apps_photography" translatable="false"></string>
<!-- Help URI, manage apps wifi access [DO NOT TRANSLATE] -->
<string name="help_uri_apps_wifi_access" translatable="false"></string>
+ <!-- Help URI, manage apps that have access to all files [DO NOT TRANSLATE] -->
+ <string name="help_uri_manage_external_storage" translatable="false"></string>
<!-- Help URI, Storage [DO NOT TRANSLATE] -->
<string name="help_uri_storage" translatable="false"></string>
<!-- Help URI, Accessibility [DO NOT TRANSLATE] -->
@@ -9445,6 +9447,16 @@
<!-- Description of allowing overlay setting [CHAR LIMIT=NONE] -->
<string name="allow_overlay_description">Allow this app to display on top of other apps you\u2019re using. It may interfere with your use of those apps or change the way they seem to appear or behave.</string>
+ <!-- Manager External Storage settings title [CHAR LIMIT=30] -->
+ <string name="manage_external_storage_title">All files access</string>
+ <!-- Label for a setting which controls whether an app can manage external storage [CHAR LIMIT=45] -->
+ <string name="permit_manage_external_storage">Allow access to manage all files</string>
+ <!-- Description for a setting which controls whether an app can manage external storage
+ [CHAR LIMIT=NONE] -->
+ <string name="allow_manage_external_storage_description">Allow this app to read, modify and delete all files on this device or any connected storage volumes. If granted, app may access files without your explicit knowledge.</string>
+ <!-- Label for showing apps that can manage external storage[CHAR LIMIT=45] -->
+ <string name="filter_manage_external_storage">Can access all files</string>
+
<!-- Keyword for VR setting -->
<string name="keywords_vr_listener">vr virtual reality listener stereo helper service</string>
<!-- Main settings screen item's title to go into the overlay settings screen [CHAR LIMIT=30] -->
diff --git a/res/xml/manage_external_storage_permission_details.xml b/res/xml/manage_external_storage_permission_details.xml
new file mode 100644
index 0000000..b540ff6
--- /dev/null
+++ b/res/xml/manage_external_storage_permission_details.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:key="manage_external_storage_permission_details"
+ android:title="@string/manage_external_storage_title">
+
+ <SwitchPreference
+ android:key="app_ops_settings_switch"
+ android:title="@string/permit_manage_external_storage"/>
+
+ <Preference
+ android:summary="@string/allow_manage_external_storage_description"
+ android:selectable="false"/>
+
+</PreferenceScreen>
diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml
index 25422bf..e511d17 100644
--- a/res/xml/special_access.xml
+++ b/res/xml/special_access.xml
@@ -21,6 +21,15 @@
android:title="@string/special_access">
<Preference
+ android:key="manage_external_storage"
+ android:title="@string/manage_external_storage_title"
+ android:fragment="com.android.settings.applications.manageapplications.ManageApplications">
+ <extra
+ android:name="classname"
+ android:value="com.android.settings.Settings$ManageExternalStorageActivity" />
+ </Preference>
+
+ <Preference
android:key="high_power_apps"
android:title="@string/high_power_apps"
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
diff --git a/src/com/android/settings/ResetNetworkConfirm.java b/src/com/android/settings/ResetNetworkConfirm.java
index ee11ce0..c4e4baf 100644
--- a/src/com/android/settings/ResetNetworkConfirm.java
+++ b/src/com/android/settings/ResetNetworkConfirm.java
@@ -47,12 +47,10 @@
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;
import com.android.settings.network.ApnSettings;
-import com.android.settings.network.SubscriptionUtil;
import com.android.settingslib.RestrictedLockUtilsInternal;
/**
@@ -127,8 +125,6 @@
}
}
- ImsManager.getInstance(mContext,
- SubscriptionUtil.getPhoneId(mContext, mSubId)).factoryReset();
restoreDefaultApn(mContext);
if (mEraseEsim) {
return RecoverySystem.wipeEuiccData(mContext, mPackageName);
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 50caf32..d5c0871 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -138,6 +138,7 @@
public static class MemorySettingsActivity extends SettingsActivity { /* empty */ }
public static class AppMemoryUsageActivity extends SettingsActivity { /* empty */ }
public static class OverlaySettingsActivity extends SettingsActivity { /* empty */ }
+ public static class ManageExternalStorageActivity extends SettingsActivity { /* empty */ }
public static class WriteSettingsActivity extends SettingsActivity { /* empty */ }
public static class ChangeWifiStateActivity extends SettingsActivity { /* empty */ }
public static class AppDrawOverlaySettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/applications/AppStateAppOpsBridge.java b/src/com/android/settings/applications/AppStateAppOpsBridge.java
index 0e3ee2d..3dbdbe9 100755
--- a/src/com/android/settings/applications/AppStateAppOpsBridge.java
+++ b/src/com/android/settings/applications/AppStateAppOpsBridge.java
@@ -328,7 +328,7 @@
public boolean isPermissible() {
// defining the default behavior as permissible as long as the package requested this
// permission (this means pre-M gets approval during install time; M apps gets approval
- // during runtime.
+ // during runtime).
if (appOpMode == AppOpsManager.MODE_DEFAULT) {
return staticPermissionGranted;
}
diff --git a/src/com/android/settings/applications/AppStateManageExternalStorageBridge.java b/src/com/android/settings/applications/AppStateManageExternalStorageBridge.java
new file mode 100644
index 0000000..5a69035
--- /dev/null
+++ b/src/com/android/settings/applications/AppStateManageExternalStorageBridge.java
@@ -0,0 +1,72 @@
+/*
+ * 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.applications;
+
+import android.Manifest;
+import android.app.AppOpsManager;
+import android.content.Context;
+
+import com.android.settingslib.applications.ApplicationsState;
+
+/**
+ * Retrieves information from {@link AppOpsManager} and {@link android.content.pm.PackageManager}
+ * regarding {@link AppOpsManager#OP_MANAGE_EXTERNAL_STORAGE} and
+ * {@link Manifest.permission#MANAGE_EXTERNAL_STORAGE}.
+ */
+public class AppStateManageExternalStorageBridge extends AppStateAppOpsBridge {
+ private static final int APP_OPS_OP_CODE = AppOpsManager.OP_MANAGE_EXTERNAL_STORAGE;
+ private static final String[] PERMISSIONS = {
+ Manifest.permission.MANAGE_EXTERNAL_STORAGE
+ };
+
+ public AppStateManageExternalStorageBridge(Context context, ApplicationsState appState,
+ Callback callback) {
+ super(context, appState, callback, APP_OPS_OP_CODE, PERMISSIONS);
+ }
+
+ @Override
+ protected void updateExtraInfo(ApplicationsState.AppEntry app, String pkg, int uid) {
+ app.extraInfo = getManageExternalStoragePermState(pkg, uid);
+ }
+
+ /**
+ * Returns the MANAGE_EXTERNAL_STORAGE {@link AppStateAppOpsBridge.PermissionState} object
+ * associated with the given package and user.
+ */
+ public PermissionState getManageExternalStoragePermState(String pkg, int uid) {
+ return getPermissionInfo(pkg, uid);
+ }
+
+ /**
+ * Used by {@link com.android.settings.applications.manageapplications.AppFilterRegistry} to
+ * determine which apps get to appear on the Special App Access list.
+ */
+ public static final ApplicationsState.AppFilter FILTER_MANAGE_EXTERNAL_STORAGE =
+ new ApplicationsState.AppFilter() {
+ @Override
+ public void init() {
+ }
+
+ @Override
+ public boolean filterApp(ApplicationsState.AppEntry info) {
+ // If extraInfo != null, it means that the app has declared
+ // Manifest.permission.MANAGE_EXTERNAL_STORAGE and therefore it should appear on our
+ // list
+ return info.extraInfo != null;
+ }
+ };
+}
diff --git a/src/com/android/settings/applications/appinfo/ManageExternalStorageDetails.java b/src/com/android/settings/applications/appinfo/ManageExternalStorageDetails.java
new file mode 100644
index 0000000..63ce440
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/ManageExternalStorageDetails.java
@@ -0,0 +1,180 @@
+/*
+ * 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.applications.appinfo;
+
+import android.app.AppOpsManager;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
+import androidx.preference.Preference;
+import androidx.preference.Preference.OnPreferenceChangeListener;
+import androidx.preference.Preference.OnPreferenceClickListener;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.R;
+import com.android.settings.applications.AppInfoWithHeader;
+import com.android.settings.applications.AppStateAppOpsBridge.PermissionState;
+import com.android.settings.applications.AppStateManageExternalStorageBridge;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+
+/**
+ * Class for displaying app info related to {@link AppOpsManager#OP_MANAGE_EXTERNAL_STORAGE}.
+ */
+public class ManageExternalStorageDetails extends AppInfoWithHeader implements
+ OnPreferenceChangeListener, OnPreferenceClickListener {
+
+ private static final String KEY_APP_OPS_SETTINGS_SWITCH = "app_ops_settings_switch";
+
+ private AppStateManageExternalStorageBridge mBridge;
+ private AppOpsManager mAppOpsManager;
+ private SwitchPreference mSwitchPref;
+ private PermissionState mPermissionState;
+ private MetricsFeatureProvider mMetricsFeatureProvider;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Context context = getActivity();
+ mBridge = new AppStateManageExternalStorageBridge(context, mState, null);
+ mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
+
+ // initialize preferences
+ addPreferencesFromResource(R.xml.manage_external_storage_permission_details);
+ mSwitchPref = findPreference(KEY_APP_OPS_SETTINGS_SWITCH);
+
+ // install event listeners
+ mSwitchPref.setOnPreferenceChangeListener(this);
+
+ mMetricsFeatureProvider =
+ FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider();
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater,
+ ViewGroup container,
+ Bundle savedInstanceState) {
+ // if we don't have a package info, show a page saying this is unsupported
+ if (mPackageInfo == null) {
+ return inflater.inflate(R.layout.manage_applications_apps_unsupported, null);
+ }
+ return super.onCreateView(inflater, container, savedInstanceState);
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ mBridge.release();
+ }
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ return false;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (preference == mSwitchPref) {
+ if (mPermissionState != null && !newValue.equals(mPermissionState.isPermissible())) {
+ setManageExternalStorageState((Boolean) newValue);
+ refreshUi();
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Toggles {@link AppOpsManager#OP_MANAGE_EXTERNAL_STORAGE} for the app.
+ */
+ private void setManageExternalStorageState(boolean newState) {
+ logSpecialPermissionChange(newState, mPackageName);
+ mAppOpsManager.setMode(AppOpsManager.OP_MANAGE_EXTERNAL_STORAGE,
+ mPackageInfo.applicationInfo.uid, mPackageName, newState
+ ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_ERRORED);
+ }
+
+ private void logSpecialPermissionChange(boolean newState, String packageName) {
+ int logCategory = newState ? SettingsEnums.APP_SPECIAL_PERMISSION_MANAGE_EXT_STRG_ALLOW
+ : SettingsEnums.APP_SPECIAL_PERMISSION_MANAGE_EXT_STRG_DENY;
+
+ mMetricsFeatureProvider.action(
+ mMetricsFeatureProvider.getAttribution(getActivity()),
+ logCategory,
+ getMetricsCategory(),
+ packageName,
+ 0 /* value */);
+ }
+
+ @Override
+ protected boolean refreshUi() {
+ if (mPackageInfo == null) {
+ return true;
+ }
+
+ mPermissionState = mBridge.getManageExternalStoragePermState(mPackageName,
+ mPackageInfo.applicationInfo.uid);
+
+ mSwitchPref.setChecked(mPermissionState.isPermissible());
+
+ // you cannot ask a user to grant you a permission you did not have!
+ mSwitchPref.setEnabled(mPermissionState.permissionDeclared);
+
+ return true;
+ }
+
+ @Override
+ protected AlertDialog createDialog(int id, int errorCode) {
+ return null;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.MANAGE_EXTERNAL_STORAGE;
+ }
+
+ /**
+ * Returns the string that states whether whether the app has access to
+ * {@link AppOpsManager#OP_MANAGE_EXTERNAL_STORAGE}.
+ * <p>This string is used in the "All files access" page that displays all apps requesting
+ * {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
+ */
+ public static CharSequence getSummary(Context context, AppEntry entry) {
+ final PermissionState state;
+ if (entry.extraInfo instanceof PermissionState) {
+ state = (PermissionState) entry.extraInfo;
+ } else {
+ state = new AppStateManageExternalStorageBridge(context, null, null)
+ .getManageExternalStoragePermState(entry.info.packageName, entry.info.uid);
+ }
+
+ return getSummary(context, state);
+ }
+
+ private static CharSequence getSummary(Context context, PermissionState state) {
+ return context.getString(state.isPermissible()
+ ? R.string.app_permission_summary_allowed
+ : R.string.app_permission_summary_not_allowed);
+ }
+}
diff --git a/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java b/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
index 250dce0..58907a7 100644
--- a/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
+++ b/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
@@ -20,6 +20,7 @@
import com.android.settings.R;
import com.android.settings.applications.AppStateInstallAppsBridge;
+import com.android.settings.applications.AppStateManageExternalStorageBridge;
import com.android.settings.applications.AppStateNotificationBridge;
import com.android.settings.applications.AppStateOverlayBridge;
import com.android.settings.applications.AppStatePowerBridge;
@@ -71,14 +72,15 @@
public static final int FILTER_APPS_INSTALL_SOURCES = 13;
public static final int FILTER_APP_CAN_CHANGE_WIFI_STATE = 15;
public static final int FILTER_APPS_BLOCKED = 16;
- // Next id: 17
+ public static final int FILTER_MANAGE_EXTERNAL_STORAGE = 17;
+ // Next id: 18. If you add an entry here, length of mFilters should be updated
private static AppFilterRegistry sRegistry;
private final AppFilterItem[] mFilters;
private AppFilterRegistry() {
- mFilters = new AppFilterItem[17];
+ mFilters = new AppFilterItem[18];
// High power whitelist, on
mFilters[FILTER_APPS_POWER_WHITELIST] = new AppFilterItem(
@@ -178,6 +180,11 @@
AppStateNotificationBridge.FILTER_APP_NOTIFICATION_BLOCKED,
FILTER_APPS_BLOCKED,
R.string.filter_notif_blocked_apps);
+
+ mFilters[FILTER_MANAGE_EXTERNAL_STORAGE] = new AppFilterItem(
+ AppStateManageExternalStorageBridge.FILTER_MANAGE_EXTERNAL_STORAGE,
+ FILTER_MANAGE_EXTERNAL_STORAGE,
+ R.string.filter_manage_external_storage);
}
public static AppFilterRegistry getInstance() {
@@ -204,6 +211,8 @@
return FILTER_APP_CAN_CHANGE_WIFI_STATE;
case ManageApplications.LIST_TYPE_NOTIFICATION:
return FILTER_APPS_RECENT;
+ case ManageApplications.LIST_MANAGE_EXTERNAL_STORAGE:
+ return FILTER_MANAGE_EXTERNAL_STORAGE;
default:
return FILTER_APPS_ALL;
}
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 02e42e2..d38893f 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -88,6 +88,7 @@
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import com.android.settings.applications.AppInfoBase;
+import com.android.settings.applications.AppStateManageExternalStorageBridge;
import com.android.settings.applications.AppStateAppOpsBridge.PermissionState;
import com.android.settings.applications.AppStateBaseBridge;
import com.android.settings.applications.AppStateInstallAppsBridge;
@@ -100,6 +101,7 @@
import com.android.settings.applications.AppStateWriteSettingsBridge;
import com.android.settings.applications.AppStorageSettings;
import com.android.settings.applications.UsageAccessDetails;
+import com.android.settings.applications.appinfo.ManageExternalStorageDetails;
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
import com.android.settings.applications.appinfo.DrawOverlayDetails;
import com.android.settings.applications.appinfo.ExternalSourcesDetails;
@@ -224,6 +226,7 @@
public static final int LIST_TYPE_MOVIES = 10;
public static final int LIST_TYPE_PHOTOGRAPHY = 11;
public static final int LIST_TYPE_WIFI_ACCESS = 13;
+ public static final int LIST_MANAGE_EXTERNAL_STORAGE = 14;
// List types that should show instant apps.
public static final Set<Integer> LIST_TYPES_WITH_INSTANT = new ArraySet<>(Arrays.asList(
@@ -311,6 +314,9 @@
} else if (className.equals(Settings.ChangeWifiStateActivity.class.getName())) {
mListType = LIST_TYPE_WIFI_ACCESS;
screenTitle = R.string.change_wifi_state_title;
+ } else if (className.equals(Settings.ManageExternalStorageActivity.class.getName())) {
+ mListType = LIST_MANAGE_EXTERNAL_STORAGE;
+ screenTitle = R.string.manage_external_storage_title;
} else if (className.equals(Settings.NotificationAppListActivity.class.getName())) {
mListType = LIST_TYPE_NOTIFICATION;
mUsageStatsManager = IUsageStatsManager.Stub.asInterface(
@@ -538,6 +544,8 @@
return SettingsEnums.MANAGE_EXTERNAL_SOURCES;
case LIST_TYPE_WIFI_ACCESS:
return SettingsEnums.CONFIGURE_WIFI;
+ case LIST_MANAGE_EXTERNAL_STORAGE:
+ return SettingsEnums.MANAGE_EXTERNAL_STORAGE;
default:
return SettingsEnums.PAGE_UNKNOWN;
}
@@ -640,6 +648,10 @@
startAppInfoFragment(ChangeWifiStateDetails.class,
R.string.change_wifi_state_title);
break;
+ case LIST_MANAGE_EXTERNAL_STORAGE:
+ startAppInfoFragment(ManageExternalStorageDetails.class,
+ R.string.manage_external_storage_title);
+ break;
// TODO: Figure out if there is a way where we can spin up the profile's settings
// process ahead of time, to avoid a long load of data when user clicks on a managed
// app. Maybe when they load the list of apps that contains managed profile apps.
@@ -713,6 +725,8 @@
return R.string.help_uri_apps_photography;
case LIST_TYPE_WIFI_ACCESS:
return R.string.help_uri_apps_wifi_access;
+ case LIST_MANAGE_EXTERNAL_STORAGE:
+ return R.string.help_uri_manage_external_storage;
default:
case LIST_TYPE_MAIN:
return R.string.help_uri_apps;
@@ -1031,6 +1045,8 @@
mExtraInfoBridge = new AppStateInstallAppsBridge(mContext, mState, this);
} else if (mManageApplications.mListType == LIST_TYPE_WIFI_ACCESS) {
mExtraInfoBridge = new AppStateChangeWifiStateBridge(mContext, mState, this);
+ } else if (mManageApplications.mListType == LIST_MANAGE_EXTERNAL_STORAGE) {
+ mExtraInfoBridge = new AppStateManageExternalStorageBridge(mContext, mState, this);
} else {
mExtraInfoBridge = null;
}
@@ -1486,6 +1502,9 @@
case LIST_TYPE_WIFI_ACCESS:
holder.setSummary(ChangeWifiStateDetails.getSummary(mContext, entry));
break;
+ case LIST_MANAGE_EXTERNAL_STORAGE:
+ holder.setSummary(ManageExternalStorageDetails.getSummary(mContext, entry));
+ break;
default:
holder.updateSizeText(entry, mManageApplications.mInvalidSizeStr, mWhichSize);
break;
diff --git a/src/com/android/settings/development/compat/PlatformCompatDashboard.java b/src/com/android/settings/development/compat/PlatformCompatDashboard.java
index 2b0c655..ffa5c29 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;
@@ -64,6 +71,8 @@
private CompatibilityChangeInfo[] mChanges;
+ private AndroidBuildClassifier mAndroidBuildClassifier = new AndroidBuildClassifier();
+
@VisibleForTesting
String mSelectedApp;
@@ -117,17 +126,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();
@@ -164,7 +177,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);
}
}
@@ -183,7 +196,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()));
@@ -195,12 +216,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);
}
/**
@@ -209,9 +226,10 @@
* <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 "
@@ -246,6 +264,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/network/telephony/DisabledSubscriptionController.java b/src/com/android/settings/network/telephony/DisabledSubscriptionController.java
index cd51735..e6cace4 100644
--- a/src/com/android/settings/network/telephony/DisabledSubscriptionController.java
+++ b/src/com/android/settings/network/telephony/DisabledSubscriptionController.java
@@ -73,7 +73,7 @@
return;
}
// TODO b/135222940: re-evaluate whether to use mSubscriptionManager#isSubscriptionEnabled
- mCategory.setVisible(mSubscriptionManager.isActiveSubId(mSubId));
+ mCategory.setVisible(mSubscriptionManager.isActiveSubscriptionId(mSubId));
}
@Override
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/MobileNetworkSwitchController.java b/src/com/android/settings/network/telephony/MobileNetworkSwitchController.java
index 9d5c7cb..a498d47 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSwitchController.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSwitchController.java
@@ -78,7 +78,7 @@
mSwitchBar.addOnSwitchChangeListener((switchView, isChecked) -> {
// TODO b/135222940: re-evaluate whether to use
// mSubscriptionManager#isSubscriptionEnabled
- if (mSubscriptionManager.isActiveSubId(mSubId) != isChecked
+ if (mSubscriptionManager.isActiveSubscriptionId(mSubId) != isChecked
&& (!mSubscriptionManager.setSubscriptionEnabled(mSubId, isChecked))) {
mSwitchBar.setChecked(!isChecked);
}
@@ -106,7 +106,7 @@
mSwitchBar.hide();
} else {
mSwitchBar.show();
- mSwitchBar.setChecked(mSubscriptionManager.isActiveSubId(mSubId));
+ mSwitchBar.setChecked(mSubscriptionManager.isActiveSubscriptionId(mSubId));
}
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index c439f75..bd9b709 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;
@@ -312,8 +313,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;
}
@@ -340,8 +341,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;
@@ -404,7 +405,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;
}
@@ -417,7 +418,7 @@
}
if (isWorldMode(context, subId)) {
- if (networkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
+ if (networkMode == TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA) {
return true;
}
}
@@ -522,12 +523,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/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/panel/PanelSlicesAdapter.java b/src/com/android/settings/panel/PanelSlicesAdapter.java
index 60c434d..779c582 100644
--- a/src/com/android/settings/panel/PanelSlicesAdapter.java
+++ b/src/com/android/settings/panel/PanelSlicesAdapter.java
@@ -51,7 +51,7 @@
* Maximum number of slices allowed on the panel view.
*/
@VisibleForTesting
- static final int MAX_NUM_OF_SLICES = 5;
+ static final int MAX_NUM_OF_SLICES = 6;
private final List<LiveData<Slice>> mSliceLiveData;
private final int mMetricsCategory;
diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java
index 0b7e652..ae36f35 100644
--- a/src/com/android/settings/sim/SimSelectNotification.java
+++ b/src/com/android/settings/sim/SimSelectNotification.java
@@ -103,7 +103,7 @@
SubscriptionManager subscriptionManager = ((SubscriptionManager) context.getSystemService(
Context.TELEPHONY_SUBSCRIPTION_SERVICE));
- if (!subscriptionManager.isActiveSubId(subId)) {
+ if (!subscriptionManager.isActiveSubscriptionId(subId)) {
Log.w(TAG, "onEnableMmsDataRequest invalid sub ID " + subId);
return;
}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/ManageExternalStorageDetailsTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/ManageExternalStorageDetailsTest.java
new file mode 100644
index 0000000..ed85c01
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/ManageExternalStorageDetailsTest.java
@@ -0,0 +1,201 @@
+/*
+ * 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.applications.appinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import android.app.AppOpsManager;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.applications.AppStateAppOpsBridge.PermissionState;
+import com.android.settings.applications.AppStateManageExternalStorageBridge;
+import com.android.settings.testutils.shadow.ShadowUserManager;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.stubbing.Answer;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+import java.util.HashMap;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowUserManager.class})
+public class ManageExternalStorageDetailsTest {
+
+ @Mock
+ private AppOpsManager mAppOpsManager;
+ @Mock
+ private SwitchPreference mSwitchPref;
+ @Mock
+ private MetricsFeatureProvider mMetricsFeatureProvider;
+ @Mock
+ private AppStateManageExternalStorageBridge mBridge;
+
+ private ManageExternalStorageDetails mFragment;
+
+ private final HashMap<String, Integer> mPkgToOpModeMap = new HashMap<>();
+ private final HashMap<Integer, Integer> mUidToOpModeMap = new HashMap<>();
+
+ @Before
+ public void setUp() {
+ // Reset the global trackers
+ mPkgToOpModeMap.clear();
+ mUidToOpModeMap.clear();
+
+ //Start the mockin'
+ MockitoAnnotations.initMocks(this);
+
+ mFragment = new ManageExternalStorageDetails();
+ ReflectionHelpers.setField(mFragment, "mAppOpsManager", mAppOpsManager);
+ ReflectionHelpers.setField(mFragment, "mSwitchPref", mSwitchPref);
+ ReflectionHelpers.setField(mFragment, "mBridge", mBridge);
+ ReflectionHelpers.setField(mFragment, "mMetricsFeatureProvider",
+ mMetricsFeatureProvider);
+
+ mockAppOpsOperations();
+ }
+
+ @Test
+ public void onPreferenceChange_enableManageExternalStorage_shouldTriggerAppOpsManager() {
+ // Inject mock package details
+ final int mockUid = 23333;
+ final String mockPkgName = "com.mock.pkg.1";
+ PackageInfo pkgInfo = mock(PackageInfo.class);
+ pkgInfo.applicationInfo = new ApplicationInfo();
+ pkgInfo.applicationInfo.uid = mockUid;
+
+ ReflectionHelpers.setField(mFragment, "mPackageInfo", pkgInfo);
+ ReflectionHelpers.setField(mFragment, "mPackageName", mockPkgName);
+
+ // Set the initial state to be disabled
+ injectPermissionState(false);
+
+ // Simulate a preference change
+ mFragment.onPreferenceChange(mSwitchPref, /* newValue */ true);
+
+ // Verify that mAppOpsManager was called to allow the app-op
+ verify(mAppOpsManager, times(1))
+ .setMode(anyInt(), anyInt(), nullable(String.class), anyInt());
+ assertThat(mPkgToOpModeMap).containsExactly(mockPkgName, AppOpsManager.MODE_ALLOWED);
+ assertThat(mUidToOpModeMap).containsExactly(mockUid, AppOpsManager.MODE_ALLOWED);
+
+ // Verify the mSwitchPref was enabled
+ ArgumentCaptor<Boolean> acSetEnabled = ArgumentCaptor.forClass(Boolean.class);
+ verify(mSwitchPref, times(1)).setEnabled(acSetEnabled.capture());
+ assertThat(acSetEnabled.getAllValues()).containsExactly(true);
+
+ // Verify that mSwitchPref was toggled to on
+ ArgumentCaptor<Boolean> acSetChecked = ArgumentCaptor.forClass(Boolean.class);
+ verify(mSwitchPref, times(1)).setChecked(acSetChecked.capture());
+ assertThat(acSetChecked.getAllValues()).containsExactly(true);
+ }
+
+ @Test
+ public void onPreferenceChange_disableManageExternalStorage_shouldTriggerAppOpsManager() {
+ // Inject mock package details
+ final int mockUid = 24444;
+ final String mockPkgName = "com.mock.pkg.2";
+ PackageInfo pkgInfo = mock(PackageInfo.class);
+ pkgInfo.applicationInfo = new ApplicationInfo();
+ pkgInfo.applicationInfo.uid = mockUid;
+
+ ReflectionHelpers.setField(mFragment, "mPackageInfo", pkgInfo);
+ ReflectionHelpers.setField(mFragment, "mPackageName", mockPkgName);
+
+ // Set the initial state to be enabled
+ injectPermissionState(true);
+
+ // Simulate a preference change
+ mFragment.onPreferenceChange(mSwitchPref, /* newValue */ false);
+
+ // Verify that mAppOpsManager was called to deny the app-op
+ verify(mAppOpsManager, times(1))
+ .setMode(anyInt(), anyInt(), nullable(String.class), anyInt());
+ assertThat(mPkgToOpModeMap).containsExactly(mockPkgName, AppOpsManager.MODE_ERRORED);
+ assertThat(mUidToOpModeMap).containsExactly(mockUid, AppOpsManager.MODE_ERRORED);
+
+ // Verify the mSwitchPref was enabled
+ ArgumentCaptor<Boolean> acSetEnabled = ArgumentCaptor.forClass(Boolean.class);
+ verify(mSwitchPref, times(1)).setEnabled(acSetEnabled.capture());
+ assertThat(acSetEnabled.getAllValues()).containsExactly(true);
+
+ // Verify that mSwitchPref was toggled to off
+ ArgumentCaptor<Boolean> acSetChecked = ArgumentCaptor.forClass(Boolean.class);
+ verify(mSwitchPref, times(1)).setChecked(acSetChecked.capture());
+ assertThat(acSetChecked.getAllValues()).containsExactly(false);
+ }
+
+ private void injectPermissionState(boolean enabled) {
+ PermissionState state = new PermissionState(null, null);
+ state.permissionDeclared = true;
+ state.appOpMode = enabled ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_ERRORED;
+ ReflectionHelpers.setField(mFragment, "mPermissionState", state);
+ }
+
+ private void mockAppOpsOperations() {
+ Answer<Void> answerSetMode = invocation -> {
+ int code = invocation.getArgument(0);
+ int uid = invocation.getArgument(1);
+ String packageName = invocation.getArgument(2);
+ int mode = invocation.getArgument(3);
+
+ if (code != AppOpsManager.OP_MANAGE_EXTERNAL_STORAGE) {
+ return null;
+ }
+
+ mPkgToOpModeMap.put(packageName, mode);
+ mUidToOpModeMap.put(uid, mode);
+
+ return null;
+ };
+
+ doAnswer(answerSetMode).when(mAppOpsManager)
+ .setMode(anyInt(), anyInt(), nullable(String.class), anyInt());
+
+ Answer<PermissionState> answerPermState = invocation -> {
+ String packageName = invocation.getArgument(0);
+ PermissionState res = new PermissionState(packageName, null);
+ res.permissionDeclared = false;
+
+ if (mPkgToOpModeMap.containsKey(packageName)) {
+ res.permissionDeclared = true;
+ res.appOpMode = mPkgToOpModeMap.get(packageName);
+ }
+ return res;
+ };
+
+ doAnswer(answerPermState).when(mBridge)
+ .getManageExternalStoragePermState(nullable(String.class), anyInt());
+ }
+}
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..d0cb97a 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,7 +94,11 @@
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;
@@ -91,6 +108,7 @@
doReturn(mPlatformCompat).when(mDashboard).getPlatformCompat();
doReturn(mPreferenceScreen).when(mDashboard).getPreferenceScreen();
doReturn(mPreferenceManager).when(mDashboard).getPreferenceManager();
+ doReturn(mPackageManager).when(mContext).getPackageManager();
}
@Test
@@ -107,8 +125,10 @@
@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");
}
@@ -128,6 +148,7 @@
assertThat(enabledPreference.getSummary()).isEqualTo(mChanges[0].getName());
assertThat(enabledPreference instanceof SwitchPreference).isTrue();
assertThat(enabledSwitchPreference.isChecked()).isTrue();
+ assertThat(enabledSwitchPreference.isEnabled()).isTrue();
}
@Test
@@ -139,10 +160,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/network/telephony/DisabledSubscriptionControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/DisabledSubscriptionControllerTest.java
index f25ffa4..38223b8 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/DisabledSubscriptionControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/DisabledSubscriptionControllerTest.java
@@ -69,32 +69,32 @@
@Test
public void displayPreference_subscriptionEnabled_categoryIsVisible() {
- doReturn(true).when(mSubscriptionManager).isActiveSubId(SUB_ID);
+ doReturn(true).when(mSubscriptionManager).isActiveSubscriptionId(SUB_ID);
mController.displayPreference(mScreen);
assertThat(mCategory.isVisible()).isTrue();
}
@Test
public void displayPreference_subscriptionDisabled_categoryIsNotVisible() {
- doReturn(false).when(mSubscriptionManager).isActiveSubId(SUB_ID);
+ doReturn(false).when(mSubscriptionManager).isActiveSubscriptionId(SUB_ID);
mController.displayPreference(mScreen);
assertThat(mCategory.isVisible()).isFalse();
}
@Test
public void onSubscriptionsChanged_subscriptionBecomesDisabled_categoryIsNotVisible() {
- doReturn(true).when(mSubscriptionManager).isActiveSubId(SUB_ID);
+ doReturn(true).when(mSubscriptionManager).isActiveSubscriptionId(SUB_ID);
mController.displayPreference(mScreen);
- doReturn(false).when(mSubscriptionManager).isActiveSubId(SUB_ID);
+ doReturn(false).when(mSubscriptionManager).isActiveSubscriptionId(SUB_ID);
mController.onSubscriptionsChanged();
assertThat(mCategory.isVisible()).isFalse();
}
@Test
public void onSubscriptionsChanged_subscriptionBecomesEnabled_categoryIsVisible() {
- doReturn(false).when(mSubscriptionManager).isActiveSubId(SUB_ID);
+ doReturn(false).when(mSubscriptionManager).isActiveSubscriptionId(SUB_ID);
mController.displayPreference(mScreen);
- doReturn(true).when(mSubscriptionManager).isActiveSubId(SUB_ID);
+ doReturn(true).when(mSubscriptionManager).isActiveSubscriptionId(SUB_ID);
mController.onSubscriptionsChanged();
assertThat(mCategory.isVisible()).isTrue();
}
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 35e1d1d..ea96e29 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java
@@ -44,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;
@@ -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/MobileNetworkSwitchControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSwitchControllerTest.java
index 04e3df8..ba839c6 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSwitchControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSwitchControllerTest.java
@@ -113,7 +113,7 @@
@Test
public void displayPreference_oneEnabledSubscription_switchBarNotHidden() {
- doReturn(true).when(mSubscriptionManager).isActiveSubId(mSubId);
+ doReturn(true).when(mSubscriptionManager).isActiveSubscriptionId(mSubId);
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mSubscription));
mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue();
@@ -121,7 +121,7 @@
@Test
public void displayPreference_oneDisabledSubscription_switchBarNotHidden() {
- doReturn(false).when(mSubscriptionManager).isActiveSubId(mSubId);
+ doReturn(false).when(mSubscriptionManager).isActiveSubscriptionId(mSubId);
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mSubscription));
mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue();
@@ -129,7 +129,7 @@
@Test
public void displayPreference_subscriptionEnabled_switchIsOn() {
- when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true);
+ when(mSubscriptionManager.isActiveSubscriptionId(mSubId)).thenReturn(true);
mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue();
assertThat(mSwitchBar.isChecked()).isTrue();
@@ -137,7 +137,7 @@
@Test
public void displayPreference_subscriptionDisabled_switchIsOff() {
- when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(false);
+ when(mSubscriptionManager.isActiveSubscriptionId(mSubId)).thenReturn(false);
mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue();
assertThat(mSwitchBar.isChecked()).isFalse();
@@ -145,7 +145,7 @@
@Test
public void switchChangeListener_fromEnabledToDisabled_setSubscriptionEnabledCalledCorrectly() {
- when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true);
+ when(mSubscriptionManager.isActiveSubscriptionId(mSubId)).thenReturn(true);
mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue();
assertThat(mSwitchBar.isChecked()).isTrue();
@@ -157,7 +157,7 @@
public void switchChangeListener_fromEnabledToDisabled_setSubscriptionEnabledFailed() {
when(mSubscriptionManager.setSubscriptionEnabled(eq(mSubId), anyBoolean()))
.thenReturn(false);
- when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true);
+ when(mSubscriptionManager.isActiveSubscriptionId(mSubId)).thenReturn(true);
mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue();
assertThat(mSwitchBar.isChecked()).isTrue();
@@ -168,7 +168,7 @@
@Test
public void switchChangeListener_fromDisabledToEnabled_setSubscriptionEnabledCalledCorrectly() {
- when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(false);
+ when(mSubscriptionManager.isActiveSubscriptionId(mSubId)).thenReturn(false);
mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue();
assertThat(mSwitchBar.isChecked()).isFalse();
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 9e13597..0d50e9e 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceControllerTest.java
@@ -36,6 +36,7 @@
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;
@@ -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/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java b/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java
index 9b53636..8f861eb 100644
--- a/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java
+++ b/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java
@@ -117,7 +117,7 @@
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
when(mTelephonyManager.isDataEnabledForApn(TYPE_MMS)).thenReturn(false);
- when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true);
+ when(mSubscriptionManager.isActiveSubscriptionId(mSubId)).thenReturn(true);
when(mSubscriptionManager.getActiveSubscriptionInfo(mSubId)).thenReturn(mSubInfo);
when(mSubInfo.getDisplayName()).thenReturn(mFakeDisplayName);
when(mContext.getResources()).thenReturn(mResources);