diff options
author | jt1134 <jt1134@gmail.com> | 2012-08-05 03:54:35 -0500 |
---|---|---|
committer | jt1134 <jt1134@gmail.com> | 2012-08-05 03:54:35 -0500 |
commit | 90ef971e1b99c4fda7652b4fe4f1b90d0767592a (patch) | |
tree | 0e2633d95e46f3048376df49358cae0fdf396917 /AriesParts | |
parent | 7bb18221eff6cb5ca9ef792328ebd2830035070a (diff) | |
download | device_samsung_aries-common-90ef971e1b99c4fda7652b4fe4f1b90d0767592a.zip device_samsung_aries-common-90ef971e1b99c4fda7652b4fe4f1b90d0767592a.tar.gz device_samsung_aries-common-90ef971e1b99c4fda7652b4fe4f1b90d0767592a.tar.bz2 |
AriesParts: disable tvout options on devices missing tvouthack
Change-Id: Ib5a945ddb6097fc16b1221089bac211478d5d85f
Diffstat (limited to 'AriesParts')
-rw-r--r-- | AriesParts/res/xml/main.xml | 3 | ||||
-rw-r--r-- | AriesParts/src/android/hardware/TvOut.java | 9 | ||||
-rw-r--r-- | AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java | 57 |
3 files changed, 43 insertions, 26 deletions
diff --git a/AriesParts/res/xml/main.xml b/AriesParts/res/xml/main.xml index 913f3fa..d50ed50 100644 --- a/AriesParts/res/xml/main.xml +++ b/AriesParts/res/xml/main.xml @@ -44,7 +44,8 @@ </PreferenceCategory> <PreferenceCategory - android:title="@string/category_tvout_title"> + android:title="@string/category_tvout_title" + android:key="category_tvout"> <CheckBoxPreference android:key="tvout_enable" android:title="@string/tvout_enable_head" diff --git a/AriesParts/src/android/hardware/TvOut.java b/AriesParts/src/android/hardware/TvOut.java index 6c0936e..349b987 100644 --- a/AriesParts/src/android/hardware/TvOut.java +++ b/AriesParts/src/android/hardware/TvOut.java @@ -1,5 +1,6 @@ package android.hardware; +import java.io.File; import java.lang.ref.WeakReference; import android.graphics.Bitmap; @@ -49,6 +50,12 @@ public class TvOut { public native void _setTvoutCableConnected(int paramInt); + private static final String FILE = "/system/bin/tvouthack"; + + public static boolean isSupported() { + return new File(FILE).exists(); + } + static { System.loadLibrary("tvout_jni"); } @@ -67,4 +74,4 @@ public class TvOut { Log.d(TAG, "Native Event: " + what + " " + arg1 + " " + arg2); } -}
\ No newline at end of file +} diff --git a/AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java b/AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java index 2501218..fff147a 100644 --- a/AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java +++ b/AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java @@ -21,6 +21,7 @@ public class DeviceSettings extends PreferenceActivity { public static final String KEY_HSPA_CATEGORY = "category_radio"; public static final String KEY_TVOUT_ENABLE = "tvout_enable"; public static final String KEY_TVOUT_SYSTEM = "tvout_system"; + public static final String KEY_TVOUT_CATEGORY = "category_tvout"; 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"; @@ -94,37 +95,45 @@ public class DeviceSettings extends PreferenceActivity { mTvOut = new TvOut(); mTvOutEnable = (CheckBoxPreference) findPreference(KEY_TVOUT_ENABLE); - mTvOutEnable.setChecked(mTvOut._isEnabled()); - - mTvOutEnable.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { - - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - boolean enable = (Boolean) newValue; - Intent i = new Intent(DeviceSettings.this, TvOutService.class); - i.putExtra(TvOutService.EXTRA_COMMAND, enable ? TvOutService.COMMAND_ENABLE : TvOutService.COMMAND_DISABLE); - startService(i); - return true; - } + mTvOutSystem = (ListPreference) findPreference(KEY_TVOUT_SYSTEM); - }); + if (mTvOut.isSupported()) { - mTvOutSystem = (ListPreference) findPreference(KEY_TVOUT_SYSTEM); - mTvOutSystem.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + mTvOutEnable.setChecked(mTvOut._isEnabled()); + mTvOutEnable.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - if (mTvOut._isEnabled()) { - int newSystem = Integer.valueOf((String) newValue); + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + boolean enable = (Boolean) newValue; Intent i = new Intent(DeviceSettings.this, TvOutService.class); - i.putExtra(TvOutService.EXTRA_COMMAND, TvOutService.COMMAND_CHANGE_SYSTEM); - i.putExtra(TvOutService.EXTRA_SYSTEM, newSystem); + i.putExtra(TvOutService.EXTRA_COMMAND, enable ? TvOutService.COMMAND_ENABLE : TvOutService.COMMAND_DISABLE); startService(i); + return true; } - return true; - } - }); + }); + + mTvOutSystem.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + if (mTvOut._isEnabled()) { + int newSystem = Integer.valueOf((String) newValue); + Intent i = new Intent(DeviceSettings.this, TvOutService.class); + i.putExtra(TvOutService.EXTRA_COMMAND, TvOutService.COMMAND_CHANGE_SYSTEM); + i.putExtra(TvOutService.EXTRA_SYSTEM, newSystem); + startService(i); + } + return true; + } + + }); + } else { + PreferenceCategory category = (PreferenceCategory) getPreferenceScreen().findPreference(KEY_TVOUT_CATEGORY); + category.removePreference(mTvOutEnable); + category.removePreference(mTvOutSystem); + getPreferenceScreen().removePreference(category); + } } @Override |