Loading Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -357,6 +357,7 @@ LOCAL_SRC_FILES += \ core/java/android/view/IPinnedStackController.aidl \ core/java/android/view/IPinnedStackListener.aidl \ core/java/android/view/IRotationWatcher.aidl \ core/java/android/view/IWallpaperVisibilityListener.aidl \ core/java/android/view/IWindow.aidl \ core/java/android/view/IWindowFocusObserver.aidl \ core/java/android/view/IWindowId.aidl \ Loading core/java/android/view/IWallpaperVisibilityListener.aidl 0 → 100644 +30 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view; /** * Listener to be invoked when wallpaper visibility changes. * {@hide} */ oneway interface IWallpaperVisibilityListener { /** * Method that will be invoked when wallpaper becomes visible or hidden. * @param visible True if wallpaper is being displayed; false otherwise. * @param displayId The id of the display where wallpaper visibility changed. */ void onWallpaperVisibilityChanged(boolean visible, int displayId); } core/java/android/view/IWindowManager.aidl +14 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.view.IDockedStackListener; import android.view.IOnKeyguardExitResult; import android.view.IPinnedStackListener; import android.view.IRotationWatcher; import android.view.IWallpaperVisibilityListener; import android.view.IWindowSession; import android.view.IWindowSessionCallback; import android.view.KeyEvent; Loading Loading @@ -255,6 +256,19 @@ interface IWindowManager */ Bitmap screenshotWallpaper(); /** * Registers a wallpaper visibility listener. * @return Current visibility. */ boolean registerWallpaperVisibilityListener(IWallpaperVisibilityListener listener, int displayId); /** * Remove a visibility watcher that was added using registerWallpaperVisibilityListener. */ void unregisterWallpaperVisibilityListener(IWallpaperVisibilityListener listener, int displayId); /** * Used only for assist -- request a screenshot of the current application. */ Loading packages/SystemUI/colorextraction/src/com/google/android/colorextraction/ColorExtractor.java +4 −11 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.WallpaperManager; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.VisibleForTesting; import android.support.v4.graphics.ColorUtils; import android.util.Log; import android.util.SparseArray; Loading @@ -41,15 +42,12 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener private static final String TAG = "ColorExtractor"; @VisibleForTesting static final int FALLBACK_COLOR = 0xff83888d; public static final int FALLBACK_COLOR = 0xff83888d; private int mMainFallbackColor = FALLBACK_COLOR; private int mSecondaryFallbackColor = FALLBACK_COLOR; private final SparseArray<GradientColors[]> mGradientColors; private final ArrayList<OnColorsChangedListener> mOnColorsChangedListeners; // Colors to return when the wallpaper isn't visible private final GradientColors mWpHiddenColors; private final Context mContext; private final ExtractionType mExtractionType; Loading @@ -60,9 +58,6 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener @VisibleForTesting public ColorExtractor(Context context, ExtractionType extractionType) { mContext = context; mWpHiddenColors = new GradientColors(); mWpHiddenColors.setMainColor(FALLBACK_COLOR); mWpHiddenColors.setSecondaryColor(FALLBACK_COLOR); mExtractionType = extractionType; mGradientColors = new SparseArray<>(); Loading Loading @@ -123,7 +118,6 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener if (which != WallpaperManager.FLAG_LOCK && which != WallpaperManager.FLAG_SYSTEM) { throw new IllegalArgumentException("which should be FLAG_SYSTEM or FLAG_NORMAL"); } return mGradientColors.get(which)[type]; } Loading @@ -134,7 +128,6 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener GradientColors[] lockColors = mGradientColors.get(WallpaperManager.FLAG_LOCK); extractInto(colors, lockColors[TYPE_NORMAL], lockColors[TYPE_DARK], lockColors[TYPE_EXTRA_DARK]); changed = true; } if ((which & WallpaperManager.FLAG_SYSTEM) != 0) { Loading @@ -149,7 +142,7 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener } } private void triggerColorsChanged(int which) { protected void triggerColorsChanged(int which) { for (OnColorsChangedListener listener: mOnColorsChangedListeners) { listener.onColorsChanged(this, which); } Loading packages/SystemUI/colorextraction/tests/src/com/google/android/colorextraction/ColorExtractorTest.java +8 −10 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ import org.junit.Test; import org.junit.runner.RunWith; /** * Tests tonal palette generation. * Tests color extraction generation. */ @SmallTest @RunWith(AndroidJUnit4.class) Loading Loading @@ -101,14 +101,12 @@ public class ColorExtractorTest { }; ColorExtractor extractor = new ColorExtractor(mContext, type); assertEquals("Extracted colors not being used!", extractor.getColors(WallpaperManager.FLAG_SYSTEM, ColorExtractor.TYPE_NORMAL), colorsExpectedNormal); assertEquals("Extracted colors not being used!", extractor.getColors(WallpaperManager.FLAG_SYSTEM, ColorExtractor.TYPE_DARK), colorsExpectedDark); assertEquals("Extracted colors not being used!", extractor.getColors(WallpaperManager.FLAG_SYSTEM, ColorExtractor.TYPE_EXTRA_DARK), colorsExpectedExtraDark); GradientColors colors = extractor.getColors(WallpaperManager.FLAG_SYSTEM, ColorExtractor.TYPE_NORMAL); assertEquals("Extracted colors not being used!", colors, colorsExpectedNormal); colors = extractor.getColors(WallpaperManager.FLAG_SYSTEM, ColorExtractor.TYPE_DARK); assertEquals("Extracted colors not being used!", colors, colorsExpectedDark); colors = extractor.getColors(WallpaperManager.FLAG_SYSTEM, ColorExtractor.TYPE_EXTRA_DARK); assertEquals("Extracted colors not being used!", colors, colorsExpectedExtraDark); } } Loading
Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -357,6 +357,7 @@ LOCAL_SRC_FILES += \ core/java/android/view/IPinnedStackController.aidl \ core/java/android/view/IPinnedStackListener.aidl \ core/java/android/view/IRotationWatcher.aidl \ core/java/android/view/IWallpaperVisibilityListener.aidl \ core/java/android/view/IWindow.aidl \ core/java/android/view/IWindowFocusObserver.aidl \ core/java/android/view/IWindowId.aidl \ Loading
core/java/android/view/IWallpaperVisibilityListener.aidl 0 → 100644 +30 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view; /** * Listener to be invoked when wallpaper visibility changes. * {@hide} */ oneway interface IWallpaperVisibilityListener { /** * Method that will be invoked when wallpaper becomes visible or hidden. * @param visible True if wallpaper is being displayed; false otherwise. * @param displayId The id of the display where wallpaper visibility changed. */ void onWallpaperVisibilityChanged(boolean visible, int displayId); }
core/java/android/view/IWindowManager.aidl +14 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.view.IDockedStackListener; import android.view.IOnKeyguardExitResult; import android.view.IPinnedStackListener; import android.view.IRotationWatcher; import android.view.IWallpaperVisibilityListener; import android.view.IWindowSession; import android.view.IWindowSessionCallback; import android.view.KeyEvent; Loading Loading @@ -255,6 +256,19 @@ interface IWindowManager */ Bitmap screenshotWallpaper(); /** * Registers a wallpaper visibility listener. * @return Current visibility. */ boolean registerWallpaperVisibilityListener(IWallpaperVisibilityListener listener, int displayId); /** * Remove a visibility watcher that was added using registerWallpaperVisibilityListener. */ void unregisterWallpaperVisibilityListener(IWallpaperVisibilityListener listener, int displayId); /** * Used only for assist -- request a screenshot of the current application. */ Loading
packages/SystemUI/colorextraction/src/com/google/android/colorextraction/ColorExtractor.java +4 −11 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.WallpaperManager; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.VisibleForTesting; import android.support.v4.graphics.ColorUtils; import android.util.Log; import android.util.SparseArray; Loading @@ -41,15 +42,12 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener private static final String TAG = "ColorExtractor"; @VisibleForTesting static final int FALLBACK_COLOR = 0xff83888d; public static final int FALLBACK_COLOR = 0xff83888d; private int mMainFallbackColor = FALLBACK_COLOR; private int mSecondaryFallbackColor = FALLBACK_COLOR; private final SparseArray<GradientColors[]> mGradientColors; private final ArrayList<OnColorsChangedListener> mOnColorsChangedListeners; // Colors to return when the wallpaper isn't visible private final GradientColors mWpHiddenColors; private final Context mContext; private final ExtractionType mExtractionType; Loading @@ -60,9 +58,6 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener @VisibleForTesting public ColorExtractor(Context context, ExtractionType extractionType) { mContext = context; mWpHiddenColors = new GradientColors(); mWpHiddenColors.setMainColor(FALLBACK_COLOR); mWpHiddenColors.setSecondaryColor(FALLBACK_COLOR); mExtractionType = extractionType; mGradientColors = new SparseArray<>(); Loading Loading @@ -123,7 +118,6 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener if (which != WallpaperManager.FLAG_LOCK && which != WallpaperManager.FLAG_SYSTEM) { throw new IllegalArgumentException("which should be FLAG_SYSTEM or FLAG_NORMAL"); } return mGradientColors.get(which)[type]; } Loading @@ -134,7 +128,6 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener GradientColors[] lockColors = mGradientColors.get(WallpaperManager.FLAG_LOCK); extractInto(colors, lockColors[TYPE_NORMAL], lockColors[TYPE_DARK], lockColors[TYPE_EXTRA_DARK]); changed = true; } if ((which & WallpaperManager.FLAG_SYSTEM) != 0) { Loading @@ -149,7 +142,7 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener } } private void triggerColorsChanged(int which) { protected void triggerColorsChanged(int which) { for (OnColorsChangedListener listener: mOnColorsChangedListeners) { listener.onColorsChanged(this, which); } Loading
packages/SystemUI/colorextraction/tests/src/com/google/android/colorextraction/ColorExtractorTest.java +8 −10 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ import org.junit.Test; import org.junit.runner.RunWith; /** * Tests tonal palette generation. * Tests color extraction generation. */ @SmallTest @RunWith(AndroidJUnit4.class) Loading Loading @@ -101,14 +101,12 @@ public class ColorExtractorTest { }; ColorExtractor extractor = new ColorExtractor(mContext, type); assertEquals("Extracted colors not being used!", extractor.getColors(WallpaperManager.FLAG_SYSTEM, ColorExtractor.TYPE_NORMAL), colorsExpectedNormal); assertEquals("Extracted colors not being used!", extractor.getColors(WallpaperManager.FLAG_SYSTEM, ColorExtractor.TYPE_DARK), colorsExpectedDark); assertEquals("Extracted colors not being used!", extractor.getColors(WallpaperManager.FLAG_SYSTEM, ColorExtractor.TYPE_EXTRA_DARK), colorsExpectedExtraDark); GradientColors colors = extractor.getColors(WallpaperManager.FLAG_SYSTEM, ColorExtractor.TYPE_NORMAL); assertEquals("Extracted colors not being used!", colors, colorsExpectedNormal); colors = extractor.getColors(WallpaperManager.FLAG_SYSTEM, ColorExtractor.TYPE_DARK); assertEquals("Extracted colors not being used!", colors, colorsExpectedDark); colors = extractor.getColors(WallpaperManager.FLAG_SYSTEM, ColorExtractor.TYPE_EXTRA_DARK); assertEquals("Extracted colors not being used!", colors, colorsExpectedExtraDark); } }