Merge "Fix work profile security challenge screen isn't properly shown" into udc-dev
This commit is contained in:
@@ -16,11 +16,13 @@ constructor(
|
|||||||
@Main private val mainExecutor: Executor,
|
@Main private val mainExecutor: Executor,
|
||||||
) {
|
) {
|
||||||
private var action: Action? = null
|
private var action: Action? = null
|
||||||
|
private var panelState: Int = -1
|
||||||
|
|
||||||
@MainThread
|
@MainThread
|
||||||
fun enable(onPanelInteraction: Runnable) {
|
fun enable(onPanelInteraction: Runnable) {
|
||||||
if (action == null) {
|
if (action == null) {
|
||||||
action = Action(onPanelInteraction)
|
action = Action(onPanelInteraction)
|
||||||
|
shadeExpansionStateManager.addStateListener(this::onPanelStateChanged)
|
||||||
shadeExpansionStateManager.addExpansionListener(this::onPanelExpansionChanged)
|
shadeExpansionStateManager.addExpansionListener(this::onPanelExpansionChanged)
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Already enabled")
|
Log.e(TAG, "Already enabled")
|
||||||
@@ -32,6 +34,8 @@ constructor(
|
|||||||
if (action != null) {
|
if (action != null) {
|
||||||
Log.i(TAG, "Disable dectector")
|
Log.i(TAG, "Disable dectector")
|
||||||
action = null
|
action = null
|
||||||
|
panelState = -1
|
||||||
|
shadeExpansionStateManager.removeStateListener(this::onPanelStateChanged)
|
||||||
shadeExpansionStateManager.removeExpansionListener(this::onPanelExpansionChanged)
|
shadeExpansionStateManager.removeExpansionListener(this::onPanelExpansionChanged)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,13 +44,34 @@ constructor(
|
|||||||
private fun onPanelExpansionChanged(event: ShadeExpansionChangeEvent) =
|
private fun onPanelExpansionChanged(event: ShadeExpansionChangeEvent) =
|
||||||
mainExecutor.execute {
|
mainExecutor.execute {
|
||||||
action?.let {
|
action?.let {
|
||||||
if (event.tracking || (event.expanded && event.fraction > 0)) {
|
if (event.tracking || (event.expanded && event.fraction > 0 && panelState == 1)) {
|
||||||
Log.i(TAG, "Detected panel interaction, event: $event")
|
Log.i(TAG, "onPanelExpansionChanged, event: $event")
|
||||||
it.onPanelInteraction.run()
|
it.onPanelInteraction.run()
|
||||||
disable()
|
disable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
|
private fun onPanelStateChanged(state: Int) =
|
||||||
|
mainExecutor.execute {
|
||||||
|
// When device owner set screen lock type as Swipe, and install work profile with
|
||||||
|
// pin/pattern/password & fingerprint or face, if work profile allow user to verify
|
||||||
|
// by BP, it is possible that BP will be displayed when keyguard is closing, in this
|
||||||
|
// case event.expanded = true and event.fraction > 0, so BP will be closed, adding
|
||||||
|
// panel state into consideration is workaround^2, this workaround works because
|
||||||
|
// onPanelStateChanged is earlier than onPanelExpansionChanged
|
||||||
|
|
||||||
|
// we don't want to close BP in below case
|
||||||
|
//
|
||||||
|
// | Action | tracking | expanded | fraction | panelState |
|
||||||
|
// | HeadsUp | NA | NA | NA | 1 |
|
||||||
|
// | b/285111529 | false | true | > 0 | 2 |
|
||||||
|
|
||||||
|
// Note: HeadsUp behavior was changed, so we can't got onPanelExpansionChanged now
|
||||||
|
panelState = state
|
||||||
|
Log.i(TAG, "onPanelStateChanged, state: $state")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private data class Action(val onPanelInteraction: Runnable)
|
private data class Action(val onPanelInteraction: Runnable)
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ import android.testing.AndroidTestingRunner
|
|||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
import com.android.systemui.SysuiTestCase
|
import com.android.systemui.SysuiTestCase
|
||||||
import com.android.systemui.shade.ShadeExpansionStateManager
|
import com.android.systemui.shade.ShadeExpansionStateManager
|
||||||
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito.times
|
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.Mockito.verifyZeroInteractions
|
import org.mockito.Mockito.verifyZeroInteractions
|
||||||
import org.mockito.junit.MockitoJUnit
|
import org.mockito.junit.MockitoJUnit
|
||||||
@@ -63,10 +63,10 @@ class AuthDialogPanelInteractionDetectorTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testEnableDetector_expandOnly_shouldPostRunnable() {
|
fun testEnableDetector_expandOnly_shouldNotPostRunnable() {
|
||||||
detector.enable(action)
|
detector.enable(action)
|
||||||
shadeExpansionStateManager.onPanelExpansionChanged(1.0f, true, false, 0f)
|
shadeExpansionStateManager.onPanelExpansionChanged(1.0f, true, false, 0f)
|
||||||
verify(action).run()
|
verifyZeroInteractions(action)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -84,4 +84,14 @@ class AuthDialogPanelInteractionDetectorTest : SysuiTestCase() {
|
|||||||
shadeExpansionStateManager.onPanelExpansionChanged(1.0f, true, true, 0f)
|
shadeExpansionStateManager.onPanelExpansionChanged(1.0f, true, true, 0f)
|
||||||
verifyZeroInteractions(action)
|
verifyZeroInteractions(action)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testFromOpenState_becomeStateClose_enableDetector_shouldNotPostRunnable() {
|
||||||
|
// STATE_OPEN is 2
|
||||||
|
shadeExpansionStateManager.updateState(2)
|
||||||
|
detector.enable(action)
|
||||||
|
shadeExpansionStateManager.onPanelExpansionChanged(0.5f, false, false, 0f)
|
||||||
|
verifyZeroInteractions(action)
|
||||||
|
Assert.assertEquals(true, shadeExpansionStateManager.isClosed())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user