diff options
| author | Philip Junker <philipjunker@google.com> | 2021-04-22 08:04:21 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-04-22 08:04:21 +0000 |
| commit | 463493f57ddd24e0a05bc0d0b6653057353b77a3 (patch) | |
| tree | a967b4efb761c930b5ad3e92e1ab48679a249449 /core/java/android | |
| parent | 3e0705d6e853296e218b0bcce55d62f97109202d (diff) | |
| parent | 275f9e2912f29bf6f6bdef95c66df8bdc413e133 (diff) | |
Merge "Add TestApi to suppress other LightsSession clients" into sc-dev
Diffstat (limited to 'core/java/android')
4 files changed, 42 insertions, 2 deletions
diff --git a/core/java/android/hardware/input/InputDeviceLightsManager.java b/core/java/android/hardware/input/InputDeviceLightsManager.java index a3b91a99fdb7..885df7be2510 100644 --- a/core/java/android/hardware/input/InputDeviceLightsManager.java +++ b/core/java/android/hardware/input/InputDeviceLightsManager.java @@ -81,6 +81,11 @@ class InputDeviceLightsManager extends LightsManager { return session; } + @Override + public @NonNull LightsSession openSession(int priority) { + throw new UnsupportedOperationException(); + } + /** * Encapsulates a session that can be used to control device lights and represents the lifetime * of the requests. diff --git a/core/java/android/hardware/lights/ILightsManager.aidl b/core/java/android/hardware/lights/ILightsManager.aidl index 6ea24b74a4a3..077797f5b0f5 100644 --- a/core/java/android/hardware/lights/ILightsManager.aidl +++ b/core/java/android/hardware/lights/ILightsManager.aidl @@ -27,7 +27,7 @@ import android.hardware.lights.LightState; interface ILightsManager { List<Light> getLights(); LightState getLightState(int lightId); - void openSession(in IBinder sessionToken); + void openSession(in IBinder sessionToken, in int priority); void closeSession(in IBinder sessionToken); void setLightStates(in IBinder sessionToken, in int[] lightIds, in LightState[] states); } diff --git a/core/java/android/hardware/lights/LightsManager.java b/core/java/android/hardware/lights/LightsManager.java index 8fd56db33c4b..8bc86dac0a8c 100644 --- a/core/java/android/hardware/lights/LightsManager.java +++ b/core/java/android/hardware/lights/LightsManager.java @@ -20,6 +20,7 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.SystemApi; import android.annotation.SystemService; +import android.annotation.TestApi; import android.content.Context; import android.os.Binder; import android.os.IBinder; @@ -84,11 +85,24 @@ public abstract class LightsManager { public abstract @NonNull LightsSession openSession(); /** + * + * Creates a new {@link LightsSession} + * + * @param priority the larger this number, the higher the priority of this session when multiple + * light state requests arrive simultaneously. + * + * @hide + */ + @TestApi + public abstract @NonNull LightsSession openSession(int priority); + + /** * Encapsulates a session that can be used to control device lights and represents the lifetime * of the requests. */ public abstract static class LightsSession implements AutoCloseable { private final IBinder mToken = new Binder(); + /** * Sends a request to modify the states of multiple lights. * diff --git a/core/java/android/hardware/lights/SystemLightsManager.java b/core/java/android/hardware/lights/SystemLightsManager.java index 726a61359c01..da034eefc09a 100644 --- a/core/java/android/hardware/lights/SystemLightsManager.java +++ b/core/java/android/hardware/lights/SystemLightsManager.java @@ -102,7 +102,28 @@ public final class SystemLightsManager extends LightsManager { public @NonNull LightsSession openSession() { try { final LightsSession session = new SystemLightsSession(); - mService.openSession(session.getToken()); + mService.openSession(session.getToken(), 0); + return session; + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * + * Creates a new {@link LightsSession} + * + * @param priority the larger this number, the higher the priority of this session when multiple + * light state requests arrive simultaneously. + * + * @hide + */ + @RequiresPermission(Manifest.permission.CONTROL_DEVICE_LIGHTS) + @Override + public @NonNull LightsSession openSession(int priority) { + try { + final LightsSession session = new SystemLightsSession(); + mService.openSession(session.getToken(), priority); return session; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); |
