livedisplay: Don't explode if no modes are available
* Don't create the mode observer or try to publish tiles if none of the adaptive modes are supported. Change-Id: Iee6fe8131b0614e10f35b5a03d65fb44c71c0da9
This commit is contained in:
parent
712426f249
commit
0ec60c69a0
@ -540,6 +540,7 @@ package cyanogenmod.hardware {
|
|||||||
method public int getDefaultMode();
|
method public int getDefaultMode();
|
||||||
method public int getDefaultNightTemperature();
|
method public int getDefaultNightTemperature();
|
||||||
method public boolean hasFeature(int);
|
method public boolean hasFeature(int);
|
||||||
|
method public boolean hasModeSupport();
|
||||||
method public boolean isAvailable();
|
method public boolean isAvailable();
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
}
|
}
|
||||||
|
@ -194,12 +194,14 @@ public class LiveDisplayService extends SystemService {
|
|||||||
|
|
||||||
updateDisplayState(mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY).getState());
|
updateDisplayState(mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY).getState());
|
||||||
|
|
||||||
mModeObserver = new ModeObserver(mHandler);
|
if (mConfig.hasModeSupport()) {
|
||||||
mModeObserver.update();
|
mModeObserver = new ModeObserver(mHandler);
|
||||||
|
mModeObserver.update();
|
||||||
|
|
||||||
mContext.registerReceiver(mNextModeReceiver,
|
mContext.registerReceiver(mNextModeReceiver,
|
||||||
new IntentFilter(ACTION_NEXT_MODE));
|
new IntentFilter(ACTION_NEXT_MODE));
|
||||||
publishCustomTile();
|
publishCustomTile();
|
||||||
|
}
|
||||||
|
|
||||||
mInitialized = true;
|
mInitialized = true;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ import cyanogenmod.os.Concierge.ParcelInfo;
|
|||||||
public class LiveDisplayConfig implements Parcelable {
|
public class LiveDisplayConfig implements Parcelable {
|
||||||
|
|
||||||
private final BitSet mCapabilities;
|
private final BitSet mCapabilities;
|
||||||
|
private final BitSet mAllModes = new BitSet();
|
||||||
|
|
||||||
private final int mDefaultDayTemperature;
|
private final int mDefaultDayTemperature;
|
||||||
private final int mDefaultNightTemperature;
|
private final int mDefaultNightTemperature;
|
||||||
private final int mDefaultMode;
|
private final int mDefaultMode;
|
||||||
@ -54,6 +56,7 @@ public class LiveDisplayConfig implements Parcelable {
|
|||||||
boolean defaultCABC, boolean defaultColorEnhancement) {
|
boolean defaultCABC, boolean defaultColorEnhancement) {
|
||||||
super();
|
super();
|
||||||
mCapabilities = (BitSet) capabilities.clone();
|
mCapabilities = (BitSet) capabilities.clone();
|
||||||
|
mAllModes.set(MODE_FIRST, MODE_LAST);
|
||||||
mDefaultMode = defaultMode;
|
mDefaultMode = defaultMode;
|
||||||
mDefaultDayTemperature = defaultDayTemperature;
|
mDefaultDayTemperature = defaultDayTemperature;
|
||||||
mDefaultNightTemperature = defaultNightTemperature;
|
mDefaultNightTemperature = defaultNightTemperature;
|
||||||
@ -91,6 +94,7 @@ public class LiveDisplayConfig implements Parcelable {
|
|||||||
|
|
||||||
// set temps
|
// set temps
|
||||||
mCapabilities = BitSet.valueOf(new long[] { capabilities });
|
mCapabilities = BitSet.valueOf(new long[] { capabilities });
|
||||||
|
mAllModes.set(MODE_FIRST, MODE_LAST);
|
||||||
mDefaultMode = defaultMode;
|
mDefaultMode = defaultMode;
|
||||||
mDefaultDayTemperature = defaultDayTemperature;
|
mDefaultDayTemperature = defaultDayTemperature;
|
||||||
mDefaultNightTemperature = defaultNightTemperature;
|
mDefaultNightTemperature = defaultNightTemperature;
|
||||||
@ -162,6 +166,15 @@ public class LiveDisplayConfig implements Parcelable {
|
|||||||
return !mCapabilities.isEmpty();
|
return !mCapabilities.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if LiveDisplay has support for adaptive modes.
|
||||||
|
*
|
||||||
|
* @return true if adaptive modes are available
|
||||||
|
*/
|
||||||
|
public boolean hasModeSupport() {
|
||||||
|
return isAvailable() && mCapabilities.intersects(mAllModes);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default color temperature to use in the daytime. This is typically
|
* Gets the default color temperature to use in the daytime. This is typically
|
||||||
* set to 6500K, however this may not be entirely accurate. Use this value for
|
* set to 6500K, however this may not be entirely accurate. Use this value for
|
||||||
|
Loading…
Reference in New Issue
Block a user