Skip to content

Commit

Permalink
livedisplay: Implement active display adjustment
Browse files Browse the repository at this point in the history
 * LiveDisplay is our new name for the various display technologies
   which adjust the screen based on environmental conditions other
   than the standard automatic backlight controls.
 * This patch implements automatic color temperature adjustment based
   on time of day. This is similar to f.lux or Redshift. My eyes are
   so happy now!
 * Automatic outdoor/SRE feature is now handled here.
 * Handling of CABC/CABL and color enhancements also handled here.
 * Manual RGB tweaking is handled here.
 * Can delegate to DisplayColor HAL if available, otherwise uses
   SurfaceFlinger's 1015 operation to apply changes.
 * Happily coexists with the new accessibility features for color
   blindness correction and color inversion.
 * All postprocessing will be disabled when powersave mode is
   activated.

Change-Id: Iac1b74f410957f8e2d8290465c4ce9cc1fd97a88

Conflicts:
	core/java/com/android/internal/util/cm/QSConstants.java
	core/res/res/values/cm_strings.xml
	core/res/res/values/cm_symbols.xml
	packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
  • Loading branch information
ryzenforce990 authored and temasek committed Mar 5, 2015
1 parent dde4184 commit e83a7b5
Show file tree
Hide file tree
Showing 19 changed files with 1,285 additions and 4 deletions.
63 changes: 62 additions & 1 deletion core/java/android/provider/Settings.java
Expand Up @@ -4153,6 +4153,54 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
*/
public static final String STATUS_BAR_SHOW_NETWORK_ACTIVITY = "status_bar_show_network_activity";

/**
* Color temperature of the display during the day
* @hide
*/
public static final String DISPLAY_TEMPERATURE_DAY = "display_temperature_day";

/**
* Color temperature of the display at night
* @hide
*/
public static final String DISPLAY_TEMPERATURE_NIGHT = "display_temperature_night";

/**
* Display color temperature adjustment mode, one of DAY (default), NIGHT, or AUTO.
* @hide
*/
public static final String DISPLAY_TEMPERATURE_MODE = "display_temperature_mode";

/**
* Automatic outdoor mode
* @hide
*/
public static final String DISPLAY_AUTO_OUTDOOR_MODE = "display_auto_outdoor_mode";

/**
* Use display power saving features such as CABC or CABL
* @hide
*/
public static final String DISPLAY_LOW_POWER = "display_low_power";

/**
* Use color enhancement feature of display
* @hide
*/
public static final String DISPLAY_COLOR_ENHANCE = "display_color_enhance";

/**
* Manual display color adjustments (RGB values as floats, separated by spaces)
* @hide
*/
public static final String DISPLAY_COLOR_ADJUSTMENT = "display_color_adjustment";

/**
* Did we tell about how they can stop breaking their eyes?
* @hide
*/
public static final String LIVE_DISPLAY_HINTED = "live_display_hinted";

/**
* Settings to backup. This is here so that it's in the same place as the settings
* keys and easy to update.
Expand Down Expand Up @@ -4230,7 +4278,12 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
STATUS_BAR_SHOW_BATTERY_PERCENT,
INCREASING_RING,
INCREASING_RING_START_VOLUME,
INCREASING_RING_RAMP_UP_TIME
INCREASING_RING_RAMP_UP_TIME,
DISPLAY_TEMPERATURE_NIGHT,
DISPLAY_TEMPERATURE_DAY,
DISPLAY_TEMPERATURE_MODE,
DISPLAY_AUTO_OUTDOOR_MODE,
LIVE_DISPLAY_HINTED
};

/**
Expand Down Expand Up @@ -6714,6 +6767,14 @@ public static boolean putFloatForUser(ContentResolver cr, String name, float val
*/
public static final String BUTTON_BACKLIGHT_TIMEOUT = "button_backlight_timeout";

/**
* Stored color matrix for LiveDisplay. This is used to allow co-existence with
* display tuning done by DisplayAdjustmentUtils when hardware support isn't
* available.
* @hide
*/
public static final String LIVE_DISPLAY_COLOR_MATRIX = "live_display_color_matrix";

/**
* This are the settings to be backed up.
*
Expand Down
2 changes: 2 additions & 0 deletions core/java/com/android/internal/util/cm/QSConstants.java
Expand Up @@ -54,6 +54,7 @@ private QSConstants() {}
public static final String TILE_EXPANDED_DESKTOP = "expanded_desktop";
public static final String TILE_REBOOT = "reboot";
public static final String TILE_AMBIENT_DISPLAY = "ambient_display";
public static final String TILE_LIVE_DISPLAY = "live_display";

// Order matters
protected static final ArrayList<String> TILES_DEFAULT = new ArrayList<String>();
Expand Down Expand Up @@ -98,5 +99,6 @@ private QSConstants() {}
TILES_AVAILABLE.add(TILE_EXPANDED_DESKTOP);
TILES_AVAILABLE.add(TILE_REBOOT);
TILES_AVAILABLE.add(TILE_AMBIENT_DISPLAY);
TILES_AVAILABLE.add(TILE_LIVE_DISPLAY);
}
}
29 changes: 29 additions & 0 deletions core/res/res/drawable/ic_livedisplay_notif.xml
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2015 The CyanogenMod 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="#FFFFFF"
android:pathData="M15.5,15.5c0.4-0.4,0.7-0.8,0.9-1.2c-1.9,1-4.3,0.7-5.8-0.9s-1.9-4-0.9-5.8C9.2,7.8,8.8,8.1,8.5,8.5
c-2,2-2,5.1,0,7.1S13.6,17.5,15.5,15.5z M19,5v14H5V5H19
M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5
C21,3.9,20.1,3,19,3L19,3z" />
</vector>
20 changes: 20 additions & 0 deletions core/res/res/values/cm_arrays.xml
Expand Up @@ -119,4 +119,24 @@
<item>2</item>
</string-array>

<string-array name="live_display_entries" translatable="false">
<item>@string/live_display_auto</item>
<item>@string/live_display_day</item>
<item>@string/live_display_night</item>
<item>@string/live_display_outdoor</item>
</string-array>

<string-array name="live_display_summaries" translatable="false">
<item>@string/live_display_auto_summary</item>
<item>@string/live_display_day_summary</item>
<item>@string/live_display_night_summary</item>
<item>@string/live_display_outdoor_summary</item>
</string-array>

<string-array name="live_display_values" translatable="false">
<item>2</item>
<item>0</item>
<item>1</item>
<item>3</item>
</string-array>
</resources>
13 changes: 13 additions & 0 deletions core/res/res/values/cm_strings.xml
Expand Up @@ -328,4 +328,17 @@
<string name="usb_ext_media_safe_unmount_notification_message">You can safely remove USB storage.</string>
<string name="usb_ext_media_nomedia_notification_title">Removed USB storage</string>
<string name="usb_ext_media_nomedia_notification_message">USB storage removed. Insert new media.</string>

<!-- LiveDisplay strings -->
<string name="live_display_title" translatable="false">LiveDisplay</string>
<string name="live_display_auto">Automatic</string>
<string name="live_display_auto_summary">Automatically adjust screen for ambient conditions</string>
<string name="live_display_day">Day</string>
<string name="live_display_day_summary">Use day settings only</string>
<string name="live_display_night">Night</string>
<string name="live_display_night_summary">Use night settings only</string>
<string name="live_display_outdoor">Outdoor (bright sun)</string>
<string name="live_display_outdoor_summary">Use outdoor settings only</string>
<string name="live_display_hint">LiveDisplay can help reduce eyestrain and help you sleep at night. Click here to try it out!</string>

</resources>
20 changes: 20 additions & 0 deletions core/res/res/values/cm_symbols.xml
Expand Up @@ -298,4 +298,24 @@
<java-symbol type="string" name="usb_ext_media_safe_unmount_notification_title" />
<java-symbol type="string" name="usb_ext_media_unmountable_notification_message" />
<java-symbol type="string" name="usb_ext_media_unmountable_notification_title" />

<!-- LiveDisplay -->
<java-symbol type="string" name="live_display_title" />
<java-symbol type="string" name="live_display_hint" />
<java-symbol type="string" name="live_display_auto" />
<java-symbol type="string" name="live_display_auto_summary" />
<java-symbol type="string" name="live_display_day" />
<java-symbol type="string" name="live_display_day_summary" />
<java-symbol type="string" name="live_display_night" />
<java-symbol type="string" name="live_display_night_summary" />
<java-symbol type="string" name="live_display_outdoor" />
<java-symbol type="string" name="live_display_outdoor_summary" />
<java-symbol type="array" name="live_display_entries" />
<java-symbol type="array" name="live_display_summaries" />
<java-symbol type="array" name="live_display_values" />
<java-symbol type="drawable" name="ic_livedisplay_notif" />

<java-symbol type="integer" name="config_dayColorTemperature" />
<java-symbol type="integer" name="config_nightColorTemperature" />
<java-symbol type="integer" name="config_outdoorAmbientLux" />
</resources>
5 changes: 5 additions & 0 deletions core/res/res/values/config.xml
Expand Up @@ -2131,4 +2131,9 @@
<!-- Support in Surfaceflinger for blur layers.
NOTE: This requires additional hardware-specific code. -->
<bool name="config_ui_blur_enabled">false</bool>

<!-- Default values for display color temperature -->
<integer name="config_dayColorTemperature">6500</integer>
<integer name="config_nightColorTemperature">4500</integer>
<integer name="config_outdoorAmbientLux">9000</integer>
</resources>
29 changes: 29 additions & 0 deletions packages/SystemUI/res/drawable/ic_livedisplay_auto.xml
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2015 The CyanogenMod 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="#FFFFFF"
android:pathData="M19,5v14H5V5H19
M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3L19,3z
M10.7,13.3h2.6L12,9.2L10.7,13.3z
M14.6,17l-0.8-2.2h-3.6L9.4,17H7.3l3.6-10h2.2l3.6,10H14.6z" />
</vector>
30 changes: 30 additions & 0 deletions packages/SystemUI/res/drawable/ic_livedisplay_day.xml
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2015 The CyanogenMod 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="#FFFFFF"
android:pathData="M19,5v14H5V5H19
M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3L19,3z
M14,12c0,1.1-0.9,2-2,2s-2-0.9-2-2s0.9-2,2-2S14,10.9,14,12z
M16,13.7l1.7-1.7L16,10.3V8h-2.3L12,6.3L10.3,8H8v2.3L6.3,12L8,13.7
V16h2.3l1.7,1.7l1.7-1.7H16V13.7z" />
</vector>
29 changes: 29 additions & 0 deletions packages/SystemUI/res/drawable/ic_livedisplay_night.xml
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2015 The CyanogenMod 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="#FFFFFF"
android:pathData="M15.5,15.5c0.4-0.4,0.7-0.8,0.9-1.2c-1.9,1-4.3,0.7-5.8-0.9s-1.9-4-0.9-5.8C9.2,7.8,8.8,8.1,8.5,8.5
c-2,2-2,5.1,0,7.1S13.6,17.5,15.5,15.5z M19,5v14H5V5H19
M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5
C21,3.9,20.1,3,19,3L19,3z" />
</vector>
27 changes: 27 additions & 0 deletions packages/SystemUI/res/drawable/ic_livedisplay_outdoor.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2015 The CyanogenMod 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="#FFFFFF"
android:pathData="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z
M19,19H5V5h14V19z M14,12.3l-2.8,3.5l-2-2.4L6.5,17h11L14,12.3z" />
</vector>
9 changes: 9 additions & 0 deletions packages/SystemUI/res/values/cm_arrays.xml
Expand Up @@ -44,4 +44,13 @@
<item>W</item> <!-- West -->
<item>NW</item> <!-- North west -->
</string-array>

<!-- LiveDisplay drawables -->
<string-array name="live_display_drawables" translatable="false">
<item>@drawable/ic_livedisplay_auto</item>
<item>@drawable/ic_livedisplay_day</item>
<item>@drawable/ic_livedisplay_night</item>
<item>@drawable/ic_livedisplay_outdoor</item>
</string-array>

</resources>

0 comments on commit e83a7b5

Please sign in to comment.