Support dnd condition in Settings

- Add way to open QS detail panels directly
 - Add internal broadcast that can launch apps when dnd mode changes

Change-Id: If2b6350dc31623f3bf2f64c7eb141cff5d3d4e89
This commit is contained in:
Jason Monk
2015-12-13 16:22:37 -05:00
parent 1d0062e183
commit a9927325ed
11 changed files with 50 additions and 13 deletions

View File

@@ -127,6 +127,14 @@ public class NotificationManager
public static final String ACTION_INTERRUPTION_FILTER_CHANGED
= "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.

View 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.

View 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);

View 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 ----

View 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);

View 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);

View 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();

View File

@@ -135,7 +135,7 @@ public class TvStatusBar extends BaseStatusBar {
}
@Override
public void animateExpandSettingsPanel() {
public void animateExpandSettingsPanel(String subPanel) {
}
@Override

View 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();
}

View 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;

View 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) {
}
}