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

Commit 918e1e01 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "6/ Update pip to use shell main thread" into sc-dev

parents 3f08df9f d19e69d0
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -472,11 +472,6 @@ class PhysicsAnimator<T> private constructor (target: T) {
     * animator is under test.
     */
    internal fun startInternal() {
        if (!Looper.getMainLooper().isCurrentThread) {
            Log.e(TAG, "Animations can only be started on the main thread. If you are seeing " +
                    "this message in a test, call PhysicsAnimatorTestUtils#prepareForTest in " +
                    "your test setup.")
        }
        val target = weakTarget.get()
        if (target == null) {
            Log.w(TAG, "Trying to animate a GC-ed object.")
+8 −3
Original line number Diff line number Diff line
@@ -17,10 +17,15 @@
package com.android.wm.shell.common;

import android.os.Looper;
import android.os.SystemClock;
import android.os.Trace;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.function.BooleanSupplier;
import java.util.function.Predicate;
import java.util.function.Supplier;

/**
 * Super basic Executor interface that adds support for delayed execution and removing callbacks.
@@ -65,17 +70,17 @@ public interface ShellExecutor extends Executor {
    /**
     * See {@link android.os.Handler#postDelayed(Runnable, long)}.
     */
    void executeDelayed(Runnable r, long delayMillis);
    void executeDelayed(Runnable runnable, long delayMillis);

    /**
     * See {@link android.os.Handler#removeCallbacks}.
     */
    void removeCallbacks(Runnable r);
    void removeCallbacks(Runnable runnable);

    /**
     * See {@link android.os.Handler#hasCallbacks(Runnable)}.
     */
    boolean hasCallback(Runnable r);
    boolean hasCallback(Runnable runnable);

    /**
     * Returns the looper that this executor is running on.
+10 −63
Original line number Diff line number Diff line
@@ -34,54 +34,17 @@ import java.util.function.Consumer;
 */
@ExternalThread
public interface Pip {
    /**
     * Closes PIP (PIPed activity and PIP system UI).
     */
    default void closePip() {
    }

    /**
     * Dump the current state and information if need.
     *
     * @param pw The stream to dump information to.
     */
    default void dump(PrintWriter pw) {
    }

    /**
     * Expand PIP, it's possible that specific request to activate the window via Alt-tab.
     */
    default void expandPip() {
    }

    /**
     * Get the touch handler which manages all the touch handling for PIP on the Phone,
     * including moving, dismissing and expanding the PIP. (Do not use in TV)
     *
     * @return
     */
    default @Nullable PipTouchHandler getPipTouchHandler() {
        return null;
    }

    /**
     * Hides the PIP menu.
     */
    default void hidePipMenu(Runnable onStartCallback, Runnable onEndCallback) {}

    /**
     * Returns {@code true} if PIP is shown.
     */
    default boolean isPipShown() {
        return false;
    }

    /**
     * Moves the PIPed activity to the fullscreen and closes PIP system UI.
     */
    default void movePipToFullscreen() {
    }

    /**
     * Called when configuration is changed.
     */
@@ -100,12 +63,6 @@ public interface Pip {
    default void onOverlayChanged() {
    }

    /**
     * Registers the session listener for the current user.
     */
    default void registerSessionListenerForCurrentUser() {
    }

    /**
     * Called when SysUI state changed.
     *
@@ -116,19 +73,9 @@ public interface Pip {
    }

    /**
     * Resize the Pip to the appropriate size for the input state.
     *
     * @param state In Pip state also used to determine the new size for the Pip.
     */
    default void resizePinnedStack(int state) {
    }

    /**
     * Resumes resizing operation on the Pip that was previously suspended.
     *
     * @param reason The reason resizing operations on the Pip was suspended.
     * Registers the session listener for the current user.
     */
    default void resumePipResizing(int reason) {
    default void registerSessionListenerForCurrentUser() {
    }

    /**
@@ -161,14 +108,6 @@ public interface Pip {
     */
    default void showPictureInPictureMenu() {}

    /**
     * Suspends resizing operation on the Pip until {@link #resumePipResizing} is called.
     *
     * @param reason The reason for suspending resizing operations on the Pip.
     */
    default void suspendPipResizing(int reason) {
    }

    /**
     * Called by Launcher when swiping an auto-pip enabled Activity to home starts
     * @param componentName {@link ComponentName} represents the Activity entering PiP
@@ -199,4 +138,12 @@ public interface Pip {
     * PiP and the Back-from-Edge gesture.
     */
    default void setPipExclusionBoundsChangeListener(Consumer<Rect> listener) { }

    /**
     * Dump the current state and information if need.
     *
     * @param pw The stream to dump information to.
     */
    default void dump(PrintWriter pw) {
    }
}
+8 −5
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.media.MediaMetadata;
import android.media.session.MediaController;
import android.media.session.MediaSessionManager;
import android.media.session.PlaybackState;
import android.os.Handler;
import android.os.UserHandle;

import androidx.annotation.Nullable;
@@ -74,6 +75,7 @@ public class PipMediaController {
    }

    private final Context mContext;
    private final Handler mMainHandler;

    private final MediaSessionManager mMediaSessionManager;
    private MediaController mMediaController;
@@ -118,15 +120,16 @@ public class PipMediaController {
    private final ArrayList<ActionListener> mActionListeners = new ArrayList<>();
    private final ArrayList<MetadataListener> mMetadataListeners = new ArrayList<>();

    public PipMediaController(Context context) {
    public PipMediaController(Context context, Handler mainHandler) {
        mContext = context;
        mMainHandler = mainHandler;
        IntentFilter mediaControlFilter = new IntentFilter();
        mediaControlFilter.addAction(ACTION_PLAY);
        mediaControlFilter.addAction(ACTION_PAUSE);
        mediaControlFilter.addAction(ACTION_NEXT);
        mediaControlFilter.addAction(ACTION_PREV);
        mContext.registerReceiver(mPlayPauseActionReceiver, mediaControlFilter,
                UserHandle.USER_ALL);
        mContext.registerReceiverForAllUsers(mPlayPauseActionReceiver, mediaControlFilter,
                null /* permission */, mainHandler);

        createMediaActions();
        mMediaSessionManager = context.getSystemService(MediaSessionManager.class);
@@ -245,7 +248,7 @@ public class PipMediaController {
    public void registerSessionListenerForCurrentUser() {
        mMediaSessionManager.removeOnActiveSessionsChangedListener(mSessionsChangedListener);
        mMediaSessionManager.addOnActiveSessionsChangedListener(mSessionsChangedListener, null,
                UserHandle.CURRENT, null);
                UserHandle.CURRENT, mMainHandler);
    }

    /**
@@ -277,7 +280,7 @@ public class PipMediaController {
            }
            mMediaController = controller;
            if (controller != null) {
                controller.registerCallback(mPlaybackChangedListener);
                controller.registerCallback(mPlaybackChangedListener, mMainHandler);
            }
            notifyActionsChanged();
            notifyMetadataChanged(getMediaMetadata());
+103 −224

File changed.

Preview size limit exceeded, changes collapsed.

Loading