[go: nahoru, domu]

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
97    /**
98     * Get an AccessibilityManager instance (create one if necessary).
99     *
100     */
101    public static AccessibilityManager getInstance(Context context) {
102        return sInstance;
103    }
104
105    /**
106     * Create an instance.
107     *
108     * @param context A {@link Context}.
109     */
110    public AccessibilityManager(Context context, IAccessibilityManager service, int userId) {
111    }
112
113    public IAccessibilityManagerClient getClient() {
114        return mClient;
115    }
116
117    /**
118     * Returns if the {@link AccessibilityManager} is enabled.
119     *
120     * @return True if this {@link AccessibilityManager} is enabled, false otherwise.
121     */
122    public boolean isEnabled() {
123        return false;
124    }
125
126    /**
127     * Returns if the touch exploration in the system is enabled.
128     *
129     * @return True if touch exploration is enabled, false otherwise.
130     */
131    public boolean isTouchExplorationEnabled() {
132        return true;
133    }
134
135    /**
136     * Returns if the high text contrast in the system is enabled.
137     * <p>
138     * <strong>Note:</strong> You need to query this only if you application is
139     * doing its own rendering and does not rely on the platform rendering pipeline.
140     * </p>
141     *
142     */
143    public boolean isHighTextContrastEnabled() {
144        return false;
145    }
146
147    /**
148     * Sends an {@link AccessibilityEvent}.
149     */
150    public void sendAccessibilityEvent(AccessibilityEvent event) {
151    }
152
153    /**
154     * Requests interruption of the accessibility feedback from all accessibility services.
155     */
156    public void interrupt() {
157    }
158
159    /**
160     * Returns the {@link ServiceInfo}s of the installed accessibility services.
161     *
162     * @return An unmodifiable list with {@link ServiceInfo}s.
163     */
164    @Deprecated
165    public List<ServiceInfo> getAccessibilityServiceList() {
166        return Collections.emptyList();
167    }
168
169    public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList() {
170        return Collections.emptyList();
171    }
172
173    /**
174     * Returns the {@link AccessibilityServiceInfo}s of the enabled accessibility services
175     * for a given feedback type.
176     *
177     * @param feedbackTypeFlags The feedback type flags.
178     * @return An unmodifiable list with {@link AccessibilityServiceInfo}s.
179     *
180     * @see AccessibilityServiceInfo#FEEDBACK_AUDIBLE
181     * @see AccessibilityServiceInfo#FEEDBACK_GENERIC
182     * @see AccessibilityServiceInfo#FEEDBACK_HAPTIC
183     * @see AccessibilityServiceInfo#FEEDBACK_SPOKEN
184     * @see AccessibilityServiceInfo#FEEDBACK_VISUAL
185     */
186    public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList(
187            int feedbackTypeFlags) {
188        return Collections.emptyList();
189    }
190
191    /**
192     * Registers an {@link AccessibilityStateChangeListener} for changes in
193     * the global accessibility state of the system.
194     *
195     * @param listener The listener.
196     * @return True if successfully registered.
197     */
198    public boolean addAccessibilityStateChangeListener(
199            AccessibilityStateChangeListener listener) {
200        return true;
201    }
202
203    public boolean removeAccessibilityStateChangeListener(
204            AccessibilityStateChangeListener listener) {
205        return true;
206    }
207
208    /**
209     * Registers a {@link TouchExplorationStateChangeListener} for changes in
210     * the global touch exploration state of the system.
211     *
212     * @param listener The listener.
213     * @return True if successfully registered.
214     */
215    public boolean addTouchExplorationStateChangeListener(
216            @NonNull TouchExplorationStateChangeListener listener) {
217        return true;
218    }
219
220    /**
221     * Unregisters a {@link TouchExplorationStateChangeListener}.
222     *
223     * @param listener The listener.
224     * @return True if successfully unregistered.
225     */
226    public boolean removeTouchExplorationStateChangeListener(
227            @NonNull TouchExplorationStateChangeListener listener) {
228        return true;
229    }
230
231    /**
232     * Registers a {@link HighTextContrastChangeListener} for changes in
233     * the global high text contrast state of the system.
234     *
235     * @param listener The listener.
236     * @return True if successfully registered.
237     *
238     */
239    public boolean addHighTextContrastStateChangeListener(
240            @NonNull HighTextContrastChangeListener listener) {
241        return true;
242    }
243
244    /**
245     * Unregisters a {@link HighTextContrastChangeListener}.
246     *
247     * @param listener The listener.
248     * @return True if successfully unregistered.
249     *
250     */
251    public boolean removeHighTextContrastStateChangeListener(
252            @NonNull HighTextContrastChangeListener listener) {
253        return true;
254    }
255
256    /**
257     * Sets the current state and notifies listeners, if necessary.
258     *
259     * @param stateFlags The state flags.
260     */
261    private void setStateLocked(int stateFlags) {
262    }
263
264    public int addAccessibilityInteractionConnection(IWindow windowToken,
265            IAccessibilityInteractionConnection connection) {
266        return View.NO_ID;
267    }
268
269    public void removeAccessibilityInteractionConnection(IWindow windowToken) {
270    }
271
272}
273