// Path: src/com/elefher/customclasses/CpuGovernors.java
// public class CpuGovernors {
// 
// 	public CpuGovernors() {
// 
// 	}
// 
// 	public static String[] getAvailableGovernors(Context cntx) {
// 		String[] governors = CpuUtils.readStringArray(findFilePath("scaling_available_governors", cntx));
// 
// 		// In case does not exist governors return null
// 		if (governors == null) {
// 			return null;
// 		}
// 
// 		return governors;
// 	}
// 	
// 	public static String getCurrentGovernor(Context cntx){
// 		String currentGov = "";
// 		try {
// 			currentGov = ReadFile.getStringOfFile(findFilePath("scaling_governor", cntx));
// 		}catch (NullPointerException e){
// 			currentGov = "Unknown";
// 			e.printStackTrace();
// 		}
// 		return currentGov;
// 	}
// 	
// 	public static boolean setGovernor(String governor, Context cntx){
// 		if(governor.isEmpty())
// 			return false;
// 		
// 		String scaling_governor = findFilePath("scaling_governor", cntx);
// 		int cores = CpuStat.getNumCores();
// 		try {
// 			List<String> commands = new ArrayList<String>();
// 
// 			for (int i = 0; i < cores; i++) {
// 				/*
// 				 * Prepare permissions so that we can write
// 				 */
// 				commands.add("chmod 0664 "
// 						+ scaling_governor.replace("cpu0", "cpu" + i) + "\n");
// 
// 				commands.add("echo " + governor + " > "
// 						+ scaling_governor.replace("cpu0", "cpu" + i) + "\n");
// 
// 				/*
// 				 * Set permissions in initial state
// 				 */
// 				commands.add("chmod 0444 "
// 						+ scaling_governor.replace("cpu0", "cpu" + i) + "\n");
// 			}
// 
// 			commands.add("exit\n");
// 
// 			Process p = Runtime.getRuntime().exec(CpuUtils.getSUbinaryPath());
// 			DataOutputStream dos = new DataOutputStream(p.getOutputStream());
// 			for (String command : commands) {
// 				dos.writeBytes(command);
// 				dos.flush();
// 			}
// 			dos.close();			
// 			
// 			p.waitFor();
// 			return true;
// 		} catch (Exception ex) {
// 			Log.e("", ex.toString() + " Error: " + ex.getMessage());
// 			return false;
// 		}
// 	}
// 
// 	private static String findFilePath(String file, Context cntx){
// 		try {
// 			String path = ReadFile.existPath(ReadFile.getListOfFile("data/paths.json", "path", file, cntx));
// 			return path;
// 		} catch (JSONException e) {
// 			e.printStackTrace();
// 		}
// 		return null;
// 	}
// }
// 
// Path: src/com/elefher/customclasses/DisplayText.java
// public class DisplayText {
// 	
// 	Activity activity;
// 	
// 	public DisplayText(Activity act){
// 		activity = act;
// 	}
// 	
// 	public static void updateText(Activity act, int rIdGovText, String descriptionString){
// 		TextView currentCpuString = (TextView) act.findViewById(rIdGovText);
// 		currentCpuString.setText(descriptionString);
// 	}
// }
// 
// Path: src/com/elefher/extendedclasses/AlertGovernors.java
// public class AlertGovernors extends AlertDialogUtils {
// 
// 	Activity activity;
// 	
// 	public AlertGovernors(Activity act) {
// 		super(act);
// 		activity = act;
// 
// 		// Set id button
// 		createButton(R.id.governorButton);
// 
// 		// Set available governors to dialog
// 		setItems(CpuGovernors.getAvailableGovernors(activity.getApplicationContext()));
// 
// 		// Set icon and tile for the dialog
// 		setIcon(R.drawable.ic_launcher);
// 		setTitle("Governor: Choose your Governor");
// 
// 		/*
// 		 *  Set positive and negative button
// 		 */
// 		setPositiveButton("Select", new DialogInterface.OnClickListener() {
// 			
// 			@Override
// 			public void onClick(DialogInterface dialog, int which) {
// 				
// 				/*
// 				 * Display message if user haven't choose a governor
// 				 */
// 				if (getStringItem.isEmpty()){
// 					Toast.makeText(activity, "You have to choose a governor first!!", Toast.LENGTH_LONG).show();
// 					return;
// 				}
// 				
// 				/*
// 				 * Set the cpu Governor and update info about the current governor 
// 				 */
// 				boolean governorChanged = CpuGovernors.setGovernor(getStringItem, activity);
// 				if(!governorChanged){
// 					Toast.makeText(activity, "Sorry, but the governor didn't change!!", Toast.LENGTH_LONG).show();
// 				} else if(governorChanged){
// 					Toast.makeText(activity, "The governor has changed to " + CpuGovernors.getCurrentGovernor(activity) +
// 							"!!", Toast.LENGTH_LONG).show();
// 				}
// 				
// 				// Update the current governor
// 				DisplayText.updateText(activity, R.id.updatedCurrentGov, CpuGovernors.getCurrentGovernor(activity));
// 				
// 				/*
// 				 *  Initialize var getStringItem in order to delete the preview choose 
// 				 */
// 				getStringItem = "";
// 				
// 			}
// 		});
// 
// 		setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
// 
// 			@Override
// 			public void onClick(DialogInterface dialog, int which) {
// 				// TODO Auto-generated method stub
// 
// 			}
// 		});
// 	}
// }


import com.cpu.handler.R;
import com.elefher.customclasses.CpuGovernors;
import com.elefher.customclasses.DisplayText;
import com.elefher.extendedclasses.AlertGovernors;
import android.app.Activity;
package com.elefher.implementation;



public class CpuGovernorPicker {

	Activity activity;

	public CpuGovernorPicker(Activity act) {
// Path: src/com/elefher/customclasses/CpuGovernors.java
// public class CpuGovernors {
// 
// 	public CpuGovernors() {
// 
// 	}
// 
// 	public static String[] getAvailableGovernors(Context cntx) {
// 		String[] governors = CpuUtils.readStringArray(findFilePath("scaling_available_governors", cntx));
// 
// 		// In case does not exist governors return null
// 		if (governors == null) {
// 			return null;
// 		}
// 
// 		return governors;
// 	}
// 	
// 	public static String getCurrentGovernor(Context cntx){
// 		String currentGov = "";
// 		try {
// 			currentGov = ReadFile.getStringOfFile(findFilePath("scaling_governor", cntx));
// 		}catch (NullPointerException e){
// 			currentGov = "Unknown";
// 			e.printStackTrace();
// 		}
// 		return currentGov;
// 	}
// 	
// 	public static boolean setGovernor(String governor, Context cntx){
// 		if(governor.isEmpty())
// 			return false;
// 		
// 		String scaling_governor = findFilePath("scaling_governor", cntx);
// 		int cores = CpuStat.getNumCores();
// 		try {
// 			List<String> commands = new ArrayList<String>();
// 
// 			for (int i = 0; i < cores; i++) {
// 				/*
// 				 * Prepare permissions so that we can write
// 				 */
// 				commands.add("chmod 0664 "
// 						+ scaling_governor.replace("cpu0", "cpu" + i) + "\n");
// 
// 				commands.add("echo " + governor + " > "
// 						+ scaling_governor.replace("cpu0", "cpu" + i) + "\n");
// 
// 				/*
// 				 * Set permissions in initial state
// 				 */
// 				commands.add("chmod 0444 "
// 						+ scaling_governor.replace("cpu0", "cpu" + i) + "\n");
// 			}
// 
// 			commands.add("exit\n");
// 
// 			Process p = Runtime.getRuntime().exec(CpuUtils.getSUbinaryPath());
// 			DataOutputStream dos = new DataOutputStream(p.getOutputStream());
// 			for (String command : commands) {
// 				dos.writeBytes(command);
// 				dos.flush();
// 			}
// 			dos.close();			
// 			
// 			p.waitFor();
// 			return true;
// 		} catch (Exception ex) {
// 			Log.e("", ex.toString() + " Error: " + ex.getMessage());
// 			return false;
// 		}
// 	}
// 
// 	private static String findFilePath(String file, Context cntx){
// 		try {
// 			String path = ReadFile.existPath(ReadFile.getListOfFile("data/paths.json", "path", file, cntx));
// 			return path;
// 		} catch (JSONException e) {
// 			e.printStackTrace();
// 		}
// 		return null;
// 	}
// }
// 
// Path: src/com/elefher/customclasses/DisplayText.java
// public class DisplayText {
// 	
// 	Activity activity;
// 	
// 	public DisplayText(Activity act){
// 		activity = act;
// 	}
// 	
// 	public static void updateText(Activity act, int rIdGovText, String descriptionString){
// 		TextView currentCpuString = (TextView) act.findViewById(rIdGovText);
// 		currentCpuString.setText(descriptionString);
// 	}
// }
// 
// Path: src/com/elefher/extendedclasses/AlertGovernors.java
// public class AlertGovernors extends AlertDialogUtils {
// 
// 	Activity activity;
// 	
// 	public AlertGovernors(Activity act) {
// 		super(act);
// 		activity = act;
// 
// 		// Set id button
// 		createButton(R.id.governorButton);
// 
// 		// Set available governors to dialog
// 		setItems(CpuGovernors.getAvailableGovernors(activity.getApplicationContext()));
// 
// 		// Set icon and tile for the dialog
// 		setIcon(R.drawable.ic_launcher);
// 		setTitle("Governor: Choose your Governor");
// 
// 		/*
// 		 *  Set positive and negative button
// 		 */
// 		setPositiveButton("Select", new DialogInterface.OnClickListener() {
// 			
// 			@Override
// 			public void onClick(DialogInterface dialog, int which) {
// 				
// 				/*
// 				 * Display message if user haven't choose a governor
// 				 */
// 				if (getStringItem.isEmpty()){
// 					Toast.makeText(activity, "You have to choose a governor first!!", Toast.LENGTH_LONG).show();
// 					return;
// 				}
// 				
// 				/*
// 				 * Set the cpu Governor and update info about the current governor 
// 				 */
// 				boolean governorChanged = CpuGovernors.setGovernor(getStringItem, activity);
// 				if(!governorChanged){
// 					Toast.makeText(activity, "Sorry, but the governor didn't change!!", Toast.LENGTH_LONG).show();
// 				} else if(governorChanged){
// 					Toast.makeText(activity, "The governor has changed to " + CpuGovernors.getCurrentGovernor(activity) +
// 							"!!", Toast.LENGTH_LONG).show();
// 				}
// 				
// 				// Update the current governor
// 				DisplayText.updateText(activity, R.id.updatedCurrentGov, CpuGovernors.getCurrentGovernor(activity));
// 				
// 				/*
// 				 *  Initialize var getStringItem in order to delete the preview choose 
// 				 */
// 				getStringItem = "";
// 				
// 			}
// 		});
// 
// 		setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
// 
// 			@Override
// 			public void onClick(DialogInterface dialog, int which) {
// 				// TODO Auto-generated method stub
// 
// 			}
// 		});
// 	}
// }


// Path: src/com/elefher/implementation/CpuGovernorPicker.java
import com.cpu.handler.R;
import com.elefher.customclasses.CpuGovernors;
import com.elefher.customclasses.DisplayText;
import com.elefher.extendedclasses.AlertGovernors;
import android.app.Activity;

package com.elefher.implementation;



public class CpuGovernorPicker {

	Activity activity;

	public CpuGovernorPicker(Activity act) {
		activity = act;