Add signal strength customization
Also add default behavior in case carrier config bundle is null. Bug: 69730732 Test: manual and new unit test Change-Id: Ia38462a7e1b6f2e27ff45d93beef09465a68ae5c
This commit is contained in:
@@ -68,6 +68,8 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final static int SERVICE_STATE_VALUE_ID = R.id.service_state_value;
|
final static int SERVICE_STATE_VALUE_ID = R.id.service_state_value;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
final static int SIGNAL_STRENGTH_LABEL_ID = R.id.signal_strength_label;
|
||||||
|
@VisibleForTesting
|
||||||
final static int SIGNAL_STRENGTH_VALUE_ID = R.id.signal_strength_value;
|
final static int SIGNAL_STRENGTH_VALUE_ID = R.id.signal_strength_value;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final static int CELLULAR_NETWORK_TYPE_VALUE_ID = R.id.network_type_value;
|
final static int CELLULAR_NETWORK_TYPE_VALUE_ID = R.id.network_type_value;
|
||||||
@@ -262,6 +264,21 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateSignalStrength(SignalStrength signalStrength) {
|
private void updateSignalStrength(SignalStrength signalStrength) {
|
||||||
|
final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
|
||||||
|
final PersistableBundle carrierConfig =
|
||||||
|
mCarrierConfigManager.getConfigForSubId(subscriptionId);
|
||||||
|
// by default we show the signal strength
|
||||||
|
boolean showSignalStrength = true;
|
||||||
|
if (carrierConfig != null) {
|
||||||
|
showSignalStrength = carrierConfig.getBoolean(
|
||||||
|
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL);
|
||||||
|
}
|
||||||
|
if (!showSignalStrength) {
|
||||||
|
mDialog.removeSettingFromScreen(SIGNAL_STRENGTH_LABEL_ID);
|
||||||
|
mDialog.removeSettingFromScreen(SIGNAL_STRENGTH_VALUE_ID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final int state = getCurrentServiceState().getState();
|
final int state = getCurrentServiceState().getState();
|
||||||
|
|
||||||
if ((ServiceState.STATE_OUT_OF_SERVICE == state) ||
|
if ((ServiceState.STATE_OUT_OF_SERVICE == state) ||
|
||||||
@@ -327,9 +344,14 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
|
|||||||
|
|
||||||
private void updateIccidNumber() {
|
private void updateIccidNumber() {
|
||||||
final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
|
final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
|
||||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subscriptionId);
|
final PersistableBundle carrierConfig =
|
||||||
final boolean showIccId = carrierConfig.getBoolean(
|
mCarrierConfigManager.getConfigForSubId(subscriptionId);
|
||||||
CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL);
|
// do not show iccid by default
|
||||||
|
boolean showIccId = false;
|
||||||
|
if (carrierConfig != null) {
|
||||||
|
showIccId = carrierConfig.getBoolean(
|
||||||
|
CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL);
|
||||||
|
}
|
||||||
if (!showIccId) {
|
if (!showIccId) {
|
||||||
mDialog.removeSettingFromScreen(ICCID_INFO_LABEL_ID);
|
mDialog.removeSettingFromScreen(ICCID_INFO_LABEL_ID);
|
||||||
mDialog.removeSettingFromScreen(ICCID_INFO_VALUE_ID);
|
mDialog.removeSettingFromScreen(ICCID_INFO_VALUE_ID);
|
||||||
|
@@ -34,11 +34,14 @@ import static com.android.settings.deviceinfo.simstatus.SimStatusDialogControlle
|
|||||||
.ROAMING_INFO_VALUE_ID;
|
.ROAMING_INFO_VALUE_ID;
|
||||||
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController
|
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController
|
||||||
.SERVICE_STATE_VALUE_ID;
|
.SERVICE_STATE_VALUE_ID;
|
||||||
|
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController
|
||||||
|
.SIGNAL_STRENGTH_LABEL_ID;
|
||||||
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController
|
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController
|
||||||
.SIGNAL_STRENGTH_VALUE_ID;
|
.SIGNAL_STRENGTH_VALUE_ID;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -157,6 +160,9 @@ public class SimStatusDialogControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void initialize_updateDataStateWithPowerOff_shouldUpdateSettingAndResetSignalStrength() {
|
public void initialize_updateDataStateWithPowerOff_shouldUpdateSettingAndResetSignalStrength() {
|
||||||
when(mServiceState.getState()).thenReturn(ServiceState.STATE_POWER_OFF);
|
when(mServiceState.getState()).thenReturn(ServiceState.STATE_POWER_OFF);
|
||||||
|
when(mPersistableBundle.getBoolean(
|
||||||
|
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(
|
||||||
|
true);
|
||||||
|
|
||||||
mController.initialize();
|
mController.initialize();
|
||||||
|
|
||||||
@@ -172,6 +178,9 @@ public class SimStatusDialogControllerTest {
|
|||||||
final int signalAsu = 50;
|
final int signalAsu = 50;
|
||||||
doReturn(signalDbm).when(mController).getDbm(mSignalStrength);
|
doReturn(signalDbm).when(mController).getDbm(mSignalStrength);
|
||||||
doReturn(signalAsu).when(mController).getAsuLevel(mSignalStrength);
|
doReturn(signalAsu).when(mController).getAsuLevel(mSignalStrength);
|
||||||
|
when(mPersistableBundle.getBoolean(
|
||||||
|
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(
|
||||||
|
true);
|
||||||
|
|
||||||
mController.initialize();
|
mController.initialize();
|
||||||
|
|
||||||
@@ -225,6 +234,30 @@ public class SimStatusDialogControllerTest {
|
|||||||
verify(mDialog).removeSettingFromScreen(ICCID_INFO_VALUE_ID);
|
verify(mDialog).removeSettingFromScreen(ICCID_INFO_VALUE_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void initialize_doNotShowSignalStrength_shouldRemoveSignalStrengthSetting() {
|
||||||
|
when(mPersistableBundle.getBoolean(
|
||||||
|
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(
|
||||||
|
false);
|
||||||
|
|
||||||
|
mController.initialize();
|
||||||
|
|
||||||
|
verify(mDialog).removeSettingFromScreen(SIGNAL_STRENGTH_LABEL_ID);
|
||||||
|
verify(mDialog).removeSettingFromScreen(SIGNAL_STRENGTH_VALUE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void initialize_showSignalStrengthAndIccId_shouldShowSignalStrengthAndIccIdSetting() {
|
||||||
|
// getConfigForSubId is nullable, so make sure the default behavior is correct
|
||||||
|
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(null);
|
||||||
|
|
||||||
|
mController.initialize();
|
||||||
|
|
||||||
|
verify(mDialog).setText(eq(SIGNAL_STRENGTH_VALUE_ID), any());
|
||||||
|
verify(mDialog).removeSettingFromScreen(ICCID_INFO_LABEL_ID);
|
||||||
|
verify(mDialog).removeSettingFromScreen(ICCID_INFO_VALUE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void initialize_showIccid_shouldSetIccidToSetting() {
|
public void initialize_showIccid_shouldSetIccidToSetting() {
|
||||||
final String iccid = "12351351231241";
|
final String iccid = "12351351231241";
|
||||||
|
Reference in New Issue
Block a user