summaryrefslogtreecommitdiffstats
path: root/AriesParts
diff options
context:
space:
mode:
Diffstat (limited to 'AriesParts')
-rw-r--r--AriesParts/res/values/strings.xml9
-rw-r--r--AriesParts/res/xml/main.xml18
-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
5 files changed, 102 insertions, 0 deletions
diff --git a/AriesParts/res/values/strings.xml b/AriesParts/res/values/strings.xml
index f4a8d23..80679a0 100644
--- a/AriesParts/res/values/strings.xml
+++ b/AriesParts/res/values/strings.xml
@@ -41,4 +41,13 @@
<string name="mic_spk_title">Speakerphone Mic</string>
<string name="mic_hp_title">Headphone Mic</string>
<string name="mic_hp_no_mic_title">Headphone (with no mic) Mic</string>
+
+ <string name="category_dock_audio_title">Dock Audio</string>
+ <string name="cardock_audio_title_head">Car Dock</string>
+ <string name="cardock_audio_summary_on">Car dock audio enabled</string>
+ <string name="cardock_audio_summary_off">Car dock audio disabled</string>
+ <string name="deskdock_audio_title_head">Desk Dock</string>
+ <string name="deskdock_audio_summary_on">Desk dock audio enabled</string>
+ <string name="deskdock_audio_summary_off">Desk dock audio disabled</string>
+
</resources>
diff --git a/AriesParts/res/xml/main.xml b/AriesParts/res/xml/main.xml
index 7f88321..913f3fa 100644
--- a/AriesParts/res/xml/main.xml
+++ b/AriesParts/res/xml/main.xml
@@ -71,4 +71,22 @@
android:summary="@string/volume_boost_summary_head" />
</PreferenceCategory>
+ <PreferenceCategory
+ android:title="@string/category_dock_audio_title"
+ android:key="category_dock_audio">
+ <!-- Dock Audio -->
+ <CheckBoxPreference
+ android:key="cardock_audio"
+ android:title="@string/cardock_audio_title_head"
+ android:summaryOn="@string/cardock_audio_summary_on"
+ android:summaryOff="@string/cardock_audio_summary_off"
+ android:persistent="true" />
+ <CheckBoxPreference
+ android:key="deskdock_audio"
+ android:title="@string/deskdock_audio_title_head"
+ android:summaryOn="@string/deskdock_audio_summary_on"
+ android:summaryOff="@string/deskdock_audio_summary_off"
+ android:persistent="true" />
+ </PreferenceCategory>
+
</PreferenceScreen>
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);
}
}