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

Commit b5c41b78 authored by Winson Chung's avatar Winson Chung
Browse files

Adding ability for an app to request auto-enter picture-in-picture.

- If an activity requests that it can auto-enter PIP, then we will trigger
  it to enter PIP when the task is effectively being occluded.  This does
  not affect the activity when the screen is locking, or if it starts new
  activities within its own task, or if it finishes itself, or if there is
  already a PIP activity.
- Changed setPictureInPictureAspectRatio to also specify the aspect ratio
  to use when auto-entering PIP.  If the activity is not PIP'ed and has
  not requested auto-enter, then the call continues to fail.

Test: android.server.cts.ActivityManagerPinnedStackTests
Test: #testAutoEnterPictureInPicture
Test: #testAutoEnterPictureInPictureLaunchActivity
Test: #testAutoEnterPictureInPictureFinish
Test: #testAutoEnterPictureInPictureAspectRatio
Test: #testAutoEnterPictureInPictureOverPip

Change-Id: I6477b6d1f160cf0219d935123bbb505f57ee7a56
parent e6308047
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -3479,6 +3479,7 @@ package android.app {
    method public void dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
    method public void dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
    method public void enterPictureInPictureMode();
    method public void enterPictureInPictureMode();
    method public void enterPictureInPictureMode(float);
    method public void enterPictureInPictureMode(float);
    method public void enterPictureInPictureModeOnMoveToBackground(boolean);
    method public android.view.View findViewById(int);
    method public android.view.View findViewById(int);
    method public void finish();
    method public void finish();
    method public void finishActivity(int);
    method public void finishActivity(int);
+1 −0
Original line number Original line Diff line number Diff line
@@ -3596,6 +3596,7 @@ package android.app {
    method public void dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
    method public void dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
    method public void enterPictureInPictureMode();
    method public void enterPictureInPictureMode();
    method public void enterPictureInPictureMode(float);
    method public void enterPictureInPictureMode(float);
    method public void enterPictureInPictureModeOnMoveToBackground(boolean);
    method public android.view.View findViewById(int);
    method public android.view.View findViewById(int);
    method public void finish();
    method public void finish();
    method public void finishActivity(int);
    method public void finishActivity(int);
+1 −0
Original line number Original line Diff line number Diff line
@@ -3481,6 +3481,7 @@ package android.app {
    method public void dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
    method public void dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
    method public void enterPictureInPictureMode();
    method public void enterPictureInPictureMode();
    method public void enterPictureInPictureMode(float);
    method public void enterPictureInPictureMode(float);
    method public void enterPictureInPictureModeOnMoveToBackground(boolean);
    method public android.view.View findViewById(int);
    method public android.view.View findViewById(int);
    method public void finish();
    method public void finish();
    method public void finishActivity(int);
    method public void finishActivity(int);
+22 −0
Original line number Original line Diff line number Diff line
@@ -2029,6 +2029,28 @@ public class Activity extends ContextThemeWrapper
        }
        }
    }
    }


    /**
     * Requests to the system that the activity can be automatically put into picture-in-picture
     * mode when the user leaves the activity causing it normally to be hidden.  This is a *not*
     * a guarantee that the activity will actually be put in picture-in-picture mode, and depends
     * on a number of factors, including whether there is already something in picture-in-picture.
     *
     * If {@param enterPictureInPictureOnMoveToBg} is true, then you may also call
     * {@link #setPictureInPictureAspectRatio(float)} to specify the aspect ratio to automatically
     * enter picture-in-picture with.
     *
     * @param enterPictureInPictureOnMoveToBg whether or not this activity can automatically enter
     *                                     picture-in-picture
     */
    public void enterPictureInPictureModeOnMoveToBackground(
            boolean enterPictureInPictureOnMoveToBg) {
        try {
            ActivityManagerNative.getDefault().enterPictureInPictureModeOnMoveToBackground(mToken,
                    enterPictureInPictureOnMoveToBg);
        } catch (RemoteException e) {
        }
    }

    /**
    /**
     * Called by the system when the device configuration changes while your
     * Called by the system when the device configuration changes while your
     * activity is running.  Note that this will <em>only</em> be called if
     * activity is running.  Note that this will <em>only</em> be called if
+5 −3
Original line number Original line Diff line number Diff line
@@ -468,6 +468,10 @@ interface IActivityManager {
    boolean isInPictureInPictureMode(in IBinder token);
    boolean isInPictureInPictureMode(in IBinder token);
    void killPackageDependents(in String packageName, int userId);
    void killPackageDependents(in String packageName, int userId);
    void enterPictureInPictureMode(in IBinder token);
    void enterPictureInPictureMode(in IBinder token);
    void enterPictureInPictureModeWithAspectRatio(in IBinder token, float aspectRatio);
    void enterPictureInPictureModeOnMoveToBackground(in IBinder token,
            boolean enterPictureInPictureOnMoveToBg);
    void setPictureInPictureAspectRatio(in IBinder token, float aspectRatio);
    void activityRelaunched(in IBinder token);
    void activityRelaunched(in IBinder token);
    IBinder getUriPermissionOwnerForActivity(in IBinder activityToken);
    IBinder getUriPermissionOwnerForActivity(in IBinder activityToken);
    /**
    /**
@@ -568,8 +572,6 @@ interface IActivityManager {
    boolean updateDisplayOverrideConfiguration(in Configuration values, int displayId);
    boolean updateDisplayOverrideConfiguration(in Configuration values, int displayId);
    void unregisterTaskStackListener(ITaskStackListener listener);
    void unregisterTaskStackListener(ITaskStackListener listener);
    void moveStackToDisplay(int stackId, int displayId);
    void moveStackToDisplay(int stackId, int displayId);
    void enterPictureInPictureModeWithAspectRatio(in IBinder token, float aspectRatio);
    void setPictureInPictureAspectRatio(in IBinder token, float aspectRatio);
    boolean requestAutoFillData(in IResultReceiver receiver, in Bundle receiverExtras,
    boolean requestAutoFillData(in IResultReceiver receiver, in Bundle receiverExtras,
            in IBinder activityToken);
            in IBinder activityToken);
    void dismissKeyguard(in IBinder token, in IKeyguardDismissCallback callback);
    void dismissKeyguard(in IBinder token, in IKeyguardDismissCallback callback);
Loading