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

Commit 303c6b78 authored by Winson Chung's avatar Winson Chung
Browse files

Fix wrong bounds being used in landscape.

- Ensure we use the right display size when calculating PIP bounds.
- Also update interface to take the display id.

Test: android.server.cts.ActivityManagerPinnedStackTests
Test: #testPinnedStackDefaultBounds
Test: #testPinnedStackMovementBounds

Change-Id: I01fd8ba6dee212c29a9a092673ee8f7843e41af6
parent 2fbeaa27
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -2943,14 +2943,16 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
        }
        case GET_DEFAULT_PICTURE_IN_PICTURE_BOUNDS_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            Rect r = getDefaultPictureInPictureBounds();
            final int displayId = data.readInt();
            Rect r = getDefaultPictureInPictureBounds(displayId);
            reply.writeNoException();
            r.writeToParcel(reply, 0);
            return true;
        }
        case GET_PICTURE_IN_PICTURE_MOVEMENT_BOUNDS_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            Rect r = getPictureInPictureMovementBounds();
            final int displayId = data.readInt();
            Rect r = getPictureInPictureMovementBounds(displayId);
            reply.writeNoException();
            r.writeToParcel(reply, 0);
            return true;
@@ -7026,11 +7028,12 @@ class ActivityManagerProxy implements IActivityManager
    }

    @Override
    public Rect getDefaultPictureInPictureBounds() throws RemoteException
    public Rect getDefaultPictureInPictureBounds(int displayId) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(displayId);
        mRemote.transact(GET_DEFAULT_PICTURE_IN_PICTURE_BOUNDS_TRANSACTION, data, reply, 0);
        reply.readException();
        Rect rect = Rect.CREATOR.createFromParcel(reply);
@@ -7040,11 +7043,12 @@ class ActivityManagerProxy implements IActivityManager
    }

    @Override
    public Rect getPictureInPictureMovementBounds() throws RemoteException
    public Rect getPictureInPictureMovementBounds(int displayId) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(displayId);
        mRemote.transact(GET_PICTURE_IN_PICTURE_MOVEMENT_BOUNDS_TRANSACTION, data, reply, 0);
        reply.readException();
        Rect rect = Rect.CREATOR.createFromParcel(reply);
+2 −2
Original line number Diff line number Diff line
@@ -662,12 +662,12 @@ public interface IActivityManager extends IInterface {
    /**
     * @return the default bounds of the PIP on the default display.
     */
    public Rect getDefaultPictureInPictureBounds() throws RemoteException;
    public Rect getDefaultPictureInPictureBounds(int displayId) throws RemoteException;

    /**
     * @return the movement bounds of the PIP on the default display.
     */
    public Rect getPictureInPictureMovementBounds() throws RemoteException;
    public Rect getPictureInPictureMovementBounds(int displayId) throws RemoteException;

    public int setVrMode(IBinder token, boolean enabled, ComponentName packageName)
            throws RemoteException;
+1 −1
Original line number Diff line number Diff line
@@ -444,7 +444,7 @@ interface IWindowManager
    /**
     * Retrieves the current stable insets from the primary display.
     */
    void getStableInsets(out Rect outInsets);
    void getStableInsets(int displayId, out Rect outInsets);

    /**
     * Register shortcut key. Shortcut code is packed as:
+3 −1
Original line number Diff line number Diff line
@@ -52,7 +52,9 @@ public class PipManager {
    /**
     * Updates the PIP per configuration changed.
     */
    public void onConfigurationChanged() {}
    public void onConfigurationChanged() {
        mTouchHandler.onConfigurationChanged();
    }

    /**
     * Gets an instance of {@link PipManager}.
+10 −2
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.graphics.Rect;
import android.os.Looper;
import android.os.RemoteException;
import android.util.Log;
import android.view.Display;
import android.view.IWindowManager;
import android.view.InputChannel;
import android.view.InputEvent;
@@ -127,6 +128,10 @@ public class PipTouchHandler {
        mFlingAnimationUtils = new FlingAnimationUtils(context, 2f);
    }

    public void onConfigurationChanged() {
        updateBoundedPinnedStackBounds();
    }

    private void handleTouchEvent(MotionEvent ev) {
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN: {
@@ -326,8 +331,11 @@ public class PipTouchHandler {
    private void updateBoundedPinnedStackBounds() {
        try {
            StackInfo info = mActivityManager.getStackInfo(PINNED_STACK_ID);
            if (info != null) {
                mPinnedStackBounds.set(info.bounds);
            mBoundedPinnedStackBounds.set(mActivityManager.getPictureInPictureMovementBounds());
                mBoundedPinnedStackBounds.set(mActivityManager.getPictureInPictureMovementBounds(
                        Display.DEFAULT_DISPLAY));
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Could not fetch PIP movement bounds.", e);
        }
Loading