1/* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.view.accessibility; 18 19import android.accessibilityservice.AccessibilityServiceInfo; 20import android.annotation.NonNull; 21import android.content.Context; 22import android.content.pm.ServiceInfo; 23import android.view.IWindow; 24import android.view.View; 25 26import java.util.Collections; 27import java.util.List; 28 29/** 30 * System level service that serves as an event dispatch for {@link AccessibilityEvent}s. 31 * Such events are generated when something notable happens in the user interface, 32 * for example an {@link android.app.Activity} starts, the focus or selection of a 33 * {@link android.view.View} changes etc. Parties interested in handling accessibility 34 * events implement and register an accessibility service which extends 35 * {@code android.accessibilityservice.AccessibilityService}. 36 * 37 * @see AccessibilityEvent 38 * @see android.content.Context#getSystemService 39 */ 40@SuppressWarnings("UnusedDeclaration") 41public final class AccessibilityManager { 42 43 private static AccessibilityManager sInstance = new AccessibilityManager(null, null, 0); 44 45 46 /** 47 * Listener for the accessibility state. 48 */ 49 public interface AccessibilityStateChangeListener { 50 51 /** 52 * Called back on change in the accessibility state. 53 * 54 * @param enabled Whether accessibility is enabled. 55 */ 56 public void onAccessibilityStateChanged(boolean enabled); 57 } 58 59 /** 60 * Listener for the system touch exploration state. To listen for changes to 61 * the touch exploration state on the device, implement this interface and 62 * register it with the system by calling 63 * {@link #addTouchExplorationStateChangeListener}. 64 */ 65 public interface TouchExplorationStateChangeListener { 66 67 /** 68 * Called when the touch exploration enabled state changes. 69 * 70 * @param enabled Whether touch exploration is enabled. 71 */ 72 public void onTouchExplorationStateChanged(boolean enabled); 73 } 74 75 /** 76 * Listener for the system high text contrast state. To listen for changes to 77 * the high text contrast state on the device, implement this interface and 78 * register it with the system by calling 79 * {@link #addHighTextContrastStateChangeListener}. 80 */ 81 public interface HighTextContrastChangeListener { 82 83 /** 84 * Called when the high text contrast enabled state changes. 85 * 86 * @param enabled Whether high text contrast is enabled. 87 */ 88 public void onHighTextContrastStateChanged(boolean enabled); 89 } 90 91 private final IAccessibilityManagerClient.Stub mClient = 92 new IAccessibilityManagerClient.Stub() { 93 public void setState(int state) { 94 } 95 96 public void notifyServicesStateChanged() { 97 } 98 99 public void setRelevantEventTypes(int eventTypes) { 100 } 101 }; 102 103 /** 104 * Get an AccessibilityManager instance (create one if necessary). 105 * 106 */ 107 public static AccessibilityManager getInstance(Context context) { 108 return sInstance; 109 } 110 111 /** 112 * Create an instance. 113 * 114 * @param context A {@link Context}. 115 */ 116 public AccessibilityManager(Context context, IAccessibilityManager service, int userId) { 117 } 118 119 public IAccessibilityManagerClient getClient() { 120 return mClient; 121 } 122 123 /** 124 * Returns if the {@link AccessibilityManager} is enabled. 125 * 126 * @return True if this {@link AccessibilityManager} is enabled, false otherwise. 127 */ 128 public boolean isEnabled() { 129 return false; 130 } 131 132 /** 133 * Returns if the touch exploration in the system is enabled. 134 * 135 * @return True if touch exploration is enabled, false otherwise. 136 */ 137 public boolean isTouchExplorationEnabled() { 138 return true; 139 } 140 141 /** 142 * Returns if the high text contrast in the system is enabled. 143 * <p> 144 * <strong>Note:</strong> You need to query this only if you application is 145 * doing its own rendering and does not rely on the platform rendering pipeline. 146 * </p> 147 * 148 */ 149 public boolean isHighTextContrastEnabled() { 150 return false; 151 } 152 153 /** 154 * Sends an {@link AccessibilityEvent}. 155 */ 156 public void sendAccessibilityEvent(AccessibilityEvent event) { 157 } 158 159 /** 160 * Requests interruption of the accessibility feedback from all accessibility services. 161 */ 162 public void interrupt() { 163 } 164 165 /** 166 * Returns the {@link ServiceInfo}s of the installed accessibility services. 167 * 168 * @return An unmodifiable list with {@link ServiceInfo}s. 169 */ 170 @Deprecated 171 public List<ServiceInfo> getAccessibilityServiceList() { 172 return Collections.emptyList(); 173 } 174 175 public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList() { 176 return Collections.emptyList(); 177 } 178 179 /** 180 * Returns the {@link AccessibilityServiceInfo}s of the enabled accessibility services 181 * for a given feedback type. 182 * 183 * @param feedbackTypeFlags The feedback type flags. 184 * @return An unmodifiable list with {@link AccessibilityServiceInfo}s. 185 * 186 * @see AccessibilityServiceInfo#FEEDBACK_AUDIBLE 187 * @see AccessibilityServiceInfo#FEEDBACK_GENERIC 188 * @see AccessibilityServiceInfo#FEEDBACK_HAPTIC 189 * @see AccessibilityServiceInfo#FEEDBACK_SPOKEN 190 * @see AccessibilityServiceInfo#FEEDBACK_VISUAL 191 */ 192 public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList( 193 int feedbackTypeFlags) { 194 return Collections.emptyList(); 195 } 196 197 /** 198 * Registers an {@link AccessibilityStateChangeListener} for changes in 199 * the global accessibility state of the system. 200 * 201 * @param listener The listener. 202 * @return True if successfully registered. 203 */ 204 public boolean addAccessibilityStateChangeListener( 205 AccessibilityStateChangeListener listener) { 206 return true; 207 } 208 209 public boolean removeAccessibilityStateChangeListener( 210 AccessibilityStateChangeListener listener) { 211 return true; 212 } 213 214 /** 215 * Registers a {@link TouchExplorationStateChangeListener} for changes in 216 * the global touch exploration state of the system. 217 * 218 * @param listener The listener. 219 * @return True if successfully registered. 220 */ 221 public boolean addTouchExplorationStateChangeListener( 222 @NonNull TouchExplorationStateChangeListener listener) { 223 return true; 224 } 225 226 /** 227 * Unregisters a {@link TouchExplorationStateChangeListener}. 228 * 229 * @param listener The listener. 230 * @return True if successfully unregistered. 231 */ 232 public boolean removeTouchExplorationStateChangeListener( 233 @NonNull TouchExplorationStateChangeListener listener) { 234 return true; 235 } 236 237 /** 238 * Registers a {@link HighTextContrastChangeListener} for changes in 239 * the global high text contrast state of the system. 240 * 241 * @param listener The listener. 242 * @return True if successfully registered. 243 * 244 */ 245 public boolean addHighTextContrastStateChangeListener( 246 @NonNull HighTextContrastChangeListener listener) { 247 return true; 248 } 249 250 /** 251 * Unregisters a {@link HighTextContrastChangeListener}. 252 * 253 * @param listener The listener. 254 * @return True if successfully unregistered. 255 * 256 */ 257 public boolean removeHighTextContrastStateChangeListener( 258 @NonNull HighTextContrastChangeListener listener) { 259 return true; 260 } 261 262 /** 263 * Sets the current state and notifies listeners, if necessary. 264 * 265 * @param stateFlags The state flags. 266 */ 267 private void setStateLocked(int stateFlags) { 268 } 269 270 public int addAccessibilityInteractionConnection(IWindow windowToken, 271 IAccessibilityInteractionConnection connection) { 272 return View.NO_ID; 273 } 274 275 public void removeAccessibilityInteractionConnection(IWindow windowToken) { 276 } 277 278} 279