• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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 com.android.server.input;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.UserIdInt;
22 import android.graphics.PointF;
23 import android.hardware.display.DisplayViewport;
24 import android.os.IBinder;
25 import android.view.InputChannel;
26 import android.view.inputmethod.InputMethodSubtype;
27 
28 import com.android.internal.inputmethod.InputMethodSubtypeHandle;
29 
30 import java.util.List;
31 
32 /**
33  * Input manager local system service interface.
34  *
35  * @hide Only for use within the system server.
36  */
37 public abstract class InputManagerInternal {
38 
39     /**
40      * Called by the display manager to set information about the displays as needed
41      * by the input system.  The input system must copy this information to retain it.
42      */
setDisplayViewports(List<DisplayViewport> viewports)43     public abstract void setDisplayViewports(List<DisplayViewport> viewports);
44 
45     /**
46      * Called by the power manager to tell the input manager whether it should start
47      * watching for wake events.
48      */
setInteractive(boolean interactive)49     public abstract void setInteractive(boolean interactive);
50 
51     /**
52      * Toggles Caps Lock state for input device with specific id.
53      *
54      * @param deviceId The id of input device.
55      */
toggleCapsLock(int deviceId)56     public abstract void toggleCapsLock(int deviceId);
57 
58     /**
59      * Set whether the input stack should deliver pulse gesture events when the device is asleep.
60      */
setPulseGestureEnabled(boolean enabled)61     public abstract void setPulseGestureEnabled(boolean enabled);
62 
63     /**
64      * Atomically transfers an active touch gesture from one window to another, as identified by
65      * their input channels.
66      *
67      * <p>Only the touch gesture that is currently being dispatched to a window associated with
68      * {@code fromChannelToken} will be effected. That window will no longer receive
69      * the touch gesture (i.e. it will receive {@link android.view.MotionEvent#ACTION_CANCEL}).
70      * A window associated with the {@code toChannelToken} will receive the rest of the gesture
71      * (i.e. beginning with {@link android.view.MotionEvent#ACTION_DOWN} or
72      * {@link android.view.MotionEvent#ACTION_POINTER_DOWN}).
73      *
74      * <p>Transferring touch gestures will have no impact on focused windows. If the {@code
75      * toChannelToken} window is focusable, this will not bring focus to that window.
76      *
77      * @param fromChannelToken The channel token of a window that has an active touch gesture.
78      * @param toChannelToken The channel token of the window that should receive the gesture in
79      *   place of the first.
80      * @return True if the transfer was successful. False if the specified windows don't exist, or
81      *   if the source window is not actively receiving a touch gesture at the time of the request.
82      */
transferTouchGesture(@onNull IBinder fromChannelToken, @NonNull IBinder toChannelToken)83     public abstract boolean transferTouchGesture(@NonNull IBinder fromChannelToken,
84             @NonNull IBinder toChannelToken);
85 
86     /**
87      * Gets the current position of the mouse cursor.
88      *
89      * Returns NaN-s as the coordinates if the cursor is not available.
90      */
getCursorPosition(int displayId)91     public abstract PointF getCursorPosition(int displayId);
92 
93     /**
94      * Enables or disables pointer acceleration for mouse movements.
95      *
96      * Note that this only affects pointer movements from mice (that is, pointing devices which send
97      * relative motions, including trackballs and pointing sticks), not from other pointer devices
98      * such as touchpads and styluses.
99      */
setMousePointerAccelerationEnabled(boolean enabled, int displayId)100     public abstract void setMousePointerAccelerationEnabled(boolean enabled, int displayId);
101 
102     /**
103      * Sets the eligibility of windows on a given display for pointer capture. If a display is
104      * marked ineligible, requests to enable pointer capture for windows on that display will be
105      * ignored.
106      */
setDisplayEligibilityForPointerCapture(int displayId, boolean isEligible)107     public abstract void setDisplayEligibilityForPointerCapture(int displayId, boolean isEligible);
108 
109     /** Sets the visibility of the cursor. */
setPointerIconVisible(boolean visible, int displayId)110     public abstract void setPointerIconVisible(boolean visible, int displayId);
111 
112     /** Registers the {@link LidSwitchCallback} to begin receiving notifications. */
registerLidSwitchCallback(@onNull LidSwitchCallback callbacks)113     public abstract void registerLidSwitchCallback(@NonNull LidSwitchCallback callbacks);
114 
115     /**
116      * Unregisters a {@link LidSwitchCallback callback} previously registered with
117      * {@link #registerLidSwitchCallback(LidSwitchCallback)}.
118      */
unregisterLidSwitchCallback(@onNull LidSwitchCallback callbacks)119     public abstract void unregisterLidSwitchCallback(@NonNull LidSwitchCallback callbacks);
120 
121     /**
122      * Notify the input manager that an IME connection is becoming active or is no longer active.
123      */
notifyInputMethodConnectionActive(boolean connectionIsActive)124     public abstract void notifyInputMethodConnectionActive(boolean connectionIsActive);
125 
126     /** Callback interface for notifications relating to the lid switch. */
127     public interface LidSwitchCallback {
128         /**
129          * This callback is invoked when the lid switch changes state. Will be triggered once on
130          * registration of the callback with a {@code whenNanos} of 0 and then on every subsequent
131          * change in lid switch state.
132          *
133          * @param whenNanos the time when the change occurred
134          * @param lidOpen true if the lid is open
135          */
notifyLidSwitchChanged(long whenNanos, boolean lidOpen)136         void notifyLidSwitchChanged(long whenNanos, boolean lidOpen);
137     }
138 
139     /** Create an {@link InputChannel} that is registered to InputDispatcher. */
createInputChannel(String inputChannelName)140     public abstract InputChannel createInputChannel(String inputChannelName);
141 
142     /**
143      * Pilfer pointers from the input channel with the given token so that ongoing gestures are
144      * canceled for all other channels.
145      */
pilferPointers(IBinder token)146     public abstract void pilferPointers(IBinder token);
147 
148     /**
149      * Called when the current input method and/or {@link InputMethodSubtype} is updated.
150      *
151      * @param userId User ID to be notified about.
152      * @param subtypeHandle A {@link InputMethodSubtypeHandle} corresponds to {@code subtype}.
153      * @param subtype A {@link InputMethodSubtype} object, or {@code null} when the current
154      *                {@link InputMethodSubtype} is not suitable for the physical keyboard layout
155      *                mapping.
156      * @see InputMethodSubtype#isSuitableForPhysicalKeyboardLayoutMapping()
157      */
onInputMethodSubtypeChangedForKeyboardLayoutMapping(@serIdInt int userId, @Nullable InputMethodSubtypeHandle subtypeHandle, @Nullable InputMethodSubtype subtype)158     public abstract void onInputMethodSubtypeChangedForKeyboardLayoutMapping(@UserIdInt int userId,
159             @Nullable InputMethodSubtypeHandle subtypeHandle,
160             @Nullable InputMethodSubtype subtype);
161 
162     /**
163      * Increments keyboard backlight level if the device has an associated keyboard backlight
164      * {@see Light.LIGHT_TYPE_KEYBOARD_BACKLIGHT}
165      */
incrementKeyboardBacklight(int deviceId)166     public abstract void incrementKeyboardBacklight(int deviceId);
167 
168     /**
169      * Decrements keyboard backlight level if the device has an associated keyboard backlight
170      * {@see Light.LIGHT_TYPE_KEYBOARD_BACKLIGHT}
171      */
decrementKeyboardBacklight(int deviceId)172     public abstract void decrementKeyboardBacklight(int deviceId);
173 
174     /**
175      * Add a runtime association between the input port and device type. Input ports are expected to
176      * be unique.
177      * @param inputPort The port of the input device.
178      * @param type The type of the device. E.g. "touchNavigation".
179      */
setTypeAssociation(@onNull String inputPort, @NonNull String type)180     public abstract void setTypeAssociation(@NonNull String inputPort, @NonNull String type);
181 
182     /**
183      * Removes a runtime association between the input device and type.
184      *
185      * @param inputPort The port of the input device.
186      */
unsetTypeAssociation(@onNull String inputPort)187     public abstract void unsetTypeAssociation(@NonNull String inputPort);
188 
189     /**
190      * Add a mapping from the input port and a keyboard layout, by unique id. Input
191      * ports are expected to be unique.
192      *
193      * @param inputPort   The port of the input device.
194      * @param languageTag the language of the input device as an IETF
195      *                    <a href="https://tools.ietf.org/html/bcp47">BCP-47</a>
196      *                    conformant tag.
197      * @param layoutType  the layout type such as "qwerty" or "azerty".
198      */
addKeyboardLayoutAssociation(@onNull String inputPort, @NonNull String languageTag, @NonNull String layoutType)199     public abstract void addKeyboardLayoutAssociation(@NonNull String inputPort,
200             @NonNull String languageTag, @NonNull String layoutType);
201 
202     /**
203      * Removes the mapping from input port to the keyboard layout identifier.
204      *
205      * @param inputPort The port of the input device.
206      */
removeKeyboardLayoutAssociation(@onNull String inputPort)207     public abstract void removeKeyboardLayoutAssociation(@NonNull String inputPort);
208 
209     /**
210      * Set whether stylus button reporting through motion events should be enabled.
211      *
212      * @param enabled When true, stylus buttons will not be reported through motion events.
213      */
setStylusButtonMotionEventsEnabled(boolean enabled)214     public abstract void setStylusButtonMotionEventsEnabled(boolean enabled);
215 
216     /**
217      * Notify whether any user activity occurred. This includes any input activity on any
218      * display, external peripherals, fingerprint sensor, etc.
219      */
notifyUserActivity()220     public abstract void notifyUserActivity();
221 
222     /**
223      * Get the device ID of the {@link InputDevice} that used most recently.
224      *
225      * @return the last used input device ID, or
226      *     {@link android.os.IInputConstants#INVALID_INPUT_DEVICE_ID} if no device has been used
227      *     since boot.
228      */
getLastUsedInputDeviceId()229     public abstract int getLastUsedInputDeviceId();
230 }
231