summaryrefslogtreecommitdiffstats
path: root/AriesParts/src/com
diff options
context:
space:
mode:
authorjt1134 <jt1134@gmail.com>2012-07-29 06:11:29 -0500
committerjt1134 <jt1134@gmail.com>2012-07-29 06:11:29 -0500
commit3c4cca0e9e8c17d7be8f8ccb207f8f2775e95ccd (patch)
treec4c0180dde1d152c85382ad6f88b2a21a877d093 /AriesParts/src/com
parent49b6cff5a8e35a354b019d2c5ff1e5a17522f074 (diff)
downloaddevice_samsung_aries-common-3c4cca0e9e8c17d7be8f8ccb207f8f2775e95ccd.zip
device_samsung_aries-common-3c4cca0e9e8c17d7be8f8ccb207f8f2775e95ccd.tar.gz
device_samsung_aries-common-3c4cca0e9e8c17d7be8f8ccb207f8f2775e95ccd.tar.bz2
AriesParts: add toggles for car and desk dock audio output
Change-Id: Icd651195588b779ff36df0d6f4e9cf23785eaaec
Diffstat (limited to 'AriesParts/src/com')
-rw-r--r--AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java17
-rw-r--r--AriesParts/src/com/cyanogenmod/settings/device/DockAudio.java57
-rw-r--r--AriesParts/src/com/cyanogenmod/settings/device/Startup.java1
3 files changed, 75 insertions, 0 deletions
diff --git a/AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java b/AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java
index 1eb677b..2501218 100644
--- a/AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java
+++ b/AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java
@@ -23,6 +23,9 @@ public class DeviceSettings extends PreferenceActivity {
public static final String KEY_TVOUT_SYSTEM = "tvout_system";
public static final String KEY_VOLUME_BOOST = "volume_boost";
public static final String KEY_VOLUME_CATEGORY = "category_volume_boost";
+ public static final String KEY_CARDOCK_AUDIO = "cardock_audio";
+ public static final String KEY_DESKDOCK_AUDIO = "deskdock_audio";
+ public static final String KEY_DOCK_AUDIO_CATEGORY = "category_dock_audio";
private ColorTuningPreference mColorTuning;
private ListPreference mMdnie;
@@ -32,6 +35,8 @@ public class DeviceSettings extends PreferenceActivity {
private ListPreference mTvOutSystem;
private TvOut mTvOut;
private VolumeBoostPreference mVolumeBoost;
+ private CheckBoxPreference mCarDockAudio;
+ private CheckBoxPreference mDeskDockAudio;
private BroadcastReceiver mHeadsetReceiver = new BroadcastReceiver() {
@@ -75,6 +80,18 @@ public class DeviceSettings extends PreferenceActivity {
getPreferenceScreen().removePreference(category);
}
+ mCarDockAudio = (CheckBoxPreference) findPreference(KEY_CARDOCK_AUDIO);
+ mDeskDockAudio = (CheckBoxPreference) findPreference(KEY_DESKDOCK_AUDIO);
+ if (DockAudio.isSupported()) {
+ mCarDockAudio.setOnPreferenceChangeListener(new DockAudio());
+ mDeskDockAudio.setOnPreferenceChangeListener(new DockAudio());
+ } else {
+ PreferenceCategory category = (PreferenceCategory) getPreferenceScreen().findPreference(KEY_DOCK_AUDIO_CATEGORY);
+ category.removePreference(mCarDockAudio);
+ category.removePreference(mDeskDockAudio);
+ getPreferenceScreen().removePreference(category);
+ }
+
mTvOut = new TvOut();
mTvOutEnable = (CheckBoxPreference) findPreference(KEY_TVOUT_ENABLE);
mTvOutEnable.setChecked(mTvOut._isEnabled());
diff --git a/AriesParts/src/com/cyanogenmod/settings/device/DockAudio.java b/AriesParts/src/com/cyanogenmod/settings/device/DockAudio.java
new file mode 100644
index 0000000..1070fa0
--- /dev/null
+++ b/AriesParts/src/com/cyanogenmod/settings/device/DockAudio.java
@@ -0,0 +1,57 @@
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.preference.CheckBoxPreference;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class DockAudio implements OnPreferenceChangeListener {
+
+ private static final String[] FILE_PATH = new String[] {
+ "/sys/class/misc/dockaudio/cardock_enable",
+ "/sys/class/misc/dockaudio/deskdock_enable"
+ };
+
+ public static boolean isSupported() {
+ boolean supported = true;
+
+ for (int i = 0; i < FILE_PATH.length; i++) {
+ if (!Utils.fileExists(FILE_PATH[i])) {
+ supported = false;
+ }
+ }
+ return supported;
+ }
+
+ /**
+ * Restore dockaudio settings from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ int value;
+ for (int i = 0; i < FILE_PATH.length; i++) {
+ if (i == 0)
+ value = sharedPrefs.getBoolean(DeviceSettings.KEY_CARDOCK_AUDIO, false) ? 1 : 0;
+ else
+ value = sharedPrefs.getBoolean(DeviceSettings.KEY_DESKDOCK_AUDIO, false) ? 1 : 0;
+
+ Utils.writeValue(FILE_PATH[i], String.valueOf(value));
+ }
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ for (int i = 0; i < FILE_PATH.length; i++) {
+ Utils.writeValue(FILE_PATH[i], ((CheckBoxPreference)preference).isChecked() ? "0" : "1");
+ }
+ return true;
+ }
+
+}
diff --git a/AriesParts/src/com/cyanogenmod/settings/device/Startup.java b/AriesParts/src/com/cyanogenmod/settings/device/Startup.java
index 7437c64..901f47e 100644
--- a/AriesParts/src/com/cyanogenmod/settings/device/Startup.java
+++ b/AriesParts/src/com/cyanogenmod/settings/device/Startup.java
@@ -13,6 +13,7 @@ public class Startup extends BroadcastReceiver {
TouchKeyBacklightTimeout.restore(context);
Hspa.restore(context);
VolumeBoostPreference.restore(context);
+ DockAudio.restore(context);
}
}