Fail the screen lock flow if the old password has already changed.
Test: atest RunSettingsRoboTests Bug: 120039091 Change-Id: Ib0860ccbc1ba84a2ac8dafcf3cf33f6ddf160e4c
This commit is contained in:
@@ -1584,6 +1584,9 @@
|
|||||||
<!-- Label for ChoosePassword/PIN Clear button that clears all text entered by the user so far. -->
|
<!-- Label for ChoosePassword/PIN Clear button that clears all text entered by the user so far. -->
|
||||||
<string name="lockpassword_clear_label">Clear</string>
|
<string name="lockpassword_clear_label">Clear</string>
|
||||||
|
|
||||||
|
<!-- Toast for a failed password change attempt when the old credential has been changed. [CHAR LIMIT=120]-->
|
||||||
|
<string name="lockpassword_credential_changed">Screen lock was already changed. Try again with the new screen lock.</string>
|
||||||
|
|
||||||
<!-- Label for LockPatternTutorial Cancel button -->
|
<!-- Label for LockPatternTutorial Cancel button -->
|
||||||
<string name="lockpattern_tutorial_cancel_label">Cancel</string>
|
<string name="lockpattern_tutorial_cancel_label">Cancel</string>
|
||||||
|
|
||||||
|
@@ -45,10 +45,10 @@ import android.text.Spannable;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.Pair;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@@ -1100,12 +1100,11 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Intent saveAndVerifyInBackground() {
|
protected Pair<Boolean, Intent> saveAndVerifyInBackground() {
|
||||||
|
final boolean success = mUtils.saveLockPassword(
|
||||||
|
mChosenPassword, mCurrentPassword, mRequestedQuality, mUserId);
|
||||||
Intent result = null;
|
Intent result = null;
|
||||||
mUtils.saveLockPassword(mChosenPassword, mCurrentPassword, mRequestedQuality,
|
if (success && mHasChallenge) {
|
||||||
mUserId);
|
|
||||||
|
|
||||||
if (mHasChallenge) {
|
|
||||||
byte[] token;
|
byte[] token;
|
||||||
try {
|
try {
|
||||||
token = mUtils.verifyPassword(mChosenPassword, mChallenge, mUserId);
|
token = mUtils.verifyPassword(mChosenPassword, mChallenge, mUserId);
|
||||||
@@ -1120,8 +1119,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
result = new Intent();
|
result = new Intent();
|
||||||
result.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
|
result.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
|
||||||
}
|
}
|
||||||
|
return Pair.create(success, result);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ import android.content.res.ColorStateList;
|
|||||||
import android.content.res.Resources.Theme;
|
import android.content.res.Resources.Theme;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.Pair;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -854,12 +855,11 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Intent saveAndVerifyInBackground() {
|
protected Pair<Boolean, Intent> saveAndVerifyInBackground() {
|
||||||
Intent result = null;
|
|
||||||
final int userId = mUserId;
|
final int userId = mUserId;
|
||||||
mUtils.saveLockPattern(mChosenPattern, mCurrentPattern, userId);
|
final boolean success = mUtils.saveLockPattern(mChosenPattern, mCurrentPattern, userId);
|
||||||
|
Intent result = null;
|
||||||
if (mHasChallenge) {
|
if (success && mHasChallenge) {
|
||||||
byte[] token;
|
byte[] token;
|
||||||
try {
|
try {
|
||||||
token = mUtils.verifyPattern(mChosenPattern, mChallenge, userId);
|
token = mUtils.verifyPattern(mChosenPattern, mChallenge, userId);
|
||||||
@@ -874,8 +874,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
result = new Intent();
|
result = new Intent();
|
||||||
result.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
|
result.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
|
||||||
}
|
}
|
||||||
|
return Pair.create(success, result);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -21,10 +21,13 @@ import android.content.Intent;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.util.Pair;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An invisible retained worker fragment to track the AsyncWork that saves (and optionally
|
* An invisible retained worker fragment to track the AsyncWork that saves (and optionally
|
||||||
@@ -84,7 +87,7 @@ abstract class SaveChosenLockWorkerBase extends Fragment {
|
|||||||
|
|
||||||
protected void start() {
|
protected void start() {
|
||||||
if (mBlocking) {
|
if (mBlocking) {
|
||||||
finish(saveAndVerifyInBackground());
|
finish(saveAndVerifyInBackground().second);
|
||||||
} else {
|
} else {
|
||||||
new Task().execute();
|
new Task().execute();
|
||||||
}
|
}
|
||||||
@@ -92,9 +95,10 @@ abstract class SaveChosenLockWorkerBase extends Fragment {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the save and verify work in background.
|
* Executes the save and verify work in background.
|
||||||
* @return Intent with challenge token or null.
|
* @return pair where the first is a boolean confirming whether the change was successful or not
|
||||||
|
* and second is the Intent which has the challenge token or is null.
|
||||||
*/
|
*/
|
||||||
protected abstract Intent saveAndVerifyInBackground();
|
protected abstract Pair<Boolean, Intent> saveAndVerifyInBackground();
|
||||||
|
|
||||||
protected void finish(Intent resultData) {
|
protected void finish(Intent resultData) {
|
||||||
mFinished = true;
|
mFinished = true;
|
||||||
@@ -108,19 +112,24 @@ abstract class SaveChosenLockWorkerBase extends Fragment {
|
|||||||
mBlocking = blocking;
|
mBlocking = blocking;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Task extends AsyncTask<Void, Void, Intent> {
|
private class Task extends AsyncTask<Void, Void, Pair<Boolean, Intent>> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Intent doInBackground(Void... params){
|
protected Pair<Boolean, Intent> doInBackground(Void... params){
|
||||||
return saveAndVerifyInBackground();
|
return saveAndVerifyInBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Intent resultData) {
|
protected void onPostExecute(Pair<Boolean, Intent> resultData) {
|
||||||
finish(resultData);
|
if (!resultData.first) {
|
||||||
|
Toast.makeText(getContext(), R.string.lockpassword_credential_changed,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
finish(resultData.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Listener {
|
interface Listener {
|
||||||
public void onChosenLockSaveFinished(boolean wasSecureBefore, Intent resultData);
|
void onChosenLockSaveFinished(boolean wasSecureBefore, Intent resultData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user