From 6cb9e0f1f9b8b7902f3c451eb86db447af4a4ebf Mon Sep 17 00:00:00 2001 From: Christoph Studer Date: Tue, 24 Jun 2014 17:18:20 +0200 Subject: Remove suppression of ZEN'd notifications Bug: 15286335 Change-Id: I3114d7bcd8f05ca3a58f3598b95fdb507f6c646c --- packages/SystemUI/res/drawable/ic_notify_zen.xml | 28 ---- packages/SystemUI/res/values/strings.xml | 8 -- .../statusbar/InterceptedNotifications.java | 143 --------------------- .../systemui/statusbar/phone/PhoneStatusBar.java | 31 ----- 4 files changed, 210 deletions(-) delete mode 100644 packages/SystemUI/res/drawable/ic_notify_zen.xml delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java diff --git a/packages/SystemUI/res/drawable/ic_notify_zen.xml b/packages/SystemUI/res/drawable/ic_notify_zen.xml deleted file mode 100644 index c46455b3f7ae..000000000000 --- a/packages/SystemUI/res/drawable/ic_notify_zen.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index e5499eef19c2..f0212533d080 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -577,14 +577,6 @@ "Slide left for %s. - - - Notification hidden - %d notifications hidden - - - Touch to show - Do not disturb diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java b/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java deleted file mode 100644 index bba49a7f5d20..000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar; - -import android.app.Notification; -import android.content.Context; -import android.os.Process; -import android.provider.Settings; -import android.service.notification.NotificationListenerService.Ranking; -import android.service.notification.NotificationListenerService.RankingMap; -import android.service.notification.StatusBarNotification; -import android.util.ArrayMap; -import android.util.ArraySet; -import android.view.View; - -import com.android.systemui.R; -import com.android.systemui.statusbar.NotificationData.Entry; -import com.android.systemui.statusbar.phone.PhoneStatusBar; - -public class InterceptedNotifications { - private static final String TAG = "InterceptedNotifications"; - private static final String SYNTHETIC_KEY = "InterceptedNotifications.SYNTHETIC_KEY"; - - private final Context mContext; - private final PhoneStatusBar mBar; - private final ArrayMap mIntercepted - = new ArrayMap(); - private final ArraySet mReleased = new ArraySet(); - - private String mSynKey; - - public InterceptedNotifications(Context context, PhoneStatusBar bar) { - mContext = context; - mBar = bar; - } - - public void releaseIntercepted() { - final int n = mIntercepted.size(); - for (int i = 0; i < n; i++) { - final StatusBarNotification sbn = mIntercepted.valueAt(i); - mReleased.add(sbn.getKey()); - mBar.displayNotification(sbn, null); - } - mIntercepted.clear(); - updateSyntheticNotification(); - } - - public boolean tryIntercept(StatusBarNotification notification, RankingMap rankingMap) { - if (rankingMap == null) return false; - if (shouldDisplayIntercepted()) return false; - if (mReleased.contains(notification.getKey())) return false; - Ranking ranking = rankingMap.getRanking(notification.getKey()); - if (!ranking.isInterceptedByDoNotDisturb()) return false; - mIntercepted.put(notification.getKey(), notification); - updateSyntheticNotification(); - return true; - } - - public void retryIntercepts(RankingMap ranking) { - if (ranking == null) return; - - final int N = mIntercepted.size(); - final ArraySet removed = new ArraySet(N); - for (int i = 0; i < N; i++) { - final StatusBarNotification sbn = mIntercepted.valueAt(i); - if (!tryIntercept(sbn, ranking)) { - removed.add(sbn.getKey()); - mBar.displayNotification(sbn, ranking); - } - } - if (!removed.isEmpty()) { - mIntercepted.removeAll(removed); - updateSyntheticNotification(); - } - } - - public void remove(String key) { - if (mIntercepted.remove(key) != null) { - updateSyntheticNotification(); - } - mReleased.remove(key); - } - - public boolean isSyntheticEntry(Entry ent) { - return ent.key.equals(mSynKey); - } - - private boolean shouldDisplayIntercepted() { - return Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.DISPLAY_INTERCEPTED_NOTIFICATIONS, 0) != 0; - } - - private void updateSyntheticNotification() { - if (mIntercepted.isEmpty()) { - if (mSynKey != null) { - mBar.removeNotification(mSynKey, null); - mSynKey = null; - } - return; - } - final Notification n = new Notification.Builder(mContext) - .setSmallIcon(R.drawable.ic_notify_zen) - .setContentTitle(mContext.getResources().getQuantityString( - R.plurals.zen_mode_notification_title, - mIntercepted.size(), mIntercepted.size())) - .setContentText(mContext.getString(R.string.zen_mode_notification_text)) - .setOngoing(true) - .build(); - final StatusBarNotification sbn = new StatusBarNotification(mContext.getPackageName(), - mContext.getBasePackageName(), - TAG.hashCode(), TAG, Process.myUid(), Process.myPid(), 0, n, - mBar.getCurrentUserHandle()); - if (mSynKey == null) { - mSynKey = sbn.getKey(); - mBar.displayNotification(sbn, null); - } else { - mBar.updateNotification(sbn, null); - } - final NotificationData.Entry entry = mBar.mNotificationData.findByKey(mSynKey); - entry.row.setOnClickListener(mSynClickListener); - } - - private final View.OnClickListener mSynClickListener = new View.OnClickListener() { - @Override - public void onClick(View v) { - releaseIntercepted(); - } - }; -} 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 2c67aa9e100a..00951b28d130 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -110,7 +110,6 @@ import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.DragDownHelper; import com.android.systemui.statusbar.ExpandableNotificationRow; import com.android.systemui.statusbar.GestureRecorder; -import com.android.systemui.statusbar.InterceptedNotifications; import com.android.systemui.statusbar.KeyguardIndicationController; import com.android.systemui.statusbar.NotificationData; import com.android.systemui.statusbar.NotificationData.Entry; @@ -399,7 +398,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, }}; private Runnable mOnFlipRunnable; - private InterceptedNotifications mIntercepted; private VelocityTracker mSettingsTracker; private float mSettingsDownY; private boolean mSettingsStarted; @@ -509,19 +507,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } }; - @Override - public void setZenMode(int mode) { - super.setZenMode(mode); - if (!isDeviceProvisioned()) return; - final boolean zen = mode != Settings.Global.ZEN_MODE_OFF; - if (!zen) { - mIntercepted.releaseIntercepted(); - } - if (mIconPolicy != null) { - mIconPolicy.setZenMode(zen); - } - } - @Override protected void setShowLockscreenNotifications(boolean show) { super.setShowLockscreenNotifications(show); @@ -533,7 +518,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); updateDisplaySize(); - mIntercepted = new InterceptedNotifications(mContext, this); super.start(); // calls createAndAddWindows() addNavigationBar(); @@ -1074,16 +1058,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, @Override public void addNotification(StatusBarNotification notification, RankingMap ranking) { if (DEBUG) Log.d(TAG, "addNotification key=" + notification.getKey()); - if (mZenMode != Global.ZEN_MODE_OFF && mIntercepted.tryIntercept(notification, ranking)) { - // Forward the ranking so we can sort the new notification. - mNotificationData.updateRanking(ranking); - return; - } - mIntercepted.remove(notification.getKey()); - displayNotification(notification, ranking); - } - - public void displayNotification(StatusBarNotification notification, RankingMap ranking) { if (mUseHeadsUp && shouldInterrupt(notification)) { if (DEBUG) Log.d(TAG, "launching notification in heads up mode"); Entry interruptionCandidate = new Entry(notification, null); @@ -1167,7 +1141,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, @Override protected void updateNotificationRanking(RankingMap ranking) { mNotificationData.updateRanking(ranking); - mIntercepted.retryIntercepts(ranking); updateNotifications(); } @@ -1195,7 +1168,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, animateCollapsePanels(); } } - mIntercepted.remove(key); setAreThereNotifications(); } @@ -1351,9 +1323,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, // in "public" mode (atop a secure keyguard), secret notifs are totally hidden continue; } - if (mIntercepted.isSyntheticEntry(ent)) { - continue; - } toShow.add(ent.icon); } -- cgit v1.2.3-59-g8ed1b