diff options
author | tbalden <illespal@gmail.com> | 2013-02-14 20:15:51 +0100 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2013-03-24 15:40:48 -0700 |
commit | 1805134df9e33632c33e3ad70500d88b5842d318 (patch) | |
tree | 71ff9cf57ecceb138f740ec85ff61de76eba5f31 | |
parent | 7d6cc8cbc31e6c3772b64e72424e063e1fb726a0 (diff) | |
download | packages_apps_settings-1805134df9e33632c33e3ad70500d88b5842d318.zip packages_apps_settings-1805134df9e33632c33e3ad70500d88b5842d318.tar.gz packages_apps_settings-1805134df9e33632c33e3ad70500d88b5842d318.tar.bz2 |
Adding configurability of frequency cap (min/max) files' path.
This way those devices that have a special path for
frequency caps can overlay it in the given device's
resources for Settings package.
It's defaulting to the general paths that are used
in most of the kernels.
It's usable for example in endeavoru device tree
where the max cap can only be set through
a different sys path.
Change-Id: Ic3113222580ebe8cc8e43d3dad7a15e041448c53
-rwxr-xr-x | res/values/config.xml | 5 | ||||
-rw-r--r-- | src/com/android/settings/cyanogenmod/BootReceiver.java | 10 | ||||
-rw-r--r-- | src/com/android/settings/cyanogenmod/Processor.java | 20 |
3 files changed, 33 insertions, 2 deletions
diff --git a/res/values/config.xml b/res/values/config.xml index 5ce3b9a..e73a9ad 100755 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -42,5 +42,10 @@ <!-- Volume rocker support. Some devices does not have volume rocker. --> <bool name="has_volume_rocker">true</bool> + + <!-- Processor menu, freq cap files --> + <string name="max_cpu_freq_file" translatable="false">/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq</string> + <string name="min_cpu_freq_file" translatable="false">/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</string> + <!-- **** CYANOGENMOD ADDITIONS END **** --> </resources> diff --git a/src/com/android/settings/cyanogenmod/BootReceiver.java b/src/com/android/settings/cyanogenmod/BootReceiver.java index 6916b9d..4311168 100644 --- a/src/com/android/settings/cyanogenmod/BootReceiver.java +++ b/src/com/android/settings/cyanogenmod/BootReceiver.java @@ -24,6 +24,7 @@ import android.os.SystemProperties; import android.preference.PreferenceManager; import android.util.Log; +import com.android.settings.R; import com.android.settings.Utils; import java.util.Arrays; @@ -66,6 +67,14 @@ public class BootReceiver extends BroadcastReceiver { } } + private void initFreqCapFiles(Context ctx) + { + if (Processor.freqCapFilesInitialized) return; + Processor.FREQ_MAX_FILE = ctx.getResources().getString(R.string.max_cpu_freq_file); + Processor.FREQ_MIN_FILE = ctx.getResources().getString(R.string.min_cpu_freq_file); + Processor.freqCapFilesInitialized = true; + } + private void configureCPU(Context ctx) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); @@ -87,6 +96,7 @@ public class BootReceiver extends BroadcastReceiver { if (noSettings) { Log.d(TAG, "No CPU settings saved. Nothing to restore."); } else { + initFreqCapFiles(ctx); if (availableGovernorsLine != null){ governors = Arrays.asList(availableGovernorsLine.split(" ")); } diff --git a/src/com/android/settings/cyanogenmod/Processor.java b/src/com/android/settings/cyanogenmod/Processor.java index ce2c404..6f21e30 100644 --- a/src/com/android/settings/cyanogenmod/Processor.java +++ b/src/com/android/settings/cyanogenmod/Processor.java @@ -43,10 +43,12 @@ public class Processor extends SettingsPreferenceFragment implements public static final String FREQ_MIN_PREF = "pref_cpu_freq_min"; public static final String FREQ_MAX_PREF = "pref_cpu_freq_max"; public static final String FREQ_LIST_FILE = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies"; - public static final String FREQ_MAX_FILE = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"; - public static final String FREQ_MIN_FILE = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"; + public static String FREQ_MAX_FILE = null; + public static String FREQ_MIN_FILE = null; public static final String SOB_PREF = "pref_cpu_set_on_boot"; + protected static boolean freqCapFilesInitialized = false; + private static final String TAG = "CPUSettings"; private String mGovernorFormat; @@ -87,10 +89,20 @@ public class Processor extends SettingsPreferenceFragment implements } }; + private void initFreqCapFiles() + { + if (freqCapFilesInitialized) return; + FREQ_MAX_FILE = getString(R.string.max_cpu_freq_file); + FREQ_MIN_FILE = getString(R.string.min_cpu_freq_file); + freqCapFilesInitialized = true; + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + initFreqCapFiles(); + mGovernorFormat = getString(R.string.cpu_governors_summary); mMinFrequencyFormat = getString(R.string.cpu_min_freq_summary); mMaxFrequencyFormat = getString(R.string.cpu_max_freq_summary); @@ -185,6 +197,8 @@ public class Processor extends SettingsPreferenceFragment implements super.onResume(); + initFreqCapFiles(); + if (Utils.fileExists(FREQ_MIN_FILE) && (temp = Utils.fileReadOneLine(FREQ_MIN_FILE)) != null) { mMinFrequencyPref.setValue(temp); mMinFrequencyPref.setSummary(String.format(mMinFrequencyFormat, toMHz(temp))); @@ -211,6 +225,8 @@ public class Processor extends SettingsPreferenceFragment implements } public boolean onPreferenceChange(Preference preference, Object newValue) { + initFreqCapFiles(); + String fname = ""; if (newValue != null) { |