Add check for null manger for a11y recents action

Bug: 31986988

Test: Ran A11y cts
Change-Id: Ia6a1e1b921d8b0008edbcf1f1a8d1d3d0eb969c6
(cherry picked from commit 3cdd6c7654)
This commit is contained in:
Phil Weaver
2016-11-03 15:28:03 -07:00
committed by Rati Agrawal
parent eed332bada
commit 2585033100
2 changed files with 16 additions and 10 deletions

View File

@@ -334,7 +334,8 @@ public abstract class AccessibilityService extends Service {
public static final int GLOBAL_ACTION_HOME = 2; public static final int GLOBAL_ACTION_HOME = 2;
/** /**
* Action to toggle showing the overview of recent apps * Action to toggle showing the overview of recent apps. Will fail on platforms that don't
* show recent apps.
*/ */
public static final int GLOBAL_ACTION_RECENTS = 3; public static final int GLOBAL_ACTION_RECENTS = 3;

View File

@@ -2891,8 +2891,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
sendDownAndUpKeyEvents(KeyEvent.KEYCODE_HOME); sendDownAndUpKeyEvents(KeyEvent.KEYCODE_HOME);
} return true; } return true;
case AccessibilityService.GLOBAL_ACTION_RECENTS: { case AccessibilityService.GLOBAL_ACTION_RECENTS: {
openRecents(); return openRecents();
} return true; }
case AccessibilityService.GLOBAL_ACTION_NOTIFICATIONS: { case AccessibilityService.GLOBAL_ACTION_NOTIFICATIONS: {
expandNotifications(); expandNotifications();
} return true; } return true;
@@ -3385,15 +3385,20 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
Binder.restoreCallingIdentity(token); Binder.restoreCallingIdentity(token);
} }
private void openRecents() { private boolean openRecents() {
final long token = Binder.clearCallingIdentity(); final long token = Binder.clearCallingIdentity();
try {
StatusBarManagerInternal statusBarService = LocalServices.getService( StatusBarManagerInternal statusBarService = LocalServices.getService(
StatusBarManagerInternal.class); StatusBarManagerInternal.class);
if (statusBarService == null) {
return false;
}
statusBarService.toggleRecentApps(); statusBarService.toggleRecentApps();
} finally {
Binder.restoreCallingIdentity(token); Binder.restoreCallingIdentity(token);
} }
return true;
}
private void showGlobalActions() { private void showGlobalActions() {
mWindowManagerService.showGlobalActions(); mWindowManagerService.showGlobalActions();