From 50f93771bca50d3ecb088ff5f57813167e3c8793 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 27 Jul 2023 21:45:05 +0000 Subject: [PATCH] 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(). Change-Id: I48b9119c19fb6378b1f88d36433ee4f4c8501d76 (cherry picked from commit 05f1eff1c9c3f82797f1a0f92ff7665b9f463488) Merged-In: I48b9119c19fb6378b1f88d36433ee4f4c8501d76 --- src/com/android/settings/password/SaveAndFinishWorker.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/password/SaveAndFinishWorker.java b/src/com/android/settings/password/SaveAndFinishWorker.java index df679e5f6cd..40054b77645 100644 --- a/src/com/android/settings/password/SaveAndFinishWorker.java +++ b/src/com/android/settings/password/SaveAndFinishWorker.java @@ -107,7 +107,12 @@ public class SaveAndFinishWorker extends Fragment { @VisibleForTesting Pair saveAndVerifyInBackground() { final int userId = mUserId; - if (!mUtils.setLockCredential(mChosenCredential, mCurrentCredential, userId)) { + try { + if (!mUtils.setLockCredential(mChosenCredential, mCurrentCredential, userId)) { + return Pair.create(false, null); + } + } catch (RuntimeException e) { + Log.e(TAG, "Failed to set lockscreen credential", e); return Pair.create(false, null); }