Snap for 5811135 from 5188a0560f to qt-qpr1-release
Change-Id: I6707a442fd7fd079623de9b9dc76dc8079d72b40
This commit is contained in:
@@ -971,7 +971,7 @@
|
||||
<!-- Button text in face settings which lets the user enroll their face [CHAR LIMIT=40] -->
|
||||
<string name="security_settings_face_settings_enroll">Set up face unlock</string>
|
||||
<!-- Text shown in face settings explaining what your face can be used for. [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_face_settings_footer">Use face unlock to unlock your device, sign in to apps, and confirm payments.\n\nKeep in mind:\nLooking at the phone can unlock it when you don\u2019t intend to.\n\nYour phone can be unlocked by someone else if it\u2019s held up to your face while your eyes are open.\n\nYour phone can be unlocked by someone who looks a lot like you, say, an identical sibling.</string>
|
||||
<string name="security_settings_face_settings_footer">Use face unlock to unlock your device, sign in to apps, and confirm payments.\n\nKeep in mind:\nLooking at the phone can unlock it when you don\u2019t intend to.\n\nYour phone can be unlocked by someone else if it\u2019s held up to your face, even if your eyes are closed.\n\nYour phone can be unlocked by someone who looks a lot like you, say, an identical sibling.</string>
|
||||
<!-- Dialog title shown when the user removes an enrollment [CHAR LIMIT=35] -->
|
||||
<string name="security_settings_face_settings_remove_dialog_title">Delete face data?</string>
|
||||
<!-- Dialog contents shown when the user removes an enrollment [CHAR LIMIT=NONE] -->
|
||||
|
||||
@@ -17,8 +17,11 @@
|
||||
package com.android.settings.wifi;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.SubscriptionManager;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
/**
|
||||
@@ -33,7 +36,7 @@ public class CellularFallbackPreferenceController extends TogglePreferenceContro
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return !avoidBadWifiConfig() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
return avoidBadWifiConfig() ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,12 +52,28 @@ public class CellularFallbackPreferenceController extends TogglePreferenceContro
|
||||
}
|
||||
|
||||
private boolean avoidBadWifiConfig() {
|
||||
return mContext.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_networkAvoidBadWifi) == 1;
|
||||
final int activeDataSubscriptionId = getActiveDataSubscriptionId();
|
||||
if (activeDataSubscriptionId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Resources resources = getResourcesForSubId(activeDataSubscriptionId);
|
||||
return resources.getInteger(com.android.internal.R.integer.config_networkAvoidBadWifi) == 1;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
int getActiveDataSubscriptionId() {
|
||||
return SubscriptionManager.getActiveDataSubscriptionId();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
Resources getResourcesForSubId(int subscriptionId) {
|
||||
return SubscriptionManager.getResourcesForSubId(mContext, subscriptionId,
|
||||
false /* useRootLocale */);
|
||||
}
|
||||
|
||||
private boolean avoidBadWifiCurrentSettings() {
|
||||
return "1".equals(Settings.Global.getString(mContext.getContentResolver(),
|
||||
Settings.Global.NETWORK_AVOID_BAD_WIFI));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,36 +18,54 @@ package com.android.settings.wifi;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.telephony.SubscriptionManager;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class CellularFallbackPreferenceControllerTest {
|
||||
private static final String KEY_CELLULAR_FALLBACK = "wifi_cellular_data_fallback";
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
|
||||
private CellularFallbackPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mController = new CellularFallbackPreferenceController(mContext, KEY_CELLULAR_FALLBACK);
|
||||
|
||||
mController = spy(new CellularFallbackPreferenceController(RuntimeEnvironment.application,
|
||||
KEY_CELLULAR_FALLBACK));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_invalidActiveSubscriptionId_shouldReturnFalse() {
|
||||
doReturn(SubscriptionManager.INVALID_SUBSCRIPTION_ID)
|
||||
.when(mController).getActiveDataSubscriptionId();
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_avoidBadWifiConfigIsFalse_shouldReturnTrue() {
|
||||
when(mContext.getResources().getInteger(
|
||||
final Resources resources = mock(Resources.class);
|
||||
|
||||
doReturn(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)
|
||||
.when(mController).getActiveDataSubscriptionId();
|
||||
doReturn(resources).when(mController).getResourcesForSubId(anyInt());
|
||||
when(resources.getInteger(
|
||||
com.android.internal.R.integer.config_networkAvoidBadWifi))
|
||||
.thenReturn(0);
|
||||
|
||||
@@ -56,10 +74,15 @@ public class CellularFallbackPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isAvailable_avoidBadWifiConfigIsTrue_shouldReturnFalse() {
|
||||
when(mContext.getResources().getInteger(
|
||||
final Resources resources = mock(Resources.class);
|
||||
|
||||
doReturn(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)
|
||||
.when(mController).getActiveDataSubscriptionId();
|
||||
doReturn(resources).when(mController).getResourcesForSubId(anyInt());
|
||||
when(resources.getInteger(
|
||||
com.android.internal.R.integer.config_networkAvoidBadWifi))
|
||||
.thenReturn(1);
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user