Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,8 @@ public class PipManager implements BasePipManager { mTouchHandler.onActivityPinned(); mMediaController.onActivityPinned(); mMenuController.onActivityPinned(); mNotificationController.onActivityPinned(packageName); mNotificationController.onActivityPinned(packageName, true /* deferUntilAnimationEnds */); SystemServicesProxy.getInstance(mContext).setPipVisibility(true); } Loading Loading @@ -104,6 +105,7 @@ public class PipManager implements BasePipManager { mTouchHandler.setTouchEnabled(true); mTouchHandler.onPinnedStackAnimationEnded(); mMenuController.onPinnedStackAnimationEnded(); mNotificationController.onPinnedStackAnimationEnded(); } @Override Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipNotificationController.java +41 −15 Original line number Diff line number Diff line Loading @@ -60,6 +60,9 @@ public class PipNotificationController { private PipMotionHelper mMotionHelper; // Used when building a deferred notification private String mDeferredNotificationPackageName; private AppOpsManager.OnOpChangedListener mAppOpsChangedListener = new OnOpChangedListener() { @Override public void onOpChanged(String op, String packageName) { Loading Loading @@ -87,40 +90,63 @@ public class PipNotificationController { mMotionHelper = motionHelper; } public void onActivityPinned(String packageName) { public void onActivityPinned(String packageName, boolean deferUntilAnimationEnds) { // Clear any existing notification mNotificationManager.cancel(NOTIFICATION_TAG, NOTIFICATION_ID); // Build a new notification final Notification.Builder builder = new Notification.Builder(mContext, NotificationChannels.GENERAL) .setLocalOnly(true) .setOngoing(true) .setSmallIcon(R.drawable.pip_notification_icon) .setColor(mContext.getColor( com.android.internal.R.color.system_notification_accent_color)); if (updateNotificationForApp(builder, packageName)) { SystemUI.overrideNotificationAppName(mContext, builder); // Show the new notification mNotificationManager.notify(NOTIFICATION_TAG, NOTIFICATION_ID, builder.build()); if (deferUntilAnimationEnds) { mDeferredNotificationPackageName = packageName; } else { showNotificationForApp(mDeferredNotificationPackageName); } // Register for changes to the app ops setting for this package while it is in PiP registerAppOpsListener(packageName); } public void onPinnedStackAnimationEnded() { if (mDeferredNotificationPackageName != null) { showNotificationForApp(mDeferredNotificationPackageName); mDeferredNotificationPackageName = null; } } public void onActivityUnpinned(ComponentName topPipActivity) { // Unregister for changes to the previously PiP'ed package unregisterAppOpsListener(); // Reset the deferred notification package mDeferredNotificationPackageName = null; if (topPipActivity != null) { onActivityPinned(topPipActivity.getPackageName()); // onActivityUnpinned() is only called after the transition is complete, so we don't // need to defer until the animation ends to update the notification onActivityPinned(topPipActivity.getPackageName(), false /* deferUntilAnimationEnds */); } else { mNotificationManager.cancel(NOTIFICATION_TAG, NOTIFICATION_ID); } } /** * Builds and shows the notification for the given app. */ private void showNotificationForApp(String packageName) { // Build a new notification final Notification.Builder builder = new Notification.Builder(mContext, NotificationChannels.GENERAL) .setLocalOnly(true) .setOngoing(true) .setSmallIcon(R.drawable.pip_notification_icon) .setColor(mContext.getColor( com.android.internal.R.color.system_notification_accent_color)); if (updateNotificationForApp(builder, packageName)) { SystemUI.overrideNotificationAppName(mContext, builder); // Show the new notification mNotificationManager.notify(NOTIFICATION_TAG, NOTIFICATION_ID, builder.build()); } } /** * Updates the notification builder with app-specific information, returning whether it was * successful. Loading Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,8 @@ public class PipManager implements BasePipManager { mTouchHandler.onActivityPinned(); mMediaController.onActivityPinned(); mMenuController.onActivityPinned(); mNotificationController.onActivityPinned(packageName); mNotificationController.onActivityPinned(packageName, true /* deferUntilAnimationEnds */); SystemServicesProxy.getInstance(mContext).setPipVisibility(true); } Loading Loading @@ -104,6 +105,7 @@ public class PipManager implements BasePipManager { mTouchHandler.setTouchEnabled(true); mTouchHandler.onPinnedStackAnimationEnded(); mMenuController.onPinnedStackAnimationEnded(); mNotificationController.onPinnedStackAnimationEnded(); } @Override Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipNotificationController.java +41 −15 Original line number Diff line number Diff line Loading @@ -60,6 +60,9 @@ public class PipNotificationController { private PipMotionHelper mMotionHelper; // Used when building a deferred notification private String mDeferredNotificationPackageName; private AppOpsManager.OnOpChangedListener mAppOpsChangedListener = new OnOpChangedListener() { @Override public void onOpChanged(String op, String packageName) { Loading Loading @@ -87,40 +90,63 @@ public class PipNotificationController { mMotionHelper = motionHelper; } public void onActivityPinned(String packageName) { public void onActivityPinned(String packageName, boolean deferUntilAnimationEnds) { // Clear any existing notification mNotificationManager.cancel(NOTIFICATION_TAG, NOTIFICATION_ID); // Build a new notification final Notification.Builder builder = new Notification.Builder(mContext, NotificationChannels.GENERAL) .setLocalOnly(true) .setOngoing(true) .setSmallIcon(R.drawable.pip_notification_icon) .setColor(mContext.getColor( com.android.internal.R.color.system_notification_accent_color)); if (updateNotificationForApp(builder, packageName)) { SystemUI.overrideNotificationAppName(mContext, builder); // Show the new notification mNotificationManager.notify(NOTIFICATION_TAG, NOTIFICATION_ID, builder.build()); if (deferUntilAnimationEnds) { mDeferredNotificationPackageName = packageName; } else { showNotificationForApp(mDeferredNotificationPackageName); } // Register for changes to the app ops setting for this package while it is in PiP registerAppOpsListener(packageName); } public void onPinnedStackAnimationEnded() { if (mDeferredNotificationPackageName != null) { showNotificationForApp(mDeferredNotificationPackageName); mDeferredNotificationPackageName = null; } } public void onActivityUnpinned(ComponentName topPipActivity) { // Unregister for changes to the previously PiP'ed package unregisterAppOpsListener(); // Reset the deferred notification package mDeferredNotificationPackageName = null; if (topPipActivity != null) { onActivityPinned(topPipActivity.getPackageName()); // onActivityUnpinned() is only called after the transition is complete, so we don't // need to defer until the animation ends to update the notification onActivityPinned(topPipActivity.getPackageName(), false /* deferUntilAnimationEnds */); } else { mNotificationManager.cancel(NOTIFICATION_TAG, NOTIFICATION_ID); } } /** * Builds and shows the notification for the given app. */ private void showNotificationForApp(String packageName) { // Build a new notification final Notification.Builder builder = new Notification.Builder(mContext, NotificationChannels.GENERAL) .setLocalOnly(true) .setOngoing(true) .setSmallIcon(R.drawable.pip_notification_icon) .setColor(mContext.getColor( com.android.internal.R.color.system_notification_accent_color)); if (updateNotificationForApp(builder, packageName)) { SystemUI.overrideNotificationAppName(mContext, builder); // Show the new notification mNotificationManager.notify(NOTIFICATION_TAG, NOTIFICATION_ID, builder.build()); } } /** * Updates the notification builder with app-specific information, returning whether it was * successful. Loading