Merge changes from topics "battery_header_bar0", "battery_header_bar06", "battery_header_bar1" into main
* changes:
[PixelCare] Catalyst migration for battery header
Remove BatteryHeaderPreferenceController usage in PowerUsageSummary.
Split battery header text to a separated preference
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index 01d75e8..6e22780 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -1,5 +1,6 @@
[Hook Scripts]
-checkcolor_hook = ${REPO_ROOT}/prebuilts/checkcolor/checkcolor.py -p .
+# TODO(b/377902600): Re-enable this hook once it is fixed.
+#checkcolor_hook = ${REPO_ROOT}/prebuilts/checkcolor/checkcolor.py -p .
checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
diff --git a/aconfig/settings_biometrics_integration_declarations.aconfig b/aconfig/settings_biometrics_integration_declarations.aconfig
index 8168c85..cc756c6 100644
--- a/aconfig/settings_biometrics_integration_declarations.aconfig
+++ b/aconfig/settings_biometrics_integration_declarations.aconfig
@@ -41,3 +41,14 @@
description: "This flag controls whether the onboarding education settings UX should be enabled"
bug: "370940762"
}
+
+flag {
+ name: "biometric_onboarding_education"
+ namespace: "biometrics_integration"
+ description: "This flag controls whether the onboarding education settings UX should be enabled"
+ bug: "370940762"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4d51512..2de7e88 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -470,6 +470,8 @@
<string name="country_selection_title">Region preference</string>
<!-- Hint text in a search edit box (used to filter long language / country lists) [CHAR LIMIT=25] -->
<string name="search_language_hint">Type language name</string>
+ <!-- Category for more language settings. [CHAR LIMIT=NONE]-->
+ <string name="more_language_settings_category">More language settings</string>
<!-- Regional Preferences begin -->
<!-- The title of the menu entry of regional preferences. [CHAR LIMIT=50] -->
@@ -3048,7 +3050,7 @@
<!-- Dark UI screen footer action text linking to Modes settings. [CHAR LIMIT=NONE] -->
<string name="dark_ui_modes_footer_action">Modes settings</string>
<!-- Even Dimmer setting title. Allows device to reduce brightness even further than standard range. [CHAR LIMIT=NONE] -->
- <string name="even_dimmer_display_title">Even dimmer</string>
+ <string name="even_dimmer_display_title">Extra dim</string>
<!-- Even Dimmer setting summary. [CHAR LIMIT=NONE] -->
<string name="even_dimmer_display_summary">Allow device to go dimmer than usual</string>
@@ -12302,8 +12304,10 @@
<string name="satellite_warning_dialog_title">Can’t turn on <xliff:g id="function" example="bluetooth">%1$s</xliff:g></string>
<!-- Content for satellite warning dialog to avoid user using wifi/bluetooth/airplane mode [CHAR_LIMIT=NONE] -->
<string name="satellite_warning_dialog_content">To turn on <xliff:g id="function" example="bluetooth">%1$s</xliff:g>, first end the satellite connection</string>
- <!-- Category title for satellite functions in mobile network settings [CHAR LIMIT=60] -->
+ <!-- Category title for satellite functions with data transmission in mobile network settings [CHAR LIMIT=60] -->
<string name="category_title_satellite_connectivity">Satellite connectivity</string>
+ <!-- Title for satellite functions with data transmission in mobile network settings [CHAR LIMIT=60] -->
+ <string name="satellite_setting_connectivity">Satellite connectivity</string>
<!-- Title for Apn settings in mobile network settings [CHAR LIMIT=60] -->
diff --git a/res/xml/language_settings.xml b/res/xml/language_settings.xml
index fb79346..f9f423e 100644
--- a/res/xml/language_settings.xml
+++ b/res/xml/language_settings.xml
@@ -28,12 +28,13 @@
android:title="@string/system_language"
android:fragment="com.android.settings.localepicker.LocaleListEditor"
settings:controller="com.android.settings.language.PhoneLanguagePreferenceController" />
+
<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">
+ settings:controller="com.android.settings.applications.appinfo.AppsLocalePreferenceController">
<extra
android:name="classname"
android:value="com.android.settings.applications.appinfo.AppLocaleDetails" />
@@ -49,6 +50,22 @@
</PreferenceCategory>
<PreferenceCategory
+ android:key="more_language_settings_category"
+ android:title="@string/more_language_settings_category"
+ settings:controller="com.android.settings.language.MoreLanguagesSettingsCategoryController">
+ <Preference
+ android:key="apps_language_in_more_language_settings"
+ 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.NewAppsLocalePreferenceController">
+ <extra
+ android:name="classname"
+ android:value="com.android.settings.applications.appinfo.AppLocaleDetails" />
+ </Preference>
+ </PreferenceCategory>
+
+ <PreferenceCategory
android:key="regional_preferences_category"
android:title="@string/regional_preferences_category_title"
settings:controller="com.android.settings.regionalpreferences.RegionalPreferencesCategoryController">
diff --git a/res/xml/mobile_network_settings.xml b/res/xml/mobile_network_settings.xml
index fb20dce..3c1317d 100644
--- a/res/xml/mobile_network_settings.xml
+++ b/res/xml/mobile_network_settings.xml
@@ -206,7 +206,7 @@
<PreferenceCategory
android:key="telephony_satellite_settings_category_key"
- android:title="@string/category_title_satellite_connectivity"
+ android:title="@string/satellite_setting_title"
settings:controller="com.android.settings.network.telephony.SatelliteSettingsPreferenceCategoryController">
<com.android.settingslib.RestrictedPreference
diff --git a/src/com/android/settings/EventLogTags.logtags b/src/com/android/settings/EventLogTags.logtags
index 2c8ad35..4e5a742 100644
--- a/src/com/android/settings/EventLogTags.logtags
+++ b/src/com/android/settings/EventLogTags.logtags
@@ -1,4 +1,4 @@
-# See system/core/logcat/event.logtags for a description of the format of this file.
+# See system/logging/logcat/event.logtags for a description of the format of this file.
option java_package com.android.settings
diff --git a/src/com/android/settings/applications/appinfo/AppsLocalePreferenceController.java b/src/com/android/settings/applications/appinfo/AppsLocalePreferenceController.java
new file mode 100644
index 0000000..c66ea58
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/AppsLocalePreferenceController.java
@@ -0,0 +1,42 @@
+/*
+ * 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.applications.appinfo;
+
+import android.content.Context;
+
+import androidx.annotation.NonNull;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.flags.Flags;
+
+/**
+ * A controller to update current locale information of application
+ * and a entry to launch {@link ManageApplications}.
+ */
+public class AppsLocalePreferenceController extends BasePreferenceController {
+ public AppsLocalePreferenceController(@NonNull Context context, @NonNull String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (!Flags.regionalPreferencesApiEnabled()) {
+ return AVAILABLE;
+ }
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/applications/appinfo/NewAppsLocalePreferenceController.java b/src/com/android/settings/applications/appinfo/NewAppsLocalePreferenceController.java
new file mode 100644
index 0000000..abd7af8
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/NewAppsLocalePreferenceController.java
@@ -0,0 +1,44 @@
+/*
+ * 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.applications.appinfo;
+
+import android.content.Context;
+
+import androidx.annotation.NonNull;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.flags.Flags;
+
+/**
+ * A controller to update current locale information of application
+ * and a entry to launch {@link ManageApplications}.
+ */
+public class NewAppsLocalePreferenceController extends BasePreferenceController {
+
+ public NewAppsLocalePreferenceController(@NonNull Context context, @NonNull String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ // TODO(b/381011808) After feature release, this class may be renamed.
+ if (Flags.regionalPreferencesApiEnabled()) {
+ return AVAILABLE;
+ }
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/language/MoreLanguagesSettingsCategoryController.java b/src/com/android/settings/language/MoreLanguagesSettingsCategoryController.java
new file mode 100644
index 0000000..3f2f9d7
--- /dev/null
+++ b/src/com/android/settings/language/MoreLanguagesSettingsCategoryController.java
@@ -0,0 +1,42 @@
+/*
+ * 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.language;
+
+import android.content.Context;
+
+import androidx.annotation.NonNull;
+
+import com.android.settings.flags.Flags;
+import com.android.settings.widget.PreferenceCategoryController;
+
+/**
+ * Controller for the "More language settings" category in the Language & region settings.
+ */
+public class MoreLanguagesSettingsCategoryController extends PreferenceCategoryController {
+
+ public MoreLanguagesSettingsCategoryController(@NonNull Context context, @NonNull String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (Flags.regionalPreferencesApiEnabled()) {
+ return AVAILABLE;
+ }
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/network/telephony/SatelliteSettingPreferenceController.java b/src/com/android/settings/network/telephony/SatelliteSettingPreferenceController.java
index 9ca0294..efdd9cb 100644
--- a/src/com/android/settings/network/telephony/SatelliteSettingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/SatelliteSettingPreferenceController.java
@@ -86,6 +86,7 @@
@Override
public void displayPreference(@NonNull PreferenceScreen screen) {
super.displayPreference(screen);
+ updateState(screen.findPreference(getPreferenceKey()));
}
@Override
diff --git a/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryController.java b/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryController.java
index 951d9ca..688e7b4 100644
--- a/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryController.java
+++ b/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryController.java
@@ -16,55 +16,120 @@
package com.android.settings.network.telephony;
+import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_DATA;
+import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_SMS;
+
import android.content.Context;
-import android.os.PersistableBundle;
-import android.telephony.CarrierConfigManager;
-import android.telephony.satellite.SatelliteManager;
+import android.telephony.TelephonyCallback;
+import android.telephony.TelephonyManager;
+import android.telephony.satellite.NtnSignalStrength;
import android.util.Log;
-import com.android.internal.telephony.flags.Flags;
-import com.android.settings.network.CarrierConfigCache;
+import androidx.annotation.NonNull;
+import androidx.annotation.VisibleForTesting;
+import androidx.lifecycle.DefaultLifecycleObserver;
+import androidx.lifecycle.LifecycleOwner;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceScreen;
-/** Preference controller for Satellite functions in mobile network settings.*/
+import com.android.settings.R;
+
+import java.util.List;
+
+/** Preference controller for Satellite functions in mobile network settings. */
public class SatelliteSettingsPreferenceCategoryController
- extends TelephonyBasePreferenceController {
+ extends TelephonyBasePreferenceController implements DefaultLifecycleObserver {
private static final String TAG = "SatelliteSettingsPrefCategoryCon";
- private CarrierConfigCache mCarrierConfigCache;
- private SatelliteManager mSatelliteManager;
+ private PreferenceCategory mPreferenceCategory;
+ private TelephonyManager mTelephonyManager = null;
+
+ @VisibleForTesting
+ final CarrierRoamingNtnModeCallback mCarrierRoamingNtnModeCallback =
+ new CarrierRoamingNtnModeCallback();
public SatelliteSettingsPreferenceCategoryController(Context context, String key) {
super(context, key);
- mCarrierConfigCache = CarrierConfigCache.getInstance(context);
- mSatelliteManager = context.getSystemService(SatelliteManager.class);
+ setAvailabilityStatus(UNSUPPORTED_ON_DEVICE);
+ mTelephonyManager = context.getSystemService(TelephonyManager.class);
}
/**
* Set subId for Satellite Settings category .
+ *
* @param subId subscription ID.
*/
public void init(int subId) {
Log.d(TAG, "init(), subId=" + subId);
mSubId = subId;
+ mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId);
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreferenceCategory = screen.findPreference(getPreferenceKey());
+ if (mPreferenceCategory.getPreferenceCount() > 0) {
+ for (int i = 0; i < mPreferenceCategory.getPreferenceCount(); i++) {
+ if (mPreferenceCategory.getPreference(i).isVisible()) {
+ setAvailabilityStatus(AVAILABLE_UNSEARCHABLE);
+ break;
+ }
+ }
+ }
}
@Override
public int getAvailabilityStatus(int subId) {
- if (!Flags.carrierEnabledSatelliteFlag()) {
- Log.d(TAG, "getAvailabilityStatus(" + subId + ") : carrierEnabledSatelliteFlag "
- + "is disabled");
- return UNSUPPORTED_ON_DEVICE;
+ return isAvailable() ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
+ }
+
+ @Override
+ public void onResume(@NonNull LifecycleOwner owner) {
+ mTelephonyManager.registerTelephonyCallback(mContext.getMainExecutor(),
+ mCarrierRoamingNtnModeCallback);
+ }
+
+ @Override
+ public void onPause(@NonNull LifecycleOwner owner) {
+ mTelephonyManager.unregisterTelephonyCallback(mCarrierRoamingNtnModeCallback);
+ }
+
+ @VisibleForTesting
+ class CarrierRoamingNtnModeCallback extends TelephonyCallback implements
+ TelephonyCallback.CarrierRoamingNtnModeListener {
+ @Override
+ public void onCarrierRoamingNtnAvailableServicesChanged(List<Integer> availableServices) {
+ CarrierRoamingNtnModeListener.super.onCarrierRoamingNtnAvailableServicesChanged(
+ availableServices);
+ boolean isSmsAvailable = availableServices.contains(SERVICE_TYPE_SMS);
+ boolean isDataAvailable = availableServices.contains(SERVICE_TYPE_DATA);
+ Log.i(TAG, "isSmsAvailable : " + isSmsAvailable
+ + " / isDataAvailable " + isDataAvailable);
+ if (mPreferenceCategory == null) {
+ Log.d(TAG, "Satellite preference category is not initialized yet");
+ return;
+ }
+ if (isDataAvailable) {
+ mPreferenceCategory.setTitle(R.string.category_title_satellite_connectivity);
+ } else if (isSmsAvailable) {
+ mPreferenceCategory.setTitle(R.string.satellite_setting_title);
+ }
}
- if (mSatelliteManager == null) {
- Log.d(TAG, "getAvailabilityStatus(" + subId + ") : SatelliteManager is null");
- return UNSUPPORTED_ON_DEVICE;
+ @Override
+ public void onCarrierRoamingNtnEligibleStateChanged(boolean eligible) {
+ // Do nothing
}
- final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
- final boolean isSatelliteAttachSupported = carrierConfig.getBoolean(
- CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL);
+ @Override
+ public void onCarrierRoamingNtnModeChanged(boolean active) {
+ // Do nothing
+ }
- return isSatelliteAttachSupported ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ @Override
+ public void onCarrierRoamingNtnSignalStrengthChanged(NtnSignalStrength ntnSignalStrength) {
+ // Do nothing
+ }
}
}
diff --git a/tests/unit/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryControllerTest.java
index 3b6e943..52c3179 100644
--- a/tests/unit/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryControllerTest.java
@@ -16,38 +16,37 @@
package com.android.settings.network.telephony;
-import static com.android.settings.core.BasePreferenceController.AVAILABLE;
-import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
+import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_DATA;
+import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_SMS;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
import android.content.Context;
import android.os.Looper;
-import android.os.PersistableBundle;
-import android.platform.test.annotations.DisableFlags;
-import android.platform.test.annotations.EnableFlags;
-import android.platform.test.flag.junit.SetFlagsRule;
-import android.telephony.CarrierConfigManager;
-import android.telephony.satellite.SatelliteManager;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
-import com.android.internal.telephony.flags.Flags;
-import com.android.settings.network.CarrierConfigCache;
+import com.android.settings.R;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
+import java.util.List;
+
@RunWith(AndroidJUnit4.class)
public class SatelliteSettingsPreferenceCategoryControllerTest {
private static final String KEY = "key";
@@ -55,16 +54,9 @@
@Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
- @Rule
- public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
-
- @Mock
- private CarrierConfigCache mCarrierConfigCache;
private Context mContext = null;
- private SatelliteManager mSatelliteManager = null;
private SatelliteSettingsPreferenceCategoryController mController = null;
- private PersistableBundle mCarrierConfig = new PersistableBundle();
@Before
public void setUp() {
@@ -72,25 +64,38 @@
Looper.prepare();
}
mContext = spy(ApplicationProvider.getApplicationContext());
- mSatelliteManager = new SatelliteManager(mContext);
- CarrierConfigCache.setTestInstance(mContext, mCarrierConfigCache);
- when(mContext.getSystemService(SatelliteManager.class)).thenReturn(mSatelliteManager);
mController = new SatelliteSettingsPreferenceCategoryController(mContext, KEY);
}
@Test
- @DisableFlags(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
- public void getAvailabilityStatus_featureDisabled_returnUnsupport() {
+ public void getAvailabilityStatus_default_returnUnsupported() {
int result = mController.getAvailabilityStatus(TEST_SUB_ID);
-
assertThat(result).isEqualTo(UNSUPPORTED_ON_DEVICE);
}
@Test
- @EnableFlags(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
- public void getAvailabilityStatus_noSatellite_returnUnsupport() {
- when(mContext.getSystemService(SatelliteManager.class)).thenReturn(null);
- mController = new SatelliteSettingsPreferenceCategoryController(mContext, KEY);
+ public void getAvailabilityStatus_hasAvailablePreference_returnAvailableUnsearchable() {
+ PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(mContext);
+ PreferenceCategory preferenceCategory = new PreferenceCategory(mContext);
+ preferenceCategory.setKey(KEY);
+ preferenceScreen.addPreference(preferenceCategory);
+ preferenceCategory.addPreference(new Preference(mContext));
+ mController.displayPreference(preferenceScreen);
+
+ int result = mController.getAvailabilityStatus(TEST_SUB_ID);
+
+ assertThat(result).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_noAvailablePreference_returnUnsupported() {
+ PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(mContext);
+ PreferenceCategory preferenceCategory = new PreferenceCategory(mContext);
+ preferenceCategory.setKey(KEY);
+ preferenceScreen.addPreference(preferenceCategory);
+ mController.displayPreference(preferenceScreen);
int result = mController.getAvailabilityStatus(TEST_SUB_ID);
@@ -98,30 +103,37 @@
}
@Test
- @EnableFlags(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
- public void getAvailabilityStatus_carrierIsNotSupport_returnUnavailable() {
- when(mContext.getSystemService(SatelliteManager.class)).thenReturn(null);
- mCarrierConfig.putBoolean(
- CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL,
- false);
- when(mCarrierConfigCache.getConfigForSubId(TEST_SUB_ID)).thenReturn(mCarrierConfig);
+ public void setPreferenceTitle_hasDataService_showConnectivity() {
+ PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(mContext);
+ PreferenceCategory preferenceCategory = new PreferenceCategory(mContext);
+ preferenceCategory.setKey(KEY);
+ preferenceScreen.addPreference(preferenceCategory);
+ preferenceCategory.addPreference(new Preference(mContext));
+ mController.displayPreference(preferenceScreen);
- int result = mController.getAvailabilityStatus(TEST_SUB_ID);
+ mController.mCarrierRoamingNtnModeCallback.onCarrierRoamingNtnAvailableServicesChanged(
+ List.of(SERVICE_TYPE_DATA));
- assertThat(result).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ assertThat(preferenceCategory.getTitle()).isEqualTo(
+ mContext.getString(R.string.satellite_setting_connectivity));
}
+
@Test
- @EnableFlags(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
- public void getAvailabilityStatus_carrierIsSupport_returnAvailable() {
- when(mContext.getSystemService(SatelliteManager.class)).thenReturn(null);
- mCarrierConfig.putBoolean(
- CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL,
- true);
- when(mCarrierConfigCache.getConfigForSubId(TEST_SUB_ID)).thenReturn(mCarrierConfig);
+ public void setPreferenceTitle_hasSmsService_showMessaging() {
+ PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(mContext);
+ PreferenceCategory preferenceCategory = new PreferenceCategory(mContext);
+ preferenceCategory.setKey(KEY);
+ preferenceScreen.addPreference(preferenceCategory);
+ preferenceCategory.addPreference(new Preference(mContext));
+ mController.displayPreference(preferenceScreen);
- int result = mController.getAvailabilityStatus(TEST_SUB_ID);
+ mController.mCarrierRoamingNtnModeCallback.onCarrierRoamingNtnAvailableServicesChanged(
+ List.of(SERVICE_TYPE_SMS));
- assertThat(result).isEqualTo(AVAILABLE);
+ assertThat(preferenceCategory.getTitle()).isEqualTo(
+ mContext.getString(R.string.satellite_setting_title));
}
}