Merge "Show confirmation dialog when user tries to skip fingerprint" into oc-mr1-dev
am: 0ed0319005
Change-Id: I37fdea03ab0193a6c42da584166c30ce6ee7b3c7
This commit is contained in:
@@ -834,6 +834,12 @@
|
|||||||
<string name="security_settings_fingerprint_enroll_introduction_cancel_setup">Skip</string>
|
<string name="security_settings_fingerprint_enroll_introduction_cancel_setup">Skip</string>
|
||||||
<!-- Button text to continue to the next screen from the introduction (this string variant is used while in setup wizard) [CHAR LIMIT=22] -->
|
<!-- Button text to continue to the next screen from the introduction (this string variant is used while in setup wizard) [CHAR LIMIT=22] -->
|
||||||
<string name="security_settings_fingerprint_enroll_introduction_continue_setup">Next</string>
|
<string name="security_settings_fingerprint_enroll_introduction_continue_setup">Next</string>
|
||||||
|
<!-- Title of dialog shown when the user tries to skip setting up fingerprint after adding lock screen during initial setup. [CHAR LIMIT=30] -->
|
||||||
|
<string name="fingerprint_enroll_skip_after_adding_lock_title">Skip fingerprint setup?</string>
|
||||||
|
<!-- Body text of dialog shown when the user tries to skip setting up fingerprint after adding lock screen during initial setup [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="fingerprint_enroll_skip_after_adding_lock_text">You\u2019ve chosen to use your fingerprint as one way to unlock your phone. If you skip now, you\u2019ll need to set this up later. Setup takes only a minute or so.</string>
|
||||||
|
<!-- Title of dialog shown when the user tries to skip setting up a screen lock, warning them of potential consequences of not doing so [CHAR LIMIT=30]-->
|
||||||
|
<string name="lock_screen_intro_skip_title">Skip screen lock?</string>
|
||||||
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning them of potential consequences of not doing so, including loss of factory reset protection. (tablet) [CHAR LIMIT=NONE] -->
|
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning them of potential consequences of not doing so, including loss of factory reset protection. (tablet) [CHAR LIMIT=NONE] -->
|
||||||
<string name="lock_screen_intro_skip_dialog_text_frp" product="tablet">Device protection features won\u2019t be turned on. You won\u2019t be able to prevent others from using this tablet if it\u2019s lost, stolen or reset.</string>
|
<string name="lock_screen_intro_skip_dialog_text_frp" product="tablet">Device protection features won\u2019t be turned on. You won\u2019t be able to prevent others from using this tablet if it\u2019s lost, stolen or reset.</string>
|
||||||
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning them of potential consequences of not doing so, including loss of factory reset protection. (device) [CHAR LIMIT=NONE] -->
|
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning them of potential consequences of not doing so, including loss of factory reset protection. (device) [CHAR LIMIT=NONE] -->
|
||||||
|
@@ -139,14 +139,18 @@ public class FingerprintEnrollFindSensor extends FingerprintEnrollBase {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.skip_button:
|
case R.id.skip_button:
|
||||||
setResult(RESULT_SKIP);
|
onSkipButtonClick();
|
||||||
finish();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
super.onClick(v);
|
super.onClick(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void onSkipButtonClick() {
|
||||||
|
setResult(RESULT_SKIP);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
private void proceedToEnrolling(boolean cancelEnrollment) {
|
private void proceedToEnrolling(boolean cancelEnrollment) {
|
||||||
if (mSidecar != null) {
|
if (mSidecar != null) {
|
||||||
if (cancelEnrollment) {
|
if (cancelEnrollment) {
|
||||||
|
@@ -16,12 +16,21 @@
|
|||||||
|
|
||||||
package com.android.settings.fingerprint;
|
package com.android.settings.fingerprint;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.app.FragmentManager;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.android.internal.logging.nano.MetricsProto;
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SetupWizardUtils;
|
import com.android.settings.SetupWizardUtils;
|
||||||
|
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||||
|
|
||||||
public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSensor {
|
public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSensor {
|
||||||
@@ -42,8 +51,54 @@ public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSenso
|
|||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSkipButtonClick() {
|
||||||
|
new SkipFingerprintDialog().show(getFragmentManager());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsEvent.FINGERPRINT_FIND_SENSOR_SETUP;
|
return MetricsEvent.FINGERPRINT_FIND_SENSOR_SETUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class SkipFingerprintDialog extends InstrumentedDialogFragment
|
||||||
|
implements DialogInterface.OnClickListener {
|
||||||
|
private static final String TAG_SKIP_DIALOG = "skip_dialog";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return MetricsProto.MetricsEvent.DIALOG_FINGERPRINT_SKIP_SETUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
return onCreateDialogBuilder().create();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public AlertDialog.Builder onCreateDialogBuilder() {
|
||||||
|
return new AlertDialog.Builder(getContext())
|
||||||
|
.setTitle(R.string.fingerprint_enroll_skip_after_adding_lock_title)
|
||||||
|
.setPositiveButton(R.string.skip_anyway_button_label, this)
|
||||||
|
.setNegativeButton(R.string.go_back_button_label, this)
|
||||||
|
.setMessage(R.string.fingerprint_enroll_skip_after_adding_lock_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int button) {
|
||||||
|
switch (button) {
|
||||||
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity != null) {
|
||||||
|
activity.setResult(RESULT_SKIP);
|
||||||
|
activity.finish();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show(FragmentManager manager) {
|
||||||
|
show(manager, TAG_SKIP_DIALOG);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -61,6 +61,7 @@ public class SetupSkipDialog extends InstrumentedDialogFragment
|
|||||||
return new AlertDialog.Builder(getContext())
|
return new AlertDialog.Builder(getContext())
|
||||||
.setPositiveButton(R.string.skip_anyway_button_label, this)
|
.setPositiveButton(R.string.skip_anyway_button_label, this)
|
||||||
.setNegativeButton(R.string.go_back_button_label, this)
|
.setNegativeButton(R.string.go_back_button_label, this)
|
||||||
|
.setTitle(R.string.lock_screen_intro_skip_title)
|
||||||
.setMessage(args.getBoolean(ARG_FRP_SUPPORTED) ?
|
.setMessage(args.getBoolean(ARG_FRP_SUPPORTED) ?
|
||||||
R.string.lock_screen_intro_skip_dialog_text_frp :
|
R.string.lock_screen_intro_skip_dialog_text_frp :
|
||||||
R.string.lock_screen_intro_skip_dialog_text);
|
R.string.lock_screen_intro_skip_dialog_text);
|
||||||
|
@@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Google Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.fingerprint;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.robolectric.RuntimeEnvironment.application;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.TestConfig;
|
||||||
|
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||||
|
import com.android.settings.password.IFingerprintManager;
|
||||||
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
|
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowDynamicIndexableContentMonitor;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowEventLogWriter;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.Shadows;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
import org.robolectric.shadows.ShadowAlertDialog;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
@Config(
|
||||||
|
manifest = TestConfig.MANIFEST_PATH,
|
||||||
|
sdk = TestConfig.SDK_VERSION,
|
||||||
|
shadows = {
|
||||||
|
SettingsShadowResources.class,
|
||||||
|
SettingsShadowResources.SettingsShadowTheme.class,
|
||||||
|
ShadowDynamicIndexableContentMonitor.class,
|
||||||
|
ShadowEventLogWriter.class,
|
||||||
|
ShadowUtils.class
|
||||||
|
})
|
||||||
|
public class SetupFingerprintEnrollFindSensorTest {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private IFingerprintManager mFingerprintManager;
|
||||||
|
|
||||||
|
private SetupFingerprintEnrollFindSensor mActivity;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
ShadowUtils.setFingerprintManager(mFingerprintManager);
|
||||||
|
RuntimeEnvironment.getAppResourceLoader().getResourceIndex();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createActivity(Intent intent) {
|
||||||
|
mActivity = Robolectric.buildActivity(
|
||||||
|
SetupFingerprintEnrollFindSensor.class, intent)
|
||||||
|
.setup().get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Intent createIntent() {
|
||||||
|
return new Intent()
|
||||||
|
// Set the challenge token so the confirm screen will not be shown
|
||||||
|
.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, new byte[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowUtils.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void fingerprintEnroll_showsAlert_whenClickingSkip() {
|
||||||
|
createActivity(createIntent());
|
||||||
|
Button skipButton = mActivity.findViewById(R.id.skip_button);
|
||||||
|
skipButton.performClick();
|
||||||
|
AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
|
||||||
|
assertNotNull(alertDialog);
|
||||||
|
ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(alertDialog);
|
||||||
|
int titleRes = R.string.fingerprint_enroll_skip_after_adding_lock_title;
|
||||||
|
assertEquals(application.getString(titleRes), shadowAlertDialog.getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Google Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.password;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.robolectric.RuntimeEnvironment.application;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.TestConfig;
|
||||||
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
|
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowDynamicIndexableContentMonitor;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowEventLogWriter;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.Shadows;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
import org.robolectric.shadows.ShadowAlertDialog;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
@Config(
|
||||||
|
manifest = TestConfig.MANIFEST_PATH,
|
||||||
|
sdk = TestConfig.SDK_VERSION,
|
||||||
|
shadows = {
|
||||||
|
SettingsShadowResources.class,
|
||||||
|
SettingsShadowResources.SettingsShadowTheme.class,
|
||||||
|
ShadowDynamicIndexableContentMonitor.class,
|
||||||
|
ShadowEventLogWriter.class,
|
||||||
|
ShadowUtils.class
|
||||||
|
})
|
||||||
|
public class SetupSkipDialogTest {
|
||||||
|
|
||||||
|
private Activity mActivity;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mActivity = Robolectric.setupActivity(Activity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void frpMessages_areShownCorrectly_whenNotSupported() {
|
||||||
|
SetupSkipDialog setupSkipDialog = SetupSkipDialog.newInstance(false);
|
||||||
|
setupSkipDialog.show(mActivity.getFragmentManager());
|
||||||
|
|
||||||
|
AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
|
||||||
|
assertNotNull(alertDialog);
|
||||||
|
ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(alertDialog);
|
||||||
|
assertEquals(application.getString(R.string.lock_screen_intro_skip_title),
|
||||||
|
shadowAlertDialog.getTitle());
|
||||||
|
assertEquals(application.getString(R.string.lock_screen_intro_skip_dialog_text),
|
||||||
|
shadowAlertDialog.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void frpMessages_areShownCorrectly_whenSupported() {
|
||||||
|
SetupSkipDialog setupSkipDialog = SetupSkipDialog.newInstance(true);
|
||||||
|
setupSkipDialog.show(mActivity.getFragmentManager());
|
||||||
|
|
||||||
|
AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
|
||||||
|
assertNotNull(alertDialog);
|
||||||
|
ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(alertDialog);
|
||||||
|
assertEquals(application.getString(R.string.lock_screen_intro_skip_title),
|
||||||
|
shadowAlertDialog.getTitle());
|
||||||
|
assertEquals(application.getString(R.string.lock_screen_intro_skip_dialog_text_frp),
|
||||||
|
shadowAlertDialog.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user