[G1 Android Development] zezol:
Hi!

I'm writing a small application that allows you to enable or disable RamHack. There is a problem. The logs show that the app does not have permission.

At the beginning of the code doing the command "su":

final Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("su");
}
catch (IOException e) {
e.printStackTrace();
}

Then after tap a button I execute this:

final Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("mkdir /sdcard/switch_rh");
runtime.exec("wget -P /sdcard/switch_rh URL_to_my_site/rhpack.zip");
runtime.exec("unzip -o /sdcard/switch_rh/rhpack.zip -d /sdcard");
runtime.exec("rwsystem");
runtime.exec("flash_image boot /sdcard/2.img");
runtime.exec("cp /sdcard/2.ko /system/lib/modules/wlan.ko");
runtime.exec("rosystem");
runtime.exec("rm -r /sdcard/2.ko");
runtime.exec("rm -r /sdcard/2.img");
runtime.exec("reboot");
}
catch (IOException e) {
e.printStackTrace();
}

The logs show like this:

03-24 19:55:30.682: WARN/System.err(12444): java.io.IOException: Error running exec(). Commands: [rwsystem] Working Directory: null Environment: null
03-24 19:55:30.692: WARN/System.err(12444): at java.lang.ProcessManager.exec(ProcessManager.java:196)
03-24 19:55:30.692: WARN/System.err(12444): at java.lang.Runtime.exec(Runtime.java:225)
03-24 19:55:30.692: WARN/System.err(12444): at java.lang.Runtime.exec(Runtime.java:313)
03-24 19:55:30.692: WARN/System.err(12444): at java.lang.Runtime.exec(Runtime.java:246)
03-24 19:55:30.692: WARN/System.err(12444): at pl.zezol.switch_rh.MainActivity$1.onClick(MainActivity.java:76)
03-24 19:55:30.692: WARN/System.err(12444): at android.view.View.performClick(View.java:2360)
03-24 19:55:30.692: WARN/System.err(12444): at android.view.View.onTouchEvent(View.java:4194)
03-24 19:55:30.692: WARN/System.err(12444): at android.widget.TextView.onTouchEvent(TextView.java:6534)
03-24 19:55:30.692: WARN/System.err(12444): at android.view.View.dispatchTouchEvent(View.java:3724)
03-24 19:55:30.692: WARN/System.err(12444): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
03-24 19:55:30.692: WARN/System.err(12444): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
03-24 19:55:30.692: WARN/System.err(12444): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
03-24 19:55:30.692: WARN/System.err(12444): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
03-24 19:55:30.722: WARN/System.err(12444): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1712)
03-24 19:55:30.722: WARN/System.err(12444): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1202)
03-24 19:55:30.742: WARN/System.err(12444): at android.app.Activity.dispatchTouchEvent(Activity.java:2019)
03-24 19:55:30.742: WARN/System.err(12444): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1696)
03-24 19:55:30.742: WARN/System.err(12444): at android.view.ViewRoot.handleMessage(ViewRoot.java:1660)
03-24 19:55:30.742: WARN/System.err(12444): at android.os.Handler.dispatchMessage(Handler.java:99)
03-24 19:55:30.742: WARN/System.err(12444): at android.os.Looper.loop(Looper.java:123)
03-24 19:55:30.742: WARN/System.err(12444): at android.app.ActivityThread.main(ActivityThread.java:4358)
03-24 19:55:30.742: WARN/System.err(12444): at java.lang.reflect.Method.invokeNative(Native Method)
03-24 19:55:30.742: WARN/System.err(12444): at java.lang.reflect.Method.invoke(Method.java:521)
03-24 19:55:30.742: WARN/System.err(12444): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
03-24 19:55:30.742: WARN/System.err(12444): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
03-24 19:55:30.742: WARN/System.err(12444): at dalvik.system.NativeStart.main(Native Method)
03-24 19:55:30.742: WARN/System.err(12444): Caused by: java.io.IOException: Permission denied
03-24 19:55:30.742: WARN/System.err(12444): at java.lang.ProcessManager.exec(Native Method)
03-24 19:55:30.742: WARN/System.err(12444): at java.lang.ProcessManager.exec(ProcessManager.java:194)
03-24 19:55:30.742: WARN/System.err(12444): ... 25 more
03-24 19:55:31.102: WARN/su(12516): request rejected (10085:10085->0:0 /system/bin/sh)

What can I do that the program had access to the root?

PS. Sorry for my bad English.

Cheers