summaryrefslogtreecommitdiffstats
path: root/cm
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-08-02 02:18:24 -0700
committerSteve Kondik <shade@chemlab.org>2016-08-04 23:56:59 -0700
commit3e7dac120a1468ade555975e6267d3db7c1b231c (patch)
tree6b65fdf034c2409200834c24363bacc91eee408e /cm
parent19345cb1ca667309762cf1e5f9f9aa11a6b3ad53 (diff)
downloadvendor_cmsdk-3e7dac120a1468ade555975e6267d3db7c1b231c.zip
vendor_cmsdk-3e7dac120a1468ade555975e6267d3db7c1b231c.tar.gz
vendor_cmsdk-3e7dac120a1468ade555975e6267d3db7c1b231c.tar.bz2
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
Diffstat (limited to 'cm')
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java49
-rw-r--r--cm/res/res/values/config.xml11
-rw-r--r--cm/res/res/values/symbols.xml3
3 files changed, 60 insertions, 3 deletions
diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java
index 6052383..9fa1269 100644
--- a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java
+++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java
@@ -20,6 +20,7 @@ import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
+import android.util.ArrayMap;
import android.util.Log;
import com.android.server.SystemService;
@@ -32,6 +33,7 @@ import cyanogenmod.hardware.IThermalListenerCallback;
import cyanogenmod.hardware.ThermalListenerCallback;
import java.io.File;
+import java.util.ArrayList;
import java.util.Arrays;
import org.cyanogenmod.hardware.AdaptiveBacklight;
@@ -65,6 +67,10 @@ public class CMHardwareService extends CMSystemService implements ThermalUpdateC
private int mCurrentThermalState = ThermalListenerCallback.State.STATE_UNKNOWN;
private RemoteCallbackList<IThermalListenerCallback> mRemoteCallbackList;
+ private final ArrayMap<String, String> mDisplayModeMappings =
+ new ArrayMap<String, String>();
+ private final boolean mFilterDisplayModes;
+
private interface CMHardwareInterface {
public int getSupportedFeatures();
public boolean get(int feature);
@@ -369,6 +375,19 @@ public class CMHardwareService extends CMSystemService implements ThermalUpdateC
mContext = context;
mCmHwImpl = getImpl(context);
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
@@ -410,6 +429,19 @@ public class CMHardwareService extends CMSystemService implements ThermalUpdateC
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 boolean isSupported(int feature) {
@@ -611,7 +643,18 @@ public class CMHardwareService extends CMSystemService implements ThermalUpdateC
Log.e(TAG, "Display modes are not supported");
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
@@ -622,7 +665,7 @@ public class CMHardwareService extends CMSystemService implements ThermalUpdateC
Log.e(TAG, "Display modes are not supported");
return null;
}
- return mCmHwImpl.getCurrentDisplayMode();
+ return remapDisplayMode(mCmHwImpl.getCurrentDisplayMode());
}
@Override
@@ -633,7 +676,7 @@ public class CMHardwareService extends CMSystemService implements ThermalUpdateC
Log.e(TAG, "Display modes are not supported");
return null;
}
- return mCmHwImpl.getDefaultDisplayMode();
+ return remapDisplayMode(mCmHwImpl.getDefaultDisplayMode());
}
@Override
diff --git a/cm/res/res/values/config.xml b/cm/res/res/values/config.xml
index ef68b00..c17539c 100644
--- a/cm/res/res/values/config.xml
+++ b/cm/res/res/values/config.xml
@@ -70,6 +70,17 @@
<bool name="config_defaultColorEnhancement">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 ?
Used to decide if the user can set LED brightness -->
<bool name="config_adjustableNotificationLedBrightness">false</bool>
diff --git a/cm/res/res/values/symbols.xml b/cm/res/res/values/symbols.xml
index e79570b..957e794 100644
--- a/cm/res/res/values/symbols.xml
+++ b/cm/res/res/values/symbols.xml
@@ -81,6 +81,9 @@
<java-symbol type="bool" name="config_defaultColorEnhancement" />
<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 -->
<java-symbol type="bool" name="config_adjustableNotificationLedBrightness" />
<java-symbol type="bool" name="config_multipleNotificationLeds" />