// Path: src/com/elefher/utils/CpuUtils.java
// public class CpuUtils {
// 	public CpuUtils() {
// 
// 	}
// 
// 	public static String getSUbinaryPath() {
// 		String s = "/system/bin/su";
// 		File f = new File(s);
// 		if (f.exists()) {
// 			return s;
// 		}
// 		s = "/system/xbin/su";
// 		f = new File(s);
// 		if (f.exists()) {
// 			return s;
// 		}
// 		return null;
// 	}
// 
// 	public static String[] readStringArray(String filename) {
// 		String line = ReadFile.getStringOfFile(filename);
// 		if (line != null) {
// 			return line.split(" ");
// 		}
// 		return null;
// 	}
// 
// 	public static ArrayList<String> readStringArray2Cells(String filename) {
// 		BufferedReader buffered_reader = null;
// 		ArrayList<String> strLines = new ArrayList<String>();
// 		try {
// 			buffered_reader = new BufferedReader(new FileReader(filename));
// 			String line;
// 
// 			while ((line = buffered_reader.readLine()) != null) {
// 				strLines.add(line);
// 			}
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		} finally {
// 			try {
// 				if (buffered_reader != null){
// 					buffered_reader.close();
// 				}
// 			} catch (IOException ex) {
// 				ex.printStackTrace();
// 			}
// 		}
// 
// 		return strLines;
// 	} 
// }


import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import android.app.Activity;
import com.elefher.utils.CpuUtils;

	/*
	 * Write commands into file and set it executable
	 */
	public boolean setOnBoot(String rootFolder) {
		String command = "";

		if (commands.isEmpty() || shell.isEmpty())
			return false;

		command += shell;

		for (String c : commands) {
			command += c;
		}

		File f = new File(SYSTEM_INITD + fileName);
		if (!f.exists()) {
			createFile(rootFolder, SYSTEM_INITD + fileName);
			createScript(command, rootFolder, SYSTEM_INITD + fileName);
		} else {
			createScript(command, rootFolder, SYSTEM_INITD + fileName);
		}
		return true;
	}

	private void createFile(String folder, String pathFileToCreate) {
		try {

			// Get Root
// Path: src/com/elefher/utils/CpuUtils.java
// public class CpuUtils {
// 	public CpuUtils() {
// 
// 	}
// 
// 	public static String getSUbinaryPath() {
// 		String s = "/system/bin/su";
// 		File f = new File(s);
// 		if (f.exists()) {
// 			return s;
// 		}
// 		s = "/system/xbin/su";
// 		f = new File(s);
// 		if (f.exists()) {
// 			return s;
// 		}
// 		return null;
// 	}
// 
// 	public static String[] readStringArray(String filename) {
// 		String line = ReadFile.getStringOfFile(filename);
// 		if (line != null) {
// 			return line.split(" ");
// 		}
// 		return null;
// 	}
// 
// 	public static ArrayList<String> readStringArray2Cells(String filename) {
// 		BufferedReader buffered_reader = null;
// 		ArrayList<String> strLines = new ArrayList<String>();
// 		try {
// 			buffered_reader = new BufferedReader(new FileReader(filename));
// 			String line;
// 
// 			while ((line = buffered_reader.readLine()) != null) {
// 				strLines.add(line);
// 			}
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		} finally {
// 			try {
// 				if (buffered_reader != null){
// 					buffered_reader.close();
// 				}
// 			} catch (IOException ex) {
// 				ex.printStackTrace();
// 			}
// 		}
// 
// 		return strLines;
// 	} 
// }


// Path: src/com/elefher/customclasses/OnBoot.java
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import android.app.Activity;
import com.elefher.utils.CpuUtils;


	/*
	 * Write commands into file and set it executable
	 */
	public boolean setOnBoot(String rootFolder) {
		String command = "";

		if (commands.isEmpty() || shell.isEmpty())
			return false;

		command += shell;

		for (String c : commands) {
			command += c;
		}

		File f = new File(SYSTEM_INITD + fileName);
		if (!f.exists()) {
			createFile(rootFolder, SYSTEM_INITD + fileName);
			createScript(command, rootFolder, SYSTEM_INITD + fileName);
		} else {
			createScript(command, rootFolder, SYSTEM_INITD + fileName);
		}
		return true;
	}

	private void createFile(String folder, String pathFileToCreate) {
		try {

			// Get Root
			Process p = Runtime.getRuntime().exec(CpuUtils.getSUbinaryPath());