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

Commit 0361403d authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Merge 971799bd on remote branch"

parents e8ffebf2 de9b9021
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,5 +22,6 @@ interface IHardwareService
    // obsolete flashlight support
    boolean getFlashlightEnabled();
    void setFlashlightEnabled(boolean on);
    void setButtonLightEnabled(boolean on);
}
+6 −0
Original line number Diff line number Diff line
@@ -1268,6 +1268,12 @@
        <item>com.android.inputmethod.latin</item>
    </string-array>

    <!-- Button back light brightness value, 2 means 10 mA, friendly user light brightness -->
    <integer name="config_button_light_bright_level">2</integer>
    <!-- Button back light brightness friendly time break. -->
    <integer name="config_button_light_timeout_msec">4000</integer>
    <bool name="config_button_light_enabled">false</bool>

    <string-array name="config_notificationScorers">
        <item>com.android.internal.notification.DemoContactNotificationScorer</item>
    </string-array>
+3 −0
Original line number Diff line number Diff line
@@ -1537,6 +1537,9 @@
  <java-symbol type="integer" name="config_shutdownBatteryTemperature" />
  <java-symbol type="integer" name="config_undockedHdmiRotation" />
  <java-symbol type="integer" name="config_virtualKeyQuietTimeMillis" />
  <java-symbol type="integer" name="config_button_light_bright_level" />
  <java-symbol type="integer" name="config_button_light_timeout_msec" />
  <java-symbol type="bool" name="config_button_light_enabled" />
  <java-symbol type="layout" name="am_compat_mode_dialog" />
  <java-symbol type="layout" name="launch_warning" />
  <java-symbol type="layout" name="safe_mode" />
+33 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import android.os.Bundle;
import android.os.FactoryTest;
import android.os.Handler;
import android.os.IBinder;
import android.os.IHardwareService;
import android.os.IRemoteCallback;
import android.os.Looper;
import android.os.Message;
@@ -203,6 +204,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     */
    private final Object mLock = new Object();

    private boolean mButtonLightEnabled;

    Context mContext;
    IWindowManager mWindowManager;
    WindowManagerFuncs mWindowManagerFuncs;
@@ -211,6 +214,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    boolean mPreloadedRecentApps;
    final Object mServiceAquireLock = new Object();
    Vibrator mVibrator; // Vibrator for giving feedback of orientation changes
    IHardwareService mLight;
    SearchManager mSearchManager;

    // Vibrator pattern for haptic feedback of a long press.
@@ -908,6 +912,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                com.android.internal.R.bool.config_lidControlsSleep);
        mTranslucentDecorEnabled = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_enableTranslucentDecor);
        mButtonLightEnabled = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_button_light_enabled);

        if (mButtonLightEnabled) {
            mLight = IHardwareService.Stub.asInterface(
                    ServiceManager.getService("hardware"));

            if(mLight == null) mButtonLightEnabled = false;
        }

        readConfigurationDependentBehaviors();

        // register for dock events
@@ -1969,6 +1983,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    + " canceled=" + canceled);
        }

        if (mButtonLightEnabled && (down && repeatCount == 0 && (keyCode == KeyEvent.KEYCODE_HOME
                || keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU
                || keyCode == KeyEvent.KEYCODE_SEARCH))) {
            try {
                mLight.setButtonLightEnabled(true);
            } catch(RemoteException e) {
                Slog.e(TAG, "remote call for turn on button light failed.");
            }
        }

        // If we think we might have a volume down & power key chord on the way
        // but we're not sure, then tell the dispatcher to wait a little while and
        // try again later before dispatching.
@@ -3985,6 +4009,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        mPowerKeyTriggered = true;
                        mPowerKeyTime = event.getDownTime();
                        interceptScreenshotChord();

                        if (mButtonLightEnabled) {
                            try {
                                mLight.setButtonLightEnabled(false);
                            } catch(RemoteException e) {
                                Slog.e(TAG, "remote call for turn off button light failed.");
                            }
                        }
                    }

                    ITelephony telephonyService = getTelephonyService();
@@ -4114,6 +4146,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
            case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK:
            case KeyEvent.KEYCODE_CAMERA:
            case KeyEvent.KEYCODE_FOCUS:
                return false;
        }
        return true;
+45 −0
Original line number Diff line number Diff line
@@ -57,6 +57,14 @@ public class LightsService {

    private final Light mLights[] = new Light[LIGHT_ID_COUNT];

    private static final int MSG_BBL_TIMEOUT = 1;

    private int mButtonLightTimeout;

    private int mButtonBrightness;

    private Handler mLightHandler = null;

    public final class Light {

        private Light(int id) {
@@ -170,6 +178,25 @@ public class LightsService {
                // fail silently
            }
        }

        public void setButtonLightEnabled(boolean on) {
            if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.HARDWARE_TEST)
                    != PackageManager.PERMISSION_GRANTED) {
                throw new SecurityException("Requires FLASHLIGHT permission");
            }

            mLightHandler.removeMessages(MSG_BBL_TIMEOUT);

            if (on) {
                getLight(LIGHT_ID_BUTTONS).setBrightness(mButtonBrightness);

                mLightHandler.sendMessageDelayed(
                        mLightHandler.obtainMessage(MSG_BBL_TIMEOUT),
                        mButtonLightTimeout);
            } else {
                getLight(LIGHT_ID_BUTTONS).setBrightness(0);
            }
        }
    };

    LightsService(Context context) {
@@ -177,6 +204,24 @@ public class LightsService {
        mNativePointer = init_native();
        mContext = context;

        mButtonLightTimeout = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_button_light_timeout_msec);

        mButtonBrightness = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_button_light_bright_level);

        mLightHandler = new Handler() {
            public void handleMessage(Message msg) {
                synchronized(this) {
                    switch(msg.what) {
                    case MSG_BBL_TIMEOUT:
                        getLight(LIGHT_ID_BUTTONS).setBrightness(0);
                        break;
                    }
                }
            }
        };

        ServiceManager.addService("hardware", mLegacyFlashlightHack);

        for (int i = 0; i < LIGHT_ID_COUNT; i++) {
Loading