Merge "Fix system action API issues in SystemActions" into rvc-dev am: f8331a8a91 am: cb18d3a091
Change-Id: I41bbd15560ab83ab6ea41f477283081c45d3d1b4
This commit is contained in:
@@ -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";
|
||||
|
||||
/**
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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" />
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
@@ -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
|
||||
*/
|
||||
@@ -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
|
||||
*/
|
||||
private static final int SYSTEM_ACTION_ID_ACCESSIBILITY_MENU = 10;
|
||||
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
|
||||
*/
|
||||
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) {
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
||||
private void registerActions() {
|
||||
RemoteAction actionBack = createRemoteAction(
|
||||
R.string.accessibility_system_action_back_label,
|
||||
SystemActionsBroadcastReceiver.INTENT_ACTION_BACK);
|
||||
|
||||
RemoteAction actionHome = createRemoteAction(
|
||||
R.string.accessibility_system_action_home_label,
|
||||
SystemActionsBroadcastReceiver.INTENT_ACTION_HOME);
|
||||
|
||||
RemoteAction actionRecents = createRemoteAction(
|
||||
R.string.accessibility_system_action_recents_label,
|
||||
SystemActionsBroadcastReceiver.INTENT_ACTION_RECENTS);
|
||||
|
||||
RemoteAction actionNotifications = createRemoteAction(
|
||||
R.string.accessibility_system_action_notifications_label,
|
||||
SystemActionsBroadcastReceiver.INTENT_ACTION_NOTIFICATIONS);
|
||||
|
||||
RemoteAction actionQuickSettings = createRemoteAction(
|
||||
R.string.accessibility_system_action_quick_settings_label,
|
||||
SystemActionsBroadcastReceiver.INTENT_ACTION_QUICK_SETTINGS);
|
||||
|
||||
RemoteAction actionPowerDialog = createRemoteAction(
|
||||
R.string.accessibility_system_action_power_dialog_label,
|
||||
SystemActionsBroadcastReceiver.INTENT_ACTION_POWER_DIALOG);
|
||||
|
||||
RemoteAction actionLockScreen = createRemoteAction(
|
||||
R.string.accessibility_system_action_lock_screen_label,
|
||||
SystemActionsBroadcastReceiver.INTENT_ACTION_LOCK_SCREEN);
|
||||
|
||||
RemoteAction actionTakeScreenshot = createRemoteAction(
|
||||
R.string.accessibility_system_action_screenshot_label,
|
||||
SystemActionsBroadcastReceiver.INTENT_ACTION_TAKE_SCREENSHOT);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private RemoteAction createRemoteAction(int labelId, String intent) {
|
||||
// TODO(b/148087487): update the icon used below to a valid one
|
||||
RemoteAction actionBack = new RemoteAction(
|
||||
return 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));
|
||||
mContext.getString(labelId),
|
||||
mContext.getString(labelId),
|
||||
mReceiver.createPendingIntent(mContext, intent));
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
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 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 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 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 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 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 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));
|
||||
|
||||
AccessibilityManager am = (AccessibilityManager) mContext.getSystemService(
|
||||
Context.ACCESSIBILITY_SERVICE);
|
||||
|
||||
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);
|
||||
/**
|
||||
* Unregister a system action.
|
||||
* @param actionId the action ID to unregister.
|
||||
*/
|
||||
public void unregister(int actionId) {
|
||||
mA11yManager.unregisterSystemAction(actionId);
|
||||
}
|
||||
|
||||
private void handleBack() {
|
||||
@@ -266,10 +318,6 @@ public class SystemActions extends SystemUI {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleToggleSplitScreen() {
|
||||
mStatusBar.toggleSplitScreen();
|
||||
}
|
||||
|
||||
private void handleLockScreen() {
|
||||
IWindowManager windowManager = WindowManagerGlobal.getWindowManagerService();
|
||||
|
||||
@@ -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";
|
||||
@@ -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) {
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,6 +62,7 @@ import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.SysuiBaseFragmentTest;
|
||||
import com.android.systemui.SysuiTestableContext;
|
||||
import com.android.systemui.accessibility.SystemActions;
|
||||
import com.android.systemui.assist.AssistManager;
|
||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||
import com.android.systemui.model.SysUiState;
|
||||
@@ -102,6 +103,8 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest {
|
||||
private Divider mDivider;
|
||||
@Mock
|
||||
private Recents mRecents;
|
||||
@Mock
|
||||
private SystemActions mSystemActions;
|
||||
|
||||
private AccessibilityManagerWrapper mAccessibilityWrapper =
|
||||
new AccessibilityManagerWrapper(mContext) {
|
||||
@@ -257,6 +260,7 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest {
|
||||
() -> mock(StatusBar.class),
|
||||
mock(ShadeController.class),
|
||||
mock(NotificationRemoteInputManager.class),
|
||||
mock(SystemActions.class),
|
||||
mHandler);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,6 @@ public class SystemActionPerformer {
|
||||
private final AccessibilityAction mLegacyNotificationsAction;
|
||||
private final AccessibilityAction mLegacyQuickSettingsAction;
|
||||
private final AccessibilityAction mLegacyPowerDialogAction;
|
||||
private final AccessibilityAction mLegacyToggleSplitScreenAction;
|
||||
private final AccessibilityAction mLegacyLockScreenAction;
|
||||
private final AccessibilityAction mLegacyTakeScreenshotAction;
|
||||
|
||||
@@ -142,10 +141,6 @@ public class SystemActionPerformer {
|
||||
AccessibilityService.GLOBAL_ACTION_POWER_DIALOG,
|
||||
mContext.getResources().getString(
|
||||
R.string.accessibility_system_action_power_dialog_label));
|
||||
mLegacyToggleSplitScreenAction = new AccessibilityAction(
|
||||
AccessibilityService.GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN,
|
||||
mContext.getResources().getString(
|
||||
R.string.accessibility_system_action_toggle_split_screen_label));
|
||||
mLegacyLockScreenAction = new AccessibilityAction(
|
||||
AccessibilityService.GLOBAL_ACTION_LOCK_SCREEN,
|
||||
mContext.getResources().getString(
|
||||
@@ -234,10 +229,6 @@ public class SystemActionPerformer {
|
||||
AccessibilityService.GLOBAL_ACTION_POWER_DIALOG)) {
|
||||
systemActions.add(mLegacyPowerDialogAction);
|
||||
}
|
||||
if (!mRegisteredSystemActions.containsKey(
|
||||
AccessibilityService.GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN)) {
|
||||
systemActions.add(mLegacyToggleSplitScreenAction);
|
||||
}
|
||||
if (!mRegisteredSystemActions.containsKey(
|
||||
AccessibilityService.GLOBAL_ACTION_LOCK_SCREEN)) {
|
||||
systemActions.add(mLegacyLockScreenAction);
|
||||
|
||||
@@ -67,7 +67,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class SystemActionPerformerTest {
|
||||
private static final int LATCH_TIMEOUT_MS = 500;
|
||||
private static final int LEGACY_SYSTEM_ACTION_COUNT = 9;
|
||||
private static final int LEGACY_SYSTEM_ACTION_COUNT = 8;
|
||||
private static final int NEW_ACTION_ID = 20;
|
||||
private static final String LABEL_1 = "label1";
|
||||
private static final String LABEL_2 = "label2";
|
||||
|
||||
Reference in New Issue
Block a user