Merge "Import translations. DO NOT MERGE ANYWHERE" into main
diff --git a/res/values-ca/arrays.xml b/res/values-ca/arrays.xml
index 612822a..aa67dfe 100644
--- a/res/values-ca/arrays.xml
+++ b/res/values-ca/arrays.xml
@@ -375,7 +375,7 @@
<item msgid="2262719249581510939">"Desconnectada"</item>
<item msgid="9141074028293812365">"S\'està inicialitzant..."</item>
<item msgid="2234425878608626285">"S\'està connectant..."</item>
- <item msgid="27547778933579155">"Connectat"</item>
+ <item msgid="27547778933579155">"Connectada"</item>
<item msgid="893506841727300393">"Temps d\'espera esgotat"</item>
<item msgid="2974952010554140659">"Incorrecte"</item>
</string-array>
diff --git a/res/values-ne/arrays.xml b/res/values-ne/arrays.xml
index d81d683..2cd1c5c 100644
--- a/res/values-ne/arrays.xml
+++ b/res/values-ne/arrays.xml
@@ -411,7 +411,7 @@
<item msgid="9080166583718385565">"0"</item>
</string-array>
<string-array name="wifi_metered_entries">
- <item msgid="3237321077949659241">"स्वतः पत्ता लगाइयोस्"</item>
+ <item msgid="3237321077949659241">"स्वतः पत्ता लगाउनुहोस्"</item>
<item msgid="3779092145391320375">"सशुल्क Wi-Fi का रूपमा लिइयोस्"</item>
<item msgid="2047166446768045816">"नि:शुल्क Wi-Fi का रूपमा लिइयोस्"</item>
</string-array>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5d4cb63..3e500b9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -8794,13 +8794,13 @@
<!-- [CHAR LIMIT=NONE] App notification settings: link to app notification settings-->
<string name="app_settings_link">Additional settings in the app</string>
- <!-- [CHAR LIMIT=20] 3-dot menu option, reloads the screen to show channels that have not
+ <!-- [CHAR LIMIT=35] 3-dot menu option, reloads the screen to show channels that have not
received notifications in the last two week -->
- <string name="show_unused_channels">Show unused channels</string>
+ <string name="show_unused_channels">Show unused categories</string>
- <!-- [CHAR LIMIT=20] 3-dot menu option, reloads the screen to hide channels that have not
+ <!-- [CHAR LIMIT=35] 3-dot menu option, reloads the screen to hide channels that have not
received notifications in the last two week -->
- <string name="hide_unused_channels">Hide unused channels</string>
+ <string name="hide_unused_channels">Hide unused categories</string>
<!-- [CHAR LIMIT=NONE] Footer listing a count of deleted channels. -->
<string name="deleted_channels">{count, plural,
diff --git a/res/xml/system_dashboard_fragment.xml b/res/xml/system_dashboard_fragment.xml
index a2cb8fa..628eab9 100644
--- a/res/xml/system_dashboard_fragment.xml
+++ b/res/xml/system_dashboard_fragment.xml
@@ -21,14 +21,6 @@
android:title="@string/header_category_system">
<Preference
- android:key="language_input_settings"
- android:title="@string/language_settings"
- android:icon="@drawable/ic_settings_language"
- android:order="-260"
- android:fragment="com.android.settings.language.LanguageAndInputSettings"
- settings:controller="com.android.settings.language.LanguageAndInputPreferenceController"/>
-
- <Preference
android:key="language_settings"
android:title="@string/languages_settings"
android:summary="@string/languages_setting_summary"
diff --git a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
index a068a08..f4c928c 100644
--- a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
+++ b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
@@ -50,6 +50,7 @@
import com.android.settings.homepage.SettingsHomepageActivity;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockPattern;
+import com.android.settings.privatespace.PrivateSpaceSetupActivity;
import com.android.settings.remoteauth.RemoteAuthActivity;
import com.android.settings.remoteauth.RemoteAuthActivityInternal;
@@ -264,6 +265,7 @@
addActivityFilter(activityFilters, RemoteAuthActivity.class);
addActivityFilter(activityFilters, RemoteAuthActivityInternal.class);
addActivityFilter(activityFilters, ChooseLockPattern.class);
+ addActivityFilter(activityFilters, PrivateSpaceSetupActivity.class);
String action = mContext.getString(R.string.config_avatar_picker_action);
addActivityFilter(activityFilters, new Intent(action));
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 57ddca2..bee1da7 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -135,7 +135,6 @@
import com.android.settings.inputmethod.TrackpadSettings;
import com.android.settings.inputmethod.UserDictionaryList;
import com.android.settings.inputmethod.UserDictionarySettings;
-import com.android.settings.language.LanguageAndInputSettings;
import com.android.settings.language.LanguageSettings;
import com.android.settings.localepicker.LocaleListEditor;
import com.android.settings.location.LocationServices;
@@ -226,7 +225,6 @@
DateTimeSettings.class.getName(),
LocaleListEditor.class.getName(),
AvailableVirtualKeyboardFragment.class.getName(),
- LanguageAndInputSettings.class.getName(),
LanguageSettings.class.getName(),
KeyboardSettings.class.getName(),
ModifierKeysSettings.class.getName(),
diff --git a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
index ffe81f1..849a80b 100644
--- a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
+++ b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
@@ -38,7 +38,6 @@
import com.android.settings.fuelgauge.batteryusage.PowerUsageSummary;
import com.android.settings.gestures.GestureSettings;
import com.android.settings.homepage.TopLevelSettings;
-import com.android.settings.language.LanguageAndInputSettings;
import com.android.settings.network.NetworkDashboardFragment;
import com.android.settings.notification.ConfigureNotificationSettings;
import com.android.settings.notification.SoundSettings;
@@ -102,8 +101,6 @@
CategoryKey.CATEGORY_ACCOUNT);
PARENT_TO_CATEGORY_KEY_MAP.put(
SystemDashboardFragment.class.getName(), CategoryKey.CATEGORY_SYSTEM);
- PARENT_TO_CATEGORY_KEY_MAP.put(LanguageAndInputSettings.class.getName(),
- CategoryKey.CATEGORY_SYSTEM_LANGUAGE);
// TODO(b/242680328) Tie new category key to LanguageSettings and KeyboardSettings page
PARENT_TO_CATEGORY_KEY_MAP.put(DevelopmentSettingsDashboardFragment.class.getName(),
CategoryKey.CATEGORY_SYSTEM_DEVELOPMENT);
diff --git a/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceController.java b/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceController.java
index 79b629e..863cd27 100644
--- a/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceController.java
+++ b/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceController.java
@@ -78,6 +78,10 @@
@Override
public boolean onPreferenceChange(@Nullable Preference preference, @NonNull Object newValue) {
+ if (!Flags.a2dpOffloadCodecExtensibilitySettings()) {
+ return false;
+ }
+
if (DEBUG) {
Log.d(TAG, "onPreferenceChange: newValue=" + (String) newValue);
}
@@ -120,6 +124,10 @@
@Override
public void updateState(@Nullable Preference preference) {
super.updateState(preference);
+ if (!Flags.a2dpOffloadCodecExtensibilitySettings()) {
+ return;
+ }
+
final List<String> codecIds = new ArrayList<>();
final List<String> labels = new ArrayList<>();
String selectedCodecId = mDefaultValue;
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java
index fa71c34..4c02feb 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java
@@ -80,7 +80,6 @@
try {
mModuleVersion =
mPackageManager.getPackageInfo(moduleProvider, 0 /* flags */).versionName;
- return;
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Failed to get mainline version.", e);
mModuleVersion = null;
@@ -124,7 +123,8 @@
return mModuleVersion;
}
- return DateFormat.getLongDateFormat(mContext).format(parsedDate.get());
+ String format = DateFormat.getBestDateTimePattern(Locale.getDefault(), "dMMMMyyyy");
+ return DateFormat.format(format, parsedDate.get());
}
private Optional<Date> parseDateFromVersionName(String text) {
diff --git a/src/com/android/settings/inputmethod/KeyboardPreferenceController.java b/src/com/android/settings/inputmethod/KeyboardPreferenceController.java
index 26b07d8..37207b8 100644
--- a/src/com/android/settings/inputmethod/KeyboardPreferenceController.java
+++ b/src/com/android/settings/inputmethod/KeyboardPreferenceController.java
@@ -18,7 +18,6 @@
import android.content.Context;
import android.hardware.input.InputManager;
-import android.util.FeatureFlagUtils;
import androidx.preference.Preference;
@@ -78,9 +77,7 @@
@Override
public int getAvailabilityStatus() {
- return FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI)
- ? AVAILABLE
- : CONDITIONALLY_UNAVAILABLE;
+ return AVAILABLE;
}
private void updateSummary() {
diff --git a/src/com/android/settings/inputmethod/KeyboardSettings.java b/src/com/android/settings/inputmethod/KeyboardSettings.java
index 9fddb93..38f7343 100644
--- a/src/com/android/settings/inputmethod/KeyboardSettings.java
+++ b/src/com/android/settings/inputmethod/KeyboardSettings.java
@@ -23,7 +23,6 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
-import android.util.FeatureFlagUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -111,11 +110,5 @@
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.keyboard_settings) {
- @Override
- protected boolean isPageSearchEnabled(Context context) {
- return FeatureFlagUtils
- .isEnabled(context, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI);
- }
- };
+ new BaseSearchIndexProvider(R.xml.keyboard_settings);
}
\ No newline at end of file
diff --git a/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java b/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java
index 06a132d..ccaf037 100644
--- a/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java
+++ b/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java
@@ -20,7 +20,6 @@
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
-import android.util.FeatureFlagUtils;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
@@ -69,8 +68,7 @@
@Override
public int getAvailabilityStatus() {
List<HardKeyboardDeviceInfo> newHardKeyboards = getHardKeyboardList();
- if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI)
- && !newHardKeyboards.isEmpty()) {
+ if (!newHardKeyboards.isEmpty()) {
for (HardKeyboardDeviceInfo hardKeyboardDeviceInfo : newHardKeyboards) {
if (mCachedDevice.getAddress() != null
&& hardKeyboardDeviceInfo.mBluetoothAddress != null
diff --git a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
index e102241..5ba1c84 100644
--- a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
@@ -110,7 +110,6 @@
private Intent mIntentWaitingForResult;
- private boolean mIsNewKeyboardSettings;
private boolean mSupportsFirmwareUpdate;
static final String EXTRA_BT_ADDRESS = "extra_bt_address";
@@ -152,8 +151,6 @@
if (mSupportsFirmwareUpdate) {
mFeatureProvider.addFirmwareUpdateCategory(getContext(), getPreferenceScreen());
}
- mIsNewKeyboardSettings = FeatureFlagUtils.isEnabled(
- getContext(), FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI);
boolean isModifierKeySettingsEnabled = FeatureFlagUtils
.isEnabled(getContext(), FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_MODIFIER_KEY);
if (!isModifierKeySettingsEnabled) {
@@ -287,27 +284,19 @@
// TODO(yukawa): Consider using com.android.settings.widget.GearPreference
final Preference pref = new Preference(getPrefContext());
pref.setTitle(hardKeyboardDeviceInfo.mDeviceName);
- if (mIsNewKeyboardSettings) {
- String currentLayout =
- NewKeyboardSettingsUtils.getSelectedKeyboardLayoutLabelForUser(getContext(),
- UserHandle.myUserId(), hardKeyboardDeviceInfo.mDeviceIdentifier);
- if (currentLayout != null) {
- pref.setSummary(currentLayout);
- }
- pref.setOnPreferenceClickListener(
- preference -> {
- showEnabledLocalesKeyboardLayoutList(
- hardKeyboardDeviceInfo.mDeviceIdentifier);
- return true;
- });
- } else {
- pref.setSummary(hardKeyboardDeviceInfo.mLayoutLabel);
- pref.setOnPreferenceClickListener(
- preference -> {
- showKeyboardLayoutDialog(hardKeyboardDeviceInfo.mDeviceIdentifier);
- return true;
- });
+ String currentLayout =
+ NewKeyboardSettingsUtils.getSelectedKeyboardLayoutLabelForUser(getContext(),
+ UserHandle.myUserId(), hardKeyboardDeviceInfo.mDeviceIdentifier);
+ if (currentLayout != null) {
+ pref.setSummary(currentLayout);
}
+ pref.setOnPreferenceClickListener(
+ preference -> {
+ showEnabledLocalesKeyboardLayoutList(
+ hardKeyboardDeviceInfo.mDeviceIdentifier);
+ return true;
+ });
+
category.addPreference(pref);
StringBuilder vendorAndProductId = new StringBuilder();
String vendorId = String.valueOf(hardKeyboardDeviceInfo.mVendorId);
diff --git a/src/com/android/settings/language/LanguageAndInputPreferenceController.java b/src/com/android/settings/language/LanguageAndInputPreferenceController.java
deleted file mode 100644
index 691d907..0000000
--- a/src/com/android/settings/language/LanguageAndInputPreferenceController.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2019 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.language;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.provider.Settings;
-import android.text.TextUtils;
-import android.util.FeatureFlagUtils;
-import android.view.inputmethod.InputMethodInfo;
-import android.view.inputmethod.InputMethodManager;
-
-import com.android.settings.core.BasePreferenceController;
-
-import java.util.List;
-
-public class LanguageAndInputPreferenceController extends BasePreferenceController {
-
- private PackageManager mPackageManager;
- private InputMethodManager mInputMethodManager;
-
- public LanguageAndInputPreferenceController(Context context, String key) {
- super(context, key);
- mPackageManager = mContext.getPackageManager();
- mInputMethodManager = mContext.getSystemService(InputMethodManager.class);
- }
-
- @Override
- public int getAvailabilityStatus() {
- boolean isFeatureOn = FeatureFlagUtils
- .isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI);
- return isFeatureOn ? CONDITIONALLY_UNAVAILABLE : AVAILABLE;
- }
-
- @Override
- public CharSequence getSummary() {
- final String flattenComponent = Settings.Secure.getString(
- mContext.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
- if (!TextUtils.isEmpty(flattenComponent)) {
- final String pkg = ComponentName.unflattenFromString(flattenComponent)
- .getPackageName();
- final List<InputMethodInfo> imis = mInputMethodManager.getInputMethodList();
- for (InputMethodInfo imi : imis) {
- if (TextUtils.equals(imi.getPackageName(), pkg)) {
- return imi.loadLabel(mPackageManager);
- }
- }
- }
- return "";
- }
-}
diff --git a/src/com/android/settings/language/LanguageAndInputSettings.java b/src/com/android/settings/language/LanguageAndInputSettings.java
deleted file mode 100644
index f40473c..0000000
--- a/src/com/android/settings/language/LanguageAndInputSettings.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2016 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.language;
-
-import static android.app.admin.DevicePolicyResources.Strings.Settings.PERSONAL_DICTIONARY_FOR_WORK;
-import static android.app.admin.DevicePolicyResources.Strings.Settings.SPELL_CHECKER_FOR_WORK;
-import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_KEYBOARDS_AND_TOOLS;
-
-import android.app.Activity;
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.os.Bundle;
-import android.util.FeatureFlagUtils;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.android.settings.R;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.inputmethod.PhysicalKeyboardPreferenceController;
-import com.android.settings.inputmethod.SpellCheckerPreferenceController;
-import com.android.settings.inputmethod.VirtualKeyboardPreferenceController;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.widget.PreferenceCategoryController;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.search.SearchIndexable;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-@SearchIndexable
-public class LanguageAndInputSettings extends DashboardFragment {
-
- private static final String TAG = "LangAndInputSettings";
-
- private static final String KEY_KEYBOARDS_CATEGORY = "keyboards_category";
- private static final String KEY_SPEECH_CATEGORY = "speech_category";
- private static final String KEY_ON_DEVICE_RECOGNITION = "odsr_settings";
- private static final String KEY_TEXT_TO_SPEECH = "tts_settings_summary";
- private static final String KEY_POINTER_CATEGORY = "pointer_category";
-
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.SETTINGS_LANGUAGE_CATEGORY;
- }
-
- @Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
- public void onResume() {
- super.onResume();
- // Hack to update action bar title. It's necessary to refresh title because this page user
- // can change locale from here and fragment won't relaunch. Once language changes, title
- // must display in the new language.
- final Activity activity = getActivity();
- if (activity == null) {
- return;
- }
- activity.setTitle(R.string.language_settings);
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- replaceEnterpriseStringTitle("language_and_input_for_work_category",
- WORK_PROFILE_KEYBOARDS_AND_TOOLS,
- R.string.language_and_input_for_work_category_title);
- replaceEnterpriseStringTitle("spellcheckers_settings_for_work_pref",
- SPELL_CHECKER_FOR_WORK,
- R.string.spellcheckers_settings_for_work_title);
- replaceEnterpriseStringTitle("user_dictionary_settings_for_work_pref",
- PERSONAL_DICTIONARY_FOR_WORK,
- R.string.user_dict_settings_for_work_title);
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.language_and_input;
- }
-
- @Override
- protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- return buildPreferenceControllers(context, getSettingsLifecycle());
- }
-
- private static List<AbstractPreferenceController> buildPreferenceControllers(
- @NonNull Context context, @Nullable Lifecycle lifecycle) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
-
- // Input
- final VirtualKeyboardPreferenceController virtualKeyboardPreferenceController =
- new VirtualKeyboardPreferenceController(context);
- final PhysicalKeyboardPreferenceController physicalKeyboardPreferenceController =
- new PhysicalKeyboardPreferenceController(context, lifecycle);
- controllers.add(virtualKeyboardPreferenceController);
- controllers.add(physicalKeyboardPreferenceController);
- controllers.add(new PreferenceCategoryController(context,
- KEY_KEYBOARDS_CATEGORY).setChildren(
- Arrays.asList(virtualKeyboardPreferenceController,
- physicalKeyboardPreferenceController)));
-
- // Speech
- final DefaultVoiceInputPreferenceController defaultVoiceInputPreferenceController =
- new DefaultVoiceInputPreferenceController(context, lifecycle);
- final TtsPreferenceController ttsPreferenceController =
- new TtsPreferenceController(context, KEY_TEXT_TO_SPEECH);
- final OnDeviceRecognitionPreferenceController onDeviceRecognitionPreferenceController =
- new OnDeviceRecognitionPreferenceController(context, KEY_ON_DEVICE_RECOGNITION);
-
- controllers.add(defaultVoiceInputPreferenceController);
- controllers.add(ttsPreferenceController);
- List<AbstractPreferenceController> speechCategoryChildren = new ArrayList<>(
- List.of(defaultVoiceInputPreferenceController, ttsPreferenceController));
-
- if (onDeviceRecognitionPreferenceController.isAvailable()) {
- controllers.add(onDeviceRecognitionPreferenceController);
- speechCategoryChildren.add(onDeviceRecognitionPreferenceController);
- }
-
- controllers.add(new PreferenceCategoryController(context, KEY_SPEECH_CATEGORY)
- .setChildren(speechCategoryChildren));
-
- // Pointer
- final PointerSpeedController pointerController = new PointerSpeedController(context);
- controllers.add(pointerController);
- controllers.add(new PreferenceCategoryController(context,
- KEY_POINTER_CATEGORY).setChildren(Arrays.asList(pointerController)));
-
- // Input Assistance
- controllers.add(new SpellCheckerPreferenceController(context));
-
- return controllers;
- }
-
- public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.language_and_input) {
- @Override
- public List<AbstractPreferenceController> createPreferenceControllers(
- Context context) {
- return buildPreferenceControllers(context, null);
- }
-
- @Override
- protected boolean isPageSearchEnabled(Context context) {
- return !FeatureFlagUtils
- .isEnabled(context, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI);
- }
- };
-}
diff --git a/src/com/android/settings/language/LanguagePreferenceController.java b/src/com/android/settings/language/LanguagePreferenceController.java
index cbccb00..84624a2 100644
--- a/src/com/android/settings/language/LanguagePreferenceController.java
+++ b/src/com/android/settings/language/LanguagePreferenceController.java
@@ -19,7 +19,6 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
-import android.util.FeatureFlagUtils;
import com.android.settings.Settings;
import com.android.settings.core.BasePreferenceController;
@@ -29,28 +28,14 @@
* TODO(b/273642892): When new layout is on board, this class shall be removed.
*/
public class LanguagePreferenceController extends BasePreferenceController {
- private static final String TAG = LanguagePreferenceController.class.getSimpleName();
-
- private boolean mCacheIsFeatureOn = false;
-
public LanguagePreferenceController(Context context, String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
- boolean isFeatureOn = FeatureFlagUtils
- .isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI);
-
- // LanguageSettingsActivity is a new entry page for new language layout.
- // LanguageAndInputSettingsActivity is existed entry page for current language layout.
- if (mCacheIsFeatureOn != isFeatureOn) {
- setActivityEnabled(
- mContext, Settings.LanguageAndInputSettingsActivity.class, !isFeatureOn);
- setActivityEnabled(mContext, Settings.LanguageSettingsActivity.class, isFeatureOn);
- mCacheIsFeatureOn = isFeatureOn;
- }
- return isFeatureOn ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ setActivityEnabled(mContext, Settings.LanguageSettingsActivity.class, true);
+ return AVAILABLE;
}
private static void setActivityEnabled(Context context, Class klass, final boolean isEnabled) {
diff --git a/src/com/android/settings/language/LanguageSettings.java b/src/com/android/settings/language/LanguageSettings.java
index 8253311..a5adb02 100644
--- a/src/com/android/settings/language/LanguageSettings.java
+++ b/src/com/android/settings/language/LanguageSettings.java
@@ -19,7 +19,6 @@
import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.util.FeatureFlagUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -112,8 +111,7 @@
}
@Override
protected boolean isPageSearchEnabled(Context context) {
- return FeatureFlagUtils
- .isEnabled(context, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI);
+ return true;
}
};
}
\ No newline at end of file
diff --git a/src/com/android/settings/media/MediaDeviceUpdateWorker.java b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
index d4aef47..c87f1e8 100644
--- a/src/com/android/settings/media/MediaDeviceUpdateWorker.java
+++ b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
@@ -81,7 +81,7 @@
mIsTouched = false;
if (mLocalMediaManager == null || !TextUtils.equals(mPackageName,
mLocalMediaManager.getPackageName())) {
- mLocalMediaManager = new LocalMediaManager(mContext, mPackageName, null);
+ mLocalMediaManager = new LocalMediaManager(mContext, mPackageName);
}
// Delaying initialization to allow mocking in Roboelectric tests.
diff --git a/src/com/android/settings/media/MediaOutputIndicatorWorker.java b/src/com/android/settings/media/MediaOutputIndicatorWorker.java
index 6e56153..0ebb373 100644
--- a/src/com/android/settings/media/MediaOutputIndicatorWorker.java
+++ b/src/com/android/settings/media/MediaOutputIndicatorWorker.java
@@ -92,8 +92,7 @@
}
if (mLocalMediaManager == null || !TextUtils.equals(mPackageName,
mLocalMediaManager.getPackageName())) {
- mLocalMediaManager = new LocalMediaManager(mContext, mPackageName,
- null /* notification */);
+ mLocalMediaManager = new LocalMediaManager(mContext, mPackageName);
}
mLocalMediaManager.registerCallback(this);
mLocalMediaManager.startScan();
diff --git a/src/com/android/settings/network/SatelliteManagerUtil.kt b/src/com/android/settings/network/SatelliteManagerUtil.kt
deleted file mode 100644
index 5dc1a84..0000000
--- a/src/com/android/settings/network/SatelliteManagerUtil.kt
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.network
-
-import android.content.Context
-import android.os.OutcomeReceiver
-import android.telephony.satellite.SatelliteManager
-import android.util.Log
-import androidx.concurrent.futures.CallbackToFutureAdapter
-import com.google.common.util.concurrent.Futures.immediateFuture
-import com.google.common.util.concurrent.ListenableFuture
-import java.util.concurrent.Executor
-
-/**
- * Utility class for interacting with the SatelliteManager API.
- */
-object SatelliteManagerUtil {
-
- private const val TAG: String = "SatelliteManagerUtil"
-
- /**
- * Checks if the satellite modem is enabled.
- *
- * @param context The application context
- * @param executor The executor to run the asynchronous operation on
- * @return A ListenableFuture that will resolve to `true` if the satellite modem enabled,
- * `false` otherwise.
- */
- @JvmStatic
- fun requestIsEnabled(context: Context, executor: Executor): ListenableFuture<Boolean> {
- val satelliteManager: SatelliteManager? =
- context.getSystemService(SatelliteManager::class.java)
- if (satelliteManager == null) {
- Log.w(TAG, "SatelliteManager is null")
- return immediateFuture(false)
- }
-
- return CallbackToFutureAdapter.getFuture { completer ->
- satelliteManager.requestIsEnabled(executor,
- object : OutcomeReceiver<Boolean, SatelliteManager.SatelliteException> {
- override fun onResult(result: Boolean) {
- Log.i(TAG, "Satellite modem enabled status: $result")
- completer.set(result)
- }
-
- override fun onError(error: SatelliteManager.SatelliteException) {
- super.onError(error)
- Log.w(TAG, "Can't get satellite modem enabled status", error)
- completer.set(false)
- }
- })
- "requestIsEnabled"
- }
- }
-}
diff --git a/src/com/android/settings/network/SatelliteRepository.kt b/src/com/android/settings/network/SatelliteRepository.kt
new file mode 100644
index 0000000..3dab7e6
--- /dev/null
+++ b/src/com/android/settings/network/SatelliteRepository.kt
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.network
+
+import android.content.Context
+import android.os.OutcomeReceiver
+import android.telephony.satellite.SatelliteManager
+import android.telephony.satellite.SatelliteModemStateCallback
+import android.util.Log
+import androidx.annotation.VisibleForTesting
+import androidx.concurrent.futures.CallbackToFutureAdapter
+import com.google.common.util.concurrent.Futures.immediateFuture
+import com.google.common.util.concurrent.ListenableFuture
+import java.util.concurrent.Executor
+import kotlinx.coroutines.CoroutineDispatcher
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.asExecutor
+import kotlinx.coroutines.channels.awaitClose
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.callbackFlow
+import kotlinx.coroutines.flow.flowOf
+
+/**
+ * A repository class for interacting with the SatelliteManager API.
+ */
+class SatelliteRepository(
+ private val context: Context,
+) {
+
+ /**
+ * Checks if the satellite modem is enabled.
+ *
+ * @param executor The executor to run the asynchronous operation on
+ * @return A ListenableFuture that will resolve to `true` if the satellite modem enabled,
+ * `false` otherwise.
+ */
+ fun requestIsEnabled(executor: Executor): ListenableFuture<Boolean> {
+ val satelliteManager: SatelliteManager? =
+ context.getSystemService(SatelliteManager::class.java)
+ if (satelliteManager == null) {
+ Log.w(TAG, "SatelliteManager is null")
+ return immediateFuture(false)
+ }
+
+ return CallbackToFutureAdapter.getFuture { completer ->
+ satelliteManager.requestIsEnabled(executor,
+ object : OutcomeReceiver<Boolean, SatelliteManager.SatelliteException> {
+ override fun onResult(result: Boolean) {
+ Log.i(TAG, "Satellite modem enabled status: $result")
+ completer.set(result)
+ }
+
+ override fun onError(error: SatelliteManager.SatelliteException) {
+ super.onError(error)
+ Log.w(TAG, "Can't get satellite modem enabled status", error)
+ completer.set(false)
+ }
+ })
+ "requestIsEnabled"
+ }
+ }
+
+ /**
+ * Provides a Flow that emits the enabled state of the satellite modem. Updates are triggered
+ * when the modem state changes.
+ *
+ * @param defaultDispatcher The CoroutineDispatcher to use (Defaults to `Dispatchers.Default`).
+ * @return A Flow emitting `true` when the modem is enabled and `false` otherwise.
+ */
+ fun getIsModemEnabledFlow(
+ defaultDispatcher: CoroutineDispatcher = Dispatchers.Default,
+ ): Flow<Boolean> {
+ val satelliteManager: SatelliteManager? =
+ context.getSystemService(SatelliteManager::class.java)
+ if (satelliteManager == null) {
+ Log.w(TAG, "SatelliteManager is null")
+ return flowOf(false)
+ }
+
+ return callbackFlow {
+ val callback = SatelliteModemStateCallback { state ->
+ val isEnabled = convertSatelliteModemStateToEnabledState(state)
+ Log.i(TAG, "Satellite modem state changed: state=$state, isEnabled=$isEnabled")
+ trySend(isEnabled)
+ }
+
+ val result = satelliteManager.registerForModemStateChanged(
+ defaultDispatcher.asExecutor(),
+ callback
+ )
+ Log.i(TAG, "Call registerForModemStateChanged: result=$result")
+
+ awaitClose { satelliteManager.unregisterForModemStateChanged(callback) }
+ }
+ }
+
+ /**
+ * Converts a [SatelliteManager.SatelliteModemState] to a boolean representing whether the modem
+ * is enabled.
+ *
+ * @param state The SatelliteModemState provided by the SatelliteManager.
+ * @return `true` if the modem is enabled, `false` otherwise.
+ */
+ @VisibleForTesting
+ fun convertSatelliteModemStateToEnabledState(
+ @SatelliteManager.SatelliteModemState state: Int,
+ ): Boolean {
+ // Mapping table based on logic from b/315928920#comment24
+ return when (state) {
+ SatelliteManager.SATELLITE_MODEM_STATE_IDLE,
+ SatelliteManager.SATELLITE_MODEM_STATE_LISTENING,
+ SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_TRANSFERRING,
+ SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_RETRYING,
+ SatelliteManager.SATELLITE_MODEM_STATE_NOT_CONNECTED,
+ SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED -> true
+ else -> false
+ }
+ }
+
+ companion object {
+ private const val TAG: String = "SatelliteRepository"
+ }
+}
diff --git a/src/com/android/settings/network/SimOnboardingActivity.kt b/src/com/android/settings/network/SimOnboardingActivity.kt
index 0160f2c..eea7286 100644
--- a/src/com/android/settings/network/SimOnboardingActivity.kt
+++ b/src/com/android/settings/network/SimOnboardingActivity.kt
@@ -46,15 +46,18 @@
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
+import androidx.lifecycle.LifecycleRegistry
import com.android.settings.R
import com.android.settings.SidecarFragment
import com.android.settings.network.telephony.SubscriptionActionDialogActivity
import com.android.settings.network.telephony.ToggleSubscriptionDialogActivity
import com.android.settings.spa.SpaActivity.Companion.startSpaActivity
import com.android.settings.spa.network.SimOnboardingPageProvider.getRoute
+import com.android.settings.wifi.WifiPickerTrackerHelper
import com.android.settingslib.spa.SpaBaseDialogActivity
import com.android.settingslib.spa.framework.theme.SettingsDimension
import com.android.settingslib.spa.framework.util.collectLatestWithLifecycle
@@ -74,6 +77,8 @@
class SimOnboardingActivity : SpaBaseDialogActivity() {
lateinit var scope: CoroutineScope
+ lateinit var wifiPickerTrackerHelper: WifiPickerTrackerHelper
+ lateinit var context: Context
lateinit var showStartingDialog: MutableState<Boolean>
lateinit var showError: MutableState<ErrorType>
lateinit var showProgressDialog: MutableState<Boolean>
@@ -86,6 +91,7 @@
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
+
if (!this.userManager.isAdminUser) {
Log.e(TAG, "It is not the admin user. Unable to toggle subscription.")
finish()
@@ -152,7 +158,10 @@
CallbackType.CALLBACK_SETUP_PRIMARY_SIM -> {
scope.launch {
- onboardingService.startSetupPrimarySim(this@SimOnboardingActivity)
+ onboardingService.startSetupPrimarySim(
+ this@SimOnboardingActivity,
+ wifiPickerTrackerHelper
+ )
}
}
@@ -184,6 +193,12 @@
showDsdsProgressDialog = rememberSaveable { mutableStateOf(false) }
showRestartDialog = rememberSaveable { mutableStateOf(false) }
scope = rememberCoroutineScope()
+ context = LocalContext.current
+ val lifecycleOwner = LocalLifecycleOwner.current
+ wifiPickerTrackerHelper = WifiPickerTrackerHelper(
+ LifecycleRegistry(lifecycleOwner), context,
+ null /* WifiPickerTrackerCallback */
+ )
registerSidecarReceiverFlow()
diff --git a/src/com/android/settings/network/SimOnboardingService.kt b/src/com/android/settings/network/SimOnboardingService.kt
index b99f18d..b7df754 100644
--- a/src/com/android/settings/network/SimOnboardingService.kt
+++ b/src/com/android/settings/network/SimOnboardingService.kt
@@ -30,6 +30,7 @@
import com.android.settings.spa.network.setDefaultData
import com.android.settings.spa.network.setDefaultSms
import com.android.settings.spa.network.setDefaultVoice
+import com.android.settings.wifi.WifiPickerTrackerHelper
import com.android.settingslib.utils.ThreadUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
@@ -336,14 +337,17 @@
}
}
- suspend fun startSetupPrimarySim(context: Context) {
+ suspend fun startSetupPrimarySim(
+ context: Context,
+ wifiPickerTrackerHelper: WifiPickerTrackerHelper
+ ) {
withContext(Dispatchers.Default) {
setDefaultVoice(subscriptionManager, targetPrimarySimCalls)
setDefaultSms(subscriptionManager, targetPrimarySimTexts)
setDefaultData(
context,
subscriptionManager,
- null,
+ wifiPickerTrackerHelper,
targetPrimarySimMobileData
)
TelephonyRepository(context).setAutomaticData(
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSwitchController.kt b/src/com/android/settings/network/telephony/MobileNetworkSwitchController.kt
index dcac74f..41cef50 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSwitchController.kt
+++ b/src/com/android/settings/network/telephony/MobileNetworkSwitchController.kt
@@ -26,16 +26,19 @@
import androidx.compose.ui.res.stringResource
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.settings.R
+import com.android.settings.network.SatelliteRepository
import com.android.settings.network.SubscriptionUtil
import com.android.settings.spa.preference.ComposePreferenceController
import com.android.settingslib.spa.widget.preference.MainSwitchPreference
import com.android.settingslib.spa.widget.preference.SwitchPreferenceModel
+import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.map
class MobileNetworkSwitchController @JvmOverloads constructor(
context: Context,
preferenceKey: String,
private val subscriptionRepository: SubscriptionRepository = SubscriptionRepository(context),
+ private val satelliteRepository: SatelliteRepository = SatelliteRepository(context)
) : ComposePreferenceController(context, preferenceKey) {
private var subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID
@@ -54,7 +57,12 @@
subscriptionRepository.isSubscriptionEnabledFlow(subId)
}.collectAsStateWithLifecycle(initialValue = null)
val changeable by remember {
- context.callStateFlow(subId).map { it == TelephonyManager.CALL_STATE_IDLE }
+ combine(
+ context.callStateFlow(subId).map { it == TelephonyManager.CALL_STATE_IDLE },
+ satelliteRepository.getIsModemEnabledFlow()
+ ) { isCallStateIdle, isSatelliteModemEnabled ->
+ isCallStateIdle && !isSatelliteModemEnabled
+ }
}.collectAsStateWithLifecycle(initialValue = true)
MainSwitchPreference(model = object : SwitchPreferenceModel {
override val title = stringResource(R.string.mobile_network_use_sim_on)
diff --git a/src/com/android/settings/network/telephony/TelephonyRepository.kt b/src/com/android/settings/network/telephony/TelephonyRepository.kt
index 18af621..cc9b53d 100644
--- a/src/com/android/settings/network/telephony/TelephonyRepository.kt
+++ b/src/com/android/settings/network/telephony/TelephonyRepository.kt
@@ -21,6 +21,8 @@
import android.telephony.TelephonyCallback
import android.telephony.TelephonyManager
import android.util.Log
+import com.android.settings.network.mobileDataEnabledFlow
+import com.android.settings.wifi.WifiPickerTrackerHelper
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.asExecutor
import kotlinx.coroutines.channels.ProducerScope
@@ -62,6 +64,42 @@
telephonyManager.setMobileDataPolicyEnabled(policy, enabled)
}
+ fun isDataEnabled(
+ subId: Int,
+ ): Flow<Boolean> {
+ if (!SubscriptionManager.isValidSubscriptionId(subId)) return flowOf(false)
+
+ Log.d(TAG, "register mobileDataEnabledFlow: [$subId]")
+ return context.mobileDataEnabledFlow(subId)
+ .map {
+ Log.d(TAG, "mobileDataEnabledFlow: receive mobile data [$subId] start")
+ val telephonyManager = context.telephonyManager(subId)
+ telephonyManager.isDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER)
+ .also { Log.d(TAG, "mobileDataEnabledFlow: [$subId] isDataEnabled(): $it") }
+ }
+ }
+
+ fun setMobileData(
+ subId: Int,
+ enabled: Boolean,
+ wifiPickerTrackerHelper: WifiPickerTrackerHelper? = null
+ ) {
+ if (!SubscriptionManager.isValidSubscriptionId(subId)) return
+
+ Log.d(TAG, "setMobileData: $enabled")
+ MobileNetworkUtils.setMobileDataEnabled(
+ context,
+ subId,
+ enabled /* enabled */,
+ true /* disableOtherSubscriptions */
+ )
+
+ if (wifiPickerTrackerHelper != null
+ && !wifiPickerTrackerHelper.isCarrierNetworkProvisionEnabled(subId)
+ ) {
+ wifiPickerTrackerHelper.setCarrierNetworkEnabled(enabled)
+ }
+ }
private companion object {
private const val TAG = "TelephonyRepository"
}
diff --git a/src/com/android/settings/notification/RemoteVolumeGroupController.java b/src/com/android/settings/notification/RemoteVolumeGroupController.java
index 919b6d0..bea2ff3 100644
--- a/src/com/android/settings/notification/RemoteVolumeGroupController.java
+++ b/src/com/android/settings/notification/RemoteVolumeGroupController.java
@@ -68,7 +68,7 @@
public RemoteVolumeGroupController(Context context, String preferenceKey) {
super(context, preferenceKey);
if (mLocalMediaManager == null) {
- mLocalMediaManager = new LocalMediaManager(mContext, null, null);
+ mLocalMediaManager = new LocalMediaManager(mContext, /* packageName= */ null);
mLocalMediaManager.registerCallback(this);
mLocalMediaManager.startScan();
}
diff --git a/src/com/android/settings/privatespace/PrivateSpaceMaintainer.java b/src/com/android/settings/privatespace/PrivateSpaceMaintainer.java
index 6d07305..3a08410 100644
--- a/src/com/android/settings/privatespace/PrivateSpaceMaintainer.java
+++ b/src/com/android/settings/privatespace/PrivateSpaceMaintainer.java
@@ -20,6 +20,7 @@
import static android.provider.Settings.Secure.HIDE_PRIVATESPACE_ENTRY_POINT;
import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK;
import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK_AFTER_DEVICE_RESTART;
+import static android.provider.Settings.Secure.SKIP_FIRST_USE_HINTS;
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
import android.app.ActivityManager;
@@ -122,6 +123,7 @@
Log.i(TAG, "Private space created with id: " + mUserHandle.getIdentifier());
resetPrivateSpaceSettings();
setUserSetupComplete();
+ setSkipFirstUseHints();
}
return true;
}
@@ -350,6 +352,17 @@
1, mUserHandle.getIdentifier());
}
+ /**
+ * Sets the SKIP_FIRST_USE_HINTS for private profile so that the first launch of an app in
+ * private space will not display introductory hints.
+ */
+ @GuardedBy("this")
+ private void setSkipFirstUseHints() {
+ Log.d(TAG, "setting SKIP_FIRST_USE_HINTS = 1 for private profile");
+ Settings.Secure.putIntForUser(mContext.getContentResolver(), SKIP_FIRST_USE_HINTS,
+ 1, mUserHandle.getIdentifier());
+ }
+
private boolean isPrivateSpaceAutoLockSupported() {
return android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.supportAutolockForPrivateSpace()
diff --git a/src/com/android/settings/privatespace/SetupPreFinishDelayFragment.java b/src/com/android/settings/privatespace/SetupPreFinishDelayFragment.java
index aee8512..9d04e79 100644
--- a/src/com/android/settings/privatespace/SetupPreFinishDelayFragment.java
+++ b/src/com/android/settings/privatespace/SetupPreFinishDelayFragment.java
@@ -124,6 +124,12 @@
}
@Override
+ public void onDestroy() {
+ sHandler.removeCallbacks(mRunnable);
+ super.onDestroy();
+ }
+
+ @Override
public int getMetricsCategory() {
return SettingsEnums.PRIVATE_SPACE_SETUP_PRE_FINISH;
}
diff --git a/src/com/android/settings/sim/receivers/SimSlotChangeReceiver.java b/src/com/android/settings/sim/receivers/SimSlotChangeReceiver.java
index 9bba217..4920bb8 100644
--- a/src/com/android/settings/sim/receivers/SimSlotChangeReceiver.java
+++ b/src/com/android/settings/sim/receivers/SimSlotChangeReceiver.java
@@ -29,7 +29,7 @@
import androidx.annotation.Nullable;
import com.android.settings.R;
-import com.android.settings.network.SatelliteManagerUtil;
+import com.android.settings.network.SatelliteRepository;
import com.google.common.util.concurrent.ListenableFuture;
@@ -58,8 +58,8 @@
if (shouldHandleSlotChange(context)) {
Log.d(TAG, "Checking satellite enabled status");
Executor executor = Executors.newSingleThreadExecutor();
- ListenableFuture<Boolean> satelliteEnabledFuture = SatelliteManagerUtil
- .requestIsEnabled(context, executor);
+ ListenableFuture<Boolean> satelliteEnabledFuture = new SatelliteRepository(context)
+ .requestIsEnabled(executor);
satelliteEnabledFuture.addListener(() -> {
boolean isSatelliteEnabled = false;
try {
diff --git a/src/com/android/settings/spa/app/appinfo/AppArchiveButton.kt b/src/com/android/settings/spa/app/appinfo/AppArchiveButton.kt
index 38a8499..292c8b8 100644
--- a/src/com/android/settings/spa/app/appinfo/AppArchiveButton.kt
+++ b/src/com/android/settings/spa/app/appinfo/AppArchiveButton.kt
@@ -21,6 +21,7 @@
import android.content.IntentFilter
import android.content.pm.ApplicationInfo
import android.content.pm.PackageInstaller
+import android.content.pm.PackageManager
import android.os.UserHandle
import android.util.Log
import android.widget.Toast
@@ -87,11 +88,15 @@
}
private fun ApplicationInfo.isActionButtonEnabled(): Boolean {
- return !isArchived
- && userPackageManager.isAppArchivable(packageName)
- // We apply the same device policy for both the uninstallation and archive
- // button.
- && !appButtonRepository.isUninstallBlockedByAdmin(this)
+ return try {
+ (!isArchived
+ && userPackageManager.isAppArchivable(packageName)
+ // We apply the same device policy for both the uninstallation and archive
+ // button.
+ && !appButtonRepository.isUninstallBlockedByAdmin(this))
+ } catch (e: PackageManager.NameNotFoundException) {
+ false
+ }
}
private fun onArchiveClicked(app: ApplicationInfo) {
diff --git a/src/com/android/settings/spa/network/MobileDataSwitchingPreference.kt b/src/com/android/settings/spa/network/MobileDataSwitchingPreference.kt
new file mode 100644
index 0000000..8c382bd
--- /dev/null
+++ b/src/com/android/settings/spa/network/MobileDataSwitchingPreference.kt
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2024 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.spa.network
+
+import android.telephony.TelephonyManager
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.ui.res.stringResource
+import com.android.settings.R
+import com.android.settings.network.telephony.TelephonyRepository
+import com.android.settingslib.spa.widget.preference.SwitchPreference
+import com.android.settingslib.spa.widget.preference.SwitchPreferenceModel
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+
+@Composable
+fun MobileDataSwitchingPreference(
+ isMobileDataEnabled: () -> Boolean?,
+ setMobileDataEnabled: (newEnabled: Boolean) -> Unit,
+) {
+ val mobileDataSummary = stringResource(id = R.string.primary_sim_automatic_data_msg)
+ val coroutineScope = rememberCoroutineScope()
+ SwitchPreference(
+ object : SwitchPreferenceModel {
+ override val title = stringResource(id = R.string.mobile_data_settings_title)
+ override val summary = { mobileDataSummary }
+ override val checked = { isMobileDataEnabled() }
+ override val onCheckedChange: (Boolean) -> Unit = { newEnabled ->
+ coroutineScope.launch(Dispatchers.Default) {
+ setMobileDataEnabled(newEnabled)
+ }
+ }
+ override val changeable:() -> Boolean = {true}
+ }
+ )
+}
diff --git a/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt b/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt
index 80be970..0ccedeb 100644
--- a/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt
+++ b/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt
@@ -38,11 +38,12 @@
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
+import androidx.lifecycle.LifecycleOwner
+import androidx.lifecycle.LifecycleRegistry
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.android.settings.R
import com.android.settings.network.SubscriptionInfoListViewModel
-import com.android.settings.network.telephony.MobileNetworkUtils
import com.android.settings.network.telephony.TelephonyRepository
import com.android.settings.spa.network.PrimarySimRepository.PrimarySimInfo
import com.android.settings.wifi.WifiPickerTrackerHelper
@@ -167,7 +168,7 @@
defaultVoiceSubId: MutableIntState,
defaultSmsSubId: MutableIntState,
defaultDataSubId: MutableIntState,
- nonDds: MutableIntState
+ nonDds: MutableIntState,
) {
val selectableSubscriptionInfoList by selectableSubscriptionInfoListFlow
.collectAsStateWithLifecycle(initialValue = emptyList())
@@ -175,22 +176,76 @@
val stringSims = stringResource(R.string.provider_network_settings_title)
RegularScaffold(title = stringSims) {
SimsSection(selectableSubscriptionInfoList)
+ MobileDataSectionImpl(defaultDataSubId,
+ nonDds,
+ )
+
PrimarySimSectionImpl(
selectableSubscriptionInfoListFlow,
defaultVoiceSubId,
defaultSmsSubId,
defaultDataSubId,
- nonDds
)
}
}
@Composable
+fun MobileDataSectionImpl(
+ mobileDataSelectedId: MutableIntState,
+ nonDds: MutableIntState,
+) {
+ val context = LocalContext.current
+ val localLifecycleOwner = LocalLifecycleOwner.current
+ val wifiPickerTrackerHelper = getWifiPickerTrackerHelper(context, localLifecycleOwner)
+
+ val subscriptionManager: SubscriptionManager? =
+ context.getSystemService(SubscriptionManager::class.java)
+
+ Category(title = stringResource(id = R.string.mobile_data_settings_title)) {
+ val isAutoDataEnabled by remember(nonDds.intValue) {
+ TelephonyRepository(context).isMobileDataPolicyEnabledFlow(
+ subId = nonDds.intValue,
+ policy = TelephonyManager.MOBILE_DATA_POLICY_AUTO_DATA_SWITCH
+ )
+ }.collectAsStateWithLifecycle(initialValue = null)
+
+ val mobileDataStateChanged by remember(mobileDataSelectedId.intValue) {
+ TelephonyRepository(context).isDataEnabled(mobileDataSelectedId.intValue)
+ }.collectAsStateWithLifecycle(initialValue = false)
+ val coroutineScope = rememberCoroutineScope()
+
+ MobileDataSwitchingPreference(
+ isMobileDataEnabled = { mobileDataStateChanged },
+ setMobileDataEnabled = { newEnabled ->
+ coroutineScope.launch {
+ setMobileData(
+ context,
+ subscriptionManager,
+ wifiPickerTrackerHelper,
+ mobileDataSelectedId.intValue,
+ newEnabled
+ )
+ }
+ },
+ )
+ if (nonDds.intValue != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ AutomaticDataSwitchingPreference(
+ isAutoDataEnabled = { isAutoDataEnabled },
+ setAutoDataEnabled = { newEnabled ->
+ TelephonyRepository(context).setAutomaticData(nonDds.intValue, newEnabled)
+ },
+ )
+ }
+ }
+}
+
+@Composable
fun PrimarySimImpl(
primarySimInfo: PrimarySimInfo,
callsSelectedId: MutableIntState,
textsSelectedId: MutableIntState,
mobileDataSelectedId: MutableIntState,
+ wifiPickerTrackerHelper: WifiPickerTrackerHelper? = null,
subscriptionManager: SubscriptionManager? =
LocalContext.current.getSystemService(SubscriptionManager::class.java),
coroutineScope: CoroutineScope = rememberCoroutineScope(),
@@ -208,20 +263,15 @@
}
},
actionSetMobileData: (Int) -> Unit = {
- mobileDataSelectedId.intValue = it
coroutineScope.launch {
- // TODO: to fix the WifiPickerTracker crash when create
- // the wifiPickerTrackerHelper
setDefaultData(
context,
subscriptionManager,
- null/*wifiPickerTrackerHelper*/,
+ wifiPickerTrackerHelper,
it
)
}
},
- isAutoDataEnabled: () -> Boolean?,
- setAutoDataEnabled: (newEnabled: Boolean) -> Unit,
) {
CreatePrimarySimListPreference(
stringResource(id = R.string.primary_sim_calls_title),
@@ -244,8 +294,6 @@
Icons.Outlined.DataUsage,
actionSetMobileData
)
-
- AutomaticDataSwitchingPreference(isAutoDataEnabled, setAutoDataEnabled)
}
@Composable
@@ -254,9 +302,11 @@
callsSelectedId: MutableIntState,
textsSelectedId: MutableIntState,
mobileDataSelectedId: MutableIntState,
- nonDds: MutableIntState,
) {
val context = LocalContext.current
+ val localLifecycleOwner = LocalLifecycleOwner.current
+ val wifiPickerTrackerHelper = getWifiPickerTrackerHelper(context, localLifecycleOwner)
+
val primarySimInfo = remember(subscriptionInfoListFlow) {
subscriptionInfoListFlow
.map { subscriptionInfoList ->
@@ -267,25 +317,25 @@
}.collectAsStateWithLifecycle(initialValue = null).value ?: return
Category(title = stringResource(id = R.string.primary_sim_title)) {
- val isAutoDataEnabled by remember(nonDds.intValue) {
- TelephonyRepository(context).isMobileDataPolicyEnabledFlow(
- subId = nonDds.intValue,
- policy = TelephonyManager.MOBILE_DATA_POLICY_AUTO_DATA_SWITCH
- )
- }.collectAsStateWithLifecycle(initialValue = null)
PrimarySimImpl(
primarySimInfo,
callsSelectedId,
textsSelectedId,
mobileDataSelectedId,
- isAutoDataEnabled = { isAutoDataEnabled },
- setAutoDataEnabled = { newEnabled ->
- TelephonyRepository(context).setAutomaticData(nonDds.intValue, newEnabled)
- },
+ wifiPickerTrackerHelper
)
}
}
+private fun getWifiPickerTrackerHelper(
+ context: Context,
+ lifecycleOwner: LifecycleOwner
+): WifiPickerTrackerHelper {
+ return WifiPickerTrackerHelper(
+ LifecycleRegistry(lifecycleOwner), context,
+ null /* WifiPickerTrackerCallback */
+ )
+}
private fun Context.defaultVoiceSubscriptionFlow(): Flow<Int> =
merge(
flowOf(null), // kick an initial value
@@ -335,18 +385,27 @@
wifiPickerTrackerHelper: WifiPickerTrackerHelper?,
subId: Int
): Unit =
+ setMobileData(
+ context,
+ subscriptionManager,
+ wifiPickerTrackerHelper,
+ subId,
+ true
+ )
+
+suspend fun setMobileData(
+ context: Context,
+ subscriptionManager: SubscriptionManager?,
+ wifiPickerTrackerHelper: WifiPickerTrackerHelper?,
+ subId: Int,
+ enabled: Boolean,
+): Unit =
withContext(Dispatchers.Default) {
- subscriptionManager?.setDefaultDataSubId(subId)
- Log.d(NetworkCellularGroupProvider.name, "setMobileDataEnabled: true")
- MobileNetworkUtils.setMobileDataEnabled(
- context,
- subId,
- true /* enabled */,
- true /* disableOtherSubscriptions */
- )
- if (wifiPickerTrackerHelper != null
- && !wifiPickerTrackerHelper.isCarrierNetworkProvisionEnabled(subId)
- ) {
- wifiPickerTrackerHelper.setCarrierNetworkEnabled(true)
+ Log.d(NetworkCellularGroupProvider.name, "setMobileData: $enabled")
+ if (enabled) {
+ Log.d(NetworkCellularGroupProvider.name, "setDefaultData: [$subId]")
+ subscriptionManager?.setDefaultDataSubId(subId)
}
- }
+ TelephonyRepository(context)
+ .setMobileData(subId, enabled, wifiPickerTrackerHelper)
+ }
\ No newline at end of file
diff --git a/src/com/android/settings/spa/network/SimOnboardingPrimarySim.kt b/src/com/android/settings/spa/network/SimOnboardingPrimarySim.kt
index 0306aad..1c96979 100644
--- a/src/com/android/settings/spa/network/SimOnboardingPrimarySim.kt
+++ b/src/com/android/settings/spa/network/SimOnboardingPrimarySim.kt
@@ -102,18 +102,21 @@
mobileDataSelectedId = mobileDataSelectedId,
actionSetCalls = {
callsSelectedId.intValue = it
- onboardingService.targetPrimarySimCalls = it},
+ onboardingService.targetPrimarySimCalls = it
+ },
actionSetTexts = {
textsSelectedId.intValue = it
- onboardingService.targetPrimarySimTexts = it},
+ onboardingService.targetPrimarySimTexts = it
+ },
actionSetMobileData = {
mobileDataSelectedId.intValue = it
- onboardingService.targetPrimarySimMobileData = it},
- isAutoDataEnabled = { isAutoDataEnabled },
+ onboardingService.targetPrimarySimMobileData = it
+ }
+ )
+ AutomaticDataSwitchingPreference(isAutoDataEnabled = { isAutoDataEnabled },
setAutoDataEnabled = { newEnabled ->
onboardingService.targetPrimarySimAutoDataSwitch.value = newEnabled
- },
- )
+ })
}
}
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java
index fc5e768..af06d52 100644
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java
+++ b/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java
@@ -53,7 +53,6 @@
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.LooperMode;
import org.robolectric.shadows.ShadowApplication;
import java.util.ArrayList;
@@ -63,7 +62,6 @@
import java.util.Set;
@RunWith(RobolectricTestRunner.class)
-@LooperMode(LooperMode.Mode.LEGACY)
public final class InstalledAppCounterTest {
@Rule
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
index 91707cd..8f983de 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
@@ -79,7 +79,6 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.android.controller.ActivityController;
-import org.robolectric.annotation.LooperMode;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
@@ -88,7 +87,6 @@
@Ignore("b/295325503")
@RunWith(RobolectricTestRunner.class)
-@LooperMode(LooperMode.Mode.LEGACY)
public class FingerprintEnrollEnrollingTest {
private static final String ENROLL_PROGRESS_COLOR_LIGHT = "#699FF3";
private static final String ENROLL_PROGRESS_COLOR_DARK = "#7DA7F1";
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceControllerTest.java
index b86d9df..fab867f 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceControllerTest.java
@@ -35,12 +35,14 @@
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
+import android.platform.test.annotations.RequiresFlagsEnabled;
import androidx.lifecycle.LifecycleOwner;
import androidx.preference.ListPreference;
import androidx.preference.PreferenceScreen;
import com.android.settings.development.BluetoothA2dpConfigStore;
+import com.android.settings.development.Flags;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
@@ -57,7 +59,6 @@
@RunWith(RobolectricTestRunner.class)
public class BluetoothCodecListPreferenceControllerTest {
-
private static final String DEVICE_ADDRESS = "00:11:22:33:44:55";
@Mock private BluetoothA2dp mBluetoothA2dp;
@@ -245,6 +246,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_A2DP_OFFLOAD_CODEC_EXTENSIBILITY_SETTINGS)
public void onPreferenceChange_notifyPreference() {
assertFalse(
mController.onPreferenceChange(
diff --git a/tests/robotests/src/com/android/settings/language/LanguageAndInputPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/language/LanguageAndInputPreferenceControllerTest.java
deleted file mode 100644
index 3f27fdd..0000000
--- a/tests/robotests/src/com/android/settings/language/LanguageAndInputPreferenceControllerTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2019 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.language;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.content.ComponentName;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.provider.Settings;
-import android.view.inputmethod.InputMethodInfo;
-
-import com.android.settings.testutils.shadow.ShadowInputMethodManagerWithMethodList;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowInputMethodManagerWithMethodList.class)
-public class LanguageAndInputPreferenceControllerTest {
- private Context mContext;
-
- @Before
- public void setUp() {
- mContext = spy(RuntimeEnvironment.application);
- }
-
- @Test
- public void getSummary_shouldSetToCurrentImeName() {
- final ComponentName componentName = new ComponentName("name1", "cls");
- final ContentResolver cr = mContext.getContentResolver();
- Settings.Secure.putString(cr, Settings.Secure.DEFAULT_INPUT_METHOD,
- componentName.flattenToString());
- final List<InputMethodInfo> imis = new ArrayList<>();
- imis.add(mock(InputMethodInfo.class));
- when(imis.get(0).getPackageName()).thenReturn("name1");
- when(imis.get(0).loadLabel(any())).thenReturn("label");
- ShadowInputMethodManagerWithMethodList.getShadow().setInputMethodList(imis);
-
- final LanguageAndInputPreferenceController controller =
- new LanguageAndInputPreferenceController(mContext, "key");
-
- assertThat(controller.getSummary().toString()).contains("label");
- }
-}
diff --git a/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java b/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java
deleted file mode 100644
index 4429dd7..0000000
--- a/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2016 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.language;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.Activity;
-import android.app.admin.DevicePolicyManager;
-import android.content.Context;
-import android.content.res.Resources;
-import android.hardware.input.InputManager;
-import android.os.UserManager;
-import android.util.FeatureFlagUtils;
-import android.view.autofill.AutofillManager;
-import android.view.inputmethod.InputMethodManager;
-import android.view.textservice.TextServicesManager;
-
-import androidx.lifecycle.LifecycleObserver;
-
-import com.android.settings.R;
-import com.android.settings.testutils.XmlTestUtils;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(RobolectricTestRunner.class)
-public class LanguageAndInputSettingsTest {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Activity mActivity;
- @Mock
- private InputManager mIm;
- @Mock
- private InputMethodManager mImm;
- @Mock
- private DevicePolicyManager mDpm;
- @Mock
- private AutofillManager mAutofillManager;
- private TestFragment mFragment;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mock(UserManager.class));
- when(mActivity.getSystemService(Context.INPUT_SERVICE))
- .thenReturn(mock(InputManager.class));
- when(mActivity.getSystemService(Context.INPUT_SERVICE)).thenReturn(mIm);
- when(mActivity.getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE))
- .thenReturn(mock(TextServicesManager.class));
- when(mActivity.getSystemService(Context.DEVICE_POLICY_SERVICE)).thenReturn(mDpm);
- when(mActivity.getSystemService(Context.INPUT_METHOD_SERVICE)).thenReturn(mImm);
- when((Object) mActivity.getSystemService(AutofillManager.class))
- .thenReturn(mAutofillManager);
- mFragment = new TestFragment(mActivity);
- }
-
- @Test
- public void testGetPreferenceScreenResId() {
- assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(R.xml.language_and_input);
- }
-
- @Test
- public void testGetPreferenceControllers_shouldRegisterLifecycleObservers() {
- final List<AbstractPreferenceController> controllers =
- mFragment.createPreferenceControllers(mActivity);
- int lifecycleObserverCount = 0;
- for (AbstractPreferenceController controller : controllers) {
- if (controller instanceof LifecycleObserver) {
- lifecycleObserverCount++;
- }
- }
- verify(mFragment.getSettingsLifecycle(), times(lifecycleObserverCount))
- .addObserver(any(LifecycleObserver.class));
- }
-
- @Test
- public void testGetPreferenceControllers_shouldAllBeCreated() {
- final List<AbstractPreferenceController> controllers =
- mFragment.createPreferenceControllers(mActivity);
-
- assertThat(controllers.isEmpty()).isFalse();
- }
-
- @Test
- public void testNonIndexableKeys_existInXmlLayout() {
- final Context context = spy(RuntimeEnvironment.application);
- final Resources res = spy(RuntimeEnvironment.application.getResources());
- final InputManager inputManager = mock(InputManager.class);
- final TextServicesManager textServicesManager = mock(TextServicesManager.class);
- FeatureFlagUtils.setEnabled(context, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI, false);
- when(inputManager.getInputDeviceIds()).thenReturn(new int[0]);
- doReturn(inputManager).when(context).getSystemService(Context.INPUT_SERVICE);
- doReturn(textServicesManager).when(context)
- .getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE);
- doReturn(res).when(context).getResources();
- doReturn(false).when(res)
- .getBoolean(com.android.internal.R.bool.config_supportSystemNavigationKeys);
- final List<String> niks =
- LanguageAndInputSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(context);
- LanguageAndInputSettings settings = new LanguageAndInputSettings();
- final int xmlId = settings.getPreferenceScreenResId();
-
- final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
-
- assertThat(keys).containsAtLeastElementsIn(niks);
- }
-
- @Test
- public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
- final Context context = spy(RuntimeEnvironment.application);
- final TextServicesManager textServicesManager = mock(TextServicesManager.class);
- doReturn(textServicesManager).when(context)
- .getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE);
- final LanguageAndInputSettings fragment = new LanguageAndInputSettings();
- final List<String> preferenceScreenKeys =
- XmlTestUtils.getKeysFromPreferenceXml(context, fragment.getPreferenceScreenResId());
- final List<String> preferenceKeys = new ArrayList<>();
-
- for (AbstractPreferenceController controller : fragment.createPreferenceControllers(context)) {
- preferenceKeys.add(controller.getPreferenceKey());
- }
-
- assertThat(preferenceScreenKeys).containsAtLeastElementsIn(preferenceKeys);
- }
-
- /**
- * Test fragment to expose lifecycle and context so we can verify behavior for observables.
- */
- public static class TestFragment extends LanguageAndInputSettings {
-
- private Lifecycle mLifecycle;
- private Context mContext;
-
- public TestFragment(Context context) {
- mContext = context;
- mLifecycle = mock(Lifecycle.class);
- }
-
- @Override
- public Context getContext() {
- return mContext;
- }
-
- @Override
- public Lifecycle getSettingsLifecycle() {
- if (mLifecycle == null) {
- return super.getSettingsLifecycle();
- }
- return mLifecycle;
- }
- }
-}
diff --git a/tests/robotests/src/com/android/settings/network/SatelliteManagerUtilTest.kt b/tests/robotests/src/com/android/settings/network/SatelliteRepositoryTest.kt
similarity index 65%
rename from tests/robotests/src/com/android/settings/network/SatelliteManagerUtilTest.kt
rename to tests/robotests/src/com/android/settings/network/SatelliteRepositoryTest.kt
index 50d7897..c7d047a 100644
--- a/tests/robotests/src/com/android/settings/network/SatelliteManagerUtilTest.kt
+++ b/tests/robotests/src/com/android/settings/network/SatelliteRepositoryTest.kt
@@ -20,10 +20,12 @@
import android.os.OutcomeReceiver
import android.telephony.satellite.SatelliteManager
import android.telephony.satellite.SatelliteManager.SatelliteException
+import android.telephony.satellite.SatelliteModemStateCallback
import androidx.test.core.app.ApplicationProvider
-import com.android.settings.network.SatelliteManagerUtil.requestIsEnabled
+import com.google.common.truth.Truth.assertThat
import com.google.common.util.concurrent.ListenableFuture
import java.util.concurrent.Executor
+import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
@@ -42,7 +44,7 @@
@RunWith(RobolectricTestRunner::class)
-class SatelliteManagerUtilTest {
+class SatelliteRepositoryTest {
@JvmField
@Rule
@@ -57,10 +59,15 @@
@Mock
private lateinit var mockExecutor: Executor
+ private lateinit var repository: SatelliteRepository
+
+
@Before
fun setUp() {
`when`(this.spyContext.getSystemService(SatelliteManager::class.java))
.thenReturn(mockSatelliteManager)
+
+ repository = SatelliteRepository(spyContext)
}
@Test
@@ -78,7 +85,7 @@
}
val result: ListenableFuture<Boolean> =
- requestIsEnabled(spyContext, mockExecutor)
+ repository.requestIsEnabled(mockExecutor)
assertTrue(result.get())
}
@@ -98,7 +105,7 @@
}
val result: ListenableFuture<Boolean> =
- requestIsEnabled(spyContext, mockExecutor)
+ repository.requestIsEnabled(mockExecutor)
assertFalse(result.get())
}
@@ -117,7 +124,7 @@
null
}
- val result = requestIsEnabled(spyContext, mockExecutor)
+ val result = repository.requestIsEnabled(mockExecutor)
assertFalse(result.get())
}
@@ -126,8 +133,52 @@
fun requestIsEnabled_nullSatelliteManager() = runBlocking {
`when`(spyContext.getSystemService(SatelliteManager::class.java)).thenReturn(null)
- val result: ListenableFuture<Boolean> = requestIsEnabled(spyContext, mockExecutor)
+ val result: ListenableFuture<Boolean> = repository.requestIsEnabled(mockExecutor)
assertFalse(result.get())
}
+
+ @Test
+ fun getIsModemEnabledFlow_isSatelliteEnabledState() = runBlocking {
+ `when`(
+ mockSatelliteManager.registerForModemStateChanged(
+ any(),
+ any()
+ )
+ ).thenAnswer { invocation ->
+ val callback = invocation.getArgument<SatelliteModemStateCallback>(1)
+ callback.onSatelliteModemStateChanged(SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED)
+ SatelliteManager.SATELLITE_RESULT_SUCCESS
+ }
+
+ val flow = repository.getIsModemEnabledFlow()
+
+ assertThat(flow.first()).isTrue()
+ }
+
+ @Test
+ fun getIsModemEnabledFlow_isSatelliteDisabledState() = runBlocking {
+ `when`(
+ mockSatelliteManager.registerForModemStateChanged(
+ any(),
+ any()
+ )
+ ).thenAnswer { invocation ->
+ val callback = invocation.getArgument<SatelliteModemStateCallback>(1)
+ callback.onSatelliteModemStateChanged(SatelliteManager.SATELLITE_MODEM_STATE_OFF)
+ SatelliteManager.SATELLITE_RESULT_SUCCESS
+ }
+
+ val flow = repository.getIsModemEnabledFlow()
+
+ assertThat(flow.first()).isFalse()
+ }
+
+ @Test
+ fun getIsModemEnabledFlow_nullSatelliteManager() = runBlocking {
+ `when`(spyContext.getSystemService(SatelliteManager::class.java)).thenReturn(null)
+
+ val flow = repository.getIsModemEnabledFlow()
+ assertThat(flow.first()).isFalse()
+ }
}
\ No newline at end of file
diff --git a/tests/spa_unit/src/com/android/settings/network/telephony/TelephonyRepositoryTest.kt b/tests/spa_unit/src/com/android/settings/network/telephony/TelephonyRepositoryTest.kt
index ce27ed4..6058935 100644
--- a/tests/spa_unit/src/com/android/settings/network/telephony/TelephonyRepositoryTest.kt
+++ b/tests/spa_unit/src/com/android/settings/network/telephony/TelephonyRepositoryTest.kt
@@ -92,6 +92,30 @@
}
@Test
+ fun isDataEnabled_invalidSub_returnFalse() = runBlocking {
+ val state = repository.isDataEnabled(
+ subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID,
+ )
+
+ assertThat(state.firstWithTimeoutOrNull()).isFalse()
+ }
+
+ @Test
+ fun isDataEnabled_validSub_returnPolicyState() = runBlocking {
+ mockTelephonyManager.stub {
+ on {
+ isDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER)
+ } doReturn true
+ }
+
+ val state = repository.isDataEnabled(
+ subId = SUB_ID,
+ )
+
+ assertThat(state.firstWithTimeoutOrNull()).isTrue()
+ }
+
+ @Test
fun telephonyCallbackFlow_callbackRegistered() = runBlocking {
val flow = context.telephonyCallbackFlow<Unit>(SUB_ID) {
object : TelephonyCallback() {}
diff --git a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppArchiveButtonTest.kt b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppArchiveButtonTest.kt
index 2afb3f1..ac82756 100644
--- a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppArchiveButtonTest.kt
+++ b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppArchiveButtonTest.kt
@@ -110,6 +110,19 @@
}
@Test
+ fun appArchiveButton_whenPackageIsNotFound_isDisabled() {
+ val app = ApplicationInfo().apply {
+ packageName = PACKAGE_NAME
+ isArchived = false
+ }
+ whenever(userPackageManager.isAppArchivable(app.packageName)).thenThrow(PackageManager.NameNotFoundException())
+
+ val actionButton = setContent(app)
+
+ assertThat(actionButton.enabled).isFalse()
+ }
+
+ @Test
fun appArchiveButton_displaysRightTextAndIcon() {
val app = ApplicationInfo().apply {
packageName = PACKAGE_NAME
diff --git a/tests/unit/src/com/android/settings/language/LanguagePreferenceControllerTest.java b/tests/unit/src/com/android/settings/language/LanguagePreferenceControllerTest.java
index 6622753..f8e790f 100644
--- a/tests/unit/src/com/android/settings/language/LanguagePreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/language/LanguagePreferenceControllerTest.java
@@ -16,71 +16,32 @@
package com.android.settings.language;
-import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
-
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
-import android.util.FeatureFlagUtils;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.Settings;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class LanguagePreferenceControllerTest {
- private boolean mCacheFeatureFlagSwitch = false;
private Context mContext;
private LanguagePreferenceController mController;
@Before
public void setup() {
mContext = ApplicationProvider.getApplicationContext();
- mCacheFeatureFlagSwitch =
- FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI);
mController = new LanguagePreferenceController(mContext, "key");
-
- }
-
- @After
- public void tearDown() {
- FeatureFlagUtils.setEnabled(
- mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI, mCacheFeatureFlagSwitch);
- }
-
- @Test
- public void getAvailabilityStatus_featureFlagOff_returnUnavailable() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI,
- false);
-
- int result = mController.getAvailabilityStatus();
-
- assertEquals(CONDITIONALLY_UNAVAILABLE, result);
- }
-
- @Test
- public void getAvailabilityStatus_featureFlagOff_LanguageAndInputSettingsActivityEnabled() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI,
- false);
-
- mController.getAvailabilityStatus();
-
- assertTrue(isActivityEnable(mContext, Settings.LanguageAndInputSettingsActivity.class));
- assertFalse(isActivityEnable(mContext, Settings.LanguageSettingsActivity.class));
}
@Test
public void getAvailabilityStatus_featureFlagOff_LanguageAndInputSettingsActivitydisabled() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI,
- true);
-
mController.getAvailabilityStatus();
assertFalse(isActivityEnable(mContext, Settings.LanguageAndInputSettingsActivity.class));
diff --git a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java
index 637b485..522dcd5 100644
--- a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java
@@ -421,6 +421,30 @@
assertThat(privateSpaceMaintainer.isPrivateSpaceEntryPointEnabled()).isFalse();
}
+ @Test
+ public void createPrivateSpace_psDoesNotExist_setsSkipFirstUseHints() {
+ mSetFlagsRule.enableFlags(
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
+ PrivateSpaceMaintainer privateSpaceMaintainer =
+ PrivateSpaceMaintainer.getInstance(mContext);
+ privateSpaceMaintainer.createPrivateSpace();
+ assertThat(getSecureSkipFirstUseHints()).isEqualTo(1);
+ }
+
+ @Test
+ public void createPrivateSpace_pSExists_doesNotChangeSkipFirstUseHints() {
+ mSetFlagsRule.enableFlags(
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
+ PrivateSpaceMaintainer privateSpaceMaintainer =
+ PrivateSpaceMaintainer.getInstance(mContext);
+ privateSpaceMaintainer.createPrivateSpace();
+ assertThat(getSecureSkipFirstUseHints()).isEqualTo(1);
+ privateSpaceMaintainer.createPrivateSpace();
+ assertThat(getSecureSkipFirstUseHints()).isEqualTo(1);
+ }
+
private int getSecureUserSetupComplete() {
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
@@ -431,6 +455,16 @@
privateSpaceMaintainer.getPrivateProfileHandle().getIdentifier());
}
+ private int getSecureSkipFirstUseHints() {
+ PrivateSpaceMaintainer privateSpaceMaintainer =
+ PrivateSpaceMaintainer.getInstance(mContext);
+ return Settings.Secure.getIntForUser(
+ mContentResolver,
+ Settings.Secure.SKIP_FIRST_USE_HINTS,
+ 0,
+ privateSpaceMaintainer.getPrivateProfileHandle().getIdentifier());
+ }
+
private int getPsSensitiveNotificationsValue(PrivateSpaceMaintainer privateSpaceMaintainer) {
return Settings.Secure.getIntForUser(mContentResolver,
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,