Created
December 4, 2012 20:32
-
-
Save JBirdVegas/4208382 to your computer and use it in GitHub Desktop.
Refactoring of VoltageControlTables com.aokp.romcontrol.performance.VoltageControlTable I just narrowed the scope of some Objects, and moved
finding the location to the Class initialization. This
way we don't overly expose variables used by the class
in
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.jbirdvegas.example; | |
import android.util.Log; | |
import java.io.File; | |
public class VoltageControlTable { | |
private final String TAG = getClass().getSimpleName(); | |
private String mTable = null; | |
public VoltageControlTable() { | |
File file = null; | |
String[] possibleLocations = { | |
"UV_mV_table", | |
"vdd_levels", | |
"vdd_sysfs_levels" }; | |
for (int i = 0; i < 3; i++) { | |
file = new File("/sys/devices/system/cpu/cpu0/cpufreq/" + possibleLocations[i]); | |
if (file.exists()) { | |
Log.d(TAG, "/sys/devices/system/cpu/cpu0/cpufreq/" + possibleLocations[i] + " is found and being used"); | |
mTable = possibleLocations[i]; | |
break; | |
} else { | |
Log.d(TAG, possibleLocations[i] + " kernel voltage implementation not found"); | |
mTable = null; | |
} | |
} | |
} | |
/** | |
* added this incase we ever need to know the location | |
* @return the location of the voltage control directory | |
*/ | |
public String getVoltageControlLocation() { | |
if (mTable == null) { | |
// meh we could return null here but thats up to you | |
return "no_voltage_table_found"; | |
} | |
return mTable; | |
} | |
public String getTable(int tableNumber) { | |
if (mTable == null) { | |
// again we could return null here but thats up to you | |
return "no_voltage_table_found"; | |
} | |
return "/sys/devices/system/cpu/cpu" + tableNumber + "/cpufreq/" + mTable; | |
} | |
} |
and given that this was literally my first attempt to write more than 3 lines of original java code, i won't hate anyone who would help me out with better examples
so thank you a lot :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
we cannot return null, ROM Control FC's with that :P