diff options
author | Steve Kondik <steve@cyngn.com> | 2016-04-25 16:34:21 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-04-26 01:17:30 -0700 |
commit | 35315d3c0f3a04fdcc46619987734cebe3b9ffeb (patch) | |
tree | 324719247126619b3f58d3205a3a070d0a3024c0 | |
parent | c68b38ac3a2d8a2714a5fcf0192956359220159c (diff) | |
download | vendor_cmsdk-35315d3c0f3a04fdcc46619987734cebe3b9ffeb.zip vendor_cmsdk-35315d3c0f3a04fdcc46619987734cebe3b9ffeb.tar.gz vendor_cmsdk-35315d3c0f3a04fdcc46619987734cebe3b9ffeb.tar.bz2 |
cmsdk: Fix crash when getting LiveDisplay config
* If capabilities is empty, BitSet.toLongArray returns an empty array.
Change-Id: I17476438995b581050feda346d0348228519ff44
-rw-r--r-- | cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java | 10 | ||||
-rw-r--r-- | sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.java | 3 |
2 files changed, 11 insertions, 2 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 015025d..70183f6 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 @@ -19,6 +19,7 @@ import static cyanogenmod.hardware.LiveDisplayManager.FEATURE_MANAGED_OUTDOOR_MO import static cyanogenmod.hardware.LiveDisplayManager.MODE_DAY; import static cyanogenmod.hardware.LiveDisplayManager.MODE_FIRST; import static cyanogenmod.hardware.LiveDisplayManager.MODE_LAST; +import static cyanogenmod.hardware.LiveDisplayManager.MODE_OFF; import static cyanogenmod.hardware.LiveDisplayManager.MODE_OUTDOOR; import android.app.Notification; @@ -357,13 +358,20 @@ public class LiveDisplayService extends SystemService { @Override public int getMode() { - return mModeObserver.getMode(); + if (mConfig.hasModeSupport()) { + return mModeObserver.getMode(); + } else { + return MODE_OFF; + } } @Override public boolean setMode(int mode) { mContext.enforceCallingOrSelfPermission( cyanogenmod.platform.Manifest.permission.MANAGE_LIVEDISPLAY, null); + if (!mConfig.hasModeSupport()) { + return false; + } return mModeObserver.setMode(mode); } diff --git a/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.java b/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.java index 9e499ce..81945f7 100644 --- a/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.java +++ b/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.java @@ -132,7 +132,8 @@ public class LiveDisplayConfig implements Parcelable { ParcelInfo parcelInfo = Concierge.prepareParcel(out); // ==== FIG ===== - out.writeLong(mCapabilities.toLongArray()[0]); + long[] caps = mCapabilities.toLongArray(); + out.writeLong(caps != null && caps.length > 0 ? caps[0] : 0L); out.writeInt(mDefaultMode); out.writeInt(mDefaultDayTemperature); out.writeInt(mDefaultNightTemperature); |