Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae9adb0d authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Automerger Merge Worker
Browse files

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

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

Change-Id: Iaa705673b224550ce95b78174ba78765eb4f4add
parents 04c02e12 5cc486b1
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -606,12 +606,14 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

    private void updateState(InsetsState newState) {
        mState.setDisplayFrame(newState.getDisplayFrame());
        for (int i = newState.getSourcesCount() - 1; i >= 0; i--) {
            InsetsSource source = newState.sourceAt(i);
        for (int i = 0; i < InsetsState.SIZE; i++) {
            InsetsSource source = newState.peekSource(i);
            if (source == null) continue;;
            getSourceConsumer(source.getType()).updateSource(source);
        }
        for (int i = mState.getSourcesCount() - 1; i >= 0; i--) {
            InsetsSource source = mState.sourceAt(i);
        for (int i = 0; i < InsetsState.SIZE; i++) {
            InsetsSource source = mState.peekSource(i);
            if (source == null) continue;
            if (newState.peekSource(source.getType()) == null) {
                mState.removeSource(source.getType());
            }
@@ -707,7 +709,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        if (hideTypes[0] != 0) {
            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,
            // so we need to update our requested state once we have control. Otherwise, our
            // requested state at the server side might be incorrect.
+51 −55
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import com.android.internal.annotations.VisibleForTesting;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
import java.util.Objects;
import java.util.StringJoiner;

@@ -117,6 +118,7 @@ public class InsetsState implements Parcelable {
    public static final int ITYPE_EXTRA_NAVIGATION_BAR = 15;

    static final int LAST_TYPE = ITYPE_EXTRA_NAVIGATION_BAR;
    public static final int SIZE = LAST_TYPE + 1;

    // Derived types

@@ -140,7 +142,7 @@ public class InsetsState implements Parcelable {
    static final int ISIDE_FLOATING = 4;
    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.
@@ -177,7 +179,7 @@ public class InsetsState implements Parcelable {
        final Rect relativeFrame = new Rect(frame);
        final Rect relativeFrameMax = new Rect(frame);
        for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) {
            InsetsSource source = mSources.get(type);
            InsetsSource source = mSources[type];
            if (source == null) {
                int index = indexOf(toPublicType(type));
                if (typeInsetsMap[index] == null) {
@@ -227,7 +229,7 @@ public class InsetsState implements Parcelable {
    public Rect calculateVisibleInsets(Rect frame, @SoftInputModeFlags int softInputMode) {
        Insets insets = Insets.NONE;
        for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) {
            InsetsSource source = mSources.get(type);
            InsetsSource source = mSources[type];
            if (source == null) {
                continue;
            }
@@ -256,7 +258,7 @@ public class InsetsState implements Parcelable {
    public int calculateUncontrollableInsetsFromFrame(Rect frame) {
        int blocked = 0;
        for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) {
            InsetsSource source = mSources.get(type);
            InsetsSource source = mSources[type];
            if (source == null) {
                continue;
            }
@@ -350,11 +352,26 @@ public class InsetsState implements Parcelable {
    }

    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) {
        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.
     */
    public boolean getSourceOrDefaultVisibility(@InternalInsetsType int type) {
        final InsetsSource source = mSources.get(type);
        final InsetsSource source = mSources[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
     */
    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
     */
    public void setSourceVisible(@InternalInsetsType int type, boolean visible) {
        InsetsSource source = mSources.get(type);
        InsetsSource source = mSources[type];
        if (source != null) {
            source.setVisible(visible);
        }
@@ -407,27 +424,21 @@ public class InsetsState implements Parcelable {

    public void set(InsetsState other, boolean copySources) {
        mDisplayFrame.set(other.mDisplayFrame);
        mSources.clear();
        if (copySources) {
            for (int i = 0; i < other.mSources.size(); i++) {
                InsetsSource source = other.mSources.valueAt(i);
                mSources.put(source.getType(), new InsetsSource(source));
            for (int i = 0; i < SIZE; i++) {
                InsetsSource source = other.mSources[i];
                if (source == null) continue;
                mSources[i] = new InsetsSource(source);
            }
        } else {
            mSources.putAll(other.mSources);
            for (int i = 0; i < SIZE; i++) {
                mSources[i] = other.mSources[i];
            }
        }

    public void addSource(InsetsSource source) {
        mSources.put(source.getType(), source);
    }

    public int getSourcesCount() {
        return mSources.size();
    }

    public InsetsSource sourceAt(int index) {
        return mSources.valueAt(index);
    public void addSource(InsetsSource source) {
        mSources[source.getType()] = source;
    }

    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) {
        pw.println(prefix + "InsetsState");
        for (int i = mSources.size() - 1; i >= 0; i--) {
            mSources.valueAt(i).dump(prefix + "  ", pw);
        for (int i = 0; i < SIZE; i++) {
            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)) {
            return false;
        }
        int size = mSources.size();
        int otherSize = state.mSources.size();
        for (int i = 0; i < SIZE; i++) {
            if (excludingCaptionInsets) {
            if (mSources.get(ITYPE_CAPTION_BAR) != null) {
                size--;
            }
            if (state.mSources.get(ITYPE_CAPTION_BAR) != null) {
                otherSize--;
            }
        }
        if (size != otherSize) {
            return false;
                if (i == ITYPE_CAPTION_BAR) continue;
            }
        for (int i = mSources.size() - 1; i >= 0; i--) {
            InsetsSource source = mSources.valueAt(i);
            if (excludingCaptionInsets) {
                if (source.getType() == ITYPE_CAPTION_BAR) continue;
            InsetsSource source = mSources[i];
            InsetsSource otherSource = state.mSources[i];
            if (source == null && otherSource == null) {
                continue;
            }
            InsetsSource otherSource = state.mSources.get(source.getType());
            if (otherSource == null) {
            if (source != null && otherSource == null || source == null && otherSource != null) {
                return false;
            }
            if (!otherSource.equals(source, excludeInvisibleImeFrames)) {
@@ -609,7 +612,7 @@ public class InsetsState implements Parcelable {

    @Override
    public int hashCode() {
        return Objects.hash(mDisplayFrame, mSources);
        return Objects.hash(mDisplayFrame, Arrays.hashCode(mSources));
    }

    public InsetsState(Parcel in) {
@@ -624,10 +627,7 @@ public class InsetsState implements Parcelable {
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(mDisplayFrame, flags);
        dest.writeInt(mSources.size());
        for (int i = 0; i < mSources.size(); i++) {
            dest.writeParcelable(mSources.valueAt(i), flags);
        }
        dest.writeParcelableArray(mSources, 0);
    }

    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) {
        mSources.clear();
        mDisplayFrame.set(in.readParcelable(null /* loader */));
        final int size = in.readInt();
        for (int i = 0; i < size; i++) {
            final InsetsSource source = in.readParcelable(null /* loader */);
            mSources.put(source.getType(), source);
        }
        mSources = in.readParcelableArray(null, InsetsSource.class);
    }

    @Override
    public String toString() {
        StringJoiner joiner = new StringJoiner(", ");
        for (InsetsSource source : mSources.values()) {
        for (int i = 0; i < SIZE; i++) {
            InsetsSource source = mSources[i];
            if (source != null) {
                joiner.add(source.toString());
            }
+3 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import android.os.Build;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Trace;
import android.util.ArrayMap;
import android.util.Log;
import android.util.SparseIntArray;
@@ -439,7 +440,9 @@ public final class SurfaceControl implements Parcelable {
            release();
        }
        if (nativeObject != 0) {
            Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "closeGuard");
            mCloseGuard.open("release");
            Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
        }
        mNativeObject = nativeObject;
        mNativeHandle = mNativeObject != 0 ? nativeGetHandle(nativeObject) : 0;
+2 −1
Original line number Diff line number Diff line
@@ -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_STATUS_BAR;
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.SYSTEM_UI_FLAG_FULLSCREEN;
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);
    boolean mPendingAlwaysConsumeSystemBars;
    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
            = new ViewTreeObserver.InternalInsetsInfo();

+20 −17
Original line number Diff line number Diff line
@@ -111,15 +111,20 @@ class InsetsPolicy {
            abortTransient();
        }
        mFocusedWin = focusedWin;
        mStateController.onBarControlTargetChanged(getStatusControlTarget(focusedWin),
                getFakeStatusControlTarget(focusedWin),
                getNavControlTarget(focusedWin),
                getFakeNavControlTarget(focusedWin));
        boolean forceShowsSystemBarsForWindowingMode = forceShowsSystemBarsForWindowingMode();
        InsetsControlTarget statusControlTarget = getStatusControlTarget(focusedWin,
                forceShowsSystemBarsForWindowingMode);
        InsetsControlTarget navControlTarget = getNavControlTarget(focusedWin,
                forceShowsSystemBarsForWindowingMode);
        mStateController.onBarControlTargetChanged(statusControlTarget,
                getFakeControlTarget(focusedWin, statusControlTarget),
                navControlTarget,
                getFakeControlTarget(focusedWin, navControlTarget));
        if (ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL) {
            return;
        }
        mStatusBar.updateVisibility(getStatusControlTarget(focusedWin), ITYPE_STATUS_BAR);
        mNavBar.updateVisibility(getNavControlTarget(focusedWin), ITYPE_NAVIGATION_BAR);
        mStatusBar.updateVisibility(statusControlTarget, ITYPE_STATUS_BAR);
        mNavBar.updateVisibility(navControlTarget, ITYPE_NAVIGATION_BAR);
        mPolicy.updateHideNavInputEventReceiver();
    }

@@ -237,16 +242,13 @@ class InsetsPolicy {
        updateBarControlTarget(mFocusedWin);
    }

    private @Nullable InsetsControlTarget getFakeStatusControlTarget(
            @Nullable WindowState focused) {
        return getStatusControlTarget(focused) == mDummyControlTarget ? focused : null;
    private @Nullable InsetsControlTarget getFakeControlTarget(@Nullable WindowState focused,
            InsetsControlTarget realControlTarget) {
        return realControlTarget == mDummyControlTarget ? focused : null;
    }

    private @Nullable InsetsControlTarget getFakeNavControlTarget(@Nullable WindowState focused) {
        return getNavControlTarget(focused) == mDummyControlTarget ? focused : null;
    }

    private @Nullable InsetsControlTarget getStatusControlTarget(@Nullable WindowState focusedWin) {
    private @Nullable InsetsControlTarget getStatusControlTarget(@Nullable WindowState focusedWin,
            boolean forceShowsSystemBarsForWindowingMode) {
        if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1) {
            return mDummyControlTarget;
        }
@@ -254,7 +256,7 @@ class InsetsPolicy {
            // Notification shade has control anyways, no reason to force anything.
            return focusedWin;
        }
        if (forceShowsSystemBarsForWindowingMode()) {
        if (forceShowsSystemBarsForWindowingMode) {
            // 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
            // visibility of status bar to the client.
@@ -274,7 +276,8 @@ class InsetsPolicy {
        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) {
            return mDummyControlTarget;
        }
@@ -282,7 +285,7 @@ class InsetsPolicy {
            // Notification shade has control anyways, no reason to force anything.
            return focusedWin;
        }
        if (forceShowsSystemBarsForWindowingMode()) {
        if (forceShowsSystemBarsForWindowingMode) {
            // 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
            // visibility of navigation bar to the client.
Loading