Loading packages/SystemUI/src/com/android/systemui/colorextraction/SysuiColorExtractor.java +19 −6 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,7 @@ import java.util.Arrays; public class SysuiColorExtractor extends ColorExtractor implements Dumpable { public class SysuiColorExtractor extends ColorExtractor implements Dumpable { private static final String TAG = "SysuiColorExtractor"; private static final String TAG = "SysuiColorExtractor"; private boolean mWallpaperVisible; private boolean mWallpaperVisible; private boolean mMediaBackdropVisible; // Colors to return when the wallpaper isn't visible // Colors to return when the wallpaper isn't visible private final GradientColors mWpHiddenColors; private final GradientColors mWpHiddenColors; Loading Loading @@ -157,14 +158,19 @@ public class SysuiColorExtractor extends ColorExtractor implements Dumpable { public GradientColors getColors(int which, int type, boolean ignoreWallpaperVisibility) { public GradientColors getColors(int which, int type, boolean ignoreWallpaperVisibility) { // mWallpaperVisible only handles the "system wallpaper" and will be always set to false // mWallpaperVisible only handles the "system wallpaper" and will be always set to false // if we have different lock and system wallpapers. // if we have different lock and system wallpapers. if (which == WallpaperManager.FLAG_LOCK) { if (which == WallpaperManager.FLAG_SYSTEM) { ignoreWallpaperVisibility = true; } if (mWallpaperVisible || ignoreWallpaperVisibility) { if (mWallpaperVisible || ignoreWallpaperVisibility) { return super.getColors(which, type); return super.getColors(which, type); } else { } else { return mWpHiddenColors; return mWpHiddenColors; } } } else { if (mMediaBackdropVisible) { return mWpHiddenColors; } else { return super.getColors(which, type); } } } } @VisibleForTesting @VisibleForTesting Loading @@ -175,6 +181,13 @@ public class SysuiColorExtractor extends ColorExtractor implements Dumpable { } } } } public void setMediaBackdropVisible(boolean visible) { if (mMediaBackdropVisible != visible) { mMediaBackdropVisible = visible; triggerColorsChanged(WallpaperManager.FLAG_LOCK); } } @Override @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("SysuiColorExtractor:"); pw.println("SysuiColorExtractor:"); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -1589,8 +1589,7 @@ public class StatusBar extends SystemUI implements DemoMode, Drawable artworkDrawable = null; Drawable artworkDrawable = null; if (mediaMetadata != null) { if (mediaMetadata != null) { Bitmap artworkBitmap = null; Bitmap artworkBitmap = mediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ART); artworkBitmap = mediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ART); if (artworkBitmap == null) { if (artworkBitmap == null) { artworkBitmap = mediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART); artworkBitmap = mediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART); // might still be null // might still be null Loading Loading @@ -1633,6 +1632,7 @@ public class StatusBar extends SystemUI implements DemoMode, mBackdrop.setAlpha(1f); mBackdrop.setAlpha(1f); } } mStatusBarWindowManager.setBackdropShowing(true); mStatusBarWindowManager.setBackdropShowing(true); mColorExtractor.setMediaBackdropVisible(true); metaDataChanged = true; metaDataChanged = true; if (DEBUG_MEDIA) { if (DEBUG_MEDIA) { Log.v(TAG, "DEBUG_MEDIA: Fading in album artwork"); Log.v(TAG, "DEBUG_MEDIA: Fading in album artwork"); Loading Loading @@ -1684,6 +1684,7 @@ public class StatusBar extends SystemUI implements DemoMode, if (DEBUG_MEDIA) { if (DEBUG_MEDIA) { Log.v(TAG, "DEBUG_MEDIA: Fading out album artwork"); Log.v(TAG, "DEBUG_MEDIA: Fading out album artwork"); } } mColorExtractor.setMediaBackdropVisible(false); boolean cannotAnimateDoze = mDozing && !ScrimState.AOD.getAnimateChange(); boolean cannotAnimateDoze = mDozing && !ScrimState.AOD.getAnimateChange(); if (mFingerprintUnlockController.getMode() if (mFingerprintUnlockController.getMode() == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING Loading packages/SystemUI/tests/src/com/android/systemui/colorextraction/SysuiColorExtractorTests.java +21 −0 Original line number Original line Diff line number Diff line Loading @@ -84,6 +84,27 @@ public class SysuiColorExtractorTests extends SysuiTestCase { } } } } @Test public void getColors_fallbackWhenMediaIsVisible() { ColorExtractor.GradientColors colors = new ColorExtractor.GradientColors(); colors.setMainColor(Color.RED); colors.setSecondaryColor(Color.RED); SysuiColorExtractor extractor = getTestableExtractor(colors); simulateEvent(extractor); extractor.setWallpaperVisible(true); extractor.setMediaBackdropVisible(true); ColorExtractor.GradientColors fallbackColors = extractor.getFallbackColors(); for (int type : sTypes) { assertEquals("Not using fallback!", extractor.getColors(WallpaperManager.FLAG_LOCK, type), fallbackColors); assertNotEquals("Media visibility should not affect system wallpaper.", extractor.getColors(WallpaperManager.FLAG_SYSTEM, type), fallbackColors); } } private SysuiColorExtractor getTestableExtractor(ColorExtractor.GradientColors colors) { private SysuiColorExtractor getTestableExtractor(ColorExtractor.GradientColors colors) { return new SysuiColorExtractor(getContext(), return new SysuiColorExtractor(getContext(), (inWallpaperColors, outGradientColorsNormal, outGradientColorsDark, (inWallpaperColors, outGradientColorsNormal, outGradientColorsDark, Loading Loading
packages/SystemUI/src/com/android/systemui/colorextraction/SysuiColorExtractor.java +19 −6 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,7 @@ import java.util.Arrays; public class SysuiColorExtractor extends ColorExtractor implements Dumpable { public class SysuiColorExtractor extends ColorExtractor implements Dumpable { private static final String TAG = "SysuiColorExtractor"; private static final String TAG = "SysuiColorExtractor"; private boolean mWallpaperVisible; private boolean mWallpaperVisible; private boolean mMediaBackdropVisible; // Colors to return when the wallpaper isn't visible // Colors to return when the wallpaper isn't visible private final GradientColors mWpHiddenColors; private final GradientColors mWpHiddenColors; Loading Loading @@ -157,14 +158,19 @@ public class SysuiColorExtractor extends ColorExtractor implements Dumpable { public GradientColors getColors(int which, int type, boolean ignoreWallpaperVisibility) { public GradientColors getColors(int which, int type, boolean ignoreWallpaperVisibility) { // mWallpaperVisible only handles the "system wallpaper" and will be always set to false // mWallpaperVisible only handles the "system wallpaper" and will be always set to false // if we have different lock and system wallpapers. // if we have different lock and system wallpapers. if (which == WallpaperManager.FLAG_LOCK) { if (which == WallpaperManager.FLAG_SYSTEM) { ignoreWallpaperVisibility = true; } if (mWallpaperVisible || ignoreWallpaperVisibility) { if (mWallpaperVisible || ignoreWallpaperVisibility) { return super.getColors(which, type); return super.getColors(which, type); } else { } else { return mWpHiddenColors; return mWpHiddenColors; } } } else { if (mMediaBackdropVisible) { return mWpHiddenColors; } else { return super.getColors(which, type); } } } } @VisibleForTesting @VisibleForTesting Loading @@ -175,6 +181,13 @@ public class SysuiColorExtractor extends ColorExtractor implements Dumpable { } } } } public void setMediaBackdropVisible(boolean visible) { if (mMediaBackdropVisible != visible) { mMediaBackdropVisible = visible; triggerColorsChanged(WallpaperManager.FLAG_LOCK); } } @Override @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("SysuiColorExtractor:"); pw.println("SysuiColorExtractor:"); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -1589,8 +1589,7 @@ public class StatusBar extends SystemUI implements DemoMode, Drawable artworkDrawable = null; Drawable artworkDrawable = null; if (mediaMetadata != null) { if (mediaMetadata != null) { Bitmap artworkBitmap = null; Bitmap artworkBitmap = mediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ART); artworkBitmap = mediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ART); if (artworkBitmap == null) { if (artworkBitmap == null) { artworkBitmap = mediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART); artworkBitmap = mediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART); // might still be null // might still be null Loading Loading @@ -1633,6 +1632,7 @@ public class StatusBar extends SystemUI implements DemoMode, mBackdrop.setAlpha(1f); mBackdrop.setAlpha(1f); } } mStatusBarWindowManager.setBackdropShowing(true); mStatusBarWindowManager.setBackdropShowing(true); mColorExtractor.setMediaBackdropVisible(true); metaDataChanged = true; metaDataChanged = true; if (DEBUG_MEDIA) { if (DEBUG_MEDIA) { Log.v(TAG, "DEBUG_MEDIA: Fading in album artwork"); Log.v(TAG, "DEBUG_MEDIA: Fading in album artwork"); Loading Loading @@ -1684,6 +1684,7 @@ public class StatusBar extends SystemUI implements DemoMode, if (DEBUG_MEDIA) { if (DEBUG_MEDIA) { Log.v(TAG, "DEBUG_MEDIA: Fading out album artwork"); Log.v(TAG, "DEBUG_MEDIA: Fading out album artwork"); } } mColorExtractor.setMediaBackdropVisible(false); boolean cannotAnimateDoze = mDozing && !ScrimState.AOD.getAnimateChange(); boolean cannotAnimateDoze = mDozing && !ScrimState.AOD.getAnimateChange(); if (mFingerprintUnlockController.getMode() if (mFingerprintUnlockController.getMode() == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING Loading
packages/SystemUI/tests/src/com/android/systemui/colorextraction/SysuiColorExtractorTests.java +21 −0 Original line number Original line Diff line number Diff line Loading @@ -84,6 +84,27 @@ public class SysuiColorExtractorTests extends SysuiTestCase { } } } } @Test public void getColors_fallbackWhenMediaIsVisible() { ColorExtractor.GradientColors colors = new ColorExtractor.GradientColors(); colors.setMainColor(Color.RED); colors.setSecondaryColor(Color.RED); SysuiColorExtractor extractor = getTestableExtractor(colors); simulateEvent(extractor); extractor.setWallpaperVisible(true); extractor.setMediaBackdropVisible(true); ColorExtractor.GradientColors fallbackColors = extractor.getFallbackColors(); for (int type : sTypes) { assertEquals("Not using fallback!", extractor.getColors(WallpaperManager.FLAG_LOCK, type), fallbackColors); assertNotEquals("Media visibility should not affect system wallpaper.", extractor.getColors(WallpaperManager.FLAG_SYSTEM, type), fallbackColors); } } private SysuiColorExtractor getTestableExtractor(ColorExtractor.GradientColors colors) { private SysuiColorExtractor getTestableExtractor(ColorExtractor.GradientColors colors) { return new SysuiColorExtractor(getContext(), return new SysuiColorExtractor(getContext(), (inWallpaperColors, outGradientColorsNormal, outGradientColorsDark, (inWallpaperColors, outGradientColorsNormal, outGradientColorsDark, Loading