summaryrefslogtreecommitdiffstats
path: root/src/org/lineageos/hardware
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/lineageos/hardware')
-rw-r--r--src/org/lineageos/hardware/DisplayColorCalibration.java88
-rw-r--r--src/org/lineageos/hardware/HighTouchSensitivity.java12
-rw-r--r--src/org/lineageos/hardware/ReadingEnhancement.java83
3 files changed, 15 insertions, 168 deletions
diff --git a/src/org/lineageos/hardware/DisplayColorCalibration.java b/src/org/lineageos/hardware/DisplayColorCalibration.java
index 3f3f6cd..0602f7f 100644
--- a/src/org/lineageos/hardware/DisplayColorCalibration.java
+++ b/src/org/lineageos/hardware/DisplayColorCalibration.java
@@ -17,17 +17,6 @@
package org.lineageos.hardware;
-import android.app.ActivityThread;
-import android.os.IBinder;
-import android.os.Parcel;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.util.Slog;
-
-import com.android.server.LocalServices;
-import com.android.server.display.DisplayTransformManager;
-import static com.android.server.display.DisplayTransformManager.LEVEL_COLOR_MATRIX_NIGHT_DISPLAY;
-
import org.lineageos.internal.util.FileUtils;
public class DisplayColorCalibration {
@@ -36,39 +25,11 @@ public class DisplayColorCalibration {
private static final String COLOR_FILE = "/sys/class/graphics/fb0/rgb";
- private static final int LEVEL_COLOR_MATRIX_LIVEDISPLAY = LEVEL_COLOR_MATRIX_NIGHT_DISPLAY + 1;
-
- private static final int MODE_UNSUPPORTED = 0;
- private static final int MODE_HWC2_COLOR_TRANSFORM = 1;
- private static final int MODE_SYSFS_RGB = 2;
-
- private static final int sMode;
-
private static final int MIN = 255;
private static final int MAX = 32768;
- private static final int[] sCurColors = new int[] { MAX, MAX, MAX };
-
- private static DisplayTransformManager sDTMService;
-
- static {
- // Determine mode of operation.
- // Order of priority is:
- // 1) HWC2 color transform
- // 2) sysfs rgb file
- if (ActivityThread.currentApplication().getApplicationContext().getResources().getBoolean(
- com.android.internal.R.bool.config_setColorTransformAccelerated)) {
- sMode = MODE_HWC2_COLOR_TRANSFORM;
- } else if (FileUtils.isFileReadable(COLOR_FILE) &&
- FileUtils.isFileWritable(COLOR_FILE)) {
- sMode = MODE_SYSFS_RGB;
- } else {
- sMode = MODE_UNSUPPORTED;
- }
- }
-
public static boolean isSupported() {
- return sMode != MODE_UNSUPPORTED;
+ return FileUtils.isFileReadable(COLOR_FILE) && FileUtils.isFileWritable(COLOR_FILE);
}
public static int getMaxValue() {
@@ -84,54 +45,11 @@ public class DisplayColorCalibration {
}
public static String getCurColors() {
- if (sMode == MODE_SYSFS_RGB) {
- return FileUtils.readOneLine(COLOR_FILE);
- }
-
- return String.format("%d %d %d", sCurColors[0],
- sCurColors[1], sCurColors[2]);
+ return FileUtils.readOneLine(COLOR_FILE);
}
public static boolean setColors(String colors) {
- if (sMode == MODE_SYSFS_RGB) {
- return FileUtils.writeLine(COLOR_FILE, colors);
- } else if (sMode == MODE_HWC2_COLOR_TRANSFORM) {
- if (sDTMService == null) {
- sDTMService = LocalServices.getService(DisplayTransformManager.class);
- if (sDTMService == null) {
- return false;
- }
- }
- sDTMService.setColorMatrix(LEVEL_COLOR_MATRIX_LIVEDISPLAY, toColorMatrix(colors));
- return true;
- }
- return false;
+ return FileUtils.writeLine(COLOR_FILE, colors);
}
- private static float[] toColorMatrix(String rgbString) {
- String[] adj = rgbString == null ? null : rgbString.split(" ");
-
- if (adj == null || adj.length != 3) {
- return null;
- }
-
- float[] mat = new float[16];
-
- // sanity check
- for (int i = 0; i < 3; i++) {
- int v = Integer.parseInt(adj[i]);
-
- if (v >= MAX) {
- v = MAX;
- } else if (v < MIN) {
- v = MIN;
- }
-
- mat[i * 5] = (float)v / (float)MAX;
- sCurColors[i] = v;
- }
-
- mat[15] = 1.0f;
- return mat;
- }
}
diff --git a/src/org/lineageos/hardware/HighTouchSensitivity.java b/src/org/lineageos/hardware/HighTouchSensitivity.java
index 2bfcd27..bb92b6d 100644
--- a/src/org/lineageos/hardware/HighTouchSensitivity.java
+++ b/src/org/lineageos/hardware/HighTouchSensitivity.java
@@ -26,7 +26,9 @@ public class HighTouchSensitivity {
*
* @return boolean Supported devices must return always true
*/
- public static boolean isSupported() { return false; }
+ public static boolean isSupported() {
+ return false;
+ }
/**
* This method return the current activation status of high touch sensitivity
@@ -34,7 +36,9 @@ public class HighTouchSensitivity {
* @return boolean Must be false if high touch sensitivity is not supported or not activated,
* or the operation failed while reading the status; true in any other case.
*/
- public static boolean isEnabled() { return false; }
+ public static boolean isEnabled() {
+ return false;
+ }
/**
* This method allows to setup high touch sensitivity status.
@@ -43,6 +47,8 @@ public class HighTouchSensitivity {
* @return boolean Must be false if high touch sensitivity is not supported or the operation
* failed; true in any other case.
*/
- public static boolean setEnabled(boolean status) { return false; }
+ public static boolean setEnabled(boolean status) {
+ return false;
+ }
}
diff --git a/src/org/lineageos/hardware/ReadingEnhancement.java b/src/org/lineageos/hardware/ReadingEnhancement.java
index 8a48699..d11a10e 100644
--- a/src/org/lineageos/hardware/ReadingEnhancement.java
+++ b/src/org/lineageos/hardware/ReadingEnhancement.java
@@ -16,17 +16,6 @@
package org.lineageos.hardware;
-import android.app.ActivityThread;
-import android.os.IBinder;
-import android.os.Parcel;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.util.Log;
-
-import com.android.server.LocalServices;
-import com.android.server.display.DisplayTransformManager;
-import static com.android.server.display.DisplayTransformManager.LEVEL_COLOR_MATRIX_GRAYSCALE;
-
import org.lineageos.internal.util.FileUtils;
/**
@@ -38,57 +27,13 @@ public class ReadingEnhancement {
private static final String FILE_READING = "/sys/class/graphics/fb0/reading_mode";
- private static final int LEVEL_COLOR_MATRIX_READING = LEVEL_COLOR_MATRIX_GRAYSCALE + 1;
-
- private static final int MODE_UNSUPPORTED = 0;
- private static final int MODE_HWC2_COLOR_TRANSFORM = 1;
- private static final int MODE_SYSFS_READING = 2;
-
- private static final int sMode;
-
- private static boolean sEnabled;
-
- /**
- * Matrix and offset used for converting color to grayscale.
- * Copied from com.android.server.accessibility.DisplayAdjustmentUtils.MATRIX_GRAYSCALE
- */
- private static final float[] MATRIX_GRAYSCALE = new float[] {
- .2126f, .2126f, .2126f, 0,
- .7152f, .7152f, .7152f, 0,
- .0722f, .0722f, .0722f, 0,
- 0, 0, 0, 1
- };
-
- /** Full color matrix and offset */
- private static final float[] MATRIX_NORMAL = new float[] {
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1
- };
-
- private static DisplayTransformManager sDTMService;
-
- static {
- // Determine mode of operation.
- if (ActivityThread.currentApplication().getApplicationContext().getResources().getBoolean(
- com.android.internal.R.bool.config_setColorTransformAccelerated)) {
- sMode = MODE_HWC2_COLOR_TRANSFORM;
- } else if (FileUtils.isFileReadable(FILE_READING) &&
- FileUtils.isFileWritable(FILE_READING)) {
- sMode = MODE_SYSFS_READING;
- } else {
- sMode = MODE_UNSUPPORTED;
- }
- }
-
/**
* Whether device supports Reader Mode
*
* @return boolean Supported devices must return always true
*/
public static boolean isSupported() {
- return sMode != MODE_UNSUPPORTED;
+ return FileUtils.isFileReadable(FILE_READING) && FileUtils.isFileWritable(FILE_READING);
}
/**
@@ -98,15 +43,7 @@ public class ReadingEnhancement {
* or the operation failed while reading the status; true in any other case.
*/
public static boolean isEnabled() {
- if (sMode == MODE_SYSFS_READING) {
- try {
- return Integer.parseInt(FileUtils.readOneLine(FILE_READING)) > 0;
- } catch (Exception e) {
- Log.e(TAG, e.getMessage(), e);
- }
- }
-
- return sEnabled;
+ return Integer.parseInt(FileUtils.readOneLine(FILE_READING)) > 0;
}
/**
@@ -117,21 +54,7 @@ public class ReadingEnhancement {
* failed; true in any other case.
*/
public static boolean setEnabled(boolean status) {
- if (sMode == MODE_SYSFS_READING) {
- return FileUtils.writeLine(FILE_READING, status ? "1" : "0");
- } else if (sMode == MODE_HWC2_COLOR_TRANSFORM) {
- if (sDTMService == null) {
- sDTMService = LocalServices.getService(DisplayTransformManager.class);
- if (sDTMService == null) {
- return false;
- }
- }
- sDTMService.setColorMatrix(LEVEL_COLOR_MATRIX_READING,
- status ? MATRIX_GRAYSCALE : MATRIX_NORMAL);
- sEnabled = status;
- return true;
- }
- return false;
+ return FileUtils.writeLine(FILE_READING, status ? "1" : "0");
}
}