diff options
author | Danny Baumann <dannybaumann@web.de> | 2016-04-15 11:58:59 +0200 |
---|---|---|
committer | Danny Baumann <dannybaumann@web.de> | 2016-04-15 12:48:07 +0200 |
commit | 842344a3589225a6f9bdd936225e943a1f05f17b (patch) | |
tree | 53d9982f0154c5acc0857be0c758d762725fec26 /cm/lib | |
parent | 7cd7f79c75841fa98171f1f6ce112927d865e395 (diff) | |
download | vendor_cmsdk-842344a3589225a6f9bdd936225e943a1f05f17b.zip vendor_cmsdk-842344a3589225a6f9bdd936225e943a1f05f17b.tar.gz vendor_cmsdk-842344a3589225a6f9bdd936225e943a1f05f17b.tar.bz2 |
livedisplay: Fix endless loop for devices that don't support outdoor
mode.
There was a logic mistake that caused _all_ modes to be skipped if
outdoor mode isn't supported. In order to avoid such mistakes in the
future, also simplify the logic and make it more easily understandable.
Change-Id: I5fe8edbb3c4d2dd05fc4b4a7f94ca05d4ecd408b
Diffstat (limited to 'cm/lib')
-rw-r--r-- | cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java index 2855c82..e21f945 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java @@ -235,24 +235,31 @@ public class LiveDisplayService extends SystemService { next = 0; } - int nextMode = 0; + int nextMode; while (true) { nextMode = Integer.valueOf(mTileValues[next]); - // Skip outdoor mode if it's unsupported, and skip the day setting - // if it's the same as the off setting - if (((!mConfig.hasFeature(MODE_OUTDOOR) || - mConfig.hasFeature(FEATURE_MANAGED_OUTDOOR_MODE) - && nextMode == MODE_OUTDOOR)) || - (mCTC.getDayColorTemperature() == mConfig.getDefaultDayTemperature() - && nextMode == MODE_DAY)) { - next++; - if (next >= mTileValues.length) { - next = 0; + if (nextMode == MODE_OUTDOOR) { + // Only accept outdoor mode if it's supported by the hardware + if (mConfig.hasFeature(MODE_OUTDOOR) + && !mConfig.hasFeature(FEATURE_MANAGED_OUTDOOR_MODE)) { + break; + } + } else if (nextMode == MODE_DAY) { + // Skip the day setting if it's the same as the off setting + if (mCTC.getDayColorTemperature() != mConfig.getDefaultDayTemperature()) { + break; } } else { + // every other mode doesn't have any preconstraints break; } + + // If we come here, we decided to skip the mode + next++; + if (next >= mTileValues.length) { + next = 0; + } } return nextMode; |