Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Race Condition on Passcode Manager #12125

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,36 +61,38 @@ class PassCodeManager(private val preferences: AppPreferences, private val clock
}

fun onActivityResumed(activity: Activity): Boolean {
var askedForPin = false
val timestamp = preferences.lockTimestamp
setSecureFlag(activity)

if (!isExemptActivity(activity)) {
val passcodeRequested = passCodeShouldBeRequested(timestamp)
val credentialsRequested = deviceCredentialsShouldBeRequested(timestamp, activity)
val shouldHideView = passcodeRequested || credentialsRequested
toggleActivityVisibility(shouldHideView, activity)
askedForPin = shouldHideView

if (passcodeRequested) {
requestPasscode(activity)
} else if (credentialsRequested) {
requestCredentials(activity)
synchronized(this) {
var askedForPin = false
val timestamp = preferences.lockTimestamp
setSecureFlag(activity)

if (!isExemptActivity(activity)) {
val passcodeRequested = passCodeShouldBeRequested(timestamp)
val credentialsRequested = deviceCredentialsShouldBeRequested(timestamp, activity)
val shouldHideView = passcodeRequested || credentialsRequested
toggleActivityVisibility(shouldHideView, activity)
askedForPin = shouldHideView

if (passcodeRequested) {
requestPasscode(activity)
} else if (credentialsRequested) {
requestCredentials(activity)
}
if (askedForPin) {
preferences.lockTimestamp = 0
}
}
if (askedForPin) {
preferences.lockTimestamp = 0

if (!askedForPin && preferences.lockTimestamp != 0L) {
updateLockTimestamp()
}
}

if (!askedForPin && preferences.lockTimestamp != 0L) {
updateLockTimestamp()
}
if (!isExemptActivity(activity)) {
addVisibleActivity(activity) // keep it AFTER passCodeShouldBeRequested was checked
}

if (!isExemptActivity(activity)) {
addVisibleActivity(activity) // keep it AFTER passCodeShouldBeRequested was checked
return askedForPin
}

return askedForPin
}

/**
Expand Down
Loading