frameworks/base
Revisión | c0fbdf45d7c9826533186751a03c27e500cac78e (tree) |
---|---|
Tiempo | 2019-08-14 09:23:26 |
Autor | android-build-team Robot <android-build-team-robot@goog...> |
Commiter | android-build-team Robot |
Merge cherrypicks of [9193293, 9193352, 9193734, 9193641, 9192591, 9193630] into qt-release
Change-Id: I34f06d8277b5d051cbe3f67a8c8512dbbe297a39
@@ -50,6 +50,7 @@ import android.view.InputDevice; | ||
50 | 50 | import android.view.KeyCharacterMap; |
51 | 51 | import android.view.KeyEvent; |
52 | 52 | import android.view.MotionEvent; |
53 | +import android.view.SurfaceControl; | |
53 | 54 | import android.view.ViewConfiguration; |
54 | 55 | import android.view.Window; |
55 | 56 | import android.view.WindowManagerGlobal; |
@@ -528,6 +529,12 @@ public class Instrumentation { | ||
528 | 529 | } while (mWaitingActivities.contains(aw)); |
529 | 530 | |
530 | 531 | waitForEnterAnimationComplete(aw.activity); |
532 | + | |
533 | + // Apply an empty transaction to ensure SF has a chance to update before | |
534 | + // the Activity is ready (b/138263890). | |
535 | + try (SurfaceControl.Transaction t = new SurfaceControl.Transaction()) { | |
536 | + t.apply(true); | |
537 | + } | |
531 | 538 | return aw.activity; |
532 | 539 | } |
533 | 540 | } |
@@ -422,7 +422,14 @@ public class NotificationData { | ||
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | - Collections.sort(mSortedAndFiltered, mRankingComparator); | |
425 | + if (mSortedAndFiltered.size() == 1) { | |
426 | + // HACK: We need the comparator to run on all children in order to set the | |
427 | + // isHighPriority field. If there is only one child, then the comparison won't be run, | |
428 | + // so we have to trigger it manually. Get rid of this code as soon as possible. | |
429 | + mRankingComparator.compare(mSortedAndFiltered.get(0), mSortedAndFiltered.get(0)); | |
430 | + } else { | |
431 | + Collections.sort(mSortedAndFiltered, mRankingComparator); | |
432 | + } | |
426 | 433 | } |
427 | 434 | |
428 | 435 | public void dump(PrintWriter pw, String indent) { |
@@ -23,6 +23,7 @@ import static android.app.Notification.CATEGORY_CALL; | ||
23 | 23 | import static android.app.Notification.CATEGORY_EVENT; |
24 | 24 | import static android.app.Notification.CATEGORY_MESSAGE; |
25 | 25 | import static android.app.Notification.CATEGORY_REMINDER; |
26 | +import static android.app.NotificationManager.IMPORTANCE_DEFAULT; | |
26 | 27 | import static android.app.NotificationManager.IMPORTANCE_LOW; |
27 | 28 | import static android.app.NotificationManager.IMPORTANCE_MIN; |
28 | 29 |
@@ -62,6 +63,8 @@ import android.testing.TestableLooper; | ||
62 | 63 | import android.testing.TestableLooper.RunWithLooper; |
63 | 64 | import android.util.ArraySet; |
64 | 65 | |
66 | +import androidx.test.filters.SmallTest; | |
67 | + | |
65 | 68 | import com.android.systemui.Dependency; |
66 | 69 | import com.android.systemui.ForegroundServiceController; |
67 | 70 | import com.android.systemui.InitController; |
@@ -84,8 +87,6 @@ import java.util.HashMap; | ||
84 | 87 | import java.util.List; |
85 | 88 | import java.util.Map; |
86 | 89 | |
87 | -import androidx.test.filters.SmallTest; | |
88 | - | |
89 | 90 | @SmallTest |
90 | 91 | @RunWith(AndroidTestingRunner.class) |
91 | 92 | @RunWithLooper |
@@ -113,6 +114,7 @@ public class NotificationDataTest extends SysuiTestCase { | ||
113 | 114 | MockitoAnnotations.initMocks(this); |
114 | 115 | when(mMockStatusBarNotification.getUid()).thenReturn(UID_NORMAL); |
115 | 116 | when(mMockStatusBarNotification.cloneLight()).thenReturn(mMockStatusBarNotification); |
117 | + when(mMockStatusBarNotification.getKey()).thenReturn("mock_key"); | |
116 | 118 | |
117 | 119 | when(mMockPackageManager.checkUidPermission( |
118 | 120 | eq(Manifest.permission.NOTIFICATION_DURING_SETUP), |
@@ -231,6 +233,7 @@ public class NotificationDataTest extends SysuiTestCase { | ||
231 | 233 | Notification n = mMockStatusBarNotification.getNotification(); |
232 | 234 | n.flags = Notification.FLAG_FOREGROUND_SERVICE; |
233 | 235 | NotificationEntry entry = new NotificationEntry(mMockStatusBarNotification); |
236 | + entry.setRow(mRow); | |
234 | 237 | mNotificationData.add(entry); |
235 | 238 | Bundle override = new Bundle(); |
236 | 239 | override.putInt(OVERRIDE_VIS_EFFECTS, 255); |
@@ -249,6 +252,7 @@ public class NotificationDataTest extends SysuiTestCase { | ||
249 | 252 | n = nb.build(); |
250 | 253 | when(mMockStatusBarNotification.getNotification()).thenReturn(n); |
251 | 254 | NotificationEntry entry = new NotificationEntry(mMockStatusBarNotification); |
255 | + entry.setRow(mRow); | |
252 | 256 | mNotificationData.add(entry); |
253 | 257 | Bundle override = new Bundle(); |
254 | 258 | override.putInt(OVERRIDE_VIS_EFFECTS, 255); |
@@ -262,6 +266,7 @@ public class NotificationDataTest extends SysuiTestCase { | ||
262 | 266 | public void testIsExemptFromDndVisualSuppression_system() { |
263 | 267 | initStatusBarNotification(false); |
264 | 268 | NotificationEntry entry = new NotificationEntry(mMockStatusBarNotification); |
269 | + entry.setRow(mRow); | |
265 | 270 | entry.mIsSystemNotification = true; |
266 | 271 | mNotificationData.add(entry); |
267 | 272 | Bundle override = new Bundle(); |
@@ -276,6 +281,7 @@ public class NotificationDataTest extends SysuiTestCase { | ||
276 | 281 | public void testIsNotExemptFromDndVisualSuppression_hiddenCategories() { |
277 | 282 | initStatusBarNotification(false); |
278 | 283 | NotificationEntry entry = new NotificationEntry(mMockStatusBarNotification); |
284 | + entry.setRow(mRow); | |
279 | 285 | entry.mIsSystemNotification = true; |
280 | 286 | Bundle override = new Bundle(); |
281 | 287 | override.putInt(OVERRIDE_VIS_EFFECTS, NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT); |
@@ -528,6 +534,62 @@ public class NotificationDataTest extends SysuiTestCase { | ||
528 | 534 | assertEquals(-1, mNotificationData.mRankingComparator.compare(a, b)); |
529 | 535 | } |
530 | 536 | |
537 | + @Test | |
538 | + public void testSort_properlySetsIsTopBucket() { | |
539 | + | |
540 | + Notification notification = new Notification.Builder(mContext, "test") | |
541 | + .build(); | |
542 | + StatusBarNotification sbn = new StatusBarNotification( | |
543 | + "pkg", | |
544 | + "pkg", | |
545 | + 0, | |
546 | + "tag", | |
547 | + 0, | |
548 | + 0, | |
549 | + notification, | |
550 | + mContext.getUser(), | |
551 | + "", | |
552 | + 0); | |
553 | + | |
554 | + Bundle override = new Bundle(); | |
555 | + override.putInt(OVERRIDE_IMPORTANCE, IMPORTANCE_DEFAULT); | |
556 | + mNotificationData.rankingOverrides.put(sbn.getKey(), override); | |
557 | + | |
558 | + NotificationEntry entry = new NotificationEntry(sbn); | |
559 | + entry.setRow(mRow); | |
560 | + mNotificationData.add(entry); | |
561 | + | |
562 | + assertTrue(entry.isTopBucket()); | |
563 | + } | |
564 | + | |
565 | + @Test | |
566 | + public void testSort_properlySetsIsNotTopBucket() { | |
567 | + Notification notification = new Notification.Builder(mContext, "test") | |
568 | + .build(); | |
569 | + StatusBarNotification sbn = new StatusBarNotification( | |
570 | + "pkg", | |
571 | + "pkg", | |
572 | + 0, | |
573 | + "tag", | |
574 | + 0, | |
575 | + 0, | |
576 | + notification, | |
577 | + mContext.getUser(), | |
578 | + "", | |
579 | + 0); | |
580 | + | |
581 | + Bundle override = new Bundle(); | |
582 | + override.putInt(OVERRIDE_IMPORTANCE, IMPORTANCE_LOW); | |
583 | + mNotificationData.rankingOverrides.put(sbn.getKey(), override); | |
584 | + | |
585 | + NotificationEntry entry = new NotificationEntry(sbn); | |
586 | + entry.setRow(mRow); | |
587 | + | |
588 | + mNotificationData.add(entry); | |
589 | + | |
590 | + assertFalse(entry.isTopBucket()); | |
591 | + } | |
592 | + | |
531 | 593 | private void initStatusBarNotification(boolean allowDuringSetup) { |
532 | 594 | Bundle bundle = new Bundle(); |
533 | 595 | bundle.putBoolean(Notification.EXTRA_ALLOW_DURING_SETUP, allowDuringSetup); |