[Java for Android App Development] DannyGM16:
import android.app.*;

import android.content.*;

import android.os.*;

import android.os.Process;

import android.util.*;

import android.view.*;

import android.view.View.*;

import android.widget.Button;

import android.widget.Toast;

import java.io.*;

import com.stericson.RootTools.RootTools;

import com.stericson.RootTools.execution.CommandCapture;

import java.util.concurrent.*;

import com.stericson.RootTools.exceptions.*;

import org.apache.commons.io.*;

public class MainActivity extends Activity {

{

}

ProgressDialog progressDialog = null;

/** Called when the activity is first created. */

[MENTION=439709]override[/MENTION]

public void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

if (RootTools.isAccessGiven()) {

} else {

makeToast("Se necesitan permisos de Superusuario!");

finish();

}

}

public void reparar(View view) throws IOException, TimeoutException, RootDeniedException, InterruptedException {

CopyFromAssets();

CopyFromAssetstosystem();

End();

}

public void CopyFromAssets() {

progressDialog = ProgressDialog.show(MainActivity.this, "Instalando parche", "Por favor, espere...", true);

String data_storage_root = getFilesDir().toString();

InputStream is= null;

OutputStream os = null;

File h = new File(data_storage_root+"/caca.txt");

File p = new File(data_storage_root+"/caca2.txt");

if (h.exists()) h.setWritable(true, true);

if (p.exists()) h.setWritable(true, true);

try {

is = getResources().getAssets().open("keypad/caca.txt");

is = getResources().getAssets().open("keypad/caca2.txt");

os = new FileOutputStream(data_storage_root+"/sec_key.kl");

os = new FileOutputStream(data_storage_root+"/sec_keypad.kl");

IOUtils.copy(is, os);

is.close();

os.flush();

os.close();

os = null;

} catch (IOException e) {

makeToast("Fallo al copiar");

finish();

}

h.setExecutable(false, true);

h.setReadable(true, true);

h.setWritable(false, true);

}

public void CopyFromAssetstosystem() throws TimeoutException, IOException, RootDeniedException {

CommandCapture command = new CommandCapture(0, "su", "mount -o rw, remount -t yaffs2 /dev/block/mtdblock4 /system", "cp /data/data/com.fixer.gminipop/files/caca.txt /system", "mount -o ro, remount -t yaffs2 /dev/block/mtdblock4 /system");

RootTools.getShell(true).add(command).waitForFinish();

}

public void End() {

ClosePD();

AlertDialog();

}

public void AlertDialog() {

AlertDialog.Builder builder = new AlertDialog.Builder(this);

builder.setMessage("Es necesario reiniciar para que se apliquen los cambios. Desea hacerlo ahora?")

.setTitle("Instalacion satisfactoria!")

.setCancelable(false)

.setNegativeButton("Reiniciar mas tarde",

new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int id) {

dialog.cancel();

}

})

.setPositiveButton("Reiniciar ahora",

new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int id) {

// metodo que se debe implementar

try {

ProcessBuilder pb = new ProcessBuilder(new String[] { "su", "-c", "/system/bin/reboot" });

java.lang.Process process = pb.start();

process.waitFor();

} catch (IOException e) {

}

// TODO Auto-generated method stub

catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

});

AlertDialog alert = builder.create();

alert.show();

}

public void ClosePD() {

progressDialog.dismiss();

}

private static void copy(InputStream is, OutputStream os) {

// TODO Auto-generated method stub

}

public void makeToast(String msg) {

Context context = getApplicationContext();

CharSequence text = msg;

int duration = Toast.LENGTH_LONG;

Toast toast = Toast.makeText(context, text, duration);

toast.show();

}

public void RootActions() {

}

}

This is all my code, I use your library and RootTool library.

I have two issues:

1- Error in waitForFinish();

2- processDialog don't appear.

Enviado desde mi GT-S5570I usando Tapatalk 2