Skip to content

Commit c4f1134

Browse files
ebiggersMeghthedev
authored andcommitted
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 05f1eff) (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:5f07aba15008e2681d5a10435dc5e1485863f21f) Merged-In: I48b9119c19fb6378b1f88d36433ee4f4c8501d76 Change-Id: I48b9119c19fb6378b1f88d36433ee4f4c8501d76
1 parent 9a4aced commit c4f1134

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,13 @@ public void start(LockPatternUtils utils, boolean required,
960960

961961
@Override
962962
protected Pair<Boolean, Intent> saveAndVerifyInBackground() {
963-
final boolean success = mUtils.setLockCredential(
964-
mChosenPassword, mCurrentCredential, mUserId);
963+
boolean success;
964+
try {
965+
success = mUtils.setLockCredential(mChosenPassword, mCurrentCredential, mUserId);
966+
} catch (RuntimeException e) {
967+
Log.e(TAG, "Failed to set lockscreen credential", e);
968+
success = false;
969+
}
965970
if (success) {
966971
unifyProfileCredentialIfRequested();
967972
}

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -920,9 +920,13 @@ public void start(LockPatternUtils utils, boolean credentialRequired, boolean ha
920920
@Override
921921
protected Pair<Boolean, Intent> saveAndVerifyInBackground() {
922922
final int userId = mUserId;
923-
mUtils.setLockPatternSize(mPatternSize, userId);
924-
final boolean success = mUtils.setLockCredential(mChosenPattern, mCurrentCredential,
925-
userId);
923+
boolean success;
924+
try {
925+
success = mUtils.setLockCredential(mChosenPattern, mCurrentCredential, userId);
926+
} catch (RuntimeException e) {
927+
Log.e(TAG, "Failed to set lockscreen credential", e);
928+
success = false;
929+
}
926930
if (success) {
927931
unifyProfileCredentialIfRequested();
928932
}

0 commit comments

Comments
 (0)