Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93edd117 authored by sallyyuen's avatar sallyyuen
Browse files

Fix system action API issues in SystemActions

1) Actions are only registered when the service starts. If the locale
changes, the labels need to be translated, so re-register the actions
when this happens.

2) When its shortcut isn't visible the a11y menu action is a no-op. The
list should be an accurate representation of what actions are available.
Pass SystemActions into NavigationBarFragment, which keeps track of the
shortcut availability,  to unregister/register the action.

To do this, SystemActions exposes register/unregister to the fragment
and makes SYSTEM_ACTION_ID_ACCESSIBILITY_MENU public.

3) Remove Toggle Split Screen from SystemActions. The trigger isn't
system-level but is rather buried in the Recents UI in a button for each
app, and the a11y user can access this like everyone else.
SystemActionPerformer will still handle the legacy action call in
performSystemAction.

4) Rename "Accessibility Menu" to "On-screen Accessibility Shortcut"

Bug: 152636060, 152635646, 154833492
Test: Manual TalkBack test
Change-Id: I9b037f91c8d3b6f193fc9aee95ef73b7f3fbf315
parent b344e0ac
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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";

    /**
+4 −4
Original line number Diff line number Diff line
@@ -5431,14 +5431,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>

+2 −1
Original line number Diff line number Diff line
@@ -3839,7 +3839,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" />

+163 −107

File changed.

Preview size limit exceeded, changes collapsed.

+14 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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;
@@ -391,6 +394,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
        mCommandQueue = commandQueue;
        mDivider = divider;
        mRecentsOptional = recentsOptional;
        mSystemActions = systemActions;
        mHandler = mainHandler;
    }

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