Merge "Add server side proto-base dumping for back navigation"
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index ec592c0..121741e0 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -3306,6 +3306,18 @@
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();
diff --git a/core/java/android/window/BackNavigationInfo.java b/core/java/android/window/BackNavigationInfo.java
index a25e035..d7bca30 100644
--- a/core/java/android/window/BackNavigationInfo.java
+++ b/core/java/android/window/BackNavigationInfo.java
@@ -19,6 +19,7 @@
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 @@
*
* @hide
*/
+@TestApi
public final class BackNavigationInfo implements Parcelable {
/**
@@ -71,6 +73,7 @@
/**
* 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 @@
* @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 @@
mPrepareRemoteAnimation = in.readBoolean();
}
+ /** @hide */
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(mType);
@@ -126,7 +129,7 @@
/**
* Returns the type of back navigation that is about to happen.
- *
+ * @hide
* @see BackTargetType
*/
public @BackTargetType int getType() {
@@ -138,7 +141,7 @@
* 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 @@
/**
* Return true if the core is preparing a back gesture nimation.
+ * @hide
*/
public boolean isPrepareRemoteAnimation() {
return mPrepareRemoteAnimation;
@@ -157,7 +161,7 @@
/**
* 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 @@
}
}
+ /** @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 @@
/**
* Translates the {@link BackNavigationInfo} integer type to its String representation
*/
+ @NonNull
public static String typeToString(@BackTargetType int type) {
switch (type) {
case TYPE_UNDEFINED:
diff --git a/core/proto/android/server/windowmanagerservice.proto b/core/proto/android/server/windowmanagerservice.proto
index 537efc0..82e1777 100644
--- a/core/proto/android/server/windowmanagerservice.proto
+++ b/core/proto/android/server/windowmanagerservice.proto
@@ -54,6 +54,7 @@
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 @@
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
diff --git a/services/core/java/com/android/server/wm/BackNavigationController.java b/services/core/java/com/android/server/wm/BackNavigationController.java
index f5da4c8..3bb0238 100644
--- a/services/core/java/com/android/server/wm/BackNavigationController.java
+++ b/services/core/java/com/android/server/wm/BackNavigationController.java
@@ -24,6 +24,9 @@
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.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 @@
private WindowManagerService mWindowManagerService;
private IWindowFocusObserver mFocusObserver;
private boolean mBackAnimationInProgress;
+ private @BackNavigationInfo.BackTargetType int mLastBackType;
private boolean mShowWallpaper;
private Runnable mPendingAnimation;
@@ -215,7 +220,7 @@
infoBuilder.setOnBackNavigationDone(new RemoteCallback(result ->
onBackNavigationDone(result, finalFocusedWindow,
BackNavigationInfo.TYPE_CALLBACK)));
-
+ mLastBackType = backType;
return infoBuilder.setType(backType).build();
}
@@ -301,7 +306,7 @@
result, finalFocusedWindow, finalBackType));
infoBuilder.setOnBackNavigationDone(onBackNavigationDone);
}
-
+ mLastBackType = backType;
return infoBuilder.build();
}
@@ -836,4 +841,13 @@
&& 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);
+ }
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 1289634..42cd8c1 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -140,6 +140,7 @@
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 @@
// 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,