Skip to content

Commit 05f1eff

Browse files
committed
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
1 parent 4b88265 commit 05f1eff

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/com/android/settings/password/SaveAndFinishWorker.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ public void start(LockPatternUtils utils, LockscreenCredential chosenCredential,
107107
@VisibleForTesting
108108
Pair<Boolean, Intent> saveAndVerifyInBackground() {
109109
final int userId = mUserId;
110-
if (!mUtils.setLockCredential(mChosenCredential, mCurrentCredential, userId)) {
110+
try {
111+
if (!mUtils.setLockCredential(mChosenCredential, mCurrentCredential, userId)) {
112+
return Pair.create(false, null);
113+
}
114+
} catch (RuntimeException e) {
115+
Log.e(TAG, "Failed to set lockscreen credential", e);
111116
return Pair.create(false, null);
112117
}
113118

0 commit comments

Comments
 (0)