Merge "Revert "Add falsing to undo button"" into tm-qpr-dev am: e419fb3987
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19807387 Change-Id: I2724b34939f2ba6952199a88875fe89a376d81bc Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
<!-- Wrap in a frame layout so that we can update the margins on the inner layout. (Since this view
|
||||
is the root view of a window, we cannot change the root view's margins.) -->
|
||||
<!-- Alphas start as 0 because the view will be animated in. -->
|
||||
<com.android.systemui.media.taptotransfer.sender.MediaTttChipRootView
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:id="@+id/media_ttt_sender_chip"
|
||||
@@ -97,4 +97,4 @@
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
</com.android.systemui.media.taptotransfer.sender.MediaTttChipRootView>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.android.internal.logging.UiEventLogger
|
||||
import com.android.internal.statusbar.IUndoMediaTransferCallback
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.media.taptotransfer.common.DEFAULT_TIMEOUT_MILLIS
|
||||
import com.android.systemui.plugins.FalsingManager
|
||||
|
||||
/**
|
||||
* A class enumerating all the possible states of the media tap-to-transfer chip on the sender
|
||||
@@ -107,15 +106,12 @@ enum class ChipStateSender(
|
||||
controllerSender: MediaTttChipControllerSender,
|
||||
routeInfo: MediaRoute2Info,
|
||||
undoCallback: IUndoMediaTransferCallback?,
|
||||
uiEventLogger: MediaTttSenderUiEventLogger,
|
||||
falsingManager: FalsingManager,
|
||||
uiEventLogger: MediaTttSenderUiEventLogger
|
||||
): View.OnClickListener? {
|
||||
if (undoCallback == null) {
|
||||
return null
|
||||
}
|
||||
return View.OnClickListener {
|
||||
if (falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return@OnClickListener
|
||||
|
||||
uiEventLogger.logUndoClicked(
|
||||
MediaTttSenderUiEvents.MEDIA_TTT_SENDER_UNDO_TRANSFER_TO_RECEIVER_CLICKED
|
||||
)
|
||||
@@ -145,15 +141,12 @@ enum class ChipStateSender(
|
||||
controllerSender: MediaTttChipControllerSender,
|
||||
routeInfo: MediaRoute2Info,
|
||||
undoCallback: IUndoMediaTransferCallback?,
|
||||
uiEventLogger: MediaTttSenderUiEventLogger,
|
||||
falsingManager: FalsingManager,
|
||||
uiEventLogger: MediaTttSenderUiEventLogger
|
||||
): View.OnClickListener? {
|
||||
if (undoCallback == null) {
|
||||
return null
|
||||
}
|
||||
return View.OnClickListener {
|
||||
if (falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return@OnClickListener
|
||||
|
||||
uiEventLogger.logUndoClicked(
|
||||
MediaTttSenderUiEvents.MEDIA_TTT_SENDER_UNDO_TRANSFER_TO_THIS_DEVICE_CLICKED
|
||||
)
|
||||
@@ -219,8 +212,7 @@ enum class ChipStateSender(
|
||||
controllerSender: MediaTttChipControllerSender,
|
||||
routeInfo: MediaRoute2Info,
|
||||
undoCallback: IUndoMediaTransferCallback?,
|
||||
uiEventLogger: MediaTttSenderUiEventLogger,
|
||||
falsingManager: FalsingManager,
|
||||
uiEventLogger: MediaTttSenderUiEventLogger
|
||||
): View.OnClickListener? = null
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -22,25 +22,21 @@ import android.media.MediaRoute2Info
|
||||
import android.os.PowerManager
|
||||
import android.util.Log
|
||||
import android.view.Gravity
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.view.accessibility.AccessibilityManager
|
||||
import android.widget.TextView
|
||||
import com.android.internal.statusbar.IUndoMediaTransferCallback
|
||||
import com.android.systemui.Gefingerpoken
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.animation.Interpolators
|
||||
import com.android.systemui.animation.ViewHierarchyAnimator
|
||||
import com.android.systemui.classifier.FalsingCollector
|
||||
import com.android.systemui.dagger.SysUISingleton
|
||||
import com.android.systemui.dagger.qualifiers.Main
|
||||
import com.android.systemui.media.taptotransfer.common.ChipInfoCommon
|
||||
import com.android.systemui.media.taptotransfer.common.MediaTttChipControllerCommon
|
||||
import com.android.systemui.media.taptotransfer.common.MediaTttLogger
|
||||
import com.android.systemui.media.taptotransfer.common.MediaTttRemovalReason
|
||||
import com.android.systemui.plugins.FalsingManager
|
||||
import com.android.systemui.statusbar.CommandQueue
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController
|
||||
import com.android.systemui.util.concurrency.DelayableExecutor
|
||||
@@ -62,9 +58,7 @@ class MediaTttChipControllerSender @Inject constructor(
|
||||
accessibilityManager: AccessibilityManager,
|
||||
configurationController: ConfigurationController,
|
||||
powerManager: PowerManager,
|
||||
private val uiEventLogger: MediaTttSenderUiEventLogger,
|
||||
private val falsingManager: FalsingManager,
|
||||
private val falsingCollector: FalsingCollector,
|
||||
private val uiEventLogger: MediaTttSenderUiEventLogger
|
||||
) : MediaTttChipControllerCommon<ChipSenderInfo>(
|
||||
context,
|
||||
logger,
|
||||
@@ -76,9 +70,6 @@ class MediaTttChipControllerSender @Inject constructor(
|
||||
powerManager,
|
||||
R.layout.media_ttt_chip,
|
||||
) {
|
||||
|
||||
private lateinit var parent: MediaTttChipRootView
|
||||
|
||||
override val windowLayoutParams = commonWindowLayoutParams.apply {
|
||||
gravity = Gravity.TOP.or(Gravity.CENTER_HORIZONTAL)
|
||||
}
|
||||
@@ -130,15 +121,6 @@ class MediaTttChipControllerSender @Inject constructor(
|
||||
|
||||
val chipState = newChipInfo.state
|
||||
|
||||
// Detect falsing touches on the chip.
|
||||
parent = currentChipView as MediaTttChipRootView
|
||||
parent.touchHandler = object : Gefingerpoken {
|
||||
override fun onTouchEvent(ev: MotionEvent?): Boolean {
|
||||
falsingCollector.onTouchEvent(ev)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// App icon
|
||||
val iconName = setIcon(currentChipView, newChipInfo.routeInfo.clientPackageName)
|
||||
|
||||
@@ -154,11 +136,7 @@ class MediaTttChipControllerSender @Inject constructor(
|
||||
// Undo
|
||||
val undoView = currentChipView.requireViewById<View>(R.id.undo)
|
||||
val undoClickListener = chipState.undoClickListener(
|
||||
this,
|
||||
newChipInfo.routeInfo,
|
||||
newChipInfo.undoCallback,
|
||||
uiEventLogger,
|
||||
falsingManager,
|
||||
this, newChipInfo.routeInfo, newChipInfo.undoCallback, uiEventLogger
|
||||
)
|
||||
undoView.setOnClickListener(undoClickListener)
|
||||
undoView.visibility = (undoClickListener != null).visibleIfTrue()
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.media.taptotransfer.sender
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.widget.FrameLayout
|
||||
import com.android.systemui.Gefingerpoken
|
||||
|
||||
/** A simple subclass that allows for observing touch events on chip. */
|
||||
class MediaTttChipRootView(
|
||||
context: Context,
|
||||
attrs: AttributeSet?
|
||||
) : FrameLayout(context, attrs) {
|
||||
|
||||
/** Assign this field to observe touch events. */
|
||||
var touchHandler: Gefingerpoken? = null
|
||||
|
||||
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
|
||||
touchHandler?.onTouchEvent(ev)
|
||||
return super.dispatchTouchEvent(ev)
|
||||
}
|
||||
}
|
||||
@@ -35,9 +35,7 @@ import com.android.internal.logging.testing.UiEventLoggerFake
|
||||
import com.android.internal.statusbar.IUndoMediaTransferCallback
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.SysuiTestCase
|
||||
import com.android.systemui.classifier.FalsingCollector
|
||||
import com.android.systemui.media.taptotransfer.common.MediaTttLogger
|
||||
import com.android.systemui.plugins.FalsingManager
|
||||
import com.android.systemui.statusbar.CommandQueue
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController
|
||||
import com.android.systemui.util.concurrency.FakeExecutor
|
||||
@@ -50,12 +48,11 @@ import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentCaptor
|
||||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.Mockito.`when` as whenever
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.mockito.Mockito.`when` as whenever
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner::class)
|
||||
@@ -81,10 +78,6 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
private lateinit var viewUtil: ViewUtil
|
||||
@Mock
|
||||
private lateinit var commandQueue: CommandQueue
|
||||
@Mock
|
||||
private lateinit var falsingManager: FalsingManager
|
||||
@Mock
|
||||
private lateinit var falsingCollector: FalsingCollector
|
||||
private lateinit var commandQueueCallback: CommandQueue.Callbacks
|
||||
private lateinit var fakeAppIconDrawable: Drawable
|
||||
private lateinit var fakeClock: FakeSystemClock
|
||||
@@ -122,9 +115,7 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
accessibilityManager,
|
||||
configurationController,
|
||||
powerManager,
|
||||
senderUiEventLogger,
|
||||
falsingManager,
|
||||
falsingCollector
|
||||
senderUiEventLogger
|
||||
)
|
||||
|
||||
val callbackCaptor = ArgumentCaptor.forClass(CommandQueue.Callbacks::class.java)
|
||||
@@ -429,38 +420,6 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
assertThat(undoCallbackCalled).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun transferToReceiverSucceeded_withUndoRunnable_falseTap_callbackNotRun() {
|
||||
whenever(falsingManager.isFalseTap(anyInt())).thenReturn(true)
|
||||
var undoCallbackCalled = false
|
||||
val undoCallback = object : IUndoMediaTransferCallback.Stub() {
|
||||
override fun onUndoTriggered() {
|
||||
undoCallbackCalled = true
|
||||
}
|
||||
}
|
||||
|
||||
controllerSender.displayChip(transferToReceiverSucceeded(undoCallback))
|
||||
getChipView().getUndoButton().performClick()
|
||||
|
||||
assertThat(undoCallbackCalled).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun transferToReceiverSucceeded_withUndoRunnable_realTap_callbackRun() {
|
||||
whenever(falsingManager.isFalseTap(anyInt())).thenReturn(false)
|
||||
var undoCallbackCalled = false
|
||||
val undoCallback = object : IUndoMediaTransferCallback.Stub() {
|
||||
override fun onUndoTriggered() {
|
||||
undoCallbackCalled = true
|
||||
}
|
||||
}
|
||||
|
||||
controllerSender.displayChip(transferToReceiverSucceeded(undoCallback))
|
||||
getChipView().getUndoButton().performClick()
|
||||
|
||||
assertThat(undoCallbackCalled).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun transferToReceiverSucceeded_undoButtonClick_switchesToTransferToThisDeviceTriggered() {
|
||||
val undoCallback = object : IUndoMediaTransferCallback.Stub() {
|
||||
|
||||
Reference in New Issue
Block a user