Disabled Settings preference in case Satellite's conditions.

Conditions
   - Satellite session started
   - Current subscription for Satellite is carrier based.
 Target preference UI in android settings
   - preferred network type
   - Automatically select network

Flag: com.android.settings.flags.satellite_oem_settings_ux_migration
Fix: b/378409439
Fix: b/378409428
Test: atest pass
Test: Manual test pass
Change-Id: I7aa04b818c8866bf5c891c28372a249c964b066f
This commit is contained in:
tomhsu
2024-11-20 13:55:05 +00:00
parent 01043fdf93
commit 9ca8709173
6 changed files with 401 additions and 24 deletions

View File

@@ -16,6 +16,9 @@
package com.android.settings.network.telephony;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_OFF;
import static androidx.lifecycle.Lifecycle.Event.ON_START;
import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.CDMA;
@@ -29,12 +32,15 @@ import static com.android.settings.network.telephony.TelephonyConstants.RadioAcc
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.os.PersistableBundle;
import android.platform.test.annotations.EnableFlags;
import android.telephony.CarrierConfigManager;
import android.telephony.RadioAccessFamily;
import android.telephony.ServiceState;
@@ -51,6 +57,7 @@ import androidx.test.annotation.UiThreadTest;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settings.flags.Flags;
import com.android.settings.network.CarrierConfigCache;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -294,6 +301,48 @@ public class EnabledNetworkModePreferenceControllerTest {
String.valueOf(TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA));
}
@UiThreadTest
@Test
@EnableFlags(Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION)
public void updateState_satelliteIsStartedAndSelectedSubForSatellite_disablePreference() {
mController.mSatelliteModemStateCallback
.onSatelliteModemStateChanged(SATELLITE_MODEM_STATE_CONNECTED);
mController.mSelectedNbIotSatelliteSubscriptionCallback
.onSelectedNbIotSatelliteSubscriptionChanged(SUB_ID);
mController.updateState(mPreference);
assertFalse(mPreference.isEnabled());
}
@UiThreadTest
@Test
@EnableFlags(Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION)
public void updateState_satelliteIsIdle_enablePreference() {
mController.mSatelliteModemStateCallback
.onSatelliteModemStateChanged(SATELLITE_MODEM_STATE_OFF);
mController.mSelectedNbIotSatelliteSubscriptionCallback
.onSelectedNbIotSatelliteSubscriptionChanged(SUB_ID);
mController.updateState(mPreference);
assertTrue(mPreference.isEnabled());
}
@UiThreadTest
@Test
@EnableFlags(Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION)
public void updateState_notSelectedSubForSatellite_enablePreference() {
mController.mSatelliteModemStateCallback
.onSatelliteModemStateChanged(SATELLITE_MODEM_STATE_CONNECTED);
mController.mSelectedNbIotSatelliteSubscriptionCallback
.onSelectedNbIotSatelliteSubscriptionChanged(0);
mController.updateState(mPreference);
assertTrue(mPreference.isEnabled());
}
@UiThreadTest
@Test
public void onPreferenceChange_updateSuccess() {

View File

@@ -16,12 +16,17 @@
package com.android.settings.network.telephony;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_OFF;
import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.GSM;
import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.RAF_TD_SCDMA;
import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.WCDMA;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
@@ -30,15 +35,18 @@ import static org.mockito.Mockito.when;
import android.content.Context;
import android.os.PersistableBundle;
import android.platform.test.annotations.EnableFlags;
import android.telephony.RadioAccessFamily;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import androidx.preference.ListPreference;
import androidx.test.annotation.UiThreadTest;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settings.flags.Flags;
import com.android.settings.network.CarrierConfigCache;
import com.android.settings.testutils.ResourcesUtils;
@@ -104,6 +112,48 @@ public class PreferredNetworkModePreferenceControllerTest {
"preferred_network_mode_tdscdma_gsm_wcdma_summary"));
}
@Test
@UiThreadTest
@EnableFlags(Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION)
public void updateState_satelliteIsStartedAndSelectedSubForSatellite_disablePreference() {
mController.mSatelliteModemStateCallback
.onSatelliteModemStateChanged(SATELLITE_MODEM_STATE_CONNECTED);
mController.mSelectedNbIotSatelliteSubscriptionCallback
.onSelectedNbIotSatelliteSubscriptionChanged(SUB_ID);
mController.updateState(mPreference);
assertFalse(mPreference.isEnabled());
}
@Test
@UiThreadTest
@EnableFlags(Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION)
public void updateState_satelliteIsIdle_enablePreference() {
mController.mSatelliteModemStateCallback
.onSatelliteModemStateChanged(SATELLITE_MODEM_STATE_OFF);
mController.mSelectedNbIotSatelliteSubscriptionCallback
.onSelectedNbIotSatelliteSubscriptionChanged(SUB_ID);
mController.updateState(mPreference);
assertTrue(mPreference.isEnabled());
}
@Test
@UiThreadTest
@EnableFlags(Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION)
public void updateState_notSelectedSubForSatellite_enablePreference() {
mController.mSatelliteModemStateCallback
.onSatelliteModemStateChanged(SATELLITE_MODEM_STATE_CONNECTED);
mController.mSelectedNbIotSatelliteSubscriptionCallback
.onSelectedNbIotSatelliteSubscriptionChanged(0);
mController.updateState(mPreference);
assertTrue(mPreference.isEnabled());
}
@Test
public void onPreferenceChange_updateNetworkMode() {
mController.onPreferenceChange(mPreference,