summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2023-07-27 21:45:05 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-08-10 17:12:27 +0000
commitc3a629f28c5f48525be9d7026322383fdd00f46c (patch)
treed8cb9e012a53633088800c424a53cb9b37b87a9f
parent1eff772d805578f2c7d3947d0ea9e8b2c547bacd (diff)
downloadSettings-c3a629f28c5f48525be9d7026322383fdd00f46c.tar.gz
RESTRICT AUTOMERGE: Catch exceptions from setLockCredential()
When LockPatternUtils#setLockCredential() fails, it can either return false or throw an exception. Catch the exception and treat it the same way as a false return value, to prevent crashing com.android.settings. Bug: 253043065 Test: Tried setting lockscreen credential while in secure FRP mode using smartlock setup activity launched by intent via adb. Verified that com.android.settings no longer crashes due to the exception from LockPatternUtils#setLockCredential(). (cherry picked from commit 05f1eff1c9c3f82797f1a0f92ff7665b9f463488) (moved change into ChooseLockPassword.java and ChooseLockPattern.java, which are merged into SaveAndFinishWorker.java on udc-qpr-dev and main) (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:50cb0a35c92e7baa27ed6335079d2948a56d43e0) Merged-In: I48b9119c19fb6378b1f88d36433ee4f4c8501d76 Change-Id: I48b9119c19fb6378b1f88d36433ee4f4c8501d76
-rw-r--r--src/com/android/settings/password/ChooseLockPassword.java9
-rw-r--r--src/com/android/settings/password/ChooseLockPattern.java9
2 files changed, 14 insertions, 4 deletions
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index 18fc611e14c..ba886470d2c 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -1020,8 +1020,13 @@ public class ChooseLockPassword extends SettingsActivity {
@Override
protected Pair<Boolean, Intent> saveAndVerifyInBackground() {
- final boolean success = mUtils.setLockCredential(
- mChosenPassword, mCurrentCredential, mUserId);
+ boolean success;
+ try {
+ success = mUtils.setLockCredential(mChosenPassword, mCurrentCredential, mUserId);
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Failed to set lockscreen credential", e);
+ success = false;
+ }
if (success) {
unifyProfileCredentialIfRequested();
}
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index e9ca9c40a5e..945c5ee6daf 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -906,8 +906,13 @@ public class ChooseLockPattern extends SettingsActivity {
@Override
protected Pair<Boolean, Intent> saveAndVerifyInBackground() {
final int userId = mUserId;
- final boolean success = mUtils.setLockCredential(mChosenPattern, mCurrentCredential,
- userId);
+ boolean success;
+ try {
+ success = mUtils.setLockCredential(mChosenPattern, mCurrentCredential, userId);
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Failed to set lockscreen credential", e);
+ success = false;
+ }
if (success) {
unifyProfileCredentialIfRequested();
}