summaryrefslogtreecommitdiff
path: root/core/java/android/view/InputDevice.java
diff options
context:
space:
mode:
authorChris Ye <lzye@google.com>2021-01-06 18:42:54 -0800
committerChris Ye <lzye@google.com>2021-02-22 16:06:35 -0800
commitcbb480c25e1757c7484e23f4f679a0a00508ea9c (patch)
treedf103a68560f3807d1747f07e3675d7a0f2a953c /core/java/android/view/InputDevice.java
parent4dd2f7f838f37d399295765cc9e7d02e2ef8762f (diff)
Support input device lights manager feature in frameworks.
Add lights manager support to input frameworks. Bug: 161633625 Test: atest LightsManagerTest, atest InputDeviceLightsManagerTest Change-Id: Ic6c701cad84f277325583c77195592d96d9296b8
Diffstat (limited to 'core/java/android/view/InputDevice.java')
-rw-r--r--core/java/android/view/InputDevice.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java
index 59e493191711..fafb885c58e0 100644
--- a/core/java/android/view/InputDevice.java
+++ b/core/java/android/view/InputDevice.java
@@ -26,6 +26,7 @@ import android.hardware.Battery;
import android.hardware.SensorManager;
import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.InputManager;
+import android.hardware.lights.LightsManager;
import android.os.Build;
import android.os.NullVibrator;
import android.os.Parcel;
@@ -89,6 +90,9 @@ public final class InputDevice implements Parcelable {
@GuardedBy("mMotionRanges")
private Battery mBattery;
+ @GuardedBy("mMotionRanges")
+ private LightsManager mLightsManager;
+
/**
* A mask for input source classes.
*
@@ -859,6 +863,21 @@ public final class InputDevice implements Parcelable {
}
/**
+ * Gets the lights manager associated with the device, if there is one.
+ * Even if the device does not have lights, the result is never null.
+ * Use {@link LightsManager#getLights} to determine whether any lights is
+ * present.
+ *
+ * @return The lights manager associated with the device, never null.
+ */
+ public @NonNull LightsManager getLightsManager() {
+ if (mLightsManager == null) {
+ mLightsManager = InputManager.getInstance().getInputDeviceLightsManager(mId);
+ }
+ return mLightsManager;
+ }
+
+ /**
* Gets the sensor manager service associated with the input device.
* Even if the device does not have a sensor, the result is never null.
* Use {@link SensorManager#getSensorList} to get a full list of all supported sensors.