SIM status page sync signal strength and service state behavior from systemUI
To make behavior consistent in the long run and refactor the code into settingslib and call it from both Settings and SystemUI. Bug: 110973964 Test: run testcase and do manual test - test case as below: 1. Testcase: packages/apps/Settings: -> ALL PASS make RunSettingsRoboTests ROBOTEST_FILTER=SimStatusDialogControllerTest 2. Fake the service state's voice and data value,voice is out of service and data is in-service,and then check service state and signal strength at sim status page -> PASS Change-Id: I4cc454b6b3d4242af4805e2878f9d46ce28649ad
This commit is contained in:
@@ -50,6 +50,7 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||
import com.android.settingslib.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -253,8 +254,8 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
|
||||
}
|
||||
|
||||
private void updateServiceState(ServiceState serviceState) {
|
||||
final int state = serviceState.getState();
|
||||
if (state == ServiceState.STATE_OUT_OF_SERVICE || state == ServiceState.STATE_POWER_OFF) {
|
||||
final int state = Utils.getCombinedServiceState(serviceState);
|
||||
if (!Utils.isInService(serviceState)) {
|
||||
resetSignalStrength();
|
||||
}
|
||||
|
||||
@@ -297,10 +298,8 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
|
||||
return;
|
||||
}
|
||||
|
||||
final int state = getCurrentServiceState().getState();
|
||||
|
||||
if ((ServiceState.STATE_OUT_OF_SERVICE == state) ||
|
||||
(ServiceState.STATE_POWER_OFF == state)) {
|
||||
ServiceState serviceState = getCurrentServiceState();
|
||||
if (serviceState == null || !Utils.isInService(serviceState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -178,7 +178,7 @@ public class SimStatusDialogControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialize_updateDataStateWithPowerOff_shouldUpdateSettingAndResetSignalStrength() {
|
||||
public void initialize_updateServiceStateWithPowerOff_shouldUpdateTextAndResetSignalStrength() {
|
||||
when(mServiceState.getState()).thenReturn(ServiceState.STATE_POWER_OFF);
|
||||
when(mPersistableBundle.getBoolean(
|
||||
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
|
||||
@@ -190,6 +190,33 @@ public class SimStatusDialogControllerTest {
|
||||
verify(mDialog).setText(SIGNAL_STRENGTH_VALUE_ID, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialize_updateVoiceDataOutOfService_shouldUpdateSettingAndResetSignalStrength() {
|
||||
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
|
||||
when(mServiceState.getDataRegState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
|
||||
when(mPersistableBundle.getBoolean(
|
||||
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
|
||||
|
||||
mController.initialize();
|
||||
|
||||
final String offServiceText = mContext.getString(R.string.radioInfo_service_out);
|
||||
verify(mDialog).setText(SERVICE_STATE_VALUE_ID, offServiceText);
|
||||
verify(mDialog).setText(SIGNAL_STRENGTH_VALUE_ID, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateTextToBeInService() {
|
||||
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
|
||||
when(mServiceState.getDataRegState()).thenReturn(ServiceState.STATE_IN_SERVICE);
|
||||
when(mPersistableBundle.getBoolean(
|
||||
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
|
||||
|
||||
mController.initialize();
|
||||
|
||||
final String inServiceText = mContext.getString(R.string.radioInfo_service_in);
|
||||
verify(mDialog).setText(SERVICE_STATE_VALUE_ID, inServiceText);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialize_updateSignalStrengthWith50_shouldUpdateSignalStrengthTo50() {
|
||||
final int signalDbm = 50;
|
||||
@@ -206,6 +233,27 @@ public class SimStatusDialogControllerTest {
|
||||
verify(mDialog).setText(SIGNAL_STRENGTH_VALUE_ID, signalStrengthString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateSignalStrengthTo50() {
|
||||
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
|
||||
when(mServiceState.getDataRegState()).thenReturn(ServiceState.STATE_IN_SERVICE);
|
||||
when(mPersistableBundle.getBoolean(
|
||||
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
|
||||
|
||||
final int signalDbm = 50;
|
||||
final int signalAsu = 50;
|
||||
doReturn(signalDbm).when(mController).getDbm(mSignalStrength);
|
||||
doReturn(signalAsu).when(mController).getAsuLevel(mSignalStrength);
|
||||
when(mPersistableBundle.getBoolean(
|
||||
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
|
||||
|
||||
mController.initialize();
|
||||
|
||||
final String signalStrengthString =
|
||||
mContext.getString(R.string.sim_signal_strength, signalDbm, signalAsu);
|
||||
verify(mDialog).setText(SIGNAL_STRENGTH_VALUE_ID, signalStrengthString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialize_updateVoiceNetworkTypeWithEdge_shouldUpdateSettingToEdge() {
|
||||
when(mTelephonyManager.getVoiceNetworkType(anyInt())).thenReturn(
|
||||
|
Reference in New Issue
Block a user