From 29fa89b41e15ee61a1ec13307596fe5f5f4c376c Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Fri, 17 Apr 2015 10:39:11 -0700 Subject: [PATCH] Fixed a crash on android tv with the new heads-up manager Bug: 20282768 Change-Id: Ibb3dc879a2529c12f4d8ab6b031711363da93d37 --- .../systemui/statusbar/BaseStatusBar.java | 30 +++++-------------- .../statusbar/phone/PhoneStatusBar.java | 29 ++++++++++++++++++ .../systemui/statusbar/tv/TvStatusBar.java | 15 ++++++++-- 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 9f86475fd1265..de4874f31285a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -687,13 +687,7 @@ public abstract class BaseStatusBar extends SystemUI implements setHeadsUpUser(newUserId); } - private void setHeadsUpUser(int newUserId) { - mHeadsUpManager.setUser(newUserId); - } - - public boolean isHeadsUp(String key) { - return mHeadsUpManager.isHeadsUp(key); - } + protected abstract void setHeadsUpUser(int newUserId); @Override // NotificationData.Environment public boolean isNotificationForCurrentProfiles(StatusBarNotification n) { @@ -1578,7 +1572,7 @@ public abstract class BaseStatusBar extends SystemUI implements mCurrentUserId); dismissKeyguardThenExecute(new OnDismissAction() { public boolean onDismiss() { - if (mHeadsUpManager.isHeadsUp(mNotificationKey)) { + if (mHeadsUpManager != null && mHeadsUpManager.isHeadsUp(mNotificationKey)) { // Release the HUN notification to the shade. // // In most cases, when FLAG_AUTO_CANCEL is set, the notification will @@ -1941,20 +1935,8 @@ public abstract class BaseStatusBar extends SystemUI implements setAreThereNotifications(); } - private void updateHeadsUp(String key, Entry entry, boolean shouldInterrupt, - boolean alertAgain) { - final boolean wasHeadsUp = isHeadsUp(key); - if (wasHeadsUp) { - mHeadsUpManager.updateNotification(entry, alertAgain); - if (!shouldInterrupt) { - // We don't want this to be interrupting anymore, lets remove it - mHeadsUpManager.removeNotification(key); - } - } else if (shouldInterrupt && alertAgain) { - // This notification was updated to be a heads-up, show it! - mHeadsUpManager.showNotification(entry); - } - } + protected abstract void updateHeadsUp(String key, Entry entry, boolean shouldInterrupt, + boolean alertAgain); private void logUpdate(Entry oldEntry, Notification n) { StatusBarNotification oldNotification = oldEntry.notification; @@ -2075,7 +2057,7 @@ public abstract class BaseStatusBar extends SystemUI implements return false; } - if (mHeadsUpManager.isSnoozed(sbn.getPackageName())) { + if (isSnoozedPackage(sbn)) { return false; } @@ -2109,6 +2091,8 @@ public abstract class BaseStatusBar extends SystemUI implements return interrupt; } + protected abstract boolean isSnoozedPackage(StatusBarNotification sbn); + public void setInteracting(int barWindow, boolean interacting) { // hook for subclasses } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index a5dad923b7761..7f65f731a84ce 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -1867,6 +1867,35 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } + protected void updateHeadsUp(String key, Entry entry, boolean shouldInterrupt, + boolean alertAgain) { + final boolean wasHeadsUp = isHeadsUp(key); + if (wasHeadsUp) { + mHeadsUpManager.updateNotification(entry, alertAgain); + if (!shouldInterrupt) { + // We don't want this to be interrupting anymore, lets remove it + mHeadsUpManager.removeNotification(key); + } + } else if (shouldInterrupt && alertAgain) { + // This notification was updated to be a heads-up, show it! + mHeadsUpManager.showNotification(entry); + } + } + + protected void setHeadsUpUser(int newUserId) { + if (mHeadsUpManager != null) { + mHeadsUpManager.setUser(newUserId); + } + } + + public boolean isHeadsUp(String key) { + return mHeadsUpManager.isHeadsUp(key); + } + + protected boolean isSnoozedPackage(StatusBarNotification sbn) { + return mHeadsUpManager.isSnoozed(sbn.getPackageName()); + } + /** * All changes to the status bar and notifications funnel through here and are batched. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java index 78122d6be6640..dce695d67b436 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java @@ -20,8 +20,6 @@ import android.os.IBinder; import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.StatusBarNotification; import android.view.View; -import android.view.ViewGroup.LayoutParams; -import android.view.WindowManager; import com.android.internal.statusbar.StatusBarIcon; import com.android.systemui.statusbar.ActivatableNotificationView; @@ -166,4 +164,17 @@ public class TvStatusBar extends BaseStatusBar { @Override public void appTransitionStarting(long startTime, long duration) { } + + @Override + protected void updateHeadsUp(String key, NotificationData.Entry entry, boolean shouldInterrupt, + boolean alertAgain) { + } + + @Override + protected void setHeadsUpUser(int newUserId) { + } + + protected boolean isSnoozedPackage(StatusBarNotification sbn) { + return false; + } }