From 0ab7642f30aefd8e472304f5d379348bc6b5347d Mon Sep 17 00:00:00 2001 From: woongki min Date: Sat, 15 Jan 2022 13:15:07 +0900 Subject: [PATCH 1/2] Fix autogroupsummary bug Summary cannot be updated with key after notification is removed from NotificationsByKey. So OngoingFlag of Autogrounpsummary remains. Modify the GroupHelper interface to deliver summary updateable information. Test: Make autogroupsummary. Test: update one of notification with ongoing flag. Test: cancel the notification and check flag of autogroupsummary. Change-Id: I0d14daaa69a94c1a3fe81b12d16b44e3a78281fe Merged-In: I0d14daaa69a94c1a3fe81b12d16b44e3a78281fe --- .../android/server/notification/GroupHelper.java | 4 ++-- .../notification/NotificationManagerService.java | 12 ++---------- .../server/notification/GroupHelperTest.java | 14 +++++++------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/services/core/java/com/android/server/notification/GroupHelper.java b/services/core/java/com/android/server/notification/GroupHelper.java index 9cb8a01052864..4f2680904faee 100644 --- a/services/core/java/com/android/server/notification/GroupHelper.java +++ b/services/core/java/com/android/server/notification/GroupHelper.java @@ -82,7 +82,7 @@ public class GroupHelper { } String combinedKey = generatePackageGroupKey(userId, sbn.getPackageName(), group); boolean needsOngoingFlag = notifications.size() > 0; - mCallback.updateAutogroupSummary(sbn.getKey(), needsOngoingFlag); + mCallback.updateAutogroupSummary(userId, sbn.getPackageName(), needsOngoingFlag); } public void onNotificationUpdated(StatusBarNotification childSbn, @@ -211,6 +211,6 @@ public class GroupHelper { void removeAutoGroup(String key); void addAutoGroupSummary(int userId, String pkg, String triggeringKey); void removeAutoGroupSummary(int user, String pkg); - void updateAutogroupSummary(String key, boolean needsOngoingFlag); + void updateAutogroupSummary(int userId, String pkg, boolean needsOngoingFlag); } } diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 211f8d6e3ec78..d9f2e97829a15 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -2498,19 +2498,11 @@ public class NotificationManagerService extends SystemService { } @Override - public void updateAutogroupSummary(String key, boolean needsOngoingFlag) { - String pkg; - synchronized (mNotificationLock) { - NotificationRecord r = mNotificationsByKey.get(key); - pkg = r != null && r.getSbn() != null ? r.getSbn().getPackageName() : null; - } + public void updateAutogroupSummary(int userId, String pkg, boolean needsOngoingFlag) { boolean isAppForeground = pkg != null && mActivityManager.getPackageImportance(pkg) == IMPORTANCE_FOREGROUND; synchronized (mNotificationLock) { - NotificationRecord r = mNotificationsByKey.get(key); - if (r == null) return; - updateAutobundledSummaryFlags(r.getUser().getIdentifier(), - r.getSbn().getPackageName(), needsOngoingFlag, isAppForeground); + updateAutobundledSummaryFlags(userId, pkg, needsOngoingFlag, isAppForeground); } } }); diff --git a/services/tests/uiservicestests/src/com/android/server/notification/GroupHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/GroupHelperTest.java index 721641a7a8c84..5458a5b84eea3 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/GroupHelperTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/GroupHelperTest.java @@ -174,7 +174,7 @@ public class GroupHelperTest extends UiServiceTestCase { } verify(mCallback, times(AUTOGROUP_AT_COUNT + 1)) - .updateAutogroupSummary(anyString(), eq(true)); + .updateAutogroupSummary(anyInt(), anyString(), eq(true)); int userId = UserHandle.SYSTEM.getIdentifier(); assertEquals(mGroupHelper.getOngoingGroupCount( @@ -203,7 +203,7 @@ public class GroupHelperTest extends UiServiceTestCase { mGroupHelper.onNotificationUpdated(notifications.get(0), true); verify(mCallback, times(AUTOGROUP_AT_COUNT + 2)) - .updateAutogroupSummary(anyString(), eq(true)); + .updateAutogroupSummary(anyInt(), anyString(), eq(true)); int userId = UserHandle.SYSTEM.getIdentifier(); assertEquals(mGroupHelper.getOngoingGroupCount( @@ -236,7 +236,7 @@ public class GroupHelperTest extends UiServiceTestCase { mGroupHelper.onNotificationUpdated(notifications.get(0), true); verify(mCallback, times(AUTOGROUP_AT_COUNT + 3)) - .updateAutogroupSummary(anyString(), eq(true)); + .updateAutogroupSummary(anyInt(), anyString(), eq(true)); int userId = UserHandle.SYSTEM.getIdentifier(); assertEquals(mGroupHelper.getOngoingGroupCount( @@ -263,7 +263,7 @@ public class GroupHelperTest extends UiServiceTestCase { mGroupHelper.onNotificationRemoved(notifications.get(0)); verify(mCallback, times(AUTOGROUP_AT_COUNT + 2)) - .updateAutogroupSummary(anyString(), eq(true)); + .updateAutogroupSummary(anyInt(), anyString(), eq(true)); int userId = UserHandle.SYSTEM.getIdentifier(); assertEquals(mGroupHelper.getOngoingGroupCount( @@ -291,7 +291,7 @@ public class GroupHelperTest extends UiServiceTestCase { mGroupHelper.onNotificationUpdated(notifications.get(0), true); verify(mCallback, times(1)) - .updateAutogroupSummary(anyString(), eq(true)); + .updateAutogroupSummary(anyInt(), anyString(), eq(true)); int userId = UserHandle.SYSTEM.getIdentifier(); assertEquals(mGroupHelper.getOngoingGroupCount( @@ -315,7 +315,7 @@ public class GroupHelperTest extends UiServiceTestCase { } verify(mCallback, times(1)) - .updateAutogroupSummary(anyString(), eq(true)); + .updateAutogroupSummary(anyInt(), anyString(), eq(true)); int userId = UserHandle.SYSTEM.getIdentifier(); assertEquals(mGroupHelper.getOngoingGroupCount( @@ -339,7 +339,7 @@ public class GroupHelperTest extends UiServiceTestCase { } verify(mCallback, times(0)) - .updateAutogroupSummary(anyString(), eq(true)); + .updateAutogroupSummary(anyInt(), anyString(), eq(true)); int userId = UserHandle.SYSTEM.getIdentifier(); assertEquals(mGroupHelper.getOngoingGroupCount(userId, pkg, AUTOGROUP_KEY), 0); From 37d61f3b05ae58dd82b4f9a2eac9c979a814016a Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Tue, 12 Apr 2022 18:25:22 +0800 Subject: [PATCH 2/2] Execute transition by starting window only if visible requested Otherwise the activity may not have been added as opening app for transition, which causes the animation to be skipped. Such as if the previous activity doesn't need to pause or take long time to pause, then its visible-requested is still false. Bug: 161781889 Test: Cold launch Settings to freeform: adb shell am start -n "com.android.settings/.Settings " \ --windowingMode 5 There should be transition animation. Change-Id: If339b1e9e5f004087dcbf2be3c8ab7a9f5524c5b --- services/core/java/com/android/server/wm/ActivityRecord.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 2be9b34054d33..9ba53d8be4d4b 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -6298,7 +6298,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // starting window is drawn, the transition can start earlier. Exclude finishing and bubble // because it may be a trampoline. if (!wasTaskVisible && mStartingData != null && !finishing && !mLaunchedFromBubble - && !mDisplayContent.mAppTransition.isReady() + && mVisibleRequested && !mDisplayContent.mAppTransition.isReady() && !mDisplayContent.mAppTransition.isRunning() && mDisplayContent.isNextTransitionForward()) { // The pending transition state will be cleared after the transition is started, so