aboutsummaryrefslogtreecommitdiff
path: root/cmhw
diff options
context:
space:
mode:
authorMister Oyster <oysterized@gmail.com>2017-01-02 12:44:35 +0100
committerMister Oyster <oysterized@gmail.com>2017-01-02 12:44:35 +0100
commita184d985bf43d3fe6eeba971bc6b32f79ea38b37 (patch)
tree6f6e56e090777cc149bc1ab39e5987cc2b03e867 /cmhw
initial releasecm-13.0
Diffstat (limited to 'cmhw')
-rw-r--r--cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java50
-rw-r--r--cmhw/org/cyanogenmod/hardware/KeyDisabler.java58
-rw-r--r--cmhw/org/cyanogenmod/hardware/VibratorHW.java79
3 files changed, 187 insertions, 0 deletions
diff --git a/cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java b/cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java
new file mode 100644
index 0000000..11d3ce1
--- /dev/null
+++ b/cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.cyanogenmod.hardware;
+
+import java.io.File;
+import java.util.Scanner;
+import org.cyanogenmod.hardware.util.FileUtils;
+
+public class DisplayColorCalibration {
+ private static final String COLOR_FILE = "/sys/devices/platform/mtk_disp_mgr.0/rgb";
+
+ public static boolean isSupported() {
+ File f = new File(COLOR_FILE);
+ return f.exists();
+ }
+
+ public static int getMaxValue() {
+ return 2000;
+ }
+
+ public static int getMinValue() {
+ return 0;
+ }
+
+ public static int getDefValue() {
+ return getMaxValue();
+ }
+
+ public static String getCurColors() {
+ return FileUtils.readOneLine(COLOR_FILE);
+ }
+
+ public static boolean setColors(String colors) {
+ return FileUtils.writeLine(COLOR_FILE, colors);
+ }
+}
diff --git a/cmhw/org/cyanogenmod/hardware/KeyDisabler.java b/cmhw/org/cyanogenmod/hardware/KeyDisabler.java
new file mode 100644
index 0000000..b101869
--- /dev/null
+++ b/cmhw/org/cyanogenmod/hardware/KeyDisabler.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2014 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.cyanogenmod.hardware;
+
+import android.util.Log;
+/*
+ * Disable capacitive keys
+ *
+ * This is intended for use on devices in which the capacitive keys
+ * can be fully disabled for replacement with a soft navbar. You
+ * really should not be using this on a device with mechanical or
+ * otherwise visible-when-inactive keys
+ */
+
+public class KeyDisabler {
+
+ private static boolean isActive = false;
+ /*
+ * All HAF classes should export this boolean.
+ * Real implementations must, of course, return true
+ */
+
+ public static boolean isSupported() { return true; }
+
+ /*
+ * Are the keys currently blocked?
+ */
+
+ public static boolean isActive() {
+ return isActive;
+ }
+
+ /*
+ * Disable capacitive keys
+ */
+
+ public static boolean setActive(boolean state) {
+ //throw new UnsupportedOperationException();
+ isActive = state;
+ Log.i("KeyDisabler", "setActive " + state);
+ return isActive;
+ }
+
+}
diff --git a/cmhw/org/cyanogenmod/hardware/VibratorHW.java b/cmhw/org/cyanogenmod/hardware/VibratorHW.java
new file mode 100644
index 0000000..6da130f
--- /dev/null
+++ b/cmhw/org/cyanogenmod/hardware/VibratorHW.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2013 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.cyanogenmod.hardware;
+
+import org.cyanogenmod.internal.util.FileUtils;
+
+/*
+ * Vibrator intensity adjustment
+ *
+ * Exports methods to get the valid value boundaries, the
+ * default and current intensities, and a method to set
+ * the vibrator.
+ *
+ * Values exported by min/max can be the direct values required
+ * by the hardware, or a local (to VibratorHW) abstraction that's
+ * internally converted to something else prior to actual use. The
+ * Settings user interface will normalize these into a 0-100 (percentage)
+ * scale before showing them to the user, but all values passed to/from
+ * the client (Settings) are in this class' scale.
+ */
+
+/* This would be just "Vibrator", but it conflicts with android.os.Vibrator */
+public class VibratorHW {
+
+ // Keep this synced to immvibe impl
+ private static final String INTENSITY_FILE = "/data/.libimmvibeclient_force";
+
+ public static boolean isSupported() {
+ return true;
+ }
+
+ public static boolean setIntensity(int intensity) {
+ return FileUtils.writeLine(INTENSITY_FILE, Integer.toString(intensity));
+ }
+
+ public static int getMaxIntensity() {
+ return 127;
+ }
+
+ public static int getMinIntensity() {
+ return 3;
+ }
+
+ public static int getWarningThreshold() {
+ // actually this is rather arbitrary
+ return 115;
+ }
+
+ public static int getCurIntensity() {
+ final String result = FileUtils.readOneLine(INTENSITY_FILE);
+ if (result == null) {
+ return 96;
+ }
+
+ try {
+ return Integer.parseInt(result.trim());
+ } catch (final NumberFormatException ignored) {
+ return 96;
+ }
+ }
+
+ public static int getDefaultIntensity() {
+ return 96;
+ }
+}