Loading core/api/test-current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -3289,7 +3289,7 @@ package android.window { method @NonNull public android.window.WindowContainerTransaction reparentTasks(@Nullable android.window.WindowContainerToken, @Nullable android.window.WindowContainerToken, @Nullable int[], @Nullable int[], boolean); method @NonNull public android.window.WindowContainerTransaction scheduleFinishEnterPip(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect); method @NonNull public android.window.WindowContainerTransaction setActivityWindowingMode(@NonNull android.window.WindowContainerToken, int); method @NonNull public android.window.WindowContainerTransaction setAdjacentRoots(@NonNull android.window.WindowContainerToken, @NonNull android.window.WindowContainerToken); method @NonNull public android.window.WindowContainerTransaction setAdjacentRoots(@NonNull android.window.WindowContainerToken, @NonNull android.window.WindowContainerToken, boolean); method @NonNull public android.window.WindowContainerTransaction setAdjacentTaskFragments(@NonNull android.os.IBinder, @Nullable android.os.IBinder, @Nullable android.window.WindowContainerTransaction.TaskFragmentAdjacentParams); method @NonNull public android.window.WindowContainerTransaction setAppBounds(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect); method @NonNull public android.window.WindowContainerTransaction setBounds(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect); Loading core/java/android/app/WallpaperManager.java +44 −37 Original line number Diff line number Diff line Loading @@ -365,19 +365,20 @@ public class WallpaperManager { private int mCachedWallpaperUserId; private Bitmap mDefaultWallpaper; private Handler mMainLooperHandler; private ArrayMap<RectF, ArraySet<LocalWallpaperColorConsumer>> mLocalColorAreas = private ArrayMap<LocalWallpaperColorConsumer, ArraySet<RectF>> mLocalColorCallbackAreas = new ArrayMap<>(); private ILocalWallpaperColorConsumer mLocalColorCallback = new ILocalWallpaperColorConsumer.Stub() { @Override public void onColorsChanged(RectF area, WallpaperColors colors) { ArraySet<LocalWallpaperColorConsumer> callbacks = mLocalColorAreas.get(area); if (callbacks == null) return; for (LocalWallpaperColorConsumer callback: callbacks) { for (LocalWallpaperColorConsumer callback : mLocalColorCallbackAreas.keySet()) { ArraySet<RectF> areas = mLocalColorCallbackAreas.get(callback); if (areas != null && areas.contains(area)) { callback.onColorsChanged(area, colors); } } } }; Globals(IWallpaperManager service, Looper looper) { Loading Loading @@ -420,17 +421,20 @@ public class WallpaperManager { } } public void addOnColorsChangedListener(@NonNull LocalWallpaperColorConsumer callback, public void addOnColorsChangedListener( @NonNull LocalWallpaperColorConsumer callback, @NonNull List<RectF> regions, int which, int userId, int displayId) { synchronized (this) { for (RectF area : regions) { ArraySet<LocalWallpaperColorConsumer> callbacks = mLocalColorAreas.get(area); if (callbacks == null) { callbacks = new ArraySet<>(); mLocalColorAreas.put(area, callbacks); ArraySet<RectF> areas = mLocalColorCallbackAreas.get(callback); if (areas == null) { areas = new ArraySet<>(); mLocalColorCallbackAreas.put(callback, areas); } callbacks.add(callback); areas.add(area); } try { // one way returns immediately mService.addOnLocalColorsChangedListener(mLocalColorCallback, regions, which, userId, displayId); } catch (RemoteException e) { Loading @@ -438,30 +442,33 @@ public class WallpaperManager { Log.e(TAG, "Can't register for local color updates", e); } } } public void removeOnColorsChangedListener( @NonNull LocalWallpaperColorConsumer callback, int which, int userId, int displayId) { final ArrayList<RectF> removeAreas = new ArrayList<>(); for (RectF area : mLocalColorAreas.keySet()) { ArraySet<LocalWallpaperColorConsumer> callbacks = mLocalColorAreas.get(area); if (callbacks == null) continue; callbacks.remove(callback); if (callbacks.size() == 0) { mLocalColorAreas.remove(area); removeAreas.add(area); synchronized (this) { final ArraySet<RectF> removeAreas = mLocalColorCallbackAreas.remove(callback); if (removeAreas == null || removeAreas.size() == 0) { return; } for (LocalWallpaperColorConsumer cb : mLocalColorCallbackAreas.keySet()) { ArraySet<RectF> areas = mLocalColorCallbackAreas.get(cb); if (areas != null && cb != callback) removeAreas.removeAll(areas); } try { if (removeAreas.size() > 0) { // one way returns immediately mService.removeOnLocalColorsChangedListener( mLocalColorCallback, removeAreas, which, userId, displayId); mLocalColorCallback, new ArrayList(removeAreas), which, userId, displayId); } } catch (RemoteException e) { // Can't get colors, connection lost. Log.e(TAG, "Can't unregister for local color updates", e); } } } /** * Stop listening to wallpaper color events. Loading core/java/android/service/wallpaper/WallpaperService.java +15 −119 Original line number Diff line number Diff line Loading @@ -196,7 +196,7 @@ public abstract class WallpaperService extends Service { EngineWindowPage[] mWindowPages = new EngineWindowPage[1]; Bitmap mLastScreenshot; int mLastWindowPage = -1; float mLastPageOffset = 0; private boolean mResetWindowPages; // Copies from mIWallpaperEngine. HandlerCaller mCaller; Loading Loading @@ -787,7 +787,7 @@ public abstract class WallpaperService extends Service { Log.w(TAG, "Can't notify system because wallpaper connection " + "was not established."); } resetWindowPages(); mResetWindowPages = true; processLocalColors(mPendingXOffset, mPendingXOffsetStep); } catch (RemoteException e) { Log.w(TAG, "Can't notify system because wallpaper connection was lost.", e); Loading Loading @@ -1515,6 +1515,7 @@ public abstract class WallpaperService extends Service { float finalXOffsetStep = xOffsetStep; float finalXOffset = xOffset; mHandler.post(() -> { resetWindowPages(); int xPage = xCurrentPage; EngineWindowPage current; if (mWindowPages.length == 0 || (mWindowPages.length != xPages)) { Loading Loading @@ -1699,15 +1700,15 @@ public abstract class WallpaperService extends Service { private void resetWindowPages() { if (supportsLocalColorExtraction()) return; if (!mResetWindowPages) return; mResetWindowPages = false; mLastWindowPage = -1; mHandler.post(() -> { for (int i = 0; i < mWindowPages.length; i++) { EngineWindowPage page = mWindowPages[i]; if (page != null) { page.setLastUpdateTime(0L); } } }); } private int getRectFPage(RectF area, float step) { Loading @@ -1730,40 +1731,8 @@ public abstract class WallpaperService extends Service { if (DEBUG) { Log.d(TAG, "addLocalColorsAreas adding local color areas " + regions); } List<WallpaperColors> colors = getLocalWallpaperColors(regions); mHandler.post(() -> { float step = mPendingXOffsetStep; if (!validStep(step)) { step = 0; } for (int i = 0; i < regions.size(); i++) { RectF area = regions.get(i); if (!isValid(area)) continue; int pageInx = getRectFPage(area, step); // no page should be null EngineWindowPage page = mWindowPages[pageInx]; if (page != null) { mLocalColorAreas.add(area); page.addArea(area); WallpaperColors color = colors.get(i); if (color != null && !color.equals(page.getColors(area))) { page.addWallpaperColors(area, color); } } else { mLocalColorsToAdd.add(area); } } for (int i = 0; i < colors.size() && colors.get(i) != null; i++) { try { mConnection.onLocalWallpaperColorsChanged(regions.get(i), colors.get(i), mDisplayContext.getDisplayId()); } catch (RemoteException e) { Log.e(TAG, "Error calling Connection.onLocalWallpaperColorsChanged", e); return; } } mLocalColorsToAdd.addAll(regions); processLocalColors(mPendingXOffset, mPendingYOffset); }); Loading @@ -1784,88 +1753,15 @@ public abstract class WallpaperService extends Service { if (!validStep(step)) { return; } for (int i = 0; i < regions.size(); i++) { RectF area = regions.get(i); if (!isValid(area)) continue; int pageInx = getRectFPage(area, step); // no page should be null EngineWindowPage page = mWindowPages[pageInx]; if (page != null) { page.removeArea(area); for (int i = 0; i < mWindowPages.length; i++) { for (int j = 0; j < regions.size(); j++) { EngineWindowPage page = mWindowPages[i]; if (page != null) page.removeArea(regions.get(j)); } } }); } private @NonNull List<WallpaperColors> getLocalWallpaperColors(@NonNull List<RectF> areas) { ArrayList<WallpaperColors> colors = new ArrayList<>(areas.size()); float step = mPendingXOffsetStep; if (!validStep(step)) { if (DEBUG) Log.d(TAG, "invalid step size " + step); step = 1.0f; } for (int i = 0; i < areas.size(); i++) { RectF currentArea = areas.get(i); if (currentArea == null || !isValid(currentArea)) { Log.wtf(TAG, "invalid local area " + currentArea); continue; } EngineWindowPage page; RectF area; int pageIndx; synchronized (mLock) { pageIndx = getRectFPage(currentArea, step); if (mWindowPages.length == 0 || pageIndx < 0 || pageIndx > mWindowPages.length || !isValid(currentArea)) { colors.add(null); continue; } area = generateSubRect(currentArea, pageIndx, mWindowPages.length); page = mWindowPages[pageIndx]; } if (page == null) { colors.add(null); continue; } float finalStep = step; int finalPageIndx = pageIndx; Bitmap screenShot = page.getBitmap(); if (screenShot == null) screenShot = mLastScreenshot; if (screenShot == null || screenShot.isRecycled()) { if (DEBUG) { Log.d(TAG, "invalid bitmap " + screenShot + " for page " + finalPageIndx); } page.setLastUpdateTime(0); colors.add(null); continue; } Bitmap b = screenShot; Rect subImage = new Rect( Math.round(area.left * b.getWidth() / finalStep), Math.round(area.top * b.getHeight()), Math.round(area.right * b.getWidth() / finalStep), Math.round(area.bottom * b.getHeight()) ); subImage = fixRect(b, subImage); if (DEBUG) { Log.d(TAG, "getting subbitmap of " + subImage.toString() + " for RectF " + area.toString() + " screenshot width " + screenShot.getWidth() + " height " + screenShot.getHeight()); } Bitmap colorImg = Bitmap.createBitmap(screenShot, subImage.left, subImage.top, subImage.width(), subImage.height()); if (DEBUG) { Log.d(TAG, "created bitmap " + colorImg.getWidth() + ", " + colorImg.getHeight()); } WallpaperColors color = WallpaperColors.fromBitmap(colorImg); colors.add(color); } return colors; } // fix the rect to be included within the bounds of the bitmap private Rect fixRect(Bitmap b, Rect r) { r.left = r.left >= r.right || r.left >= b.getWidth() || r.left > 0 Loading core/java/android/window/WindowContainerTransaction.java +28 −4 Original line number Diff line number Diff line Loading @@ -368,10 +368,12 @@ public final class WindowContainerTransaction implements Parcelable { */ @NonNull public WindowContainerTransaction setAdjacentRoots( @NonNull WindowContainerToken root1, @NonNull WindowContainerToken root2) { @NonNull WindowContainerToken root1, @NonNull WindowContainerToken root2, boolean moveTogether) { mHierarchyOps.add(HierarchyOp.createForAdjacentRoots( root1.asBinder(), root2.asBinder())); root2.asBinder(), moveTogether)); return this; } Loading Loading @@ -975,6 +977,9 @@ public final class WindowContainerTransaction implements Parcelable { private boolean mReparentTopOnly; // TODO(b/207185041): Remove this once having a single-top root for split screen. private boolean mMoveAdjacentTogether; @Nullable private int[] mWindowingModes; Loading Loading @@ -1033,10 +1038,13 @@ public final class WindowContainerTransaction implements Parcelable { .build(); } public static HierarchyOp createForAdjacentRoots(IBinder root1, IBinder root2) { /** Create a hierarchy op for setting adjacent root tasks. */ public static HierarchyOp createForAdjacentRoots(IBinder root1, IBinder root2, boolean moveTogether) { return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS) .setContainer(root1) .setReparentContainer(root2) .setMoveAdjacentTogether(moveTogether) .build(); } Loading Loading @@ -1070,6 +1078,7 @@ public final class WindowContainerTransaction implements Parcelable { mReparent = copy.mReparent; mToTop = copy.mToTop; mReparentTopOnly = copy.mReparentTopOnly; mMoveAdjacentTogether = copy.mMoveAdjacentTogether; mWindowingModes = copy.mWindowingModes; mActivityTypes = copy.mActivityTypes; mLaunchOptions = copy.mLaunchOptions; Loading @@ -1084,6 +1093,7 @@ public final class WindowContainerTransaction implements Parcelable { mReparent = in.readStrongBinder(); mToTop = in.readBoolean(); mReparentTopOnly = in.readBoolean(); mMoveAdjacentTogether = in.readBoolean(); mWindowingModes = in.createIntArray(); mActivityTypes = in.createIntArray(); mLaunchOptions = in.readBundle(); Loading Loading @@ -1128,6 +1138,10 @@ public final class WindowContainerTransaction implements Parcelable { return mReparentTopOnly; } public boolean getMoveAdjacentTogether() { return mMoveAdjacentTogether; } public int[] getWindowingModes() { return mWindowingModes; } Loading Loading @@ -1175,7 +1189,8 @@ public final class WindowContainerTransaction implements Parcelable { return "{reorder: " + mContainer + " to " + (mToTop ? "top" : "bottom") + "}"; case HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS: return "{SetAdjacentRoot: container=" + mContainer + " adjacentRoot=" + mReparent + "}"; + " adjacentRoot=" + mReparent + " mMoveAdjacentTogether=" + mMoveAdjacentTogether + "}"; case HIERARCHY_OP_TYPE_LAUNCH_TASK: return "{LaunchTask: " + mLaunchOptions + "}"; case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT: Loading Loading @@ -1212,6 +1227,7 @@ public final class WindowContainerTransaction implements Parcelable { dest.writeStrongBinder(mReparent); dest.writeBoolean(mToTop); dest.writeBoolean(mReparentTopOnly); dest.writeBoolean(mMoveAdjacentTogether); dest.writeIntArray(mWindowingModes); dest.writeIntArray(mActivityTypes); dest.writeBundle(mLaunchOptions); Loading Loading @@ -1251,6 +1267,8 @@ public final class WindowContainerTransaction implements Parcelable { private boolean mReparentTopOnly; private boolean mMoveAdjacentTogether; @Nullable private int[] mWindowingModes; Loading Loading @@ -1293,6 +1311,11 @@ public final class WindowContainerTransaction implements Parcelable { return this; } Builder setMoveAdjacentTogether(boolean moveAdjacentTogether) { mMoveAdjacentTogether = moveAdjacentTogether; return this; } Builder setWindowingModes(@Nullable int[] windowingModes) { mWindowingModes = windowingModes; return this; Loading Loading @@ -1336,6 +1359,7 @@ public final class WindowContainerTransaction implements Parcelable { : null; hierarchyOp.mToTop = mToTop; hierarchyOp.mReparentTopOnly = mReparentTopOnly; hierarchyOp.mMoveAdjacentTogether = mMoveAdjacentTogether; hierarchyOp.mLaunchOptions = mLaunchOptions; hierarchyOp.mActivityIntent = mActivityIntent; hierarchyOp.mPendingIntent = mPendingIntent; Loading core/tests/coretests/res/drawable/custom_drawable.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!-- ~ Copyright (C) 2021 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. --> <drawable xmlns:android="http://schemas.android.com/apk/res/android" class="android.window.CustomDrawable" android:drawable="@drawable/bitmap_drawable" android:inset="10dp" /> No newline at end of file Loading
core/api/test-current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -3289,7 +3289,7 @@ package android.window { method @NonNull public android.window.WindowContainerTransaction reparentTasks(@Nullable android.window.WindowContainerToken, @Nullable android.window.WindowContainerToken, @Nullable int[], @Nullable int[], boolean); method @NonNull public android.window.WindowContainerTransaction scheduleFinishEnterPip(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect); method @NonNull public android.window.WindowContainerTransaction setActivityWindowingMode(@NonNull android.window.WindowContainerToken, int); method @NonNull public android.window.WindowContainerTransaction setAdjacentRoots(@NonNull android.window.WindowContainerToken, @NonNull android.window.WindowContainerToken); method @NonNull public android.window.WindowContainerTransaction setAdjacentRoots(@NonNull android.window.WindowContainerToken, @NonNull android.window.WindowContainerToken, boolean); method @NonNull public android.window.WindowContainerTransaction setAdjacentTaskFragments(@NonNull android.os.IBinder, @Nullable android.os.IBinder, @Nullable android.window.WindowContainerTransaction.TaskFragmentAdjacentParams); method @NonNull public android.window.WindowContainerTransaction setAppBounds(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect); method @NonNull public android.window.WindowContainerTransaction setBounds(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect); Loading
core/java/android/app/WallpaperManager.java +44 −37 Original line number Diff line number Diff line Loading @@ -365,19 +365,20 @@ public class WallpaperManager { private int mCachedWallpaperUserId; private Bitmap mDefaultWallpaper; private Handler mMainLooperHandler; private ArrayMap<RectF, ArraySet<LocalWallpaperColorConsumer>> mLocalColorAreas = private ArrayMap<LocalWallpaperColorConsumer, ArraySet<RectF>> mLocalColorCallbackAreas = new ArrayMap<>(); private ILocalWallpaperColorConsumer mLocalColorCallback = new ILocalWallpaperColorConsumer.Stub() { @Override public void onColorsChanged(RectF area, WallpaperColors colors) { ArraySet<LocalWallpaperColorConsumer> callbacks = mLocalColorAreas.get(area); if (callbacks == null) return; for (LocalWallpaperColorConsumer callback: callbacks) { for (LocalWallpaperColorConsumer callback : mLocalColorCallbackAreas.keySet()) { ArraySet<RectF> areas = mLocalColorCallbackAreas.get(callback); if (areas != null && areas.contains(area)) { callback.onColorsChanged(area, colors); } } } }; Globals(IWallpaperManager service, Looper looper) { Loading Loading @@ -420,17 +421,20 @@ public class WallpaperManager { } } public void addOnColorsChangedListener(@NonNull LocalWallpaperColorConsumer callback, public void addOnColorsChangedListener( @NonNull LocalWallpaperColorConsumer callback, @NonNull List<RectF> regions, int which, int userId, int displayId) { synchronized (this) { for (RectF area : regions) { ArraySet<LocalWallpaperColorConsumer> callbacks = mLocalColorAreas.get(area); if (callbacks == null) { callbacks = new ArraySet<>(); mLocalColorAreas.put(area, callbacks); ArraySet<RectF> areas = mLocalColorCallbackAreas.get(callback); if (areas == null) { areas = new ArraySet<>(); mLocalColorCallbackAreas.put(callback, areas); } callbacks.add(callback); areas.add(area); } try { // one way returns immediately mService.addOnLocalColorsChangedListener(mLocalColorCallback, regions, which, userId, displayId); } catch (RemoteException e) { Loading @@ -438,30 +442,33 @@ public class WallpaperManager { Log.e(TAG, "Can't register for local color updates", e); } } } public void removeOnColorsChangedListener( @NonNull LocalWallpaperColorConsumer callback, int which, int userId, int displayId) { final ArrayList<RectF> removeAreas = new ArrayList<>(); for (RectF area : mLocalColorAreas.keySet()) { ArraySet<LocalWallpaperColorConsumer> callbacks = mLocalColorAreas.get(area); if (callbacks == null) continue; callbacks.remove(callback); if (callbacks.size() == 0) { mLocalColorAreas.remove(area); removeAreas.add(area); synchronized (this) { final ArraySet<RectF> removeAreas = mLocalColorCallbackAreas.remove(callback); if (removeAreas == null || removeAreas.size() == 0) { return; } for (LocalWallpaperColorConsumer cb : mLocalColorCallbackAreas.keySet()) { ArraySet<RectF> areas = mLocalColorCallbackAreas.get(cb); if (areas != null && cb != callback) removeAreas.removeAll(areas); } try { if (removeAreas.size() > 0) { // one way returns immediately mService.removeOnLocalColorsChangedListener( mLocalColorCallback, removeAreas, which, userId, displayId); mLocalColorCallback, new ArrayList(removeAreas), which, userId, displayId); } } catch (RemoteException e) { // Can't get colors, connection lost. Log.e(TAG, "Can't unregister for local color updates", e); } } } /** * Stop listening to wallpaper color events. Loading
core/java/android/service/wallpaper/WallpaperService.java +15 −119 Original line number Diff line number Diff line Loading @@ -196,7 +196,7 @@ public abstract class WallpaperService extends Service { EngineWindowPage[] mWindowPages = new EngineWindowPage[1]; Bitmap mLastScreenshot; int mLastWindowPage = -1; float mLastPageOffset = 0; private boolean mResetWindowPages; // Copies from mIWallpaperEngine. HandlerCaller mCaller; Loading Loading @@ -787,7 +787,7 @@ public abstract class WallpaperService extends Service { Log.w(TAG, "Can't notify system because wallpaper connection " + "was not established."); } resetWindowPages(); mResetWindowPages = true; processLocalColors(mPendingXOffset, mPendingXOffsetStep); } catch (RemoteException e) { Log.w(TAG, "Can't notify system because wallpaper connection was lost.", e); Loading Loading @@ -1515,6 +1515,7 @@ public abstract class WallpaperService extends Service { float finalXOffsetStep = xOffsetStep; float finalXOffset = xOffset; mHandler.post(() -> { resetWindowPages(); int xPage = xCurrentPage; EngineWindowPage current; if (mWindowPages.length == 0 || (mWindowPages.length != xPages)) { Loading Loading @@ -1699,15 +1700,15 @@ public abstract class WallpaperService extends Service { private void resetWindowPages() { if (supportsLocalColorExtraction()) return; if (!mResetWindowPages) return; mResetWindowPages = false; mLastWindowPage = -1; mHandler.post(() -> { for (int i = 0; i < mWindowPages.length; i++) { EngineWindowPage page = mWindowPages[i]; if (page != null) { page.setLastUpdateTime(0L); } } }); } private int getRectFPage(RectF area, float step) { Loading @@ -1730,40 +1731,8 @@ public abstract class WallpaperService extends Service { if (DEBUG) { Log.d(TAG, "addLocalColorsAreas adding local color areas " + regions); } List<WallpaperColors> colors = getLocalWallpaperColors(regions); mHandler.post(() -> { float step = mPendingXOffsetStep; if (!validStep(step)) { step = 0; } for (int i = 0; i < regions.size(); i++) { RectF area = regions.get(i); if (!isValid(area)) continue; int pageInx = getRectFPage(area, step); // no page should be null EngineWindowPage page = mWindowPages[pageInx]; if (page != null) { mLocalColorAreas.add(area); page.addArea(area); WallpaperColors color = colors.get(i); if (color != null && !color.equals(page.getColors(area))) { page.addWallpaperColors(area, color); } } else { mLocalColorsToAdd.add(area); } } for (int i = 0; i < colors.size() && colors.get(i) != null; i++) { try { mConnection.onLocalWallpaperColorsChanged(regions.get(i), colors.get(i), mDisplayContext.getDisplayId()); } catch (RemoteException e) { Log.e(TAG, "Error calling Connection.onLocalWallpaperColorsChanged", e); return; } } mLocalColorsToAdd.addAll(regions); processLocalColors(mPendingXOffset, mPendingYOffset); }); Loading @@ -1784,88 +1753,15 @@ public abstract class WallpaperService extends Service { if (!validStep(step)) { return; } for (int i = 0; i < regions.size(); i++) { RectF area = regions.get(i); if (!isValid(area)) continue; int pageInx = getRectFPage(area, step); // no page should be null EngineWindowPage page = mWindowPages[pageInx]; if (page != null) { page.removeArea(area); for (int i = 0; i < mWindowPages.length; i++) { for (int j = 0; j < regions.size(); j++) { EngineWindowPage page = mWindowPages[i]; if (page != null) page.removeArea(regions.get(j)); } } }); } private @NonNull List<WallpaperColors> getLocalWallpaperColors(@NonNull List<RectF> areas) { ArrayList<WallpaperColors> colors = new ArrayList<>(areas.size()); float step = mPendingXOffsetStep; if (!validStep(step)) { if (DEBUG) Log.d(TAG, "invalid step size " + step); step = 1.0f; } for (int i = 0; i < areas.size(); i++) { RectF currentArea = areas.get(i); if (currentArea == null || !isValid(currentArea)) { Log.wtf(TAG, "invalid local area " + currentArea); continue; } EngineWindowPage page; RectF area; int pageIndx; synchronized (mLock) { pageIndx = getRectFPage(currentArea, step); if (mWindowPages.length == 0 || pageIndx < 0 || pageIndx > mWindowPages.length || !isValid(currentArea)) { colors.add(null); continue; } area = generateSubRect(currentArea, pageIndx, mWindowPages.length); page = mWindowPages[pageIndx]; } if (page == null) { colors.add(null); continue; } float finalStep = step; int finalPageIndx = pageIndx; Bitmap screenShot = page.getBitmap(); if (screenShot == null) screenShot = mLastScreenshot; if (screenShot == null || screenShot.isRecycled()) { if (DEBUG) { Log.d(TAG, "invalid bitmap " + screenShot + " for page " + finalPageIndx); } page.setLastUpdateTime(0); colors.add(null); continue; } Bitmap b = screenShot; Rect subImage = new Rect( Math.round(area.left * b.getWidth() / finalStep), Math.round(area.top * b.getHeight()), Math.round(area.right * b.getWidth() / finalStep), Math.round(area.bottom * b.getHeight()) ); subImage = fixRect(b, subImage); if (DEBUG) { Log.d(TAG, "getting subbitmap of " + subImage.toString() + " for RectF " + area.toString() + " screenshot width " + screenShot.getWidth() + " height " + screenShot.getHeight()); } Bitmap colorImg = Bitmap.createBitmap(screenShot, subImage.left, subImage.top, subImage.width(), subImage.height()); if (DEBUG) { Log.d(TAG, "created bitmap " + colorImg.getWidth() + ", " + colorImg.getHeight()); } WallpaperColors color = WallpaperColors.fromBitmap(colorImg); colors.add(color); } return colors; } // fix the rect to be included within the bounds of the bitmap private Rect fixRect(Bitmap b, Rect r) { r.left = r.left >= r.right || r.left >= b.getWidth() || r.left > 0 Loading
core/java/android/window/WindowContainerTransaction.java +28 −4 Original line number Diff line number Diff line Loading @@ -368,10 +368,12 @@ public final class WindowContainerTransaction implements Parcelable { */ @NonNull public WindowContainerTransaction setAdjacentRoots( @NonNull WindowContainerToken root1, @NonNull WindowContainerToken root2) { @NonNull WindowContainerToken root1, @NonNull WindowContainerToken root2, boolean moveTogether) { mHierarchyOps.add(HierarchyOp.createForAdjacentRoots( root1.asBinder(), root2.asBinder())); root2.asBinder(), moveTogether)); return this; } Loading Loading @@ -975,6 +977,9 @@ public final class WindowContainerTransaction implements Parcelable { private boolean mReparentTopOnly; // TODO(b/207185041): Remove this once having a single-top root for split screen. private boolean mMoveAdjacentTogether; @Nullable private int[] mWindowingModes; Loading Loading @@ -1033,10 +1038,13 @@ public final class WindowContainerTransaction implements Parcelable { .build(); } public static HierarchyOp createForAdjacentRoots(IBinder root1, IBinder root2) { /** Create a hierarchy op for setting adjacent root tasks. */ public static HierarchyOp createForAdjacentRoots(IBinder root1, IBinder root2, boolean moveTogether) { return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS) .setContainer(root1) .setReparentContainer(root2) .setMoveAdjacentTogether(moveTogether) .build(); } Loading Loading @@ -1070,6 +1078,7 @@ public final class WindowContainerTransaction implements Parcelable { mReparent = copy.mReparent; mToTop = copy.mToTop; mReparentTopOnly = copy.mReparentTopOnly; mMoveAdjacentTogether = copy.mMoveAdjacentTogether; mWindowingModes = copy.mWindowingModes; mActivityTypes = copy.mActivityTypes; mLaunchOptions = copy.mLaunchOptions; Loading @@ -1084,6 +1093,7 @@ public final class WindowContainerTransaction implements Parcelable { mReparent = in.readStrongBinder(); mToTop = in.readBoolean(); mReparentTopOnly = in.readBoolean(); mMoveAdjacentTogether = in.readBoolean(); mWindowingModes = in.createIntArray(); mActivityTypes = in.createIntArray(); mLaunchOptions = in.readBundle(); Loading Loading @@ -1128,6 +1138,10 @@ public final class WindowContainerTransaction implements Parcelable { return mReparentTopOnly; } public boolean getMoveAdjacentTogether() { return mMoveAdjacentTogether; } public int[] getWindowingModes() { return mWindowingModes; } Loading Loading @@ -1175,7 +1189,8 @@ public final class WindowContainerTransaction implements Parcelable { return "{reorder: " + mContainer + " to " + (mToTop ? "top" : "bottom") + "}"; case HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS: return "{SetAdjacentRoot: container=" + mContainer + " adjacentRoot=" + mReparent + "}"; + " adjacentRoot=" + mReparent + " mMoveAdjacentTogether=" + mMoveAdjacentTogether + "}"; case HIERARCHY_OP_TYPE_LAUNCH_TASK: return "{LaunchTask: " + mLaunchOptions + "}"; case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT: Loading Loading @@ -1212,6 +1227,7 @@ public final class WindowContainerTransaction implements Parcelable { dest.writeStrongBinder(mReparent); dest.writeBoolean(mToTop); dest.writeBoolean(mReparentTopOnly); dest.writeBoolean(mMoveAdjacentTogether); dest.writeIntArray(mWindowingModes); dest.writeIntArray(mActivityTypes); dest.writeBundle(mLaunchOptions); Loading Loading @@ -1251,6 +1267,8 @@ public final class WindowContainerTransaction implements Parcelable { private boolean mReparentTopOnly; private boolean mMoveAdjacentTogether; @Nullable private int[] mWindowingModes; Loading Loading @@ -1293,6 +1311,11 @@ public final class WindowContainerTransaction implements Parcelable { return this; } Builder setMoveAdjacentTogether(boolean moveAdjacentTogether) { mMoveAdjacentTogether = moveAdjacentTogether; return this; } Builder setWindowingModes(@Nullable int[] windowingModes) { mWindowingModes = windowingModes; return this; Loading Loading @@ -1336,6 +1359,7 @@ public final class WindowContainerTransaction implements Parcelable { : null; hierarchyOp.mToTop = mToTop; hierarchyOp.mReparentTopOnly = mReparentTopOnly; hierarchyOp.mMoveAdjacentTogether = mMoveAdjacentTogether; hierarchyOp.mLaunchOptions = mLaunchOptions; hierarchyOp.mActivityIntent = mActivityIntent; hierarchyOp.mPendingIntent = mPendingIntent; Loading
core/tests/coretests/res/drawable/custom_drawable.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!-- ~ Copyright (C) 2021 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. --> <drawable xmlns:android="http://schemas.android.com/apk/res/android" class="android.window.CustomDrawable" android:drawable="@drawable/bitmap_drawable" android:inset="10dp" /> No newline at end of file