Merge changes Ia7d9514e,I3e9e4f47 into rvc-dev am: 5cc486b1a1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11920861

Change-Id: Ib95a002e8574feddc6bd8348ebcd060d186c2d74
This commit is contained in:
Jorim Jaggi
2020-06-19 14:18:42 +00:00
committed by Automerger Merge Worker
10 changed files with 138 additions and 123 deletions

View File

@@ -606,12 +606,14 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
private void updateState(InsetsState newState) { private void updateState(InsetsState newState) {
mState.setDisplayFrame(newState.getDisplayFrame()); mState.setDisplayFrame(newState.getDisplayFrame());
for (int i = newState.getSourcesCount() - 1; i >= 0; i--) { for (int i = 0; i < InsetsState.SIZE; i++) {
InsetsSource source = newState.sourceAt(i); InsetsSource source = newState.peekSource(i);
if (source == null) continue;;
getSourceConsumer(source.getType()).updateSource(source); getSourceConsumer(source.getType()).updateSource(source);
} }
for (int i = mState.getSourcesCount() - 1; i >= 0; i--) { for (int i = 0; i < InsetsState.SIZE; i++) {
InsetsSource source = mState.sourceAt(i); InsetsSource source = mState.peekSource(i);
if (source == null) continue;
if (newState.peekSource(source.getType()) == null) { if (newState.peekSource(source.getType()) == null) {
mState.removeSource(source.getType()); mState.removeSource(source.getType());
} }
@@ -707,7 +709,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
if (hideTypes[0] != 0) { if (hideTypes[0] != 0) {
applyAnimation(hideTypes[0], false /* show */, false /* fromIme */); applyAnimation(hideTypes[0], false /* show */, false /* fromIme */);
} }
if (hasControl && mRequestedState.getSourcesCount() > 0) { if (hasControl && mRequestedState.hasSources()) {
// We might have changed our requested visibilities while we don't have the control, // We might have changed our requested visibilities while we don't have the control,
// so we need to update our requested state once we have control. Otherwise, our // so we need to update our requested state once we have control. Otherwise, our
// requested state at the server side might be incorrect. // requested state at the server side might be incorrect.

View File

@@ -50,6 +50,7 @@ import com.android.internal.annotations.VisibleForTesting;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
import java.util.StringJoiner; import java.util.StringJoiner;
@@ -117,6 +118,7 @@ public class InsetsState implements Parcelable {
public static final int ITYPE_EXTRA_NAVIGATION_BAR = 15; public static final int ITYPE_EXTRA_NAVIGATION_BAR = 15;
static final int LAST_TYPE = ITYPE_EXTRA_NAVIGATION_BAR; static final int LAST_TYPE = ITYPE_EXTRA_NAVIGATION_BAR;
public static final int SIZE = LAST_TYPE + 1;
// Derived types // Derived types
@@ -140,7 +142,7 @@ public class InsetsState implements Parcelable {
static final int ISIDE_FLOATING = 4; static final int ISIDE_FLOATING = 4;
static final int ISIDE_UNKNOWN = 5; static final int ISIDE_UNKNOWN = 5;
private final ArrayMap<Integer, InsetsSource> mSources = new ArrayMap<>(); private InsetsSource[] mSources = new InsetsSource[SIZE];
/** /**
* The frame of the display these sources are relative to. * The frame of the display these sources are relative to.
@@ -177,7 +179,7 @@ public class InsetsState implements Parcelable {
final Rect relativeFrame = new Rect(frame); final Rect relativeFrame = new Rect(frame);
final Rect relativeFrameMax = new Rect(frame); final Rect relativeFrameMax = new Rect(frame);
for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) { for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) {
InsetsSource source = mSources.get(type); InsetsSource source = mSources[type];
if (source == null) { if (source == null) {
int index = indexOf(toPublicType(type)); int index = indexOf(toPublicType(type));
if (typeInsetsMap[index] == null) { if (typeInsetsMap[index] == null) {
@@ -227,7 +229,7 @@ public class InsetsState implements Parcelable {
public Rect calculateVisibleInsets(Rect frame, @SoftInputModeFlags int softInputMode) { public Rect calculateVisibleInsets(Rect frame, @SoftInputModeFlags int softInputMode) {
Insets insets = Insets.NONE; Insets insets = Insets.NONE;
for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) { for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) {
InsetsSource source = mSources.get(type); InsetsSource source = mSources[type];
if (source == null) { if (source == null) {
continue; continue;
} }
@@ -256,7 +258,7 @@ public class InsetsState implements Parcelable {
public int calculateUncontrollableInsetsFromFrame(Rect frame) { public int calculateUncontrollableInsetsFromFrame(Rect frame) {
int blocked = 0; int blocked = 0;
for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) { for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) {
InsetsSource source = mSources.get(type); InsetsSource source = mSources[type];
if (source == null) { if (source == null) {
continue; continue;
} }
@@ -350,11 +352,26 @@ public class InsetsState implements Parcelable {
} }
public InsetsSource getSource(@InternalInsetsType int type) { public InsetsSource getSource(@InternalInsetsType int type) {
return mSources.computeIfAbsent(type, InsetsSource::new); InsetsSource source = mSources[type];
if (source != null) {
return source;
}
source = new InsetsSource(type);
mSources[type] = source;
return source;
} }
public @Nullable InsetsSource peekSource(@InternalInsetsType int type) { public @Nullable InsetsSource peekSource(@InternalInsetsType int type) {
return mSources.get(type); return mSources[type];
}
public boolean hasSources() {
for (int i = 0; i < SIZE; i++) {
if (mSources[i] != null) {
return true;
}
}
return false;
} }
/** /**
@@ -366,7 +383,7 @@ public class InsetsState implements Parcelable {
* doesn't exist. * doesn't exist.
*/ */
public boolean getSourceOrDefaultVisibility(@InternalInsetsType int type) { public boolean getSourceOrDefaultVisibility(@InternalInsetsType int type) {
final InsetsSource source = mSources.get(type); final InsetsSource source = mSources[type];
return source != null ? source.isVisible() : getDefaultVisibility(type); return source != null ? source.isVisible() : getDefaultVisibility(type);
} }
@@ -385,7 +402,7 @@ public class InsetsState implements Parcelable {
* @param type The {@link InternalInsetsType} of the source to remove * @param type The {@link InternalInsetsType} of the source to remove
*/ */
public void removeSource(@InternalInsetsType int type) { public void removeSource(@InternalInsetsType int type) {
mSources.remove(type); mSources[type] = null;
} }
/** /**
@@ -395,7 +412,7 @@ public class InsetsState implements Parcelable {
* @param visible {@code true} for visible * @param visible {@code true} for visible
*/ */
public void setSourceVisible(@InternalInsetsType int type, boolean visible) { public void setSourceVisible(@InternalInsetsType int type, boolean visible) {
InsetsSource source = mSources.get(type); InsetsSource source = mSources[type];
if (source != null) { if (source != null) {
source.setVisible(visible); source.setVisible(visible);
} }
@@ -407,27 +424,21 @@ public class InsetsState implements Parcelable {
public void set(InsetsState other, boolean copySources) { public void set(InsetsState other, boolean copySources) {
mDisplayFrame.set(other.mDisplayFrame); mDisplayFrame.set(other.mDisplayFrame);
mSources.clear();
if (copySources) { if (copySources) {
for (int i = 0; i < other.mSources.size(); i++) { for (int i = 0; i < SIZE; i++) {
InsetsSource source = other.mSources.valueAt(i); InsetsSource source = other.mSources[i];
mSources.put(source.getType(), new InsetsSource(source)); if (source == null) continue;
mSources[i] = new InsetsSource(source);
} }
} else { } else {
mSources.putAll(other.mSources); for (int i = 0; i < SIZE; i++) {
mSources[i] = other.mSources[i];
}
} }
} }
public void addSource(InsetsSource source) { public void addSource(InsetsSource source) {
mSources.put(source.getType(), source); mSources[source.getType()] = source;
}
public int getSourcesCount() {
return mSources.size();
}
public InsetsSource sourceAt(int index) {
return mSources.valueAt(index);
} }
public static @InternalInsetsType ArraySet<Integer> toInternalType(@InsetsType int types) { public static @InternalInsetsType ArraySet<Integer> toInternalType(@InsetsType int types) {
@@ -508,8 +519,10 @@ public class InsetsState implements Parcelable {
public void dump(String prefix, PrintWriter pw) { public void dump(String prefix, PrintWriter pw) {
pw.println(prefix + "InsetsState"); pw.println(prefix + "InsetsState");
for (int i = mSources.size() - 1; i >= 0; i--) { for (int i = 0; i < SIZE; i++) {
mSources.valueAt(i).dump(prefix + " ", pw); InsetsSource source = mSources[i];
if (source == null) continue;
source.dump(prefix + " ", pw);
} }
} }
@@ -578,26 +591,16 @@ public class InsetsState implements Parcelable {
if (!mDisplayFrame.equals(state.mDisplayFrame)) { if (!mDisplayFrame.equals(state.mDisplayFrame)) {
return false; return false;
} }
int size = mSources.size(); for (int i = 0; i < SIZE; i++) {
int otherSize = state.mSources.size();
if (excludingCaptionInsets) {
if (mSources.get(ITYPE_CAPTION_BAR) != null) {
size--;
}
if (state.mSources.get(ITYPE_CAPTION_BAR) != null) {
otherSize--;
}
}
if (size != otherSize) {
return false;
}
for (int i = mSources.size() - 1; i >= 0; i--) {
InsetsSource source = mSources.valueAt(i);
if (excludingCaptionInsets) { if (excludingCaptionInsets) {
if (source.getType() == ITYPE_CAPTION_BAR) continue; if (i == ITYPE_CAPTION_BAR) continue;
} }
InsetsSource otherSource = state.mSources.get(source.getType()); InsetsSource source = mSources[i];
if (otherSource == null) { InsetsSource otherSource = state.mSources[i];
if (source == null && otherSource == null) {
continue;
}
if (source != null && otherSource == null || source == null && otherSource != null) {
return false; return false;
} }
if (!otherSource.equals(source, excludeInvisibleImeFrames)) { if (!otherSource.equals(source, excludeInvisibleImeFrames)) {
@@ -609,7 +612,7 @@ public class InsetsState implements Parcelable {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(mDisplayFrame, mSources); return Objects.hash(mDisplayFrame, Arrays.hashCode(mSources));
} }
public InsetsState(Parcel in) { public InsetsState(Parcel in) {
@@ -624,10 +627,7 @@ public class InsetsState implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(mDisplayFrame, flags); dest.writeParcelable(mDisplayFrame, flags);
dest.writeInt(mSources.size()); dest.writeParcelableArray(mSources, 0);
for (int i = 0; i < mSources.size(); i++) {
dest.writeParcelable(mSources.valueAt(i), flags);
}
} }
public static final @android.annotation.NonNull Creator<InsetsState> CREATOR = new Creator<InsetsState>() { public static final @android.annotation.NonNull Creator<InsetsState> CREATOR = new Creator<InsetsState>() {
@@ -642,19 +642,15 @@ public class InsetsState implements Parcelable {
}; };
public void readFromParcel(Parcel in) { public void readFromParcel(Parcel in) {
mSources.clear();
mDisplayFrame.set(in.readParcelable(null /* loader */)); mDisplayFrame.set(in.readParcelable(null /* loader */));
final int size = in.readInt(); mSources = in.readParcelableArray(null, InsetsSource.class);
for (int i = 0; i < size; i++) {
final InsetsSource source = in.readParcelable(null /* loader */);
mSources.put(source.getType(), source);
}
} }
@Override @Override
public String toString() { public String toString() {
StringJoiner joiner = new StringJoiner(", "); StringJoiner joiner = new StringJoiner(", ");
for (InsetsSource source : mSources.values()) { for (int i = 0; i < SIZE; i++) {
InsetsSource source = mSources[i];
if (source != null) { if (source != null) {
joiner.add(source.toString()); joiner.add(source.toString());
} }

View File

@@ -49,6 +49,7 @@ import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.os.Trace;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.Log; import android.util.Log;
import android.util.SparseIntArray; import android.util.SparseIntArray;
@@ -439,7 +440,9 @@ public final class SurfaceControl implements Parcelable {
release(); release();
} }
if (nativeObject != 0) { if (nativeObject != 0) {
Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "closeGuard");
mCloseGuard.open("release"); mCloseGuard.open("release");
Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
} }
mNativeObject = nativeObject; mNativeObject = nativeObject;
mNativeHandle = mNativeObject != 0 ? nativeGetHandle(nativeObject) : 0; mNativeHandle = mNativeObject != 0 ? nativeGetHandle(nativeObject) : 0;

View File

@@ -22,6 +22,7 @@ import static android.view.InputDevice.SOURCE_CLASS_NONE;
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR;
import static android.view.InsetsState.LAST_TYPE; import static android.view.InsetsState.LAST_TYPE;
import static android.view.InsetsState.SIZE;
import static android.view.View.PFLAG_DRAW_ANIMATION; import static android.view.View.PFLAG_DRAW_ANIMATION;
import static android.view.View.SYSTEM_UI_FLAG_FULLSCREEN; import static android.view.View.SYSTEM_UI_FLAG_FULLSCREEN;
import static android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; import static android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
@@ -564,7 +565,7 @@ public final class ViewRootImpl implements ViewParent,
new DisplayCutout.ParcelableWrapper(DisplayCutout.NO_CUTOUT); new DisplayCutout.ParcelableWrapper(DisplayCutout.NO_CUTOUT);
boolean mPendingAlwaysConsumeSystemBars; boolean mPendingAlwaysConsumeSystemBars;
private final InsetsState mTempInsets = new InsetsState(); private final InsetsState mTempInsets = new InsetsState();
private final InsetsSourceControl[] mTempControls = new InsetsSourceControl[LAST_TYPE + 1]; private final InsetsSourceControl[] mTempControls = new InsetsSourceControl[SIZE];
final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets
= new ViewTreeObserver.InternalInsetsInfo(); = new ViewTreeObserver.InternalInsetsInfo();

View File

@@ -111,15 +111,20 @@ class InsetsPolicy {
abortTransient(); abortTransient();
} }
mFocusedWin = focusedWin; mFocusedWin = focusedWin;
mStateController.onBarControlTargetChanged(getStatusControlTarget(focusedWin), boolean forceShowsSystemBarsForWindowingMode = forceShowsSystemBarsForWindowingMode();
getFakeStatusControlTarget(focusedWin), InsetsControlTarget statusControlTarget = getStatusControlTarget(focusedWin,
getNavControlTarget(focusedWin), forceShowsSystemBarsForWindowingMode);
getFakeNavControlTarget(focusedWin)); InsetsControlTarget navControlTarget = getNavControlTarget(focusedWin,
forceShowsSystemBarsForWindowingMode);
mStateController.onBarControlTargetChanged(statusControlTarget,
getFakeControlTarget(focusedWin, statusControlTarget),
navControlTarget,
getFakeControlTarget(focusedWin, navControlTarget));
if (ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL) { if (ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL) {
return; return;
} }
mStatusBar.updateVisibility(getStatusControlTarget(focusedWin), ITYPE_STATUS_BAR); mStatusBar.updateVisibility(statusControlTarget, ITYPE_STATUS_BAR);
mNavBar.updateVisibility(getNavControlTarget(focusedWin), ITYPE_NAVIGATION_BAR); mNavBar.updateVisibility(navControlTarget, ITYPE_NAVIGATION_BAR);
mPolicy.updateHideNavInputEventReceiver(); mPolicy.updateHideNavInputEventReceiver();
} }
@@ -237,16 +242,13 @@ class InsetsPolicy {
updateBarControlTarget(mFocusedWin); updateBarControlTarget(mFocusedWin);
} }
private @Nullable InsetsControlTarget getFakeStatusControlTarget( private @Nullable InsetsControlTarget getFakeControlTarget(@Nullable WindowState focused,
@Nullable WindowState focused) { InsetsControlTarget realControlTarget) {
return getStatusControlTarget(focused) == mDummyControlTarget ? focused : null; return realControlTarget == mDummyControlTarget ? focused : null;
} }
private @Nullable InsetsControlTarget getFakeNavControlTarget(@Nullable WindowState focused) { private @Nullable InsetsControlTarget getStatusControlTarget(@Nullable WindowState focusedWin,
return getNavControlTarget(focused) == mDummyControlTarget ? focused : null; boolean forceShowsSystemBarsForWindowingMode) {
}
private @Nullable InsetsControlTarget getStatusControlTarget(@Nullable WindowState focusedWin) {
if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1) { if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1) {
return mDummyControlTarget; return mDummyControlTarget;
} }
@@ -254,7 +256,7 @@ class InsetsPolicy {
// Notification shade has control anyways, no reason to force anything. // Notification shade has control anyways, no reason to force anything.
return focusedWin; return focusedWin;
} }
if (forceShowsSystemBarsForWindowingMode()) { if (forceShowsSystemBarsForWindowingMode) {
// Status bar is forcibly shown for the windowing mode which is a steady state. // Status bar is forcibly shown for the windowing mode which is a steady state.
// We don't want the client to control the status bar, and we will dispatch the real // We don't want the client to control the status bar, and we will dispatch the real
// visibility of status bar to the client. // visibility of status bar to the client.
@@ -274,7 +276,8 @@ class InsetsPolicy {
return focusedWin; return focusedWin;
} }
private @Nullable InsetsControlTarget getNavControlTarget(@Nullable WindowState focusedWin) { private @Nullable InsetsControlTarget getNavControlTarget(@Nullable WindowState focusedWin,
boolean forceShowsSystemBarsForWindowingMode) {
if (mShowingTransientTypes.indexOf(ITYPE_NAVIGATION_BAR) != -1) { if (mShowingTransientTypes.indexOf(ITYPE_NAVIGATION_BAR) != -1) {
return mDummyControlTarget; return mDummyControlTarget;
} }
@@ -282,7 +285,7 @@ class InsetsPolicy {
// Notification shade has control anyways, no reason to force anything. // Notification shade has control anyways, no reason to force anything.
return focusedWin; return focusedWin;
} }
if (forceShowsSystemBarsForWindowingMode()) { if (forceShowsSystemBarsForWindowingMode) {
// Navigation bar is forcibly shown for the windowing mode which is a steady state. // Navigation bar is forcibly shown for the windowing mode which is a steady state.
// We don't want the client to control the navigation bar, and we will dispatch the real // We don't want the client to control the navigation bar, and we will dispatch the real
// visibility of navigation bar to the client. // visibility of navigation bar to the client.

View File

@@ -254,8 +254,9 @@ class InsetsStateController {
void onInsetsModified(InsetsControlTarget windowState, InsetsState state) { void onInsetsModified(InsetsControlTarget windowState, InsetsState state) {
boolean changed = false; boolean changed = false;
for (int i = state.getSourcesCount() - 1; i >= 0; i--) { for (int i = 0; i < InsetsState.SIZE; i++) {
final InsetsSource source = state.sourceAt(i); final InsetsSource source = state.peekSource(i);
if (source == null) continue;
final InsetsSourceProvider provider = mProviders.get(source.getType()); final InsetsSourceProvider provider = mProviders.get(source.getType());
if (provider == null) { if (provider == null) {
continue; continue;

View File

@@ -179,6 +179,8 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
* Applied as part of the animation pass in "prepareSurfaces". * Applied as part of the animation pass in "prepareSurfaces".
*/ */
protected final SurfaceAnimator mSurfaceAnimator; protected final SurfaceAnimator mSurfaceAnimator;
private boolean mAnyParentAnimating;
final SurfaceFreezer mSurfaceFreezer; final SurfaceFreezer mSurfaceFreezer;
protected final WindowManagerService mWmService; protected final WindowManagerService mWmService;
@@ -2460,21 +2462,16 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
*/ */
@Nullable @Nullable
WindowContainer getAnimatingContainer(int flags, int typesToCheck) { WindowContainer getAnimatingContainer(int flags, int typesToCheck) {
int animationType = mSurfaceAnimator.getAnimationType(); if (isSelfAnimating(flags, typesToCheck)) {
if (mSurfaceAnimator.isAnimating() && (animationType & typesToCheck) > 0) {
return this;
}
if ((flags & TRANSITION) != 0 && isWaitingForTransitionStart()) {
return this; return this;
} }
if ((flags & PARENTS) != 0) { if ((flags & PARENTS) != 0) {
final WindowContainer parent = getParent(); WindowContainer parent = getParent();
if (parent != null) { while (parent != null) {
final WindowContainer wc = parent.getAnimatingContainer( if (parent.isSelfAnimating(flags, typesToCheck)) {
flags & ~CHILDREN, typesToCheck); return parent;
if (wc != null) {
return wc;
} }
parent = parent.getParent();
} }
} }
if ((flags & CHILDREN) != 0) { if ((flags & CHILDREN) != 0) {
@@ -2489,6 +2486,21 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
return null; return null;
} }
/**
* Internal method only to be used during {@link #getAnimatingContainer(int, int)}.DO NOT CALL
* FROM OUTSIDE.
*/
protected boolean isSelfAnimating(int flags, int typesToCheck) {
if (mSurfaceAnimator.isAnimating()
&& (mSurfaceAnimator.getAnimationType() & typesToCheck) > 0) {
return true;
}
if ((flags & TRANSITION) != 0 && isWaitingForTransitionStart()) {
return true;
}
return false;
}
/** /**
* @deprecated Use {@link #getAnimatingContainer(int, int)} instead. * @deprecated Use {@link #getAnimatingContainer(int, int)} instead.
*/ */

View File

@@ -2866,15 +2866,13 @@ public class WindowManagerService extends IWindowManager.Stub
aspectRatio); aspectRatio);
} }
public void getStackBounds(int windowingMode, int activityType, Rect bounds) { void getStackBounds(int windowingMode, int activityType, Rect bounds) {
synchronized (mGlobalLock) { final ActivityStack stack = mRoot.getStack(windowingMode, activityType);
final ActivityStack stack = mRoot.getStack(windowingMode, activityType); if (stack != null) {
if (stack != null) { stack.getBounds(bounds);
stack.getBounds(bounds); return;
return;
}
bounds.setEmpty();
} }
bounds.setEmpty();
} }
/** /**

View File

@@ -706,6 +706,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
static final int BLAST_TIMEOUT_DURATION = 5000; /* milliseconds */ static final int BLAST_TIMEOUT_DURATION = 5000; /* milliseconds */
private final WindowProcessController mWpcForDisplayConfigChanges;
/** /**
* @return The insets state as requested by the client, i.e. the dispatched insets state * @return The insets state as requested by the client, i.e. the dispatched insets state
* for which the visibilities are overridden with what the client requested. * for which the visibilities are overridden with what the client requested.
@@ -720,8 +722,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
void updateRequestedInsetsState(InsetsState state) { void updateRequestedInsetsState(InsetsState state) {
// Only update the sources the client is actually controlling. // Only update the sources the client is actually controlling.
for (int i = state.getSourcesCount() - 1; i >= 0; i--) { for (int i = 0; i < InsetsState.SIZE; i++) {
final InsetsSource source = state.sourceAt(i); final InsetsSource source = state.peekSource(i);
if (source == null) continue;
mRequestedInsetsState.addSource(source); mRequestedInsetsState.addSource(source);
} }
} }
@@ -873,6 +876,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mSubLayer = 0; mSubLayer = 0;
mInputWindowHandle = null; mInputWindowHandle = null;
mWinAnimator = null; mWinAnimator = null;
mWpcForDisplayConfigChanges = null;
return; return;
} }
mDeathRecipient = deathRecipient; mDeathRecipient = deathRecipient;
@@ -928,6 +932,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
ProtoLog.v(WM_DEBUG_ADD_REMOVE, "Adding %s to %s", this, parentWindow); ProtoLog.v(WM_DEBUG_ADD_REMOVE, "Adding %s to %s", this, parentWindow);
parentWindow.addChild(this, sWindowSubLayerComparator); parentWindow.addChild(this, sWindowSubLayerComparator);
} }
// System process or invalid process cannot register to display config change.
mWpcForDisplayConfigChanges = (s.mPid == MY_PID || s.mPid < 0)
? null
: service.mAtmService.getProcessController(s.mPid, s.mUid);
} }
void attach() { void attach() {
@@ -3514,13 +3523,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
/** @return {@code true} if the process registered to a display as a config listener. */ /** @return {@code true} if the process registered to a display as a config listener. */
private boolean registeredForDisplayConfigChanges() { private boolean registeredForDisplayConfigChanges() {
final WindowState parentWindow = getParentWindow(); final WindowState parentWindow = getParentWindow();
final Session session = parentWindow != null ? parentWindow.mSession : mSession; final WindowProcessController wpc = parentWindow != null
// System process or invalid process cannot register to display config change. ? parentWindow.mWpcForDisplayConfigChanges
if (session.mPid == MY_PID || session.mPid < 0) return false; : mWpcForDisplayConfigChanges;
WindowProcessController app = return wpc != null && wpc.registeredForDisplayConfigChanges();
mWmService.mAtmService.getProcessController(session.mPid, session.mUid);
if (app == null || !app.registeredForDisplayConfigChanges()) return false;
return true;
} }
void reportResized() { void reportResized() {
@@ -5103,13 +5109,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mWindowFrames.updateLastInsetValues(); mWindowFrames.updateLastInsetValues();
} }
@Nullable
@Override @Override
WindowContainer<WindowState> getAnimatingContainer(int flags, int typesToCheck) { protected boolean isSelfAnimating(int flags, int typesToCheck) {
if (mControllableInsetProvider != null) { if (mControllableInsetProvider != null) {
return null; return false;
} }
return super.getAnimatingContainer(flags, typesToCheck); return super.isSelfAnimating(flags, typesToCheck);
} }
void startAnimation(Animation anim) { void startAnimation(Animation anim) {
@@ -5299,10 +5304,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
return mWillReplaceWindow; return mWillReplaceWindow;
} }
private void applyDims(Dimmer dimmer) { private void applyDims() {
if (!mAnimatingExit && mAppDied) { if (!mAnimatingExit && mAppDied) {
mIsDimming = true; mIsDimming = true;
dimmer.dimAbove(getSyncTransaction(), this, DEFAULT_DIM_AMOUNT_DEAD_WINDOW); getDimmer().dimAbove(getSyncTransaction(), this, DEFAULT_DIM_AMOUNT_DEAD_WINDOW);
} else if ((mAttrs.flags & FLAG_DIM_BEHIND) != 0 && isVisibleNow() && !mHidden) { } else if ((mAttrs.flags & FLAG_DIM_BEHIND) != 0 && isVisibleNow() && !mHidden) {
// Only show a dim behind when the following is satisfied: // Only show a dim behind when the following is satisfied:
// 1. The window has the flag FLAG_DIM_BEHIND // 1. The window has the flag FLAG_DIM_BEHIND
@@ -5310,7 +5315,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
// 3. The WS is considered visible according to the isVisible() method // 3. The WS is considered visible according to the isVisible() method
// 4. The WS is not hidden. // 4. The WS is not hidden.
mIsDimming = true; mIsDimming = true;
dimmer.dimBelow(getSyncTransaction(), this, mAttrs.dimAmount); getDimmer().dimBelow(getSyncTransaction(), this, mAttrs.dimAmount);
} }
} }
@@ -5334,11 +5339,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
@Override @Override
void prepareSurfaces() { void prepareSurfaces() {
final Dimmer dimmer = getDimmer();
mIsDimming = false; mIsDimming = false;
if (dimmer != null) { applyDims();
applyDims(dimmer);
}
updateSurfacePosition(); updateSurfacePosition();
// Send information to SufaceFlinger about the priority of the current window. // Send information to SufaceFlinger about the priority of the current window.
updateFrameRateSelectionPriorityIfNeeded(); updateFrameRateSelectionPriorityIfNeeded();

View File

@@ -87,10 +87,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
.setWindow(statusBar, null, null); .setWindow(statusBar, null, null);
statusBar.setControllableInsetProvider(getController().getSourceProvider(ITYPE_STATUS_BAR)); statusBar.setControllableInsetProvider(getController().getSourceProvider(ITYPE_STATUS_BAR));
final InsetsState state = getController().getInsetsForDispatch(statusBar); final InsetsState state = getController().getInsetsForDispatch(statusBar);
for (int i = state.getSourcesCount() - 1; i >= 0; i--) { assertNull(state.peekSource(ITYPE_STATUS_BAR));
final InsetsSource source = state.sourceAt(i);
assertNotEquals(ITYPE_STATUS_BAR, source.getType());
}
} }
@Test @Test