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

Commit edd81e4e authored by Caitlin Cassidy's avatar Caitlin Cassidy Committed by Android (Google) Code Review
Browse files

Merge changes from topics "presubmit-am-75f37079dffc432aa517bc8e4eb8269b",...

Merge changes from topics "presubmit-am-75f37079dffc432aa517bc8e4eb8269b", "presubmit-am-b883696932b4444b93bf6cb6589993f3" into tm-dev

* changes:
  [Media TTT] Don't hide the chip if we're in a transfer triggered state. Also give those states a longer timeout.
  [Media TTT] Add debug logging to the sender and receiver.
parents 98e05e00 2403c96c
Loading
Loading
Loading
Loading
+22 −0
Original line number Original line Diff line number Diff line
@@ -154,6 +154,28 @@ public class LogModule {
        return factory.create("SwipeStatusBarAwayLog", 30);
        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. */
    /** Allows logging buffers to be tweaked via adb on debug builds but not on prod builds. */
    @Provides
    @Provides
    @SysUISingleton
    @SysUISingleton
+36 −0
Original line number Original line 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 {
}
+36 −0
Original line number Original line 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 {
}
+24 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,9 @@
package com.android.systemui.media.dagger;
package com.android.systemui.media.dagger;


import com.android.systemui.dagger.SysUISingleton;
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.MediaDataManager;
import com.android.systemui.media.MediaFlags;
import com.android.systemui.media.MediaFlags;
import com.android.systemui.media.MediaHierarchyManager;
import com.android.systemui.media.MediaHierarchyManager;
@@ -27,8 +30,11 @@ import com.android.systemui.media.muteawait.MediaMuteAwaitConnectionCli;
import com.android.systemui.media.nearby.NearbyMediaDevicesManager;
import com.android.systemui.media.nearby.NearbyMediaDevicesManager;
import com.android.systemui.media.taptotransfer.MediaTttCommandLineHelper;
import com.android.systemui.media.taptotransfer.MediaTttCommandLineHelper;
import com.android.systemui.media.taptotransfer.MediaTttFlags;
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.MediaTttChipControllerReceiver;
import com.android.systemui.media.taptotransfer.receiver.MediaTttReceiverLogger;
import com.android.systemui.media.taptotransfer.sender.MediaTttChipControllerSender;
import com.android.systemui.media.taptotransfer.sender.MediaTttChipControllerSender;
import com.android.systemui.media.taptotransfer.sender.MediaTttSenderLogger;


import java.util.Optional;
import java.util.Optional;


@@ -112,6 +118,24 @@ public interface MediaModule {
        return Optional.of(controllerReceiverLazy.get());
        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
    @Provides
    @SysUISingleton
    @SysUISingleton
+22 −9
Original line number Original line Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.systemui.util.view.ViewUtil
 */
 */
abstract class MediaTttChipControllerCommon<T : MediaTttChipState>(
abstract class MediaTttChipControllerCommon<T : MediaTttChipState>(
    internal val context: Context,
    internal val context: Context,
    internal val logger: MediaTttLogger,
    private val windowManager: WindowManager,
    private val windowManager: WindowManager,
    private val viewUtil: ViewUtil,
    private val viewUtil: ViewUtil,
    @Main private val mainExecutor: DelayableExecutor,
    @Main private val mainExecutor: DelayableExecutor,
@@ -93,18 +94,26 @@ abstract class MediaTttChipControllerCommon<T : MediaTttChipState>(


        // Cancel and re-set the chip timeout each time we get a new state.
        // Cancel and re-set the chip timeout each time we get a new state.
        cancelChipViewTimeout?.run()
        cancelChipViewTimeout?.run()
        cancelChipViewTimeout = mainExecutor.executeDelayed(this::removeChip, TIMEOUT_MILLIS)
        cancelChipViewTimeout = mainExecutor.executeDelayed(
            { removeChip(MediaTttRemovalReason.REASON_TIMEOUT) },
            chipState.getTimeoutMs()
        )
    }
    }


    /** Hides the chip. */
    /**
    fun removeChip() {
     * Hides the chip.
        // 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
     * @param removalReason a short string describing why the chip was removed (timeout, state
        //  to move away from the receiver device but still see the status of the transfer.
     *     change, etc.)
     */
    open fun removeChip(removalReason: String) {
        if (chipView == null) { return }
        if (chipView == null) { return }
        logger.logChipRemoval(removalReason)
        tapGestureDetector.removeOnGestureDetectedCallback(TAG)
        tapGestureDetector.removeOnGestureDetectedCallback(TAG)
        windowManager.removeView(chipView)
        windowManager.removeView(chipView)
        chipView = null
        chipView = null
        // No need to time the chip out since it's already gone
        cancelChipViewTimeout?.run()
    }
    }


    /**
    /**
@@ -136,7 +145,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
        // If the tap is within the chip bounds, we shouldn't hide the chip (in case users think the
        // chip is tappable).
        // chip is tappable).
        if (!viewUtil.touchIsWithinView(view, e.x, e.y)) {
        if (!viewUtil.touchIsWithinView(view, e.x, e.y)) {
            removeChip()
            removeChip(MediaTttRemovalReason.REASON_SCREEN_TAP)
        }
        }
    }
    }
}
}
@@ -145,5 +154,9 @@ abstract class MediaTttChipControllerCommon<T : MediaTttChipState>(
// UpdateMediaTapToTransferReceiverDisplayTest
// UpdateMediaTapToTransferReceiverDisplayTest
private const val WINDOW_TITLE = "Media Transfer Chip View"
private const val WINDOW_TITLE = "Media Transfer Chip View"
private val TAG = MediaTttChipControllerCommon::class.simpleName!!
private val TAG = MediaTttChipControllerCommon::class.simpleName!!
@VisibleForTesting

const val TIMEOUT_MILLIS = 3000L
object MediaTttRemovalReason {
    const val REASON_TIMEOUT = "TIMEOUT"
    const val REASON_SCREEN_TAP = "SCREEN_TAP"
}
Loading