From 3623128d13839b48693245a64448fb2dabc1977f Mon Sep 17 00:00:00 2001 From: John Spurlock Date: Sat, 23 Jun 2012 17:11:27 -0400 Subject: [PATCH] TabletStatusBar: Hide notifications during Setup Wizard Protect tablet users going through the initial setup wizard from trapping themselves in Settings before the setup wizard is complete. A similar change was already made for phones, so use the same logic. Also hide quick-settings button (another way to get trapped in Settings) and associated panel click handler. Remove clear button since we're no longer showing notification items. Bug: 6704080 Change-Id: If7148cde9d18f493627f8367fd4b39d22e0d5ef1 --- .../android/systemui/statusbar/BaseStatusBar.java | 18 ++++++++++++++++++ .../systemui/statusbar/phone/PhoneStatusBar.java | 17 ----------------- .../systemui/statusbar/tablet/NotificationPanel.java | 11 +++++++++-- .../statusbar/tablet/NotificationPanelTitle.java | 8 +++++--- .../systemui/statusbar/tablet/TabletStatusBar.java | 20 ++++++++++++++------ 5 files changed, 46 insertions(+), 28 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index a3ec6c33da13..08016df81398 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -65,6 +65,7 @@ import com.android.systemui.recent.RecentsPanelView; import com.android.systemui.recent.RecentTasksLoader; import com.android.systemui.recent.TaskDescription; import com.android.systemui.statusbar.CommandQueue; +import com.android.systemui.statusbar.NotificationData.Entry; import com.android.systemui.statusbar.policy.NotificationRowLayout; import com.android.systemui.statusbar.tablet.StatusBarPanel; @@ -904,4 +905,21 @@ public abstract class BaseStatusBar extends SystemUI implements } } } + + // Q: What kinds of notifications should show during setup? + // A: Almost none! Only things coming from the system (package is "android") that also + // have special "kind" tags marking them as relevant for setup (see below). + protected boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) { + if ("android".equals(sbn.pkg)) { + if (sbn.notification.kind != null) { + for (String aKind : sbn.notification.kind) { + // IME switcher, created by InputMethodManagerService + if ("android.system.imeswitcher".equals(aKind)) return true; + // OTA availability & errors, created by SystemUpdateService + if ("android.system.update".equals(aKind)) return true; + } + } + } + return false; + } } 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 3c19ad227e03..eff6061c18a3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -821,23 +821,6 @@ public class PhoneStatusBar extends BaseStatusBar { R.integer.config_show_search_delay); } - // Q: What kinds of notifications should show during setup? - // A: Almost none! Only things coming from the system (package is "android") that also - // have special "kind" tags marking them as relevant for setup (see below). - private boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) { - if ("android".equals(sbn.pkg)) { - if (sbn.notification.kind != null) { - for (String aKind : sbn.notification.kind) { - // IME switcher, created by InputMethodManagerService - if ("android.system.imeswitcher".equals(aKind)) return true; - // OTA availability & errors, created by SystemUpdateService - if ("android.system.update".equals(aKind)) return true; - } - } - } - return false; - } - private void loadNotificationShade() { if (mPile == null) return; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java index af0f9d3496dc..fdbfb65b6fef 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java @@ -217,7 +217,7 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel, */ public void onClick(View v) { - if (v == mTitleArea) { + if (mSettingsButton.isEnabled() && v == mTitleArea) { swapPanels(); } } @@ -280,7 +280,7 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel, public void updatePanelModeButtons() { final boolean settingsVisible = (mSettingsView != null); - mSettingsButton.setVisibility(!settingsVisible ? View.VISIBLE : View.GONE); + mSettingsButton.setVisibility(!settingsVisible && mSettingsButton.isEnabled() ? View.VISIBLE : View.GONE); mNotificationButton.setVisibility(settingsVisible ? View.VISIBLE : View.GONE); } @@ -421,5 +421,12 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel, super.onTouchEvent(ev); return handled; } + + public void setSettingsEnabled(boolean settingsEnabled) { + if (mSettingsButton != null) { + mSettingsButton.setEnabled(settingsEnabled); + mSettingsButton.setVisibility(settingsEnabled ? View.VISIBLE : View.GONE); + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanelTitle.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanelTitle.java index 00cf3c54f4a7..d180ab9185ac 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanelTitle.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanelTitle.java @@ -32,7 +32,7 @@ import com.android.systemui.R; public class NotificationPanelTitle extends RelativeLayout implements View.OnClickListener { private NotificationPanel mPanel; private ArrayList buttons; - private View mNotificationsButton; + private View mSettingsButton; public NotificationPanelTitle(Context context, AttributeSet attrs) { super(context, attrs); @@ -47,7 +47,7 @@ public class NotificationPanelTitle extends RelativeLayout implements View.OnCli @Override public void onFinishInflate() { super.onFinishInflate(); - buttons.add(findViewById(R.id.settings_button)); + buttons.add(mSettingsButton = findViewById(R.id.settings_button)); buttons.add(findViewById(R.id.notification_button)); } @@ -63,6 +63,8 @@ public class NotificationPanelTitle extends RelativeLayout implements View.OnCli @Override public boolean onTouchEvent(MotionEvent e) { + if (!mSettingsButton.isEnabled()) + return false; switch (e.getAction()) { case MotionEvent.ACTION_DOWN: setPressed(true); @@ -88,7 +90,7 @@ public class NotificationPanelTitle extends RelativeLayout implements View.OnCli @Override public void onClick(View v) { - if (v == this) { + if (mSettingsButton.isEnabled() && v == this) { mPanel.swapPanels(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java index 9b46af893114..29d8c9807b39 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java @@ -1235,7 +1235,7 @@ public class TabletStatusBar extends BaseStatusBar implements @Override protected void setAreThereNotifications() { if (mNotificationPanel != null) { - mNotificationPanel.setClearable(mNotificationData.hasClearableItems()); + mNotificationPanel.setClearable(isDeviceProvisioned() && mNotificationData.hasClearableItems()); } } @@ -1533,10 +1533,13 @@ public class TabletStatusBar extends BaseStatusBar implements if (mInputMethodSwitchButton.getVisibility() != View.GONE) maxNotificationIconsCount --; if (mCompatModeButton.getVisibility() != View.GONE) maxNotificationIconsCount --; + final boolean provisioned = isDeviceProvisioned(); + // If the device hasn't been through Setup, we only show system notifications for (int i=0; toShow.size()< maxNotificationIconsCount; i++) { if (i >= N) break; Entry ent = mNotificationData.get(N-i-1); - if (ent.notification.score >= HIDE_ICONS_BELOW_SCORE) { + if ((provisioned && ent.notification.score >= HIDE_ICONS_BELOW_SCORE) + || showNotificationEvenIfUnprovisioned(ent.notification)) { toShow.add(ent.icon); } } @@ -1567,9 +1570,13 @@ public class TabletStatusBar extends BaseStatusBar implements ArrayList toShow = new ArrayList(); + final boolean provisioned = isDeviceProvisioned(); + // If the device hasn't been through Setup, we only show system notifications for (int i=0; i toRemove = new ArrayList(); @@ -1588,11 +1595,12 @@ public class TabletStatusBar extends BaseStatusBar implements View v = toShow.get(i); if (v.getParent() == null) { // the notification panel has the most important things at the bottom - mPile.addView(v, N-1-i); + mPile.addView(v, Math.min(toShow.size()-1-i, mPile.getChildCount())); } } - mNotificationPanel.setNotificationCount(N); + mNotificationPanel.setNotificationCount(toShow.size()); + mNotificationPanel.setSettingsEnabled(isDeviceProvisioned()); } @Override -- 2.11.0