Loading core/java/android/app/NotificationChannel.java +3 −3 Original line number Diff line number Diff line Loading @@ -547,7 +547,7 @@ public final class NotificationChannel implements Parcelable { * @hide */ public void setId(String id) { mId = id; mId = getTrimmedString(id); } // Modifiable by apps on channel creation. Loading Loading @@ -772,8 +772,8 @@ public final class NotificationChannel implements Parcelable { */ public void setConversationId(@NonNull String parentChannelId, @NonNull String conversationId) { mParentId = parentChannelId; mConversationId = conversationId; mParentId = getTrimmedString(parentChannelId); mConversationId = getTrimmedString(conversationId); } /** Loading core/java/android/app/admin/DeviceAdminInfo.java +2 −0 Original line number Diff line number Diff line Loading @@ -397,6 +397,8 @@ public final class DeviceAdminInfo implements Parcelable { } catch (NameNotFoundException e) { throw new XmlPullParserException( "Unable to create context for: " + mActivityInfo.packageName); } catch (OutOfMemoryError e) { throw new XmlPullParserException("Out of memory when parsing", null, e); } finally { if (parser != null) parser.close(); } Loading core/java/android/companion/AssociationRequest.java +7 −0 Original line number Diff line number Diff line Loading @@ -233,6 +233,8 @@ public final class AssociationRequest implements Parcelable { */ private boolean mSkipPrompt; private static final int DISPLAY_NAME_LENGTH_LIMIT = 1024; /** * Creates a new AssociationRequest. * Loading Loading @@ -419,6 +421,11 @@ public final class AssociationRequest implements Parcelable { public Builder setDisplayName(@NonNull CharSequence displayName) { checkNotUsed(); mDisplayName = requireNonNull(displayName); if (displayName.length() > DISPLAY_NAME_LENGTH_LIMIT) { throw new IllegalArgumentException("Length of the display name must be at most " + DISPLAY_NAME_LENGTH_LIMIT + " characters"); } return this; } Loading core/tests/coretests/src/android/app/NotificationChannelTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -230,6 +230,36 @@ public class NotificationChannelTest { fromParcel.getSound().toString().length()); } @Test public void testSetId_longStringIsTrimmed() { NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_DEFAULT); String longId = Strings.repeat("A", NotificationChannel.MAX_TEXT_LENGTH + 10); channel.setId(longId); assertThat(channel.getId()).hasLength(NotificationChannel.MAX_TEXT_LENGTH); assertThat(channel.getId()) .isEqualTo(longId.substring(0, NotificationChannel.MAX_TEXT_LENGTH)); } @Test public void testSetConversationId_longStringsAreTrimmed() { NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_DEFAULT); String longParentId = Strings.repeat("P", NotificationChannel.MAX_TEXT_LENGTH + 10); String longConversationId = Strings.repeat("C", NotificationChannel.MAX_TEXT_LENGTH + 10); channel.setConversationId(longParentId, longConversationId); assertThat(channel.getParentChannelId()).hasLength(NotificationChannel.MAX_TEXT_LENGTH); assertThat(channel.getParentChannelId()) .isEqualTo(longParentId.substring(0, NotificationChannel.MAX_TEXT_LENGTH)); assertThat(channel.getConversationId()).hasLength(NotificationChannel.MAX_TEXT_LENGTH); assertThat(channel.getConversationId()) .isEqualTo(longConversationId.substring(0, NotificationChannel.MAX_TEXT_LENGTH)); } @Test @EnableFlags({Flags.FLAG_NOTIFICATION_CHANNEL_VIBRATION_EFFECT_API, Flags.FLAG_NOTIF_CHANNEL_CROP_VIBRATION_EFFECTS}) Loading packages/CtsShim/build/Android.bp +8 −36 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ genrule { name: "generate_priv_manifest", srcs: [ "shim_priv/AndroidManifest.xml", ":CtsShimPrivUpgrade", ":CtsShimPrivUpgrade" ], out: ["AndroidManifest.xml"], cmd: "sed -e s/__HASH__/`sha512sum -b $(location :CtsShimPrivUpgrade) | cut -d' ' -f1`/ $(location shim_priv/AndroidManifest.xml) > $(out)", Loading Loading @@ -152,34 +152,6 @@ android_app { ], } //########################################################## // Variant: System app upgrade android_app { name: "CtsShimUpgrade", sdk_version: "current", optimize: { enabled: false, }, dex_preopt: { enabled: false, }, manifest: "shim/AndroidManifestUpgrade.xml", min_sdk_version: "24", } genrule { name: "generate_shim_manifest", srcs: [ "shim/AndroidManifest.xml", ":CtsShimUpgrade", ], out: ["AndroidManifest.xml"], cmd: "sed -e s/__HASH__/`sha512sum -b $(location :CtsShimUpgrade) | cut -d' ' -f1`/ $(location shim/AndroidManifest.xml) > $(out)", } //########################################################## // Variant: System app Loading @@ -194,7 +166,7 @@ android_app { enabled: false, }, manifest: ":generate_shim_manifest", manifest: "shim/AndroidManifest.xml", apex_available: [ "//apex_available:platform", "com.android.apex.cts.shim.v1", Loading Loading
core/java/android/app/NotificationChannel.java +3 −3 Original line number Diff line number Diff line Loading @@ -547,7 +547,7 @@ public final class NotificationChannel implements Parcelable { * @hide */ public void setId(String id) { mId = id; mId = getTrimmedString(id); } // Modifiable by apps on channel creation. Loading Loading @@ -772,8 +772,8 @@ public final class NotificationChannel implements Parcelable { */ public void setConversationId(@NonNull String parentChannelId, @NonNull String conversationId) { mParentId = parentChannelId; mConversationId = conversationId; mParentId = getTrimmedString(parentChannelId); mConversationId = getTrimmedString(conversationId); } /** Loading
core/java/android/app/admin/DeviceAdminInfo.java +2 −0 Original line number Diff line number Diff line Loading @@ -397,6 +397,8 @@ public final class DeviceAdminInfo implements Parcelable { } catch (NameNotFoundException e) { throw new XmlPullParserException( "Unable to create context for: " + mActivityInfo.packageName); } catch (OutOfMemoryError e) { throw new XmlPullParserException("Out of memory when parsing", null, e); } finally { if (parser != null) parser.close(); } Loading
core/java/android/companion/AssociationRequest.java +7 −0 Original line number Diff line number Diff line Loading @@ -233,6 +233,8 @@ public final class AssociationRequest implements Parcelable { */ private boolean mSkipPrompt; private static final int DISPLAY_NAME_LENGTH_LIMIT = 1024; /** * Creates a new AssociationRequest. * Loading Loading @@ -419,6 +421,11 @@ public final class AssociationRequest implements Parcelable { public Builder setDisplayName(@NonNull CharSequence displayName) { checkNotUsed(); mDisplayName = requireNonNull(displayName); if (displayName.length() > DISPLAY_NAME_LENGTH_LIMIT) { throw new IllegalArgumentException("Length of the display name must be at most " + DISPLAY_NAME_LENGTH_LIMIT + " characters"); } return this; } Loading
core/tests/coretests/src/android/app/NotificationChannelTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -230,6 +230,36 @@ public class NotificationChannelTest { fromParcel.getSound().toString().length()); } @Test public void testSetId_longStringIsTrimmed() { NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_DEFAULT); String longId = Strings.repeat("A", NotificationChannel.MAX_TEXT_LENGTH + 10); channel.setId(longId); assertThat(channel.getId()).hasLength(NotificationChannel.MAX_TEXT_LENGTH); assertThat(channel.getId()) .isEqualTo(longId.substring(0, NotificationChannel.MAX_TEXT_LENGTH)); } @Test public void testSetConversationId_longStringsAreTrimmed() { NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_DEFAULT); String longParentId = Strings.repeat("P", NotificationChannel.MAX_TEXT_LENGTH + 10); String longConversationId = Strings.repeat("C", NotificationChannel.MAX_TEXT_LENGTH + 10); channel.setConversationId(longParentId, longConversationId); assertThat(channel.getParentChannelId()).hasLength(NotificationChannel.MAX_TEXT_LENGTH); assertThat(channel.getParentChannelId()) .isEqualTo(longParentId.substring(0, NotificationChannel.MAX_TEXT_LENGTH)); assertThat(channel.getConversationId()).hasLength(NotificationChannel.MAX_TEXT_LENGTH); assertThat(channel.getConversationId()) .isEqualTo(longConversationId.substring(0, NotificationChannel.MAX_TEXT_LENGTH)); } @Test @EnableFlags({Flags.FLAG_NOTIFICATION_CHANNEL_VIBRATION_EFFECT_API, Flags.FLAG_NOTIF_CHANNEL_CROP_VIBRATION_EFFECTS}) Loading
packages/CtsShim/build/Android.bp +8 −36 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ genrule { name: "generate_priv_manifest", srcs: [ "shim_priv/AndroidManifest.xml", ":CtsShimPrivUpgrade", ":CtsShimPrivUpgrade" ], out: ["AndroidManifest.xml"], cmd: "sed -e s/__HASH__/`sha512sum -b $(location :CtsShimPrivUpgrade) | cut -d' ' -f1`/ $(location shim_priv/AndroidManifest.xml) > $(out)", Loading Loading @@ -152,34 +152,6 @@ android_app { ], } //########################################################## // Variant: System app upgrade android_app { name: "CtsShimUpgrade", sdk_version: "current", optimize: { enabled: false, }, dex_preopt: { enabled: false, }, manifest: "shim/AndroidManifestUpgrade.xml", min_sdk_version: "24", } genrule { name: "generate_shim_manifest", srcs: [ "shim/AndroidManifest.xml", ":CtsShimUpgrade", ], out: ["AndroidManifest.xml"], cmd: "sed -e s/__HASH__/`sha512sum -b $(location :CtsShimUpgrade) | cut -d' ' -f1`/ $(location shim/AndroidManifest.xml) > $(out)", } //########################################################## // Variant: System app Loading @@ -194,7 +166,7 @@ android_app { enabled: false, }, manifest: ":generate_shim_manifest", manifest: "shim/AndroidManifest.xml", apex_available: [ "//apex_available:platform", "com.android.apex.cts.shim.v1", Loading