Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/IPip.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -75,4 +75,9 @@ interface IPip { * Sets the height and visibility of the Launcher keep clear area. */ oneway void setLauncherKeepClearAreaHeight(boolean visible, int height) = 6; /** * Sets the app icon size in pixel used by Launcher */ oneway void setLauncherAppIconSize(int iconSizePx) = 7; } libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java +3 −2 Original line number Diff line number Diff line Loading @@ -371,10 +371,11 @@ public class PipAnimationController { new PipContentOverlay.PipSnapshotOverlay(snapshot, sourceRectHint)); } void setAppIconContentOverlay(Context context, Rect bounds, ActivityInfo activityInfo) { void setAppIconContentOverlay(Context context, Rect bounds, ActivityInfo activityInfo, int appIconSizePx) { reattachContentOverlay( new PipContentOverlay.PipAppIconOverlay(context, bounds, () -> new IconProvider(context).getIcon(activityInfo))); new IconProvider(context).getIcon(activityInfo), appIconSizePx)); } private void reattachContentOverlay(PipContentOverlay overlay) { Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipBoundsState.java +25 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ public class PipBoundsState { private int mStashedState = STASH_TYPE_NONE; private int mStashOffset; private @Nullable PipReentryState mPipReentryState; private final LauncherState mLauncherState = new LauncherState(); private final @Nullable PipSizeSpecHandler mPipSizeSpecHandler; private @Nullable ComponentName mLastPipComponentName; private int mDisplayId = Display.DEFAULT_DISPLAY; Loading Loading @@ -497,6 +498,10 @@ public class PipBoundsState { mOnPipExclusionBoundsChangeCallbacks.remove(onPipExclusionBoundsChangeCallback); } public LauncherState getLauncherState() { return mLauncherState; } /** Source of truth for the current bounds of PIP that may be in motion. */ public static class MotionBoundsState { /** The bounds used when PIP is in motion (e.g. during a drag or animation) */ Loading Loading @@ -549,6 +554,25 @@ public class PipBoundsState { } } /** Data class for Launcher state. */ public static final class LauncherState { private int mAppIconSizePx; public void setAppIconSizePx(int appIconSizePx) { mAppIconSizePx = appIconSizePx; } public int getAppIconSizePx() { return mAppIconSizePx; } void dump(PrintWriter pw, String prefix) { final String innerPrefix = prefix + " "; pw.println(prefix + LauncherState.class.getSimpleName()); pw.println(innerPrefix + "getAppIconSizePx=" + getAppIconSizePx()); } } static final class PipReentryState { private static final String TAG = PipReentryState.class.getSimpleName(); Loading Loading @@ -603,6 +627,7 @@ public class PipBoundsState { } else { mPipReentryState.dump(pw, innerPrefix); } mLauncherState.dump(pw, innerPrefix); mMotionBoundsState.dump(pw, innerPrefix); } } libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipContentOverlay.java +9 −11 Original line number Diff line number Diff line Loading @@ -32,8 +32,6 @@ import android.view.SurfaceControl; import android.view.SurfaceSession; import android.window.TaskSnapshot; import java.util.function.Supplier; /** * Represents the content overlay used during the entering PiP animation. */ Loading Loading @@ -176,9 +174,8 @@ public abstract class PipContentOverlay { /** A {@link PipContentOverlay} shows app icon on solid color background. */ public static final class PipAppIconOverlay extends PipContentOverlay { private static final String TAG = PipAppIconOverlay.class.getSimpleName(); // Align with the practical / reasonable launcher:iconImageSize as in // vendor/unbundled_google/packages/NexusLauncher/res/xml/device_profiles.xml private static final int APP_ICON_SIZE_DP = 66; // The maximum size for app icon in pixel. private static final int MAX_APP_ICON_SIZE_DP = 72; private final Context mContext; private final int mAppIconSizePx; Loading @@ -188,14 +185,16 @@ public abstract class PipContentOverlay { private Bitmap mBitmap; public PipAppIconOverlay(Context context, Rect appBounds, Supplier<Drawable> iconSupplier) { public PipAppIconOverlay(Context context, Rect appBounds, Drawable appIcon, int appIconSizePx) { mContext = context; mAppIconSizePx = (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, APP_ICON_SIZE_DP, context.getResources().getDisplayMetrics()); final int maxAppIconSizePx = (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, MAX_APP_ICON_SIZE_DP, context.getResources().getDisplayMetrics()); mAppIconSizePx = Math.min(maxAppIconSizePx, appIconSizePx); mAppBounds = new Rect(appBounds); mBitmap = Bitmap.createBitmap(appBounds.width(), appBounds.height(), Bitmap.Config.ARGB_8888); prepareAppIconOverlay(iconSupplier); prepareAppIconOverlay(appIcon); mLeash = new SurfaceControl.Builder(new SurfaceSession()) .setCallsite(TAG) .setName(LAYER_NAME) Loading Loading @@ -238,7 +237,7 @@ public abstract class PipContentOverlay { } } private void prepareAppIconOverlay(Supplier<Drawable> iconSupplier) { private void prepareAppIconOverlay(Drawable appIcon) { final Canvas canvas = new Canvas(); canvas.setBitmap(mBitmap); final TypedArray ta = mContext.obtainStyledAttributes(new int[] { Loading @@ -252,7 +251,6 @@ public abstract class PipContentOverlay { } finally { ta.recycle(); } final Drawable appIcon = iconSupplier.get(); final Rect appIconBounds = new Rect( mAppBounds.centerX() - mAppIconSizePx / 2, mAppBounds.centerY() - mAppIconSizePx / 2, Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +2 −1 Original line number Diff line number Diff line Loading @@ -1610,7 +1610,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, if (SystemProperties.getBoolean( "persist.wm.debug.enable_pip_app_icon_overlay", true)) { animator.setAppIconContentOverlay( mContext, currentBounds, mTaskInfo.topActivityInfo); mContext, currentBounds, mTaskInfo.topActivityInfo, mPipBoundsState.getLauncherState().getAppIconSizePx()); } else { animator.setColorContentOverlay(mContext); } Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/IPip.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -75,4 +75,9 @@ interface IPip { * Sets the height and visibility of the Launcher keep clear area. */ oneway void setLauncherKeepClearAreaHeight(boolean visible, int height) = 6; /** * Sets the app icon size in pixel used by Launcher */ oneway void setLauncherAppIconSize(int iconSizePx) = 7; }
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java +3 −2 Original line number Diff line number Diff line Loading @@ -371,10 +371,11 @@ public class PipAnimationController { new PipContentOverlay.PipSnapshotOverlay(snapshot, sourceRectHint)); } void setAppIconContentOverlay(Context context, Rect bounds, ActivityInfo activityInfo) { void setAppIconContentOverlay(Context context, Rect bounds, ActivityInfo activityInfo, int appIconSizePx) { reattachContentOverlay( new PipContentOverlay.PipAppIconOverlay(context, bounds, () -> new IconProvider(context).getIcon(activityInfo))); new IconProvider(context).getIcon(activityInfo), appIconSizePx)); } private void reattachContentOverlay(PipContentOverlay overlay) { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipBoundsState.java +25 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ public class PipBoundsState { private int mStashedState = STASH_TYPE_NONE; private int mStashOffset; private @Nullable PipReentryState mPipReentryState; private final LauncherState mLauncherState = new LauncherState(); private final @Nullable PipSizeSpecHandler mPipSizeSpecHandler; private @Nullable ComponentName mLastPipComponentName; private int mDisplayId = Display.DEFAULT_DISPLAY; Loading Loading @@ -497,6 +498,10 @@ public class PipBoundsState { mOnPipExclusionBoundsChangeCallbacks.remove(onPipExclusionBoundsChangeCallback); } public LauncherState getLauncherState() { return mLauncherState; } /** Source of truth for the current bounds of PIP that may be in motion. */ public static class MotionBoundsState { /** The bounds used when PIP is in motion (e.g. during a drag or animation) */ Loading Loading @@ -549,6 +554,25 @@ public class PipBoundsState { } } /** Data class for Launcher state. */ public static final class LauncherState { private int mAppIconSizePx; public void setAppIconSizePx(int appIconSizePx) { mAppIconSizePx = appIconSizePx; } public int getAppIconSizePx() { return mAppIconSizePx; } void dump(PrintWriter pw, String prefix) { final String innerPrefix = prefix + " "; pw.println(prefix + LauncherState.class.getSimpleName()); pw.println(innerPrefix + "getAppIconSizePx=" + getAppIconSizePx()); } } static final class PipReentryState { private static final String TAG = PipReentryState.class.getSimpleName(); Loading Loading @@ -603,6 +627,7 @@ public class PipBoundsState { } else { mPipReentryState.dump(pw, innerPrefix); } mLauncherState.dump(pw, innerPrefix); mMotionBoundsState.dump(pw, innerPrefix); } }
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipContentOverlay.java +9 −11 Original line number Diff line number Diff line Loading @@ -32,8 +32,6 @@ import android.view.SurfaceControl; import android.view.SurfaceSession; import android.window.TaskSnapshot; import java.util.function.Supplier; /** * Represents the content overlay used during the entering PiP animation. */ Loading Loading @@ -176,9 +174,8 @@ public abstract class PipContentOverlay { /** A {@link PipContentOverlay} shows app icon on solid color background. */ public static final class PipAppIconOverlay extends PipContentOverlay { private static final String TAG = PipAppIconOverlay.class.getSimpleName(); // Align with the practical / reasonable launcher:iconImageSize as in // vendor/unbundled_google/packages/NexusLauncher/res/xml/device_profiles.xml private static final int APP_ICON_SIZE_DP = 66; // The maximum size for app icon in pixel. private static final int MAX_APP_ICON_SIZE_DP = 72; private final Context mContext; private final int mAppIconSizePx; Loading @@ -188,14 +185,16 @@ public abstract class PipContentOverlay { private Bitmap mBitmap; public PipAppIconOverlay(Context context, Rect appBounds, Supplier<Drawable> iconSupplier) { public PipAppIconOverlay(Context context, Rect appBounds, Drawable appIcon, int appIconSizePx) { mContext = context; mAppIconSizePx = (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, APP_ICON_SIZE_DP, context.getResources().getDisplayMetrics()); final int maxAppIconSizePx = (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, MAX_APP_ICON_SIZE_DP, context.getResources().getDisplayMetrics()); mAppIconSizePx = Math.min(maxAppIconSizePx, appIconSizePx); mAppBounds = new Rect(appBounds); mBitmap = Bitmap.createBitmap(appBounds.width(), appBounds.height(), Bitmap.Config.ARGB_8888); prepareAppIconOverlay(iconSupplier); prepareAppIconOverlay(appIcon); mLeash = new SurfaceControl.Builder(new SurfaceSession()) .setCallsite(TAG) .setName(LAYER_NAME) Loading Loading @@ -238,7 +237,7 @@ public abstract class PipContentOverlay { } } private void prepareAppIconOverlay(Supplier<Drawable> iconSupplier) { private void prepareAppIconOverlay(Drawable appIcon) { final Canvas canvas = new Canvas(); canvas.setBitmap(mBitmap); final TypedArray ta = mContext.obtainStyledAttributes(new int[] { Loading @@ -252,7 +251,6 @@ public abstract class PipContentOverlay { } finally { ta.recycle(); } final Drawable appIcon = iconSupplier.get(); final Rect appIconBounds = new Rect( mAppBounds.centerX() - mAppIconSizePx / 2, mAppBounds.centerY() - mAppIconSizePx / 2, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +2 −1 Original line number Diff line number Diff line Loading @@ -1610,7 +1610,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, if (SystemProperties.getBoolean( "persist.wm.debug.enable_pip_app_icon_overlay", true)) { animator.setAppIconContentOverlay( mContext, currentBounds, mTaskInfo.topActivityInfo); mContext, currentBounds, mTaskInfo.topActivityInfo, mPipBoundsState.getLauncherState().getAppIconSizePx()); } else { animator.setColorContentOverlay(mContext); } Loading