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

Commit 951764b9 authored by Dan Murphy's avatar Dan Murphy Committed by Mike Lockwood
Browse files

Add automatic lighting control framework



Add changes to have the ability to turn on and off the
automatic light sensing for the device.  This is fully configurable
and is by default not  present.  Vendors should override the ALS setting
to enable the automatic lighting controls.

These changes will add a check box to the Brightness settings menu to give control
to the user to allow the device's display lighting to be controlled via the slide bar
or the auto lighting system.

If the user selects auto then the slide bar will become invisible.  Manual mode
will present the slide bar to the user.

Change-Id: I146a6d75b99b08c9b839218ce6b85adf21f9fd73
Signed-off-by: default avatarDan Murphy <D.Murphy@motorola.com>
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent 151921a6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -32,6 +32,9 @@ interface IHardwareService
    // sets the brightness of the backlights (screen, keyboard, button) 0-255
    void setBacklights(int brightness);

    // enables or disables automatic brightness mode
    void setAutoBrightness(boolean on);

    // for the phone
    void setAttentionLight(boolean on);
}
+6 −0
Original line number Diff line number Diff line
@@ -1060,6 +1060,12 @@ public final class Settings {
         */
        public static final String SCREEN_BRIGHTNESS = "screen_brightness";

        /**
         * Control whether to enable automatic brightness mode.
         * @hide
         */
        public static final String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode";

        /**
         * Control whether the process CPU usage meter should be shown.
         */
+2 −0
Original line number Diff line number Diff line
@@ -81,4 +81,6 @@
        <item>30</item>
    </integer-array>
    
    <!-- Flag indicating whether the device supports automatic brightness mode. -->
    <bool name="config_automatic_brightness_available">false</bool>
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
    <bool name="def_accelerometer_rotation">true</bool>
    <!-- Default screen brightness, from 0 to 255.  102 is 40%. -->
    <integer name="def_screen_brightness">102</integer>
    <bool name="def_screen_brightness_automatic_mode">false</bool>
    <fraction name="def_window_animation_scale">100%</fraction>
    <fraction name="def_window_transition_scale">0%</fraction>
    
+20 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
    // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
    // is properly propagated through your change.  Not doing so will result in a loss of user
    // settings.
    private static final int DATABASE_VERSION = 39;
    private static final int DATABASE_VERSION = 40;

    private Context mContext;

@@ -465,6 +465,22 @@ public class DatabaseHelper extends SQLiteOpenHelper {
            upgradeVersion = 39;
        }

        if (upgradeVersion == 39) {
            db.beginTransaction();
            try {
                String value =
                        mContext.getResources().getBoolean(
                        R.bool.def_screen_brightness_automatic_mode) ? "1" : "0";
                db.execSQL("INSERT OR IGNORE INTO system(name,value) values('" +
                        Settings.System.SCREEN_BRIGHTNESS_MODE + "','" + value + "');");
                db.setTransactionSuccessful();
            } finally {
                db.endTransaction();
            }

            upgradeVersion = 40;
        }

        if (upgradeVersion != currentVersion) {
            Log.w(TAG, "Got stuck trying to upgrade from version " + upgradeVersion
                    + ", must wipe the settings provider");
@@ -701,6 +717,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
        loadIntegerSetting(stmt, Settings.System.SCREEN_BRIGHTNESS,
                R.integer.def_screen_brightness);

        loadBooleanSetting(stmt, Settings.System.SCREEN_BRIGHTNESS_MODE,
                R.bool.def_screen_brightness_automatic_mode);

        loadDefaultAnimationSettings(stmt);

        loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION,
Loading