From 842344a3589225a6f9bdd936225e943a1f05f17b Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Fri, 15 Apr 2016 11:58:59 +0200 Subject: 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 --- .../internal/display/LiveDisplayService.java | 29 ++++++++++++++-------- 1 file 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; -- cgit v1.1