From 4da20d24c4986b71a24d453df07298dc6daa2c03 Mon Sep 17 00:00:00 2001 From: arunvoddu Date: Wed, 8 Jan 2025 12:51:50 +0000 Subject: [PATCH] [Satellite] Satellite UX changes in SIM settings as per new UX design. Bug: 382707562 Flag: EXEMPT UX bug fix Test: Verified UX on device Change-Id: I9e600d8f1fd6c273329e05a74079f1e03c209c65 --- res/values/strings.xml | 6 +- ...eSettingsPreferenceCategoryController.java | 73 +------------------ ...tingsPreferenceCategoryControllerTest.java | 31 +------- 3 files changed, 7 insertions(+), 103 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index c3fb2f94ead..0144996f754 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -12431,9 +12431,9 @@ About %1$s - You can send and receive text messages by satellite as part of an eligible %1$s account + You can send and receive text messages by satellite with an eligible %1$s account - Your %1$s plan + Your %1$s account Messaging is included with your account @@ -12451,7 +12451,7 @@ You can text anyone, including emergency services. Your phone will reconnect to a mobile network when available. - %1$s may take longer and is available only in some areas. Weather and certain structures may affect your satellite connection. Calling by satellite isn\u2019t available. Emergency calls may still connect.\n\nIt may take some time for account changes to show in Settings. Contact %1$s for details. + %1$s may take longer and is available only in some areas. Weather and certain structures may affect your satellite connection. Calling by satellite isn\u2019t available. Emergency calls may still connect.\n\nIt may take some time for account changes to show in Settings. Contact %2$s for details. More about %1$s diff --git a/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryController.java b/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryController.java index f0d1da42c88..6218e055038 100644 --- a/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryController.java +++ b/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryController.java @@ -18,21 +18,13 @@ package com.android.settings.network.telephony; import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL; import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ESOS_SUPPORTED_BOOL; -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.TelephonyCallback; -import android.telephony.TelephonyManager; -import android.telephony.satellite.NtnSignalStrength; import android.telephony.satellite.SatelliteManager; import android.util.Log; -import androidx.annotation.NonNull; -import androidx.annotation.VisibleForTesting; import androidx.lifecycle.DefaultLifecycleObserver; -import androidx.lifecycle.LifecycleOwner; import androidx.preference.PreferenceCategory; import androidx.preference.PreferenceScreen; @@ -40,9 +32,6 @@ import com.android.settings.R; import com.android.settings.flags.Flags; import com.android.settings.network.CarrierConfigCache; -import java.util.Arrays; -import java.util.List; - /** Preference controller for Satellite functions in mobile network settings. */ public class SatelliteSettingsPreferenceCategoryController extends TelephonyBasePreferenceController implements DefaultLifecycleObserver { @@ -51,17 +40,11 @@ public class SatelliteSettingsPreferenceCategoryController private CarrierConfigCache mCarrierConfigCache; private SatelliteManager mSatelliteManager; private PreferenceCategory mPreferenceCategory; - private TelephonyManager mTelephonyManager; - - @VisibleForTesting - final CarrierRoamingNtnModeCallback mCarrierRoamingNtnModeCallback = - new CarrierRoamingNtnModeCallback(); public SatelliteSettingsPreferenceCategoryController(Context context, String key) { super(context, key); mCarrierConfigCache = CarrierConfigCache.getInstance(context); mSatelliteManager = context.getSystemService(SatelliteManager.class); - mTelephonyManager = context.getSystemService(TelephonyManager.class); } /** @@ -72,13 +55,13 @@ public class SatelliteSettingsPreferenceCategoryController 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()); + mPreferenceCategory.setTitle(R.string.category_title_satellite_connectivity); } @Override @@ -103,58 +86,4 @@ public class SatelliteSettingsPreferenceCategoryController return (isSatelliteAttachSupported || isSatelliteSosSupported) ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE; } - - @Override - public void onResume(@NonNull LifecycleOwner owner) { - if (Flags.satelliteOemSettingsUxMigration()) { - mTelephonyManager.registerTelephonyCallback(mContext.getMainExecutor(), - mCarrierRoamingNtnModeCallback); - } - } - - @Override - public void onPause(@NonNull LifecycleOwner owner) { - if (Flags.satelliteOemSettingsUxMigration()) { - mTelephonyManager.unregisterTelephonyCallback(mCarrierRoamingNtnModeCallback); - } - } - - @VisibleForTesting - class CarrierRoamingNtnModeCallback extends TelephonyCallback implements - TelephonyCallback.CarrierRoamingNtnListener { - @Override - public void onCarrierRoamingNtnAvailableServicesChanged(int[] availableServices) { - CarrierRoamingNtnListener.super.onCarrierRoamingNtnAvailableServicesChanged( - availableServices); - List availableServicesList = Arrays.stream(availableServices).boxed().toList(); - boolean isSmsAvailable = availableServicesList.contains(SERVICE_TYPE_SMS); - boolean isDataAvailable = availableServicesList.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); - } - } - - @Override - public void onCarrierRoamingNtnEligibleStateChanged(boolean eligible) { - // Do nothing - } - - @Override - public void onCarrierRoamingNtnModeChanged(boolean active) { - // Do nothing - } - - @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 82119f17bd3..085a68d8173 100644 --- a/tests/unit/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryControllerTest.java +++ b/tests/unit/src/com/android/settings/network/telephony/SatelliteSettingsPreferenceCategoryControllerTest.java @@ -16,13 +16,12 @@ package com.android.settings.network.telephony; -import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_DATA; -import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_SMS; - import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE; import static com.google.common.truth.Truth.assertThat; +import static junit.framework.Assert.assertEquals; + import static org.mockito.Mockito.spy; import android.content.Context; @@ -35,8 +34,6 @@ import androidx.preference.PreferenceScreen; import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.android.settings.R; - import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; @@ -72,24 +69,6 @@ public class SatelliteSettingsPreferenceCategoryControllerTest { assertThat(result).isEqualTo(UNSUPPORTED_ON_DEVICE); } - @Test - @Ignore("b/382664790") - public void setPreferenceTitle_hasDataService_showConnectivity() { - PreferenceManager preferenceManager = new PreferenceManager(mContext); - PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(mContext); - PreferenceCategory preferenceCategory = new PreferenceCategory(mContext); - preferenceCategory.setKey(KEY); - preferenceCategory.addPreference(new Preference(mContext)); - preferenceScreen.addPreference(preferenceCategory); - mController.displayPreference(preferenceScreen); - - mController.mCarrierRoamingNtnModeCallback.onCarrierRoamingNtnAvailableServicesChanged( - new int[]{SERVICE_TYPE_DATA}); - - assertThat(preferenceCategory.getTitle()).isEqualTo( - mContext.getString(R.string.title_satellite_setting_connectivity)); - } - @Test @Ignore("b/382664790") public void setPreferenceTitle_hasSmsService_showMessaging() { @@ -101,10 +80,6 @@ public class SatelliteSettingsPreferenceCategoryControllerTest { preferenceCategory.addPreference(new Preference(mContext)); mController.displayPreference(preferenceScreen); - mController.mCarrierRoamingNtnModeCallback.onCarrierRoamingNtnAvailableServicesChanged( - new int[]{SERVICE_TYPE_SMS}); - - assertThat(preferenceCategory.getTitle()).isEqualTo( - mContext.getString(R.string.satellite_setting_title)); + assertEquals(preferenceCategory.getTitle(), "Satellite connectivity"); } }