Merge "Exposing some accessibility methods and state to be used in Launcher" into qt-dev

am: 389b4d9033

Change-Id: Ic124f387ba43f08b1a644be090cc02a73025d80c
This commit is contained in:
Sunny Goyal
2019-04-24 20:17:25 -07:00
committed by android-build-merger
4 changed files with 84 additions and 42 deletions

View File

@@ -72,17 +72,6 @@ interface ISystemUiProxy {
*/
void onStatusBarMotionEvent(in MotionEvent event) = 9;
/**
* Get the corner radius of windows in pixels.
*/
float getWindowCornerRadius() = 10;
/**
* If device supports live rounded corners on windows.
* This might be turned off for performance reasons
*/
boolean supportsRoundedCornersOnWindows() = 11;
/**
* Proxies the assistant gesture's progress started from navigation bar.
*/
@@ -97,4 +86,14 @@ interface ISystemUiProxy {
* Creates a new gesture monitor
*/
Bundle monitorGestureInput(String name, int displayId) = 14;
/**
* Notifies that the accessibility button in the system's navigation area has been clicked
*/
void notifyAccessibilityButtonClicked(int displayId) = 15;
/**
* Notifies that the accessibility button in the system's navigation area has been long clicked
*/
void notifyAccessibilityButtonLongClicked() = 16;
}

View File

@@ -52,11 +52,16 @@ public class QuickStepContract {
public static final int SYSUI_STATE_NAV_BAR_HIDDEN = 1 << 1;
public static final int SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED = 1 << 2;
public static final int SYSUI_STATE_BOUNCER_SHOWING = 1 << 3;
public static final int SYSUI_STATE_A11Y_BUTTON_CLICKABLE = 1 << 4;
public static final int SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE = 1 << 5;
@Retention(RetentionPolicy.SOURCE)
@IntDef({SYSUI_STATE_SCREEN_PINNING,
SYSUI_STATE_NAV_BAR_HIDDEN,
SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED
SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED,
SYSUI_STATE_BOUNCER_SHOWING,
SYSUI_STATE_A11Y_BUTTON_CLICKABLE,
SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE
})
public @interface SystemUiStateFlags {}

View File

@@ -54,6 +54,7 @@ import android.os.UserHandle;
import android.util.Log;
import android.view.InputMonitor;
import android.view.MotionEvent;
import android.view.accessibility.AccessibilityManager;
import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.systemui.Dependency;
@@ -126,6 +127,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
private ISystemUiProxy mSysUiProxy = new ISystemUiProxy.Stub() {
@Override
public void startScreenPinning(int taskId) {
if (!verifyCaller("startScreenPinning")) {
return;
@@ -144,6 +146,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
}
@Override
public void onStatusBarMotionEvent(MotionEvent event) {
if (!verifyCaller("onStatusBarMotionEvent")) {
return;
@@ -172,6 +175,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
}
@Override
public void onSplitScreenInvoked() {
if (!verifyCaller("onSplitScreenInvoked")) {
return;
@@ -187,6 +191,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
}
@Override
public void onOverviewShown(boolean fromHome) {
if (!verifyCaller("onOverviewShown")) {
return;
@@ -203,6 +208,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
}
@Override
public void setInteractionState(@InteractionType int flags) {
if (!verifyCaller("setInteractionState")) {
return;
@@ -223,6 +229,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
}
@Override
public Rect getNonMinimizedSplitScreenSecondaryBounds() {
if (!verifyCaller("getNonMinimizedSplitScreenSecondaryBounds")) {
return null;
@@ -239,6 +246,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
}
@Override
public void setBackButtonAlpha(float alpha, boolean animate) {
if (!verifyCaller("setBackButtonAlpha")) {
return;
@@ -254,30 +262,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
}
public float getWindowCornerRadius() {
if (!verifyCaller("getWindowCornerRadius")) {
return 0;
}
long token = Binder.clearCallingIdentity();
try {
return mWindowCornerRadius;
} finally {
Binder.restoreCallingIdentity(token);
}
}
public boolean supportsRoundedCornersOnWindows() {
if (!verifyCaller("supportsRoundedCornersOnWindows")) {
return false;
}
long token = Binder.clearCallingIdentity();
try {
return mSupportsRoundedCornersOnWindows;
} finally {
Binder.restoreCallingIdentity(token);
}
}
@Override
public void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {
if (!verifyCaller("onAssistantProgress")) {
return;
@@ -290,6 +275,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
}
@Override
public void startAssistant(Bundle bundle) {
if (!verifyCaller("startAssistant")) {
return;
@@ -302,6 +288,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
}
@Override
public Bundle monitorGestureInput(String name, int displayId) {
if (!verifyCaller("monitorGestureInput")) {
return null;
@@ -318,6 +305,35 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
}
@Override
public void notifyAccessibilityButtonClicked(int displayId) {
if (!verifyCaller("notifyAccessibilityButtonClicked")) {
return;
}
long token = Binder.clearCallingIdentity();
try {
AccessibilityManager.getInstance(mContext)
.notifyAccessibilityButtonClicked(displayId);
} finally {
Binder.restoreCallingIdentity(token);
}
}
@Override
public void notifyAccessibilityButtonLongClicked() {
if (!verifyCaller("notifyAccessibilityButtonLongClicked")) {
return;
}
long token = Binder.clearCallingIdentity();
try {
Intent intent = new Intent(AccessibilityManager.ACTION_CHOOSE_ACCESSIBILITY_BUTTON);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
mContext.startActivityAsUser(intent, UserHandle.CURRENT);
} finally {
Binder.restoreCallingIdentity(token);
}
}
private boolean verifyCaller(String reason) {
final int callerId = Binder.getCallingUserHandle().getIdentifier();
if (callerId != mCurrentBoundedUserId) {
@@ -515,6 +531,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
? SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED : 0;
mSysUiStateFlags |= bouncerShowing
? SYSUI_STATE_BOUNCER_SHOWING : 0;
mSysUiStateFlags |= navBarFragment != null ? navBarFragment.getA11yButtonState(null) : 0;
notifySystemUiStateFlags(mSysUiStateFlags);
}

View File

@@ -24,6 +24,8 @@ import static android.app.StatusBarManager.windowStateToString;
import static com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
import static com.android.systemui.shared.system.NavigationBarCompat.InteractionType;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NAV_BAR_HIDDEN;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT;
@@ -867,6 +869,25 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
}
private void updateAccessibilityServicesState(AccessibilityManager accessibilityManager) {
boolean[] feedbackEnabled = new boolean[1];
int flags = getA11yButtonState(feedbackEnabled);
mNavigationBarView.getRotateSuggestionButton()
.setAccessibilityFeedbackEnabled(feedbackEnabled[0]);
boolean clickable = (flags & SYSUI_STATE_A11Y_BUTTON_CLICKABLE) != 0;
boolean longClickable = (flags & SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE) != 0;
mNavigationBarView.setAccessibilityButtonState(clickable, longClickable);
mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_A11Y_BUTTON_CLICKABLE, clickable);
mOverviewProxyService.setSystemUiStateFlag(
SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE, longClickable);
}
/**
* Returns the system UI flags corresponding the the current accessibility button state
* @param outFeedbackEnabled if non-null, sets it to true if accessibility feedback is enabled.
*/
public int getA11yButtonState(@Nullable boolean[] outFeedbackEnabled) {
int requestingServices = 0;
try {
if (Settings.Secure.getIntForUser(mContentResolver,
@@ -881,7 +902,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
// AccessibilityManagerService resolves services for the current user since the local
// AccessibilityManager is created from a Context with the INTERACT_ACROSS_USERS permission
final List<AccessibilityServiceInfo> services =
accessibilityManager.getEnabledAccessibilityServiceList(
mAccessibilityManager.getEnabledAccessibilityServiceList(
AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
for (int i = services.size() - 1; i >= 0; --i) {
AccessibilityServiceInfo info = services.get(i);
@@ -895,12 +916,12 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
}
}
mNavigationBarView.getRotateSuggestionButton()
.setAccessibilityFeedbackEnabled(feedbackEnabled);
if (outFeedbackEnabled != null) {
outFeedbackEnabled[0] = feedbackEnabled;
}
final boolean showAccessibilityButton = requestingServices >= 1;
final boolean targetSelection = requestingServices >= 2;
mNavigationBarView.setAccessibilityButtonState(showAccessibilityButton, targetSelection);
return (requestingServices >= 1 ? SYSUI_STATE_A11Y_BUTTON_CLICKABLE : 0)
| (requestingServices >= 2 ? SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE : 0);
}
private void sendAssistantAvailability(boolean available) {