OSDN Git Service

Support dnd condition in Settings
authorJason Monk <jmonk@google.com>
Sun, 13 Dec 2015 21:22:37 +0000 (16:22 -0500)
committerJason Monk <jmonk@google.com>
Sun, 13 Dec 2015 21:22:37 +0000 (16:22 -0500)
 - Add way to open QS detail panels directly
 - Add internal broadcast that can launch apps when dnd mode changes

Change-Id: If2b6350dc31623f3bf2f64c7eb141cff5d3d4e89

core/java/android/app/NotificationManager.java
core/java/android/app/StatusBarManager.java
core/java/com/android/internal/statusbar/IStatusBar.aidl
core/java/com/android/internal/statusbar/IStatusBarService.aidl
packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
services/core/java/com/android/server/notification/NotificationManagerService.java
services/core/java/com/android/server/notification/ZenModeHelper.java
services/core/java/com/android/server/statusbar/StatusBarManagerService.java

index 89610e9..85d9831 100644 (file)
@@ -128,6 +128,14 @@ public class NotificationManager
             = "android.app.action.INTERRUPTION_FILTER_CHANGED";
 
     /**
+     * Intent that is broadcast when the state of getCurrentInterruptionFilter() changes.
+     * @hide
+     */
+    @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
+    public static final String ACTION_INTERRUPTION_FILTER_CHANGED_INTERNAL
+            = "android.app.action.INTERRUPTION_FILTER_CHANGED_INTERNAL";
+
+    /**
      * {@link #getCurrentInterruptionFilter() Interruption filter} constant -
      *     Normal interruption filter.
      */
index 5e8ad68..b899116 100644 (file)
@@ -180,10 +180,17 @@ public class StatusBarManager {
      * Expand the settings panel.
      */
     public void expandSettingsPanel() {
+        expandSettingsPanel(null);
+    }
+
+    /**
+     * Expand the settings panel and open a subPanel, pass null to just open the settings panel.
+     */
+    public void expandSettingsPanel(String subPanel) {
         try {
             final IStatusBarService svc = getService();
             if (svc != null) {
-                svc.expandSettingsPanel();
+                svc.expandSettingsPanel(subPanel);
             }
         } catch (RemoteException ex) {
             // system process is dead anyway.
index 11ef18b..849d314 100644 (file)
@@ -28,7 +28,7 @@ oneway interface IStatusBar
     void removeIcon(int index);
     void disable(int state1, int state2);
     void animateExpandNotificationsPanel();
-    void animateExpandSettingsPanel();
+    void animateExpandSettingsPanel(String subPanel);
     void animateCollapsePanels();
     void setSystemUiVisibility(int vis, int mask);
     void topAppWindowChanged(boolean menuVisible);
index 6c957be..0a4ad06 100644 (file)
@@ -39,7 +39,7 @@ interface IStatusBarService
     void topAppWindowChanged(boolean menuVisible);
     void setImeWindowStatus(in IBinder token, int vis, int backDisposition,
             boolean showImeSwitcher);
-    void expandSettingsPanel();
+    void expandSettingsPanel(String subPanel);
     void setCurrentUser(int newUserId);
 
     // ---- Methods below are for use by the status bar policy services ----
index ae8542a..16fd9eb 100644 (file)
@@ -154,6 +154,20 @@ public class QSPanel extends FrameLayout implements Tunable {
         }
     }
 
+    public void openDetails(String subPanel) {
+        QSTile<?> tile = getTile(subPanel);
+        showDetailAdapter(true, tile.getDetailAdapter(), new int[] {getWidth() / 2, 0});
+    }
+
+    private QSTile<?> getTile(String subPanel) {
+        for (int i = 0; i < mRecords.size(); i++) {
+            if (subPanel.equals(mRecords.get(i).tile.getTileSpec())) {
+                return mRecords.get(i).tile;
+            }
+        }
+        return mHost.createTile(subPanel);
+    }
+
     protected void createCustomizePanel() {
         mCustomizePanel = (QSCustomizer) LayoutInflater.from(mContext)
                 .inflate(R.layout.qs_customize_panel, null);
index 10d4a96..deedae0 100644 (file)
@@ -91,7 +91,7 @@ public class CommandQueue extends IStatusBar.Stub {
         public void disable(int state1, int state2, boolean animate);
         public void animateExpandNotificationsPanel();
         public void animateCollapsePanels(int flags);
-        public void animateExpandSettingsPanel();
+        public void animateExpandSettingsPanel(String obj);
         public void setSystemUiVisibility(int vis, int mask);
         public void topAppWindowChanged(boolean visible);
         public void setImeWindowStatus(IBinder token, int vis, int backDisposition,
@@ -157,10 +157,10 @@ public class CommandQueue extends IStatusBar.Stub {
         }
     }
 
-    public void animateExpandSettingsPanel() {
+    public void animateExpandSettingsPanel(String subPanel) {
         synchronized (mList) {
             mHandler.removeMessages(MSG_EXPAND_SETTINGS);
-            mHandler.sendEmptyMessage(MSG_EXPAND_SETTINGS);
+            mHandler.obtainMessage(MSG_EXPAND_SETTINGS, subPanel).sendToTarget();
         }
     }
 
@@ -353,7 +353,7 @@ public class CommandQueue extends IStatusBar.Stub {
                     mCallbacks.animateCollapsePanels(0);
                     break;
                 case MSG_EXPAND_SETTINGS:
-                    mCallbacks.animateExpandSettingsPanel();
+                    mCallbacks.animateExpandSettingsPanel((String) msg.obj);
                     break;
                 case MSG_SET_SYSTEMUI_VISIBILITY:
                     mCallbacks.setSystemUiVisibility(msg.arg1, msg.arg2);
index 76b8223..8f7c95e 100644 (file)
@@ -2162,7 +2162,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                     animateExpandNotificationsPanel();
                     break;
                 case MSG_OPEN_SETTINGS_PANEL:
-                    animateExpandSettingsPanel();
+                    animateExpandSettingsPanel((String) m.obj);
                     break;
                 case MSG_CLOSE_PANELS:
                     animateCollapsePanels();
@@ -2305,7 +2305,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
     }
 
     @Override
-    public void animateExpandSettingsPanel() {
+    public void animateExpandSettingsPanel(String subPanel) {
         if (SPEW) Log.d(TAG, "animateExpand: mExpandedVisible=" + mExpandedVisible);
         if (!panelsEnabled()) {
             return;
@@ -2314,6 +2314,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
         // Settings are not available in setup
         if (!mUserSetup) return;
 
+
+        if (subPanel != null) {
+            mQSPanel.openDetails(subPanel);
+        }
         mNotificationPanel.expandWithQs();
 
         if (false) postStartTracing();
index 856a774..44b41c5 100644 (file)
@@ -135,7 +135,7 @@ public class TvStatusBar extends BaseStatusBar {
     }
 
     @Override
-    public void animateExpandSettingsPanel() {
+    public void animateExpandSettingsPanel(String subPanel) {
     }
 
     @Override
index 07343a9..1464ea4 100644 (file)
@@ -880,6 +880,9 @@ public class NotificationManagerService extends SystemService {
             @Override
             void onZenModeChanged() {
                 sendRegisteredOnlyBroadcast(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED);
+                getContext().sendBroadcastAsUser(
+                        new Intent(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED_INTERNAL),
+                        UserHandle.ALL, android.Manifest.permission.MANAGE_NOTIFICATIONS);
                 synchronized(mNotificationList) {
                     updateInterruptionFilterLocked();
                 }
index 3c891df..6030bab 100644 (file)
@@ -564,6 +564,7 @@ public class ZenModeHelper {
 
     private boolean evaluateZenMode(String reason, boolean setRingerMode) {
         if (DEBUG) Log.d(TAG, "evaluateZenMode");
+        final int zenBefore = mZenMode;
         final int zen = computeZenMode();
         ZenLog.traceSetZenMode(zen, reason);
         mZenMode = zen;
@@ -573,7 +574,7 @@ public class ZenModeHelper {
             applyZenToRingerMode();
         }
         applyRestrictions();
-        if (zen != mZenMode) {
+        if (zen != zenBefore) {
             mHandler.postDispatchOnZenModeChanged();
         }
         return true;
index 19b03d5..fc27170 100644 (file)
@@ -216,12 +216,12 @@ public class StatusBarManagerService extends IStatusBarService.Stub {
     }
 
     @Override
-    public void expandSettingsPanel() {
+    public void expandSettingsPanel(String subPanel) {
         enforceExpandStatusBar();
 
         if (mBar != null) {
             try {
-                mBar.animateExpandSettingsPanel();
+                mBar.animateExpandSettingsPanel(subPanel);
             } catch (RemoteException ex) {
             }
         }