summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java22
-rw-r--r--packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/people/widget/AppWidgetOptionsHelper.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java55
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java9
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java6
7 files changed, 71 insertions, 30 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java
index eefe5ca93793..52104b5eecb8 100644
--- a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java
+++ b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java
@@ -245,9 +245,9 @@ public class PeopleSpaceUtils {
* {@code messagesCount}.
*/
public static PeopleSpaceTile augmentTileFromNotification(Context context, PeopleSpaceTile tile,
- NotificationEntry notificationEntry, int messagesCount) {
+ PeopleTileKey key, NotificationEntry notificationEntry, int messagesCount) {
if (notificationEntry == null || notificationEntry.getSbn().getNotification() == null) {
- if (DEBUG) Log.d(TAG, "Notification is null");
+ if (DEBUG) Log.d(TAG, "Tile key: " + key.toString() + ". Notification is null");
return removeNotificationFields(tile);
}
Notification notification = notificationEntry.getSbn().getNotification();
@@ -256,7 +256,7 @@ public class PeopleSpaceUtils {
getMessagingStyleMessages(notification);
if (!isMissedCall && ArrayUtils.isEmpty(messages)) {
- if (DEBUG) Log.d(TAG, "Notification has no content");
+ if (DEBUG) Log.d(TAG, "Tile key: " + key.toString() + ". Notification has no content");
return removeNotificationFields(tile);
}
@@ -268,7 +268,10 @@ public class PeopleSpaceUtils {
CharSequence content = (isMissedCall && !hasMessageText)
? context.getString(R.string.missed_call) : message.getText();
Uri dataUri = message != null ? message.getDataUri() : null;
- if (DEBUG) Log.d(TAG, "Notification message has text: " + hasMessageText);
+ if (DEBUG) {
+ Log.d(TAG, "Tile key: " + key.toString() + ". Notification message has text: "
+ + hasMessageText);
+ }
return tile
.toBuilder()
@@ -459,7 +462,7 @@ public class PeopleSpaceUtils {
}
if (DEBUG) {
Log.d(TAG, "Widget: " + appWidgetId + ", " + tile.getUserName() + ", "
- + tile.getPackageName());
+ + tile.getPackageName() + ". Updating app widget view.");
}
RemoteViews views = new PeopleTileViewHelper(context, tile, appWidgetId,
options).getViews();
@@ -472,7 +475,9 @@ public class PeopleSpaceUtils {
public static void updateAppWidgetOptionsAndView(AppWidgetManager appWidgetManager,
Context context, int appWidgetId, PeopleSpaceTile tile) {
if (tile == null) {
- Log.d(TAG, "Tile is null, skipping storage and update.");
+ if (DEBUG) {
+ Log.w(TAG, "Widget: " + appWidgetId + "Tile is null, skipping storage and update.");
+ }
return;
}
Bundle options = AppWidgetOptionsHelper.setPeopleTile(appWidgetManager, appWidgetId, tile);
@@ -483,7 +488,10 @@ public class PeopleSpaceUtils {
public static void updateAppWidgetOptionsAndView(AppWidgetManager appWidgetManager,
Context context, int appWidgetId, Optional<PeopleSpaceTile> optionalTile) {
if (!optionalTile.isPresent()) {
- Log.d(TAG, "Tile is null, skipping storage and update.");
+ if (DEBUG) {
+ Log.w(TAG, "Widget: " + appWidgetId
+ + "Optional tile is not present, skipping storage and update.");
+ }
return;
}
updateAppWidgetOptionsAndView(appWidgetManager, context, appWidgetId, optionalTile.get());
diff --git a/packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java b/packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java
index dd89f749d1bc..2ec8597a7361 100644
--- a/packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java
@@ -59,6 +59,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.R;
import com.android.systemui.people.widget.LaunchConversationActivity;
import com.android.systemui.people.widget.PeopleSpaceWidgetProvider;
+import com.android.systemui.people.widget.PeopleTileKey;
import java.text.NumberFormat;
import java.time.Duration;
@@ -148,6 +149,8 @@ public class PeopleTileViewHelper {
* content, then birthdays, then the most recent status, and finally last interaction.
*/
private RemoteViews getViewForTile() {
+ PeopleTileKey key = new PeopleTileKey(mTile);
+ if (DEBUG) Log.d(TAG, "Creating view for tile key: " + key.toString());
if (Objects.equals(mTile.getNotificationCategory(), CATEGORY_MISSED_CALL)) {
if (DEBUG) Log.d(TAG, "Create missed call view");
return createMissedCallRemoteViews();
diff --git a/packages/SystemUI/src/com/android/systemui/people/widget/AppWidgetOptionsHelper.java b/packages/SystemUI/src/com/android/systemui/people/widget/AppWidgetOptionsHelper.java
index 7254eec71d07..73c43ebfdaf0 100644
--- a/packages/SystemUI/src/com/android/systemui/people/widget/AppWidgetOptionsHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/people/widget/AppWidgetOptionsHelper.java
@@ -41,7 +41,7 @@ public class AppWidgetOptionsHelper {
PeopleSpaceTile tile) {
Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId);
if (tile == null) {
- if (DEBUG) Log.d(TAG, "Requested to store null tile");
+ if (DEBUG) Log.w(TAG, "Requested to store null tile");
return options;
}
options.putParcelable(OPTIONS_PEOPLE_TILE, tile);
diff --git a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java
index f11c1bdc6bfb..64a6509ea0aa 100644
--- a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java
+++ b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java
@@ -236,7 +236,7 @@ public class PeopleSpaceWidgetManager {
@Nullable
public PeopleSpaceTile getTileFromPersistentStorage(PeopleTileKey key) {
if (!key.isValid()) {
- Log.e(TAG, "PeopleTileKey invalid: " + key);
+ Log.e(TAG, "PeopleTileKey invalid: " + key.toString());
return null;
}
@@ -267,7 +267,14 @@ public class PeopleSpaceWidgetManager {
*/
public void updateWidgetsWithNotificationChanged(StatusBarNotification sbn,
PeopleSpaceUtils.NotificationAction notificationAction) {
- if (DEBUG) Log.d(TAG, "updateWidgetsWithNotificationChanged called");
+ if (DEBUG) {
+ Log.d(TAG, "updateWidgetsWithNotificationChanged called");
+ if (notificationAction == PeopleSpaceUtils.NotificationAction.POSTED) {
+ Log.d(TAG, "Notification posted, key: " + sbn.getKey());
+ } else {
+ Log.d(TAG, "Notification removed, key: " + sbn.getKey());
+ }
+ }
if (mIsForTesting) {
updateWidgetsWithNotificationChangedInBackground(sbn, notificationAction);
return;
@@ -282,7 +289,7 @@ public class PeopleSpaceWidgetManager {
PeopleTileKey key = new PeopleTileKey(
sbn.getShortcutId(), sbn.getUser().getIdentifier(), sbn.getPackageName());
if (!key.isValid()) {
- Log.d(TAG, "Invalid key from sbn");
+ Log.d(TAG, "Sbn doesn't contain valid PeopleTileKey: " + key.toString());
return;
}
int[] widgetIds = mAppWidgetManager.getAppWidgetIds(
@@ -309,8 +316,12 @@ public class PeopleSpaceWidgetManager {
/** Updates {@code widgetIdsToUpdate} with {@code action}. */
private void updateWidgetIdsBasedOnNotifications(Set<String> widgetIdsToUpdate) {
- Log.d(TAG, "Fetching grouped notifications");
+ if (widgetIdsToUpdate.isEmpty()) {
+ if (DEBUG) Log.d(TAG, "No widgets to update, returning.");
+ return;
+ }
try {
+ if (DEBUG) Log.d(TAG, "Fetching grouped notifications");
Map<PeopleTileKey, Set<NotificationEntry>> groupedNotifications =
getGroupedConversationNotifications();
@@ -331,14 +342,15 @@ public class PeopleSpaceWidgetManager {
* Augments {@code tile} based on notifications returned from {@code notificationEntryManager}.
*/
public PeopleSpaceTile augmentTileFromNotificationEntryManager(PeopleSpaceTile tile) {
- Log.d(TAG, "Augmenting tile from NotificationEntryManager widget: " + tile.getId());
+ PeopleTileKey key = new PeopleTileKey(tile);
+ Log.d(TAG, "Augmenting tile from NotificationEntryManager widget: " + key.toString());
Map<PeopleTileKey, Set<NotificationEntry>> notifications =
getGroupedConversationNotifications();
String contactUri = null;
if (tile.getContactUri() != null) {
contactUri = tile.getContactUri().toString();
}
- return augmentTileFromNotifications(tile, contactUri, notifications);
+ return augmentTileFromNotifications(tile, key, contactUri, notifications);
}
/** Returns active and pending notifications grouped by {@link PeopleTileKey}. */
@@ -367,9 +379,9 @@ public class PeopleSpaceWidgetManager {
}
/** Augments {@code tile} based on {@code notifications}, matching {@code contactUri}. */
- public PeopleSpaceTile augmentTileFromNotifications(PeopleSpaceTile tile, String contactUri,
- Map<PeopleTileKey, Set<NotificationEntry>> notifications) {
- if (DEBUG) Log.d(TAG, "Augmenting tile from notifications. Tile id: " + tile.getId());
+ public PeopleSpaceTile augmentTileFromNotifications(PeopleSpaceTile tile, PeopleTileKey key,
+ String contactUri, Map<PeopleTileKey, Set<NotificationEntry>> notifications) {
+ if (DEBUG) Log.d(TAG, "Augmenting tile from notifications. Tile key: " + key.toString());
boolean hasReadContactsPermission = mPackageManager.checkPermission(READ_CONTACTS,
tile.getPackageName()) == PackageManager.PERMISSION_GRANTED;
@@ -384,13 +396,12 @@ public class PeopleSpaceWidgetManager {
}
}
- PeopleTileKey key = new PeopleTileKey(tile);
Set<NotificationEntry> allNotifications = notifications.get(key);
if (allNotifications == null) {
allNotifications = new HashSet<>();
}
if (allNotifications.isEmpty() && notificationsByUri.isEmpty()) {
- if (DEBUG) Log.d(TAG, "No existing notifications for tile: " + key);
+ if (DEBUG) Log.d(TAG, "No existing notifications for tile: " + key.toString());
return removeNotificationFields(tile);
}
@@ -402,22 +413,28 @@ public class PeopleSpaceWidgetManager {
NotificationEntry highestPriority = getHighestPriorityNotification(allNotifications);
if (DEBUG) Log.d(TAG, "Augmenting tile from notification, key: " + key.toString());
- return augmentTileFromNotification(mContext, tile, highestPriority, messagesCount);
+ return augmentTileFromNotification(mContext, tile, key, highestPriority, messagesCount);
}
/** Returns an augmented tile for an existing widget. */
@Nullable
public Optional<PeopleSpaceTile> getAugmentedTileForExistingWidget(int widgetId,
Map<PeopleTileKey, Set<NotificationEntry>> notifications) {
- Log.d(TAG, "Augmenting tile for widget: " + widgetId);
+ Log.d(TAG, "Augmenting tile for existing widget: " + widgetId);
PeopleSpaceTile tile = getTileForExistingWidget(widgetId);
if (tile == null) {
+ if (DEBUG) {
+ Log.w(TAG, "Widget: " + widgetId
+ + ". Null tile for existing widget, skipping update.");
+ }
return Optional.empty();
}
String contactUriString = mSharedPrefs.getString(String.valueOf(widgetId), null);
// Should never be null, but using ofNullable for extra safety.
+ PeopleTileKey key = new PeopleTileKey(tile);
+ if (DEBUG) Log.d(TAG, "Existing widget: " + widgetId + ". Tile key: " + key.toString());
return Optional.ofNullable(
- augmentTileFromNotifications(tile, contactUriString, notifications));
+ augmentTileFromNotifications(tile, key, contactUriString, notifications));
}
/** Returns stored widgets for the conversation specified. */
@@ -644,12 +661,12 @@ public class PeopleSpaceWidgetManager {
}
synchronized (mLock) {
- if (DEBUG) Log.d(TAG, "Add storage for : " + tile.getId());
+ if (DEBUG) Log.d(TAG, "Add storage for : " + key.toString());
PeopleSpaceUtils.setSharedPreferencesStorageForTile(mContext, key, appWidgetId,
tile.getContactUri());
}
try {
- if (DEBUG) Log.d(TAG, "Caching shortcut for PeopleTile: " + tile.getId());
+ if (DEBUG) Log.d(TAG, "Caching shortcut for PeopleTile: " + key.toString());
mLauncherApps.cacheShortcuts(tile.getPackageName(),
Collections.singletonList(tile.getId()),
tile.getUserHandle(), LauncherApps.FLAG_CACHE_PEOPLE_TILE_SHORTCUTS);
@@ -679,7 +696,7 @@ public class PeopleSpaceWidgetManager {
if (DEBUG) Log.d(TAG, "Already registered listener");
return;
}
- if (DEBUG) Log.d(TAG, "Register listener for " + widgetId + " with " + key);
+ if (DEBUG) Log.d(TAG, "Register listener for " + widgetId + " with " + key.toString());
mListeners.put(key, newListener);
}
mPeopleManager.registerConversationListener(key.getPackageName(),
@@ -750,7 +767,9 @@ public class PeopleSpaceWidgetManager {
if (DEBUG) Log.d(TAG, "Cannot find listener to unregister");
return;
}
- if (DEBUG) Log.d(TAG, "Unregister listener for " + appWidgetId + " with " + key);
+ if (DEBUG) {
+ Log.d(TAG, "Unregister listener for " + appWidgetId + " with " + key.toString());
+ }
mListeners.remove(key);
}
mPeopleManager.unregisterConversationListener(registeredListener);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java
index c929073d9a09..42cc869d24b8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java
@@ -59,6 +59,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.appwidget.IAppWidgetService;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.people.widget.PeopleTileKey;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -94,6 +95,7 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase {
private static final Uri URI = Uri.parse("fake_uri");
private static final Icon ICON = Icon.createWithResource("package", R.drawable.ic_android);
private static final String NAME = "username";
+ private static final UserHandle USER = new UserHandle(0);
private static final Person PERSON = new Person.Builder()
.setName("name")
.setKey("abc")
@@ -103,6 +105,7 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase {
private static final PeopleSpaceTile PERSON_TILE =
new PeopleSpaceTile
.Builder(SHORTCUT_ID_1, NAME, ICON, new Intent())
+ .setUserHandle(USER)
.setLastInteractionTimestamp(123L)
.setNotificationKey(NOTIFICATION_KEY)
.setNotificationContent(NOTIFICATION_CONTENT)
@@ -231,8 +234,9 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase {
.setPackageName(PACKAGE_NAME)
.setUserHandle(new UserHandle(0))
.build();
+ PeopleTileKey key = new PeopleTileKey(tile);
PeopleSpaceTile actual = PeopleSpaceUtils
- .augmentTileFromNotification(mContext, tile, mNotificationEntry1, 0);
+ .augmentTileFromNotification(mContext, tile, key, mNotificationEntry1, 0);
assertThat(actual.getNotificationContent().toString()).isEqualTo(NOTIFICATION_TEXT_2);
}
@@ -245,8 +249,9 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase {
.setPackageName(PACKAGE_NAME)
.setUserHandle(new UserHandle(0))
.build();
+ PeopleTileKey key = new PeopleTileKey(tile);
PeopleSpaceTile actual = PeopleSpaceUtils
- .augmentTileFromNotification(mContext, tile, mNotificationEntry3, 0);
+ .augmentTileFromNotification(mContext, tile, key, mNotificationEntry3, 0);
assertThat(actual.getNotificationContent()).isEqualTo(null);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java
index 3cc55f2f9070..d9ceab836cb9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java
@@ -42,6 +42,7 @@ import android.content.res.Resources;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Bundle;
+import android.os.UserHandle;
import android.testing.AndroidTestingRunner;
import android.util.DisplayMetrics;
import android.view.View;
@@ -73,10 +74,12 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
private static final String GAME_DESCRIPTION = "Playing a game!";
private static final CharSequence MISSED_CALL = "Custom missed call message";
private static final String NAME = "username";
+ private static final UserHandle USER = new UserHandle(0);
private static final PeopleSpaceTile PERSON_TILE_WITHOUT_NOTIFICATION =
new PeopleSpaceTile
.Builder(SHORTCUT_ID_1, NAME, ICON, new Intent())
.setLastInteractionTimestamp(0L)
+ .setUserHandle(USER)
.build();
private static final PeopleSpaceTile PERSON_TILE =
new PeopleSpaceTile
@@ -85,6 +88,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
.setNotificationKey(NOTIFICATION_KEY)
.setNotificationContent(NOTIFICATION_CONTENT)
.setNotificationDataUri(URI)
+ .setUserHandle(USER)
.build();
private static final ConversationStatus GAME_STATUS =
new ConversationStatus
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java
index 725e5d4523a7..411fb02ba87a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java
@@ -1201,7 +1201,8 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase {
.setPackageName(TEST_PACKAGE_A)
.setUserHandle(new UserHandle(0))
.build();
- PeopleSpaceTile actual = mManager.augmentTileFromNotifications(tile, EMPTY_STRING,
+ PeopleTileKey key = new PeopleTileKey(tile);
+ PeopleSpaceTile actual = mManager.augmentTileFromNotifications(tile, key, EMPTY_STRING,
Map.of(new PeopleTileKey(mNotificationEntry),
new HashSet<>(Collections.singleton(mNotificationEntry))));
@@ -1216,8 +1217,9 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase {
.setPackageName(TEST_PACKAGE_A)
.setUserHandle(new UserHandle(0))
.build();
+ PeopleTileKey key = new PeopleTileKey(tile);
PeopleSpaceTile actual = mManager
- .augmentTileFromNotifications(tile, EMPTY_STRING,
+ .augmentTileFromNotifications(tile, key, EMPTY_STRING,
Map.of(new PeopleTileKey(mNotificationEntry),
new HashSet<>(Collections.singleton(mNotificationEntry))));