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

Commit e3c8be54 authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Dump attached insets in InsetsSource

This is necessary to let CTS support relative insets. Also the
information can be used for debugging.

Test: SplashscreenTests
Bug: 277292497
Flag: com.android.window.flags.relative_insets
Change-Id: I598c12b0e0fccdf695f692e6fe212854754b9625
parent 8d6d2846
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.view;

import static android.view.InsetsSourceProto.ATTACHED_INSETS;
import static android.view.InsetsSourceProto.FRAME;
import static android.view.InsetsSourceProto.TYPE;
import static android.view.InsetsSourceProto.TYPE_NUMBER;
@@ -699,6 +700,9 @@ public class InsetsSource implements Parcelable {
        }
        proto.write(VISIBLE, mVisible);
        proto.write(TYPE_NUMBER, mType);
        if (mAttachedInsets != null) {
            mAttachedInsets.dumpDebug(proto, ATTACHED_INSETS);
        }
        proto.end(token);
    }

+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";
package android.graphics;

import "frameworks/base/core/proto/android/privacy.proto";

option java_multiple_files = true;

message InsetsProto {
    option (android.msg_privacy).dest = DEST_AUTOMATIC;

    optional int32 left = 1;
    optional int32 top = 2;
    optional int32 right = 3;
    optional int32 bottom = 4;
}
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

syntax = "proto2";

import "frameworks/base/core/proto/android/graphics/insets.proto";
import "frameworks/base/core/proto/android/graphics/rect.proto";

package android.view;
@@ -31,4 +32,5 @@ message InsetsSourceProto {
    optional .android.graphics.RectProto visible_frame = 3;
    optional bool visible = 4;
    optional int32 type_number = 5;
    optional .android.graphics.InsetsProto attached_insets = 6;
}
 No newline at end of file
+18 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.proto.ProtoOutputStream;

/**
 * An Insets instance holds four integer offsets which describe changes to the four
@@ -185,6 +186,23 @@ public final class Insets implements Parcelable {
        out.writeInt(bottom);
    }

    /**
     * Write to a protocol buffer output stream.
     * Protocol buffer message definition at {@link android.graphics.InsetsProto}
     *
     * @param protoOutputStream Stream to write the Insets object to.
     * @param fieldId           Field Id of the Insets as defined in the parent message
     * @hide
     */
    public void dumpDebug(@NonNull ProtoOutputStream protoOutputStream, long fieldId) {
        final long token = protoOutputStream.start(fieldId);
        protoOutputStream.write(InsetsProto.LEFT, left);
        protoOutputStream.write(InsetsProto.TOP, top);
        protoOutputStream.write(InsetsProto.RIGHT, right);
        protoOutputStream.write(InsetsProto.BOTTOM, bottom);
        protoOutputStream.end(token);
    }

    public static final @android.annotation.NonNull Parcelable.Creator<Insets> CREATOR = new Parcelable.Creator<Insets>() {
        @Override
        public Insets createFromParcel(Parcel in) {