diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-07-26 02:16:45 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-07-26 02:16:45 +0000 |
commit | 86e0e0ba19c81b974b9bc26524b7a16f5f98f82a (patch) | |
tree | a98efe98de3d969ad6a4e7fe30c47ca93c7d1f6b | |
parent | 7f91561b59d74fa9a495ab94c0568c467e13e8e3 (diff) | |
parent | 475ca92491fe525fec4442472c532d4bec4d69dd (diff) | |
download | base-86e0e0ba19c81b974b9bc26524b7a16f5f98f82a.tar.gz |
Merge cherrypicks of [8894175, 8894118, 8894119, 8894120, 8891937, 8894143, 8894144] into qt-release
Change-Id: I308f140fb027a19e9e4a5f4c9d74d0eb0b6263ed
-rw-r--r-- | core/java/android/os/SharedMemory.java | 13 | ||||
-rw-r--r-- | services/core/java/com/android/server/wm/AppWindowToken.java | 13 | ||||
-rw-r--r-- | services/core/java/com/android/server/wm/WindowState.java | 7 |
3 files changed, 28 insertions, 5 deletions
diff --git a/core/java/android/os/SharedMemory.java b/core/java/android/os/SharedMemory.java index 57a88012a31a..0540e3611b52 100644 --- a/core/java/android/os/SharedMemory.java +++ b/core/java/android/os/SharedMemory.java @@ -62,7 +62,7 @@ public final class SharedMemory implements Parcelable, Closeable { mMemoryRegistration = new MemoryRegistration(mSize); mCleaner = Cleaner.create(mFileDescriptor, - new Closer(mFileDescriptor, mMemoryRegistration)); + new Closer(mFileDescriptor.getInt$(), mMemoryRegistration)); } /** @@ -259,6 +259,9 @@ public final class SharedMemory implements Parcelable, Closeable { mCleaner.clean(); mCleaner = null; } + + // Cleaner.clean doesn't clear the value of the file descriptor. + mFileDescriptor.setInt$(-1); } @Override @@ -290,10 +293,10 @@ public final class SharedMemory implements Parcelable, Closeable { * Cleaner that closes the FD */ private static final class Closer implements Runnable { - private FileDescriptor mFd; + private int mFd; private MemoryRegistration mMemoryReference; - private Closer(FileDescriptor fd, MemoryRegistration memoryReference) { + private Closer(int fd, MemoryRegistration memoryReference) { mFd = fd; mMemoryReference = memoryReference; } @@ -301,7 +304,9 @@ public final class SharedMemory implements Parcelable, Closeable { @Override public void run() { try { - Os.close(mFd); + FileDescriptor fd = new FileDescriptor(); + fd.setInt$(mFd); + Os.close(fd); } catch (ErrnoException e) { /* swallow error */ } mMemoryReference.release(); mMemoryReference = null; diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index 03cae429904f..eab5e0dd270e 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -79,6 +79,7 @@ import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL; import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES; import static com.android.server.wm.WindowManagerService.logWithStack; import static com.android.server.wm.WindowState.LEGACY_POLICY_VISIBILITY; +import static com.android.server.wm.WindowStateAnimator.HAS_DRAWN; import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_AFTER_ANIM; import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_BEFORE_ANIM; @@ -540,6 +541,18 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree // If the app was already visible, don't reset the waitingToShow state. if (isHidden()) { waitingToShow = true; + + // Let's reset the draw state in order to prevent the starting window to be + // immediately dismissed when the app still has the surface. + forAllWindows(w -> { + if (w.mWinAnimator.mDrawState == HAS_DRAWN) { + w.mWinAnimator.resetDrawState(); + + // Force add to mResizingWindows, so that we are guaranteed to get + // another reportDrawn callback. + w.resetLastContentInsets(); + } + }, true /* traverseTopToBottom */); } } diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 43ad091b08c0..703fe4ac867b 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -1623,7 +1623,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP || !mRelayoutCalled || (atoken == null && mToken.isHidden()) || (atoken != null && atoken.hiddenRequested) - || isParentWindowHidden() + || isParentWindowGoneForLayout() || (mAnimatingExit && !isAnimatingLw()) || mDestroying; } @@ -3795,6 +3795,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP return parent != null && parent.mHidden; } + private boolean isParentWindowGoneForLayout() { + final WindowState parent = getParentWindow(); + return parent != null && parent.isGoneForLayoutLw(); + } + void setWillReplaceWindow(boolean animate) { for (int i = mChildren.size() - 1; i >= 0; i--) { final WindowState c = mChildren.get(i); |