Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e376b79 authored by Ivailo Karamanolev's avatar Ivailo Karamanolev Committed by Robin Lee
Browse files

Add LightsManager implementation to LightsService

Includes backend code to support LightsManager binder calls and route
them to the HALs.

Bug: 144979010
Bug: 144978691
Bug: 142715294
Change-Id: I0080972620ba7a3fb1197cdd0288287d3cfa8780
Fix: 142230898
Test: atest LightsManagerTest
Test: atest LightsServiceTest
Merged-In: I2db7f2caa432cd1e2389ea5ca6544200ada18675
parent 4c5ac6b3
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ package android {
    field public static final String CONFIGURE_DISPLAY_BRIGHTNESS = "android.permission.CONFIGURE_DISPLAY_BRIGHTNESS";
    field @Deprecated public static final String CONNECTIVITY_INTERNAL = "android.permission.CONNECTIVITY_INTERNAL";
    field public static final String CONNECTIVITY_USE_RESTRICTED_NETWORKS = "android.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS";
    field public static final String CONTROL_DEVICE_LIGHTS = "android.permission.CONTROL_DEVICE_LIGHTS";
    field public static final String CONTROL_DISPLAY_COLOR_TRANSFORMS = "android.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS";
    field public static final String CONTROL_DISPLAY_SATURATION = "android.permission.CONTROL_DISPLAY_SATURATION";
    field public static final String CONTROL_INCALL_EXPERIENCE = "android.permission.CONTROL_INCALL_EXPERIENCE";
@@ -2562,6 +2563,48 @@ package android.hardware.hdmi {
}
package android.hardware.lights {
  public final class Light implements android.os.Parcelable {
    method public int describeContents();
    method public int getId();
    method public int getOrdinal();
    method public int getType();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.lights.Light> CREATOR;
  }
  public final class LightState implements android.os.Parcelable {
    ctor public LightState(@ColorInt int);
    method public int describeContents();
    method @ColorInt public int getColor();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.lights.LightState> CREATOR;
  }
  public final class LightsManager {
    method @NonNull @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_LIGHTS) public java.util.List<android.hardware.lights.Light> getLights();
    method @NonNull @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_LIGHTS) public android.hardware.lights.LightsManager.LightsSession openSession();
    field public static final int LIGHT_TYPE_MICROPHONE = 8; // 0x8
  }
  public final class LightsManager.LightsSession implements java.lang.AutoCloseable {
    method @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_LIGHTS) public void close();
    method @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_LIGHTS) public void setLights(@NonNull android.hardware.lights.LightsRequest);
  }
  public final class LightsRequest {
  }
  public static final class LightsRequest.Builder {
    ctor public LightsRequest.Builder();
    method @NonNull public android.hardware.lights.LightsRequest build();
    method @NonNull public android.hardware.lights.LightsRequest.Builder clearLight(@NonNull android.hardware.lights.Light);
    method @NonNull public android.hardware.lights.LightsRequest.Builder setLight(@NonNull android.hardware.lights.Light, @NonNull android.hardware.lights.LightState);
  }
}
package android.hardware.location {
  public class ContextHubClient implements java.io.Closeable {
+44 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ package android {
    field public static final String CHANGE_APP_IDLE_STATE = "android.permission.CHANGE_APP_IDLE_STATE";
    field public static final String CLEAR_APP_USER_DATA = "android.permission.CLEAR_APP_USER_DATA";
    field public static final String CONFIGURE_DISPLAY_BRIGHTNESS = "android.permission.CONFIGURE_DISPLAY_BRIGHTNESS";
    field public static final String CONTROL_DEVICE_LIGHTS = "android.permission.CONTROL_DEVICE_LIGHTS";
    field public static final String FORCE_STOP_PACKAGES = "android.permission.FORCE_STOP_PACKAGES";
    field public static final String MANAGE_ACTIVITY_STACKS = "android.permission.MANAGE_ACTIVITY_STACKS";
    field public static final String MANAGE_ROLLBACKS = "android.permission.MANAGE_ROLLBACKS";
@@ -985,6 +986,49 @@ package android.hardware.display {

}

package android.hardware.lights {

  public final class Light implements android.os.Parcelable {
    method public int describeContents();
    method public int getId();
    method public int getOrdinal();
    method public int getType();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.lights.Light> CREATOR;
  }

  public final class LightState implements android.os.Parcelable {
    ctor public LightState(@ColorInt int);
    method public int describeContents();
    method @ColorInt public int getColor();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.lights.LightState> CREATOR;
  }

  public final class LightsManager {
    method @NonNull @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_LIGHTS) public android.hardware.lights.LightState getLightState(@NonNull android.hardware.lights.Light);
    method @NonNull @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_LIGHTS) public java.util.List<android.hardware.lights.Light> getLights();
    method @NonNull @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_LIGHTS) public android.hardware.lights.LightsManager.LightsSession openSession();
    field public static final int LIGHT_TYPE_MICROPHONE = 8; // 0x8
  }

  public final class LightsManager.LightsSession implements java.lang.AutoCloseable {
    method @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_LIGHTS) public void close();
    method @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_LIGHTS) public void setLights(@NonNull android.hardware.lights.LightsRequest);
  }

  public final class LightsRequest {
  }

  public static final class LightsRequest.Builder {
    ctor public LightsRequest.Builder();
    method @NonNull public android.hardware.lights.LightsRequest build();
    method @NonNull public android.hardware.lights.LightsRequest.Builder clearLight(@NonNull android.hardware.lights.Light);
    method @NonNull public android.hardware.lights.LightsRequest.Builder setLight(@NonNull android.hardware.lights.Light, @NonNull android.hardware.lights.LightState);
  }

}

package android.location {

  public final class GnssClock implements android.os.Parcelable {
+8 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ import android.hardware.hdmi.IHdmiControlService;
import android.hardware.input.InputManager;
import android.hardware.iris.IIrisService;
import android.hardware.iris.IrisManager;
import android.hardware.lights.LightsManager;
import android.hardware.location.ContextHubManager;
import android.hardware.radio.RadioManager;
import android.hardware.usb.IUsbManager;
@@ -1348,6 +1349,13 @@ final class SystemServiceRegistry {
                        return new DynamicSystemManager(
                                IDynamicSystemService.Stub.asInterface(b));
                    }});
        registerService(Context.LIGHTS_SERVICE, LightsManager.class,
            new CachedServiceFetcher<LightsManager>() {
                @Override
                public LightsManager createService(ContextImpl ctx)
                    throws ServiceNotFoundException {
                    return new LightsManager(ctx);
                }});
        //CHECKSTYLE:ON IndentationCheck
    }

+10 −0
Original line number Diff line number Diff line
@@ -3380,6 +3380,7 @@ public abstract class Context {
            //@hide: TIME_DETECTOR_SERVICE,
            //@hide: TIME_ZONE_DETECTOR_SERVICE,
            PERMISSION_SERVICE,
            LIGHTS_SERVICE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ServiceName {}
@@ -4879,6 +4880,15 @@ public abstract class Context {
    @SystemApi
    public static final String TELEPHONY_REGISTRY_SERVICE = "telephony_registry";

    /**
     * Use with {@link #getSystemService(String)} to retrieve a
     * {@link android.hardware.lights.LightsManager} for controlling device lights.
     *
     * @see #getSystemService(String)
     * @hide
     */
    public static final String LIGHTS_SERVICE = "lights";

    /**
     * Determine whether the given permission is allowed for a particular
     * process and user ID running in the system.
+33 −0
Original line number Diff line number Diff line
/**
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.lights;

import android.hardware.lights.Light;
import android.hardware.lights.LightState;

/**
 * API to lights manager service.
 *
 * {@hide}
 */
interface ILightsManager {
  List<Light> getLights();
  LightState getLightState(int lightId);
  void openSession(in IBinder sessionToken);
  void closeSession(in IBinder sessionToken);
  void setLightStates(in IBinder sessionToken, in int[] lightIds, in LightState[] states);
}
Loading