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

Commit f773e10a authored by Ivailo Karamanolev's avatar Ivailo Karamanolev
Browse files

Rename Light to LogicalLight to avoid namespace conflicts when adding

AIDL HAL lights support.

LogicalLight is the internal implementation of Light that used to be
exposed directly from LightsService and consumed by
NotificationManagerService and a few more other places. The new
canonical API is going to be android.hardware.lights.Light, hence
renaming this one.

Bug: 142230898
Test: manual; basic device sanity check
Change-Id: Id5f7bfc74cef6d584c42712fcbea816e456b8b2d
Exempt-From-Owner-Approval: Reviewed in OOO OWNERS's stead.
parent fa75a86d
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -66,8 +66,8 @@ import com.android.internal.app.IBatteryStats;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.util.DumpUtils;
import com.android.server.am.BatteryStatsService;
import com.android.server.lights.Light;
import com.android.server.lights.LightsManager;
import com.android.server.lights.LogicalLight;

import java.io.File;
import java.io.FileDescriptor;
@@ -1065,7 +1065,7 @@ public final class BatteryService extends SystemService {
    }

    private final class Led {
        private final Light mBatteryLight;
        private final LogicalLight mBatteryLight;

        private final int mBatteryLowARGB;
        private final int mBatteryMediumARGB;
@@ -1100,7 +1100,7 @@ public final class BatteryService extends SystemService {
                    mBatteryLight.setColor(mBatteryLowARGB);
                } else {
                    // Flash red when battery is low and not charging
                    mBatteryLight.setFlashing(mBatteryLowARGB, Light.LIGHT_FLASH_TIMED,
                    mBatteryLight.setFlashing(mBatteryLowARGB, LogicalLight.LIGHT_FLASH_TIMED,
                            mBatteryLedOn, mBatteryLedOff);
                }
            } else if (status == BatteryManager.BATTERY_STATUS_CHARGING
+2 −2
Original line number Diff line number Diff line
@@ -41,8 +41,8 @@ import android.view.SurfaceControl;
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.server.LocalServices;
import com.android.server.lights.Light;
import com.android.server.lights.LightsManager;
import com.android.server.lights.LogicalLight;

import java.io.PrintWriter;
import java.util.ArrayList;
@@ -164,7 +164,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {

    private final class LocalDisplayDevice extends DisplayDevice {
        private final long mPhysicalDisplayId;
        private final Light mBacklight;
        private final LogicalLight mBacklight;
        private final SparseArray<DisplayModeRecord> mSupportedModes = new SparseArray<>();
        private final ArrayList<Integer> mSupportedColorModes = new ArrayList<>();
        private final boolean mIsInternal;
+4 −1
Original line number Diff line number Diff line
@@ -29,5 +29,8 @@ public abstract class LightsManager {
    public static final int LIGHT_ID_WIFI = Type.WIFI;
    public static final int LIGHT_ID_COUNT = Type.COUNT;

    public abstract Light getLight(int id);
    /**
     * Returns the logical light with the given type.
     */
    public abstract LogicalLight getLight(int id);
}
+2 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ public class LightsService extends SystemService {

    final LightImpl mLights[] = new LightImpl[LightsManager.LIGHT_ID_COUNT];

    private final class LightImpl extends Light {
    private final class LightImpl extends LogicalLight {

        private final IBinder mDisplayToken;
        private final int mSurfaceControlMaximumBrightness;
@@ -249,7 +249,7 @@ public class LightsService extends SystemService {

    private final LightsManager mService = new LightsManager() {
        @Override
        public Light getLight(int id) {
        public LogicalLight getLight(int id) {
            if (0 <= id && id < LIGHT_ID_COUNT) {
                return mLights[id];
            } else {
+39 −1
Original line number Diff line number Diff line
@@ -19,9 +19,24 @@ package com.android.server.lights;
import android.hardware.light.V2_0.Brightness;
import android.hardware.light.V2_0.Flash;

public abstract class Light {
/**
 * Allow control over a logical light of a given type. The mapping of logical lights to physical
 * lights is HAL implementation-dependent.
 */
public abstract class LogicalLight {
    /**
     * Keep the light steady on or off.
     */
    public static final int LIGHT_FLASH_NONE = Flash.NONE;

    /**
     * Flash the light at specified rate.
     */
    public static final int LIGHT_FLASH_TIMED = Flash.TIMED;

    /**
     * Flash the light using hardware assist.
     */
    public static final int LIGHT_FLASH_HARDWARE = Flash.HARDWARE;

    /**
@@ -55,10 +70,33 @@ public abstract class Light {
     */
    public abstract void setBrightnessFloat(float brightness);

    /**
     * Set the color of a light.
     */
    public abstract void setColor(int color);

    /**
     * Set the color of a light and control flashing.
     */
    public abstract void setFlashing(int color, int mode, int onMS, int offMS);

    /**
     * Pulses the light.
     */
    public abstract void pulse();

    /**
     * Pulses the light with a specified color for a specified duration.
     */
    public abstract void pulse(int color, int onMS);

    /**
     * Turns off the light.
     */
    public abstract void turnOff();

    /**
     * Set the VR mode of a display.
     */
    public abstract void setVrMode(boolean enabled);
}
Loading