Merge "Revert "Don't generate irrelevant a11y events - framework""
diff --git a/api/current.txt b/api/current.txt
index f16ff14..e968841 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -47970,7 +47970,6 @@
method public void interrupt();
method public static boolean isAccessibilityButtonSupported();
method public boolean isEnabled();
- method public boolean isObservedEventType(int);
method public boolean isTouchExplorationEnabled();
method public void removeAccessibilityRequestPreparer(android.view.accessibility.AccessibilityRequestPreparer);
method public boolean removeAccessibilityStateChangeListener(android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener);
diff --git a/api/test-current.txt b/api/test-current.txt
index 7e0731a..5cbefb2 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -941,15 +941,6 @@
package android.view.accessibility {
- public final class AccessibilityManager {
- method public void addAccessibilityServicesStateChangeListener(android.view.accessibility.AccessibilityManager.AccessibilityServicesStateChangeListener, android.os.Handler);
- method public void removeAccessibilityServicesStateChangeListener(android.view.accessibility.AccessibilityManager.AccessibilityServicesStateChangeListener);
- }
-
- public static abstract interface AccessibilityManager.AccessibilityServicesStateChangeListener {
- method public abstract void onAccessibilityServicesStateChanged(android.view.accessibility.AccessibilityManager);
- }
-
public class AccessibilityNodeInfo implements android.os.Parcelable {
method public static void setNumInstancesInUseCounter(java.util.concurrent.atomic.AtomicInteger);
}
diff --git a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java
index e0d60cd..06a9b06 100644
--- a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java
+++ b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java
@@ -16,8 +16,6 @@
package android.accessibilityservice;
-import static android.content.pm.PackageManager.FEATURE_FINGERPRINT;
-
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -49,6 +47,8 @@
import java.util.Collections;
import java.util.List;
+import static android.content.pm.PackageManager.FEATURE_FINGERPRINT;
+
/**
* This class describes an {@link AccessibilityService}. The system notifies an
* {@link AccessibilityService} for {@link android.view.accessibility.AccessibilityEvent}s
@@ -554,7 +554,7 @@
}
/**
- * Updates the properties that an AccessibilityService can change dynamically.
+ * Updates the properties that an AccessibilitySerivice can change dynamically.
*
* @param other The info from which to update the properties.
*
diff --git a/core/java/android/inputmethodservice/KeyboardView.java b/core/java/android/inputmethodservice/KeyboardView.java
index 7836cd0..13b9206 100644
--- a/core/java/android/inputmethodservice/KeyboardView.java
+++ b/core/java/android/inputmethodservice/KeyboardView.java
@@ -21,16 +21,18 @@
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
-import android.graphics.Paint.Align;
import android.graphics.PorterDuff;
import android.graphics.Rect;
-import android.graphics.Region.Op;
import android.graphics.Typeface;
+import android.graphics.Paint.Align;
+import android.graphics.Region.Op;
import android.graphics.drawable.Drawable;
import android.inputmethodservice.Keyboard.Key;
import android.media.AudioManager;
import android.os.Handler;
import android.os.Message;
+import android.os.UserHandle;
+import android.provider.Settings;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.GestureDetector;
@@ -984,9 +986,6 @@
private void sendAccessibilityEventForUnicodeCharacter(int eventType, int code) {
if (mAccessibilityManager.isEnabled()) {
- if (!mAccessibilityManager.isObservedEventType(eventType)) {
- return;
- }
AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
onInitializeAccessibilityEvent(event);
final String text;
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 0525ab1..345e300 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -7208,8 +7208,7 @@
* @param text The announcement text.
*/
public void announceForAccessibility(CharSequence text) {
- if (AccessibilityManager.getInstance(mContext).isObservedEventType(
- AccessibilityEvent.TYPE_ANNOUNCEMENT) && mParent != null) {
+ if (AccessibilityManager.getInstance(mContext).isEnabled() && mParent != null) {
AccessibilityEvent event = AccessibilityEvent.obtain(
AccessibilityEvent.TYPE_ANNOUNCEMENT);
onInitializeAccessibilityEvent(event);
@@ -10968,8 +10967,7 @@
if ((mPrivateFlags2 & PFLAG2_ACCESSIBILITY_FOCUSED) != 0) {
mPrivateFlags2 &= ~PFLAG2_ACCESSIBILITY_FOCUSED;
invalidate();
- if (AccessibilityManager.getInstance(mContext).isObservedEventType(
- AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED)) {
+ if (AccessibilityManager.getInstance(mContext).isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
event.setAction(action);
@@ -11794,8 +11792,7 @@
private void sendViewTextTraversedAtGranularityEvent(int action, int granularity,
int fromIndex, int toIndex) {
- if (mParent == null || !AccessibilityManager.getInstance(mContext).isObservedEventType(
- AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY)) {
+ if (mParent == null) {
return;
}
AccessibilityEvent event = AccessibilityEvent.obtain(
@@ -26185,8 +26182,7 @@
@Override
public void run() {
- if (AccessibilityManager.getInstance(mContext).isObservedEventType(
- AccessibilityEvent.TYPE_VIEW_SCROLLED)) {
+ if (AccessibilityManager.getInstance(mContext).isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(
AccessibilityEvent.TYPE_VIEW_SCROLLED);
event.setScrollDeltaX(mDeltaX);
diff --git a/core/java/android/view/accessibility/AccessibilityManager.java b/core/java/android/view/accessibility/AccessibilityManager.java
index 0375635..35f6acb 100644
--- a/core/java/android/view/accessibility/AccessibilityManager.java
+++ b/core/java/android/view/accessibility/AccessibilityManager.java
@@ -24,7 +24,6 @@
import android.annotation.Nullable;
import android.annotation.SdkConstant;
import android.annotation.SystemService;
-import android.annotation.TestApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -188,7 +187,6 @@
*
* @hide
*/
- @TestApi
public interface AccessibilityServicesStateChangeListener {
/**
@@ -454,18 +452,6 @@
}
/**
- * Returns whether there are observers registered for this event type. If
- * this method returns false you shuold not generate events of this type
- * to conserve resources.
- *
- * @param type The event type.
- * @return Whether the event is being observed.
- */
- public boolean isObservedEventType(@AccessibilityEvent.EventType int type) {
- return mIsEnabled && (mRelevantEventTypes & type) != 0;
- }
-
- /**
* Requests feedback interruption from all accessibility services.
*/
public void interrupt() {
@@ -697,7 +683,6 @@
* for a callback on the process's main handler.
* @hide
*/
- @TestApi
public void addAccessibilityServicesStateChangeListener(
@NonNull AccessibilityServicesStateChangeListener listener, @Nullable Handler handler) {
synchronized (mLock) {
@@ -713,7 +698,6 @@
*
* @hide
*/
- @TestApi
public void removeAccessibilityServicesStateChangeListener(
@NonNull AccessibilityServicesStateChangeListener listener) {
// Final CopyOnWriteArrayList - no lock needed.
diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java
index b379280..4d3189e 100644
--- a/core/java/android/widget/NumberPicker.java
+++ b/core/java/android/widget/NumberPicker.java
@@ -1952,8 +1952,7 @@
CharSequence beforeText = mInputText.getText();
if (!text.equals(beforeText.toString())) {
mInputText.setText(text);
- if (AccessibilityManager.getInstance(mContext).isObservedEventType(
- AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED)) {
+ if (AccessibilityManager.getInstance(mContext).isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(
AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
mInputText.onInitializeAccessibilityEvent(event);
@@ -2613,7 +2612,7 @@
}
private void sendAccessibilityEventForVirtualText(int eventType) {
- if (AccessibilityManager.getInstance(mContext).isObservedEventType(eventType)) {
+ if (AccessibilityManager.getInstance(mContext).isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
mInputText.onInitializeAccessibilityEvent(event);
mInputText.onPopulateAccessibilityEvent(event);
@@ -2624,7 +2623,7 @@
private void sendAccessibilityEventForVirtualButton(int virtualViewId, int eventType,
String text) {
- if (AccessibilityManager.getInstance(mContext).isObservedEventType(eventType)) {
+ if (AccessibilityManager.getInstance(mContext).isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
event.setClassName(Button.class.getName());
event.setPackageName(mContext.getPackageName());
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 71532a7..d9bc51f 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -10836,10 +10836,6 @@
void sendAccessibilityEventTypeViewTextChanged(CharSequence beforeText,
int fromIndex, int removedCount, int addedCount) {
- if (!AccessibilityManager.getInstance(mContext).isObservedEventType(
- AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED)) {
- return;
- }
AccessibilityEvent event =
AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
event.setFromIndex(fromIndex);
diff --git a/core/java/android/widget/Toast.java b/core/java/android/widget/Toast.java
index bfde6ac..d807120 100644
--- a/core/java/android/widget/Toast.java
+++ b/core/java/android/widget/Toast.java
@@ -504,8 +504,7 @@
private void trySendAccessibilityEvent() {
AccessibilityManager accessibilityManager =
AccessibilityManager.getInstance(mView.getContext());
- if (!accessibilityManager.isObservedEventType(
- AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED)) {
+ if (!accessibilityManager.isEnabled()) {
return;
}
// treat toasts as notifications since they are used to
diff --git a/core/java/com/android/internal/widget/ExploreByTouchHelper.java b/core/java/com/android/internal/widget/ExploreByTouchHelper.java
index 759a41a..50ad547 100644
--- a/core/java/com/android/internal/widget/ExploreByTouchHelper.java
+++ b/core/java/com/android/internal/widget/ExploreByTouchHelper.java
@@ -186,9 +186,6 @@
}
final AccessibilityEvent event = createEvent(virtualViewId, eventType);
- if (event == null) {
- return false;
- }
return parent.requestSendAccessibilityEvent(mView, event);
}
@@ -243,9 +240,6 @@
if (parent != null) {
final AccessibilityEvent event = createEvent(virtualViewId,
AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
- if (event == null) {
- return;
- }
event.setContentChangeTypes(changeTypes);
parent.requestSendAccessibilityEvent(mView, event);
}
@@ -311,9 +305,6 @@
* the specified item.
*/
private AccessibilityEvent createEventForHost(int eventType) {
- if (!AccessibilityManager.getInstance(mContext).isObservedEventType(eventType)) {
- return null;
- }
final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
mView.onInitializeAccessibilityEvent(event);
@@ -334,9 +325,6 @@
* the specified item.
*/
private AccessibilityEvent createEventForChild(int virtualViewId, int eventType) {
- if (!AccessibilityManager.getInstance(mContext).isObservedEventType(eventType)) {
- return null;
- }
final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
event.setEnabled(true);
event.setClassName(DEFAULT_CLASS_NAME);
diff --git a/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java b/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java
index 0219db3..12f75bb 100644
--- a/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java
+++ b/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java
@@ -307,9 +307,8 @@
void sendAccessibilityEventTypeViewTextChanged(String beforeText, int fromIndex,
int removedCount, int addedCount) {
- if (AccessibilityManager.getInstance(mContext).isObservedEventType(
- AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED)
- && (isFocused() || isSelected() && isShown())) {
+ if (AccessibilityManager.getInstance(mContext).isEnabled() &&
+ (isFocused() || isSelected() && isShown())) {
AccessibilityEvent event =
AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
event.setFromIndex(fromIndex);
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
index 51175d1..2b48e0f 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
@@ -387,9 +387,7 @@
}
case MotionEvent.ACTION_HOVER_ENTER:
case MotionEvent.ACTION_HOVER_MOVE: {
- if (mAccessibilityManager.isObservedEventType(
- AccessibilityEvent.TYPE_VIEW_HOVER_ENTER)
- && !mSendingHoverAccessibilityEvents) {
+ if (mAccessibilityManager.isEnabled() && !mSendingHoverAccessibilityEvents) {
AccessibilityEvent event = AccessibilityEvent.obtain(
AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
event.setImportantForAccessibility(true);
@@ -402,9 +400,7 @@
break;
}
case MotionEvent.ACTION_HOVER_EXIT: {
- if (mAccessibilityManager.isObservedEventType(
- AccessibilityEvent.TYPE_VIEW_HOVER_EXIT)
- && mSendingHoverAccessibilityEvents) {
+ if (mAccessibilityManager.isEnabled() && mSendingHoverAccessibilityEvents) {
AccessibilityEvent event = AccessibilityEvent.obtain(
AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
event.setImportantForAccessibility(true);
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityClientConnection.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityClientConnection.java
index 22d922b..7e94d7b 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityClientConnection.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityClientConnection.java
@@ -20,7 +20,9 @@
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY;
+import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
+import android.accessibilityservice.GestureDescription;
import android.accessibilityservice.IAccessibilityServiceClient;
import android.accessibilityservice.IAccessibilityServiceConnection;
import android.annotation.NonNull;
@@ -47,6 +49,7 @@
import android.view.View;
import android.view.accessibility.AccessibilityCache;
import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityInteractionClient;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityWindowInfo;
import android.view.accessibility.IAccessibilityInteractionConnection;
@@ -62,7 +65,6 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -104,7 +106,7 @@
int mFeedbackType;
- final Set<String> mPackageNames = new HashSet<>();
+ Set<String> mPackageNames = new HashSet<>();
boolean mIsDefault;
@@ -282,98 +284,40 @@
return true;
}
- boolean setDynamicallyConfigurableProperties(AccessibilityServiceInfo info) {
- boolean somethingChanged = false;
-
- if (mEventTypes != info.eventTypes) {
- mEventTypes = info.eventTypes;
- somethingChanged = true;
+ public void setDynamicallyConfigurableProperties(AccessibilityServiceInfo info) {
+ mEventTypes = info.eventTypes;
+ mFeedbackType = info.feedbackType;
+ String[] packageNames = info.packageNames;
+ if (packageNames != null) {
+ mPackageNames.addAll(Arrays.asList(packageNames));
}
-
- if (mFeedbackType != info.feedbackType) {
- mFeedbackType = info.feedbackType;
- somethingChanged = true;
- }
-
- final String[] oldPackageNames = mPackageNames.toArray(new String[mPackageNames.size()]);
- if (!Arrays.equals(oldPackageNames, info.packageNames)) {
- mPackageNames.clear();
- if (info.packageNames != null) {
- Collections.addAll(mPackageNames, info.packageNames);
- }
- somethingChanged = true;
- }
-
- if (mNotificationTimeout != info.notificationTimeout) {
- mNotificationTimeout = info.notificationTimeout;
- somethingChanged = true;
- }
-
- final boolean newIsDefault = (info.flags & DEFAULT) != 0;
- if (mIsDefault != newIsDefault) {
- mIsDefault = newIsDefault;
- somethingChanged = true;
- }
+ mNotificationTimeout = info.notificationTimeout;
+ mIsDefault = (info.flags & DEFAULT) != 0;
if (supportsFlagForNotImportantViews(info)) {
- somethingChanged |= updateFetchFlag(info.flags,
- AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS);
- }
-
- somethingChanged |= updateFetchFlag(info.flags,
- AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS);
-
- final boolean newRequestTouchExplorationMode = (info.flags
- & AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE) != 0;
- if (mRequestTouchExplorationMode != newRequestTouchExplorationMode) {
- mRequestTouchExplorationMode = newRequestTouchExplorationMode;
- somethingChanged = true;
- }
-
- final boolean newRequestFilterKeyEvents = (info.flags
- & AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS) != 0;
- if (mRequestFilterKeyEvents != newRequestFilterKeyEvents) {
- mRequestFilterKeyEvents = newRequestFilterKeyEvents;
- somethingChanged = true;
- }
-
- final boolean newRetrieveInteractiveWindows = (info.flags
- & AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS) != 0;
- if (mRetrieveInteractiveWindows != newRetrieveInteractiveWindows) {
- mRetrieveInteractiveWindows = newRetrieveInteractiveWindows;
- somethingChanged = true;
- }
-
- final boolean newCaptureFingerprintGestures = (info.flags
- & AccessibilityServiceInfo.FLAG_REQUEST_FINGERPRINT_GESTURES) != 0;
- if (mCaptureFingerprintGestures != newCaptureFingerprintGestures) {
- mCaptureFingerprintGestures = newCaptureFingerprintGestures;
- somethingChanged = true;
- }
-
- final boolean newRequestAccessibilityButton = (info.flags
- & AccessibilityServiceInfo.FLAG_REQUEST_ACCESSIBILITY_BUTTON) != 0;
- if (mRequestAccessibilityButton != newRequestAccessibilityButton) {
- mRequestAccessibilityButton = newRequestAccessibilityButton;
- somethingChanged = true;
- }
-
- return somethingChanged;
- }
-
- private boolean updateFetchFlag(int allFlags, int flagToUpdate) {
- if ((allFlags & flagToUpdate) != 0) {
- if ((mFetchFlags & flagToUpdate) == 0) {
- mFetchFlags |= flagToUpdate;
- return true;
+ if ((info.flags & AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) != 0) {
+ mFetchFlags |= AccessibilityNodeInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
+ } else {
+ mFetchFlags &= ~AccessibilityNodeInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
}
+ }
+
+ if ((info.flags & AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS) != 0) {
+ mFetchFlags |= AccessibilityNodeInfo.FLAG_REPORT_VIEW_IDS;
} else {
- if ((mFetchFlags & flagToUpdate) != 0) {
- mFetchFlags &= ~flagToUpdate;
- return true;
- }
+ mFetchFlags &= ~AccessibilityNodeInfo.FLAG_REPORT_VIEW_IDS;
}
- return false;
+
+ mRequestTouchExplorationMode = (info.flags
+ & AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE) != 0;
+ mRequestFilterKeyEvents = (info.flags
+ & AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS) != 0;
+ mRetrieveInteractiveWindows = (info.flags
+ & AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS) != 0;
+ mCaptureFingerprintGestures = (info.flags
+ & AccessibilityServiceInfo.FLAG_REQUEST_FINGERPRINT_GESTURES) != 0;
+ mRequestAccessibilityButton = (info.flags
+ & AccessibilityServiceInfo.FLAG_REQUEST_ACCESSIBILITY_BUTTON) != 0;
}
protected boolean supportsFlagForNotImportantViews(AccessibilityServiceInfo info) {
@@ -405,15 +349,14 @@
// If the XML manifest had data to configure the service its info
// should be already set. In such a case update only the dynamically
// configurable properties.
- final boolean serviceInfoChanged;
AccessibilityServiceInfo oldInfo = mAccessibilityServiceInfo;
if (oldInfo != null) {
oldInfo.updateDynamicallyConfigurableProperties(info);
- serviceInfoChanged = setDynamicallyConfigurableProperties(oldInfo);
+ setDynamicallyConfigurableProperties(oldInfo);
} else {
- serviceInfoChanged = setDynamicallyConfigurableProperties(info);
+ setDynamicallyConfigurableProperties(info);
}
- mSystemSupport.onClientChange(serviceInfoChanged);
+ mSystemSupport.onClientChange(true);
}
} finally {
Binder.restoreCallingIdentity(identity);
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index 8b5c85a7..3554448 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -2400,8 +2400,7 @@
private void announceNewUserIfNeeded() {
synchronized (mLock) {
UserState userState = getCurrentUserStateLocked();
- if (userState.isHandlingAccessibilityEvents()
- && userState.isObservedEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT)) {
+ if (userState.isHandlingAccessibilityEvents()) {
UserManager userManager = (UserManager) mContext.getSystemService(
Context.USER_SERVICE);
String message = mContext.getString(R.string.user_switched,
@@ -3158,21 +3157,13 @@
if (mWindowsForAccessibilityCallback == null) {
return;
}
- final int userId;
- synchronized (mLock) {
- userId = mCurrentUserId;
- final UserState userState = getUserStateLocked(userId);
- if (!userState.isObservedEventType(AccessibilityEvent.TYPE_WINDOWS_CHANGED)) {
- return;
- }
- }
final long identity = Binder.clearCallingIdentity();
try {
// Let the client know the windows changed.
AccessibilityEvent event = AccessibilityEvent.obtain(
AccessibilityEvent.TYPE_WINDOWS_CHANGED);
event.setEventTime(SystemClock.uptimeMillis());
- sendAccessibilityEvent(event, userId);
+ sendAccessibilityEvent(event, mCurrentUserId);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -3377,10 +3368,6 @@
mUserId = userId;
}
- public boolean isObservedEventType(@AccessibilityEvent.EventType int type) {
- return (mLastSentRelevantEventTypes & type) != 0;
- }
-
public int getClientState() {
int clientState = 0;
final boolean a11yEnabled = (mUiAutomationManager.isUiAutomationRunningLocked()
diff --git a/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java b/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java
index 62017e8..3419b80 100644
--- a/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java
+++ b/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java
@@ -791,7 +791,7 @@
*/
private void sendAccessibilityEvent(int type) {
AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(mContext);
- if (accessibilityManager.isObservedEventType(type)) {
+ if (accessibilityManager.isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(type);
event.setWindowId(mAms.getActiveWindowId());
accessibilityManager.sendAccessibilityEvent(event);
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index bec6fc2..cf01400 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -4743,8 +4743,7 @@
}
void sendAccessibilityEvent(Notification notification, CharSequence packageName) {
- if (!mAccessibilityManager.isObservedEventType(
- AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED)) {
+ if (!mAccessibilityManager.isEnabled()) {
return;
}