• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package android.view.accessibility;
18 
19 import android.accessibilityservice.AccessibilityServiceInfo;
20 import android.content.Context;
21 import android.content.pm.ServiceInfo;
22 import android.view.IWindow;
23 import android.view.View;
24 
25 import java.util.Collections;
26 import java.util.List;
27 
28 /**
29  * System level service that serves as an event dispatch for {@link AccessibilityEvent}s.
30  * Such events are generated when something notable happens in the user interface,
31  * for example an {@link android.app.Activity} starts, the focus or selection of a
32  * {@link android.view.View} changes etc. Parties interested in handling accessibility
33  * events implement and register an accessibility service which extends
34  * {@link android.accessibilityservice.AccessibilityService}.
35  *
36  * @see AccessibilityEvent
37  * @see android.accessibilityservice.AccessibilityService
38  * @see android.content.Context#getSystemService
39  */
40 public final class AccessibilityManager {
41     private static AccessibilityManager sInstance = new AccessibilityManager();
42 
43     /**
44      * Listener for the accessibility state.
45      */
46     public interface AccessibilityStateChangeListener {
47 
48         /**
49          * Called back on change in the accessibility state.
50          *
51          * @param enabled Whether accessibility is enabled.
52          */
onAccessibilityStateChanged(boolean enabled)53         public void onAccessibilityStateChanged(boolean enabled);
54     }
55 
56     /**
57      * Get an AccessibilityManager instance (create one if necessary).
58      *
59      * @hide
60      */
getInstance(Context context)61     public static AccessibilityManager getInstance(Context context) {
62         return sInstance;
63     }
64 
65     /**
66      * Create an instance.
67      *
68      * @param context A {@link Context}.
69      */
AccessibilityManager()70     private AccessibilityManager() {
71     }
72 
73     /**
74      * Returns if the {@link AccessibilityManager} is enabled.
75      *
76      * @return True if this {@link AccessibilityManager} is enabled, false otherwise.
77      */
isEnabled()78     public boolean isEnabled() {
79         return false;
80     }
81 
82     /**
83      * Sends an {@link AccessibilityEvent}. If this {@link AccessibilityManager} is not
84      * enabled the call is a NOOP.
85      *
86      * @param event The {@link AccessibilityEvent}.
87      *
88      * @throws IllegalStateException if a client tries to send an {@link AccessibilityEvent}
89      *         while accessibility is not enabled.
90      */
sendAccessibilityEvent(AccessibilityEvent event)91     public void sendAccessibilityEvent(AccessibilityEvent event) {
92     }
93 
94     /**
95      * Requests interruption of the accessibility feedback from all accessibility services.
96      */
interrupt()97     public void interrupt() {
98     }
99 
100     /**
101      * Returns the {@link ServiceInfo}s of the installed accessibility services.
102      *
103      * @return An unmodifiable list with {@link ServiceInfo}s.
104      */
getAccessibilityServiceList()105     public List<ServiceInfo> getAccessibilityServiceList() {
106         // normal implementation does this in some case, so let's do the same
107         // (unmodifiableList wrapped around null).
108         List<ServiceInfo> services = null;
109         return Collections.unmodifiableList(services);
110     }
111 
getInstalledAccessibilityServiceList()112     public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList() {
113         // normal implementation does this in some case, so let's do the same
114         // (unmodifiableList wrapped around null).
115         List<AccessibilityServiceInfo> services = null;
116         return Collections.unmodifiableList(services);
117     }
118 
addAccessibilityStateChangeListener( AccessibilityStateChangeListener listener)119     public boolean addAccessibilityStateChangeListener(
120             AccessibilityStateChangeListener listener) {
121         return true;
122     }
123 
removeAccessibilityStateChangeListener( AccessibilityStateChangeListener listener)124     public boolean removeAccessibilityStateChangeListener(
125             AccessibilityStateChangeListener listener) {
126         return true;
127     }
128 
addAccessibilityInteractionConnection(IWindow windowToken, IAccessibilityInteractionConnection connection)129     public int addAccessibilityInteractionConnection(IWindow windowToken,
130             IAccessibilityInteractionConnection connection) {
131         return View.NO_ID;
132     }
133 
removeAccessibilityInteractionConnection(IWindow windowToken)134     public void removeAccessibilityInteractionConnection(IWindow windowToken) {
135     }
136 
137 }
138