Update Security & location preference summary depending on biometrics
Fixes: 110960063 Test: manual Test: make -j56 SettingsRoboTests ROBOTEST_FILTER=SecuritySettingsTest Change-Id: Ia9186af37c84f4ff0391d1b72043948934ed997b
This commit is contained in:
@@ -842,6 +842,8 @@
|
||||
<!-- In the security screen, the header title for security statuses -->
|
||||
<string name="security_status_title">Security status</string>
|
||||
<!-- Summary for Security settings, explaining a few important settings under it [CHAR LIMIT=NONE] -->
|
||||
<string name="security_dashboard_summary_face">Screen lock, face unlock</string>
|
||||
<!-- Summary for Security settings, explaining a few important settings under it [CHAR LIMIT=NONE] -->
|
||||
<string name="security_dashboard_summary">Screen lock, fingerprint</string>
|
||||
<!-- Summary for Security settings when fingerprint is not supported [CHAR LIMIT=NONE]-->
|
||||
<string name="security_dashboard_summary_no_fingerprint">Screen lock</string>
|
||||
|
@@ -21,6 +21,7 @@ import static com.android.settings.security.EncryptionStatusPreferenceController
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
@@ -181,7 +182,12 @@ public class SecuritySettings extends DashboardFragment {
|
||||
if (listening) {
|
||||
final FingerprintManager fpm =
|
||||
Utils.getFingerprintManagerOrNull(mContext);
|
||||
if (fpm != null && fpm.isHardwareDetected()) {
|
||||
final FaceManager faceManager =
|
||||
Utils.getFaceManagerOrNull(mContext);
|
||||
if (faceManager != null && faceManager.isHardwareDetected()) {
|
||||
mSummaryLoader.setSummary(this,
|
||||
mContext.getString(R.string.security_dashboard_summary_face));
|
||||
} else if (fpm != null && fpm.isHardwareDetected()) {
|
||||
mSummaryLoader.setSummary(this,
|
||||
mContext.getString(R.string.security_dashboard_summary));
|
||||
} else {
|
||||
|
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -44,6 +45,8 @@ public class SecuritySettingsTest {
|
||||
private SummaryLoader mSummaryLoader;
|
||||
@Mock
|
||||
private FingerprintManager mFingerprintManager;
|
||||
@Mock
|
||||
private FaceManager mFaceManager;
|
||||
private SecuritySettings.SummaryProvider mSummaryProvider;
|
||||
|
||||
@Before
|
||||
@@ -51,7 +54,8 @@ public class SecuritySettingsTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mContext.getSystemService(Context.FINGERPRINT_SERVICE))
|
||||
.thenReturn(mFingerprintManager);
|
||||
|
||||
when(mContext.getSystemService(Context.FACE_SERVICE))
|
||||
.thenReturn(mFaceManager);
|
||||
mSummaryProvider = new SecuritySettings.SummaryProvider(mContext, mSummaryLoader);
|
||||
}
|
||||
|
||||
@@ -62,8 +66,21 @@ public class SecuritySettingsTest {
|
||||
verifyNoMoreInteractions(mSummaryLoader);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSummaryProvider_hasFace_hasStaticSummary() {
|
||||
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE))
|
||||
.thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
|
||||
mSummaryProvider.setListening(true);
|
||||
|
||||
verify(mContext).getString(R.string.security_dashboard_summary_face);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSummaryProvider_hasFingerPrint_hasStaticSummary() {
|
||||
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE))
|
||||
.thenReturn(false);
|
||||
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
|
||||
.thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -74,9 +91,11 @@ public class SecuritySettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSummaryProvider_noFpFeature_shouldSetSummaryWithNoFingerprint() {
|
||||
public void testSummaryProvider_noFpFeature_shouldSetSummaryWithNoBiometrics() {
|
||||
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
|
||||
.thenReturn(false);
|
||||
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE))
|
||||
.thenReturn(false);
|
||||
|
||||
mSummaryProvider.setListening(true);
|
||||
|
||||
@@ -84,7 +103,9 @@ public class SecuritySettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSummaryProvider_noFpHardware_shouldSetSummaryWithNoFingerprint() {
|
||||
public void testSummaryProvider_noFpHardware_shouldSetSummaryWithNoBiometrics() {
|
||||
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE))
|
||||
.thenReturn(false);
|
||||
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
|
||||
.thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
@@ -93,4 +114,29 @@ public class SecuritySettingsTest {
|
||||
|
||||
verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSummaryProvider_noFaceFeature_shouldSetSummaryWithNoBiometrics() {
|
||||
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
|
||||
.thenReturn(false);
|
||||
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE))
|
||||
.thenReturn(false);
|
||||
|
||||
mSummaryProvider.setListening(true);
|
||||
|
||||
verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSummaryProvider_noFaceHardware_shouldSetSummaryWithNoBiometrics() {
|
||||
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE))
|
||||
.thenReturn(true);
|
||||
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
|
||||
.thenReturn(false);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(false);
|
||||
|
||||
mSummaryProvider.setListening(true);
|
||||
|
||||
verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user