Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java +65 −2 Original line number Diff line number Diff line Loading @@ -27,10 +27,12 @@ import android.app.Notification; import android.app.WallpaperManager; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.hardware.display.DisplayManager; import android.media.MediaMetadata; import android.media.session.MediaController; import android.media.session.MediaSession; Loading @@ -41,6 +43,7 @@ import android.service.notification.NotificationStats; import android.service.notification.StatusBarNotification; import android.util.ArraySet; import android.util.Log; import android.view.Display; import android.view.View; import android.widget.ImageView; Loading Loading @@ -74,11 +77,15 @@ import com.android.systemui.util.concurrency.DelayableExecutor; import java.io.PrintWriter; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import dagger.Lazy; Loading Loading @@ -138,6 +145,14 @@ public class NotificationMediaManager implements Dumpable { private BackDropView mBackdrop; private ImageView mBackdropFront; private ImageView mBackdropBack; private final Point mTmpDisplaySize = new Point(); private final DisplayManager mDisplayManager; @Nullable private List<String> mSmallerInternalDisplayUids; private Display mCurrentDisplay; private LockscreenWallpaper.WallpaperDrawable mWallapperDrawable; private final MediaController.Callback mMediaListener = new MediaController.Callback() { @Override Loading Loading @@ -184,7 +199,8 @@ public class NotificationMediaManager implements Dumpable { SysuiColorExtractor colorExtractor, KeyguardStateController keyguardStateController, DumpManager dumpManager, WallpaperManager wallpaperManager) { WallpaperManager wallpaperManager, DisplayManager displayManager) { mContext = context; mMediaArtworkProcessor = mediaArtworkProcessor; mKeyguardBypassController = keyguardBypassController; Loading @@ -200,6 +216,7 @@ public class NotificationMediaManager implements Dumpable { mStatusBarStateController = statusBarStateController; mColorExtractor = colorExtractor; mKeyguardStateController = keyguardStateController; mDisplayManager = displayManager; mIsLockscreenLiveWallpaperEnabled = wallpaperManager.isLockscreenLiveWallpaperEnabled(); setupNotifPipeline(); Loading Loading @@ -476,6 +493,48 @@ public class NotificationMediaManager implements Dumpable { mMediaController = null; } /** * Notify lockscreen wallpaper drawable the current internal display. */ public void onDisplayUpdated(Display display) { Trace.beginSection("NotificationMediaManager#onDisplayUpdated"); mCurrentDisplay = display; if (mWallapperDrawable != null) { mWallapperDrawable.onDisplayUpdated(isOnSmallerInternalDisplays()); } Trace.endSection(); } private boolean isOnSmallerInternalDisplays() { if (mSmallerInternalDisplayUids == null) { mSmallerInternalDisplayUids = findSmallerInternalDisplayUids(); } return mSmallerInternalDisplayUids.contains(mCurrentDisplay.getUniqueId()); } private List<String> findSmallerInternalDisplayUids() { if (mSmallerInternalDisplayUids != null) { return mSmallerInternalDisplayUids; } List<Display> internalDisplays = Arrays.stream(mDisplayManager.getDisplays( DisplayManager.DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED)) .filter(display -> display.getType() == Display.TYPE_INTERNAL) .collect(Collectors.toList()); if (internalDisplays.isEmpty()) { return List.of(); } Display largestDisplay = internalDisplays.stream() .max(Comparator.comparingInt(this::getRealDisplayArea)) .orElse(internalDisplays.get(0)); internalDisplays.remove(largestDisplay); return internalDisplays.stream().map(Display::getUniqueId).collect(Collectors.toList()); } private int getRealDisplayArea(Display display) { display.getRealSize(mTmpDisplaySize); return mTmpDisplaySize.x * mTmpDisplaySize.y; } /** * Refresh or remove lockscreen artwork from media metadata or the lockscreen wallpaper. */ Loading Loading @@ -551,7 +610,7 @@ public class NotificationMediaManager implements Dumpable { mLockscreenWallpaper != null ? mLockscreenWallpaper.getBitmap() : null; if (lockWallpaper != null) { artworkDrawable = new LockscreenWallpaper.WallpaperDrawable( mBackdropBack.getResources(), lockWallpaper); mBackdropBack.getResources(), lockWallpaper, isOnSmallerInternalDisplays()); // We're in the SHADE mode on the SIM screen - yet we still need to show // the lockscreen wallpaper in that mode. allowWhenShade = mStatusBarStateController.getState() == KEYGUARD; Loading Loading @@ -611,6 +670,10 @@ public class NotificationMediaManager implements Dumpable { mBackdropBack.setBackgroundColor(0xFFFFFFFF); mBackdropBack.setImageDrawable(new ColorDrawable(c)); } else { if (artworkDrawable instanceof LockscreenWallpaper.WallpaperDrawable) { mWallapperDrawable = (LockscreenWallpaper.WallpaperDrawable) artworkDrawable; } mBackdropBack.setImageDrawable(artworkDrawable); } Loading packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java +5 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.statusbar.dagger; import android.app.IActivityManager; import android.app.WallpaperManager; import android.content.Context; import android.hardware.display.DisplayManager; import android.os.RemoteException; import android.service.dreams.IDreamManager; import android.util.Log; Loading Loading @@ -144,7 +145,8 @@ public interface CentralSurfacesDependenciesModule { SysuiColorExtractor colorExtractor, KeyguardStateController keyguardStateController, DumpManager dumpManager, WallpaperManager wallpaperManager) { WallpaperManager wallpaperManager, DisplayManager displayManager) { return new NotificationMediaManager( context, centralSurfacesOptionalLazy, Loading @@ -160,7 +162,8 @@ public interface CentralSurfacesDependenciesModule { colorExtractor, keyguardStateController, dumpManager, wallpaperManager); wallpaperManager, displayManager); } /** */ Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +1 −0 Original line number Diff line number Diff line Loading @@ -2267,6 +2267,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { void updateDisplaySize() { mDisplay.getMetrics(mDisplayMetrics); mDisplay.getSize(mCurrentDisplaySize); mMediaManager.onDisplayUpdated(mDisplay); if (DEBUG_GESTURES) { mGestureRec.tag("display", String.format("%dx%d", mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels)); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java +30 −6 Original line number Diff line number Diff line Loading @@ -281,19 +281,25 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen /** * Drawable that aligns left horizontally and center vertically (like ImageWallpaper). * * <p>Aligns to the center when showing on the smaller internal display of a multi display * device. */ public static class WallpaperDrawable extends DrawableWrapper { private final ConstantState mState; private final Rect mTmpRect = new Rect(); private boolean mIsOnSmallerInternalDisplays; public WallpaperDrawable(Resources r, Bitmap b) { this(r, new ConstantState(b)); public WallpaperDrawable(Resources r, Bitmap b, boolean isOnSmallerInternalDisplays) { this(r, new ConstantState(b), isOnSmallerInternalDisplays); } private WallpaperDrawable(Resources r, ConstantState state) { private WallpaperDrawable(Resources r, ConstantState state, boolean isOnSmallerInternalDisplays) { super(new BitmapDrawable(r, state.mBackground)); mState = state; mIsOnSmallerInternalDisplays = isOnSmallerInternalDisplays; } @Override Loading Loading @@ -332,10 +338,17 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen } dy = (vheight - dheight * scale) * 0.5f; int offsetX = 0; // Offset to show the center area of the wallpaper on a smaller display for multi // display device if (mIsOnSmallerInternalDisplays) { offsetX = bounds.centerX() - (Math.round(dwidth * scale) / 2); } mTmpRect.set( bounds.left, bounds.left + offsetX, bounds.top + Math.round(dy), bounds.left + Math.round(dwidth * scale), bounds.left + Math.round(dwidth * scale) + offsetX, bounds.top + Math.round(dheight * scale + dy)); super.onBoundsChange(mTmpRect); Loading @@ -346,6 +359,17 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen return mState; } /** * Update bounds when the hosting display or the display size has changed. * * @param isOnSmallerInternalDisplays true if the drawable is on one of the internal * displays with the smaller area. */ public void onDisplayUpdated(boolean isOnSmallerInternalDisplays) { mIsOnSmallerInternalDisplays = isOnSmallerInternalDisplays; onBoundsChange(getBounds()); } static class ConstantState extends Drawable.ConstantState { private final Bitmap mBackground; Loading @@ -361,7 +385,7 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen @Override public Drawable newDrawable(@Nullable Resources res) { return new WallpaperDrawable(res, this); return new WallpaperDrawable(res, this, /* isOnSmallerInternalDisplays= */ false); } @Override Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java +65 −2 Original line number Diff line number Diff line Loading @@ -27,10 +27,12 @@ import android.app.Notification; import android.app.WallpaperManager; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.hardware.display.DisplayManager; import android.media.MediaMetadata; import android.media.session.MediaController; import android.media.session.MediaSession; Loading @@ -41,6 +43,7 @@ import android.service.notification.NotificationStats; import android.service.notification.StatusBarNotification; import android.util.ArraySet; import android.util.Log; import android.view.Display; import android.view.View; import android.widget.ImageView; Loading Loading @@ -74,11 +77,15 @@ import com.android.systemui.util.concurrency.DelayableExecutor; import java.io.PrintWriter; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import dagger.Lazy; Loading Loading @@ -138,6 +145,14 @@ public class NotificationMediaManager implements Dumpable { private BackDropView mBackdrop; private ImageView mBackdropFront; private ImageView mBackdropBack; private final Point mTmpDisplaySize = new Point(); private final DisplayManager mDisplayManager; @Nullable private List<String> mSmallerInternalDisplayUids; private Display mCurrentDisplay; private LockscreenWallpaper.WallpaperDrawable mWallapperDrawable; private final MediaController.Callback mMediaListener = new MediaController.Callback() { @Override Loading Loading @@ -184,7 +199,8 @@ public class NotificationMediaManager implements Dumpable { SysuiColorExtractor colorExtractor, KeyguardStateController keyguardStateController, DumpManager dumpManager, WallpaperManager wallpaperManager) { WallpaperManager wallpaperManager, DisplayManager displayManager) { mContext = context; mMediaArtworkProcessor = mediaArtworkProcessor; mKeyguardBypassController = keyguardBypassController; Loading @@ -200,6 +216,7 @@ public class NotificationMediaManager implements Dumpable { mStatusBarStateController = statusBarStateController; mColorExtractor = colorExtractor; mKeyguardStateController = keyguardStateController; mDisplayManager = displayManager; mIsLockscreenLiveWallpaperEnabled = wallpaperManager.isLockscreenLiveWallpaperEnabled(); setupNotifPipeline(); Loading Loading @@ -476,6 +493,48 @@ public class NotificationMediaManager implements Dumpable { mMediaController = null; } /** * Notify lockscreen wallpaper drawable the current internal display. */ public void onDisplayUpdated(Display display) { Trace.beginSection("NotificationMediaManager#onDisplayUpdated"); mCurrentDisplay = display; if (mWallapperDrawable != null) { mWallapperDrawable.onDisplayUpdated(isOnSmallerInternalDisplays()); } Trace.endSection(); } private boolean isOnSmallerInternalDisplays() { if (mSmallerInternalDisplayUids == null) { mSmallerInternalDisplayUids = findSmallerInternalDisplayUids(); } return mSmallerInternalDisplayUids.contains(mCurrentDisplay.getUniqueId()); } private List<String> findSmallerInternalDisplayUids() { if (mSmallerInternalDisplayUids != null) { return mSmallerInternalDisplayUids; } List<Display> internalDisplays = Arrays.stream(mDisplayManager.getDisplays( DisplayManager.DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED)) .filter(display -> display.getType() == Display.TYPE_INTERNAL) .collect(Collectors.toList()); if (internalDisplays.isEmpty()) { return List.of(); } Display largestDisplay = internalDisplays.stream() .max(Comparator.comparingInt(this::getRealDisplayArea)) .orElse(internalDisplays.get(0)); internalDisplays.remove(largestDisplay); return internalDisplays.stream().map(Display::getUniqueId).collect(Collectors.toList()); } private int getRealDisplayArea(Display display) { display.getRealSize(mTmpDisplaySize); return mTmpDisplaySize.x * mTmpDisplaySize.y; } /** * Refresh or remove lockscreen artwork from media metadata or the lockscreen wallpaper. */ Loading Loading @@ -551,7 +610,7 @@ public class NotificationMediaManager implements Dumpable { mLockscreenWallpaper != null ? mLockscreenWallpaper.getBitmap() : null; if (lockWallpaper != null) { artworkDrawable = new LockscreenWallpaper.WallpaperDrawable( mBackdropBack.getResources(), lockWallpaper); mBackdropBack.getResources(), lockWallpaper, isOnSmallerInternalDisplays()); // We're in the SHADE mode on the SIM screen - yet we still need to show // the lockscreen wallpaper in that mode. allowWhenShade = mStatusBarStateController.getState() == KEYGUARD; Loading Loading @@ -611,6 +670,10 @@ public class NotificationMediaManager implements Dumpable { mBackdropBack.setBackgroundColor(0xFFFFFFFF); mBackdropBack.setImageDrawable(new ColorDrawable(c)); } else { if (artworkDrawable instanceof LockscreenWallpaper.WallpaperDrawable) { mWallapperDrawable = (LockscreenWallpaper.WallpaperDrawable) artworkDrawable; } mBackdropBack.setImageDrawable(artworkDrawable); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java +5 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.statusbar.dagger; import android.app.IActivityManager; import android.app.WallpaperManager; import android.content.Context; import android.hardware.display.DisplayManager; import android.os.RemoteException; import android.service.dreams.IDreamManager; import android.util.Log; Loading Loading @@ -144,7 +145,8 @@ public interface CentralSurfacesDependenciesModule { SysuiColorExtractor colorExtractor, KeyguardStateController keyguardStateController, DumpManager dumpManager, WallpaperManager wallpaperManager) { WallpaperManager wallpaperManager, DisplayManager displayManager) { return new NotificationMediaManager( context, centralSurfacesOptionalLazy, Loading @@ -160,7 +162,8 @@ public interface CentralSurfacesDependenciesModule { colorExtractor, keyguardStateController, dumpManager, wallpaperManager); wallpaperManager, displayManager); } /** */ Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +1 −0 Original line number Diff line number Diff line Loading @@ -2267,6 +2267,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { void updateDisplaySize() { mDisplay.getMetrics(mDisplayMetrics); mDisplay.getSize(mCurrentDisplaySize); mMediaManager.onDisplayUpdated(mDisplay); if (DEBUG_GESTURES) { mGestureRec.tag("display", String.format("%dx%d", mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels)); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java +30 −6 Original line number Diff line number Diff line Loading @@ -281,19 +281,25 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen /** * Drawable that aligns left horizontally and center vertically (like ImageWallpaper). * * <p>Aligns to the center when showing on the smaller internal display of a multi display * device. */ public static class WallpaperDrawable extends DrawableWrapper { private final ConstantState mState; private final Rect mTmpRect = new Rect(); private boolean mIsOnSmallerInternalDisplays; public WallpaperDrawable(Resources r, Bitmap b) { this(r, new ConstantState(b)); public WallpaperDrawable(Resources r, Bitmap b, boolean isOnSmallerInternalDisplays) { this(r, new ConstantState(b), isOnSmallerInternalDisplays); } private WallpaperDrawable(Resources r, ConstantState state) { private WallpaperDrawable(Resources r, ConstantState state, boolean isOnSmallerInternalDisplays) { super(new BitmapDrawable(r, state.mBackground)); mState = state; mIsOnSmallerInternalDisplays = isOnSmallerInternalDisplays; } @Override Loading Loading @@ -332,10 +338,17 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen } dy = (vheight - dheight * scale) * 0.5f; int offsetX = 0; // Offset to show the center area of the wallpaper on a smaller display for multi // display device if (mIsOnSmallerInternalDisplays) { offsetX = bounds.centerX() - (Math.round(dwidth * scale) / 2); } mTmpRect.set( bounds.left, bounds.left + offsetX, bounds.top + Math.round(dy), bounds.left + Math.round(dwidth * scale), bounds.left + Math.round(dwidth * scale) + offsetX, bounds.top + Math.round(dheight * scale + dy)); super.onBoundsChange(mTmpRect); Loading @@ -346,6 +359,17 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen return mState; } /** * Update bounds when the hosting display or the display size has changed. * * @param isOnSmallerInternalDisplays true if the drawable is on one of the internal * displays with the smaller area. */ public void onDisplayUpdated(boolean isOnSmallerInternalDisplays) { mIsOnSmallerInternalDisplays = isOnSmallerInternalDisplays; onBoundsChange(getBounds()); } static class ConstantState extends Drawable.ConstantState { private final Bitmap mBackground; Loading @@ -361,7 +385,7 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen @Override public Drawable newDrawable(@Nullable Resources res) { return new WallpaperDrawable(res, this); return new WallpaperDrawable(res, this, /* isOnSmallerInternalDisplays= */ false); } @Override Loading