Loading res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1584,6 +1584,9 @@ <!-- Label for ChoosePassword/PIN Clear button that clears all text entered by the user so far. --> <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 --> <string name="lockpattern_tutorial_cancel_label">Cancel</string> Loading src/com/android/settings/password/ChooseLockPassword.java +6 −8 Original line number Diff line number Diff line Loading @@ -45,10 +45,10 @@ import android.text.Spannable; import android.text.TextUtils; import android.text.TextWatcher; import android.util.Log; import android.util.Pair; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; import android.widget.LinearLayout; Loading Loading @@ -1100,12 +1100,11 @@ public class ChooseLockPassword extends SettingsActivity { } @Override protected Intent saveAndVerifyInBackground() { protected Pair<Boolean, Intent> saveAndVerifyInBackground() { final boolean success = mUtils.saveLockPassword( mChosenPassword, mCurrentPassword, mRequestedQuality, mUserId); Intent result = null; mUtils.saveLockPassword(mChosenPassword, mCurrentPassword, mRequestedQuality, mUserId); if (mHasChallenge) { if (success && mHasChallenge) { byte[] token; try { token = mUtils.verifyPassword(mChosenPassword, mChallenge, mUserId); Loading @@ -1120,8 +1119,7 @@ public class ChooseLockPassword extends SettingsActivity { result = new Intent(); result.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token); } return result; return Pair.create(success, result); } } } src/com/android/settings/password/ChooseLockPattern.java +6 −7 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.res.ColorStateList; import android.content.res.Resources.Theme; import android.os.Bundle; import android.util.Log; import android.util.Pair; import android.util.TypedValue; import android.view.KeyEvent; import android.view.LayoutInflater; Loading Loading @@ -854,12 +855,11 @@ public class ChooseLockPattern extends SettingsActivity { } @Override protected Intent saveAndVerifyInBackground() { Intent result = null; protected Pair<Boolean, Intent> saveAndVerifyInBackground() { final int userId = mUserId; mUtils.saveLockPattern(mChosenPattern, mCurrentPattern, userId); if (mHasChallenge) { final boolean success = mUtils.saveLockPattern(mChosenPattern, mCurrentPattern, userId); Intent result = null; if (success && mHasChallenge) { byte[] token; try { token = mUtils.verifyPattern(mChosenPattern, mChallenge, userId); Loading @@ -874,8 +874,7 @@ public class ChooseLockPattern extends SettingsActivity { result = new Intent(); result.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token); } return result; return Pair.create(success, result); } @Override Loading src/com/android/settings/password/SaveChosenLockWorkerBase.java +17 −8 Original line number Diff line number Diff line Loading @@ -21,10 +21,13 @@ import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.os.UserManager; import android.util.Pair; import android.widget.Toast; import androidx.fragment.app.Fragment; import com.android.internal.widget.LockPatternUtils; import com.android.settings.R; /** * An invisible retained worker fragment to track the AsyncWork that saves (and optionally Loading Loading @@ -84,7 +87,7 @@ abstract class SaveChosenLockWorkerBase extends Fragment { protected void start() { if (mBlocking) { finish(saveAndVerifyInBackground()); finish(saveAndVerifyInBackground().second); } else { new Task().execute(); } Loading @@ -92,9 +95,10 @@ abstract class SaveChosenLockWorkerBase extends Fragment { /** * 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) { mFinished = true; Loading @@ -108,19 +112,24 @@ abstract class SaveChosenLockWorkerBase extends Fragment { mBlocking = blocking; } private class Task extends AsyncTask<Void, Void, Intent> { private class Task extends AsyncTask<Void, Void, Pair<Boolean, Intent>> { @Override protected Intent doInBackground(Void... params){ protected Pair<Boolean, Intent> doInBackground(Void... params){ return saveAndVerifyInBackground(); } @Override protected void onPostExecute(Intent resultData) { finish(resultData); protected void onPostExecute(Pair<Boolean, Intent> resultData) { if (!resultData.first) { Toast.makeText(getContext(), R.string.lockpassword_credential_changed, Toast.LENGTH_LONG).show(); } finish(resultData.second); } } interface Listener { public void onChosenLockSaveFinished(boolean wasSecureBefore, Intent resultData); void onChosenLockSaveFinished(boolean wasSecureBefore, Intent resultData); } } Loading
res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1584,6 +1584,9 @@ <!-- Label for ChoosePassword/PIN Clear button that clears all text entered by the user so far. --> <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 --> <string name="lockpattern_tutorial_cancel_label">Cancel</string> Loading
src/com/android/settings/password/ChooseLockPassword.java +6 −8 Original line number Diff line number Diff line Loading @@ -45,10 +45,10 @@ import android.text.Spannable; import android.text.TextUtils; import android.text.TextWatcher; import android.util.Log; import android.util.Pair; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; import android.widget.LinearLayout; Loading Loading @@ -1100,12 +1100,11 @@ public class ChooseLockPassword extends SettingsActivity { } @Override protected Intent saveAndVerifyInBackground() { protected Pair<Boolean, Intent> saveAndVerifyInBackground() { final boolean success = mUtils.saveLockPassword( mChosenPassword, mCurrentPassword, mRequestedQuality, mUserId); Intent result = null; mUtils.saveLockPassword(mChosenPassword, mCurrentPassword, mRequestedQuality, mUserId); if (mHasChallenge) { if (success && mHasChallenge) { byte[] token; try { token = mUtils.verifyPassword(mChosenPassword, mChallenge, mUserId); Loading @@ -1120,8 +1119,7 @@ public class ChooseLockPassword extends SettingsActivity { result = new Intent(); result.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token); } return result; return Pair.create(success, result); } } }
src/com/android/settings/password/ChooseLockPattern.java +6 −7 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.res.ColorStateList; import android.content.res.Resources.Theme; import android.os.Bundle; import android.util.Log; import android.util.Pair; import android.util.TypedValue; import android.view.KeyEvent; import android.view.LayoutInflater; Loading Loading @@ -854,12 +855,11 @@ public class ChooseLockPattern extends SettingsActivity { } @Override protected Intent saveAndVerifyInBackground() { Intent result = null; protected Pair<Boolean, Intent> saveAndVerifyInBackground() { final int userId = mUserId; mUtils.saveLockPattern(mChosenPattern, mCurrentPattern, userId); if (mHasChallenge) { final boolean success = mUtils.saveLockPattern(mChosenPattern, mCurrentPattern, userId); Intent result = null; if (success && mHasChallenge) { byte[] token; try { token = mUtils.verifyPattern(mChosenPattern, mChallenge, userId); Loading @@ -874,8 +874,7 @@ public class ChooseLockPattern extends SettingsActivity { result = new Intent(); result.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token); } return result; return Pair.create(success, result); } @Override Loading
src/com/android/settings/password/SaveChosenLockWorkerBase.java +17 −8 Original line number Diff line number Diff line Loading @@ -21,10 +21,13 @@ import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.os.UserManager; import android.util.Pair; import android.widget.Toast; import androidx.fragment.app.Fragment; import com.android.internal.widget.LockPatternUtils; import com.android.settings.R; /** * An invisible retained worker fragment to track the AsyncWork that saves (and optionally Loading Loading @@ -84,7 +87,7 @@ abstract class SaveChosenLockWorkerBase extends Fragment { protected void start() { if (mBlocking) { finish(saveAndVerifyInBackground()); finish(saveAndVerifyInBackground().second); } else { new Task().execute(); } Loading @@ -92,9 +95,10 @@ abstract class SaveChosenLockWorkerBase extends Fragment { /** * 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) { mFinished = true; Loading @@ -108,19 +112,24 @@ abstract class SaveChosenLockWorkerBase extends Fragment { mBlocking = blocking; } private class Task extends AsyncTask<Void, Void, Intent> { private class Task extends AsyncTask<Void, Void, Pair<Boolean, Intent>> { @Override protected Intent doInBackground(Void... params){ protected Pair<Boolean, Intent> doInBackground(Void... params){ return saveAndVerifyInBackground(); } @Override protected void onPostExecute(Intent resultData) { finish(resultData); protected void onPostExecute(Pair<Boolean, Intent> resultData) { if (!resultData.first) { Toast.makeText(getContext(), R.string.lockpassword_credential_changed, Toast.LENGTH_LONG).show(); } finish(resultData.second); } } interface Listener { public void onChosenLockSaveFinished(boolean wasSecureBefore, Intent resultData); void onChosenLockSaveFinished(boolean wasSecureBefore, Intent resultData); } }