summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yunfan Chen <yunfanc@google.com> 2023-11-17 16:22:37 +0900
committer Yunfan Chen <yunfanc@google.com> 2023-12-15 17:03:37 +0900
commite52ae82e727f8049ec5e0d56d7e60b149dc65a8d (patch)
tree8b2a711d2e24551287aaa536c1011454d4598b6a
parent5d46b5c6434ef65478adbaa3d1d72d9a089686d8 (diff)
Deprecate type name proto dump
Stop dumping type name string into proto and use the type number instead. For CTS purpose, exposet the toString to CTS as a test API. Test: m cts Test: winscope Bug: 311548419 Change-Id: I793c1273861f60be82e780165c3ec89702cf7145
-rw-r--r--core/api/test-current.txt4
-rw-r--r--core/java/android/view/InsetsSource.java4
-rw-r--r--core/java/android/view/InsetsSourceConsumer.java4
-rw-r--r--core/java/android/view/InsetsSourceControl.java6
-rw-r--r--core/java/android/view/WindowInsets.java5
-rw-r--r--core/proto/android/view/insetssource.proto2
-rw-r--r--core/proto/android/view/insetssourceconsumer.proto3
-rw-r--r--core/proto/android/view/insetssourcecontrol.proto3
8 files changed, 20 insertions, 11 deletions
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index f4c8429619dd..baccd46f4282 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -3589,6 +3589,10 @@ package android.view {
method @Nullable public android.view.View getStatusBarBackgroundView();
}
+ public static final class WindowInsets.Type {
+ method @NonNull public static String toString(int);
+ }
+
public interface WindowManager extends android.view.ViewManager {
method public default int getDisplayImePolicy(int);
method public static boolean hasWindowExtensionsEnabled();
diff --git a/core/java/android/view/InsetsSource.java b/core/java/android/view/InsetsSource.java
index cabab6c80bf5..0927d4519b9c 100644
--- a/core/java/android/view/InsetsSource.java
+++ b/core/java/android/view/InsetsSource.java
@@ -17,7 +17,6 @@
package android.view;
import static android.view.InsetsSourceProto.FRAME;
-import static android.view.InsetsSourceProto.TYPE;
import static android.view.InsetsSourceProto.TYPE_NUMBER;
import static android.view.InsetsSourceProto.VISIBLE;
import static android.view.InsetsSourceProto.VISIBLE_FRAME;
@@ -353,13 +352,12 @@ public class InsetsSource implements Parcelable {
*/
public void dumpDebug(ProtoOutputStream proto, long fieldId) {
final long token = proto.start(fieldId);
- proto.write(TYPE, WindowInsets.Type.toString(mType));
- proto.write(TYPE_NUMBER, mType);
mFrame.dumpDebug(proto, FRAME);
if (mVisibleFrame != null) {
mVisibleFrame.dumpDebug(proto, VISIBLE_FRAME);
}
proto.write(VISIBLE, mVisible);
+ proto.write(TYPE_NUMBER, mType);
proto.end(token);
}
diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java
index 34b288460a67..0ce61bb17774 100644
--- a/core/java/android/view/InsetsSourceConsumer.java
+++ b/core/java/android/view/InsetsSourceConsumer.java
@@ -21,11 +21,11 @@ import static android.view.InsetsController.AnimationType;
import static android.view.InsetsController.DEBUG;
import static android.view.InsetsSourceConsumerProto.ANIMATION_STATE;
import static android.view.InsetsSourceConsumerProto.HAS_WINDOW_FOCUS;
-import static android.view.InsetsSourceConsumerProto.INTERNAL_INSETS_TYPE;
import static android.view.InsetsSourceConsumerProto.IS_REQUESTED_VISIBLE;
import static android.view.InsetsSourceConsumerProto.PENDING_FRAME;
import static android.view.InsetsSourceConsumerProto.PENDING_VISIBLE_FRAME;
import static android.view.InsetsSourceConsumerProto.SOURCE_CONTROL;
+import static android.view.InsetsSourceConsumerProto.TYPE_NUMBER;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE;
@@ -393,7 +393,6 @@ public class InsetsSourceConsumer {
void dumpDebug(ProtoOutputStream proto, long fieldId) {
final long token = proto.start(fieldId);
- proto.write(INTERNAL_INSETS_TYPE, WindowInsets.Type.toString(mType));
proto.write(HAS_WINDOW_FOCUS, mHasWindowFocus);
proto.write(IS_REQUESTED_VISIBLE, isShowRequested());
if (mSourceControl != null) {
@@ -406,6 +405,7 @@ public class InsetsSourceConsumer {
mPendingVisibleFrame.dumpDebug(proto, PENDING_VISIBLE_FRAME);
}
proto.write(ANIMATION_STATE, mAnimationState);
+ proto.write(TYPE_NUMBER, mType);
proto.end(token);
}
}
diff --git a/core/java/android/view/InsetsSourceControl.java b/core/java/android/view/InsetsSourceControl.java
index 7ea93f5a7542..527c7ed8e5f6 100644
--- a/core/java/android/view/InsetsSourceControl.java
+++ b/core/java/android/view/InsetsSourceControl.java
@@ -20,7 +20,7 @@ import static android.graphics.PointProto.X;
import static android.graphics.PointProto.Y;
import static android.view.InsetsSourceControlProto.LEASH;
import static android.view.InsetsSourceControlProto.POSITION;
-import static android.view.InsetsSourceControlProto.TYPE;
+import static android.view.InsetsSourceControlProto.TYPE_NUMBER;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -244,8 +244,6 @@ public class InsetsSourceControl implements Parcelable {
*/
public void dumpDebug(ProtoOutputStream proto, long fieldId) {
final long token = proto.start(fieldId);
- proto.write(TYPE, WindowInsets.Type.toString(mType));
-
final long surfaceToken = proto.start(POSITION);
proto.write(X, mSurfacePosition.x);
proto.write(Y, mSurfacePosition.y);
@@ -254,6 +252,8 @@ public class InsetsSourceControl implements Parcelable {
if (mLeash != null) {
mLeash.dumpDebug(proto, LEASH);
}
+
+ proto.write(TYPE_NUMBER, mType);
proto.end(token);
}
diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java
index 57a41619ff8d..921afaa99277 100644
--- a/core/java/android/view/WindowInsets.java
+++ b/core/java/android/view/WindowInsets.java
@@ -38,6 +38,8 @@ import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SuppressLint;
+import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Intent;
import android.graphics.Insets;
@@ -1519,6 +1521,9 @@ public final class WindowInsets {
}
/** @hide */
+ @TestApi
+ @NonNull
+ @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
public static String toString(@InsetsType int types) {
StringBuilder result = new StringBuilder();
if ((types & STATUS_BARS) != 0) {
diff --git a/core/proto/android/view/insetssource.proto b/core/proto/android/view/insetssource.proto
index e6c6d5978779..118dfc8165d2 100644
--- a/core/proto/android/view/insetssource.proto
+++ b/core/proto/android/view/insetssource.proto
@@ -26,7 +26,7 @@ option java_multiple_files = true;
* Represents a {@link android.view.InsetsSource} object.
*/
message InsetsSourceProto {
- optional string type = 1;
+ optional string type = 1 [deprecated=true];
optional .android.graphics.RectProto frame = 2;
optional .android.graphics.RectProto visible_frame = 3;
optional bool visible = 4;
diff --git a/core/proto/android/view/insetssourceconsumer.proto b/core/proto/android/view/insetssourceconsumer.proto
index a01ad8eea582..882163f6a9d4 100644
--- a/core/proto/android/view/insetssourceconsumer.proto
+++ b/core/proto/android/view/insetssourceconsumer.proto
@@ -27,11 +27,12 @@ option java_multiple_files = true;
* Represents a {@link android.view.InsetsSourceConsumer} object.
*/
message InsetsSourceConsumerProto {
- optional string internal_insets_type = 1;
+ optional string internal_insets_type = 1 [deprecated=true];
optional bool has_window_focus = 2;
optional bool is_requested_visible = 3;
optional InsetsSourceControlProto source_control = 4;
optional .android.graphics.RectProto pending_frame = 5;
optional .android.graphics.RectProto pending_visible_frame = 6;
optional int32 animation_state = 7;
+ optional int32 type_number = 8;
} \ No newline at end of file
diff --git a/core/proto/android/view/insetssourcecontrol.proto b/core/proto/android/view/insetssourcecontrol.proto
index 3ac3cbfafaff..afab57f416cf 100644
--- a/core/proto/android/view/insetssourcecontrol.proto
+++ b/core/proto/android/view/insetssourcecontrol.proto
@@ -27,7 +27,8 @@ option java_multiple_files = true;
* Represents a {@link android.view.InsetsSourceControl} object.
*/
message InsetsSourceControlProto {
- optional string type = 1;
+ optional string type = 1 [deprecated=true];
optional .android.graphics.PointProto position = 2;
optional SurfaceControlProto leash = 3;
+ optional int32 type_number = 4;
} \ No newline at end of file