cmhw: Add support for display mode remapping
* Simple mechanism for mapping vendor names to the various modes used in CM (with translations). Change-Id: I791e6302e48f1b886dfc3228a96176d7318679d5
This commit is contained in:
parent
19345cb1ca
commit
3e7dac120a
|
@ -20,6 +20,7 @@ import android.content.Intent;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteCallbackList;
|
import android.os.RemoteCallbackList;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.server.SystemService;
|
import com.android.server.SystemService;
|
||||||
|
@ -32,6 +33,7 @@ import cyanogenmod.hardware.IThermalListenerCallback;
|
||||||
import cyanogenmod.hardware.ThermalListenerCallback;
|
import cyanogenmod.hardware.ThermalListenerCallback;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.cyanogenmod.hardware.AdaptiveBacklight;
|
import org.cyanogenmod.hardware.AdaptiveBacklight;
|
||||||
|
@ -65,6 +67,10 @@ public class CMHardwareService extends CMSystemService implements ThermalUpdateC
|
||||||
private int mCurrentThermalState = ThermalListenerCallback.State.STATE_UNKNOWN;
|
private int mCurrentThermalState = ThermalListenerCallback.State.STATE_UNKNOWN;
|
||||||
private RemoteCallbackList<IThermalListenerCallback> mRemoteCallbackList;
|
private RemoteCallbackList<IThermalListenerCallback> mRemoteCallbackList;
|
||||||
|
|
||||||
|
private final ArrayMap<String, String> mDisplayModeMappings =
|
||||||
|
new ArrayMap<String, String>();
|
||||||
|
private final boolean mFilterDisplayModes;
|
||||||
|
|
||||||
private interface CMHardwareInterface {
|
private interface CMHardwareInterface {
|
||||||
public int getSupportedFeatures();
|
public int getSupportedFeatures();
|
||||||
public boolean get(int feature);
|
public boolean get(int feature);
|
||||||
|
@ -369,6 +375,19 @@ public class CMHardwareService extends CMSystemService implements ThermalUpdateC
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mCmHwImpl = getImpl(context);
|
mCmHwImpl = getImpl(context);
|
||||||
publishBinderService(CMContextConstants.CM_HARDWARE_SERVICE, mService);
|
publishBinderService(CMContextConstants.CM_HARDWARE_SERVICE, mService);
|
||||||
|
|
||||||
|
final String[] mappings = mContext.getResources().getStringArray(
|
||||||
|
org.cyanogenmod.platform.internal.R.array.config_displayModeMappings);
|
||||||
|
if (mappings != null && mappings.length > 0) {
|
||||||
|
for (String mapping : mappings) {
|
||||||
|
String[] split = mapping.split(":");
|
||||||
|
if (split.length == 2) {
|
||||||
|
mDisplayModeMappings.put(split[0], split[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mFilterDisplayModes = mContext.getResources().getBoolean(
|
||||||
|
org.cyanogenmod.platform.internal.R.bool.config_filterDisplayModes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -410,6 +429,19 @@ public class CMHardwareService extends CMSystemService implements ThermalUpdateC
|
||||||
mRemoteCallbackList.finishBroadcast();
|
mRemoteCallbackList.finishBroadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DisplayMode remapDisplayMode(DisplayMode in) {
|
||||||
|
if (in == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (mDisplayModeMappings.containsKey(in.name)) {
|
||||||
|
return new DisplayMode(in.id, mDisplayModeMappings.get(in.name));
|
||||||
|
}
|
||||||
|
if (!mFilterDisplayModes) {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private final IBinder mService = new ICMHardwareService.Stub() {
|
private final IBinder mService = new ICMHardwareService.Stub() {
|
||||||
|
|
||||||
private boolean isSupported(int feature) {
|
private boolean isSupported(int feature) {
|
||||||
|
@ -611,7 +643,18 @@ public class CMHardwareService extends CMSystemService implements ThermalUpdateC
|
||||||
Log.e(TAG, "Display modes are not supported");
|
Log.e(TAG, "Display modes are not supported");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return mCmHwImpl.getDisplayModes();
|
final DisplayMode[] modes = mCmHwImpl.getDisplayModes();
|
||||||
|
if (modes == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final ArrayList<DisplayMode> remapped = new ArrayList<DisplayMode>();
|
||||||
|
for (DisplayMode mode : modes) {
|
||||||
|
DisplayMode r = remapDisplayMode(mode);
|
||||||
|
if (r != null) {
|
||||||
|
remapped.add(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return remapped.toArray(new DisplayMode[remapped.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -622,7 +665,7 @@ public class CMHardwareService extends CMSystemService implements ThermalUpdateC
|
||||||
Log.e(TAG, "Display modes are not supported");
|
Log.e(TAG, "Display modes are not supported");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return mCmHwImpl.getCurrentDisplayMode();
|
return remapDisplayMode(mCmHwImpl.getCurrentDisplayMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -633,7 +676,7 @@ public class CMHardwareService extends CMSystemService implements ThermalUpdateC
|
||||||
Log.e(TAG, "Display modes are not supported");
|
Log.e(TAG, "Display modes are not supported");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return mCmHwImpl.getDefaultDisplayMode();
|
return remapDisplayMode(mCmHwImpl.getDefaultDisplayMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -70,6 +70,17 @@
|
||||||
<bool name="config_defaultColorEnhancement">true</bool>
|
<bool name="config_defaultColorEnhancement">true</bool>
|
||||||
<bool name="config_defaultCABC">true</bool>
|
<bool name="config_defaultCABC">true</bool>
|
||||||
|
|
||||||
|
<!-- Display mode remapping table.
|
||||||
|
If the mode names returned by the backend do not match
|
||||||
|
the predefined and translated strings in the Settings
|
||||||
|
app, they can be remapped here. The format is
|
||||||
|
"oldname:newname", one per entry. -->
|
||||||
|
<string-array name="config_displayModeMappings" translatable="false">
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Should we filter any display modes which are unampped? -->
|
||||||
|
<bool name="config_filterDisplayModes">false</bool>
|
||||||
|
|
||||||
<!-- Is the notification LED brightness adjustable ?
|
<!-- Is the notification LED brightness adjustable ?
|
||||||
Used to decide if the user can set LED brightness -->
|
Used to decide if the user can set LED brightness -->
|
||||||
<bool name="config_adjustableNotificationLedBrightness">false</bool>
|
<bool name="config_adjustableNotificationLedBrightness">false</bool>
|
||||||
|
|
|
@ -81,6 +81,9 @@
|
||||||
<java-symbol type="bool" name="config_defaultColorEnhancement" />
|
<java-symbol type="bool" name="config_defaultColorEnhancement" />
|
||||||
<java-symbol type="bool" name="config_defaultCABC" />
|
<java-symbol type="bool" name="config_defaultCABC" />
|
||||||
|
|
||||||
|
<java-symbol type="bool" name="config_filterDisplayModes" />
|
||||||
|
<java-symbol type="array" name="config_displayModeMappings" />
|
||||||
|
|
||||||
<!-- Notification and battery light -->
|
<!-- Notification and battery light -->
|
||||||
<java-symbol type="bool" name="config_adjustableNotificationLedBrightness" />
|
<java-symbol type="bool" name="config_adjustableNotificationLedBrightness" />
|
||||||
<java-symbol type="bool" name="config_multipleNotificationLeds" />
|
<java-symbol type="bool" name="config_multipleNotificationLeds" />
|
||||||
|
|
Loading…
Reference in New Issue