Remove @VisibleForTesting from Message#toBundle to make it public.

This changes the method from private to public to allow other platform
components to depend on it.

Test: atest FrameworksCoreTests:NotificationTest
Bug: 275303162
Change-Id: I8fb45b5ab1a42921ae19b904f83013e2f0ca4449
This commit is contained in:
David Krska
2023-03-29 13:07:44 +00:00
parent 00558ac53a
commit 71cd8f7d9f
2 changed files with 24 additions and 1 deletions

View File

@@ -8723,9 +8723,11 @@ public class Notification implements Parcelable
}
/**
* Converts the message into a {@link Bundle}. To extract the message back,
* check {@link #getMessageFromBundle()}
* @hide
*/
@VisibleForTesting
@NonNull
public Bundle toBundle() {
Bundle bundle = new Bundle();
if (mText != null) {

View File

@@ -931,6 +931,27 @@ public class NotificationTest {
// no crash, good
}
@Test
public void testToBundle_getMessageFromBundle_returnsSameData() {
Notification.MessagingStyle.Message message =
new Notification.MessagingStyle.Message(
"a", 100, new Person.Builder().setName("hi").build());
message.setData("text", Uri.parse("http://test/uri"));
Notification.MessagingStyle.Message convertedMessage =
Notification.MessagingStyle.Message.getMessageFromBundle(message.toBundle());
assertThat(convertedMessage).isNotNull();
assertThat(message.getText()).isEqualTo(convertedMessage.getText());
assertThat(message.getTimestamp()).isEqualTo(convertedMessage.getTimestamp());
assertThat(message.getExtras().size()).isEqualTo(convertedMessage.getExtras().size());
assertThat(message.getSender()).isEqualTo(convertedMessage.getSender());
assertThat(message.getSenderPerson()).isEqualTo(convertedMessage.getSenderPerson());
assertThat(message.getDataMimeType()).isEqualTo(convertedMessage.getDataMimeType());
assertThat(message.getDataUri()).isEqualTo(convertedMessage.getDataUri());
assertThat(message.isRemoteInputHistory())
.isEqualTo(convertedMessage.isRemoteInputHistory());
}
@Test
public void testDoesNotStripsExtenders() {