Skip to content

Commit

Permalink
AriesParts: add controls for fast USB charging
Browse files Browse the repository at this point in the history
Change-Id: I0e033199775461d685fcb02877f0fdf707f1b4fe
  • Loading branch information
jt1134 committed Mar 15, 2013
1 parent b84801b commit 7e1b3bf
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions AriesParts/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@
<string name="imei_not_sane_message">A problem was detected with your device. Your device IMEI number is invalid. An invalid IMEI number could cause network issues including the inability to call emergency numbers.</string>
<string name="imei_not_sane_ok">OK</string>

<!-- Fast USB charging -->
<string name="category_force_fast_charge_title">USB Charging</string>
<string name="force_fast_charge_title_head">Force fast charging</string>
<string name="force_fast_charge_summary_on">Fast charging enabled</string>
<string name="force_fast_charge_summary_off">Fast charging disabled</string>
</resources>
11 changes: 11 additions & 0 deletions AriesParts/res/xml/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,15 @@
android:summary="@string/vibration_summary_head" />
</PreferenceCategory>

<PreferenceCategory
android:title="@string/category_force_fast_charge_title"
android:key="category_force_fast_charge">
<!-- Fast charge -->
<CheckBoxPreference
android:key="force_fast_charge"
android:title="@string/force_fast_charge_title_head"
android:summaryOn="@string/force_fast_charge_summary_on"
android:summaryOff="@string/force_fast_charge_summary_off" />
</PreferenceCategory>

</PreferenceScreen>
12 changes: 12 additions & 0 deletions AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class DeviceSettings extends PreferenceActivity {
public static final String KEY_DESKDOCK_AUDIO = "deskdock_audio";
public static final String KEY_DOCK_AUDIO_CATEGORY = "category_dock_audio";
public static final String KEY_VIBRATION = "vibration";
public static final String KEY_FORCE_FAST_CHARGE = "force_fast_charge";
public static final String KEY_FORCE_FAST_CHARGE_CATEGORY = "category_force_fast_charge";

private ColorTuningPreference mColorTuning;
private ListPreference mMdnie;
Expand All @@ -40,6 +42,7 @@ public class DeviceSettings extends PreferenceActivity {
private CheckBoxPreference mCarDockAudio;
private CheckBoxPreference mDeskDockAudio;
private VibrationPreference mVibration;
private CheckBoxPreference mForceFastCharge;

private BroadcastReceiver mHeadsetReceiver = new BroadcastReceiver() {

Expand Down Expand Up @@ -98,6 +101,15 @@ public void onCreate(Bundle savedInstanceState) {
mVibration = (VibrationPreference) findPreference(KEY_VIBRATION);
mVibration.setEnabled(VibrationPreference.isSupported());

mForceFastCharge = (CheckBoxPreference) findPreference(KEY_FORCE_FAST_CHARGE);
if (ForceFastCharge.isSupported()) {
mForceFastCharge.setOnPreferenceChangeListener(new ForceFastCharge());
} else {
PreferenceCategory category = (PreferenceCategory) getPreferenceScreen().findPreference(KEY_FORCE_FAST_CHARGE_CATEGORY);
category.removePreference(mForceFastCharge);
getPreferenceScreen().removePreference(category);
}

mTvOut = new TvOut();
mTvOutEnable = (CheckBoxPreference) findPreference(KEY_TVOUT_ENABLE);
mTvOutSystem = (ListPreference) findPreference(KEY_TVOUT_SYSTEM);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.cyanogenmod.settings.device;

import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;

public class ForceFastCharge implements OnPreferenceChangeListener {

private static final String FILE = "/sys/kernel/fast_charge/force_fast_charge";

public static boolean isSupported() {
return Utils.fileExists(FILE);
}

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Utils.writeValue(FILE, ((Boolean) newValue) ? "1" : "0");
return true;
}

}

0 comments on commit 7e1b3bf

Please sign in to comment.