Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fb: TRDS change auto detect light conditions method
Currently on critical light conditions it still switches to often between
on and off which results in bad UX and in worse cases to unusable phone
due that it is permanently switching. To prevend that slacken the light mode
level detection and set it when it goes to dark mode way more higher (LIGHT_CONDITION)
and when into light mode back to lower level (DARK_CONDITION)

PS
- 25 looks good

Change-Id: I665f3141fe31f26ca371d10593ff95174d68fc9e
  • Loading branch information
kufikugel authored and temasek committed May 16, 2014
1 parent bc7b99b commit d5c573f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion services/java/com/android/server/UiModeManagerService.java
Expand Up @@ -62,6 +62,9 @@ final class UiModeManagerService extends IUiModeManager.Stub
private static final String TAG = UiModeManager.class.getSimpleName();
private static final boolean LOG = false;

private static float LIGHT_CONDITION = 25f;
private static float DARK_CONDITION = 0.25f;

// Enable launching of applications when entering the dock.
private static final boolean ENABLE_LAUNCH_CAR_DOCK_APP = true;
private static final boolean ENABLE_LAUNCH_DESK_DOCK_APP = true;
Expand Down Expand Up @@ -90,6 +93,7 @@ final class UiModeManagerService extends IUiModeManager.Stub
private int mSetUiMode = 0;
private int mSetUiThemeMode = 0;
private boolean mAllowConfigChange = true;
private float mCurrentSwitchLevel = DARK_CONDITION;

private boolean mHoldingConfiguration = false;
private Configuration mConfiguration = new Configuration();
Expand Down Expand Up @@ -315,9 +319,11 @@ private void updateUiThemeMode() {
public void onSensorChanged(SensorEvent event) {
int type = event.sensor.getType();
if (type == Sensor.TYPE_LIGHT) {
if (event.values[0] <= SensorManager.LIGHT_FULLMOON) {
if (event.values[0] <= mCurrentSwitchLevel) {
mCurrentSwitchLevel = LIGHT_CONDITION;
mConfiguration.uiThemeMode = Configuration.UI_THEME_MODE_HOLO_DARK;
} else {
mCurrentSwitchLevel = DARK_CONDITION;
mConfiguration.uiThemeMode = Configuration.UI_THEME_MODE_HOLO_LIGHT;
}

Expand Down

0 comments on commit d5c573f

Please sign in to comment.