Loading core/java/android/app/servertransaction/WindowStateResizeItem.java +13 −5 Original line number Diff line number Diff line Loading @@ -48,12 +48,13 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { private final boolean mReportDraw; private final boolean mForceLayout; private final int mDisplayId; private final boolean mSyncWithBuffers; private final boolean mDragResizing; public WindowStateResizeItem(@NonNull IWindow window, @NonNull ClientWindowFrames frames, boolean reportDraw, @NonNull MergedConfiguration configuration, @NonNull InsetsState insetsState, boolean forceLayout, int displayId, int syncSeqId, boolean dragResizing, public WindowStateResizeItem(@NonNull IWindow window, @NonNull ClientWindowFrames frames, boolean reportDraw, @NonNull MergedConfiguration configuration, @NonNull InsetsState insetsState, boolean forceLayout, int displayId, int syncSeqId, boolean syncWithBuffers, boolean dragResizing, @Nullable ActivityWindowInfo activityWindowInfo) { super(window); mLayout.frames.setTo(frames); Loading @@ -68,6 +69,7 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { mForceLayout = forceLayout; mDisplayId = displayId; mLayout.syncSeqId = syncSeqId; mSyncWithBuffers = syncWithBuffers; mDragResizing = dragResizing; } Loading @@ -77,7 +79,8 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, mReportDraw ? "windowResizedReport" : "windowResized"); try { window.resized(mLayout, mReportDraw, mForceLayout, mDisplayId, mDragResizing); window.resized(mLayout, mReportDraw, mForceLayout, mDisplayId, mSyncWithBuffers, mDragResizing); } catch (RemoteException e) { // Should be a local call. // An exception could happen if the process is restarted. It is safe to ignore since Loading @@ -97,6 +100,7 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { dest.writeBoolean(mReportDraw); dest.writeBoolean(mForceLayout); dest.writeInt(mDisplayId); dest.writeBoolean(mSyncWithBuffers); dest.writeBoolean(mDragResizing); } Loading @@ -107,6 +111,7 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { mReportDraw = in.readBoolean(); mForceLayout = in.readBoolean(); mDisplayId = in.readInt(); mSyncWithBuffers = in.readBoolean(); mDragResizing = in.readBoolean(); } Loading Loading @@ -136,6 +141,7 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { && mForceLayout == other.mForceLayout && mDisplayId == other.mDisplayId && mLayout.syncSeqId == other.mLayout.syncSeqId && mSyncWithBuffers == other.mSyncWithBuffers && mDragResizing == other.mDragResizing && Objects.equals(mLayout.activityWindowInfo, other.mLayout.activityWindowInfo); } Loading @@ -151,6 +157,7 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { result = 31 * result + (mForceLayout ? 1 : 0); result = 31 * result + mDisplayId; result = 31 * result + mLayout.syncSeqId; result = 31 * result + (mSyncWithBuffers ? 1 : 0); result = 31 * result + (mDragResizing ? 1 : 0); result = 31 * result + Objects.hashCode(mLayout.activityWindowInfo); return result; Loading @@ -160,6 +167,7 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { public String toString() { return "WindowStateResizeItem{" + super.toString() + ", reportDrawn=" + mReportDraw + ", syncSeqId=" + mLayout.syncSeqId + (mSyncWithBuffers ? "+buf" : "") + ", configuration=" + mLayout.mergedConfiguration + ", activityWindowInfo=" + mLayout.activityWindowInfo + "}"; Loading core/java/android/service/wallpaper/WallpaperService.java +37 −25 Original line number Diff line number Diff line Loading @@ -321,6 +321,14 @@ public abstract class WallpaperService extends Service { final WindowManager.LayoutParams mLayout = new WindowManager.LayoutParams(); IWindowSession mSession; int mSeqId = -1; /** * Sequence id for the most-recent visibility change. Track this separately since there are * many inputs that effect visibility and they all need to use the same seqId. */ @GuardedBy("mLock") private int mVisSeqId = -1; final Object mLock = new Object(); private final Object mSurfaceReleaseLock = new Object(); Loading Loading @@ -484,9 +492,9 @@ public abstract class WallpaperService extends Service { final BaseIWindow mWindow = new BaseIWindow() { @Override public void resized(WindowRelayoutResult layout, boolean reportDraw, boolean forceLayout, int displayId, boolean dragResizing) { Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED, reportDraw ? 1 : 0, boolean forceLayout, int displayId, boolean syncWithBuffers, boolean dragResizing) { Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED, reportDraw ? 1 : 0, layout.mergedConfiguration); mIWallpaperEngine.mPendingResizeCount.incrementAndGet(); mCaller.sendMessage(msg); Loading @@ -499,12 +507,12 @@ public abstract class WallpaperService extends Service { } @Override public void dispatchAppVisibility(boolean visible) { public void dispatchAppVisibility(boolean visible, int seqId) { // We don't do this in preview mode; we'll let the preview // activity tell us when to run. if (!mIWallpaperEngine.mIsPreview) { Message msg = mCaller.obtainMessageI(MSG_VISIBILITY_CHANGED, visible ? 1 : 0); Message msg = mCaller.obtainMessageII(MSG_VISIBILITY_CHANGED, visible ? 1 : 0, seqId); mCaller.sendMessage(msg); } } Loading Loading @@ -706,7 +714,7 @@ public abstract class WallpaperService extends Service { ? (mWindowFlags&~WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE) : (mWindowFlags|WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); if (mCreated) { updateSurface(false, false, false); updateSurface(false, -1, false); } } Loading @@ -725,7 +733,7 @@ public abstract class WallpaperService extends Service { : (mWindowPrivateFlags & ~WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS); if (mCreated) { updateSurface(false, false, false); updateSurface(false, -1, false); } } Loading @@ -737,7 +745,7 @@ public abstract class WallpaperService extends Service { : (mWindowPrivateFlags & ~WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS); if (mCreated) { updateSurface(false, false, false); updateSurface(false, -1, false); } } Loading Loading @@ -1087,14 +1095,14 @@ public abstract class WallpaperService extends Service { animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { updateSurface(false, false, true); updateSurface(false, -1, true); } }); animator.start(); } else { Log.v(TAG, "Setting wallpaper dimming: " + 0); surfaceControlTransaction.setAlpha(mBbqSurfaceControl, 1.0f).apply(); updateSurface(false, false, true); updateSurface(false, -1, true); } mPreviousWallpaperDimAmount = mWallpaperDimAmount; Loading Loading @@ -1208,7 +1216,7 @@ public abstract class WallpaperService extends Service { } } void updateSurface(boolean forceRelayout, boolean forceReport, boolean redrawNeeded) { void updateSurface(boolean forceRelayout, int seqId, boolean redrawNeeded) { if (mDestroyed) { Log.w(TAG, "Ignoring updateSurface due to destroyed"); return; Loading @@ -1230,6 +1238,8 @@ public abstract class WallpaperService extends Service { final boolean typeChanged = mType != mSurfaceHolder.getRequestedType(); final boolean flagsChanged = mCurWindowFlags != mWindowFlags || mCurWindowPrivateFlags != mWindowPrivateFlags; final boolean reportDraw = false; redrawNeeded = redrawNeeded || reportDraw; if (forceRelayout || creating || surfaceCreating || formatChanged || sizeChanged || typeChanged || flagsChanged || redrawNeeded || !mIWallpaperEngine.mShownReported) { Loading Loading @@ -1459,12 +1469,12 @@ public abstract class WallpaperService extends Service { redrawNeeded |= creating || (relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0; if (forceReport || creating || surfaceCreating if (reportDraw || creating || surfaceCreating || formatChanged || sizeChanged) { if (DEBUG) { RuntimeException e = new RuntimeException(); e.fillInStackTrace(); Log.w(TAG, "forceReport=" + forceReport + " creating=" + creating Log.w(TAG, "reportDraw=" + reportDraw + " creating=" + creating + " formatChanged=" + formatChanged + " sizeChanged=" + sizeChanged, e); } Loading Loading @@ -1627,7 +1637,7 @@ public abstract class WallpaperService extends Service { mReportedVisible = false; Trace.beginSection("WPMS.Engine.updateSurface"); updateSurface(false, false, false); updateSurface(false, -1, false); Trace.endSection(); } Loading Loading @@ -1685,7 +1695,7 @@ public abstract class WallpaperService extends Service { if (DEBUG) Log.v(TAG, "onDisplayPaddingChanged(" + padding + "): " + this); if (!mIWallpaperEngine.mDisplayPadding.equals(padding)) { mIWallpaperEngine.mDisplayPadding.set(padding); updateSurface(true, false, false); updateSurface(true, -1, false); } } } Loading Loading @@ -1742,7 +1752,7 @@ public abstract class WallpaperService extends Service { // sure it is re-created. doOffsetsChanged(false); // It will check mSurfaceCreated so no need to force relayout. updateSurface(false /* forceRelayout */, false /* forceReport */, updateSurface(false /* forceRelayout */, mVisSeqId, false /* redrawNeeded */); } onVisibilityChanged(visible); Loading Loading @@ -2532,8 +2542,8 @@ public abstract class WallpaperService extends Service { } public void setVisibility(boolean visible) { Message msg = mCaller.obtainMessageI(MSG_VISIBILITY_CHANGED, visible ? 1 : 0); Message msg = mCaller.obtainMessageII(MSG_VISIBILITY_CHANGED, visible ? 1 : 0, -1); mCaller.sendMessage(msg); } Loading Loading @@ -2732,7 +2742,7 @@ public abstract class WallpaperService extends Service { return; } case MSG_UPDATE_SURFACE: mEngine.updateSurface(true, false, false); mEngine.updateSurface(true, -1, false); break; case MSG_ZOOM: mEngine.setZoom(Float.intBitsToFloat(message.arg1)); Loading Loading @@ -2763,7 +2773,7 @@ public abstract class WallpaperService extends Service { mEngine.doCommand(cmd); } break; case MSG_WINDOW_RESIZED: { handleResized((MergedConfiguration) message.obj, message.arg1 != 0); handleResized((MergedConfiguration) message.obj, message.arg1); } break; case MSG_WINDOW_MOVED: { // Do nothing. What does it mean for a Wallpaper to move? Loading Loading @@ -2818,10 +2828,12 @@ public abstract class WallpaperService extends Service { * handled (ignore intermediate states). Note that this procedure cannot be skipped if the * configuration is not changed because this is also used to dispatch insets changes. */ private void handleResized(MergedConfiguration config, boolean reportDraw) { private void handleResized(MergedConfiguration config, int seqId) { // The config can be null when retrying for a changed config from relayout, otherwise // it is from IWindow#resized which always sends non-null config. final int pendingCount = config != null ? mPendingResizeCount.decrementAndGet() : -1; final boolean fromResized = config != null; final boolean reportDraw = seqId != 0; final int pendingCount = fromResized ? mPendingResizeCount.decrementAndGet() : -1; if (reportDraw) { mReportDraw = true; } Loading @@ -2833,14 +2845,14 @@ public abstract class WallpaperService extends Service { } return; } if (config != null) { if (fromResized) { if (DEBUG) { Log.d(TAG, "Update config from resized, bounds=" + config.getMergedConfiguration().windowConfiguration.getMaxBounds()); } mEngine.mMergedConfiguration.setTo(config); } mEngine.updateSurface(true /* forceRelayout */, false /* forceReport */, mReportDraw); mEngine.updateSurface(true /* forceRelayout */, -1 /* seqId */, mReportDraw); mReportDraw = false; mEngine.doOffsetsChanged(true); mEngine.scaleAndCropScreenshot(); Loading core/java/android/view/IWindow.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ oneway interface IWindow { * the system server. */ void resized(in WindowRelayoutResult layout, boolean reportDraw, boolean forceLayout, int displayId, boolean dragResizing); int displayId, boolean syncWithBuffers, boolean dragResizing); /** * Called when this window retrieved control over a specified set of insets sources. Loading @@ -83,7 +83,7 @@ oneway interface IWindow { void hideInsets(int types, in @nullable ImeTracker.Token statsToken); void moved(int newX, int newY); void dispatchAppVisibility(boolean visible); void dispatchAppVisibility(boolean visible, int seqId); void dispatchGetNewSurface(); void closeSystemDialogs(String reason); Loading core/java/android/view/IWindowSession.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ interface IWindowSession { * @param viewVisibility Window root view's visibility. * @param flags Request flags: {@link WindowManagerGlobal#RELAYOUT_INSETS_PENDING}. * @param seq The calling sequence of {@link #relayout} and {@link #relayoutAsync}. * @param lastSyncSeqId The last SyncSeqId that the client applied. * @param syncSeqId The latest SyncSeqId that the client is using. * @param outRelayoutResult Data object contains the info to be returned from server side. * @param outSurface Object in which is placed the new display surface. * @return int Result flags, defined in {@link WindowManagerGlobal}. Loading Loading @@ -359,7 +359,7 @@ interface IWindowSession { /** * Returns whether this window needs to cancel draw and retry later. */ boolean cancelDraw(IWindow window); boolean cancelDraw(IWindow window, int seqId); /** * Moves the focus to the adjacent window if there is one in the given direction. This can only Loading core/java/android/view/ViewRootImpl.java +27 −19 Original line number Diff line number Diff line Loading @@ -2263,7 +2263,7 @@ public final class ViewRootImpl implements ViewParent, return originalMode; } void handleAppVisibility(boolean visible) { void handleAppVisibility(boolean visible, int seqId) { if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) { Trace.instant(Trace.TRACE_TAG_VIEW, TextUtils.formatSimple( "%s visibilityChanged oldVisibility=%b newVisibility=%b", mTag, Loading Loading @@ -2298,7 +2298,7 @@ public final class ViewRootImpl implements ViewParent, /** Handles messages {@link #MSG_RESIZED} and {@link #MSG_RESIZED_REPORT}. */ private void handleResized(ClientWindowFrames frames, boolean reportDraw, MergedConfiguration mergedConfiguration, InsetsState insetsState, boolean forceLayout, int displayId, int syncSeqId, boolean dragResizing, int displayId, int seqId, boolean syncWithBuffers, boolean dragResizing, @Nullable ActivityWindowInfo activityWindowInfo) { if (!mAdded) { return; Loading Loading @@ -2367,7 +2367,7 @@ public final class ViewRootImpl implements ViewParent, mForceNextWindowRelayout |= forceLayout; mPendingAlwaysConsumeSystemBars = false; mSyncSeqId = syncSeqId > mSyncSeqId ? syncSeqId : mSyncSeqId; mSyncSeqId = seqId > mSyncSeqId ? seqId : mSyncSeqId; if (reportDraw) { reportNextDraw("resized"); Loading Loading @@ -4206,7 +4206,7 @@ public final class ViewRootImpl implements ViewParent, // traversal. So we don't know if the sync is complete that we can continue to draw. // Here invokes cancelDraw to obtain the information. try { cancelDraw = mWindowSession.cancelDraw(mWindow); cancelDraw = mWindowSession.cancelDraw(mWindow, 0); cancelReason = "wm_sync"; if (DEBUG_BLAST) { Log.d(mTag, "cancelDraw returned " + cancelDraw); Loading Loading @@ -6982,7 +6982,7 @@ public final class ViewRootImpl implements ViewParent, doProcessInputEvents(); break; case MSG_DISPATCH_APP_VISIBILITY: handleAppVisibility(msg.arg1 != 0); handleAppVisibility(msg.arg1 != 0, msg.arg2); break; case MSG_DISPATCH_GET_NEW_SURFACE: handleGetNewSurface(); Loading @@ -6994,10 +6994,11 @@ public final class ViewRootImpl implements ViewParent, final boolean reportDraw = msg.what == MSG_RESIZED_REPORT; final boolean forceLayout = args.argi1 != 0; final int displayId = args.argi2; final boolean dragResizing = args.argi3 != 0; final boolean syncWithBuffers = args.argi3 != 0; final boolean dragResizing = args.argi4 != 0; handleResized(layout.frames, reportDraw, layout.mergedConfiguration, layout.insetsState, forceLayout, displayId, layout.syncSeqId, dragResizing, layout.activityWindowInfo); syncWithBuffers, dragResizing, layout.activityWindowInfo); args.recycle(); break; } Loading Loading @@ -9599,16 +9600,17 @@ public final class ViewRootImpl implements ViewParent, final int requestedHeight = (int) (measuredHeight * appScale + 0.5f); int relayoutResult = 0; mRelayoutSeq++; final int seqId = mLastSyncSeqId; if (relayoutAsync) { mWindowSession.relayoutAsync(mWindow, params, requestedWidth, requestedHeight, viewVisibility, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, mRelayoutSeq, mLastSyncSeqId); seqId); } else { relayoutResult = mWindowSession.relayout(mWindow, params, requestedWidth, requestedHeight, viewVisibility, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, mRelayoutSeq, mLastSyncSeqId, mRelayoutResult, mSurfaceControl); mRelayoutSeq, seqId, mRelayoutResult, mSurfaceControl); mRelayoutRequested = true; onClientWindowFramesChanged(mTmpFrames); Loading Loading @@ -10272,13 +10274,14 @@ public final class ViewRootImpl implements ViewParent, @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private void dispatchResized(WindowRelayoutResult layout, boolean reportDraw, boolean forceLayout, int displayId, boolean dragResizing) { boolean forceLayout, int displayId, boolean syncWithBuffers, boolean dragResizing) { Message msg = mHandler.obtainMessage(reportDraw ? MSG_RESIZED_REPORT : MSG_RESIZED); SomeArgs args = SomeArgs.obtain(); args.arg1 = layout; args.argi1 = forceLayout ? 1 : 0; args.argi2 = displayId; args.argi3 = dragResizing ? 1 : 0; args.argi3 = syncWithBuffers ? 1 : 0; args.argi4 = dragResizing ? 1 : 0; msg.obj = args; mHandler.sendMessage(msg); Loading Loading @@ -11017,9 +11020,13 @@ public final class ViewRootImpl implements ViewParent, synthesizeInputEvent(event); } public void dispatchAppVisibility(boolean visible) { /** * Notify that the visibility has changed */ public void dispatchAppVisibility(boolean visible, int seqId) { Message msg = mHandler.obtainMessage(MSG_DISPATCH_APP_VISIBILITY); msg.arg1 = visible ? 1 : 0; msg.arg2 = seqId; mHandler.sendMessage(msg); } Loading Loading @@ -11777,8 +11784,8 @@ public final class ViewRootImpl implements ViewParent, } @Override public void resized(WindowRelayoutResult layout, boolean reportDraw, boolean forceLayout, int displayId, boolean dragResizing) { public void resized(WindowRelayoutResult layout, boolean reportDraw, boolean forceLayout, int displayId, boolean syncWithBuffers, boolean dragResizing) { final boolean isFromResizeItem = mIsFromTransactionItem; mIsFromTransactionItem = false; // Although this is a AIDL method, it will only be triggered in local process through Loading @@ -11797,8 +11804,8 @@ public final class ViewRootImpl implements ViewParent, if (isFromResizeItem && viewAncestor.mHandler.getLooper() == ActivityThread.currentActivityThread().getLooper()) { viewAncestor.handleResized(layout.frames, reportDraw, layout.mergedConfiguration, layout.insetsState, forceLayout, displayId, layout.syncSeqId, dragResizing, layout.activityWindowInfo); layout.insetsState, forceLayout, displayId, layout.syncSeqId, syncWithBuffers, dragResizing, layout.activityWindowInfo); return; } // The the parameters from WindowStateResizeItem are already copied. Loading @@ -11807,7 +11814,8 @@ public final class ViewRootImpl implements ViewParent, if (needsCopy) { layout = new WindowRelayoutResult(layout); } viewAncestor.dispatchResized(layout, reportDraw, forceLayout, displayId, dragResizing); viewAncestor.dispatchResized(layout, reportDraw, forceLayout, displayId, syncWithBuffers, dragResizing); } @Override Loading Loading @@ -11879,10 +11887,10 @@ public final class ViewRootImpl implements ViewParent, } @Override public void dispatchAppVisibility(boolean visible) { public void dispatchAppVisibility(boolean visible, int seqId) { final ViewRootImpl viewAncestor = mViewAncestor.get(); if (viewAncestor != null) { viewAncestor.dispatchAppVisibility(visible); viewAncestor.dispatchAppVisibility(visible, seqId); } } Loading Loading
core/java/android/app/servertransaction/WindowStateResizeItem.java +13 −5 Original line number Diff line number Diff line Loading @@ -48,12 +48,13 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { private final boolean mReportDraw; private final boolean mForceLayout; private final int mDisplayId; private final boolean mSyncWithBuffers; private final boolean mDragResizing; public WindowStateResizeItem(@NonNull IWindow window, @NonNull ClientWindowFrames frames, boolean reportDraw, @NonNull MergedConfiguration configuration, @NonNull InsetsState insetsState, boolean forceLayout, int displayId, int syncSeqId, boolean dragResizing, public WindowStateResizeItem(@NonNull IWindow window, @NonNull ClientWindowFrames frames, boolean reportDraw, @NonNull MergedConfiguration configuration, @NonNull InsetsState insetsState, boolean forceLayout, int displayId, int syncSeqId, boolean syncWithBuffers, boolean dragResizing, @Nullable ActivityWindowInfo activityWindowInfo) { super(window); mLayout.frames.setTo(frames); Loading @@ -68,6 +69,7 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { mForceLayout = forceLayout; mDisplayId = displayId; mLayout.syncSeqId = syncSeqId; mSyncWithBuffers = syncWithBuffers; mDragResizing = dragResizing; } Loading @@ -77,7 +79,8 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, mReportDraw ? "windowResizedReport" : "windowResized"); try { window.resized(mLayout, mReportDraw, mForceLayout, mDisplayId, mDragResizing); window.resized(mLayout, mReportDraw, mForceLayout, mDisplayId, mSyncWithBuffers, mDragResizing); } catch (RemoteException e) { // Should be a local call. // An exception could happen if the process is restarted. It is safe to ignore since Loading @@ -97,6 +100,7 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { dest.writeBoolean(mReportDraw); dest.writeBoolean(mForceLayout); dest.writeInt(mDisplayId); dest.writeBoolean(mSyncWithBuffers); dest.writeBoolean(mDragResizing); } Loading @@ -107,6 +111,7 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { mReportDraw = in.readBoolean(); mForceLayout = in.readBoolean(); mDisplayId = in.readInt(); mSyncWithBuffers = in.readBoolean(); mDragResizing = in.readBoolean(); } Loading Loading @@ -136,6 +141,7 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { && mForceLayout == other.mForceLayout && mDisplayId == other.mDisplayId && mLayout.syncSeqId == other.mLayout.syncSeqId && mSyncWithBuffers == other.mSyncWithBuffers && mDragResizing == other.mDragResizing && Objects.equals(mLayout.activityWindowInfo, other.mLayout.activityWindowInfo); } Loading @@ -151,6 +157,7 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { result = 31 * result + (mForceLayout ? 1 : 0); result = 31 * result + mDisplayId; result = 31 * result + mLayout.syncSeqId; result = 31 * result + (mSyncWithBuffers ? 1 : 0); result = 31 * result + (mDragResizing ? 1 : 0); result = 31 * result + Objects.hashCode(mLayout.activityWindowInfo); return result; Loading @@ -160,6 +167,7 @@ public class WindowStateResizeItem extends WindowStateTransactionItem { public String toString() { return "WindowStateResizeItem{" + super.toString() + ", reportDrawn=" + mReportDraw + ", syncSeqId=" + mLayout.syncSeqId + (mSyncWithBuffers ? "+buf" : "") + ", configuration=" + mLayout.mergedConfiguration + ", activityWindowInfo=" + mLayout.activityWindowInfo + "}"; Loading
core/java/android/service/wallpaper/WallpaperService.java +37 −25 Original line number Diff line number Diff line Loading @@ -321,6 +321,14 @@ public abstract class WallpaperService extends Service { final WindowManager.LayoutParams mLayout = new WindowManager.LayoutParams(); IWindowSession mSession; int mSeqId = -1; /** * Sequence id for the most-recent visibility change. Track this separately since there are * many inputs that effect visibility and they all need to use the same seqId. */ @GuardedBy("mLock") private int mVisSeqId = -1; final Object mLock = new Object(); private final Object mSurfaceReleaseLock = new Object(); Loading Loading @@ -484,9 +492,9 @@ public abstract class WallpaperService extends Service { final BaseIWindow mWindow = new BaseIWindow() { @Override public void resized(WindowRelayoutResult layout, boolean reportDraw, boolean forceLayout, int displayId, boolean dragResizing) { Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED, reportDraw ? 1 : 0, boolean forceLayout, int displayId, boolean syncWithBuffers, boolean dragResizing) { Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED, reportDraw ? 1 : 0, layout.mergedConfiguration); mIWallpaperEngine.mPendingResizeCount.incrementAndGet(); mCaller.sendMessage(msg); Loading @@ -499,12 +507,12 @@ public abstract class WallpaperService extends Service { } @Override public void dispatchAppVisibility(boolean visible) { public void dispatchAppVisibility(boolean visible, int seqId) { // We don't do this in preview mode; we'll let the preview // activity tell us when to run. if (!mIWallpaperEngine.mIsPreview) { Message msg = mCaller.obtainMessageI(MSG_VISIBILITY_CHANGED, visible ? 1 : 0); Message msg = mCaller.obtainMessageII(MSG_VISIBILITY_CHANGED, visible ? 1 : 0, seqId); mCaller.sendMessage(msg); } } Loading Loading @@ -706,7 +714,7 @@ public abstract class WallpaperService extends Service { ? (mWindowFlags&~WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE) : (mWindowFlags|WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); if (mCreated) { updateSurface(false, false, false); updateSurface(false, -1, false); } } Loading @@ -725,7 +733,7 @@ public abstract class WallpaperService extends Service { : (mWindowPrivateFlags & ~WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS); if (mCreated) { updateSurface(false, false, false); updateSurface(false, -1, false); } } Loading @@ -737,7 +745,7 @@ public abstract class WallpaperService extends Service { : (mWindowPrivateFlags & ~WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS); if (mCreated) { updateSurface(false, false, false); updateSurface(false, -1, false); } } Loading Loading @@ -1087,14 +1095,14 @@ public abstract class WallpaperService extends Service { animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { updateSurface(false, false, true); updateSurface(false, -1, true); } }); animator.start(); } else { Log.v(TAG, "Setting wallpaper dimming: " + 0); surfaceControlTransaction.setAlpha(mBbqSurfaceControl, 1.0f).apply(); updateSurface(false, false, true); updateSurface(false, -1, true); } mPreviousWallpaperDimAmount = mWallpaperDimAmount; Loading Loading @@ -1208,7 +1216,7 @@ public abstract class WallpaperService extends Service { } } void updateSurface(boolean forceRelayout, boolean forceReport, boolean redrawNeeded) { void updateSurface(boolean forceRelayout, int seqId, boolean redrawNeeded) { if (mDestroyed) { Log.w(TAG, "Ignoring updateSurface due to destroyed"); return; Loading @@ -1230,6 +1238,8 @@ public abstract class WallpaperService extends Service { final boolean typeChanged = mType != mSurfaceHolder.getRequestedType(); final boolean flagsChanged = mCurWindowFlags != mWindowFlags || mCurWindowPrivateFlags != mWindowPrivateFlags; final boolean reportDraw = false; redrawNeeded = redrawNeeded || reportDraw; if (forceRelayout || creating || surfaceCreating || formatChanged || sizeChanged || typeChanged || flagsChanged || redrawNeeded || !mIWallpaperEngine.mShownReported) { Loading Loading @@ -1459,12 +1469,12 @@ public abstract class WallpaperService extends Service { redrawNeeded |= creating || (relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0; if (forceReport || creating || surfaceCreating if (reportDraw || creating || surfaceCreating || formatChanged || sizeChanged) { if (DEBUG) { RuntimeException e = new RuntimeException(); e.fillInStackTrace(); Log.w(TAG, "forceReport=" + forceReport + " creating=" + creating Log.w(TAG, "reportDraw=" + reportDraw + " creating=" + creating + " formatChanged=" + formatChanged + " sizeChanged=" + sizeChanged, e); } Loading Loading @@ -1627,7 +1637,7 @@ public abstract class WallpaperService extends Service { mReportedVisible = false; Trace.beginSection("WPMS.Engine.updateSurface"); updateSurface(false, false, false); updateSurface(false, -1, false); Trace.endSection(); } Loading Loading @@ -1685,7 +1695,7 @@ public abstract class WallpaperService extends Service { if (DEBUG) Log.v(TAG, "onDisplayPaddingChanged(" + padding + "): " + this); if (!mIWallpaperEngine.mDisplayPadding.equals(padding)) { mIWallpaperEngine.mDisplayPadding.set(padding); updateSurface(true, false, false); updateSurface(true, -1, false); } } } Loading Loading @@ -1742,7 +1752,7 @@ public abstract class WallpaperService extends Service { // sure it is re-created. doOffsetsChanged(false); // It will check mSurfaceCreated so no need to force relayout. updateSurface(false /* forceRelayout */, false /* forceReport */, updateSurface(false /* forceRelayout */, mVisSeqId, false /* redrawNeeded */); } onVisibilityChanged(visible); Loading Loading @@ -2532,8 +2542,8 @@ public abstract class WallpaperService extends Service { } public void setVisibility(boolean visible) { Message msg = mCaller.obtainMessageI(MSG_VISIBILITY_CHANGED, visible ? 1 : 0); Message msg = mCaller.obtainMessageII(MSG_VISIBILITY_CHANGED, visible ? 1 : 0, -1); mCaller.sendMessage(msg); } Loading Loading @@ -2732,7 +2742,7 @@ public abstract class WallpaperService extends Service { return; } case MSG_UPDATE_SURFACE: mEngine.updateSurface(true, false, false); mEngine.updateSurface(true, -1, false); break; case MSG_ZOOM: mEngine.setZoom(Float.intBitsToFloat(message.arg1)); Loading Loading @@ -2763,7 +2773,7 @@ public abstract class WallpaperService extends Service { mEngine.doCommand(cmd); } break; case MSG_WINDOW_RESIZED: { handleResized((MergedConfiguration) message.obj, message.arg1 != 0); handleResized((MergedConfiguration) message.obj, message.arg1); } break; case MSG_WINDOW_MOVED: { // Do nothing. What does it mean for a Wallpaper to move? Loading Loading @@ -2818,10 +2828,12 @@ public abstract class WallpaperService extends Service { * handled (ignore intermediate states). Note that this procedure cannot be skipped if the * configuration is not changed because this is also used to dispatch insets changes. */ private void handleResized(MergedConfiguration config, boolean reportDraw) { private void handleResized(MergedConfiguration config, int seqId) { // The config can be null when retrying for a changed config from relayout, otherwise // it is from IWindow#resized which always sends non-null config. final int pendingCount = config != null ? mPendingResizeCount.decrementAndGet() : -1; final boolean fromResized = config != null; final boolean reportDraw = seqId != 0; final int pendingCount = fromResized ? mPendingResizeCount.decrementAndGet() : -1; if (reportDraw) { mReportDraw = true; } Loading @@ -2833,14 +2845,14 @@ public abstract class WallpaperService extends Service { } return; } if (config != null) { if (fromResized) { if (DEBUG) { Log.d(TAG, "Update config from resized, bounds=" + config.getMergedConfiguration().windowConfiguration.getMaxBounds()); } mEngine.mMergedConfiguration.setTo(config); } mEngine.updateSurface(true /* forceRelayout */, false /* forceReport */, mReportDraw); mEngine.updateSurface(true /* forceRelayout */, -1 /* seqId */, mReportDraw); mReportDraw = false; mEngine.doOffsetsChanged(true); mEngine.scaleAndCropScreenshot(); Loading
core/java/android/view/IWindow.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ oneway interface IWindow { * the system server. */ void resized(in WindowRelayoutResult layout, boolean reportDraw, boolean forceLayout, int displayId, boolean dragResizing); int displayId, boolean syncWithBuffers, boolean dragResizing); /** * Called when this window retrieved control over a specified set of insets sources. Loading @@ -83,7 +83,7 @@ oneway interface IWindow { void hideInsets(int types, in @nullable ImeTracker.Token statsToken); void moved(int newX, int newY); void dispatchAppVisibility(boolean visible); void dispatchAppVisibility(boolean visible, int seqId); void dispatchGetNewSurface(); void closeSystemDialogs(String reason); Loading
core/java/android/view/IWindowSession.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ interface IWindowSession { * @param viewVisibility Window root view's visibility. * @param flags Request flags: {@link WindowManagerGlobal#RELAYOUT_INSETS_PENDING}. * @param seq The calling sequence of {@link #relayout} and {@link #relayoutAsync}. * @param lastSyncSeqId The last SyncSeqId that the client applied. * @param syncSeqId The latest SyncSeqId that the client is using. * @param outRelayoutResult Data object contains the info to be returned from server side. * @param outSurface Object in which is placed the new display surface. * @return int Result flags, defined in {@link WindowManagerGlobal}. Loading Loading @@ -359,7 +359,7 @@ interface IWindowSession { /** * Returns whether this window needs to cancel draw and retry later. */ boolean cancelDraw(IWindow window); boolean cancelDraw(IWindow window, int seqId); /** * Moves the focus to the adjacent window if there is one in the given direction. This can only Loading
core/java/android/view/ViewRootImpl.java +27 −19 Original line number Diff line number Diff line Loading @@ -2263,7 +2263,7 @@ public final class ViewRootImpl implements ViewParent, return originalMode; } void handleAppVisibility(boolean visible) { void handleAppVisibility(boolean visible, int seqId) { if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) { Trace.instant(Trace.TRACE_TAG_VIEW, TextUtils.formatSimple( "%s visibilityChanged oldVisibility=%b newVisibility=%b", mTag, Loading Loading @@ -2298,7 +2298,7 @@ public final class ViewRootImpl implements ViewParent, /** Handles messages {@link #MSG_RESIZED} and {@link #MSG_RESIZED_REPORT}. */ private void handleResized(ClientWindowFrames frames, boolean reportDraw, MergedConfiguration mergedConfiguration, InsetsState insetsState, boolean forceLayout, int displayId, int syncSeqId, boolean dragResizing, int displayId, int seqId, boolean syncWithBuffers, boolean dragResizing, @Nullable ActivityWindowInfo activityWindowInfo) { if (!mAdded) { return; Loading Loading @@ -2367,7 +2367,7 @@ public final class ViewRootImpl implements ViewParent, mForceNextWindowRelayout |= forceLayout; mPendingAlwaysConsumeSystemBars = false; mSyncSeqId = syncSeqId > mSyncSeqId ? syncSeqId : mSyncSeqId; mSyncSeqId = seqId > mSyncSeqId ? seqId : mSyncSeqId; if (reportDraw) { reportNextDraw("resized"); Loading Loading @@ -4206,7 +4206,7 @@ public final class ViewRootImpl implements ViewParent, // traversal. So we don't know if the sync is complete that we can continue to draw. // Here invokes cancelDraw to obtain the information. try { cancelDraw = mWindowSession.cancelDraw(mWindow); cancelDraw = mWindowSession.cancelDraw(mWindow, 0); cancelReason = "wm_sync"; if (DEBUG_BLAST) { Log.d(mTag, "cancelDraw returned " + cancelDraw); Loading Loading @@ -6982,7 +6982,7 @@ public final class ViewRootImpl implements ViewParent, doProcessInputEvents(); break; case MSG_DISPATCH_APP_VISIBILITY: handleAppVisibility(msg.arg1 != 0); handleAppVisibility(msg.arg1 != 0, msg.arg2); break; case MSG_DISPATCH_GET_NEW_SURFACE: handleGetNewSurface(); Loading @@ -6994,10 +6994,11 @@ public final class ViewRootImpl implements ViewParent, final boolean reportDraw = msg.what == MSG_RESIZED_REPORT; final boolean forceLayout = args.argi1 != 0; final int displayId = args.argi2; final boolean dragResizing = args.argi3 != 0; final boolean syncWithBuffers = args.argi3 != 0; final boolean dragResizing = args.argi4 != 0; handleResized(layout.frames, reportDraw, layout.mergedConfiguration, layout.insetsState, forceLayout, displayId, layout.syncSeqId, dragResizing, layout.activityWindowInfo); syncWithBuffers, dragResizing, layout.activityWindowInfo); args.recycle(); break; } Loading Loading @@ -9599,16 +9600,17 @@ public final class ViewRootImpl implements ViewParent, final int requestedHeight = (int) (measuredHeight * appScale + 0.5f); int relayoutResult = 0; mRelayoutSeq++; final int seqId = mLastSyncSeqId; if (relayoutAsync) { mWindowSession.relayoutAsync(mWindow, params, requestedWidth, requestedHeight, viewVisibility, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, mRelayoutSeq, mLastSyncSeqId); seqId); } else { relayoutResult = mWindowSession.relayout(mWindow, params, requestedWidth, requestedHeight, viewVisibility, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, mRelayoutSeq, mLastSyncSeqId, mRelayoutResult, mSurfaceControl); mRelayoutSeq, seqId, mRelayoutResult, mSurfaceControl); mRelayoutRequested = true; onClientWindowFramesChanged(mTmpFrames); Loading Loading @@ -10272,13 +10274,14 @@ public final class ViewRootImpl implements ViewParent, @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private void dispatchResized(WindowRelayoutResult layout, boolean reportDraw, boolean forceLayout, int displayId, boolean dragResizing) { boolean forceLayout, int displayId, boolean syncWithBuffers, boolean dragResizing) { Message msg = mHandler.obtainMessage(reportDraw ? MSG_RESIZED_REPORT : MSG_RESIZED); SomeArgs args = SomeArgs.obtain(); args.arg1 = layout; args.argi1 = forceLayout ? 1 : 0; args.argi2 = displayId; args.argi3 = dragResizing ? 1 : 0; args.argi3 = syncWithBuffers ? 1 : 0; args.argi4 = dragResizing ? 1 : 0; msg.obj = args; mHandler.sendMessage(msg); Loading Loading @@ -11017,9 +11020,13 @@ public final class ViewRootImpl implements ViewParent, synthesizeInputEvent(event); } public void dispatchAppVisibility(boolean visible) { /** * Notify that the visibility has changed */ public void dispatchAppVisibility(boolean visible, int seqId) { Message msg = mHandler.obtainMessage(MSG_DISPATCH_APP_VISIBILITY); msg.arg1 = visible ? 1 : 0; msg.arg2 = seqId; mHandler.sendMessage(msg); } Loading Loading @@ -11777,8 +11784,8 @@ public final class ViewRootImpl implements ViewParent, } @Override public void resized(WindowRelayoutResult layout, boolean reportDraw, boolean forceLayout, int displayId, boolean dragResizing) { public void resized(WindowRelayoutResult layout, boolean reportDraw, boolean forceLayout, int displayId, boolean syncWithBuffers, boolean dragResizing) { final boolean isFromResizeItem = mIsFromTransactionItem; mIsFromTransactionItem = false; // Although this is a AIDL method, it will only be triggered in local process through Loading @@ -11797,8 +11804,8 @@ public final class ViewRootImpl implements ViewParent, if (isFromResizeItem && viewAncestor.mHandler.getLooper() == ActivityThread.currentActivityThread().getLooper()) { viewAncestor.handleResized(layout.frames, reportDraw, layout.mergedConfiguration, layout.insetsState, forceLayout, displayId, layout.syncSeqId, dragResizing, layout.activityWindowInfo); layout.insetsState, forceLayout, displayId, layout.syncSeqId, syncWithBuffers, dragResizing, layout.activityWindowInfo); return; } // The the parameters from WindowStateResizeItem are already copied. Loading @@ -11807,7 +11814,8 @@ public final class ViewRootImpl implements ViewParent, if (needsCopy) { layout = new WindowRelayoutResult(layout); } viewAncestor.dispatchResized(layout, reportDraw, forceLayout, displayId, dragResizing); viewAncestor.dispatchResized(layout, reportDraw, forceLayout, displayId, syncWithBuffers, dragResizing); } @Override Loading Loading @@ -11879,10 +11887,10 @@ public final class ViewRootImpl implements ViewParent, } @Override public void dispatchAppVisibility(boolean visible) { public void dispatchAppVisibility(boolean visible, int seqId) { final ViewRootImpl viewAncestor = mViewAncestor.get(); if (viewAncestor != null) { viewAncestor.dispatchAppVisibility(visible); viewAncestor.dispatchAppVisibility(visible, seqId); } } Loading