Loading packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +22 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,28 @@ public class LogModule { return factory.create("SwipeStatusBarAwayLog", 30); } /** * Provides a logging buffer for logs related to the media tap-to-transfer chip on the sender * device. See {@link com.android.systemui.media.taptotransfer.sender.MediaTttSenderLogger}. */ @Provides @SysUISingleton @MediaTttSenderLogBuffer public static LogBuffer provideMediaTttSenderLogBuffer(LogBufferFactory factory) { return factory.create("MediaTttSender", 20); } /** * Provides a logging buffer for logs related to the media tap-to-transfer chip on the receiver * device. See {@link com.android.systemui.media.taptotransfer.receiver.MediaTttReceiverLogger}. */ @Provides @SysUISingleton @MediaTttReceiverLogBuffer public static LogBuffer provideMediaTttReceiverLogBuffer(LogBufferFactory factory) { return factory.create("MediaTttReceiver", 20); } /** Allows logging buffers to be tweaked via adb on debug builds but not on prod builds. */ @Provides @SysUISingleton Loading packages/SystemUI/src/com/android/systemui/log/dagger/MediaTttReceiverLogBuffer.java 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * 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.log.dagger; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.android.systemui.log.LogBuffer; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import javax.inject.Qualifier; /** * A {@link LogBuffer} for * {@link com.android.systemui.media.taptotransfer.receiver.MediaTttReceiverLogger}. */ @Qualifier @Documented @Retention(RUNTIME) public @interface MediaTttReceiverLogBuffer { } packages/SystemUI/src/com/android/systemui/log/dagger/MediaTttSenderLogBuffer.java 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * 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.log.dagger; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.android.systemui.log.LogBuffer; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import javax.inject.Qualifier; /** * A {@link LogBuffer} for * {@link com.android.systemui.media.taptotransfer.sender.MediaTttSenderLogger}. */ @Qualifier @Documented @Retention(RUNTIME) public @interface MediaTttSenderLogBuffer { } packages/SystemUI/src/com/android/systemui/media/dagger/MediaModule.java +24 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,9 @@ package com.android.systemui.media.dagger; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.log.LogBuffer; import com.android.systemui.log.dagger.MediaTttReceiverLogBuffer; import com.android.systemui.log.dagger.MediaTttSenderLogBuffer; import com.android.systemui.media.MediaDataManager; import com.android.systemui.media.MediaFlags; import com.android.systemui.media.MediaHierarchyManager; Loading @@ -27,8 +30,11 @@ 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.MediaTttFlags; import com.android.systemui.media.taptotransfer.common.MediaTttLogger; import com.android.systemui.media.taptotransfer.receiver.MediaTttChipControllerReceiver; import com.android.systemui.media.taptotransfer.receiver.MediaTttReceiverLogger; import com.android.systemui.media.taptotransfer.sender.MediaTttChipControllerSender; import com.android.systemui.media.taptotransfer.sender.MediaTttSenderLogger; import java.util.Optional; Loading Loading @@ -112,6 +118,24 @@ public interface MediaModule { return Optional.of(controllerReceiverLazy.get()); } @Provides @SysUISingleton @MediaTttSenderLogger static MediaTttLogger providesMediaTttSenderLogger( @MediaTttSenderLogBuffer LogBuffer buffer ) { return new MediaTttLogger("Sender", buffer); } @Provides @SysUISingleton @MediaTttReceiverLogger static MediaTttLogger providesMediaTttReceiverLogger( @MediaTttReceiverLogBuffer LogBuffer buffer ) { return new MediaTttLogger("Receiver", buffer); } /** */ @Provides @SysUISingleton Loading packages/SystemUI/src/com/android/systemui/media/taptotransfer/common/MediaTttChipControllerCommon.kt +19 −4 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import com.android.systemui.util.view.ViewUtil */ abstract class MediaTttChipControllerCommon<T : MediaTttChipState>( internal val context: Context, internal val logger: MediaTttLogger, private val windowManager: WindowManager, private val viewUtil: ViewUtil, @Main private val mainExecutor: DelayableExecutor, Loading Loading @@ -93,18 +94,29 @@ abstract class MediaTttChipControllerCommon<T : MediaTttChipState>( // Cancel and re-set the chip timeout each time we get a new state. cancelChipViewTimeout?.run() cancelChipViewTimeout = mainExecutor.executeDelayed(this::removeChip, TIMEOUT_MILLIS) cancelChipViewTimeout = mainExecutor.executeDelayed( { removeChip(REASON_TIMEOUT) }, TIMEOUT_MILLIS ) } /** Hides the chip. */ fun removeChip() { /** * Hides the chip. * * @param removalReason a short string describing why the chip was removed (timeout, state * change, etc.) */ fun removeChip(removalReason: String) { // TODO(b/203800347): We may not want to hide the chip if we're currently in a // TransferTriggered state: Once the user has initiated the transfer, they should be able // to move away from the receiver device but still see the status of the transfer. if (chipView == null) { return } logger.logChipRemoval(removalReason) tapGestureDetector.removeOnGestureDetectedCallback(TAG) windowManager.removeView(chipView) chipView = null // No need to time the chip out since it's already gone cancelChipViewTimeout?.run() } /** Loading Loading @@ -136,7 +148,7 @@ abstract class MediaTttChipControllerCommon<T : MediaTttChipState>( // If the tap is within the chip bounds, we shouldn't hide the chip (in case users think the // chip is tappable). if (!viewUtil.touchIsWithinView(view, e.x, e.y)) { removeChip() removeChip(REASON_SCREEN_TAP) } } } Loading @@ -147,3 +159,6 @@ private const val WINDOW_TITLE = "Media Transfer Chip View" private val TAG = MediaTttChipControllerCommon::class.simpleName!! @VisibleForTesting const val TIMEOUT_MILLIS = 3000L private const val REASON_TIMEOUT = "TIMEOUT" private const val REASON_SCREEN_TAP = "SCREEN_TAP" Loading
packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +22 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,28 @@ public class LogModule { return factory.create("SwipeStatusBarAwayLog", 30); } /** * Provides a logging buffer for logs related to the media tap-to-transfer chip on the sender * device. See {@link com.android.systemui.media.taptotransfer.sender.MediaTttSenderLogger}. */ @Provides @SysUISingleton @MediaTttSenderLogBuffer public static LogBuffer provideMediaTttSenderLogBuffer(LogBufferFactory factory) { return factory.create("MediaTttSender", 20); } /** * Provides a logging buffer for logs related to the media tap-to-transfer chip on the receiver * device. See {@link com.android.systemui.media.taptotransfer.receiver.MediaTttReceiverLogger}. */ @Provides @SysUISingleton @MediaTttReceiverLogBuffer public static LogBuffer provideMediaTttReceiverLogBuffer(LogBufferFactory factory) { return factory.create("MediaTttReceiver", 20); } /** Allows logging buffers to be tweaked via adb on debug builds but not on prod builds. */ @Provides @SysUISingleton Loading
packages/SystemUI/src/com/android/systemui/log/dagger/MediaTttReceiverLogBuffer.java 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * 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.log.dagger; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.android.systemui.log.LogBuffer; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import javax.inject.Qualifier; /** * A {@link LogBuffer} for * {@link com.android.systemui.media.taptotransfer.receiver.MediaTttReceiverLogger}. */ @Qualifier @Documented @Retention(RUNTIME) public @interface MediaTttReceiverLogBuffer { }
packages/SystemUI/src/com/android/systemui/log/dagger/MediaTttSenderLogBuffer.java 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * 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.log.dagger; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.android.systemui.log.LogBuffer; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import javax.inject.Qualifier; /** * A {@link LogBuffer} for * {@link com.android.systemui.media.taptotransfer.sender.MediaTttSenderLogger}. */ @Qualifier @Documented @Retention(RUNTIME) public @interface MediaTttSenderLogBuffer { }
packages/SystemUI/src/com/android/systemui/media/dagger/MediaModule.java +24 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,9 @@ package com.android.systemui.media.dagger; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.log.LogBuffer; import com.android.systemui.log.dagger.MediaTttReceiverLogBuffer; import com.android.systemui.log.dagger.MediaTttSenderLogBuffer; import com.android.systemui.media.MediaDataManager; import com.android.systemui.media.MediaFlags; import com.android.systemui.media.MediaHierarchyManager; Loading @@ -27,8 +30,11 @@ 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.MediaTttFlags; import com.android.systemui.media.taptotransfer.common.MediaTttLogger; import com.android.systemui.media.taptotransfer.receiver.MediaTttChipControllerReceiver; import com.android.systemui.media.taptotransfer.receiver.MediaTttReceiverLogger; import com.android.systemui.media.taptotransfer.sender.MediaTttChipControllerSender; import com.android.systemui.media.taptotransfer.sender.MediaTttSenderLogger; import java.util.Optional; Loading Loading @@ -112,6 +118,24 @@ public interface MediaModule { return Optional.of(controllerReceiverLazy.get()); } @Provides @SysUISingleton @MediaTttSenderLogger static MediaTttLogger providesMediaTttSenderLogger( @MediaTttSenderLogBuffer LogBuffer buffer ) { return new MediaTttLogger("Sender", buffer); } @Provides @SysUISingleton @MediaTttReceiverLogger static MediaTttLogger providesMediaTttReceiverLogger( @MediaTttReceiverLogBuffer LogBuffer buffer ) { return new MediaTttLogger("Receiver", buffer); } /** */ @Provides @SysUISingleton Loading
packages/SystemUI/src/com/android/systemui/media/taptotransfer/common/MediaTttChipControllerCommon.kt +19 −4 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import com.android.systemui.util.view.ViewUtil */ abstract class MediaTttChipControllerCommon<T : MediaTttChipState>( internal val context: Context, internal val logger: MediaTttLogger, private val windowManager: WindowManager, private val viewUtil: ViewUtil, @Main private val mainExecutor: DelayableExecutor, Loading Loading @@ -93,18 +94,29 @@ abstract class MediaTttChipControllerCommon<T : MediaTttChipState>( // Cancel and re-set the chip timeout each time we get a new state. cancelChipViewTimeout?.run() cancelChipViewTimeout = mainExecutor.executeDelayed(this::removeChip, TIMEOUT_MILLIS) cancelChipViewTimeout = mainExecutor.executeDelayed( { removeChip(REASON_TIMEOUT) }, TIMEOUT_MILLIS ) } /** Hides the chip. */ fun removeChip() { /** * Hides the chip. * * @param removalReason a short string describing why the chip was removed (timeout, state * change, etc.) */ fun removeChip(removalReason: String) { // TODO(b/203800347): We may not want to hide the chip if we're currently in a // TransferTriggered state: Once the user has initiated the transfer, they should be able // to move away from the receiver device but still see the status of the transfer. if (chipView == null) { return } logger.logChipRemoval(removalReason) tapGestureDetector.removeOnGestureDetectedCallback(TAG) windowManager.removeView(chipView) chipView = null // No need to time the chip out since it's already gone cancelChipViewTimeout?.run() } /** Loading Loading @@ -136,7 +148,7 @@ abstract class MediaTttChipControllerCommon<T : MediaTttChipState>( // If the tap is within the chip bounds, we shouldn't hide the chip (in case users think the // chip is tappable). if (!viewUtil.touchIsWithinView(view, e.x, e.y)) { removeChip() removeChip(REASON_SCREEN_TAP) } } } Loading @@ -147,3 +159,6 @@ private const val WINDOW_TITLE = "Media Transfer Chip View" private val TAG = MediaTttChipControllerCommon::class.simpleName!! @VisibleForTesting const val TIMEOUT_MILLIS = 3000L private const val REASON_TIMEOUT = "TIMEOUT" private const val REASON_SCREEN_TAP = "SCREEN_TAP"