Merge "Controls Activity - Always close when keyguard becomes active" into sc-qpr1-dev am: 6ea42dcf9f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15839048 Change-Id: I34e27163ec47ca182ed4a16673f0923bd2c13feb
This commit is contained in:
@@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
package com.android.systemui.controls.ui
|
package com.android.systemui.controls.ui
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -23,18 +27,25 @@ import android.view.WindowInsets
|
|||||||
import android.view.WindowInsets.Type
|
import android.view.WindowInsets.Type
|
||||||
|
|
||||||
import com.android.systemui.R
|
import com.android.systemui.R
|
||||||
|
import com.android.systemui.broadcast.BroadcastDispatcher
|
||||||
import com.android.systemui.controls.management.ControlsAnimations
|
import com.android.systemui.controls.management.ControlsAnimations
|
||||||
import com.android.systemui.util.LifecycleActivity
|
import com.android.systemui.util.LifecycleActivity
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays Device Controls inside an activity
|
* Displays Device Controls inside an activity. This activity is available to be displayed over the
|
||||||
|
* lockscreen if the user has allowed it via
|
||||||
|
* [android.provider.Settings.Secure.LOCKSCREEN_SHOW_CONTROLS]. This activity will be
|
||||||
|
* destroyed on SCREEN_OFF events, due to issues with occluded activities over lockscreen as well as
|
||||||
|
* user expectations for the activity to not continue running.
|
||||||
*/
|
*/
|
||||||
class ControlsActivity @Inject constructor(
|
class ControlsActivity @Inject constructor(
|
||||||
private val uiController: ControlsUiController
|
private val uiController: ControlsUiController,
|
||||||
|
private val broadcastDispatcher: BroadcastDispatcher
|
||||||
) : LifecycleActivity() {
|
) : LifecycleActivity() {
|
||||||
|
|
||||||
private lateinit var parent: ViewGroup
|
private lateinit var parent: ViewGroup
|
||||||
|
private lateinit var broadcastReceiver: BroadcastReceiver
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -62,6 +73,8 @@ class ControlsActivity @Inject constructor(
|
|||||||
WindowInsets.CONSUMED
|
WindowInsets.CONSUMED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initBroadcastReceiver()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
@@ -83,4 +96,25 @@ class ControlsActivity @Inject constructor(
|
|||||||
|
|
||||||
uiController.hide()
|
uiController.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
|
||||||
|
broadcastDispatcher.unregisterReceiver(broadcastReceiver)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initBroadcastReceiver() {
|
||||||
|
broadcastReceiver = object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
val action = intent.getAction()
|
||||||
|
if (Intent.ACTION_SCREEN_OFF.equals(action)) {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val filter = IntentFilter()
|
||||||
|
filter.addAction(Intent.ACTION_SCREEN_OFF)
|
||||||
|
broadcastDispatcher.registerReceiver(broadcastReceiver, filter)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user