Merge "Update TTT controllers to be in CoreStartable." into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9a6046ab0b
@@ -27,9 +27,6 @@ import com.android.systemui.dump.DumpManager;
|
||||
import com.android.systemui.keyguard.KeyguardSliceProvider;
|
||||
import com.android.systemui.media.muteawait.MediaMuteAwaitConnectionCli;
|
||||
import com.android.systemui.media.nearby.NearbyMediaDevicesManager;
|
||||
import com.android.systemui.media.taptotransfer.MediaTttCommandLineHelper;
|
||||
import com.android.systemui.media.taptotransfer.receiver.MediaTttChipControllerReceiver;
|
||||
import com.android.systemui.media.taptotransfer.sender.MediaTttChipControllerSender;
|
||||
import com.android.systemui.people.PeopleProvider;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
import com.android.systemui.unfold.FoldStateLogger;
|
||||
@@ -133,9 +130,6 @@ public interface SysUIComponent {
|
||||
});
|
||||
getNaturalRotationUnfoldProgressProvider().ifPresent(o -> o.init());
|
||||
// No init method needed, just needs to be gotten so that it's created.
|
||||
getMediaTttChipControllerSender();
|
||||
getMediaTttChipControllerReceiver();
|
||||
getMediaTttCommandLineHelper();
|
||||
getMediaMuteAwaitConnectionCli();
|
||||
getNearbyMediaDevicesManager();
|
||||
getUnfoldLatencyTracker().init();
|
||||
@@ -205,15 +199,6 @@ public interface SysUIComponent {
|
||||
*/
|
||||
Optional<NaturalRotationUnfoldProgressProvider> getNaturalRotationUnfoldProgressProvider();
|
||||
|
||||
/** */
|
||||
Optional<MediaTttChipControllerSender> getMediaTttChipControllerSender();
|
||||
|
||||
/** */
|
||||
Optional<MediaTttChipControllerReceiver> getMediaTttChipControllerReceiver();
|
||||
|
||||
/** */
|
||||
Optional<MediaTttCommandLineHelper> getMediaTttCommandLineHelper();
|
||||
|
||||
/** */
|
||||
Optional<MediaMuteAwaitConnectionCli> getMediaMuteAwaitConnectionCli();
|
||||
|
||||
|
||||
@@ -32,6 +32,9 @@ import com.android.systemui.keyboard.KeyboardUI
|
||||
import com.android.systemui.keyguard.KeyguardViewMediator
|
||||
import com.android.systemui.log.SessionTracker
|
||||
import com.android.systemui.media.RingtonePlayer
|
||||
import com.android.systemui.media.taptotransfer.MediaTttCommandLineHelper
|
||||
import com.android.systemui.media.taptotransfer.receiver.MediaTttChipControllerReceiver
|
||||
import com.android.systemui.media.taptotransfer.sender.MediaTttChipControllerSender
|
||||
import com.android.systemui.power.PowerUI
|
||||
import com.android.systemui.recents.Recents
|
||||
import com.android.systemui.settings.dagger.MultiUserUtilsModule
|
||||
@@ -213,4 +216,26 @@ abstract class SystemUICoreStartableModule {
|
||||
@IntoMap
|
||||
@ClassKey(KeyguardLiftController::class)
|
||||
abstract fun bindKeyguardLiftController(sysui: KeyguardLiftController): CoreStartable
|
||||
|
||||
/** Inject into MediaTttChipControllerReceiver. */
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(MediaTttChipControllerReceiver::class)
|
||||
abstract fun bindMediaTttChipControllerReceiver(
|
||||
sysui: MediaTttChipControllerReceiver
|
||||
): CoreStartable
|
||||
|
||||
/** Inject into MediaTttChipControllerSender. */
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(MediaTttChipControllerSender::class)
|
||||
abstract fun bindMediaTttChipControllerSender(
|
||||
sysui: MediaTttChipControllerSender
|
||||
): CoreStartable
|
||||
|
||||
/** Inject into MediaTttCommandLineHelper. */
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(MediaTttCommandLineHelper::class)
|
||||
abstract fun bindMediaTttCommandLineHelper(sysui: MediaTttCommandLineHelper): CoreStartable
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.content.Context
|
||||
import android.media.MediaRoute2Info
|
||||
import android.util.Log
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import com.android.systemui.CoreStartable
|
||||
import com.android.systemui.dagger.SysUISingleton
|
||||
import com.android.systemui.dagger.qualifiers.Main
|
||||
import com.android.systemui.media.taptotransfer.receiver.ChipStateReceiver
|
||||
@@ -39,14 +40,10 @@ import javax.inject.Inject
|
||||
*/
|
||||
@SysUISingleton
|
||||
class MediaTttCommandLineHelper @Inject constructor(
|
||||
commandRegistry: CommandRegistry,
|
||||
private val commandRegistry: CommandRegistry,
|
||||
private val context: Context,
|
||||
@Main private val mainExecutor: Executor
|
||||
) {
|
||||
init {
|
||||
commandRegistry.registerCommand(SENDER_COMMAND) { SenderCommand() }
|
||||
commandRegistry.registerCommand(RECEIVER_COMMAND) { ReceiverCommand() }
|
||||
}
|
||||
) : CoreStartable(context) {
|
||||
|
||||
/** All commands for the sender device. */
|
||||
inner class SenderCommand : Command {
|
||||
@@ -56,7 +53,7 @@ class MediaTttCommandLineHelper @Inject constructor(
|
||||
val displayState: Int?
|
||||
try {
|
||||
displayState = ChipStateSender.getSenderStateIdFromName(commandName)
|
||||
} catch (ex: IllegalArgumentException) {
|
||||
} catch (ex: IllegalArgumentException) {
|
||||
pw.println("Invalid command name $commandName")
|
||||
return
|
||||
}
|
||||
@@ -150,6 +147,11 @@ class MediaTttCommandLineHelper @Inject constructor(
|
||||
"<chipState> useAppIcon=[true|false]")
|
||||
}
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
commandRegistry.registerCommand(SENDER_COMMAND) { SenderCommand() }
|
||||
commandRegistry.registerCommand(RECEIVER_COMMAND) { ReceiverCommand() }
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -55,7 +55,7 @@ import javax.inject.Inject
|
||||
*/
|
||||
@SysUISingleton
|
||||
class MediaTttChipControllerReceiver @Inject constructor(
|
||||
commandQueue: CommandQueue,
|
||||
private val commandQueue: CommandQueue,
|
||||
context: Context,
|
||||
@MediaTttReceiverLogger logger: MediaTttLogger,
|
||||
windowManager: WindowManager,
|
||||
@@ -101,10 +101,6 @@ class MediaTttChipControllerReceiver @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
commandQueue.addCallback(commandQueueCallbacks)
|
||||
}
|
||||
|
||||
private fun updateMediaTapToTransferReceiverDisplay(
|
||||
@StatusBarManager.MediaTransferReceiverState displayState: Int,
|
||||
routeInfo: MediaRoute2Info,
|
||||
@@ -141,6 +137,10 @@ class MediaTttChipControllerReceiver @Inject constructor(
|
||||
)
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
commandQueue.addCallback(commandQueueCallbacks)
|
||||
}
|
||||
|
||||
override fun updateView(newInfo: ChipReceiverInfo, currentView: ViewGroup) {
|
||||
val iconInfo = MediaTttUtils.getIconInfoFromPackageName(
|
||||
context, newInfo.routeInfo.clientPackageName, logger
|
||||
|
||||
@@ -48,7 +48,6 @@ import com.android.systemui.temporarydisplay.TemporaryViewDisplayController
|
||||
import com.android.systemui.temporarydisplay.TemporaryViewInfo
|
||||
import com.android.systemui.util.concurrency.DelayableExecutor
|
||||
import com.android.systemui.util.view.ViewUtil
|
||||
import dagger.Lazy
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
@@ -57,7 +56,7 @@ import javax.inject.Inject
|
||||
*/
|
||||
@SysUISingleton
|
||||
open class MediaTttChipControllerSender @Inject constructor(
|
||||
commandQueue: CommandQueue,
|
||||
private val commandQueue: CommandQueue,
|
||||
context: Context,
|
||||
@MediaTttSenderLogger logger: MediaTttLogger,
|
||||
windowManager: WindowManager,
|
||||
@@ -66,10 +65,8 @@ open class MediaTttChipControllerSender @Inject constructor(
|
||||
configurationController: ConfigurationController,
|
||||
powerManager: PowerManager,
|
||||
private val uiEventLogger: MediaTttSenderUiEventLogger,
|
||||
// Added Lazy<> to delay the time we create Falsing instances.
|
||||
// And overcome performance issue, check [b/247817628] for details.
|
||||
private val falsingManager: Lazy<FalsingManager>,
|
||||
private val falsingCollector: Lazy<FalsingCollector>,
|
||||
private val falsingManager: FalsingManager,
|
||||
private val falsingCollector: FalsingCollector,
|
||||
private val viewUtil: ViewUtil,
|
||||
) : TemporaryViewDisplayController<ChipSenderInfo, MediaTttLogger>(
|
||||
context,
|
||||
@@ -102,10 +99,6 @@ open class MediaTttChipControllerSender @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
commandQueue.addCallback(commandQueueCallbacks)
|
||||
}
|
||||
|
||||
private fun updateMediaTapToTransferSenderDisplay(
|
||||
@StatusBarManager.MediaTransferSenderState displayState: Int,
|
||||
routeInfo: MediaRoute2Info,
|
||||
@@ -128,6 +121,10 @@ open class MediaTttChipControllerSender @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
commandQueue.addCallback(commandQueueCallbacks)
|
||||
}
|
||||
|
||||
override fun updateView(
|
||||
newInfo: ChipSenderInfo,
|
||||
currentView: ViewGroup
|
||||
@@ -138,7 +135,7 @@ open class MediaTttChipControllerSender @Inject constructor(
|
||||
parent = currentView.requireViewById(R.id.media_ttt_sender_chip)
|
||||
parent.touchHandler = object : Gefingerpoken {
|
||||
override fun onTouchEvent(ev: MotionEvent?): Boolean {
|
||||
falsingCollector.get().onTouchEvent(ev)
|
||||
falsingCollector.onTouchEvent(ev)
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -167,7 +164,7 @@ open class MediaTttChipControllerSender @Inject constructor(
|
||||
newInfo.routeInfo,
|
||||
newInfo.undoCallback,
|
||||
uiEventLogger,
|
||||
falsingManager.get(),
|
||||
falsingManager,
|
||||
)
|
||||
undoView.setOnClickListener(undoClickListener)
|
||||
undoView.visibility = (undoClickListener != null).visibleIfTrue()
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.view.accessibility.AccessibilityManager
|
||||
import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_CONTROLS
|
||||
import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_ICONS
|
||||
import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_TEXT
|
||||
import com.android.systemui.CoreStartable
|
||||
import com.android.systemui.dagger.qualifiers.Main
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController
|
||||
import com.android.systemui.util.concurrency.DelayableExecutor
|
||||
@@ -61,7 +62,7 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora
|
||||
@LayoutRes private val viewLayoutRes: Int,
|
||||
private val windowTitle: String,
|
||||
private val wakeReason: String,
|
||||
) {
|
||||
) : CoreStartable(context) {
|
||||
/**
|
||||
* Window layout params that will be used as a starting point for the [windowLayoutParams] of
|
||||
* all subclasses.
|
||||
|
||||
@@ -64,6 +64,7 @@ class MediaTttCommandLineHelperTest : SysuiTestCase() {
|
||||
context,
|
||||
FakeExecutor(FakeSystemClock()),
|
||||
)
|
||||
mediaTttCommandLineHelper.start()
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException::class)
|
||||
|
||||
@@ -110,6 +110,7 @@ class MediaTttChipControllerReceiverTest : SysuiTestCase() {
|
||||
receiverUiEventLogger,
|
||||
viewUtil,
|
||||
)
|
||||
controllerReceiver.start()
|
||||
|
||||
val callbackCaptor = ArgumentCaptor.forClass(CommandQueue.Callbacks::class.java)
|
||||
verify(commandQueue).addCallback(callbackCaptor.capture())
|
||||
|
||||
@@ -49,7 +49,6 @@ import com.android.systemui.util.mockito.eq
|
||||
import com.android.systemui.util.time.FakeSystemClock
|
||||
import com.android.systemui.util.view.ViewUtil
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import dagger.Lazy
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -84,12 +83,8 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
@Mock
|
||||
private lateinit var commandQueue: CommandQueue
|
||||
@Mock
|
||||
private lateinit var lazyFalsingManager: Lazy<FalsingManager>
|
||||
@Mock
|
||||
private lateinit var falsingManager: FalsingManager
|
||||
@Mock
|
||||
private lateinit var lazyFalsingCollector: Lazy<FalsingCollector>
|
||||
@Mock
|
||||
private lateinit var falsingCollector: FalsingCollector
|
||||
@Mock
|
||||
private lateinit var viewUtil: ViewUtil
|
||||
@@ -119,8 +114,6 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
senderUiEventLogger = MediaTttSenderUiEventLogger(uiEventLoggerFake)
|
||||
|
||||
whenever(accessibilityManager.getRecommendedTimeoutMillis(any(), any())).thenReturn(TIMEOUT)
|
||||
whenever(lazyFalsingManager.get()).thenReturn(falsingManager)
|
||||
whenever(lazyFalsingCollector.get()).thenReturn(falsingCollector)
|
||||
|
||||
controllerSender = TestMediaTttChipControllerSender(
|
||||
commandQueue,
|
||||
@@ -132,10 +125,11 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
configurationController,
|
||||
powerManager,
|
||||
senderUiEventLogger,
|
||||
lazyFalsingManager,
|
||||
lazyFalsingCollector,
|
||||
falsingManager,
|
||||
falsingCollector,
|
||||
viewUtil,
|
||||
)
|
||||
controllerSender.start()
|
||||
|
||||
val callbackCaptor = ArgumentCaptor.forClass(CommandQueue.Callbacks::class.java)
|
||||
verify(commandQueue).addCallback(callbackCaptor.capture())
|
||||
@@ -441,7 +435,7 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun transferToReceiverSucceeded_withUndoRunnable_falseTap_callbackNotRun() {
|
||||
whenever(lazyFalsingManager.get().isFalseTap(anyInt())).thenReturn(true)
|
||||
whenever(falsingManager.isFalseTap(anyInt())).thenReturn(true)
|
||||
var undoCallbackCalled = false
|
||||
val undoCallback = object : IUndoMediaTransferCallback.Stub() {
|
||||
override fun onUndoTriggered() {
|
||||
@@ -457,7 +451,7 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun transferToReceiverSucceeded_withUndoRunnable_realTap_callbackRun() {
|
||||
whenever(lazyFalsingManager.get().isFalseTap(anyInt())).thenReturn(false)
|
||||
whenever(falsingManager.isFalseTap(anyInt())).thenReturn(false)
|
||||
var undoCallbackCalled = false
|
||||
val undoCallback = object : IUndoMediaTransferCallback.Stub() {
|
||||
override fun onUndoTriggered() {
|
||||
@@ -839,8 +833,8 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
configurationController: ConfigurationController,
|
||||
powerManager: PowerManager,
|
||||
uiEventLogger: MediaTttSenderUiEventLogger,
|
||||
falsingManager: Lazy<FalsingManager>,
|
||||
falsingCollector: Lazy<FalsingCollector>,
|
||||
falsingManager: FalsingManager,
|
||||
falsingCollector: FalsingCollector,
|
||||
viewUtil: ViewUtil,
|
||||
) : MediaTttChipControllerSender(
|
||||
commandQueue,
|
||||
|
||||
@@ -260,6 +260,9 @@ class TemporaryViewDisplayControllerTest : SysuiTestCase() {
|
||||
var mostRecentViewInfo: ViewInfo? = null
|
||||
|
||||
override val windowLayoutParams = commonWindowLayoutParams
|
||||
|
||||
override fun start() {}
|
||||
|
||||
override fun updateView(newInfo: ViewInfo, currentView: ViewGroup) {
|
||||
mostRecentViewInfo = newInfo
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user