Merge "Handle audio content on People Tiles." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f8a68352de
@@ -52,6 +52,7 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.UiEvent;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.internal.widget.MessagingMessage;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.people.widget.PeopleSpaceWidgetManager;
|
||||
@@ -265,10 +266,16 @@ public class PeopleSpaceUtils {
|
||||
boolean hasMessageText = message != null && !TextUtils.isEmpty(message.getText());
|
||||
CharSequence content = (isMissedCall && !hasMessageText)
|
||||
? context.getString(R.string.missed_call) : message.getText();
|
||||
Uri dataUri = message != null ? message.getDataUri() : null;
|
||||
|
||||
// We only use the URI if it's an image, otherwise we fallback to text (for example, with an
|
||||
// audio URI)
|
||||
Uri imageUri = message != null && MessagingMessage.hasImage(message)
|
||||
? message.getDataUri() : null;
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Tile key: " + key.toString() + ". Notification message has text: "
|
||||
+ hasMessageText + " Has last interaction: " + sbn.getPostTime());
|
||||
+ hasMessageText + ". Image URI: " + imageUri + ". Has last interaction: "
|
||||
+ sbn.getPostTime());
|
||||
}
|
||||
CharSequence sender = getSenderIfGroupConversation(notification, message);
|
||||
|
||||
@@ -278,7 +285,7 @@ public class PeopleSpaceUtils {
|
||||
.setNotificationCategory(notification.category)
|
||||
.setNotificationContent(content)
|
||||
.setNotificationSender(sender)
|
||||
.setNotificationDataUri(dataUri)
|
||||
.setNotificationDataUri(imageUri)
|
||||
.setMessagesCount(messagesCount)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -284,6 +284,73 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase {
|
||||
assertThat(actual.getNotificationSender().toString()).isEqualTo("name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAugmentTileFromNotificationGroupWithImageUri() {
|
||||
Notification notification = new Notification.Builder(mContext, "test")
|
||||
.setContentTitle("TEST_TITLE")
|
||||
.setContentText("TEST_TEXT")
|
||||
.setShortcutId(SHORTCUT_ID_1)
|
||||
.setStyle(new Notification.MessagingStyle(PERSON)
|
||||
.addMessage(new Notification.MessagingStyle.Message(
|
||||
NOTIFICATION_TEXT_1, 0, PERSON)
|
||||
.setData("image/jpeg", URI))
|
||||
)
|
||||
.build();
|
||||
NotificationEntry notificationEntry = new NotificationEntryBuilder()
|
||||
.setNotification(notification)
|
||||
.setShortcutInfo(new ShortcutInfo.Builder(mContext, SHORTCUT_ID_1).build())
|
||||
.setUser(UserHandle.of(0))
|
||||
.setPkg(PACKAGE_NAME)
|
||||
.build();
|
||||
PeopleSpaceTile tile =
|
||||
new PeopleSpaceTile
|
||||
.Builder(SHORTCUT_ID_1, "userName", ICON, new Intent())
|
||||
.setPackageName(PACKAGE_NAME)
|
||||
.setUserHandle(new UserHandle(0))
|
||||
.build();
|
||||
PeopleTileKey key = new PeopleTileKey(tile);
|
||||
PeopleSpaceTile actual = PeopleSpaceUtils
|
||||
.augmentTileFromNotification(mContext, tile, key, notificationEntry, 0,
|
||||
Optional.empty());
|
||||
|
||||
assertThat(actual.getNotificationContent().toString()).isEqualTo(NOTIFICATION_TEXT_1);
|
||||
assertThat(actual.getNotificationDataUri()).isEqualTo(URI);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAugmentTileFromNotificationGroupWithAudioUri() {
|
||||
Notification notification = new Notification.Builder(mContext, "test")
|
||||
.setContentTitle("TEST_TITLE")
|
||||
.setContentText("TEST_TEXT")
|
||||
.setShortcutId(SHORTCUT_ID_1)
|
||||
.setStyle(new Notification.MessagingStyle(PERSON)
|
||||
.addMessage(new Notification.MessagingStyle.Message(
|
||||
NOTIFICATION_TEXT_1, 0, PERSON)
|
||||
.setData("audio/ogg", URI))
|
||||
)
|
||||
.build();
|
||||
NotificationEntry notificationEntry = new NotificationEntryBuilder()
|
||||
.setNotification(notification)
|
||||
.setShortcutInfo(new ShortcutInfo.Builder(mContext, SHORTCUT_ID_1).build())
|
||||
.setUser(UserHandle.of(0))
|
||||
.setPkg(PACKAGE_NAME)
|
||||
.build();
|
||||
PeopleSpaceTile tile =
|
||||
new PeopleSpaceTile
|
||||
.Builder(SHORTCUT_ID_1, "userName", ICON, new Intent())
|
||||
.setPackageName(PACKAGE_NAME)
|
||||
.setUserHandle(new UserHandle(0))
|
||||
.build();
|
||||
PeopleTileKey key = new PeopleTileKey(tile);
|
||||
PeopleSpaceTile actual = PeopleSpaceUtils
|
||||
.augmentTileFromNotification(mContext, tile, key, notificationEntry, 0,
|
||||
Optional.empty());
|
||||
|
||||
assertThat(actual.getNotificationContent().toString()).isEqualTo(NOTIFICATION_TEXT_1);
|
||||
assertThat(actual.getNotificationDataUri()).isNull();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAugmentTileFromNotificationNoContent() {
|
||||
PeopleSpaceTile tile =
|
||||
|
||||
Reference in New Issue
Block a user