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.ListNote: 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")); + } }