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

Commit b79806ed authored by Arthur Hung's avatar Arthur Hung Committed by Android (Google) Code Review
Browse files

Merge "Add server side proto-base dumping for back navigation"

parents 4fa4a098 514e45af
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -3306,6 +3306,18 @@ package android.widget.inline {

package android.window {

  public final class BackNavigationInfo implements android.os.Parcelable {
    method @NonNull public static String typeToString(int);
    field @NonNull public static final android.os.Parcelable.Creator<android.window.BackNavigationInfo> CREATOR;
    field public static final String KEY_TRIGGER_BACK = "TriggerBack";
    field public static final int TYPE_CALLBACK = 4; // 0x4
    field public static final int TYPE_CROSS_ACTIVITY = 2; // 0x2
    field public static final int TYPE_CROSS_TASK = 3; // 0x3
    field public static final int TYPE_DIALOG_CLOSE = 0; // 0x0
    field public static final int TYPE_RETURN_TO_HOME = 1; // 0x1
    field public static final int TYPE_UNDEFINED = -1; // 0xffffffff
  }

  public final class DisplayAreaAppearedInfo implements android.os.Parcelable {
    ctor public DisplayAreaAppearedInfo(@NonNull android.window.DisplayAreaInfo, @NonNull android.view.SurfaceControl);
    method public int describeContents();
+11 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.window;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
@@ -29,6 +30,7 @@ import android.os.RemoteCallback;
 *
 * @hide
 */
@TestApi
public final class BackNavigationInfo implements Parcelable {

    /**
@@ -71,6 +73,7 @@ public final class BackNavigationInfo implements Parcelable {
    /**
     * Defines the type of back destinations a back even can lead to. This is used to define the
     * type of animation that need to be run on SystemUI.
     * @hide
     */
    @IntDef(prefix = "TYPE_", value = {
            TYPE_UNDEFINED,
@@ -97,7 +100,6 @@ public final class BackNavigationInfo implements Parcelable {
     * @param onBackNavigationDone    The callback to be called once the client is done with the
     *                                back preview.
     * @param onBackInvokedCallback   The back callback registered by the current top level window.
     * @param departingWindowContainerToken The {@link WindowContainerToken} of departing window.
     */
    private BackNavigationInfo(@BackTargetType int type,
            @Nullable RemoteCallback onBackNavigationDone,
@@ -116,6 +118,7 @@ public final class BackNavigationInfo implements Parcelable {
        mPrepareRemoteAnimation = in.readBoolean();
    }

    /** @hide */
    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mType);
@@ -126,7 +129,7 @@ public final class BackNavigationInfo implements Parcelable {

    /**
     * Returns the type of back navigation that is about to happen.
     *
     * @hide
     * @see BackTargetType
     */
    public @BackTargetType int getType() {
@@ -138,7 +141,7 @@ public final class BackNavigationInfo implements Parcelable {
     * the client didn't register a callback.
     * <p>
     * This is never null when {@link #getType} returns {@link #TYPE_CALLBACK}.
     *
     * @hide
     * @see OnBackInvokedCallback
     * @see OnBackInvokedDispatcher
     */
@@ -149,6 +152,7 @@ public final class BackNavigationInfo implements Parcelable {

    /**
     * Return true if the core is preparing a back gesture nimation.
     * @hide
     */
    public boolean isPrepareRemoteAnimation() {
        return mPrepareRemoteAnimation;
@@ -157,7 +161,7 @@ public final class BackNavigationInfo implements Parcelable {
    /**
     * Callback to be called when the back preview is finished in order to notify the server that
     * it can clean up the resources created for the animation.
     *
     * @hide
     * @param triggerBack Boolean indicating if back navigation has been triggered.
     */
    public void onBackNavigationFinished(boolean triggerBack) {
@@ -168,11 +172,13 @@ public final class BackNavigationInfo implements Parcelable {
        }
    }

    /** @hide */
    @Override
    public int describeContents() {
        return 0;
    }

    @NonNull
    public static final Creator<BackNavigationInfo> CREATOR = new Creator<BackNavigationInfo>() {
        @Override
        public BackNavigationInfo createFromParcel(Parcel in) {
@@ -197,6 +203,7 @@ public final class BackNavigationInfo implements Parcelable {
    /**
     * Translates the {@link BackNavigationInfo} integer type to its String representation
     */
    @NonNull
    public static String typeToString(@BackTargetType int type) {
        switch (type) {
            case TYPE_UNDEFINED:
+9 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ message WindowManagerServiceDumpProto {
    optional int32 focused_display_id = 9;
    optional bool hard_keyboard_available = 10;
    optional bool window_frames_valid = 11;
    optional BackNavigationProto back_navigation = 12;
}

/* represents RootWindowContainer object */
@@ -595,3 +596,11 @@ message ImeInsetsSourceProviderProto {
    optional WindowStateProto ime_target_from_ime = 2;
    optional bool is_ime_layout_drawn = 3;
}

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

    optional bool animation_in_progress = 1;
    optional int32 last_back_type = 2;
    optional bool show_wallpaper = 3;
}
 No newline at end of file
+16 −2
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_TO_BACK;

import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_BACK_PREVIEW;
import static com.android.server.wm.BackNavigationProto.ANIMATION_IN_PROGRESS;
import static com.android.server.wm.BackNavigationProto.LAST_BACK_TYPE;
import static com.android.server.wm.BackNavigationProto.SHOW_WALLPAPER;

import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -37,6 +40,7 @@ import android.os.RemoteException;
import android.os.SystemProperties;
import android.util.ArraySet;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;
import android.view.IWindowFocusObserver;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl;
@@ -60,6 +64,7 @@ class BackNavigationController {
    private WindowManagerService mWindowManagerService;
    private IWindowFocusObserver mFocusObserver;
    private boolean mBackAnimationInProgress;
    private @BackNavigationInfo.BackTargetType int mLastBackType;
    private boolean mShowWallpaper;
    private Runnable mPendingAnimation;

@@ -215,7 +220,7 @@ class BackNavigationController {
                infoBuilder.setOnBackNavigationDone(new RemoteCallback(result ->
                        onBackNavigationDone(result, finalFocusedWindow,
                                BackNavigationInfo.TYPE_CALLBACK)));

                mLastBackType = backType;
                return infoBuilder.setType(backType).build();
            }

@@ -301,7 +306,7 @@ class BackNavigationController {
                    result, finalFocusedWindow, finalBackType));
            infoBuilder.setOnBackNavigationDone(onBackNavigationDone);
        }

        mLastBackType = backType;
        return infoBuilder.build();
    }

@@ -836,4 +841,13 @@ class BackNavigationController {
                && w.mAttrs.type == TYPE_BASE_APPLICATION && w.mActivityRecord != null
                && mAnimationTargets.isTarget(w.mActivityRecord, true /* open */);
    }

    // Called from WindowManagerService to write to a protocol buffer output stream.
    void dumpDebug(ProtoOutputStream proto, long fieldId) {
        final long token = proto.start(fieldId);
        proto.write(ANIMATION_IN_PROGRESS, mBackAnimationInProgress);
        proto.write(LAST_BACK_TYPE, mLastBackType);
        proto.write(SHOW_WALLPAPER, mShowWallpaper);
        proto.end(token);
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -140,6 +140,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.SHOW_STACK_CRAWLS;
import static com.android.server.wm.WindowManagerDebugConfig.SHOW_VERBOSE_TRANSACTIONS;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerServiceDumpProto.BACK_NAVIGATION;
import static com.android.server.wm.WindowManagerServiceDumpProto.DISPLAY_FROZEN;
import static com.android.server.wm.WindowManagerServiceDumpProto.FOCUSED_APP;
import static com.android.server.wm.WindowManagerServiceDumpProto.FOCUSED_DISPLAY_ID;
@@ -6554,6 +6555,9 @@ public class WindowManagerService extends IWindowManager.Stub
        // Once we move the window layout to the client side, this can be false when we are waiting
        // for the frames.
        proto.write(WINDOW_FRAMES_VALID, true);

        // Write the BackNavigationController's state into the protocol buffer
        mAtmService.mBackNavigationController.dumpDebug(proto, BACK_NAVIGATION);
    }

    private void dumpWindowsLocked(PrintWriter pw, boolean dumpAll,