Merge "Fix Pip dependenices on TV"
This commit is contained in:
committed by
Android (Google) Code Review
commit
46b043f746
@@ -224,10 +224,11 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
|
||||
PipBoundsHandler pipBoundsHandler,
|
||||
PipTaskOrganizer pipTaskOrganizer,
|
||||
PipMediaController pipMediaController,
|
||||
PipNotification pipNotification,
|
||||
WindowManagerShellWrapper windowManagerShellWrapper) {
|
||||
mContext = context;
|
||||
mPipBoundsState = pipBoundsState;
|
||||
mPipNotification = new PipNotification(context, this);
|
||||
mPipNotification = pipNotification;
|
||||
mPipBoundsHandler = pipBoundsHandler;
|
||||
mPipMediaController = pipMediaController;
|
||||
// Ensure that we have the display info in case we get calls to update the bounds
|
||||
@@ -242,6 +243,8 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
|
||||
mPipTaskOrganizer.registerPipTransitionCallback(this);
|
||||
mActivityTaskManager = ActivityTaskManager.getService();
|
||||
|
||||
addListener(mPipNotification);
|
||||
|
||||
final IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(ACTION_CLOSE);
|
||||
intentFilter.addAction(ACTION_MENU);
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.wm.shell.R;
|
||||
import com.android.wm.shell.pip.PipMediaController;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -40,7 +41,7 @@ import java.util.Objects;
|
||||
* <p>Once it's created, it will manage the PIP notification UI by itself except for handling
|
||||
* configuration changes.
|
||||
*/
|
||||
public class PipNotification {
|
||||
public class PipNotification implements PipController.Listener {
|
||||
private static final boolean DEBUG = PipController.DEBUG;
|
||||
private static final String TAG = "PipNotification";
|
||||
|
||||
@@ -63,42 +64,7 @@ public class PipNotification {
|
||||
private String mMediaTitle;
|
||||
private Bitmap mArt;
|
||||
|
||||
private PipController.Listener mPipListener = new PipController.Listener() {
|
||||
@Override
|
||||
public void onPipEntered(String packageName) {
|
||||
mPackageName = packageName;
|
||||
notifyPipNotification();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPipActivityClosed() {
|
||||
dismissPipNotification();
|
||||
mPackageName = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowPipMenu() {
|
||||
// no-op.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPipMenuActionsChanged(ParceledListSlice<RemoteAction> actions) {
|
||||
// no-op.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoveToFullscreen() {
|
||||
dismissPipNotification();
|
||||
mPackageName = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPipResizeAboutToStart() {
|
||||
// no-op.
|
||||
}
|
||||
};
|
||||
|
||||
public PipNotification(Context context, PipController pipController) {
|
||||
public PipNotification(Context context, PipMediaController pipMediaController) {
|
||||
mPackageManager = context.getPackageManager();
|
||||
mNotificationManager = context.getSystemService(NotificationManager.class);
|
||||
|
||||
@@ -110,12 +76,44 @@ public class PipNotification {
|
||||
.setContentIntent(createPendingIntent(context, ACTION_MENU))
|
||||
.setDeleteIntent(createPendingIntent(context, ACTION_CLOSE)));
|
||||
|
||||
pipController.addListener(mPipListener);
|
||||
pipController.getPipMediaController().addMetadataListener(this::onMediaMetadataChanged);
|
||||
pipMediaController.addMetadataListener(this::onMediaMetadataChanged);
|
||||
|
||||
onConfigurationChanged(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPipEntered(String packageName) {
|
||||
mPackageName = packageName;
|
||||
notifyPipNotification();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPipActivityClosed() {
|
||||
dismissPipNotification();
|
||||
mPackageName = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowPipMenu() {
|
||||
// no-op.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPipMenuActionsChanged(ParceledListSlice<RemoteAction> actions) {
|
||||
// no-op.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoveToFullscreen() {
|
||||
dismissPipNotification();
|
||||
mPackageName = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPipResizeAboutToStart() {
|
||||
// no-op.
|
||||
}
|
||||
|
||||
private void onMediaMetadataChanged(MediaMetadata metadata) {
|
||||
if (updateMediaControllerMetadata(metadata) && mNotified) {
|
||||
// update notification
|
||||
|
||||
@@ -53,6 +53,7 @@ public abstract class TvPipModule {
|
||||
PipBoundsHandler pipBoundsHandler,
|
||||
PipTaskOrganizer pipTaskOrganizer,
|
||||
PipMediaController pipMediaController,
|
||||
PipNotification pipNotification,
|
||||
WindowManagerShellWrapper windowManagerShellWrapper) {
|
||||
return Optional.of(
|
||||
new PipController(
|
||||
@@ -61,6 +62,7 @@ public abstract class TvPipModule {
|
||||
pipBoundsHandler,
|
||||
pipTaskOrganizer,
|
||||
pipMediaController,
|
||||
pipNotification,
|
||||
windowManagerShellWrapper));
|
||||
}
|
||||
|
||||
@@ -80,8 +82,8 @@ public abstract class TvPipModule {
|
||||
@WMSingleton
|
||||
@Provides
|
||||
static PipNotification providePipNotification(Context context,
|
||||
PipController pipController) {
|
||||
return new PipNotification(context, pipController);
|
||||
PipMediaController pipMediaController) {
|
||||
return new PipNotification(context, pipMediaController);
|
||||
}
|
||||
|
||||
@WMSingleton
|
||||
|
||||
Reference in New Issue
Block a user