Move PipMediaController from pip/phone/ to pip/

Move PipMediaContoller from com.android.wm.shell.pip.phone to
com.android.wm.shell.pip.
Since PipMediaController relies on the PipUtils, move that along.

Bug: 169575409
Bug: 165795012
Test: make WindowManager-Shell
Change-Id: Ide2dfd813eb8df906b58f50e1ed9b57a62d63dbc
This commit is contained in:
Sergey Nikolaienkov
2020-10-27 12:32:31 +00:00
parent 898168cb24
commit ca3aa40238
10 changed files with 25 additions and 24 deletions

View File

@@ -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);

View File

@@ -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(

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -32,7 +32,6 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.ActivityManager;
import android.app.PendingIntent.CanceledException;
import android.app.RemoteAction;
import android.content.ComponentName;
@@ -61,6 +60,7 @@ import android.widget.LinearLayout;
import com.android.wm.shell.R;
import com.android.wm.shell.animation.Interpolators;
import com.android.wm.shell.pip.PipUtils;
import java.util.ArrayList;
import java.util.List;
@@ -452,7 +452,7 @@ public class PipMenuView extends FrameLayout {
private void showSettings() {
final Pair<ComponentName, Integer> topPipActivityInfo =
PipUtils.getTopPipActivity(mContext, ActivityManager.getService());
PipUtils.getTopPipActivity(mContext);
if (topPipActivityInfo.first != null) {
final Intent settingsIntent = new Intent(ACTION_PICTURE_IN_PICTURE_SETTINGS,
Uri.fromParts("package", topPipActivityInfo.first.getPackageName(), null));

View File

@@ -36,6 +36,7 @@ import com.android.wm.shell.WindowManagerShellWrapper;
import com.android.wm.shell.common.DisplayController;
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 com.android.wm.shell.pip.PipTestCase;

View File

@@ -71,7 +71,7 @@ import com.android.wm.shell.onehanded.OneHandedEvents;
import com.android.wm.shell.onehanded.OneHandedGestureHandler.OneHandedGestureEventCallback;
import com.android.wm.shell.onehanded.OneHandedTransitionCallback;
import com.android.wm.shell.pip.Pip;
import com.android.wm.shell.pip.phone.PipUtils;
import com.android.wm.shell.pip.PipUtils;
import com.android.wm.shell.protolog.ShellProtoLogImpl;
import com.android.wm.shell.splitscreen.SplitScreen;
@@ -211,8 +211,7 @@ public final class WMShell extends SystemUI
@Override
public void onActivityUnpinned() {
final Pair<ComponentName, Integer> topPipActivityInfo =
PipUtils.getTopPipActivity(
mContext, ActivityManager.getService());
PipUtils.getTopPipActivity(mContext);
final ComponentName topActivity = topPipActivityInfo.first;
pip.onActivityUnpinned(topActivity);
mInputConsumerController.unregisterInputConsumer();

View File

@@ -41,10 +41,10 @@ import com.android.wm.shell.draganddrop.DragAndDropController;
import com.android.wm.shell.onehanded.OneHanded;
import com.android.wm.shell.onehanded.OneHandedController;
import com.android.wm.shell.pip.Pip;
import com.android.wm.shell.pip.PipMediaController;
import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
import com.android.wm.shell.pip.PipUiEventLogger;
import com.android.wm.shell.pip.phone.PipAppOpsListener;
import com.android.wm.shell.pip.phone.PipMediaController;
import com.android.wm.shell.pip.phone.PipTouchHandler;
import com.android.wm.shell.splitscreen.SplitScreen;

View File

@@ -33,12 +33,12 @@ import com.android.wm.shell.common.TransactionPool;
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.PipSurfaceTransactionHelper;
import com.android.wm.shell.pip.PipTaskOrganizer;
import com.android.wm.shell.pip.PipUiEventLogger;
import com.android.wm.shell.pip.phone.PipAppOpsListener;
import com.android.wm.shell.pip.phone.PipController;
import com.android.wm.shell.pip.phone.PipMediaController;
import com.android.wm.shell.pip.phone.PipMenuActivityController;
import com.android.wm.shell.pip.phone.PipTouchHandler;
import com.android.wm.shell.splitscreen.SplitScreen;