Skip to content

Commit

Permalink
RESTRICT AUTOMERGE: Catch exceptions from setLockCredential()
Browse files Browse the repository at this point in the history
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:e0b5a793a19198370d479401101cea97c2f1d835)
Merged-In: I48b9119c19fb6378b1f88d36433ee4f4c8501d76
Change-Id: I48b9119c19fb6378b1f88d36433ee4f4c8501d76
  • Loading branch information
ebiggers authored and thestinger committed Oct 3, 2023
1 parent 87a0644 commit aaba724
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/com/android/settings/password/ChooseLockPassword.java
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,13 @@ public void start(LockPatternUtils utils, boolean required,

@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();
}
Expand Down
9 changes: 7 additions & 2 deletions src/com/android/settings/password/ChooseLockPattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,13 @@ public void start(LockPatternUtils utils, boolean credentialRequired,
@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();
}
Expand Down

0 comments on commit aaba724

Please sign in to comment.