From e79aa09f873117177354fa61e1ed8ba6180700bb Mon Sep 17 00:00:00 2001 From: TYM Tsai Date: Mon, 27 Apr 2020 21:31:27 +0800 Subject: [PATCH] Update the documentation for inline suggestion APIs Update the APIs documentation and add test cases Bug: 152316540 Test: atest InlinePresentationStyleUtilsTest Change-Id: Icff5d5b36fecd94ceb7db5446eefa16b4b1aac3b --- .../inputmethod/InlineSuggestionsRequest.java | 11 +++- .../widget/inline/InlinePresentationSpec.java | 11 +++- .../InlinePresentationStyleUtilsTest.java | 54 +++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/core/java/android/view/inputmethod/InlineSuggestionsRequest.java b/core/java/android/view/inputmethod/InlineSuggestionsRequest.java index 4d4faa4ba2a33..cce109074d82e 100644 --- a/core/java/android/view/inputmethod/InlineSuggestionsRequest.java +++ b/core/java/android/view/inputmethod/InlineSuggestionsRequest.java @@ -72,6 +72,9 @@ public final class InlineSuggestionsRequest implements Parcelable { /** * The extras state propagated from the IME to pass extra data. + * + *

Note: There should be no remote objects in the bundle, all included remote objects will + * be removed from the bundle before transmission.

*/ private @NonNull Bundle mExtras; @@ -261,6 +264,9 @@ public final class InlineSuggestionsRequest implements Parcelable { /** * The extras state propagated from the IME to pass extra data. + * + *

Note: There should be no remote objects in the bundle, all included remote objects will + * be removed from the bundle before transmission.

*/ @DataClass.Generated.Member public @NonNull Bundle getExtras() { @@ -513,6 +519,9 @@ public final class InlineSuggestionsRequest implements Parcelable { /** * The extras state propagated from the IME to pass extra data. + * + *

Note: There should be no remote objects in the bundle, all included remote objects will + * be removed from the bundle before transmission.

*/ @DataClass.Generated.Member public @NonNull Builder setExtras(@NonNull Bundle value) { @@ -595,7 +604,7 @@ public final class InlineSuggestionsRequest implements Parcelable { } @DataClass.Generated( - time = 1587537617922L, + time = 1588109685838L, codegenVersion = "1.0.15", sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestionsRequest.java", inputSignatures = "public static final int SUGGESTION_COUNT_UNLIMITED\nprivate final int mMaxSuggestionCount\nprivate final @android.annotation.NonNull java.util.List mInlinePresentationSpecs\nprivate @android.annotation.NonNull java.lang.String mHostPackageName\nprivate @android.annotation.NonNull android.os.LocaleList mSupportedLocales\nprivate @android.annotation.NonNull android.os.Bundle mExtras\nprivate @android.annotation.Nullable android.os.IBinder mHostInputToken\nprivate int mHostDisplayId\npublic void setHostInputToken(android.os.IBinder)\nprivate boolean extrasEquals(android.os.Bundle)\nprivate void parcelHostInputToken(android.os.Parcel,int)\nprivate @android.annotation.Nullable android.os.IBinder unparcelHostInputToken(android.os.Parcel)\npublic void setHostDisplayId(int)\nprivate void onConstructed()\npublic void filterContentTypes()\nprivate static int defaultMaxSuggestionCount()\nprivate static java.lang.String defaultHostPackageName()\nprivate static android.os.LocaleList defaultSupportedLocales()\nprivate static @android.annotation.Nullable android.os.IBinder defaultHostInputToken()\nprivate static @android.annotation.Nullable int defaultHostDisplayId()\nprivate static @android.annotation.NonNull android.os.Bundle defaultExtras()\nclass InlineSuggestionsRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setInlinePresentationSpecs(java.util.List)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostPackageName(java.lang.String)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostInputToken(android.os.IBinder)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostDisplayId(int)\nclass BaseBuilder extends java.lang.Object implements []") diff --git a/core/java/android/widget/inline/InlinePresentationSpec.java b/core/java/android/widget/inline/InlinePresentationSpec.java index 9f966d84eb347..5f924c6ae194a 100644 --- a/core/java/android/widget/inline/InlinePresentationSpec.java +++ b/core/java/android/widget/inline/InlinePresentationSpec.java @@ -44,6 +44,9 @@ public final class InlinePresentationSpec implements Parcelable { /** * The extras encoding the UI style information. Defaults to {@code Bundle.Empty} in which case * the default system UI style will be used. + * + *

Note: There should be no remote objects in the bundle, all included remote objects will + * be removed from the bundle before transmission.

*/ @NonNull private final Bundle mStyle; @@ -122,6 +125,9 @@ public final class InlinePresentationSpec implements Parcelable { /** * The extras encoding the UI style information. Defaults to {@code Bundle.Empty} in which case * the default system UI style will be used. + * + *

Note: There should be no remote objects in the bundle, all included remote objects will + * be removed from the bundle before transmission.

*/ @DataClass.Generated.Member public @NonNull Bundle getStyle() { @@ -260,6 +266,9 @@ public final class InlinePresentationSpec implements Parcelable { /** * The extras encoding the UI style information. Defaults to {@code Bundle.Empty} in which case * the default system UI style will be used. + * + *

Note: There should be no remote objects in the bundle, all included remote objects will + * be removed from the bundle before transmission.

*/ @DataClass.Generated.Member public @NonNull Builder setStyle(@NonNull Bundle value) { @@ -293,7 +302,7 @@ public final class InlinePresentationSpec implements Parcelable { } @DataClass.Generated( - time = 1586935491105L, + time = 1588109681295L, codegenVersion = "1.0.15", sourceFile = "frameworks/base/core/java/android/widget/inline/InlinePresentationSpec.java", inputSignatures = "private final @android.annotation.NonNull android.util.Size mMinSize\nprivate final @android.annotation.NonNull android.util.Size mMaxSize\nprivate final @android.annotation.NonNull android.os.Bundle mStyle\nprivate static @android.annotation.NonNull android.os.Bundle defaultStyle()\nprivate boolean styleEquals(android.os.Bundle)\npublic void filterContentTypes()\nclass InlinePresentationSpec extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nclass BaseBuilder extends java.lang.Object implements []") diff --git a/core/tests/utiltests/src/com/android/internal/util/InlinePresentationStyleUtilsTest.java b/core/tests/utiltests/src/com/android/internal/util/InlinePresentationStyleUtilsTest.java index 8e4f38ef15d34..35c56818a1088 100644 --- a/core/tests/utiltests/src/com/android/internal/util/InlinePresentationStyleUtilsTest.java +++ b/core/tests/utiltests/src/com/android/internal/util/InlinePresentationStyleUtilsTest.java @@ -16,9 +16,13 @@ package com.android.internal.util; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import android.os.Binder; import android.os.Bundle; import androidx.test.filters.SmallTest; @@ -110,4 +114,54 @@ public class InlinePresentationStyleUtilsTest { bundle2.putInt("KEY", 22); assertFalse(InlinePresentationStyleUtils.bundleEquals(bundle1, bundle2)); } + + @Test + public void testFilterContentTypes_nullOrEmpty() { + InlinePresentationStyleUtils.filterContentTypes(null); + InlinePresentationStyleUtils.filterContentTypes(new Bundle()); + } + + @Test + public void testFilterContentTypes_basic() { + Bundle bundle = new Bundle(); + bundle.putInt("int", 11); + bundle.putString("str", "test"); + bundle.putString("null", null); + + InlinePresentationStyleUtils.filterContentTypes(bundle); + + assertEquals(11, bundle.getInt("int")); + assertEquals("test", bundle.getString("str")); + assertTrue(bundle.keySet().contains("null")); + } + + @Test + public void testFilterContentTypes_binder_removedBinder() { + Bundle bundle = new Bundle(); + bundle.putInt("int", 11); + bundle.putString("str", "test"); + bundle.putString("null", null); + bundle.putBinder("binder", new Binder()); + + InlinePresentationStyleUtils.filterContentTypes(bundle); + + assertEquals(11, bundle.getInt("int")); + assertEquals("test", bundle.getString("str")); + assertTrue(bundle.keySet().contains("null")); + assertNull(bundle.getBinder("binder")); + } + + @Test + public void testFilterContentTypes_binderInChild_removedBinder() { + Bundle child = new Bundle(); + child.putBinder("binder", new Binder()); + Bundle bundle = new Bundle(); + bundle.putBundle("child", child); + + InlinePresentationStyleUtils.filterContentTypes(bundle); + + Bundle child2 = bundle.getBundle("child"); + assertNotNull(child2); + assertNull(child2.getBinder("binder")); + } }