Skip to content

Commit e20a177

Browse files
committed
Adding a global accessibility action to open quick settings.
1. Added APIs for opening the quick settings to the StatusBarManagerService and the local StatausBarManager. The new APIs are protected by the old EXPAND_STATUS_BAR permission. Renamed the expand* and collapse* non-public APIs that are expanding the notifications to expandNotifications* collapseNotifications* to better convey what they do given that this change adds expandQuickSettings* and collapseQuickSettings*. Added a global action to the accessibility layer to expand the quick settings which is calling into the new status bar manager APIs. bug:7030487 Change-Id: Ic7b46e1a132f1c0d71355f18e7c5a9a2424171c3
1 parent 1ab8a08 commit e20a177

File tree

18 files changed

+219
-140
lines changed

18 files changed

+219
-140
lines changed

api/current.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,6 +2066,7 @@ package android.accessibilityservice {
20662066
field public static final int GLOBAL_ACTION_BACK = 1; // 0x1
20672067
field public static final int GLOBAL_ACTION_HOME = 2; // 0x2
20682068
field public static final int GLOBAL_ACTION_NOTIFICATIONS = 4; // 0x4
2069+
field public static final int GLOBAL_ACTION_QUICK_SETTINGS = 5; // 0x5
20692070
field public static final int GLOBAL_ACTION_RECENTS = 3; // 0x3
20702071
field public static final java.lang.String SERVICE_INTERFACE = "android.accessibilityservice.AccessibilityService";
20712072
field public static final java.lang.String SERVICE_META_DATA = "android.accessibilityservice";

core/java/android/accessibilityservice/AccessibilityService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public abstract class AccessibilityService extends Service {
323323
public static final int GLOBAL_ACTION_HOME = 2;
324324

325325
/**
326-
* Action to open the recents.
326+
* Action to open the recent apps.
327327
*/
328328
public static final int GLOBAL_ACTION_RECENTS = 3;
329329

@@ -332,6 +332,11 @@ public abstract class AccessibilityService extends Service {
332332
*/
333333
public static final int GLOBAL_ACTION_NOTIFICATIONS = 4;
334334

335+
/**
336+
* Action to open the quick settings.
337+
*/
338+
public static final int GLOBAL_ACTION_QUICK_SETTINGS = 5;
339+
335340
private static final String LOG_TAG = "AccessibilityService";
336341

337342
interface Callbacks {

core/java/android/app/StatusBarManager.java

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ public void disable(int what) {
9797
}
9898

9999
/**
100-
* Expand the status bar.
100+
* Expand the notifications.
101101
*/
102-
public void expand() {
102+
public void expandNotifications() {
103103
try {
104104
final IStatusBarService svc = getService();
105105
if (svc != null) {
106-
svc.expand();
106+
svc.expandNotifications();
107107
}
108108
} catch (RemoteException ex) {
109109
// system process is dead anyway.
@@ -112,13 +112,43 @@ public void expand() {
112112
}
113113

114114
/**
115-
* Collapse the status bar.
115+
* Collapse the notifications.
116116
*/
117-
public void collapse() {
117+
public void collapseNotifications() {
118118
try {
119119
final IStatusBarService svc = getService();
120120
if (svc != null) {
121-
svc.collapse();
121+
svc.collapseNotifications();
122+
}
123+
} catch (RemoteException ex) {
124+
// system process is dead anyway.
125+
throw new RuntimeException(ex);
126+
}
127+
}
128+
129+
/**
130+
* Expand the quick settings.
131+
*/
132+
public void expandQuickSettings() {
133+
try {
134+
final IStatusBarService svc = getService();
135+
if (svc != null) {
136+
svc.expandQuickSettings();
137+
}
138+
} catch (RemoteException ex) {
139+
// system process is dead anyway.
140+
throw new RuntimeException(ex);
141+
}
142+
}
143+
144+
/**
145+
* Collapse the quick settings.
146+
*/
147+
public void collapseQuickSettings() {
148+
try {
149+
final IStatusBarService svc = getService();
150+
if (svc != null) {
151+
svc.collapseQuickSettings();
122152
}
123153
} catch (RemoteException ex) {
124154
// system process is dead anyway.

core/java/com/android/internal/statusbar/IStatusBar.aidl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ oneway interface IStatusBar
2828
void updateNotification(IBinder key, in StatusBarNotification notification);
2929
void removeNotification(IBinder key);
3030
void disable(int state);
31-
void animateExpand();
32-
void animateCollapse();
31+
void animateExpandNotifications();
32+
void animateCollapseNotifications();
33+
void animateExpandQuickSettings();
34+
void animateCollapseQuickSettings();
3335
void setSystemUiVisibility(int vis, int mask);
3436
void topAppWindowChanged(boolean menuVisible);
3537
void setImeWindowStatus(in IBinder token, int vis, int backDisposition);

core/java/com/android/internal/statusbar/IStatusBarService.aidl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ import com.android.internal.statusbar.StatusBarNotification;
2424
/** @hide */
2525
interface IStatusBarService
2626
{
27-
void expand();
28-
void collapse();
27+
void expandNotifications();
28+
void collapseNotifications();
29+
void expandQuickSettings();
30+
void collapseQuickSettings();
2931
void disable(int what, IBinder token, String pkg);
3032
void setIcon(String slot, String iconPackage, int iconId, int iconLevel, String contentDescription);
3133
void setIconVisibility(String slot, boolean visible);

packages/SystemUI/src/com/android/systemui/SearchPanelView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public SearchPanelView(Context context, AttributeSet attrs, int defStyle) {
7272

7373
private void startAssistActivity() {
7474
// Close Recent Apps if needed
75-
mBar.animateCollapse(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL);
75+
mBar.animateCollapseNotifications(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL);
7676
// Launch Assist
7777
Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
7878
.getAssistIntent(mContext, UserHandle.USER_CURRENT);
@@ -220,7 +220,7 @@ public void show(final boolean show, boolean animate) {
220220
public void hide(boolean animate) {
221221
if (mBar != null) {
222222
// This will indirectly cause show(false, ...) to get called
223-
mBar.animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
223+
mBar.animateCollapseNotifications(CommandQueue.FLAG_EXCLUDE_NONE);
224224
} else {
225225
setVisibility(View.INVISIBLE);
226226
}

packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public boolean onClickHandler(View view, PendingIntent pendingIntent, Intent fil
184184

185185
if (isActivity && handled) {
186186
// close the shade if it was open
187-
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
187+
animateCollapseNotifications(CommandQueue.FLAG_EXCLUDE_NONE);
188188
visibilityChanged(false);
189189
}
190190
return handled;
@@ -361,7 +361,7 @@ public boolean onLongClick(View v) {
361361
public boolean onMenuItemClick(MenuItem item) {
362362
if (item.getItemId() == R.id.notification_inspect_item) {
363363
startApplicationDetailsActivity(packageNameF);
364-
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
364+
animateCollapseNotifications(CommandQueue.FLAG_EXCLUDE_NONE);
365365
} else {
366366
return false;
367367
}
@@ -793,7 +793,7 @@ public void onClick(View v) {
793793
}
794794

795795
// close the shade if it was open
796-
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
796+
animateCollapseNotifications(CommandQueue.FLAG_EXCLUDE_NONE);
797797
visibilityChanged(false);
798798

799799
// If this click was on the intruder alert, hide that instead

packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java

Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,30 @@
3333
* are coalesced, note that they are all idempotent.
3434
*/
3535
public class CommandQueue extends IStatusBar.Stub {
36-
private static final String TAG = "StatusBar.CommandQueue";
37-
3836
private static final int INDEX_MASK = 0xffff;
3937
private static final int MSG_SHIFT = 16;
4038
private static final int MSG_MASK = 0xffff << MSG_SHIFT;
4139

42-
43-
private static final int MSG_ICON = 1 << MSG_SHIFT;
4440
private static final int OP_SET_ICON = 1;
4541
private static final int OP_REMOVE_ICON = 2;
4642

47-
private static final int MSG_ADD_NOTIFICATION = 2 << MSG_SHIFT;
48-
private static final int MSG_UPDATE_NOTIFICATION = 3 << MSG_SHIFT;
49-
private static final int MSG_REMOVE_NOTIFICATION = 4 << MSG_SHIFT;
50-
51-
private static final int MSG_DISABLE = 5 << MSG_SHIFT;
52-
53-
private static final int MSG_SET_VISIBILITY = 6 << MSG_SHIFT;
54-
private static final int OP_EXPAND = 1;
55-
private static final int OP_COLLAPSE = 2;
56-
57-
private static final int MSG_SET_SYSTEMUI_VISIBILITY = 7 << MSG_SHIFT;
58-
59-
private static final int MSG_TOP_APP_WINDOW_CHANGED = 8 << MSG_SHIFT;
60-
private static final int MSG_SHOW_IME_BUTTON = 9 << MSG_SHIFT;
61-
private static final int MSG_SET_HARD_KEYBOARD_STATUS = 10 << MSG_SHIFT;
62-
63-
private static final int MSG_TOGGLE_RECENT_APPS = 11 << MSG_SHIFT;
64-
private static final int MSG_PRELOAD_RECENT_APPS = 12 << MSG_SHIFT;
65-
private static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 13 << MSG_SHIFT;
66-
67-
private static final int MSG_SET_NAVIGATION_ICON_HINTS = 14 << MSG_SHIFT;
43+
private static final int MSG_ICON = 1 << MSG_SHIFT;
44+
private static final int MSG_ADD_NOTIFICATION = 2 << MSG_SHIFT;
45+
private static final int MSG_UPDATE_NOTIFICATION = 3 << MSG_SHIFT;
46+
private static final int MSG_REMOVE_NOTIFICATION = 4 << MSG_SHIFT;
47+
private static final int MSG_DISABLE = 5 << MSG_SHIFT;
48+
private static final int MSG_EXPAND_NOTIFICATIONS = 6 << MSG_SHIFT;
49+
private static final int MSG_COLLAPSE_NOTIFICATIONS = 7 << MSG_SHIFT;
50+
private static final int MSG_EXPAND_QUICK_SETTINGS = 8 << MSG_SHIFT;
51+
private static final int MSG_COLLAPSE_QUICK_SETTINGS = 9 << MSG_SHIFT;
52+
private static final int MSG_SET_SYSTEMUI_VISIBILITY = 10 << MSG_SHIFT;
53+
private static final int MSG_TOP_APP_WINDOW_CHANGED = 11 << MSG_SHIFT;
54+
private static final int MSG_SHOW_IME_BUTTON = 12 << MSG_SHIFT;
55+
private static final int MSG_SET_HARD_KEYBOARD_STATUS = 13 << MSG_SHIFT;
56+
private static final int MSG_TOGGLE_RECENT_APPS = 14 << MSG_SHIFT;
57+
private static final int MSG_PRELOAD_RECENT_APPS = 15 << MSG_SHIFT;
58+
private static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 16 << MSG_SHIFT;
59+
private static final int MSG_SET_NAVIGATION_ICON_HINTS = 17 << MSG_SHIFT;
6860

6961
public static final int FLAG_EXCLUDE_NONE = 0;
7062
public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -94,8 +86,10 @@ public void updateIcon(String slot, int index, int viewIndex,
9486
public void updateNotification(IBinder key, StatusBarNotification notification);
9587
public void removeNotification(IBinder key);
9688
public void disable(int state);
97-
public void animateExpand();
98-
public void animateCollapse(int flags);
89+
public void animateExpandNotifications();
90+
public void animateCollapseNotifications(int flags);
91+
public void animateExpandQuickSettings();
92+
public void animateCollapseQuickSettings();
9993
public void setSystemUiVisibility(int vis, int mask);
10094
public void topAppWindowChanged(boolean visible);
10195
public void setImeWindowStatus(IBinder token, int vis, int backDisposition);
@@ -160,21 +154,31 @@ public void disable(int state) {
160154
}
161155
}
162156

163-
public void animateExpand() {
157+
public void animateExpandNotifications() {
158+
synchronized (mList) {
159+
mHandler.removeMessages(MSG_EXPAND_NOTIFICATIONS);
160+
mHandler.sendEmptyMessage(MSG_EXPAND_NOTIFICATIONS);
161+
}
162+
}
163+
164+
public void animateCollapseNotifications() {
164165
synchronized (mList) {
165-
mHandler.removeMessages(MSG_SET_VISIBILITY);
166-
mHandler.obtainMessage(MSG_SET_VISIBILITY, OP_EXPAND, 0, null).sendToTarget();
166+
mHandler.removeMessages(MSG_COLLAPSE_NOTIFICATIONS);
167+
mHandler.sendEmptyMessage(MSG_COLLAPSE_NOTIFICATIONS);
167168
}
168169
}
169170

170-
public void animateCollapse() {
171-
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
171+
public void animateExpandQuickSettings() {
172+
synchronized (mList) {
173+
mHandler.removeMessages(MSG_EXPAND_QUICK_SETTINGS);
174+
mHandler.sendEmptyMessage(MSG_EXPAND_QUICK_SETTINGS);
175+
}
172176
}
173177

174-
public void animateCollapse(int flags) {
178+
public void animateCollapseQuickSettings() {
175179
synchronized (mList) {
176-
mHandler.removeMessages(MSG_SET_VISIBILITY);
177-
mHandler.obtainMessage(MSG_SET_VISIBILITY, OP_COLLAPSE, flags, null).sendToTarget();
180+
mHandler.removeMessages(MSG_COLLAPSE_QUICK_SETTINGS);
181+
mHandler.sendEmptyMessage(MSG_COLLAPSE_QUICK_SETTINGS);
178182
}
179183
}
180184

@@ -284,12 +288,17 @@ public void handleMessage(Message msg) {
284288
case MSG_DISABLE:
285289
mCallbacks.disable(msg.arg1);
286290
break;
287-
case MSG_SET_VISIBILITY:
288-
if (msg.arg1 == OP_EXPAND) {
289-
mCallbacks.animateExpand();
290-
} else {
291-
mCallbacks.animateCollapse(msg.arg2);
292-
}
291+
case MSG_EXPAND_NOTIFICATIONS:
292+
mCallbacks.animateExpandNotifications();
293+
break;
294+
case MSG_COLLAPSE_NOTIFICATIONS:
295+
mCallbacks.animateCollapseNotifications(0);
296+
break;
297+
case MSG_EXPAND_QUICK_SETTINGS:
298+
mCallbacks.animateExpandQuickSettings();
299+
break;
300+
case MSG_COLLAPSE_QUICK_SETTINGS:
301+
mCallbacks.animateCollapseQuickSettings();
293302
break;
294303
case MSG_SET_SYSTEMUI_VISIBILITY:
295304
mCallbacks.setSystemUiVisibility(msg.arg1, msg.arg2);

0 commit comments

Comments
 (0)