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

Commit 8d25bbe0 authored by Gaurav Bhola's avatar Gaurav Bhola Committed by Android (Google) Code Review
Browse files

Merge "Add APIs to add/remove local InsetsSourceProviders in WindowContainer."

parents 1b7d772b eeb1b258
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -89,7 +89,9 @@ public class InsetsState implements Parcelable {
            ITYPE_BOTTOM_DISPLAY_CUTOUT,
            ITYPE_IME,
            ITYPE_CLIMATE_BAR,
            ITYPE_EXTRA_NAVIGATION_BAR
            ITYPE_EXTRA_NAVIGATION_BAR,
            ITYPE_LOCAL_NAVIGATION_BAR_1,
            ITYPE_LOCAL_NAVIGATION_BAR_2
    })
    public @interface InternalInsetsType {}

@@ -132,7 +134,11 @@ public class InsetsState implements Parcelable {
    public static final int ITYPE_CLIMATE_BAR = 20;
    public static final int ITYPE_EXTRA_NAVIGATION_BAR = 21;

    static final int LAST_TYPE = ITYPE_EXTRA_NAVIGATION_BAR;
    /** Additional types for local insets. **/
    public static final int ITYPE_LOCAL_NAVIGATION_BAR_1 = 22;
    public static final int ITYPE_LOCAL_NAVIGATION_BAR_2 = 23;

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

    // Derived types
@@ -674,6 +680,8 @@ public class InsetsState implements Parcelable {
        if ((types & Type.NAVIGATION_BARS) != 0) {
            result.add(ITYPE_NAVIGATION_BAR);
            result.add(ITYPE_EXTRA_NAVIGATION_BAR);
            result.add(ITYPE_LOCAL_NAVIGATION_BAR_1);
            result.add(ITYPE_LOCAL_NAVIGATION_BAR_2);
        }
        if ((types & Type.CAPTION_BAR) != 0) {
            result.add(ITYPE_CAPTION_BAR);
@@ -714,6 +722,8 @@ public class InsetsState implements Parcelable {
                return Type.STATUS_BARS;
            case ITYPE_NAVIGATION_BAR:
            case ITYPE_EXTRA_NAVIGATION_BAR:
            case ITYPE_LOCAL_NAVIGATION_BAR_1:
            case ITYPE_LOCAL_NAVIGATION_BAR_2:
                return Type.NAVIGATION_BARS;
            case ITYPE_CAPTION_BAR:
                return Type.CAPTION_BAR;
@@ -833,6 +843,10 @@ public class InsetsState implements Parcelable {
                return "ITYPE_CLIMATE_BAR";
            case ITYPE_EXTRA_NAVIGATION_BAR:
                return "ITYPE_EXTRA_NAVIGATION_BAR";
            case ITYPE_LOCAL_NAVIGATION_BAR_1:
                return "ITYPE_LOCAL_NAVIGATION_BAR_1";
            case ITYPE_LOCAL_NAVIGATION_BAR_2:
                return "ITYPE_LOCAL_NAVIGATION_BAR_2";
            default:
                return "ITYPE_UNKNOWN_" + type;
        }
+15 −4
Original line number Diff line number Diff line
@@ -3326,8 +3326,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }
        if (mInsetsStateController != null) {
            for (@InternalInsetsType int type = 0; type < InsetsState.SIZE; type++) {
                final InsetsSourceProvider provider = mInsetsStateController.peekSourceProvider(
                        type);
                final WindowContainerInsetsSourceProvider provider = mInsetsStateController
                        .peekSourceProvider(type);
                if (provider != null) {
                    provider.dumpDebug(proto, type == ITYPE_IME ? IME_INSETS_SOURCE_PROVIDER :
                            INSETS_SOURCE_PROVIDERS, logLevel);
@@ -4036,7 +4036,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        // app.
        assignWindowLayers(true /* setLayoutNeeded */);
        // 3. The z-order of IME might have been changed. Update the above insets state.
        mInsetsStateController.updateAboveInsetsState(mInputMethodWindow,
        mInsetsStateController.updateAboveInsetsState(
                mInsetsStateController.getRawInsetsState().getSourceOrDefaultVisibility(ITYPE_IME));
        // 4. Update the IME control target to apply any inset change and animation.
        // 5. Reparent the IME container surface to either the input target app, or the IME window
@@ -4167,7 +4167,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        if (mImeInputTarget != target) {
            ProtoLog.i(WM_DEBUG_IME, "setInputMethodInputTarget %s", target);
            setImeInputTarget(target);
            mInsetsStateController.updateAboveInsetsState(mInputMethodWindow, mInsetsStateController
            mInsetsStateController.updateAboveInsetsState(mInsetsStateController
                    .getRawInsetsState().getSourceOrDefaultVisibility(ITYPE_IME));
            updateImeControlTarget();
        }
@@ -4809,6 +4809,17 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            return candidate;
        }

        @Override
        void updateAboveInsetsState(InsetsState aboveInsetsState,
                SparseArray<InsetsSourceProvider> localInsetsSourceProvidersFromParent,
                ArraySet<WindowState> insetsChangedWindows) {
            if (skipImeWindowsDuringTraversal(mDisplayContent)) {
                return;
            }
            super.updateAboveInsetsState(aboveInsetsState, localInsetsSourceProvidersFromParent,
                    insetsChangedWindows);
        }

        @Override
        boolean forAllWindows(ToBooleanFunction<WindowState> callback,
                boolean traverseTopToBottom) {
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ import java.io.PrintWriter;
 * Controller for IME inset source on the server. It's called provider as it provides the
 * {@link InsetsSource} to the client that uses it in {@link InsetsSourceConsumer}.
 */
final class ImeInsetsSourceProvider extends InsetsSourceProvider {
final class ImeInsetsSourceProvider extends WindowContainerInsetsSourceProvider {

    private InsetsControlTarget mImeRequester;
    private Runnable mShowImeRunner;
+5 −4
Original line number Diff line number Diff line
@@ -176,7 +176,8 @@ class InsetsPolicy {
    }

    boolean isHidden(@InternalInsetsType int type) {
        final InsetsSourceProvider provider =  mStateController.peekSourceProvider(type);
        final WindowContainerInsetsSourceProvider provider = mStateController
                .peekSourceProvider(type);
        return provider != null && provider.hasWindowContainer()
                && !provider.getSource().isVisible();
    }
@@ -358,10 +359,10 @@ class InsetsPolicy {

            // IME needs different frames for certain cases (e.g. navigation bar in gesture nav).
            if (type == ITYPE_IME) {
                ArrayMap<Integer, InsetsSourceProvider> providers = mStateController
                ArrayMap<Integer, WindowContainerInsetsSourceProvider> providers = mStateController
                        .getSourceProviders();
                for (int i = providers.size() - 1; i >= 0; i--) {
                    InsetsSourceProvider otherProvider = providers.valueAt(i);
                    WindowContainerInsetsSourceProvider otherProvider = providers.valueAt(i);
                    if (otherProvider.overridesImeFrame()) {
                        InsetsSource override =
                                new InsetsSource(
@@ -662,7 +663,7 @@ class InsetsPolicy {
        final IntArray showingTransientTypes = mShowingTransientTypes;
        for (int i = showingTransientTypes.size() - 1; i >= 0; i--) {
            final @InternalInsetsType int type = showingTransientTypes.get(i);
            InsetsSourceProvider provider = mStateController.getSourceProvider(type);
            WindowContainerInsetsSourceProvider provider = mStateController.getSourceProvider(type);
            InsetsSourceControl control = provider.getControl(mDummyControlTarget);
            if (control == null || control.getLeash() == null) {
                continue;
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ import java.util.function.Consumer;
 * Controller for a specific inset source on the server. It's called provider as it provides the
 * {@link InsetsSource} to the client that uses it in {@link android.view.InsetsSourceConsumer}.
 */
class InsetsSourceProvider {
abstract class InsetsSourceProvider {

    protected final DisplayContent mDisplayContent;
    protected final @NonNull InsetsSource mSource;
Loading