From 8f1496f742f27fc1fd20852710c9d7146e5fae16 Mon Sep 17 00:00:00 2001 From: KalimochoAz Date: Tue, 1 May 2012 03:11:50 +0200 Subject: Add control for fast USB Charge Change-Id: I60e791ac3560f192d1dd3401fe79e36da577a512 --- GNexusParts/res/values-de/strings.xml | 2 +- GNexusParts/res/values-ja/strings.xml | 2 +- GNexusParts/res/values-ru/strings.xml | 1 - GNexusParts/res/values/strings.xml | 6 ++++-- GNexusParts/res/xml/general_preferences.xml | 8 ++++++-- .../settings/device/DeviceSettings.java | 1 + .../settings/device/GeneralFragmentActivity.java | 22 ++++++++++++++++++++++ 7 files changed, 35 insertions(+), 7 deletions(-) diff --git a/GNexusParts/res/values-de/strings.xml b/GNexusParts/res/values-de/strings.xml index ed03759..e5e4826 100644 --- a/GNexusParts/res/values-de/strings.xml +++ b/GNexusParts/res/values-de/strings.xml @@ -6,7 +6,7 @@ ALLGEMEIN BILDSCHIRM - Prozessor + System WM8994 Einstellungen ( voodoo ) Farbmultiplikator Farbmultiplikator einstellen diff --git a/GNexusParts/res/values-ja/strings.xml b/GNexusParts/res/values-ja/strings.xml index 357a2d8..6a650f3 100644 --- a/GNexusParts/res/values-ja/strings.xml +++ b/GNexusParts/res/values-ja/strings.xml @@ -6,7 +6,7 @@ 一般 ディスプレイ - CPU + SYSTEM WM8994設定 ( voodoo ) カラーマルチプライヤチューニング 画面の色味を調整する diff --git a/GNexusParts/res/values-ru/strings.xml b/GNexusParts/res/values-ru/strings.xml index cd76fca..57fc0ca 100644 --- a/GNexusParts/res/values-ru/strings.xml +++ b/GNexusParts/res/values-ru/strings.xml @@ -6,7 +6,6 @@ ОСНОВНЫЕ ДИСПЛЕЙ - ЦП Настройки WM8994 ( voodoo ) Настройка цвета мультипликатора Калибровка цвета мультипликатора diff --git a/GNexusParts/res/values/strings.xml b/GNexusParts/res/values/strings.xml index 43f27a5..f06093f 100644 --- a/GNexusParts/res/values/strings.xml +++ b/GNexusParts/res/values/strings.xml @@ -6,7 +6,7 @@ GENERAL DISPLAY - CPU + System WM8994 Settings ( voodoo ) Color Multipliers Tuning Calibrate multipliers screen color @@ -23,6 +23,8 @@ Default CM Sett. Dark Sett. + Fast charge USB + Fast charge when connected to computer USB interface Default. Natural @@ -30,7 +32,7 @@ Warm Dark Cold Cross Proc. - Credits: ale.landra91 cpaixao provolinoo + Credits: ale.landra91 cpaixao malycomix Touch Keys Backlight Notifications diff --git a/GNexusParts/res/xml/general_preferences.xml b/GNexusParts/res/xml/general_preferences.xml index fc07c42..2bf2c43 100644 --- a/GNexusParts/res/xml/general_preferences.xml +++ b/GNexusParts/res/xml/general_preferences.xml @@ -2,8 +2,12 @@ - + + + diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/DeviceSettings.java b/GNexusParts/src/com/cyanogenmod/settings/device/DeviceSettings.java index e131654..d5d7838 100644 --- a/GNexusParts/src/com/cyanogenmod/settings/device/DeviceSettings.java +++ b/GNexusParts/src/com/cyanogenmod/settings/device/DeviceSettings.java @@ -45,6 +45,7 @@ public class DeviceSettings extends Activity { public static final String KEY_GAMMA_TUNING = "gamma_tuning"; public static final String KEY_CATEGORY_RADIO = "category_radio"; public static final String KEY_HSPA = "hspa"; + public static final String KEY_USB_FAST_CHARGE = "fast_charge_usb"; ViewPager mViewPager; TabsAdapter mTabsAdapter; diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/GeneralFragmentActivity.java b/GNexusParts/src/com/cyanogenmod/settings/device/GeneralFragmentActivity.java index ca1b155..17644e6 100644 --- a/GNexusParts/src/com/cyanogenmod/settings/device/GeneralFragmentActivity.java +++ b/GNexusParts/src/com/cyanogenmod/settings/device/GeneralFragmentActivity.java @@ -27,6 +27,7 @@ import android.preference.PreferenceFragment; import android.preference.PreferenceManager; import android.preference.PreferenceScreen; import android.util.Log; +import android.view.View; import com.cyanogenmod.settings.device.R; @@ -34,6 +35,9 @@ public class GeneralFragmentActivity extends PreferenceFragment { private static final String PREF_ENABLED = "1"; private static final String TAG = "GNexusParts_General"; + private static final String USB_FAST_CHARGE_FILE = "/sys/kernel/fast_charge/force_fast_charge"; + + private CheckBoxPreference mUSBFastCharge; @Override public void onCreate(Bundle savedInstanceState) { @@ -42,6 +46,13 @@ public class GeneralFragmentActivity extends PreferenceFragment { addPreferencesFromResource(R.xml.general_preferences); PreferenceScreen prefSet = getPreferenceScreen(); + mUSBFastCharge = (CheckBoxPreference) findPreference(DeviceSettings.KEY_USB_FAST_CHARGE); + + if (isSupported(USB_FAST_CHARGE_FILE)) { + mUSBFastCharge.setChecked(PREF_ENABLED.equals(Utils.readOneLine(USB_FAST_CHARGE_FILE))); + } else { + mUSBFastCharge.setEnabled(false); + } } @@ -53,6 +64,12 @@ public class GeneralFragmentActivity extends PreferenceFragment { Log.w(TAG, "key: " + key); + if (key.equals(DeviceSettings.KEY_USB_FAST_CHARGE)) { + final CheckBoxPreference chkPref = (CheckBoxPreference) preference; + boxValue = chkPref.isChecked() ? "1" : "0"; + Utils.writeValue(USB_FAST_CHARGE_FILE, boxValue); + } + return true; } @@ -62,5 +79,10 @@ public class GeneralFragmentActivity extends PreferenceFragment { public static void restore(Context context) { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); + if (isSupported(USB_FAST_CHARGE_FILE)) { + String sDefaultValue = Utils.readOneLine(USB_FAST_CHARGE_FILE); + Utils.writeValue(USB_FAST_CHARGE_FILE, sharedPrefs.getBoolean(DeviceSettings.KEY_USB_FAST_CHARGE, + PREF_ENABLED.equals(sDefaultValue))); + } } } -- cgit v1.1