cmsdk: Fix crash when getting LiveDisplay config
* If capabilities is empty, BitSet.toLongArray returns an empty array. Change-Id: I17476438995b581050feda346d0348228519ff44
This commit is contained in:
parent
c68b38ac3a
commit
35315d3c0f
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user