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

Commit e8b4b3b9 authored by YuanQY's avatar YuanQY Committed by Gerrit Code Review
Browse files

Keyboard light: Fix the physical keyboard not light when it's visiable.

Change-Id: I595afd3cb6b422a17ae0f6ec20aa51979db13810
parent c83dd114
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -53,4 +53,6 @@ interface IPowerManager
    void setAttentionLight(boolean on, int color);

    void cpuBoost(int duration);

    void setKeyboardVisibility(boolean visible);
}
+13 −0
Original line number Diff line number Diff line
@@ -840,4 +840,17 @@ public final class PowerManager {
            }
        }
    }

    /**
     * @hide
     */
    public void setKeyboardVisibility(boolean visible)
    {
        try {
            if (mService != null) {
                mService.setKeyboardVisibility(visible);
            }
        } catch (RemoteException e) {
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -4824,6 +4824,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    private void applyLidSwitchState() {
        mPowerManager.setKeyboardVisibility(isBuiltInKeyboardVisible());

        if (mLidState == LID_CLOSED && mLidControlsSleep) {
            mPowerManager.goToSleep(SystemClock.uptimeMillis());
        }
+1 −0
Original line number Diff line number Diff line
@@ -769,6 +769,7 @@ final class DisplayPowerController {
                mNotifier.onScreenOn();
            } else {
                mLights.getLight(LightsService.LIGHT_ID_BUTTONS).setBrightness(0);
                mLights.getLight(LightsService.LIGHT_ID_KEYBOARD).setBrightness(0);
                mNotifier.onScreenOff();
            }
        }
+17 −0
Original line number Diff line number Diff line
@@ -187,6 +187,7 @@ public final class PowerManagerService extends IPowerManager.Stub
    private DreamManagerService mDreamManager;
    private LightsService.Light mAttentionLight;
    private LightsService.Light mButtonsLight;
    private LightsService.Light mKeyboardLight;

    private final Object mLock = new Object();

@@ -376,6 +377,7 @@ public final class PowerManagerService extends IPowerManager.Stub
    private static native void nativeSetInteractive(boolean enable);
    private static native void nativeSetAutoSuspend(boolean enable);
    private static native void nativeCpuBoost(int duration);
    private boolean mKeyboardVisible = false;

    public PowerManagerService() {
        synchronized (mLock) {
@@ -449,6 +451,7 @@ public final class PowerManagerService extends IPowerManager.Stub
            mSettingsObserver = new SettingsObserver(mHandler);
            mAttentionLight = mLightsService.getLight(LightsService.LIGHT_ID_ATTENTION);
            mButtonsLight = mLightsService.getLight(LightsService.LIGHT_ID_BUTTONS);
            mKeyboardLight = mLightsService.getLight(LightsService.LIGHT_ID_KEYBOARD);

            // Register for broadcasts from other components of the system.
            IntentFilter filter = new IntentFilter();
@@ -876,6 +879,18 @@ public final class PowerManagerService extends IPowerManager.Stub
        return false;
    }

    @Override // Binder call
    public void setKeyboardVisibility(boolean visible) {
        synchronized (mLock) {
            if (DEBUG_SPEW) {
                Slog.d(TAG, "setKeyboardVisibility: " + visible);
            }
            if (mKeyboardVisible != visible) {
                mKeyboardVisible = visible;
            }
        }
    }

    @Override // Binder call
    public void wakeUp(long eventTime) {
        if (eventTime > SystemClock.uptimeMillis()) {
@@ -1304,11 +1319,13 @@ public final class PowerManagerService extends IPowerManager.Stub
                    if (now < nextTimeout) {
                        if (now > mLastUserActivityTime + BUTTON_ON_DURATION) {
                            mButtonsLight.setBrightness(0);
                            mKeyboardLight.setBrightness(0);
                        } else {
                            int brightness = mButtonBrightnessOverrideFromWindowManager >= 0
                                    ? mButtonBrightnessOverrideFromWindowManager
                                    : mDisplayPowerRequest.screenBrightness;
                            mButtonsLight.setBrightness(brightness);
                            mKeyboardLight.setBrightness(mKeyboardVisible ? brightness : 0);
                            if (brightness != 0) {
                                nextTimeout = now + BUTTON_ON_DURATION;
                            }
Loading