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

Commit 805dcb44 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move PipMediaController from pip/phone/ to pip/"

parents ee5d3693 ca3aa402
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.wm.shell.pip.phone;
package com.android.wm.shell.pip;

import static android.app.PendingIntent.FLAG_IMMUTABLE;
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
@@ -46,10 +46,10 @@ import java.util.List;
 */
public class PipMediaController {

    private static final String ACTION_PLAY = "com.android.wm.shell.pip.phone.PLAY";
    private static final String ACTION_PAUSE = "com.android.wm.shell.pip.phone.PAUSE";
    private static final String ACTION_NEXT = "com.android.wm.shell.pip.phone.NEXT";
    private static final String ACTION_PREV = "com.android.wm.shell.pip.phone.PREV";
    private static final String ACTION_PLAY = "com.android.wm.shell.pip.PLAY";
    private static final String ACTION_PAUSE = "com.android.wm.shell.pip.PAUSE";
    private static final String ACTION_NEXT = "com.android.wm.shell.pip.NEXT";
    private static final String ACTION_PREV = "com.android.wm.shell.pip.PREV";

    /**
     * A listener interface to receive notification on changes to the media actions.
@@ -113,8 +113,7 @@ public class PipMediaController {
                UserHandle.USER_ALL);

        createMediaActions();
        mMediaSessionManager =
                (MediaSessionManager) context.getSystemService(Context.MEDIA_SESSION_SERVICE);
        mMediaSessionManager = context.getSystemService(MediaSessionManager.class);
    }

    /**
@@ -140,7 +139,7 @@ public class PipMediaController {
     * Removes a media action listener.
     */
    public void removeListener(ActionListener listener) {
        listener.onMediaActionsChanged(Collections.EMPTY_LIST);
        listener.onMediaActionsChanged(Collections.emptyList());
        mListeners.remove(listener);
    }

@@ -149,7 +148,7 @@ public class PipMediaController {
     */
    private List<RemoteAction> getMediaActions() {
        if (mMediaController == null || mMediaController.getPlaybackState() == null) {
            return Collections.EMPTY_LIST;
            return Collections.emptyList();
        }

        ArrayList<RemoteAction> mediaActions = new ArrayList<>();
@@ -216,8 +215,7 @@ public class PipMediaController {
     */
    private void resolveActiveMediaController(List<MediaController> controllers) {
        if (controllers != null) {
            final ComponentName topActivity = PipUtils.getTopPipActivity(mContext,
                    mActivityManager).first;
            final ComponentName topActivity = PipUtils.getTopPipActivity(mContext).first;
            if (topActivity != null) {
                for (int i = 0; i < controllers.size(); i++) {
                    final MediaController controller = controllers.get(i);
+3 −4
Original line number Diff line number Diff line
@@ -14,20 +14,20 @@
 * limitations under the License.
 */

package com.android.wm.shell.pip.phone;
package com.android.wm.shell.pip;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;

import android.app.ActivityTaskManager;
import android.app.ActivityTaskManager.RootTaskInfo;
import android.app.IActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.os.RemoteException;
import android.util.Log;
import android.util.Pair;

/** A class that includes convenience methods. */
public class PipUtils {
    private static final String TAG = "PipUtils";

@@ -35,8 +35,7 @@ public class PipUtils {
     * @return the ComponentName and user id of the top non-SystemUI activity in the pinned stack.
     * The component name may be null if no such activity exists.
     */
    public static Pair<ComponentName, Integer> getTopPipActivity(Context context,
            IActivityManager activityManager) {
    public static Pair<ComponentName, Integer> getTopPipActivity(Context context) {
        try {
            final String sysUiPackageName = context.getPackageName();
            final RootTaskInfo pinnedTaskInfo = ActivityTaskManager.getService().getRootTaskInfo(
+3 −1
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Handler;
import android.util.Pair;

import com.android.wm.shell.pip.PipUtils;

public class PipAppOpsListener {
    private static final String TAG = PipAppOpsListener.class.getSimpleName();

@@ -44,7 +46,7 @@ public class PipAppOpsListener {
            try {
                // Dismiss the PiP once the user disables the app ops setting for that package
                final Pair<ComponentName, Integer> topPipActivityInfo =
                        PipUtils.getTopPipActivity(mContext, mActivityManager);
                        PipUtils.getTopPipActivity(mContext);
                if (topPipActivityInfo.first != null) {
                    final ApplicationInfo appInfo = mContext.getPackageManager()
                            .getApplicationInfoAsUser(packageName, 0, topPipActivityInfo.second);
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.wm.shell.pip.PinnedStackListenerForwarder;
import com.android.wm.shell.pip.Pip;
import com.android.wm.shell.pip.PipBoundsHandler;
import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipMediaController;
import com.android.wm.shell.pip.PipTaskOrganizer;

import java.io.PrintWriter;
+2 −1
Original line number Diff line number Diff line
@@ -34,8 +34,9 @@ import android.view.MotionEvent;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;

import com.android.wm.shell.pip.PipMediaController;
import com.android.wm.shell.pip.PipMediaController.ActionListener;
import com.android.wm.shell.pip.PipTaskOrganizer;
import com.android.wm.shell.pip.phone.PipMediaController.ActionListener;

import java.io.PrintWriter;
import java.util.ArrayList;
Loading