Merge "Don't dismiss the keyguard from the binder thread" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2aea66b332
@@ -15,12 +15,17 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.systemui.screenshot
|
package com.android.systemui.screenshot
|
||||||
|
|
||||||
import android.app.Service
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import androidx.lifecycle.LifecycleService
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import com.android.systemui.dagger.qualifiers.Main
|
||||||
import com.android.systemui.shade.ShadeExpansionStateManager
|
import com.android.systemui.shade.ShadeExpansionStateManager
|
||||||
import com.android.systemui.statusbar.phone.CentralSurfaces
|
import com.android.systemui.statusbar.phone.CentralSurfaces
|
||||||
|
import kotlinx.coroutines.CoroutineDispatcher
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import java.util.Optional
|
import java.util.Optional
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@@ -30,7 +35,8 @@ import javax.inject.Inject
|
|||||||
internal class ScreenshotProxyService @Inject constructor(
|
internal class ScreenshotProxyService @Inject constructor(
|
||||||
private val mExpansionMgr: ShadeExpansionStateManager,
|
private val mExpansionMgr: ShadeExpansionStateManager,
|
||||||
private val mCentralSurfacesOptional: Optional<CentralSurfaces>,
|
private val mCentralSurfacesOptional: Optional<CentralSurfaces>,
|
||||||
) : Service() {
|
@Main private val mMainDispatcher: CoroutineDispatcher,
|
||||||
|
) : LifecycleService() {
|
||||||
|
|
||||||
private val mBinder: IBinder = object : IScreenshotProxy.Stub() {
|
private val mBinder: IBinder = object : IScreenshotProxy.Stub() {
|
||||||
/**
|
/**
|
||||||
@@ -43,20 +49,28 @@ internal class ScreenshotProxyService @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun dismissKeyguard(callback: IOnDoneCallback) {
|
override fun dismissKeyguard(callback: IOnDoneCallback) {
|
||||||
if (mCentralSurfacesOptional.isPresent) {
|
lifecycleScope.launch {
|
||||||
mCentralSurfacesOptional.get().executeRunnableDismissingKeyguard(
|
executeAfterDismissing(callback)
|
||||||
Runnable {
|
|
||||||
callback.onDone(true)
|
|
||||||
}, null,
|
|
||||||
true /* dismissShade */, true /* afterKeyguardGone */,
|
|
||||||
true /* deferred */
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
callback.onDone(false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun executeAfterDismissing(callback: IOnDoneCallback) =
|
||||||
|
withContext(mMainDispatcher) {
|
||||||
|
mCentralSurfacesOptional.ifPresentOrElse(
|
||||||
|
{
|
||||||
|
it.executeRunnableDismissingKeyguard(
|
||||||
|
Runnable {
|
||||||
|
callback.onDone(true)
|
||||||
|
}, null,
|
||||||
|
true /* dismissShade */, true /* afterKeyguardGone */,
|
||||||
|
true /* deferred */
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{ callback.onDone(false) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBind(intent: Intent): IBinder? {
|
override fun onBind(intent: Intent): IBinder? {
|
||||||
Log.d(TAG, "onBind: $intent")
|
Log.d(TAG, "onBind: $intent")
|
||||||
return mBinder
|
return mBinder
|
||||||
|
|||||||
Reference in New Issue
Block a user