Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit edea2a4a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Media TTT] Remove MEDIA_TAP_TO_TRANSFER flag." into main

parents ca872048 3a81df95
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -220,10 +220,6 @@ object Flags {
    // TODO(b/293380347): Tracking Bug
    @JvmField val COLOR_FIDELITY = unreleasedFlag("color_fidelity")

    // 900 - media
    // TODO(b/254512697): Tracking Bug
    val MEDIA_TAP_TO_TRANSFER = releasedFlag("media_tap_to_transfer")

    // TODO(b/254512654): Tracking Bug
    @JvmField val DREAM_MEDIA_COMPLICATION = unreleasedFlag("dream_media_complication")

+0 −17
Original line number Diff line number Diff line
@@ -27,17 +27,12 @@ import com.android.systemui.media.controls.ui.controller.MediaHierarchyManager;
import com.android.systemui.media.controls.ui.controller.MediaHostStatesManager;
import com.android.systemui.media.controls.ui.view.MediaHost;
import com.android.systemui.media.dream.dagger.MediaComplicationComponent;
import com.android.systemui.media.taptotransfer.MediaTttCommandLineHelper;
import com.android.systemui.media.taptotransfer.MediaTttFlags;
import com.android.systemui.media.taptotransfer.receiver.MediaTttReceiverLogBuffer;
import com.android.systemui.media.taptotransfer.sender.MediaTttSenderLogBuffer;

import dagger.Lazy;
import dagger.Module;
import dagger.Provides;

import java.util.Optional;

import javax.inject.Named;

/** Dagger module for the media package. */
@@ -132,16 +127,4 @@ public interface MediaModule {
    static LogBuffer provideMediaTttReceiverLogBuffer(LogBufferFactory factory) {
        return factory.create("MediaTttReceiver", 20);
    }

    /** */
    @Provides
    @SysUISingleton
    static Optional<MediaTttCommandLineHelper> providesMediaTttCommandLineHelper(
            MediaTttFlags mediaTttFlags,
            Lazy<MediaTttCommandLineHelper> helperLazy) {
        if (!mediaTttFlags.isMediaTttEnabled()) {
            return Optional.empty();
        }
        return Optional.of(helperLazy.get());
    }
}
+0 −29
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import javax.inject.Inject

/** Flags related to media tap-to-transfer. */
@SysUISingleton
class MediaTttFlags @Inject constructor(private val featureFlags: FeatureFlags) {
    /** */
    fun isMediaTttEnabled(): Boolean = featureFlags.isEnabled(Flags.MEDIA_TAP_TO_TRANSFER)
}
+88 −84
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ import com.android.systemui.common.ui.binder.TintedIconViewBinder
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dump.DumpManager
import com.android.systemui.media.taptotransfer.MediaTttFlags
import com.android.systemui.media.taptotransfer.common.MediaTttIcon
import com.android.systemui.media.taptotransfer.common.MediaTttUtils
import com.android.systemui.res.R
@@ -68,7 +67,9 @@ import javax.inject.Inject
 * TODO(b/245610654): Re-name this to be MediaTttReceiverCoordinator.
 */
@SysUISingleton
open class MediaTttChipControllerReceiver @Inject constructor(
open class MediaTttChipControllerReceiver
@Inject
constructor(
    private val commandQueue: CommandQueue,
    context: Context,
    logger: MediaTttReceiverLogger,
@@ -79,14 +80,14 @@ open class MediaTttChipControllerReceiver @Inject constructor(
    dumpManager: DumpManager,
    powerManager: PowerManager,
    @Main private val mainHandler: Handler,
        private val mediaTttFlags: MediaTttFlags,
    private val uiEventLogger: MediaTttReceiverUiEventLogger,
    private val viewUtil: ViewUtil,
    wakeLockBuilder: WakeLock.Builder,
    systemClock: SystemClock,
    private val rippleController: MediaTttReceiverRippleController,
    private val temporaryViewUiEventLogger: TemporaryViewUiEventLogger,
) : TemporaryViewDisplayController<ChipReceiverInfo, MediaTttReceiverLogger>(
) :
    TemporaryViewDisplayController<ChipReceiverInfo, MediaTttReceiverLogger>(
        context,
        logger,
        viewCaptureAwareWindowManager,
@@ -101,31 +102,38 @@ open class MediaTttChipControllerReceiver @Inject constructor(
        temporaryViewUiEventLogger,
    ) {
    @SuppressLint("WrongConstant") // We're allowed to use LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
    override val windowLayoutParams = commonWindowLayoutParams.apply {
    override val windowLayoutParams =
        commonWindowLayoutParams.apply {
            gravity = Gravity.BOTTOM.or(Gravity.CENTER_HORIZONTAL)
            // Params below are needed for the ripple to work correctly
            width = WindowManager.LayoutParams.MATCH_PARENT
            height = WindowManager.LayoutParams.MATCH_PARENT
        layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
            layoutInDisplayCutoutMode =
                WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
            fitInsetsTypes = 0 // Ignore insets from all system bars
        }

    // Value animator that controls the bouncing animation of views.
    private val bounceAnimator = ValueAnimator.ofFloat(0f, 1f).apply {
    private val bounceAnimator =
        ValueAnimator.ofFloat(0f, 1f).apply {
            repeatCount = ValueAnimator.INFINITE
            repeatMode = ValueAnimator.REVERSE
            duration = ICON_BOUNCE_ANIM_DURATION
        }

    private val commandQueueCallbacks = object : CommandQueue.Callbacks {
    private val commandQueueCallbacks =
        object : CommandQueue.Callbacks {
            override fun updateMediaTapToTransferReceiverDisplay(
                @StatusBarManager.MediaTransferReceiverState displayState: Int,
                routeInfo: MediaRoute2Info,
                appIcon: Icon?,
            appName: CharSequence?
                appName: CharSequence?,
            ) {
                this@MediaTttChipControllerReceiver.updateMediaTapToTransferReceiverDisplay(
                displayState, routeInfo, appIcon, appName
                    displayState,
                    routeInfo,
                    appIcon,
                    appName,
                )
            }
        }
@@ -139,7 +147,7 @@ open class MediaTttChipControllerReceiver @Inject constructor(
        @StatusBarManager.MediaTransferReceiverState displayState: Int,
        routeInfo: MediaRoute2Info,
        appIcon: Icon?,
        appName: CharSequence?
        appName: CharSequence?,
    ) {
        val chipState: ChipStateReceiver? = ChipStateReceiver.getReceiverStateFromId(displayState)
        val stateName = chipState?.name ?: "Invalid"
@@ -150,8 +158,8 @@ open class MediaTttChipControllerReceiver @Inject constructor(
            return
        }

        val instanceId: InstanceId = instanceMap[routeInfo.id]
                ?: temporaryViewUiEventLogger.getNewInstanceId()
        val instanceId: InstanceId =
            instanceMap[routeInfo.id] ?: temporaryViewUiEventLogger.getNewInstanceId()
        uiEventLogger.logReceiverStateChange(chipState, instanceId)

        if (chipState != ChipStateReceiver.CLOSE_TO_SENDER) {
@@ -189,36 +197,34 @@ open class MediaTttChipControllerReceiver @Inject constructor(
            },
            // Notify the listener on the main handler since the listener will update
            // the UI.
                mainHandler
            mainHandler,
        )
    }

    override fun start() {
        super.start()
        if (mediaTttFlags.isMediaTttEnabled()) {
        commandQueue.addCallback(commandQueueCallbacks)
        }
        registerListener(displayListener)
    }

    override fun updateView(newInfo: ChipReceiverInfo, currentView: ViewGroup) {
        val packageName: String? = newInfo.routeInfo.clientPackageName
        var iconInfo = MediaTttUtils.getIconInfoFromPackageName(
            context,
            packageName,
            isReceiver = true,
        ) {
        var iconInfo =
            MediaTttUtils.getIconInfoFromPackageName(context, packageName, isReceiver = true) {
                packageName?.let { logger.logPackageNotFound(it) }
            }

        if (newInfo.appNameOverride != null) {
            iconInfo = iconInfo.copy(
                contentDescription = ContentDescription.Loaded(newInfo.appNameOverride.toString())
            iconInfo =
                iconInfo.copy(
                    contentDescription =
                        ContentDescription.Loaded(newInfo.appNameOverride.toString())
                )
        }

        if (newInfo.appIconDrawableOverride != null) {
            iconInfo = iconInfo.copy(
            iconInfo =
                iconInfo.copy(
                    icon = MediaTttIcon.Loaded(newInfo.appIconDrawableOverride),
                    isAppIcon = true,
                )
@@ -298,16 +304,14 @@ open class MediaTttChipControllerReceiver @Inject constructor(
        alphaDuration: Long = ICON_ALPHA_ANIM_DURATION,
        onAnimationEnd: Runnable? = null,
    ) {
        view.animate()
        view
            .animate()
            .translationYBy(translationYBy)
            .setInterpolator(interpolator)
            .setDuration(translationDuration)
            .withEndAction { onAnimationEnd?.run() }
            .start()
        view.animate()
            .alpha(alphaEndValue)
            .setDuration(alphaDuration)
            .start()
        view.animate().alpha(alphaEndValue).setDuration(alphaDuration).start()
    }

    /** Returns the amount that the chip will be translated by in its intro animation. */
+9 −23
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import com.android.systemui.Dumpable
import com.android.systemui.common.shared.model.Text
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
import com.android.systemui.media.taptotransfer.MediaTttFlags
import com.android.systemui.media.taptotransfer.common.MediaTttUtils
import com.android.systemui.res.R
import com.android.systemui.statusbar.CommandQueue
@@ -53,7 +52,6 @@ constructor(
    private val context: Context,
    private val dumpManager: DumpManager,
    private val logger: MediaTttSenderLogger,
    private val mediaTttFlags: MediaTttFlags,
    private val uiEventLogger: MediaTttSenderUiEventLogger,
) : CoreStartable, Dumpable {

@@ -68,27 +66,25 @@ constructor(
            override fun updateMediaTapToTransferSenderDisplay(
                @StatusBarManager.MediaTransferSenderState displayState: Int,
                routeInfo: MediaRoute2Info,
                undoCallback: IUndoMediaTransferCallback?
                undoCallback: IUndoMediaTransferCallback?,
            ) {
                this@MediaTttSenderCoordinator.updateMediaTapToTransferSenderDisplay(
                    displayState,
                    routeInfo,
                    undoCallback
                    undoCallback,
                )
            }
        }

    override fun start() {
        if (mediaTttFlags.isMediaTttEnabled()) {
        commandQueue.addCallback(commandQueueCallbacks)
        dumpManager.registerNormalDumpable(this)
    }
    }

    private fun updateMediaTapToTransferSenderDisplay(
        @StatusBarManager.MediaTransferSenderState displayState: Int,
        routeInfo: MediaRoute2Info,
        undoCallback: IUndoMediaTransferCallback?
        undoCallback: IUndoMediaTransferCallback?,
    ) {
        val chipState: ChipStateSender? = ChipStateSender.getSenderStateFromId(displayState)
        val stateName = chipState?.name ?: "Invalid"
@@ -107,7 +103,7 @@ constructor(
            // ChipStateSender.FAR_FROM_RECEIVER is the default state when there is no state.
            logger.logInvalidStateTransitionError(
                currentState = currentStateForId?.name ?: ChipStateSender.FAR_FROM_RECEIVER.name,
                chipState.name
                chipState.name,
            )
            return
        }
@@ -126,7 +122,7 @@ constructor(
                // still be able to see the status of the transfer.
                logger.logRemovalBypass(
                    removalReason,
                    bypassReason = "transferStatus=${currentStateForId.transferStatus.name}"
                    bypassReason = "transferStatus=${currentStateForId.transferStatus.name}",
                )
                return
            }
@@ -139,14 +135,7 @@ constructor(
            logger.logStateMap(stateMap)
            chipbarCoordinator.registerListener(displayListener)
            chipbarCoordinator.displayView(
                createChipbarInfo(
                    chipState,
                    routeInfo,
                    undoCallback,
                    context,
                    logger,
                    instanceId,
                )
                createChipbarInfo(chipState, routeInfo, undoCallback, context, logger, instanceId)
            )
        }
    }
@@ -245,10 +234,7 @@ constructor(
                )
            }

        return ChipbarEndItem.Button(
            Text.Resource(R.string.media_transfer_undo),
            onClickListener,
        )
        return ChipbarEndItem.Button(Text.Resource(R.string.media_transfer_undo), onClickListener)
    }

    private val displayListener =
Loading