Loading core/java/android/accessibilityservice/AccessibilityService.java +12 −0 Original line number Diff line number Diff line Loading @@ -501,6 +501,18 @@ public abstract class AccessibilityService extends Service { */ public static final int GLOBAL_ACTION_KEYCODE_HEADSETHOOK = 10; /** * Action to trigger the Accessibility Button * @hide */ public static final int GLOBAL_ACTION_ACCESSIBILITY_BUTTON = 11; /** * Action to bring up the Accessibility Button's chooser menu * @hide */ public static final int GLOBAL_ACTION_ACCESSIBILITY_BUTTON_CHOOSER = 12; private static final String LOG_TAG = "AccessibilityService"; /** Loading core/res/res/values/strings.xml +4 −4 Original line number Diff line number Diff line Loading @@ -5437,14 +5437,14 @@ <string name="accessibility_system_action_quick_settings_label">Quick Settings</string> <!-- Label for opening power dialog action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_power_dialog_label">Power Dialog</string> <!-- Label for toggle split screen action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_toggle_split_screen_label">Toggle Split Screen</string> <!-- Label for lock screen action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_lock_screen_label">Lock Screen</string> <!-- Label for taking screenshot action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_screenshot_label">Screenshot</string> <!-- Label for showing accessibility menu action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_accessibility_menu_label">Accessibility Menu</string> <!-- Label for showing accessibility shortcut action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_accessibility_button_label">On-screen Accessibility Shortcut</string> <!-- Label for showing accessibility shortcut menu action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_accessibility_button_chooser_label">On-screen Accessibility Shortcut Chooser</string> <!-- Accessibility description of caption view --> <string name="accessibility_freeform_caption">Caption bar of <xliff:g id="app_name">%1$s</xliff:g>.</string> Loading core/res/res/values/symbols.xml +2 −1 Original line number Diff line number Diff line Loading @@ -3842,7 +3842,8 @@ <java-symbol type="string" name="accessibility_system_action_recents_label" /> <java-symbol type="string" name="accessibility_system_action_screenshot_label" /> <java-symbol type="string" name="accessibility_system_action_toggle_split_screen_label" /> <java-symbol type="string" name="accessibility_system_action_accessibility_menu_label" /> <java-symbol type="string" name="accessibility_system_action_accessibility_button_label" /> <java-symbol type="string" name="accessibility_system_action_accessibility_button_chooser_label" /> <java-symbol type="string" name="accessibility_freeform_caption" /> Loading packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java +163 −107 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.systemui.accessibility; import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_GLOBAL_ACTIONS; import static com.android.internal.accessibility.common.ShortcutConstants.CHOOSER_PACKAGE_NAME; import android.accessibilityservice.AccessibilityService; import android.app.PendingIntent; import android.app.RemoteAction; Loading @@ -25,6 +27,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Configuration; import android.graphics.drawable.Icon; import android.hardware.input.InputManager; import android.os.Handler; Loading @@ -32,6 +35,7 @@ import android.os.Looper; import android.os.PowerManager; import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.util.Log; import android.view.Display; import android.view.IWindowManager; Loading @@ -43,12 +47,15 @@ import android.view.WindowManagerGlobal; import android.view.accessibility.AccessibilityManager; import com.android.internal.R; import com.android.internal.accessibility.dialog.AccessibilityButtonChooserActivity; import com.android.internal.util.ScreenshotHelper; import com.android.systemui.Dependency; import com.android.systemui.SystemUI; import com.android.systemui.recents.Recents; import com.android.systemui.statusbar.phone.StatusBar; import java.util.Locale; import javax.inject.Inject; import javax.inject.Singleton; Loading @@ -58,7 +65,6 @@ import javax.inject.Singleton; @Singleton public class SystemActions extends SystemUI { private static final String TAG = "SystemActions"; // TODO(b/147916452): add implementation on launcher side to register this action. /** * Action ID to go back. Loading Loading @@ -95,12 +101,6 @@ public class SystemActions extends SystemUI { private static final int SYSTEM_ACTION_ID_POWER_DIALOG = AccessibilityService.GLOBAL_ACTION_POWER_DIALOG; // = 6 /** * Action ID to toggle docking the current app's window */ private static final int SYSTEM_ACTION_ID_TOGGLE_SPLIT_SCREEN = AccessibilityService.GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN; // = 7 /** * Action ID to lock the screen */ Loading @@ -114,13 +114,22 @@ public class SystemActions extends SystemUI { AccessibilityService.GLOBAL_ACTION_TAKE_SCREENSHOT; // = 9 /** * Action ID to show accessibility menu * Action ID to trigger the accessibility button */ public static final int SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON = AccessibilityService.GLOBAL_ACTION_ACCESSIBILITY_BUTTON; // 11 /** * Action ID to show accessibility button's menu of services */ private static final int SYSTEM_ACTION_ID_ACCESSIBILITY_MENU = 10; public static final int SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON_CHOOSER = AccessibilityService.GLOBAL_ACTION_ACCESSIBILITY_BUTTON_CHOOSER; // 12 private Recents mRecents; private StatusBar mStatusBar; private SystemActionsBroadcastReceiver mReceiver; private Locale mLocale; private AccessibilityManager mA11yManager; @Inject public SystemActions(Context context) { Loading @@ -128,96 +137,139 @@ public class SystemActions extends SystemUI { mRecents = Dependency.get(Recents.class); mStatusBar = Dependency.get(StatusBar.class); mReceiver = new SystemActionsBroadcastReceiver(); mLocale = mContext.getResources().getConfiguration().getLocales().get(0); mA11yManager = (AccessibilityManager) mContext.getSystemService( Context.ACCESSIBILITY_SERVICE); } @Override public void start() { mContext.registerReceiverForAllUsers(mReceiver, mReceiver.createIntentFilter(), null, null); registerActions(); } // TODO(b/148087487): update the icon used below to a valid one RemoteAction actionBack = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_back_label), mContext.getString(R.string.accessibility_system_action_back_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_BACK)); RemoteAction actionHome = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_home_label), mContext.getString(R.string.accessibility_system_action_home_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_HOME)); @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); final Locale locale = mContext.getResources().getConfiguration().getLocales().get(0); if (!locale.equals(mLocale)) { mLocale = locale; registerActions(); } } RemoteAction actionRecents = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_recents_label), mContext.getString(R.string.accessibility_system_action_recents_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_RECENTS)); private void registerActions() { RemoteAction actionBack = createRemoteAction( R.string.accessibility_system_action_back_label, SystemActionsBroadcastReceiver.INTENT_ACTION_BACK); RemoteAction actionNotifications = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_notifications_label), mContext.getString(R.string.accessibility_system_action_notifications_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_NOTIFICATIONS)); RemoteAction actionHome = createRemoteAction( R.string.accessibility_system_action_home_label, SystemActionsBroadcastReceiver.INTENT_ACTION_HOME); RemoteAction actionQuickSettings = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_quick_settings_label), mContext.getString(R.string.accessibility_system_action_quick_settings_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_QUICK_SETTINGS)); RemoteAction actionRecents = createRemoteAction( R.string.accessibility_system_action_recents_label, SystemActionsBroadcastReceiver.INTENT_ACTION_RECENTS); RemoteAction actionPowerDialog = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_power_dialog_label), mContext.getString(R.string.accessibility_system_action_power_dialog_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_POWER_DIALOG)); RemoteAction actionNotifications = createRemoteAction( R.string.accessibility_system_action_notifications_label, SystemActionsBroadcastReceiver.INTENT_ACTION_NOTIFICATIONS); RemoteAction actionToggleSplitScreen = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_toggle_split_screen_label), mContext.getString(R.string.accessibility_system_action_toggle_split_screen_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_TOGGLE_SPLIT_SCREEN)); RemoteAction actionQuickSettings = createRemoteAction( R.string.accessibility_system_action_quick_settings_label, SystemActionsBroadcastReceiver.INTENT_ACTION_QUICK_SETTINGS); RemoteAction actionLockScreen = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_lock_screen_label), mContext.getString(R.string.accessibility_system_action_lock_screen_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_LOCK_SCREEN)); RemoteAction actionPowerDialog = createRemoteAction( R.string.accessibility_system_action_power_dialog_label, SystemActionsBroadcastReceiver.INTENT_ACTION_POWER_DIALOG); RemoteAction actionTakeScreenshot = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_screenshot_label), mContext.getString(R.string.accessibility_system_action_screenshot_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_TAKE_SCREENSHOT)); RemoteAction actionLockScreen = createRemoteAction( R.string.accessibility_system_action_lock_screen_label, SystemActionsBroadcastReceiver.INTENT_ACTION_LOCK_SCREEN); RemoteAction actionAccessibilityMenu = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_accessibility_menu_label), mContext.getString(R.string.accessibility_system_action_accessibility_menu_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_ACCESSIBILITY_MENU)); RemoteAction actionTakeScreenshot = createRemoteAction( R.string.accessibility_system_action_screenshot_label, SystemActionsBroadcastReceiver.INTENT_ACTION_TAKE_SCREENSHOT); AccessibilityManager am = (AccessibilityManager) mContext.getSystemService( Context.ACCESSIBILITY_SERVICE); mA11yManager.registerSystemAction(actionBack, SYSTEM_ACTION_ID_BACK); mA11yManager.registerSystemAction(actionHome, SYSTEM_ACTION_ID_HOME); mA11yManager.registerSystemAction(actionRecents, SYSTEM_ACTION_ID_RECENTS); mA11yManager.registerSystemAction(actionNotifications, SYSTEM_ACTION_ID_NOTIFICATIONS); mA11yManager.registerSystemAction(actionQuickSettings, SYSTEM_ACTION_ID_QUICK_SETTINGS); mA11yManager.registerSystemAction(actionPowerDialog, SYSTEM_ACTION_ID_POWER_DIALOG); mA11yManager.registerSystemAction(actionLockScreen, SYSTEM_ACTION_ID_LOCK_SCREEN); mA11yManager.registerSystemAction(actionTakeScreenshot, SYSTEM_ACTION_ID_TAKE_SCREENSHOT); } /** * Register a system action. * @param actionId the action ID to register. */ public void register(int actionId) { int labelId; String intent; switch (actionId) { case SYSTEM_ACTION_ID_BACK: labelId = R.string.accessibility_system_action_back_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_BACK; break; case SYSTEM_ACTION_ID_HOME: labelId = R.string.accessibility_system_action_home_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_HOME; break; case SYSTEM_ACTION_ID_RECENTS: labelId = R.string.accessibility_system_action_recents_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_RECENTS; break; case SYSTEM_ACTION_ID_NOTIFICATIONS: labelId = R.string.accessibility_system_action_notifications_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_NOTIFICATIONS; break; case SYSTEM_ACTION_ID_QUICK_SETTINGS: labelId = R.string.accessibility_system_action_quick_settings_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_QUICK_SETTINGS; break; case SYSTEM_ACTION_ID_POWER_DIALOG: labelId = R.string.accessibility_system_action_power_dialog_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_POWER_DIALOG; break; case SYSTEM_ACTION_ID_LOCK_SCREEN: labelId = R.string.accessibility_system_action_lock_screen_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_LOCK_SCREEN; break; case SYSTEM_ACTION_ID_TAKE_SCREENSHOT: labelId = R.string.accessibility_system_action_screenshot_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_TAKE_SCREENSHOT; break; case SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON: labelId = R.string.accessibility_system_action_accessibility_button_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_ACCESSIBILITY_BUTTON; break; case SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON_CHOOSER: labelId = R.string.accessibility_system_action_accessibility_button_chooser_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER; break; default: return; } mA11yManager.registerSystemAction(createRemoteAction(labelId, intent), actionId); } am.registerSystemAction(actionBack, SYSTEM_ACTION_ID_BACK); am.registerSystemAction(actionHome, SYSTEM_ACTION_ID_HOME); am.registerSystemAction(actionRecents, SYSTEM_ACTION_ID_RECENTS); am.registerSystemAction(actionNotifications, SYSTEM_ACTION_ID_NOTIFICATIONS); am.registerSystemAction(actionQuickSettings, SYSTEM_ACTION_ID_QUICK_SETTINGS); am.registerSystemAction(actionPowerDialog, SYSTEM_ACTION_ID_POWER_DIALOG); am.registerSystemAction(actionToggleSplitScreen, SYSTEM_ACTION_ID_TOGGLE_SPLIT_SCREEN); am.registerSystemAction(actionLockScreen, SYSTEM_ACTION_ID_LOCK_SCREEN); am.registerSystemAction(actionTakeScreenshot, SYSTEM_ACTION_ID_TAKE_SCREENSHOT); am.registerSystemAction(actionAccessibilityMenu, SYSTEM_ACTION_ID_ACCESSIBILITY_MENU); private RemoteAction createRemoteAction(int labelId, String intent) { // TODO(b/148087487): update the icon used below to a valid one return new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(labelId), mContext.getString(labelId), mReceiver.createPendingIntent(mContext, intent)); } /** * Unregister a system action. * @param actionId the action ID to unregister. */ public void unregister(int actionId) { mA11yManager.unregisterSystemAction(actionId); } private void handleBack() { Loading Loading @@ -266,10 +318,6 @@ public class SystemActions extends SystemUI { } } private void handleToggleSplitScreen() { mStatusBar.toggleSplitScreen(); } private void handleLockScreen() { IWindowManager windowManager = WindowManagerGlobal.getWindowManagerService(); Loading @@ -288,11 +336,19 @@ public class SystemActions extends SystemUI { SCREENSHOT_GLOBAL_ACTIONS, new Handler(Looper.getMainLooper()), null); } private void handleAccessibilityMenu() { private void handleAccessibilityButton() { AccessibilityManager.getInstance(mContext).notifyAccessibilityButtonClicked( Display.DEFAULT_DISPLAY); } private void handleAccessibilityButtonChooser() { final Intent intent = new Intent(AccessibilityManager.ACTION_CHOOSE_ACCESSIBILITY_BUTTON); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); final String chooserClassName = AccessibilityButtonChooserActivity.class.getName(); intent.setClassName(CHOOSER_PACKAGE_NAME, chooserClassName); mContext.startActivityAsUser(intent, UserHandle.CURRENT); } private class SystemActionsBroadcastReceiver extends BroadcastReceiver { private static final String INTENT_ACTION_BACK = "SYSTEM_ACTION_BACK"; private static final String INTENT_ACTION_HOME = "SYSTEM_ACTION_HOME"; Loading @@ -300,12 +356,12 @@ public class SystemActions extends SystemUI { private static final String INTENT_ACTION_NOTIFICATIONS = "SYSTEM_ACTION_NOTIFICATIONS"; private static final String INTENT_ACTION_QUICK_SETTINGS = "SYSTEM_ACTION_QUICK_SETTINGS"; private static final String INTENT_ACTION_POWER_DIALOG = "SYSTEM_ACTION_POWER_DIALOG"; private static final String INTENT_ACTION_TOGGLE_SPLIT_SCREEN = "SYSTEM_ACTION_TOGGLE_SPLIT_SCREEN"; private static final String INTENT_ACTION_LOCK_SCREEN = "SYSTEM_ACTION_LOCK_SCREEN"; private static final String INTENT_ACTION_TAKE_SCREENSHOT = "SYSTEM_ACTION_TAKE_SCREENSHOT"; private static final String INTENT_ACTION_ACCESSIBILITY_MENU = "SYSTEM_ACTION_ACCESSIBILITY_MENU"; private static final String INTENT_ACTION_ACCESSIBILITY_BUTTON = "SYSTEM_ACTION_ACCESSIBILITY_BUTTON"; private static final String INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER = "SYSTEM_ACTION_ACCESSIBILITY_BUTTON_MENU"; private PendingIntent createPendingIntent(Context context, String intentAction) { switch (intentAction) { Loading @@ -315,10 +371,10 @@ public class SystemActions extends SystemUI { case INTENT_ACTION_NOTIFICATIONS: case INTENT_ACTION_QUICK_SETTINGS: case INTENT_ACTION_POWER_DIALOG: case INTENT_ACTION_TOGGLE_SPLIT_SCREEN: case INTENT_ACTION_LOCK_SCREEN: case INTENT_ACTION_TAKE_SCREENSHOT: case INTENT_ACTION_ACCESSIBILITY_MENU: { case INTENT_ACTION_ACCESSIBILITY_BUTTON: case INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER: { Intent intent = new Intent(intentAction); return PendingIntent.getBroadcast(context, 0, intent, 0); } Loading @@ -336,10 +392,10 @@ public class SystemActions extends SystemUI { intentFilter.addAction(INTENT_ACTION_NOTIFICATIONS); intentFilter.addAction(INTENT_ACTION_QUICK_SETTINGS); intentFilter.addAction(INTENT_ACTION_POWER_DIALOG); intentFilter.addAction(INTENT_ACTION_TOGGLE_SPLIT_SCREEN); intentFilter.addAction(INTENT_ACTION_LOCK_SCREEN); intentFilter.addAction(INTENT_ACTION_TAKE_SCREENSHOT); intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_MENU); intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_BUTTON); intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER); return intentFilter; } Loading Loading @@ -371,10 +427,6 @@ public class SystemActions extends SystemUI { handlePowerDialog(); break; } case INTENT_ACTION_TOGGLE_SPLIT_SCREEN: { handleToggleSplitScreen(); break; } case INTENT_ACTION_LOCK_SCREEN: { handleLockScreen(); break; Loading @@ -383,8 +435,12 @@ public class SystemActions extends SystemUI { handleTakeScreenshot(); break; } case INTENT_ACTION_ACCESSIBILITY_MENU: { handleAccessibilityMenu(); case INTENT_ACTION_ACCESSIBILITY_BUTTON: { handleAccessibilityButton(); break; } case INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER: { handleAccessibilityButtonChooser(); break; } default: Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +14 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.util.LatencyTracker; import com.android.internal.view.AppearanceRegion; import com.android.systemui.R; import com.android.systemui.accessibility.SystemActions; import com.android.systemui.assist.AssistHandleViewController; import com.android.systemui.assist.AssistManager; import com.android.systemui.broadcast.BroadcastDispatcher; Loading Loading @@ -185,6 +186,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback private WindowManager mWindowManager; private final CommandQueue mCommandQueue; private long mLastLockToAppLongPress; private final SystemActions mSystemActions; private Locale mLocale; private int mLayoutDirection; Loading Loading @@ -373,6 +375,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback Optional<Recents> recentsOptional, Lazy<StatusBar> statusBarLazy, ShadeController shadeController, NotificationRemoteInputManager notificationRemoteInputManager, SystemActions systemActions, @Main Handler mainHandler) { mAccessibilityManagerWrapper = accessibilityManagerWrapper; mDeviceProvisionedController = deviceProvisionedController; Loading @@ -391,6 +394,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback mCommandQueue = commandQueue; mDivider = divider; mRecentsOptional = recentsOptional; mSystemActions = systemActions; mHandler = mainHandler; } Loading Loading @@ -1168,6 +1172,16 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback .setFlag(SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE, longClickable) .setFlag(SYSUI_STATE_NAV_BAR_HIDDEN, !isNavBarWindowVisible()) .commitUpdate(mDisplayId); registerAction(clickable, SystemActions.SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON); registerAction(longClickable, SystemActions.SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON_CHOOSER); } private void registerAction(boolean register, int actionId) { if (register) { mSystemActions.register(actionId); } else { mSystemActions.unregister(actionId); } } /** Loading Loading
core/java/android/accessibilityservice/AccessibilityService.java +12 −0 Original line number Diff line number Diff line Loading @@ -501,6 +501,18 @@ public abstract class AccessibilityService extends Service { */ public static final int GLOBAL_ACTION_KEYCODE_HEADSETHOOK = 10; /** * Action to trigger the Accessibility Button * @hide */ public static final int GLOBAL_ACTION_ACCESSIBILITY_BUTTON = 11; /** * Action to bring up the Accessibility Button's chooser menu * @hide */ public static final int GLOBAL_ACTION_ACCESSIBILITY_BUTTON_CHOOSER = 12; private static final String LOG_TAG = "AccessibilityService"; /** Loading
core/res/res/values/strings.xml +4 −4 Original line number Diff line number Diff line Loading @@ -5437,14 +5437,14 @@ <string name="accessibility_system_action_quick_settings_label">Quick Settings</string> <!-- Label for opening power dialog action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_power_dialog_label">Power Dialog</string> <!-- Label for toggle split screen action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_toggle_split_screen_label">Toggle Split Screen</string> <!-- Label for lock screen action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_lock_screen_label">Lock Screen</string> <!-- Label for taking screenshot action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_screenshot_label">Screenshot</string> <!-- Label for showing accessibility menu action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_accessibility_menu_label">Accessibility Menu</string> <!-- Label for showing accessibility shortcut action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_accessibility_button_label">On-screen Accessibility Shortcut</string> <!-- Label for showing accessibility shortcut menu action [CHAR LIMIT=NONE] --> <string name="accessibility_system_action_accessibility_button_chooser_label">On-screen Accessibility Shortcut Chooser</string> <!-- Accessibility description of caption view --> <string name="accessibility_freeform_caption">Caption bar of <xliff:g id="app_name">%1$s</xliff:g>.</string> Loading
core/res/res/values/symbols.xml +2 −1 Original line number Diff line number Diff line Loading @@ -3842,7 +3842,8 @@ <java-symbol type="string" name="accessibility_system_action_recents_label" /> <java-symbol type="string" name="accessibility_system_action_screenshot_label" /> <java-symbol type="string" name="accessibility_system_action_toggle_split_screen_label" /> <java-symbol type="string" name="accessibility_system_action_accessibility_menu_label" /> <java-symbol type="string" name="accessibility_system_action_accessibility_button_label" /> <java-symbol type="string" name="accessibility_system_action_accessibility_button_chooser_label" /> <java-symbol type="string" name="accessibility_freeform_caption" /> Loading
packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java +163 −107 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.systemui.accessibility; import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_GLOBAL_ACTIONS; import static com.android.internal.accessibility.common.ShortcutConstants.CHOOSER_PACKAGE_NAME; import android.accessibilityservice.AccessibilityService; import android.app.PendingIntent; import android.app.RemoteAction; Loading @@ -25,6 +27,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Configuration; import android.graphics.drawable.Icon; import android.hardware.input.InputManager; import android.os.Handler; Loading @@ -32,6 +35,7 @@ import android.os.Looper; import android.os.PowerManager; import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.util.Log; import android.view.Display; import android.view.IWindowManager; Loading @@ -43,12 +47,15 @@ import android.view.WindowManagerGlobal; import android.view.accessibility.AccessibilityManager; import com.android.internal.R; import com.android.internal.accessibility.dialog.AccessibilityButtonChooserActivity; import com.android.internal.util.ScreenshotHelper; import com.android.systemui.Dependency; import com.android.systemui.SystemUI; import com.android.systemui.recents.Recents; import com.android.systemui.statusbar.phone.StatusBar; import java.util.Locale; import javax.inject.Inject; import javax.inject.Singleton; Loading @@ -58,7 +65,6 @@ import javax.inject.Singleton; @Singleton public class SystemActions extends SystemUI { private static final String TAG = "SystemActions"; // TODO(b/147916452): add implementation on launcher side to register this action. /** * Action ID to go back. Loading Loading @@ -95,12 +101,6 @@ public class SystemActions extends SystemUI { private static final int SYSTEM_ACTION_ID_POWER_DIALOG = AccessibilityService.GLOBAL_ACTION_POWER_DIALOG; // = 6 /** * Action ID to toggle docking the current app's window */ private static final int SYSTEM_ACTION_ID_TOGGLE_SPLIT_SCREEN = AccessibilityService.GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN; // = 7 /** * Action ID to lock the screen */ Loading @@ -114,13 +114,22 @@ public class SystemActions extends SystemUI { AccessibilityService.GLOBAL_ACTION_TAKE_SCREENSHOT; // = 9 /** * Action ID to show accessibility menu * Action ID to trigger the accessibility button */ public static final int SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON = AccessibilityService.GLOBAL_ACTION_ACCESSIBILITY_BUTTON; // 11 /** * Action ID to show accessibility button's menu of services */ private static final int SYSTEM_ACTION_ID_ACCESSIBILITY_MENU = 10; public static final int SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON_CHOOSER = AccessibilityService.GLOBAL_ACTION_ACCESSIBILITY_BUTTON_CHOOSER; // 12 private Recents mRecents; private StatusBar mStatusBar; private SystemActionsBroadcastReceiver mReceiver; private Locale mLocale; private AccessibilityManager mA11yManager; @Inject public SystemActions(Context context) { Loading @@ -128,96 +137,139 @@ public class SystemActions extends SystemUI { mRecents = Dependency.get(Recents.class); mStatusBar = Dependency.get(StatusBar.class); mReceiver = new SystemActionsBroadcastReceiver(); mLocale = mContext.getResources().getConfiguration().getLocales().get(0); mA11yManager = (AccessibilityManager) mContext.getSystemService( Context.ACCESSIBILITY_SERVICE); } @Override public void start() { mContext.registerReceiverForAllUsers(mReceiver, mReceiver.createIntentFilter(), null, null); registerActions(); } // TODO(b/148087487): update the icon used below to a valid one RemoteAction actionBack = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_back_label), mContext.getString(R.string.accessibility_system_action_back_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_BACK)); RemoteAction actionHome = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_home_label), mContext.getString(R.string.accessibility_system_action_home_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_HOME)); @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); final Locale locale = mContext.getResources().getConfiguration().getLocales().get(0); if (!locale.equals(mLocale)) { mLocale = locale; registerActions(); } } RemoteAction actionRecents = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_recents_label), mContext.getString(R.string.accessibility_system_action_recents_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_RECENTS)); private void registerActions() { RemoteAction actionBack = createRemoteAction( R.string.accessibility_system_action_back_label, SystemActionsBroadcastReceiver.INTENT_ACTION_BACK); RemoteAction actionNotifications = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_notifications_label), mContext.getString(R.string.accessibility_system_action_notifications_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_NOTIFICATIONS)); RemoteAction actionHome = createRemoteAction( R.string.accessibility_system_action_home_label, SystemActionsBroadcastReceiver.INTENT_ACTION_HOME); RemoteAction actionQuickSettings = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_quick_settings_label), mContext.getString(R.string.accessibility_system_action_quick_settings_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_QUICK_SETTINGS)); RemoteAction actionRecents = createRemoteAction( R.string.accessibility_system_action_recents_label, SystemActionsBroadcastReceiver.INTENT_ACTION_RECENTS); RemoteAction actionPowerDialog = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_power_dialog_label), mContext.getString(R.string.accessibility_system_action_power_dialog_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_POWER_DIALOG)); RemoteAction actionNotifications = createRemoteAction( R.string.accessibility_system_action_notifications_label, SystemActionsBroadcastReceiver.INTENT_ACTION_NOTIFICATIONS); RemoteAction actionToggleSplitScreen = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_toggle_split_screen_label), mContext.getString(R.string.accessibility_system_action_toggle_split_screen_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_TOGGLE_SPLIT_SCREEN)); RemoteAction actionQuickSettings = createRemoteAction( R.string.accessibility_system_action_quick_settings_label, SystemActionsBroadcastReceiver.INTENT_ACTION_QUICK_SETTINGS); RemoteAction actionLockScreen = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_lock_screen_label), mContext.getString(R.string.accessibility_system_action_lock_screen_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_LOCK_SCREEN)); RemoteAction actionPowerDialog = createRemoteAction( R.string.accessibility_system_action_power_dialog_label, SystemActionsBroadcastReceiver.INTENT_ACTION_POWER_DIALOG); RemoteAction actionTakeScreenshot = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_screenshot_label), mContext.getString(R.string.accessibility_system_action_screenshot_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_TAKE_SCREENSHOT)); RemoteAction actionLockScreen = createRemoteAction( R.string.accessibility_system_action_lock_screen_label, SystemActionsBroadcastReceiver.INTENT_ACTION_LOCK_SCREEN); RemoteAction actionAccessibilityMenu = new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(R.string.accessibility_system_action_accessibility_menu_label), mContext.getString(R.string.accessibility_system_action_accessibility_menu_label), mReceiver.createPendingIntent( mContext, SystemActionsBroadcastReceiver.INTENT_ACTION_ACCESSIBILITY_MENU)); RemoteAction actionTakeScreenshot = createRemoteAction( R.string.accessibility_system_action_screenshot_label, SystemActionsBroadcastReceiver.INTENT_ACTION_TAKE_SCREENSHOT); AccessibilityManager am = (AccessibilityManager) mContext.getSystemService( Context.ACCESSIBILITY_SERVICE); mA11yManager.registerSystemAction(actionBack, SYSTEM_ACTION_ID_BACK); mA11yManager.registerSystemAction(actionHome, SYSTEM_ACTION_ID_HOME); mA11yManager.registerSystemAction(actionRecents, SYSTEM_ACTION_ID_RECENTS); mA11yManager.registerSystemAction(actionNotifications, SYSTEM_ACTION_ID_NOTIFICATIONS); mA11yManager.registerSystemAction(actionQuickSettings, SYSTEM_ACTION_ID_QUICK_SETTINGS); mA11yManager.registerSystemAction(actionPowerDialog, SYSTEM_ACTION_ID_POWER_DIALOG); mA11yManager.registerSystemAction(actionLockScreen, SYSTEM_ACTION_ID_LOCK_SCREEN); mA11yManager.registerSystemAction(actionTakeScreenshot, SYSTEM_ACTION_ID_TAKE_SCREENSHOT); } /** * Register a system action. * @param actionId the action ID to register. */ public void register(int actionId) { int labelId; String intent; switch (actionId) { case SYSTEM_ACTION_ID_BACK: labelId = R.string.accessibility_system_action_back_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_BACK; break; case SYSTEM_ACTION_ID_HOME: labelId = R.string.accessibility_system_action_home_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_HOME; break; case SYSTEM_ACTION_ID_RECENTS: labelId = R.string.accessibility_system_action_recents_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_RECENTS; break; case SYSTEM_ACTION_ID_NOTIFICATIONS: labelId = R.string.accessibility_system_action_notifications_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_NOTIFICATIONS; break; case SYSTEM_ACTION_ID_QUICK_SETTINGS: labelId = R.string.accessibility_system_action_quick_settings_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_QUICK_SETTINGS; break; case SYSTEM_ACTION_ID_POWER_DIALOG: labelId = R.string.accessibility_system_action_power_dialog_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_POWER_DIALOG; break; case SYSTEM_ACTION_ID_LOCK_SCREEN: labelId = R.string.accessibility_system_action_lock_screen_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_LOCK_SCREEN; break; case SYSTEM_ACTION_ID_TAKE_SCREENSHOT: labelId = R.string.accessibility_system_action_screenshot_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_TAKE_SCREENSHOT; break; case SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON: labelId = R.string.accessibility_system_action_accessibility_button_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_ACCESSIBILITY_BUTTON; break; case SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON_CHOOSER: labelId = R.string.accessibility_system_action_accessibility_button_chooser_label; intent = SystemActionsBroadcastReceiver.INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER; break; default: return; } mA11yManager.registerSystemAction(createRemoteAction(labelId, intent), actionId); } am.registerSystemAction(actionBack, SYSTEM_ACTION_ID_BACK); am.registerSystemAction(actionHome, SYSTEM_ACTION_ID_HOME); am.registerSystemAction(actionRecents, SYSTEM_ACTION_ID_RECENTS); am.registerSystemAction(actionNotifications, SYSTEM_ACTION_ID_NOTIFICATIONS); am.registerSystemAction(actionQuickSettings, SYSTEM_ACTION_ID_QUICK_SETTINGS); am.registerSystemAction(actionPowerDialog, SYSTEM_ACTION_ID_POWER_DIALOG); am.registerSystemAction(actionToggleSplitScreen, SYSTEM_ACTION_ID_TOGGLE_SPLIT_SCREEN); am.registerSystemAction(actionLockScreen, SYSTEM_ACTION_ID_LOCK_SCREEN); am.registerSystemAction(actionTakeScreenshot, SYSTEM_ACTION_ID_TAKE_SCREENSHOT); am.registerSystemAction(actionAccessibilityMenu, SYSTEM_ACTION_ID_ACCESSIBILITY_MENU); private RemoteAction createRemoteAction(int labelId, String intent) { // TODO(b/148087487): update the icon used below to a valid one return new RemoteAction( Icon.createWithResource(mContext, R.drawable.ic_info), mContext.getString(labelId), mContext.getString(labelId), mReceiver.createPendingIntent(mContext, intent)); } /** * Unregister a system action. * @param actionId the action ID to unregister. */ public void unregister(int actionId) { mA11yManager.unregisterSystemAction(actionId); } private void handleBack() { Loading Loading @@ -266,10 +318,6 @@ public class SystemActions extends SystemUI { } } private void handleToggleSplitScreen() { mStatusBar.toggleSplitScreen(); } private void handleLockScreen() { IWindowManager windowManager = WindowManagerGlobal.getWindowManagerService(); Loading @@ -288,11 +336,19 @@ public class SystemActions extends SystemUI { SCREENSHOT_GLOBAL_ACTIONS, new Handler(Looper.getMainLooper()), null); } private void handleAccessibilityMenu() { private void handleAccessibilityButton() { AccessibilityManager.getInstance(mContext).notifyAccessibilityButtonClicked( Display.DEFAULT_DISPLAY); } private void handleAccessibilityButtonChooser() { final Intent intent = new Intent(AccessibilityManager.ACTION_CHOOSE_ACCESSIBILITY_BUTTON); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); final String chooserClassName = AccessibilityButtonChooserActivity.class.getName(); intent.setClassName(CHOOSER_PACKAGE_NAME, chooserClassName); mContext.startActivityAsUser(intent, UserHandle.CURRENT); } private class SystemActionsBroadcastReceiver extends BroadcastReceiver { private static final String INTENT_ACTION_BACK = "SYSTEM_ACTION_BACK"; private static final String INTENT_ACTION_HOME = "SYSTEM_ACTION_HOME"; Loading @@ -300,12 +356,12 @@ public class SystemActions extends SystemUI { private static final String INTENT_ACTION_NOTIFICATIONS = "SYSTEM_ACTION_NOTIFICATIONS"; private static final String INTENT_ACTION_QUICK_SETTINGS = "SYSTEM_ACTION_QUICK_SETTINGS"; private static final String INTENT_ACTION_POWER_DIALOG = "SYSTEM_ACTION_POWER_DIALOG"; private static final String INTENT_ACTION_TOGGLE_SPLIT_SCREEN = "SYSTEM_ACTION_TOGGLE_SPLIT_SCREEN"; private static final String INTENT_ACTION_LOCK_SCREEN = "SYSTEM_ACTION_LOCK_SCREEN"; private static final String INTENT_ACTION_TAKE_SCREENSHOT = "SYSTEM_ACTION_TAKE_SCREENSHOT"; private static final String INTENT_ACTION_ACCESSIBILITY_MENU = "SYSTEM_ACTION_ACCESSIBILITY_MENU"; private static final String INTENT_ACTION_ACCESSIBILITY_BUTTON = "SYSTEM_ACTION_ACCESSIBILITY_BUTTON"; private static final String INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER = "SYSTEM_ACTION_ACCESSIBILITY_BUTTON_MENU"; private PendingIntent createPendingIntent(Context context, String intentAction) { switch (intentAction) { Loading @@ -315,10 +371,10 @@ public class SystemActions extends SystemUI { case INTENT_ACTION_NOTIFICATIONS: case INTENT_ACTION_QUICK_SETTINGS: case INTENT_ACTION_POWER_DIALOG: case INTENT_ACTION_TOGGLE_SPLIT_SCREEN: case INTENT_ACTION_LOCK_SCREEN: case INTENT_ACTION_TAKE_SCREENSHOT: case INTENT_ACTION_ACCESSIBILITY_MENU: { case INTENT_ACTION_ACCESSIBILITY_BUTTON: case INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER: { Intent intent = new Intent(intentAction); return PendingIntent.getBroadcast(context, 0, intent, 0); } Loading @@ -336,10 +392,10 @@ public class SystemActions extends SystemUI { intentFilter.addAction(INTENT_ACTION_NOTIFICATIONS); intentFilter.addAction(INTENT_ACTION_QUICK_SETTINGS); intentFilter.addAction(INTENT_ACTION_POWER_DIALOG); intentFilter.addAction(INTENT_ACTION_TOGGLE_SPLIT_SCREEN); intentFilter.addAction(INTENT_ACTION_LOCK_SCREEN); intentFilter.addAction(INTENT_ACTION_TAKE_SCREENSHOT); intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_MENU); intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_BUTTON); intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER); return intentFilter; } Loading Loading @@ -371,10 +427,6 @@ public class SystemActions extends SystemUI { handlePowerDialog(); break; } case INTENT_ACTION_TOGGLE_SPLIT_SCREEN: { handleToggleSplitScreen(); break; } case INTENT_ACTION_LOCK_SCREEN: { handleLockScreen(); break; Loading @@ -383,8 +435,12 @@ public class SystemActions extends SystemUI { handleTakeScreenshot(); break; } case INTENT_ACTION_ACCESSIBILITY_MENU: { handleAccessibilityMenu(); case INTENT_ACTION_ACCESSIBILITY_BUTTON: { handleAccessibilityButton(); break; } case INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER: { handleAccessibilityButtonChooser(); break; } default: Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +14 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.util.LatencyTracker; import com.android.internal.view.AppearanceRegion; import com.android.systemui.R; import com.android.systemui.accessibility.SystemActions; import com.android.systemui.assist.AssistHandleViewController; import com.android.systemui.assist.AssistManager; import com.android.systemui.broadcast.BroadcastDispatcher; Loading Loading @@ -185,6 +186,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback private WindowManager mWindowManager; private final CommandQueue mCommandQueue; private long mLastLockToAppLongPress; private final SystemActions mSystemActions; private Locale mLocale; private int mLayoutDirection; Loading Loading @@ -373,6 +375,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback Optional<Recents> recentsOptional, Lazy<StatusBar> statusBarLazy, ShadeController shadeController, NotificationRemoteInputManager notificationRemoteInputManager, SystemActions systemActions, @Main Handler mainHandler) { mAccessibilityManagerWrapper = accessibilityManagerWrapper; mDeviceProvisionedController = deviceProvisionedController; Loading @@ -391,6 +394,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback mCommandQueue = commandQueue; mDivider = divider; mRecentsOptional = recentsOptional; mSystemActions = systemActions; mHandler = mainHandler; } Loading Loading @@ -1168,6 +1172,16 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback .setFlag(SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE, longClickable) .setFlag(SYSUI_STATE_NAV_BAR_HIDDEN, !isNavBarWindowVisible()) .commitUpdate(mDisplayId); registerAction(clickable, SystemActions.SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON); registerAction(longClickable, SystemActions.SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON_CHOOSER); } private void registerAction(boolean register, int actionId) { if (register) { mSystemActions.register(actionId); } else { mSystemActions.unregister(actionId); } } /** Loading