Merge changes from topics "addSettingsEntrypointToAddASupervisedUser", "simple fallback activity for supervised user creation"
* changes:
Create a simple fallback activity for supervised user creation
Add settings entrypoint to add a supervised user
diff --git a/Android.bp b/Android.bp
index 2c3b2ec..0116237 100644
--- a/Android.bp
+++ b/Android.bp
@@ -59,7 +59,6 @@
"com.google.android.material_material",
"setupcompat",
"setupdesign",
- "androidx-constraintlayout_constraintlayout-solver",
"androidx.lifecycle_lifecycle-runtime",
"androidx.lifecycle_lifecycle-extensions",
"guava",
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c32406b..3fddf39 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -111,6 +111,7 @@
<uses-permission android:name="android.permission.LAUNCH_MULTI_PANE_SETTINGS_DEEP_LINK" />
<uses-permission android:name="android.permission.ALLOW_PLACE_IN_MULTI_PANE_SETTINGS" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
+ <uses-permission android:name="android.permission.READ_APP_SPECIFIC_LOCALES" />
<application
android:name=".SettingsApplication"
@@ -240,6 +241,7 @@
<activity android:name=".network.telephony.MobileNetworkActivity"
android:label="@string/network_settings_title"
android:exported="true"
+ android:taskAffinity="com.android.settings.root"
android:launchMode="singleTask"
android:configChanges="orientation|screenSize|keyboardHidden">
<!-- Note: Since the framework does not support the multiple requests of network scan
@@ -257,6 +259,14 @@
</intent-filter>
</activity>
+ <activity
+ android:name=".Settings$SubscriptionSettingsActivity"
+ android:label="@string/network_settings_title"
+ android:exported="false">
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.network.telephony.MobileNetworkSettings"/>
+ </activity>
+
<activity android:name=".Settings$MobileNetworkListActivity"
android:exported="true"
android:label="@string/network_settings_title">
diff --git a/res/layout/app_locale_details_description.xml b/res/layout/app_locale_details_description.xml
new file mode 100644
index 0000000..989f6c9
--- /dev/null
+++ b/res/layout/app_locale_details_description.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal" >
+ <TextView
+ android:id="@id/description"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="15dip"
+ android:layout_marginRight="6dip"
+ android:layout_marginTop="6dip"
+ android:textAlignment="center"/>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/dialog_sim_status.xml b/res/layout/dialog_sim_status.xml
index 27d12a8..c169e58 100644
--- a/res/layout/dialog_sim_status.xml
+++ b/res/layout/dialog_sim_status.xml
@@ -166,6 +166,7 @@
android:id="@+id/esim_id_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:textIsSelectable="true"
android:text="@string/device_info_not_available"/>
<TextView
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ed867d2..275ffab 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -461,7 +461,7 @@
<string name="next_label">Next</string>
<!-- LocalePicker -->
- <!-- Title for the locale picker activity -->
+ <!-- Title for the locale picker activity. [CHAR LIMIT=30]-->
<string name="language_picker_title">Languages</string>
<!-- Menu item in the locale menu. Will remove the selected locales. [CHAR LIMIT=30] -->
@@ -470,6 +470,29 @@
<!-- "Button" that opens a language picker. The selected language gets added to the language list. [CHAR LIMIT=30] -->
<string name="add_a_language">Add a language</string>
+ <!-- Title of preference for the locale picker activity. [CHAR LIMIT=30]-->
+ <string name="app_locale_preference_title">Language</string>
+
+ <!-- Title for the locale picker category. [CHAR LIMIT=50]-->
+ <string name="locale_picker_category_title">Preferred Language</string>
+
+ <!-- Title for the Apps' locale menu entry [CHAR LIMIT=50]-->
+ <string name="app_locales_picker_menu_title">App Languages</string>
+
+ <!-- Summary for the app's locale picker activity. [CHAR LIMIT=50]-->
+ <string name="app_locale_picker_summary">Set the language for each app</string>
+
+ <!-- Title for the App's locale picker activity. [CHAR LIMIT=50]-->
+ <string name="app_locale_picker_title">App Language</string>
+
+ <!-- Category for the suggested app's locales. [CHAR LIMIT=50]-->
+ <string name="suggested_app_locales_title">Suggested languages</string>
+
+ <!-- Category for the app's locale picker activity. [CHAR LIMIT=50]-->
+ <string name="all_supported_app_locales_title">All languages</string>
+
+ <!-- Description for the app without any supported languages. [CHAR LIMIT=NONE]-->
+ <string name="no_multiple_language_supported">The app is set to <xliff:g id="default_language" example="English (United States)">%1$s</xliff:g> by default and doesn\u2019t support multiple languages.</string>
<!-- The title of the confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] -->
<plurals name="dlg_remove_locales_title">
<item quantity="one">Remove selected language?</item>
@@ -5275,13 +5298,13 @@
<!-- Message of the magnification mode option to choose the magnification mode. [CHAR LIMIT=none] -->
<string name="accessibility_magnification_area_settings_mode_switch_summary">Tap the switch button to move between both options</string>
<!-- Title for the accessibility magnification switch shortcut dialog. [CHAR LIMIT=48] -->
- <string name="accessibility_magnification_switch_shortcut_title">This may slow down your keyboard</string>
+ <string name="accessibility_magnification_switch_shortcut_title">Switch to accessibility button?</string>
<!-- Message for the accessibility magnification switch shortcut dialog. [CHAR LIMIT=none] -->
- <string name="accessibility_magnification_switch_shortcut_message">When using triple-tap to magnify part of your screen, you may notice issues over the keyboard.\n\nTo avoid this, you can change your magnification shortcut from triple-tap to another option.\n<annotation id="link">Change setting</annotation></string>
- <!-- Title for the switch shortcut button in accessibility switch shortcut dialog to confirm the action. [CHAR LIMIT=45] -->
- <string name="accessibility_magnification_switch_shortcut_positive_button">Continue anyway</string>
- <!-- Title for the cancel button in accessibility switch shortcut dialog to go back to edit. [CHAR LIMIT=54] -->
- <string name="accessibility_magnification_switch_shortcut_negative_button">Cancel</string>
+ <string name="accessibility_magnification_switch_shortcut_message">Using triple-tap to magnify part of your screen causes typing and other delays.\n\nThe accessibility button floats on your screen over other apps. Tap it to magnify.</string>
+ <!-- Title for the switch shortcut button in accessibility switch shortcut dialog to change the config shortcut value. [CHAR LIMIT=45] -->
+ <string name="accessibility_magnification_switch_shortcut_positive_button">Switch to accessibility button</string>
+ <!-- Title for the cancel button in accessibility switch shortcut dialog to keep the config shortcut value. [CHAR LIMIT=54] -->
+ <string name="accessibility_magnification_switch_shortcut_negative_button">Use triple-tap</string>
<!-- Title for the accessibility preference screen to enable screen magnification settings. [CHAR LIMIT=35] -->
<string name="accessibility_magnification_service_settings_title">Magnification settings</string>
<!-- Title for the accessibility preference screen to enable triple-tap gesture screen magnification. [CHAR LIMIT=35] -->
@@ -13328,9 +13351,9 @@
<string name="lockscreen_privacy_wallet_summary">Allow access to wallet from lock screen and quick settings</string>
<!-- QR Code Scanner toggle name [CHAR LIMIT=60] -->
- <string name="lockscreen_privacy_qr_code_scanner_setting_toggle">Show QR Code Scanner</string>
+ <string name="lockscreen_privacy_qr_code_scanner_setting_toggle">Show QR Scanner</string>
<!-- QR Code Scanner summary [CHAR LIMIT=NONE] -->
- <string name="lockscreen_privacy_qr_code_scanner_summary">Allow access to QR code scanner from lock screen</string>
+ <string name="lockscreen_privacy_qr_code_scanner_summary">Allow access to QR scanner from lock screen</string>
<!-- Device controls toggle name [CHAR LIMIT=60] -->
<string name="lockscreen_privacy_controls_setting_toggle">Show device controls</string>
diff --git a/res/xml/app_info_settings.xml b/res/xml/app_info_settings.xml
index 1442960..562c7d1 100644
--- a/res/xml/app_info_settings.xml
+++ b/res/xml/app_info_settings.xml
@@ -89,6 +89,12 @@
android:summary="@string/summary_placeholder" />
<Preference
+ android:key="app_language_setting"
+ android:title="@string/app_locale_preference_title"
+ android:summary="@string/summary_placeholder"
+ settings:controller="com.android.settings.applications.appinfo.AppLocalePreferenceController" />
+
+ <Preference
android:key="preferred_settings"
android:title="@string/launch_by_default"
android:summary="@string/summary_placeholder"
diff --git a/res/xml/app_locale_details.xml b/res/xml/app_locale_details.xml
new file mode 100644
index 0000000..8056cbf
--- /dev/null
+++ b/res/xml/app_locale_details.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:title="@string/app_locale_picker_title">
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="app_locale_description"
+ android:layout="@layout/app_locale_details_description"
+ android:selectable="false"
+ android:visibility="gone"
+ settings:allowDividerBelow="true"
+ settings:searchable="false"/>
+
+ <PreferenceCategory
+ android:key="category_key_suggested_languages"
+ android:title="@string/suggested_app_locales_title" />
+
+ <PreferenceCategory
+ android:key="category_key_all_languages"
+ android:title="@string/all_supported_app_locales_title" />
+
+</PreferenceScreen>
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index f33ef5c..f2b6d8a 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -19,12 +19,28 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/language_settings">
+ <PreferenceCategory
+ android:key="languages_category"
+ android:title="@string/locale_picker_category_title">
+ <Preference
+ android:key="phone_language"
+ android:title="@string/phone_language"
+ android:icon="@drawable/ic_translate_24dp"
+ android:fragment="com.android.settings.localepicker.LocaleListEditor" />
- <Preference
- android:key="phone_language"
- android:title="@string/phone_language"
- android:icon="@drawable/ic_translate_24dp"
- android:fragment="com.android.settings.localepicker.LocaleListEditor" />
+ <Preference
+ android:key="apps_language"
+ android:title="@string/app_locales_picker_menu_title"
+ android:summary="@string/app_locale_picker_summary"
+ android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
+ settings:controller="com.android.settings.applications.appinfo.ManageAppLocalePreferenceController">
+ <extra
+ android:name="classname"
+ android:value="com.android.settings.applications.appinfo.AppLocaleDetails" />
+ </Preference>
+
+
+ </PreferenceCategory>
<PreferenceCategory
android:key="keyboards_category"
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index afd0d15..4e919d6 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -304,6 +304,8 @@
public static class WifiCallingDisclaimerActivity extends SettingsActivity { /* empty */ }
public static class MobileNetworkListActivity extends SettingsActivity {}
public static class PowerMenuSettingsActivity extends SettingsActivity {}
+ public static class SubscriptionSettingsActivity extends SettingsActivity { /* empty */ }
+
/**
* Activity for BugReportHandlerPicker.
*/
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 42a6068..2988ddc 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -1230,8 +1230,4 @@
public static int getHomepageIconColorHighlight(Context context) {
return getColorAttrDefaultColor(context, android.R.attr.textColorSecondaryInverse);
}
-
- public static boolean isProviderModelEnabled(Context context) {
- return FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL);
- }
}
diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
index e1ea8e4..159eec6 100755
--- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
+++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
@@ -205,6 +205,10 @@
use(AdvancedAppInfoPreferenceCategoryController.class).setChildren(Arrays.asList(
writeSystemSettings, drawOverlay, pip, externalSource, acrossProfiles,
alarmsAndReminders));
+
+ final AppLocalePreferenceController appLocale =
+ use(AppLocalePreferenceController.class);
+ appLocale.setParentFragment(this);
}
@Override
diff --git a/src/com/android/settings/applications/appinfo/AppLocaleDetails.java b/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
new file mode 100644
index 0000000..742ce04
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
@@ -0,0 +1,314 @@
+/*
+ * Copyright (C) 2021 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.android.settings.widget.EntityHeaderController.ActionType;
+
+import android.app.Activity;
+import android.app.LocaleManager;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.os.LocaleList;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceGroup;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.applications.AppInfoBase;
+import com.android.settings.widget.EntityHeaderController;
+import com.android.settingslib.applications.AppUtils;
+import com.android.settingslib.widget.LayoutPreference;
+import com.android.settingslib.widget.RadioButtonPreference;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Locale;
+
+/**
+ * A fragment to show the current app locale info and help the user to select the expected locale.
+ */
+public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreference.OnClickListener {
+ private static final String TAG = "AppLocaleDetails";
+
+ private static final String CATEGORY_KEY_SUGGESTED_LANGUAGES =
+ "category_key_suggested_languages";
+ private static final String CATEGORY_KEY_ALL_LANGUAGES =
+ "category_key_all_languages";
+ private static final String KEY_APP_DESCRIPTION = "app_locale_description";
+
+ private boolean mCreated = false;
+ private AppLocaleDetailsHelper mAppLocaleDetailsHelper;
+
+ private PreferenceGroup mGroupOfSuggestedLocales;
+ private PreferenceGroup mGroupOfSupportedLocales;
+ private LayoutPreference mPrefOfDescription;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.app_locale_details);
+ mAppLocaleDetailsHelper = new AppLocaleDetailsHelper(getContext(), mPackageName);
+
+ mGroupOfSuggestedLocales =
+ getPreferenceScreen().findPreference(CATEGORY_KEY_SUGGESTED_LANGUAGES);
+ mGroupOfSupportedLocales =
+ getPreferenceScreen().findPreference(CATEGORY_KEY_ALL_LANGUAGES);
+ mPrefOfDescription = getPreferenceScreen().findPreference(KEY_APP_DESCRIPTION);
+ }
+
+ // Override here so we don't have an empty screen
+ @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 onResume() {
+ // Update Locales first, before refresh ui.
+ mAppLocaleDetailsHelper.handleAllLocalesData();
+ super.onResume();
+ }
+
+ @Override
+ protected boolean refreshUi() {
+ if (mAppLocaleDetailsHelper.getSupportedLocales().isEmpty()) {
+ Log.d(TAG, "No supported language.");
+ mGroupOfSuggestedLocales.setVisible(false);
+ mGroupOfSupportedLocales.setVisible(false);
+ mPrefOfDescription.setVisible(true);
+ TextView description = (TextView) mPrefOfDescription.findViewById(R.id.description);
+ Locale locale = mAppLocaleDetailsHelper.getCurrentSystemLocales().get(0);
+ description.setText(getContext().getString(R.string.no_multiple_language_supported,
+ locale.getDisplayName(locale)));
+ return true;
+ }
+
+ mGroupOfSuggestedLocales.removeAll();
+ mGroupOfSupportedLocales.removeAll();
+ Locale appLocale = AppLocaleDetailsHelper.getAppDefaultLocale(getContext(), mPackageName);
+ setLanguagesPreference(mGroupOfSuggestedLocales,
+ mAppLocaleDetailsHelper.getSuggestedLocales(), appLocale);
+ setLanguagesPreference(mGroupOfSupportedLocales,
+ mAppLocaleDetailsHelper.getSupportedLocales(), appLocale);
+ return true;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.APPS_LOCALE_LIST;
+ }
+
+ @Override
+ protected AlertDialog createDialog(int id, int errorCode) {
+ return null;
+ }
+
+ @Override
+ public void onRadioButtonClicked(RadioButtonPreference pref) {
+ mAppLocaleDetailsHelper.setAppDefaultLocale(pref.getKey());
+ refreshUi();
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ if (mCreated) {
+ Log.w(TAG, "onActivityCreated: ignoring duplicate call");
+ return;
+ }
+ mCreated = true;
+ if (mPackageInfo == null) {
+ return;
+ }
+ // Creates a head icon button of app on this page.
+ final Activity activity = getActivity();
+ final Preference pref = EntityHeaderController
+ .newInstance(activity, this, null /* header */)
+ .setRecyclerView(getListView(), getSettingsLifecycle())
+ .setIcon(Utils.getBadgedIcon(getContext(), mPackageInfo.applicationInfo))
+ .setLabel(mPackageInfo.applicationInfo.loadLabel(mPm))
+ .setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
+ .setPackageName(mPackageName)
+ .setUid(mPackageInfo.applicationInfo.uid)
+ .setHasAppInfoLink(true)
+ .setButtonActions(ActionType.ACTION_NONE, ActionType.ACTION_NONE)
+ .done(activity, getPrefContext());
+ getPreferenceScreen().addPreference(pref);
+ }
+
+ /**
+ * TODO (b209962418) Do a performance test to low end device.
+ * @return Return the summary to show the current app's language.
+ */
+ public static CharSequence getSummary(Context context, String packageName) {
+ Locale appLocale =
+ AppLocaleDetailsHelper.getAppDefaultLocale(context, packageName);
+ return appLocale == null ? "" : appLocale.getDisplayName(appLocale);
+ }
+
+ private void setLanguagesPreference(PreferenceGroup group,
+ Collection<Locale> locales, Locale appLocale) {
+ if (locales == null) {
+ return;
+ }
+
+ for (Locale locale : locales) {
+ RadioButtonPreference pref = new RadioButtonPreference(getContext());
+ pref.setTitle(locale.getDisplayName(locale));
+ pref.setKey(locale.toLanguageTag());
+ pref.setChecked(locale.equals(appLocale));
+ pref.setOnClickListener(this);
+ group.addPreference(pref);
+ }
+ }
+
+ @VisibleForTesting
+ static class AppLocaleDetailsHelper {
+ private String mPackageName;
+ private Context mContext;
+ private TelephonyManager mTelephonyManager;
+ private LocaleManager mLocaleManager;
+
+ private Collection<Locale> mSuggestedLocales = new ArrayList<>();;
+ private Collection<Locale> mSupportedLocales = new ArrayList<>();;
+
+ AppLocaleDetailsHelper(Context context, String packageName) {
+ mContext = context;
+ mPackageName = packageName;
+ mTelephonyManager = context.getSystemService(TelephonyManager.class);
+ mLocaleManager = context.getSystemService(LocaleManager.class);
+ }
+
+ /** Handle suggested and supported locales for UI display. */
+ public void handleAllLocalesData() {
+ clearLocalesData();
+ handleSuggestedLocales();
+ handleSupportedLocales();
+ }
+
+ /** Gets suggested locales in the app. */
+ public Collection<Locale> getSuggestedLocales() {
+ return mSuggestedLocales;
+ }
+
+ /** Gets supported locales in the app. */
+ public Collection<Locale> getSupportedLocales() {
+ return mSupportedLocales;
+ }
+
+ @VisibleForTesting
+ void handleSuggestedLocales() {
+ LocaleList currentSystemLocales = getCurrentSystemLocales();
+ Locale simLocale = mTelephonyManager.getSimLocale();
+ Locale appLocale = getAppDefaultLocale(mContext, mPackageName);
+ // 1st locale in suggested languages group.
+ if (appLocale != null) {
+ mSuggestedLocales.add(appLocale);
+ }
+ // 2nd locale in suggested languages group.
+ if (simLocale != null && !simLocale.equals(appLocale)) {
+ mSuggestedLocales.add(simLocale);
+ }
+ // Other locales in suggested languages group.
+ for (int i = 0; i < currentSystemLocales.size(); i++) {
+ Locale locale = currentSystemLocales.get(i);
+ if (!locale.equals(appLocale) && !locale.equals(simLocale)) {
+ mSuggestedLocales.add(locale);
+ }
+ }
+ }
+
+ @VisibleForTesting
+ void handleSupportedLocales() {
+ //TODO Waiting for PackageManager api
+ String[] languages = getAssetSystemLocales();
+
+ for (String language : languages) {
+ mSupportedLocales.add(Locale.forLanguageTag(language));
+ }
+ if (mSuggestedLocales != null || !mSuggestedLocales.isEmpty()) {
+ mSupportedLocales.removeAll(mSuggestedLocales);
+ }
+ }
+
+ private void clearLocalesData() {
+ mSuggestedLocales.clear();
+ mSupportedLocales.clear();
+ }
+
+ /** Gets per app's default locale */
+ public static Locale getAppDefaultLocale(Context context, String packageName) {
+ LocaleManager localeManager = context.getSystemService(LocaleManager.class);
+ LocaleList localeList = (localeManager == null)
+ ? new LocaleList() : localeManager.getApplicationLocales(packageName);
+ return localeList.isEmpty() ? null : localeList.get(0);
+ }
+
+ /** Sets per app's default language to system. */
+ public void setAppDefaultLocale(String languageTag) {
+ if (languageTag.isEmpty()) {
+ Log.w(TAG, "[setAppDefaultLocale] No language tag.");
+ return;
+ }
+ setAppDefaultLocale(LocaleList.forLanguageTags(languageTag));
+ }
+
+ /** Sets per app's default language to system. */
+ public void setAppDefaultLocale(LocaleList localeList) {
+ if (mLocaleManager == null) {
+ Log.w(TAG, "LocaleManager is null, and cannot set the app locale up.");
+ return;
+ }
+ mLocaleManager.setApplicationLocales(mPackageName, localeList);
+ }
+
+ @VisibleForTesting
+ LocaleList getCurrentSystemLocales() {
+ return Resources.getSystem().getConfiguration().getLocales();
+ }
+
+ @VisibleForTesting
+ String[] getAssetSystemLocales() {
+ try {
+ PackageManager packageManager = mContext.getPackageManager();
+ return packageManager.getResourcesForApplication(
+ packageManager.getPackageInfo(mPackageName, PackageManager.MATCH_ALL)
+ .applicationInfo).getAssets().getNonSystemLocales();
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.w(TAG, "Can not found the package name : " + e);
+ }
+ return new String[0];
+ }
+ }
+}
diff --git a/src/com/android/settings/applications/appinfo/AppLocalePreferenceController.java b/src/com/android/settings/applications/appinfo/AppLocalePreferenceController.java
new file mode 100644
index 0000000..f1e43ad
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/AppLocalePreferenceController.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2021 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.content.Context;
+import android.util.FeatureFlagUtils;
+
+import com.android.settings.SettingsPreferenceFragment;
+
+/**
+ * A controller to update current locale information of application.
+ */
+public class AppLocalePreferenceController extends AppInfoPreferenceControllerBase {
+ public AppLocalePreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return FeatureFlagUtils
+ .isEnabled(mContext, FeatureFlagUtils.SETTINGS_APP_LANGUAGE_SELECTION)
+ ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ }
+
+ @Override
+ protected Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
+ return AppLocaleDetails.class;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ return AppLocaleDetails.getSummary(mContext, mParent.getAppEntry().info.packageName);
+ }
+}
diff --git a/src/com/android/settings/applications/appinfo/ManageAppLocalePreferenceController.java b/src/com/android/settings/applications/appinfo/ManageAppLocalePreferenceController.java
new file mode 100644
index 0000000..aa12b62
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/ManageAppLocalePreferenceController.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 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.content.Context;
+import android.util.FeatureFlagUtils;
+
+import com.android.settings.core.BasePreferenceController;
+
+/**
+ * A controller to update current locale information of application
+ * and a entry to launch {@link ManageApplications}.
+ * TODO(209775925) After feature release, this class may be removed.
+ */
+public class ManageAppLocalePreferenceController extends BasePreferenceController {
+ public ManageAppLocalePreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return FeatureFlagUtils
+ .isEnabled(mContext, FeatureFlagUtils.SETTINGS_APP_LANGUAGE_SELECTION)
+ ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 7b5c221..d985482 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -108,6 +108,7 @@
import com.android.settings.applications.UsageAccessDetails;
import com.android.settings.applications.appinfo.AlarmsAndRemindersDetails;
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
+import com.android.settings.applications.appinfo.AppLocaleDetails;
import com.android.settings.applications.appinfo.DrawOverlayDetails;
import com.android.settings.applications.appinfo.ExternalSourcesDetails;
import com.android.settings.applications.appinfo.ManageExternalStorageDetails;
@@ -231,6 +232,7 @@
public static final int LIST_MANAGE_EXTERNAL_STORAGE = 11;
public static final int LIST_TYPE_ALARMS_AND_REMINDERS = 12;
public static final int LIST_TYPE_MEDIA_MANAGEMENT_APPS = 13;
+ public static final int LIST_TYPE_APPS_LOCAL = 14;
// List types that should show instant apps.
public static final Set<Integer> LIST_TYPES_WITH_INSTANT = new ArraySet<>(Arrays.asList(
@@ -318,6 +320,8 @@
ServiceManager.getService(Context.USAGE_STATS_SERVICE));
mNotificationBackend = new NotificationBackend();
mSortOrder = R.id.sort_order_recent_notification;
+ } else if (className.equals(AppLocaleDetails.class.getName())) {
+ mListType = LIST_TYPE_APPS_LOCAL;
} else {
mListType = LIST_TYPE_MAIN;
}
@@ -500,6 +504,8 @@
return SettingsEnums.ALARMS_AND_REMINDERS;
case LIST_TYPE_MEDIA_MANAGEMENT_APPS:
return SettingsEnums.MEDIA_MANAGEMENT_APPS;
+ case LIST_TYPE_APPS_LOCAL:
+ return SettingsEnums.APPS_LOCALE_LIST;
default:
return SettingsEnums.PAGE_UNKNOWN;
}
@@ -623,6 +629,10 @@
startAppInfoFragment(MediaManagementAppsDetails.class,
R.string.media_management_apps_title);
break;
+ case LIST_TYPE_APPS_LOCAL:
+ startAppInfoFragment(AppLocaleDetails.class,
+ R.string.app_locale_picker_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.
@@ -899,6 +909,8 @@
screenTitle = R.string.alarms_and_reminders_title;
} else if (className.equals(Settings.NotificationAppListActivity.class.getName())) {
screenTitle = R.string.app_notifications_title;
+ } else if (className.equals(AppLocaleDetails.class.getName())) {
+ screenTitle = R.string.app_locales_picker_menu_title;
} else {
if (screenTitle == -1) {
screenTitle = R.string.all_apps;
@@ -1521,6 +1533,10 @@
case LIST_TYPE_MEDIA_MANAGEMENT_APPS:
holder.setSummary(MediaManagementAppsDetails.getSummary(mContext, entry));
break;
+ case LIST_TYPE_APPS_LOCAL:
+ holder.setSummary(AppLocaleDetails
+ .getSummary(mContext, entry.info.packageName));
+ break;
default:
holder.updateSizeText(entry, mManageApplications.mInvalidSizeStr, mWhichSize);
break;
diff --git a/src/com/android/settings/connecteddevice/usb/UsbBackend.java b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
index 244818f..7f3a598 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbBackend.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
@@ -41,7 +41,10 @@
*/
public class UsbBackend {
- static final int PD_ROLE_SWAP_TIMEOUT_MS = 3000;
+ // extend this value from 3s to 4s because of switching data role
+ // in USB driver side takes about 3s in some devices, plus the usb
+ // port change event dispatching time, 3s is not enough.
+ static final int PD_ROLE_SWAP_TIMEOUT_MS = 4000;
static final int NONPD_ROLE_SWAP_TIMEOUT_MS = 15000;
private final boolean mFileTransferRestricted;
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 87e176e..e94fafc 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -123,6 +123,7 @@
import com.android.settings.network.NetworkProviderSettings;
import com.android.settings.network.apn.ApnEditor;
import com.android.settings.network.apn.ApnSettings;
+import com.android.settings.network.telephony.MobileNetworkSettings;
import com.android.settings.network.telephony.NetworkSelectSettings;
import com.android.settings.nfc.AndroidBeam;
import com.android.settings.nfc.PaymentSettings;
@@ -329,7 +330,8 @@
AlarmsAndRemindersDetails.class.getName(),
MediaManagementAppsDetails.class.getName(),
AutoBrightnessSettings.class.getName(),
- OneHandedSettings.class.getName()
+ OneHandedSettings.class.getName(),
+ MobileNetworkSettings.class.getName()
};
public static final String[] SETTINGS_FOR_RESTRICTED = {
diff --git a/src/com/android/settings/datausage/DataUsageList.java b/src/com/android/settings/datausage/DataUsageList.java
index f72a006..cd033e3 100644
--- a/src/com/android/settings/datausage/DataUsageList.java
+++ b/src/com/android/settings/datausage/DataUsageList.java
@@ -142,12 +142,7 @@
mChart = findPreference(KEY_CHART_DATA);
mApps = findPreference(KEY_APPS_GROUP);
- // TODO(b/167474581): This is a temporary solution to hide unnecessary warning
- // preference, when the provider model is completed, the following code should be removed.
- final Preference unnecessaryWarningPreference =
- FeatureFlagUtils.isEnabled(getContext(), FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)
- ? findPreference("operator_warning")
- : findPreference("non_carrier_data_usage_warning");
+ final Preference unnecessaryWarningPreference = findPreference("operator_warning");
if (unnecessaryWarningPreference != null) {
unnecessaryWarningPreference.setVisible(false);
}
diff --git a/src/com/android/settings/network/MobileNetworkSummaryController.java b/src/com/android/settings/network/MobileNetworkSummaryController.java
index 94d1ff5..1a85a7f 100644
--- a/src/com/android/settings/network/MobileNetworkSummaryController.java
+++ b/src/com/android/settings/network/MobileNetworkSummaryController.java
@@ -36,7 +36,7 @@
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.network.helper.SubscriptionAnnotation;
-import com.android.settings.network.telephony.MobileNetworkActivity;
+import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.AddPreference;
import com.android.settingslib.Utils;
@@ -190,12 +190,8 @@
SubscriptionAnnotation info = subs.get(0);
if (info.getSubInfo().isEmbedded() || info.isActive()
|| mStatusCache.isPhysicalSimDisableSupport()) {
- final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
- intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
- // MobileNetworkActivity is singleTask, set SplitPairRule to show in 2-pane.
- MobileNetworkTwoPaneUtils.registerTwoPaneForMobileNetwork(mContext, intent,
- null);
- mContext.startActivity(intent);
+ MobileNetworkUtils.launchMobileNetworkSettings(mContext,
+ info.getSubInfo());
return true;
}
diff --git a/src/com/android/settings/network/MobileNetworkTwoPaneUtils.java b/src/com/android/settings/network/MobileNetworkTwoPaneUtils.java
deleted file mode 100644
index 8b3503e..0000000
--- a/src/com/android/settings/network/MobileNetworkTwoPaneUtils.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.android.settings.network;
-
-import android.annotation.Nullable;
-import android.content.Context;
-import android.content.Intent;
-import android.util.Log;
-
-import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
-
-public class MobileNetworkTwoPaneUtils {
-
- private static final String TAG = "MobileNetworkTwoPaneUtils";
-
- /**
- * TODO: b/206061070, the problem of multi-instance should be fixed in Android T to apply the
- * Settings' architecture and 2 panes mode instead of registering the rule.
- *
- * The launchMode of MobileNetworkActivity is singleTask, set SplitPairRule to show in 2-pane.
- */
- public static void registerTwoPaneForMobileNetwork(Context context, Intent intent,
- @Nullable String secondaryIntentAction) {
- Log.d(TAG, "registerTwoPaneForMobileNetwork");
- ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
- context,
- intent.getComponent(),
- secondaryIntentAction /* secondaryIntentAction */,
- false /* clearTop */);
- }
-}
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index c762197..286e4e3 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -118,9 +118,7 @@
controllers.add(internetPreferenceController);
}
controllers.add(privateDnsPreferenceController);
- if (Utils.isProviderModelEnabled(context)) {
- controllers.add(new NetworkProviderCallsSmsController(context, lifecycle));
- }
+ controllers.add(new NetworkProviderCallsSmsController(context, lifecycle));
return controllers;
}
@@ -155,20 +153,7 @@
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.network_and_internet) {
-
- @Override
- // TODO(b/167474581): Should remove this method when Provider Model finished.
- public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
- boolean enabled) {
- if (Utils.isProviderModelEnabled(context)) {
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.network_provider_internet;
- return Arrays.asList(sir);
- }
- return super.getXmlResourcesToIndex(context, enabled);
- }
-
+ new BaseSearchIndexProvider(R.xml.network_provider_internet) {
@Override
public List<AbstractPreferenceController> createPreferenceControllers(Context
context) {
diff --git a/src/com/android/settings/network/NetworkProviderDownloadedSimListController.java b/src/com/android/settings/network/NetworkProviderDownloadedSimListController.java
index 1bb50cb..48cd8aa 100644
--- a/src/com/android/settings/network/NetworkProviderDownloadedSimListController.java
+++ b/src/com/android/settings/network/NetworkProviderDownloadedSimListController.java
@@ -36,7 +36,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.network.telephony.MobileNetworkActivity;
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -128,11 +127,7 @@
pref.setSummary(getSummary(subId));
pref.setOnPreferenceClickListener(clickedPref -> {
- final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
- intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
- // MobileNetworkActivity is singleTask, set SplitPairRule to show in 2-pane.
- MobileNetworkTwoPaneUtils.registerTwoPaneForMobileNetwork(mContext, intent, null);
- mContext.startActivity(intent);
+ MobileNetworkUtils.launchMobileNetworkSettings(mContext, info);
return true;
});
mPreferences.put(subId, pref);
diff --git a/src/com/android/settings/network/NetworkProviderSimListController.java b/src/com/android/settings/network/NetworkProviderSimListController.java
index d6eaab8..77d665a 100644
--- a/src/com/android/settings/network/NetworkProviderSimListController.java
+++ b/src/com/android/settings/network/NetworkProviderSimListController.java
@@ -36,7 +36,7 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.network.telephony.MobileNetworkActivity;
+import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -126,12 +126,7 @@
SubscriptionUtil.startToggleSubscriptionDialogActivity(mContext, subId,
true);
} else {
- final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
- intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
- // MobileNetworkActivity is singleTask, set SplitPairRule to show in 2-pane.
- MobileNetworkTwoPaneUtils.registerTwoPaneForMobileNetwork(mContext, intent,
- null);
- mContext.startActivity(intent);
+ MobileNetworkUtils.launchMobileNetworkSettings(mContext, info);
}
return true;
});
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index d7e5876..1ba0502 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -24,6 +24,7 @@
import android.annotation.Nullable;
import android.content.Context;
import android.os.ParcelUuid;
+import android.provider.Settings;
import android.telephony.PhoneNumberUtils;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
@@ -37,6 +38,8 @@
import com.android.internal.telephony.MccTable;
import com.android.settings.R;
+import com.android.settings.network.helper.SelectableSubscriptions;
+import com.android.settings.network.helper.SubscriptionAnnotation;
import com.android.settings.network.telephony.DeleteEuiccSubscriptionDialogActivity;
import com.android.settings.network.telephony.ToggleSubscriptionDialogActivity;
import com.android.settingslib.DeviceInfoUtils;
@@ -48,6 +51,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -643,4 +647,49 @@
private static int getDefaultDataSubscriptionId() {
return SubscriptionManager.getDefaultDataSubscriptionId();
}
+
+
+ /**
+ * Select one of the subscription as the default subscription.
+ * @param subAnnoList a list of {@link SubscriptionAnnotation}
+ * @return ideally the {@link SubscriptionAnnotation} as expected
+ */
+ private static SubscriptionAnnotation getDefaultSubscriptionSelection(
+ List<SubscriptionAnnotation> subAnnoList) {
+ return (subAnnoList == null) ? null :
+ subAnnoList.stream()
+ .filter(SubscriptionAnnotation::isDisplayAllowed)
+ .filter(SubscriptionAnnotation::isActive)
+ .findFirst().orElse(null);
+ }
+
+ public static SubscriptionInfo getSubscriptionOrDefault(Context context, int subscriptionId) {
+ return getSubscription(context, subscriptionId,
+ (subscriptionId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) ? null : (
+ subAnnoList -> getDefaultSubscriptionSelection(subAnnoList)
+ ));
+ }
+
+ /**
+ * Get the current subscription to display. First check whether intent has {@link
+ * Settings#EXTRA_SUB_ID} and if so find the subscription with that id.
+ * If not, select default one based on {@link Function} provided.
+ *
+ * @param preferredSubscriptionId preferred subscription id
+ * @param selectionOfDefault when true current subscription is absent
+ */
+ private static SubscriptionInfo getSubscription(Context context, int preferredSubscriptionId,
+ Function<List<SubscriptionAnnotation>, SubscriptionAnnotation> selectionOfDefault) {
+ List<SubscriptionAnnotation> subList =
+ (new SelectableSubscriptions(context, true)).call();
+ Log.d(TAG, "get subId=" + preferredSubscriptionId + " from " + subList);
+ SubscriptionAnnotation currentSubInfo = subList.stream()
+ .filter(SubscriptionAnnotation::isDisplayAllowed)
+ .filter(subAnno -> (subAnno.getSubscriptionId() == preferredSubscriptionId))
+ .findFirst().orElse(null);
+ if ((currentSubInfo == null) && (selectionOfDefault != null)) {
+ currentSubInfo = selectionOfDefault.apply(subList);
+ }
+ return (currentSubInfo == null) ? null : currentSubInfo.getSubInfo();
+ }
}
diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java
index 5541888..87c4697 100644
--- a/src/com/android/settings/network/SubscriptionsPreferenceController.java
+++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java
@@ -55,7 +55,6 @@
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.network.telephony.DataConnectivityListener;
-import com.android.settings.network.telephony.MobileNetworkActivity;
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settings.network.telephony.SignalStrengthListener;
import com.android.settings.network.telephony.TelephonyDisplayInfoListener;
@@ -237,7 +236,7 @@
});
mSubsGearPref.setOnGearClickListener(p ->
- startMobileNetworkActivity(mContext, subInfo.getSubscriptionId()));
+ MobileNetworkUtils.launchMobileNetworkSettings(mContext, subInfo));
}
if (!(mContext.getSystemService(UserManager.class)).isAdminUser()) {
@@ -335,14 +334,6 @@
mSubsGearPref.setSummary("");
}
- private static void startMobileNetworkActivity(Context context, int subId) {
- final Intent intent = new Intent(context, MobileNetworkActivity.class);
- intent.putExtra(Settings.EXTRA_SUB_ID, subId);
- // MobileNetworkActivity is singleTask, set SplitPairRule to show in 2-pane.
- MobileNetworkTwoPaneUtils.registerTwoPaneForMobileNetwork(context, intent, null);
- context.startActivity(intent);
- }
-
@VisibleForTesting
boolean shouldInflateSignalStrength(int subId) {
return SignalStrengthUtil.shouldInflateSignalStrength(mContext, subId);
diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index 25e0ae0..aa58663 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -23,9 +23,11 @@
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.util.Log;
+import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
@@ -59,16 +61,25 @@
private CarrierConfigManager mCarrierConfigManager;
private PreferenceEntriesBuilder mBuilder;
private SubscriptionsChangeListener mSubscriptionsListener;
+ private int mCallState = TelephonyManager.CALL_STATE_IDLE;
+ private PhoneCallStateTelephonyCallback mTelephonyCallback;
public EnabledNetworkModePreferenceController(Context context, String key) {
super(context, key);
mSubscriptionsListener = new SubscriptionsChangeListener(context, this);
mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
+ if (mTelephonyCallback == null) {
+ mTelephonyCallback = new PhoneCallStateTelephonyCallback();
+ }
}
@Override
public int getAvailabilityStatus(int subId) {
boolean visible;
+ if (!isCallStateIdle()) {
+ return AVAILABLE_UNSEARCHABLE;
+ }
+
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
visible = false;
@@ -87,23 +98,28 @@
return visible ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
+ protected boolean isCallStateIdle() {
+ return mCallState == TelephonyManager.CALL_STATE_IDLE;
+ }
@OnLifecycleEvent(ON_START)
public void onStart() {
mSubscriptionsListener.start();
- if (mAllowedNetworkTypesListener == null) {
+ if (mAllowedNetworkTypesListener == null || mTelephonyCallback == null) {
return;
}
mAllowedNetworkTypesListener.register(mContext, mSubId);
+ mTelephonyCallback.register(mTelephonyManager, mSubId);
}
@OnLifecycleEvent(ON_STOP)
public void onStop() {
mSubscriptionsListener.stop();
- if (mAllowedNetworkTypesListener == null) {
+ if (mAllowedNetworkTypesListener == null || mTelephonyCallback == null) {
return;
}
mAllowedNetworkTypesListener.unregister(mContext, mSubId);
+ mTelephonyCallback.unregister();
}
@Override
@@ -125,6 +141,7 @@
listPreference.setEntryValues(mBuilder.getEntryValues());
listPreference.setValue(Integer.toString(mBuilder.getSelectedEntryValue()));
listPreference.setSummary(mBuilder.getSummary());
+ listPreference.setEnabled(isCallStateIdle());
}
@Override
@@ -157,7 +174,6 @@
updatePreference();
});
}
-
lifecycle.addObserver(this);
}
@@ -828,6 +844,43 @@
}
+ @VisibleForTesting
+ class PhoneCallStateTelephonyCallback extends TelephonyCallback implements
+ TelephonyCallback.CallStateListener {
+
+ private TelephonyManager mTelephonyManager;
+
+ @Override
+ public void onCallStateChanged(int state) {
+ Log.d(LOG_TAG, "onCallStateChanged:" + state);
+ mCallState = state;
+ mBuilder.updateConfig();
+ updatePreference();
+ }
+
+ public void register(TelephonyManager telephonyManager, int subId) {
+ mTelephonyManager = telephonyManager;
+
+ // assign current call state so that it helps to show correct preference state even
+ // before first onCallStateChanged() by initial registration.
+ mCallState = mTelephonyManager.getCallState(subId);
+ mTelephonyManager.registerTelephonyCallback(
+ mContext.getMainExecutor(), mTelephonyCallback);
+ }
+
+ public void unregister() {
+ mCallState = TelephonyManager.CALL_STATE_IDLE;
+ if (mTelephonyManager != null) {
+ mTelephonyManager.unregisterTelephonyCallback(this);
+ }
+ }
+ }
+
+ @VisibleForTesting
+ PhoneCallStateTelephonyCallback getTelephonyCallback() {
+ return mTelephonyCallback;
+ }
+
@Override
public void onAirplaneModeChanged(boolean airplaneModeEnabled) {
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkActivity.java b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
index bbff57d..d3ff546 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkActivity.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
@@ -18,8 +18,8 @@
import static com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
-import android.app.ActionBar;
-import android.content.Context;
+import android.app.Activity;
+import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserManager;
@@ -29,84 +29,27 @@
import android.telephony.ims.ImsRcsManager;
import android.text.TextUtils;
import android.util.Log;
-import android.view.View;
-import android.widget.Toolbar;
-import androidx.annotation.NonNull;
-import androidx.annotation.VisibleForTesting;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-import androidx.lifecycle.Lifecycle;
-import com.android.settings.R;
-import com.android.settings.core.SettingsBaseActivity;
-import com.android.settings.network.ProxySubscriptionManager;
+import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
+import com.android.settings.activityembedding.ActivityEmbeddingUtils;
import com.android.settings.network.SubscriptionUtil;
-import com.android.settings.network.helper.SelectableSubscriptions;
-import com.android.settings.network.helper.SubscriptionAnnotation;
-
-import java.util.List;
-import java.util.function.Function;
/**
- * Activity for displaying MobileNetworkSettings
+ * Activity for displaying MobileNetworkSettings.
+ *
+ * @Deprecated The MobileNetworkActivity should be removed in Android U. Instead of using the
+ * singleTask activity which will cause an additional window transition when users launch the SIMs
+ * page, using the {@link com.android.settings.Settings.SubscriptionSettingsActivity} which can be
+ * managed by {@link SettingsActivity} and be migrated into the Settings architecture.
*/
-public class MobileNetworkActivity extends SettingsBaseActivity
- implements ProxySubscriptionManager.OnActiveSubscriptionChangedListener {
+@Deprecated
+public class MobileNetworkActivity extends Activity {
private static final String TAG = "MobileNetworkActivity";
- @VisibleForTesting
- static final String MOBILE_SETTINGS_TAG = "mobile_settings:";
- @VisibleForTesting
- static final int SUB_ID_NULL = Integer.MIN_VALUE;
-
- @VisibleForTesting
- ProxySubscriptionManager mProxySubscriptionMgr;
-
- private int mCurSubscriptionId = SUB_ID_NULL;
-
- // This flag forces subscription information fragment to be re-created.
- // Otherwise, fragment will be kept when subscription id has not been changed.
- //
- // Set initial value to true allows subscription information fragment to be re-created when
- // Activity re-create occur.
- private boolean mPendingSubscriptionChange = true;
-
- @Override
- protected void onNewIntent(Intent intent) {
- super.onNewIntent(intent);
- validate(intent);
- setIntent(intent);
-
- int updateSubscriptionIndex = mCurSubscriptionId;
- if (intent != null) {
- updateSubscriptionIndex = intent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL);
- }
- SubscriptionInfo info = getSubscriptionOrDefault(updateSubscriptionIndex);
- if (info == null) {
- Log.d(TAG, "Invalid subId request " + mCurSubscriptionId
- + " -> " + updateSubscriptionIndex);
- return;
- }
-
- int oldSubId = mCurSubscriptionId;
- updateSubscriptions(info, null);
-
- // If the subscription has changed or the new intent doesnt contain the opt in action,
- // remove the old discovery dialog. If the activity is being recreated, we will see
- // onCreate -> onNewIntent, so the dialog will first be recreated for the old subscription
- // and then removed.
- if (mCurSubscriptionId != oldSubId || !doesIntentContainOptInAction(intent)) {
- removeContactDiscoveryDialog(oldSubId);
- }
- // evaluate showing the new discovery dialog if this intent contains an action to show the
- // opt-in.
- if (doesIntentContainOptInAction(intent)) {
- maybeShowContactDiscoveryDialog(info);
- }
- }
-
+ public static final String SHOW_CAPABILITY_DISCOVERY_OPT_IN =
+ "show_capability_discovery_opt_in";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -116,318 +59,63 @@
return;
}
- final Toolbar toolbar = findViewById(R.id.action_bar);
- toolbar.setVisibility(View.VISIBLE);
- setActionBar(toolbar);
-
- final ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowTitleEnabled(true);
- }
-
- getProxySubscriptionManager().setLifecycle(getLifecycle());
-
- final Intent startIntent = getIntent();
- validate(startIntent);
- mCurSubscriptionId = savedInstanceState != null
- ? savedInstanceState.getInt(Settings.EXTRA_SUB_ID, SUB_ID_NULL)
- : ((startIntent != null)
- ? startIntent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL)
- : SUB_ID_NULL);
- // perform registration after mCurSubscriptionId been configured.
- registerActiveSubscriptionsListener();
-
- SubscriptionInfo subscription = getSubscriptionOrDefault(mCurSubscriptionId);
- if (subscription == null) {
- Log.d(TAG, "Invalid subId request " + mCurSubscriptionId);
- tryToFinishActivity();
+ // TODO: Move these intent's extra into SubscriptionSettingsActivity if the
+ // MobileNetworkActivity is removed in Android U.
+ Intent intent = getIntent();
+ if (intent == null) {
+ Log.d(TAG, "onCreate(), intent = null");
+ this.finish();
return;
}
- maybeShowContactDiscoveryDialog(subscription);
-
- updateSubscriptions(subscription, null);
- }
-
- @VisibleForTesting
- ProxySubscriptionManager getProxySubscriptionManager() {
- if (mProxySubscriptionMgr == null) {
- mProxySubscriptionMgr = ProxySubscriptionManager.getInstance(this);
- }
- return mProxySubscriptionMgr;
- }
-
- @VisibleForTesting
- void registerActiveSubscriptionsListener() {
- getProxySubscriptionManager().addActiveSubscriptionsListener(this);
- }
-
- /**
- * Implementation of ProxySubscriptionManager.OnActiveSubscriptionChangedListener
- */
- public void onChanged() {
- mPendingSubscriptionChange = false;
-
- if (mCurSubscriptionId == SUB_ID_NULL) {
- return;
+ Intent trampolineIntent;
+ final Intent subscriptionSettingsIntent = new Intent(this,
+ com.android.settings.Settings.SubscriptionSettingsActivity.class);
+ if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this) || !isTaskRoot()) {
+ trampolineIntent = subscriptionSettingsIntent;
+ } else {
+ trampolineIntent = new Intent(Settings.ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY)
+ .setPackage(Utils.SETTINGS_PACKAGE_NAME);
+ trampolineIntent.putExtra(
+ android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI,
+ subscriptionSettingsIntent.toUri(Intent.URI_INTENT_SCHEME));
}
- if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
- mPendingSubscriptionChange = true;
- return;
+ int subId = intent.getIntExtra(Settings.EXTRA_SUB_ID,
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ SubscriptionInfo subInfo = SubscriptionUtil.getSubscriptionOrDefault(this, subId);
+ CharSequence title = SubscriptionUtil.getUniqueSubscriptionDisplayName(subInfo, this);
+ trampolineIntent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE, title);
+ trampolineIntent.putExtra(Settings.EXTRA_SUB_ID, subId);
+ if (Settings.ACTION_MMS_MESSAGE_SETTING.equals(intent.getAction())) {
+ // highlight "mms_message" preference.
+ trampolineIntent.putExtra(EXTRA_FRAGMENT_ARG_KEY, "mms_message");
}
- SubscriptionInfo subInfo = getSubscription(mCurSubscriptionId, null);
- if (subInfo != null) {
- if (mCurSubscriptionId != subInfo.getSubscriptionId()) {
- // update based on subscription status change
- removeContactDiscoveryDialog(mCurSubscriptionId);
- updateSubscriptions(subInfo, null);
- }
- return;
+ if (doesIntentContainOptInAction(intent)) {
+ trampolineIntent.putExtra(SHOW_CAPABILITY_DISCOVERY_OPT_IN,
+ maybeShowContactDiscoveryDialog(subId));
}
- Log.w(TAG, "subId missing: " + mCurSubscriptionId);
-
- // When UI is not the active one, avoid from destroy it immediately
- // but wait until onResume() to see if subscription back online again.
- // This is to avoid from glitch behavior of subscription which changes
- // the UI when UI is considered as in the background or only partly
- // visible.
- if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
- mPendingSubscriptionChange = true;
- return;
- }
-
- // Subscription could be missing
- tryToFinishActivity();
- }
-
- protected void runSubscriptionUpdate(Runnable onUpdateRemaining) {
- SubscriptionInfo subInfo = getSubscription(mCurSubscriptionId, null);
- if (subInfo == null) {
- onUpdateRemaining.run();
- tryToFinishActivity();
- return;
- }
- if (mCurSubscriptionId != subInfo.getSubscriptionId()) {
- removeContactDiscoveryDialog(mCurSubscriptionId);
- updateSubscriptions(subInfo, null);
- }
- onUpdateRemaining.run();
- }
-
- protected void tryToFinishActivity() {
- if ((!isFinishing()) && (!isDestroyed())) {
+ startActivity(trampolineIntent);
+ if (isTaskRoot()) {
+ finishAndRemoveTask();
+ } else {
finish();
}
}
- @Override
- protected void onStart() {
- getProxySubscriptionManager().setLifecycle(getLifecycle());
- if (mPendingSubscriptionChange) {
- mPendingSubscriptionChange = false;
- runSubscriptionUpdate(() -> super.onStart());
- return;
- }
- super.onStart();
- }
-
- @Override
- protected void onResume() {
- if (mPendingSubscriptionChange) {
- mPendingSubscriptionChange = false;
- runSubscriptionUpdate(() -> super.onResume());
- return;
- }
- super.onResume();
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- if (mProxySubscriptionMgr == null) {
- return;
- }
- mProxySubscriptionMgr.removeActiveSubscriptionsListener(this);
- }
-
- @Override
- protected void onSaveInstanceState(@NonNull Bundle outState) {
- super.onSaveInstanceState(outState);
- saveInstanceState(outState);
- }
-
- @VisibleForTesting
- void saveInstanceState(@NonNull Bundle outState) {
- outState.putInt(Settings.EXTRA_SUB_ID, mCurSubscriptionId);
- }
-
- private void updateTitleAndNavigation(SubscriptionInfo subscription) {
- // Set the title to the name of the subscription. If we don't have subscription info, the
- // title will just default to the label for this activity that's already specified in
- // AndroidManifest.xml.
- if (subscription != null) {
- setTitle(SubscriptionUtil.getUniqueSubscriptionDisplayName(subscription, this));
- }
- }
-
- @VisibleForTesting
- void updateSubscriptions(SubscriptionInfo subscription, Bundle savedInstanceState) {
- if (subscription == null) {
- return;
- }
- final int subscriptionIndex = subscription.getSubscriptionId();
-
- updateTitleAndNavigation(subscription);
- if (savedInstanceState == null) {
- switchFragment(subscription);
- }
-
- mCurSubscriptionId = subscriptionIndex;
- }
-
- /**
- * Select one of the subscription as the default subscription.
- * @param subAnnoList a list of {@link SubscriptionAnnotation}
- * @return ideally the {@link SubscriptionAnnotation} as expected
- */
- protected SubscriptionAnnotation defaultSubscriptionSelection(
- List<SubscriptionAnnotation> subAnnoList) {
- return (subAnnoList == null) ? null :
- subAnnoList.stream()
- .filter(SubscriptionAnnotation::isDisplayAllowed)
- .filter(SubscriptionAnnotation::isActive)
- .findFirst().orElse(null);
- }
-
- protected SubscriptionInfo getSubscriptionOrDefault(int subscriptionId) {
- return getSubscription(subscriptionId,
- (subscriptionId != SUB_ID_NULL) ? null : (
- subAnnoList -> defaultSubscriptionSelection(subAnnoList)
- ));
- }
-
- /**
- * Get the current subscription to display. First check whether intent has {@link
- * Settings#EXTRA_SUB_ID} and if so find the subscription with that id.
- * If not, select default one based on {@link Function} provided.
- *
- * @param preferredSubscriptionId preferred subscription id
- * @param selectionOfDefault when true current subscription is absent
- */
- @VisibleForTesting
- protected SubscriptionInfo getSubscription(int preferredSubscriptionId,
- Function<List<SubscriptionAnnotation>, SubscriptionAnnotation> selectionOfDefault) {
- List<SubscriptionAnnotation> subList =
- (new SelectableSubscriptions(this, true)).call();
- Log.d(TAG, "get subId=" + preferredSubscriptionId + " from " + subList);
- SubscriptionAnnotation currentSubInfo = subList.stream()
- .filter(SubscriptionAnnotation::isDisplayAllowed)
- .filter(subAnno -> (subAnno.getSubscriptionId() == preferredSubscriptionId))
- .findFirst().orElse(null);
- if ((currentSubInfo == null) && (selectionOfDefault != null)) {
- currentSubInfo = selectionOfDefault.apply(subList);
- }
- return (currentSubInfo == null) ? null : currentSubInfo.getSubInfo();
- }
-
- @VisibleForTesting
- SubscriptionInfo getSubscriptionForSubId(int subId) {
- return SubscriptionUtil.getAvailableSubscription(this,
- getProxySubscriptionManager(), subId);
- }
-
- @VisibleForTesting
- void switchFragment(SubscriptionInfo subInfo) {
- final FragmentManager fragmentManager = getSupportFragmentManager();
- final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
-
- final int subId = subInfo.getSubscriptionId();
- final Intent intent = getIntent();
- final Bundle bundle = new Bundle();
- bundle.putInt(Settings.EXTRA_SUB_ID, subId);
- if (intent != null && Settings.ACTION_MMS_MESSAGE_SETTING.equals(intent.getAction())) {
- // highlight "mms_message" preference.
- bundle.putString(EXTRA_FRAGMENT_ARG_KEY, "mms_message");
- }
-
- final String fragmentTag = buildFragmentTag(subId);
- if (fragmentManager.findFragmentByTag(fragmentTag) != null) {
- Log.d(TAG, "Construct fragment: " + fragmentTag);
- }
-
- final Fragment fragment = new MobileNetworkSettings();
- fragment.setArguments(bundle);
- fragmentTransaction.replace(R.id.content_frame, fragment, fragmentTag);
- fragmentTransaction.commitAllowingStateLoss();
- }
-
- private void removeContactDiscoveryDialog(int subId) {
- ContactDiscoveryDialogFragment fragment = getContactDiscoveryFragment(subId);
- if (fragment != null) {
- fragment.dismiss();
- }
- }
-
- private ContactDiscoveryDialogFragment getContactDiscoveryFragment(int subId) {
- // In the case that we are rebuilding this activity after it has been destroyed and
- // recreated, look up the dialog in the fragment manager.
- return (ContactDiscoveryDialogFragment) getSupportFragmentManager()
- .findFragmentByTag(ContactDiscoveryDialogFragment.getFragmentTag(subId));
- }
-
- private void maybeShowContactDiscoveryDialog(SubscriptionInfo info) {
- int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
- CharSequence carrierName = "";
- if (info != null) {
- subId = info.getSubscriptionId();
- carrierName = SubscriptionUtil.getUniqueSubscriptionDisplayName(info, this);
- }
+ private boolean maybeShowContactDiscoveryDialog(int subId) {
// If this activity was launched using ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN, show the
// associated dialog only if the opt-in has not been granted yet.
- boolean showOptInDialog = doesIntentContainOptInAction(getIntent())
- // has the carrier config enabled capability discovery?
- && MobileNetworkUtils.isContactDiscoveryVisible(this, subId)
+ return MobileNetworkUtils.isContactDiscoveryVisible(this, subId)
// has the user already enabled this configuration?
&& !MobileNetworkUtils.isContactDiscoveryEnabled(this, subId);
- ContactDiscoveryDialogFragment fragment = getContactDiscoveryFragment(subId);
- if (showOptInDialog) {
- if (fragment == null) {
- fragment = ContactDiscoveryDialogFragment.newInstance(subId, carrierName);
- }
- // Only try to show the dialog if it has not already been added, otherwise we may
- // accidentally add it multiple times, causing multiple dialogs.
- if (!fragment.isAdded()) {
- fragment.show(getSupportFragmentManager(),
- ContactDiscoveryDialogFragment.getFragmentTag(subId));
- }
- }
}
- private boolean doesIntentContainOptInAction(Intent intent) {
+ public static boolean doesIntentContainOptInAction(Intent intent) {
String intentAction = (intent != null ? intent.getAction() : null);
return TextUtils.equals(intentAction,
ImsRcsManager.ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN);
}
-
- private void validate(Intent intent) {
- // Do not allow ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN without a subscription id specified,
- // since we do not want the user to accidentally turn on capability polling for the wrong
- // subscription.
- if (doesIntentContainOptInAction(intent)) {
- if (SUB_ID_NULL == intent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL)) {
- throw new IllegalArgumentException("Intent with action "
- + "SHOW_CAPABILITY_DISCOVERY_OPT_IN must also include the extra "
- + "Settings#EXTRA_SUB_ID");
- }
- }
- }
-
- @VisibleForTesting
- String buildFragmentTag(int subscriptionId) {
- return MOBILE_SETTINGS_TAG + subscriptionId;
- }
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index ba80a8c..cf0f889 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -23,8 +23,10 @@
import android.os.Bundle;
import android.os.UserManager;
import android.provider.Settings;
+import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import android.telephony.ims.ImsRcsManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
@@ -39,6 +41,7 @@
import com.android.settings.datausage.DataUsageSummaryPreferenceController;
import com.android.settings.network.ActiveSubscriptionsListener;
import com.android.settings.network.CarrierWifiTogglePreferenceController;
+import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.telephony.cdma.CdmaSubscriptionPreferenceController;
import com.android.settings.network.telephony.cdma.CdmaSystemSelectPreferenceController;
import com.android.settings.network.telephony.gsm.AutoSelectPreferenceController;
@@ -115,9 +118,16 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- mSubId = getArguments().getInt(Settings.EXTRA_SUB_ID,
- MobileNetworkUtils.getSearchableSubscriptionId(context));
- Log.i(LOG_TAG, "display subId: " + mSubId);
+ Intent intent = getIntent();
+ if (intent != null) {
+ mSubId = intent.getIntExtra(Settings.EXTRA_SUB_ID,
+ MobileNetworkUtils.getSearchableSubscriptionId(context));
+ Log.i(LOG_TAG, "display subId from intent: " + mSubId);
+ } else {
+ mSubId = getArguments().getInt(Settings.EXTRA_SUB_ID,
+ MobileNetworkUtils.getSearchableSubscriptionId(context));
+ Log.i(LOG_TAG, "display subId from getArguments(): " + mSubId);
+ }
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
return Arrays.asList();
@@ -131,6 +141,30 @@
public void onAttach(Context context) {
super.onAttach(context);
+ Intent intent = getIntent();
+ SubscriptionInfo info = SubscriptionUtil.getSubscriptionOrDefault(context, mSubId);
+ if (info == null) {
+ Log.d(LOG_TAG, "Invalid subId request " + mSubId);
+ return;
+ }
+
+ int oldSubId = mSubId;
+ updateSubscriptions(info);
+ // If the subscription has changed or the new intent does not contain the opt in action,
+ // remove the old discovery dialog. If the activity is being recreated, we will see
+ // onCreate -> onNewIntent, so the dialog will first be recreated for the old subscription
+ // and then removed.
+ if (!MobileNetworkActivity.doesIntentContainOptInAction(intent)) {
+ removeContactDiscoveryDialog(oldSubId);
+ }
+
+ // evaluate showing the new discovery dialog if this intent contains an action to show the
+ // opt-in.
+ if (MobileNetworkActivity.doesIntentContainOptInAction(intent)) {
+ showContactDiscoveryDialog(
+ SubscriptionUtil.getSubscriptionOrDefault(context, mSubId));
+ }
+
final DataUsageSummaryPreferenceController dataUsageSummaryPreferenceController =
use(DataUsageSummaryPreferenceController.class);
if (dataUsageSummaryPreferenceController != null) {
@@ -339,4 +373,49 @@
return context.getSystemService(UserManager.class).isAdminUser();
}
};
+
+ private ContactDiscoveryDialogFragment getContactDiscoveryFragment(int subId) {
+ // In the case that we are rebuilding this activity after it has been destroyed and
+ // recreated, look up the dialog in the fragment manager.
+ return (ContactDiscoveryDialogFragment) getChildFragmentManager()
+ .findFragmentByTag(ContactDiscoveryDialogFragment.getFragmentTag(subId));
+ }
+
+
+ private void removeContactDiscoveryDialog(int subId) {
+ ContactDiscoveryDialogFragment fragment = getContactDiscoveryFragment(subId);
+ if (fragment != null) {
+ fragment.dismiss();
+ }
+ }
+
+ private void showContactDiscoveryDialog(SubscriptionInfo info) {
+ if (info == null) {
+ Log.d(LOG_TAG, "Invalid subId request " + mSubId);
+ onDestroy();
+ return;
+ }
+
+ CharSequence carrierName = SubscriptionUtil.getUniqueSubscriptionDisplayName(info,
+ getContext());
+ ContactDiscoveryDialogFragment fragment = getContactDiscoveryFragment(mSubId);
+ if (fragment == null) {
+ fragment = ContactDiscoveryDialogFragment.newInstance(mSubId, carrierName);
+ }
+ // Only try to show the dialog if it has not already been added, otherwise we may
+ // accidentally add it multiple times, causing multiple dialogs.
+ if (!fragment.isAdded()) {
+ fragment.show(getChildFragmentManager(),
+ ContactDiscoveryDialogFragment.getFragmentTag(mSubId));
+ }
+ }
+
+ private void updateSubscriptions(SubscriptionInfo subscription) {
+ if (subscription == null) {
+ return;
+ }
+ final int subscriptionIndex = subscription.getSubscriptionId();
+
+ mSubId = subscriptionIndex;
+ }
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 658f650..e2d158d 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -45,6 +45,7 @@
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
+import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.SystemClock;
import android.os.SystemProperties;
@@ -73,9 +74,11 @@
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.SubSettingLauncher;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.ims.WifiCallingQueryImsState;
import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
+import com.android.settingslib.core.instrumentation.Instrumentable;
import com.android.settingslib.development.DevelopmentSettingsEnabler;
import com.android.settingslib.graph.SignalDrawable;
import com.android.settingslib.utils.ThreadUtils;
@@ -1008,4 +1011,21 @@
return context.getResources().getString(resId);
}
+ public static void launchMobileNetworkSettings(Context context, SubscriptionInfo info) {
+ final int subId = info.getSubscriptionId();
+ if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ Log.d(TAG, "launchMobileNetworkSettings fail, subId is invalid");
+ return;
+ }
+
+ final Bundle extra = new Bundle();
+ extra.putInt(Settings.EXTRA_SUB_ID, subId);
+ new SubSettingLauncher(context)
+ .setTitleText(SubscriptionUtil.getUniqueSubscriptionDisplayName(info, context))
+ .setDestination(MobileNetworkSettings.class.getCanonicalName())
+ .setSourceMetricsCategory(Instrumentable.METRICS_CATEGORY_UNKNOWN)
+ .setArguments(extra)
+ .launch();
+ }
+
}
diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java
index 84b7523..6d15737 100644
--- a/src/com/android/settings/sim/SimSelectNotification.java
+++ b/src/com/android/settings/sim/SimSelectNotification.java
@@ -52,7 +52,6 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.HelpTrampoline;
import com.android.settings.R;
-import com.android.settings.network.MobileNetworkTwoPaneUtils;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.telephony.MobileNetworkActivity;
@@ -264,9 +263,6 @@
Intent resultIntent = new Intent(Settings.ACTION_MMS_MESSAGE_SETTING);
resultIntent.setClass(context, MobileNetworkActivity.class);
resultIntent.putExtra(Settings.EXTRA_SUB_ID, subId);
- // MobileNetworkActivity is singleTask, set SplitPairRule to show in 2-pane.
- MobileNetworkTwoPaneUtils.registerTwoPaneForMobileNetwork(context, resultIntent,
- Settings.ACTION_MMS_MESSAGE_SETTING);
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
builder.setContentIntent(resultPendingIntent);
diff --git a/src/com/android/settings/wifi/ConfigureWifiSettings.java b/src/com/android/settings/wifi/ConfigureWifiSettings.java
index 68d47b5..6bb4389 100644
--- a/src/com/android/settings/wifi/ConfigureWifiSettings.java
+++ b/src/com/android/settings/wifi/ConfigureWifiSettings.java
@@ -58,9 +58,7 @@
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
- getActivity().setTitle(R.string.network_and_internet_preferences_title);
- }
+ getActivity().setTitle(R.string.network_and_internet_preferences_title);
mCertinstallerPreference = findPreference(KEY_INSTALL_CREDENTIALS);
if (mCertinstallerPreference != null) {
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
index 3636341..c73bffa 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
@@ -179,7 +179,8 @@
.setTitle(res.getText(R.string.wifi_calling_settings_title))
.addEndItem(
SliceAction.createToggle(
- getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED),
+ getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED,
+ isWifiCallingEnabled),
null /* actionTitle */, isWifiCallingEnabled))
.setPrimaryAction(SliceAction.createDeeplink(
getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
@@ -316,7 +317,7 @@
final Resources res = getResourcesForSubId(subId);
return new RowBuilder()
.setTitle(res.getText(preferenceTitleResId))
- .setTitleItem(SliceAction.createToggle(getBroadcastIntent(action),
+ .setTitleItem(SliceAction.createToggle(getBroadcastIntent(action, checked),
icon, res.getText(preferenceTitleResId), checked));
}
@@ -370,25 +371,31 @@
public void handleWifiCallingChanged(Intent intent) {
final int subId = getDefaultVoiceSubId();
- if (SubscriptionManager.isValidSubscriptionId(subId)) {
+ if (SubscriptionManager.isValidSubscriptionId(subId)
+ && intent.hasExtra(EXTRA_TOGGLE_STATE)) {
final WifiCallingQueryImsState queryState = queryImsState(subId);
if (queryState.isWifiCallingProvisioned()) {
- final boolean currentValue = queryState.isEnabledByUser()
- && queryState.isAllowUserControl();
+ final boolean currentValue = isWifiCallingEnabled();
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
currentValue);
final Intent activationAppIntent =
getWifiCallingCarrierActivityIntent(subId);
- if (!newValue || activationAppIntent == null) {
+ if ((newValue == currentValue) && activationAppIntent == null) {
// If either the action is to turn off wifi calling setting
// or there is no activation involved - Update the setting
- if (newValue != currentValue) {
- final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
- imsMmTelManager.setVoWiFiSettingEnabled(newValue);
- }
+ final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
+ imsMmTelManager.setVoWiFiSettingEnabled(!newValue);
+ } else {
+ Log.w(TAG, "action not taken: subId " + subId
+ + " from " + currentValue + " to " + newValue);
}
+ } else {
+ Log.w(TAG, "action not taken: subId " + subId + " needs provision");
}
+ } else {
+ Log.w(TAG, "action not taken: subId " + subId);
}
+
// notify change in slice in any case to get re-queried. This would result in displaying
// appropriate message with the updated setting.
mContext.getContentResolver().notifyChange(WIFI_CALLING_URI, null);
@@ -541,10 +548,20 @@
PendingIntent.FLAG_IMMUTABLE);
}
- private PendingIntent getBroadcastIntent(String action) {
+ /**
+ * Create PendingIntent for Slice.
+ * Note: SliceAction#createDeeplink() didn't support toggle status so far,
+ * therefore, embedding toggle status within PendingIntent.
+ *
+ * @param action Slice action
+ * @param isChecked Status when Slice created.
+ * @return PendingIntent
+ */
+ private PendingIntent getBroadcastIntent(String action, boolean isChecked) {
final Intent intent = new Intent(action);
intent.setClass(mContext, SliceBroadcastReceiver.class);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ intent.putExtra(EXTRA_TOGGLE_STATE, isChecked);
return PendingIntent.getBroadcast(mContext, 0 /* requestCode */, intent,
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp
index bc25377..2945bef 100644
--- a/tests/robotests/Android.bp
+++ b/tests/robotests/Android.bp
@@ -37,7 +37,6 @@
"com.google.android.material_material",
"setupcompat",
"setupdesign",
- "androidx-constraintlayout_constraintlayout-solver",
"androidx.lifecycle_lifecycle-runtime",
"androidx.lifecycle_lifecycle-extensions",
"androidx.test.core",
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
index 6870e7a..b60bfb8 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
@@ -212,86 +212,6 @@
}
@Test
- @Ignore
- public void getSummary_twoSubscriptions_correctSummaryAndFragment() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
- final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
- final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
- when(sub1.getSubscriptionId()).thenReturn(1);
- when(sub2.getSubscriptionId()).thenReturn(2);
-
- SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
- mController.displayPreference(mPreferenceScreen);
- mController.onResume();
- assertThat(mController.getSummary()).isEqualTo("2 SIMs");
- assertThat(mPreference.getFragment()).isEqualTo(MobileNetworkListFragment.class.getName());
- }
-
- @Test
- @Ignore
- public void getSummaryAfterUpdate_twoSubscriptionsBecomesOne_correctSummaryAndFragment() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
- final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
- final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
- when(sub1.getSubscriptionId()).thenReturn(1);
- when(sub2.getSubscriptionId()).thenReturn(2);
- when(sub1.getDisplayName()).thenReturn("sub1");
- when(sub2.getDisplayName()).thenReturn("sub2");
-
- SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
- SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
- mController.displayPreference(mPreferenceScreen);
- mController.onResume();
- assertThat(mController.getSummary()).isEqualTo("2 SIMs");
- assertThat(mPreference.getFragment()).isEqualTo(MobileNetworkListFragment.class.getName());
-
- // Simulate sub2 having disappeared - the end result should change to be the same as
- // if there were just one subscription.
- SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
- mController.onSubscriptionsChanged();
- assertThat(mController.getSummary()).isEqualTo("sub1");
- assertThat(mPreference.getFragment()).isNull();
- final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
- doNothing().when(mContext).startActivity(intentCaptor.capture());
- mPreference.getOnPreferenceClickListener().onPreferenceClick(mPreference);
- assertThat(intentCaptor.getValue().getComponent().getClassName()).isEqualTo(
- MobileNetworkActivity.class.getName());
- }
-
- @Test
- @Ignore
- public void getSummaryAfterUpdate_oneSubscriptionBecomesTwo_correctSummaryAndFragment() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
- final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
- final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
- when(sub1.getSubscriptionId()).thenReturn(1);
- when(sub2.getSubscriptionId()).thenReturn(2);
- when(sub1.getDisplayName()).thenReturn("sub1");
- when(sub2.getDisplayName()).thenReturn("sub2");
-
- when(mSubscriptionManager.getAvailableSubscriptionInfoList()).thenReturn(
- Arrays.asList(sub1));
- SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1));
- mController.displayPreference(mPreferenceScreen);
- mController.onResume();
- assertThat(mController.getSummary()).isEqualTo("sub1");
- assertThat(mPreference.getFragment()).isNull();
- final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
- doNothing().when(mContext).startActivity(intentCaptor.capture());
- mPreference.getOnPreferenceClickListener().onPreferenceClick(mPreference);
- assertThat(intentCaptor.getValue().getComponent().getClassName()).isEqualTo(
- MobileNetworkActivity.class.getName());
-
- // Simulate sub2 appearing in the list of subscriptions and check the results.
- SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
- mController.displayPreference(mPreferenceScreen);
- mController.onResume();
- assertThat(mController.getSummary()).isEqualTo("2 SIMs");
- assertThat(mPreference.getFragment()).isEqualTo(MobileNetworkListFragment.class.getName());
- }
-
- @Test
- @Ignore
public void getSummary_providerModel_Enabled() {
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
@@ -302,15 +222,9 @@
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
mController.displayPreference(mPreferenceScreen);
mController.onResume();
assertThat(mController.getSummary()).isEqualTo("sub1, sub2");
-
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
- mController.displayPreference(mPreferenceScreen);
- mController.onResume();
- assertThat(mController.getSummary()).isEqualTo("2 SIMs");
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
index 459d77e..5729208 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
@@ -16,13 +16,10 @@
package com.android.settings.network.telephony;
-import static androidx.lifecycle.Lifecycle.State;
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
import static org.robolectric.Shadows.shadowOf;
import android.content.Context;
@@ -30,21 +27,17 @@
import android.os.Bundle;
import android.os.UserManager;
import android.provider.Settings;
-import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
import androidx.test.core.app.ActivityScenario;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
-import com.android.internal.telephony.TelephonyIntents;
-import com.android.settings.network.ProxySubscriptionManager;
+import com.android.settings.SettingsActivity;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -58,22 +51,16 @@
@RunWith(AndroidJUnit4.class)
public class MobileNetworkActivityTest {
- private static final int CURRENT_SUB_ID = 3;
- private static final int PREV_SUB_ID = 1;
+ private static final int SUB_ID = 1;
+ private static final String DISPLAY_NAME = "SUB_ID";
private Context mContext;
private ShadowContextImpl mShadowContextImpl;
private Intent mTestIntent;
-
@Mock
private UserManager mUserManager;
- @Mock
- private TelephonyManager mTelephonyManager;
-
private ShadowSubscriptionManager mSubscriptionManager;
- private SubscriptionInfo mSubscriptionInfo1;
- private SubscriptionInfo mSubscriptionInfo2;
-
+ private SubscriptionInfo mSubscriptionInfo;
private ActivityScenario<MobileNetworkActivity> mMobileNetworkActivity;
@Before
@@ -82,20 +69,16 @@
mContext = ApplicationProvider.getApplicationContext();
mShadowContextImpl = Shadow.extract(RuntimeEnvironment.application.getBaseContext());
-
+ mSubscriptionManager = shadowOf(mContext.getSystemService(SubscriptionManager.class));
mShadowContextImpl.setSystemService(Context.USER_SERVICE, mUserManager);
doReturn(true).when(mUserManager).isAdminUser();
- mShadowContextImpl.setSystemService(Context.TELEPHONY_SERVICE, mTelephonyManager);
- doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt());
-
- mTestIntent = new Intent(mContext, MockMobileNetworkActivity.class);
-
- mSubscriptionManager = shadowOf(mContext.getSystemService(SubscriptionManager.class));
- mSubscriptionInfo1 = SubscriptionInfoBuilder.newBuilder()
- .setId(PREV_SUB_ID).buildSubscriptionInfo();
- mSubscriptionInfo2 = SubscriptionInfoBuilder.newBuilder()
- .setId(CURRENT_SUB_ID).buildSubscriptionInfo();
+ mTestIntent = new Intent(mContext, MobileNetworkActivity.class);
+ mSubscriptionInfo = SubscriptionInfoBuilder.newBuilder()
+ .setId(SUB_ID).setDisplayName(DISPLAY_NAME).buildSubscriptionInfo();
+ mTestIntent.putExtra(Settings.EXTRA_SUB_ID, SUB_ID);
+ mTestIntent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE,
+ mSubscriptionInfo.getDisplayName());
}
@After
@@ -105,116 +88,21 @@
}
}
- private static class MockMobileNetworkActivity extends MobileNetworkActivity {
- private MockMobileNetworkActivity() {
- super();
- }
-
- private SubscriptionInfo mSubscriptionInFragment;
-
- @Override
- ProxySubscriptionManager getProxySubscriptionManager() {
- if (mProxySubscriptionMgr == null) {
- mProxySubscriptionMgr = mock(ProxySubscriptionManager.class);
- }
- return mProxySubscriptionMgr;
- }
-
- @Override
- void registerActiveSubscriptionsListener() {
- onChanged();
- }
-
- @Override
- void switchFragment(SubscriptionInfo subInfo) {
- mSubscriptionInFragment = subInfo;
- }
- }
-
private ActivityScenario<MobileNetworkActivity> createTargetActivity(Intent activityIntent) {
return ActivityScenario.launch(activityIntent);
}
@Test
- @Ignore
- public void updateBottomNavigationView_oneSubscription_shouldNotCrash() {
- mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1);
-
+ public void onCreate_getExtraFromIntent() {
+ mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo);
mMobileNetworkActivity = createTargetActivity(mTestIntent);
- mMobileNetworkActivity.moveToState(State.STARTED);
- }
-
- @Test
- @Ignore
- public void updateBottomNavigationView_twoSubscription_shouldNotCrash() {
- mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1, mSubscriptionInfo2);
-
- mMobileNetworkActivity = createTargetActivity(mTestIntent);
-
- mMobileNetworkActivity.moveToState(State.STARTED);
- }
-
- @Test
- @Ignore
- public void switchFragment_switchBetweenTwoSubscriptions() {
- mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1, mSubscriptionInfo2);
-
- mTestIntent.putExtra(Settings.EXTRA_SUB_ID, PREV_SUB_ID);
- mMobileNetworkActivity = createTargetActivity(mTestIntent);
-
- mMobileNetworkActivity.moveToState(State.STARTED);
-
- mMobileNetworkActivity.onActivity(activity -> {
- final MockMobileNetworkActivity mockActivity = (MockMobileNetworkActivity) activity;
- mockActivity.switchFragment(mSubscriptionInfo1);
- assertThat(mockActivity.mSubscriptionInFragment).isEqualTo(mSubscriptionInfo1);
- });
- }
-
- @Test
- @Ignore
- public void switchFragment_subscriptionsUpdate_notifyByIntent() {
- mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1, mSubscriptionInfo2);
-
- mTestIntent.putExtra(Settings.EXTRA_SUB_ID, PREV_SUB_ID);
- mMobileNetworkActivity = createTargetActivity(mTestIntent);
-
- mMobileNetworkActivity.moveToState(State.STARTED);
-
- mMobileNetworkActivity.onActivity(activity -> {
- final MockMobileNetworkActivity mockActivity = (MockMobileNetworkActivity) activity;
- mockActivity.switchFragment(mSubscriptionInfo1);
- assertThat(mockActivity.mSubscriptionInFragment).isEqualTo(mSubscriptionInfo1);
-
- mContext.sendBroadcast(new Intent(
- CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED), null);
-
- mockActivity.switchFragment(mSubscriptionInfo2);
- assertThat(mockActivity.mSubscriptionInFragment).isEqualTo(mSubscriptionInfo2);
-
- mContext.sendBroadcast(new Intent(
- TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED), null);
-
- mockActivity.switchFragment(mSubscriptionInfo1);
- assertThat(mockActivity.mSubscriptionInFragment).isEqualTo(mSubscriptionInfo1);
- });
- }
-
- @Test
- @Ignore
- public void onSaveInstanceState_saveCurrentSubId() {
- mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1, mSubscriptionInfo2);
-
- mTestIntent.putExtra(Settings.EXTRA_SUB_ID, PREV_SUB_ID);
- mMobileNetworkActivity = createTargetActivity(mTestIntent);
-
- mMobileNetworkActivity.moveToState(State.STARTED);
-
mMobileNetworkActivity.onActivity(activity -> {
final Bundle bundle = new Bundle();
- activity.saveInstanceState(bundle);
- assertThat(bundle.getInt(Settings.EXTRA_SUB_ID)).isEqualTo(PREV_SUB_ID);
+ activity.onCreate(bundle);
+ assertThat(bundle.getInt(Settings.EXTRA_SUB_ID)).isEqualTo(SUB_ID);
+ assertThat(bundle.getString(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE)).isEqualTo(
+ DISPLAY_NAME);
});
}
}
diff --git a/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java b/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java
new file mode 100644
index 0000000..a97656c
--- /dev/null
+++ b/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2021 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 org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.app.LocaleManager;
+import android.content.Context;
+import android.os.LocaleList;
+import android.os.Looper;
+import android.telephony.TelephonyManager;
+
+import androidx.test.annotation.UiThreadTest;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.google.common.collect.Iterables;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.util.Locale;
+
+@RunWith(AndroidJUnit4.class)
+public class AppLocaleDetailsTest {
+ private static final String APP_PACKAGE_NAME = "app_package_name";
+
+ @Mock
+ private TelephonyManager mTelephonyManager;
+ @Mock
+ private LocaleManager mLocaleManager;
+
+ private Context mContext;
+ private LocaleList mSystemLocales;
+ private Locale mSimLocale;
+ private LocaleList mAppLocale;
+ private String[] mAssetLocales;
+
+ @Before
+ @UiThreadTest
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+ mContext = spy(ApplicationProvider.getApplicationContext());
+ when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
+ when(mContext.getSystemService(LocaleManager.class)).thenReturn(mLocaleManager);
+
+ setupInitialLocales("en",
+ "uk",
+ "en, uk, jp, ne",
+ new String[]{"en", "ne", "ms", "pa"});
+ }
+
+ @Test
+ @UiThreadTest
+ public void handleAllLocalesData_localeManagerIsNull_noCrash() {
+ when(mContext.getSystemService(LocaleManager.class)).thenReturn(null);
+
+ DummyAppLocaleDetailsHelper helper =
+ new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
+
+ helper.handleAllLocalesData();
+ }
+
+ @Test
+ @UiThreadTest
+ public void handleAllLocalesData_1stLocaleOfSuggestedLocaleListIsAppLocale() {
+ DummyAppLocaleDetailsHelper helper =
+ new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
+
+ helper.handleAllLocalesData();
+
+ Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
+ assertTrue(locale.equals(mAppLocale.get(0)));
+ }
+
+ @Test
+ @UiThreadTest
+ public void handleAllLocalesData_2ndLocaleOfSuggestedLocaleListIsSimLocale() {
+ DummyAppLocaleDetailsHelper helper =
+ new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
+
+ helper.handleAllLocalesData();
+
+ Locale locale = Iterables.get(helper.getSuggestedLocales(), 1);
+ assertTrue(locale.equals(mSimLocale));
+ }
+
+ @Test
+ @UiThreadTest
+ public void handleAllLocalesData_withoutAppLocale_1stLocaleOfSuggestedLocaleListIsSimLocal() {
+ setupInitialLocales("",
+ "uk",
+ "en, uk, jp, ne",
+ new String[]{"en", "ne", "ms", "pa"});
+ DummyAppLocaleDetailsHelper helper =
+ new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
+
+ helper.handleAllLocalesData();
+
+ Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
+ assertTrue(locale.equals(mSimLocale));
+ }
+
+ @Test
+ @UiThreadTest
+ public void handleAllLocalesData_noAppAndSimLocale_1stLocaleIsFirstOneInSystemLocales() {
+ setupInitialLocales("",
+ "",
+ "en, uk, jp, ne",
+ new String[]{"en", "ne", "ms", "pa"});
+ DummyAppLocaleDetailsHelper helper =
+ new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
+
+ helper.handleAllLocalesData();
+
+ Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
+ assertTrue(locale.equals(mSystemLocales.get(0)));
+ }
+
+ @Test
+ @UiThreadTest
+ public void handleAllLocalesData_supportLocaleListIsNotEmpty() {
+ DummyAppLocaleDetailsHelper helper =
+ new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
+
+ helper.handleAllLocalesData();
+
+ assertFalse(helper.getSupportedLocales().isEmpty());
+ }
+
+ /**
+ * Sets the initial Locale data
+ *
+ * @param appLocale Application locale, it shall be a language tag.
+ * example: "en"
+ * @param simLocale SIM carrier locale, it shall be a language tag.
+ * example: "en"
+ * @param systemLocales System locales, a locale list by a multiple language tags with comma.
+ * example: "en, uk, jp"
+ * @param assetLocales Asset locales, a locale list by a multiple language tags with String
+ * array.
+ * example: new String[] {"en", "ne", "ms", "pa"}
+ */
+ private void setupInitialLocales(String appLocale,
+ String simLocale,
+ String systemLocales,
+ String[] assetLocales) {
+ mAppLocale = LocaleList.forLanguageTags(appLocale);
+ mSimLocale = Locale.forLanguageTag(simLocale);
+ mSystemLocales = LocaleList.forLanguageTags(systemLocales);
+ mAssetLocales = assetLocales;
+ when(mTelephonyManager.getSimLocale()).thenReturn(simLocale.isEmpty() ? null : mSimLocale);
+ when(mLocaleManager.getApplicationLocales(anyString())).thenReturn(mAppLocale);
+ }
+
+ private class DummyAppLocaleDetailsHelper
+ extends AppLocaleDetails.AppLocaleDetailsHelper {
+
+ DummyAppLocaleDetailsHelper(Context context, String packageName) {
+ super(context, packageName);
+ }
+
+ @Override
+ String[] getAssetSystemLocales() {
+ return mAssetLocales;
+ }
+
+ @Override
+ LocaleList getCurrentSystemLocales() {
+ return mSystemLocales;
+ }
+ }
+
+}
diff --git a/tests/unit/src/com/android/settings/applications/appinfo/AppLocalePreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/appinfo/AppLocalePreferenceControllerTest.java
new file mode 100644
index 0000000..d7e3f92
--- /dev/null
+++ b/tests/unit/src/com/android/settings/applications/appinfo/AppLocalePreferenceControllerTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2021 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.Mockito.spy;
+
+import android.content.Context;
+import android.util.FeatureFlagUtils;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+
+@RunWith(AndroidJUnit4.class)
+public class AppLocalePreferenceControllerTest {
+
+ private Context mContext;
+ private AppLocalePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(ApplicationProvider.getApplicationContext());
+
+ mController = spy(new AppLocalePreferenceController(mContext, "test_key"));
+ FeatureFlagUtils
+ .setEnabled(mContext, FeatureFlagUtils.SETTINGS_APP_LANGUAGE_SELECTION, true);
+ }
+
+ @Test
+ public void getAvailabilityStatus_featureFlagOff_shouldReturnUnavailable() {
+ FeatureFlagUtils
+ .setEnabled(mContext, FeatureFlagUtils.SETTINGS_APP_LANGUAGE_SELECTION, false);
+
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_featureFlagOn_shouldReturnAvailable() {
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(BasePreferenceController.AVAILABLE);
+ }
+}
diff --git a/tests/unit/src/com/android/settings/applications/appinfo/ManageAppLocalePreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/appinfo/ManageAppLocalePreferenceControllerTest.java
new file mode 100644
index 0000000..648c757
--- /dev/null
+++ b/tests/unit/src/com/android/settings/applications/appinfo/ManageAppLocalePreferenceControllerTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2021 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.Mockito.spy;
+
+import android.content.Context;
+import android.util.FeatureFlagUtils;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+
+@RunWith(AndroidJUnit4.class)
+public class ManageAppLocalePreferenceControllerTest {
+ private Context mContext;
+ private ManageAppLocalePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(ApplicationProvider.getApplicationContext());
+ mController = spy(new ManageAppLocalePreferenceController(mContext, "a key"));
+
+ FeatureFlagUtils
+ .setEnabled(mContext, FeatureFlagUtils.SETTINGS_APP_LANGUAGE_SELECTION, true);
+ }
+
+ @Test
+ public void getAvailabilityStatus_featureFlagOff_shouldReturnUnavailable() {
+ FeatureFlagUtils
+ .setEnabled(mContext, FeatureFlagUtils.SETTINGS_APP_LANGUAGE_SELECTION, false);
+
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_featureFlagOn_shouldReturnAvailable() {
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(BasePreferenceController.AVAILABLE);
+ }
+}
diff --git a/tests/unit/src/com/android/settings/network/EnabledNetworkModePreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/EnabledNetworkModePreferenceControllerTest.java
index 81841b7..20f8a55 100644
--- a/tests/unit/src/com/android/settings/network/EnabledNetworkModePreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/EnabledNetworkModePreferenceControllerTest.java
@@ -19,6 +19,7 @@
import static androidx.lifecycle.Lifecycle.Event.ON_START;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
import static com.android.settings.network.telephony.MobileNetworkUtils.getRafFromNetworkType;
import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.CDMA;
@@ -32,6 +33,8 @@
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -154,6 +157,30 @@
@UiThreadTest
@Test
+ public void getAvailabilityStatus_callStateIsIdle_returnAvailable() {
+ mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_NR_LTE_GSM_WCDMA);
+ mController.getTelephonyCallback().onCallStateChanged(TelephonyManager.CALL_STATE_IDLE);
+
+ mController.updateState(mPreference);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ assertTrue(mPreference.isEnabled());
+ }
+
+ @UiThreadTest
+ @Test
+ public void getAvailabilityStatus_duringCalling_returnAvailable() {
+ mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_NR_LTE_GSM_WCDMA);
+ mController.getTelephonyCallback().onCallStateChanged(TelephonyManager.CALL_STATE_OFFHOOK);
+
+ mController.updateState(mPreference);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ assertFalse(mPreference.isEnabled());
+ }
+
+ @UiThreadTest
+ @Test
public void updateState_LteWorldPhone_GlobalHasLte() {
mPersistableBundle.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
diff --git a/tests/unit/src/com/android/settings/network/telephony/NetworkProviderBackupCallingGroupTest.java b/tests/unit/src/com/android/settings/network/telephony/NetworkProviderBackupCallingGroupTest.java
index e7a6af3..8396f1b 100644
--- a/tests/unit/src/com/android/settings/network/telephony/NetworkProviderBackupCallingGroupTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/NetworkProviderBackupCallingGroupTest.java
@@ -153,7 +153,6 @@
@Test
public void
shouldShowBackupCallingForSub_crossSimDisabled_returnFalse() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
doReturn(false).when(mNetworkProviderBackupCallingGroup).isCrossSimEnabledByPlatform(
mContext, SUB_ID_1);
@@ -163,7 +162,6 @@
@Test
public void shouldBackupCallingForSub_crossSimEnabled_returnTrue() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
doReturn(true).when(mNetworkProviderBackupCallingGroup).isCrossSimEnabledByPlatform(
mContext, SUB_ID_1);
diff --git a/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroupTest.java b/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroupTest.java
index 660772e..9cd12fe 100644
--- a/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroupTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroupTest.java
@@ -147,7 +147,6 @@
@Test
public void
shouldShowWifiCallingForSub_wifiCallingDisabledWithWifiCallingNotReady_returnFalse() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
setWifiCallingEnabled(false);
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
@@ -157,7 +156,6 @@
@Test
public void shouldShowWifiCallingForSub_wifiCallingEnabledWithWifiCallingIsReady_returnTrue() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
setWifiCallingEnabled(true);
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
@@ -168,7 +166,6 @@
@Test
public void
shouldShowWifiCallingForSub_wifiCallingDisabledWithNoActivityHandleIntent_returnFalse() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
buildPhoneAccountConfigureIntent(false);
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
doReturn(mPhoneAccountHandle).when(mNetworkProviderWifiCallingGroup)
@@ -181,7 +178,6 @@
@Test
public void
shouldShowWifiCallingForSub_wifiCallingEnabledWithActivityHandleIntent_returnTrue() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
buildPhoneAccountConfigureIntent(true);
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
doReturn(mPhoneAccountHandle).when(mNetworkProviderWifiCallingGroup)