Created
January 15, 2013 22:42
-
-
Save JBirdVegas/4542875 to your computer and use it in GitHub Desktop.
Threaded IO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.untitled1; | |
import android.provider.SyncStateContract; | |
/** | |
* Since we have no need to interact with the UI thread we can do all these | |
* operations in the worker thread. We generally use the AsyncTask class | |
* if we need to do something on the UI thread (ie update view) after | |
* our long running task but since here we are only performing IO tasks | |
* we don't need the UI thread to be involved | |
* | |
* we can launch like any other thread example usage: | |
* | |
* ThreadedIO ioThread = new ThreadedIO() | |
* ioThread.start(); | |
*/ | |
public class ThreadedIO extends Thread { | |
CMDProcessor cmd = new CMDProcessor(); | |
@Override | |
public void run() { | |
super.run(); | |
SyncStateContract.Helpers.lockFreqs(false, getActivity()); | |
cmd.su.runWaitFor("busybox echo " + mPreferences.getString(PREF_MAX_CPU, null) | |
+ " > " + MAX_FREQ_PATH.replace("cpu0", "cpu" + i)); | |
cmd.su.runWaitFor("busybox echo " + mPreferences.getString(PREF_MIN_CPU, null) | |
+ " > " + MIN_FREQ_PATH.replace("cpu0", "cpu" + i)); | |
if (mIsTegra3) { | |
cmd.su.runWaitFor("busybox echo " + mPreferences.getString(PREF_MAX_CPU, null) | |
+ " > " + TEGRA_MAX_FREQ_PATH); | |
} | |
cmd.su.runWaitFor("busybox echo " + mPreferences.getString(PREF_GOV, null) | |
+ " > " + GOVERNOR_PATH.replace("cpu0", "cpu" + i)); | |
cmd.su.runWaitFor("busybox echo " + mPreferences.getString(PREF_IO, null) | |
+ " > " + IO_SCHEDULER_PATH); | |
if (lockFreqs) { | |
// Lock it back up so the frameworks / Power HALS can't meddle | |
SyncStateContract.Helpers.lockFreqs(true, getActivity()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment