Avoid race condition in heads up snooze code path.
The user can still snooze the heads up as its in the process of timing out. In this case, mHeadsUp is already null. We save the package name so that we can still snooze the package. Bug: 18639224 Change-Id: I9bcce99a5c912e70a6856b277b61adab9cdcbc33
This commit is contained in:
@@ -73,6 +73,7 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
|
||||
|
||||
private NotificationData.Entry mHeadsUp;
|
||||
private int mUser;
|
||||
private String mMostRecentPackageName;
|
||||
|
||||
public HeadsUpNotificationView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
@@ -117,6 +118,7 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
|
||||
}
|
||||
|
||||
if (mHeadsUp != null) {
|
||||
mMostRecentPackageName = mHeadsUp.notification.getPackageName();
|
||||
mHeadsUp.row.setSystemExpanded(true);
|
||||
mHeadsUp.row.setSensitive(false);
|
||||
mHeadsUp.row.setHeadsUp(true);
|
||||
@@ -198,8 +200,10 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
|
||||
}
|
||||
|
||||
private void snooze() {
|
||||
mSnoozedPackages.put(snoozeKey(mHeadsUp.notification.getPackageName(), mUser),
|
||||
SystemClock.elapsedRealtime() + mSnoozeLengthMs);
|
||||
if (mMostRecentPackageName != null) {
|
||||
mSnoozedPackages.put(snoozeKey(mMostRecentPackageName, mUser),
|
||||
SystemClock.elapsedRealtime() + mSnoozeLengthMs);
|
||||
}
|
||||
releaseAndClose();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user