Skip to content
Merged
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 @@ -94,9 +94,8 @@ class ScreenLockActivity : BaseActionBarActivity() {
}
})

// Start and bind to the KeyCachingService instance.
// Bind now; the service is started from onResume.
val bindIntent = Intent(this, KeyCachingService::class.java)
startService(bindIntent)
bindService(bindIntent, object : ServiceConnection {
override fun onServiceConnected(name: ComponentName?, service: IBinder) {
keyCachingService = (service as KeySetBinder).service
Expand Down Expand Up @@ -196,6 +195,13 @@ class ScreenLockActivity : BaseActionBarActivity() {

override fun onResume() {
super.onResume()

// KeyCachingService must be started, not only bound, or it is destroyed (clearing the key)
// once nothing is bound. Android refuses startService while the app is in the background,
// and this activity can be created there, so start it once we're visible.
// handleAuthenticated only needs the bound service, so it may run before this.
startService(Intent(this, KeyCachingService::class.java))

setLockTypeVisibility()
if (isScreenLockEnabled(this) && !authenticated && !failure) { resumeScreenLock() }
failure = false
Expand Down
Loading