Merge "Fix notification count showing on 1x1" into sc-dev
diff --git a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java
index 5f6d95f..0fbe1f7 100644
--- a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java
+++ b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java
@@ -319,6 +319,7 @@
         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);
 
         return tile
                 .toBuilder()
diff --git a/packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java b/packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java
index 96fbe69..3bc91bc 100644
--- a/packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java
@@ -391,6 +391,7 @@
             statusText = getStatusTextByType(status.getActivity());
         }
         views.setViewVisibility(R.id.predefined_icon, View.VISIBLE);
+        views.setViewVisibility(R.id.messages_count, View.GONE);
         setMaxLines(views);
         // Secondary text color for statuses.
         TypedValue typedValue = new TypedValue();
@@ -530,6 +531,7 @@
         if (mLayoutSize == LAYOUT_SMALL) {
             views.setViewVisibility(R.id.predefined_icon, View.VISIBLE);
             views.setViewVisibility(R.id.name, View.GONE);
+            views.setViewVisibility(R.id.messages_count, View.GONE);
         } else {
             views.setViewVisibility(R.id.predefined_icon, View.GONE);
             views.setViewVisibility(R.id.name, View.VISIBLE);
@@ -544,6 +546,7 @@
         if (mLayoutSize == LAYOUT_SMALL) {
             views.setViewVisibility(R.id.name, View.VISIBLE);
             views.setViewVisibility(R.id.predefined_icon, View.GONE);
+            views.setViewVisibility(R.id.messages_count, View.GONE);
         }
         String status = PeopleSpaceUtils.getLastInteractionString(mContext,
                 mTile.getLastInteractionTimestamp());
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 5be2d4a..117be47 100644
--- a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java
+++ b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java
@@ -285,7 +285,7 @@
                 updateTilesByUri(key, sbn, action);
             }
         } catch (Exception e) {
-            Log.e(TAG, "Exception: " + e);
+            Log.e(TAG, "Throwing exception: " + e);
         }
     }
 
@@ -498,7 +498,7 @@
         if (notificationAction == PeopleSpaceUtils.NotificationAction.POSTED) {
             if (DEBUG) Log.i(TAG, "Adding notification to storage, appWidgetId: " + appWidgetId);
             storedTile = augmentTileFromNotification(mContext, storedTile, sbn);
-        } else if (storedTile.getNotificationKey().equals(sbn.getKey())) {
+        } else if (Objects.equals(storedTile.getNotificationKey(), sbn.getKey())) {
             if (DEBUG) {
                 Log.i(TAG, "Removing notification from storage, appWidgetId: " + appWidgetId);
             }
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 8db0f33..107ac83 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java
@@ -162,6 +162,9 @@
         assertEquals(View.GONE, smallResult.findViewById(R.id.predefined_icon).getVisibility());
         // Shows person icon.
         assertEquals(View.VISIBLE, smallResult.findViewById(R.id.person_icon).getVisibility());
+        // No messages count.
+        assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
+
 
         mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
                 getSizeInDp(R.dimen.required_width_for_large));
@@ -220,6 +223,8 @@
         // Has person icon.
         assertEquals(View.VISIBLE,
                 smallResult.findViewById(R.id.person_icon).getVisibility());
+        // No messages count.
+        assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
 
         mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
                 getSizeInDp(R.dimen.required_width_for_large));
@@ -281,6 +286,8 @@
         // Has person icon.
         assertEquals(View.VISIBLE,
                 smallResult.findViewById(R.id.person_icon).getVisibility());
+        // No messages count.
+        assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
 
         mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
                 getSizeInDp(R.dimen.required_width_for_large));
@@ -342,6 +349,8 @@
         // Has person icon.
         assertEquals(View.VISIBLE,
                 smallResult.findViewById(R.id.person_icon).getVisibility());
+        // No messages count.
+        assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
 
         mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
                 getSizeInDp(R.dimen.required_width_for_large));
@@ -404,6 +413,8 @@
                 smallResult.findViewById(R.id.predefined_icon).getVisibility());
         // Has person icon.
         assertEquals(View.VISIBLE, smallResult.findViewById(R.id.person_icon).getVisibility());
+        // No messages count.
+        assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
 
         mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
                 getSizeInDp(R.dimen.required_width_for_large));
@@ -471,7 +482,7 @@
                 smallResult.findViewById(R.id.person_icon).getVisibility());
 
         // Has a single message, no count shown.
-        assertEquals(View.GONE, result.findViewById(R.id.messages_count).getVisibility());
+        assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
 
         mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
                 getSizeInDp(R.dimen.required_width_for_large));
@@ -497,7 +508,7 @@
         assertThat(statusContent.getMaxLines()).isEqualTo(3);
 
         // Has a single message, no count shown.
-        assertEquals(View.GONE, result.findViewById(R.id.messages_count).getVisibility());
+        assertEquals(View.GONE, largeResult.findViewById(R.id.messages_count).getVisibility());
 
     }
 
@@ -544,7 +555,7 @@
                 smallResult.findViewById(R.id.person_icon).getVisibility());
 
         // Has two messages, show count.
-        assertEquals(View.VISIBLE, result.findViewById(R.id.messages_count).getVisibility());
+        assertEquals(View.VISIBLE, smallResult.findViewById(R.id.messages_count).getVisibility());
 
         mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
                 getSizeInDp(R.dimen.required_width_for_large));
@@ -570,7 +581,7 @@
         assertThat(statusContent.getMaxLines()).isEqualTo(3);
 
         // Has two messages, show count.
-        assertEquals(View.VISIBLE, result.findViewById(R.id.messages_count).getVisibility());
+        assertEquals(View.VISIBLE, largeResult.findViewById(R.id.messages_count).getVisibility());
     }