Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install apk in background using busybox

can i install apk in background using busybox on rooted device ???

i see something like that but it doesn't work

process install;
CommandCapture command = new CommandCapture(0, "chmod 777 /data/app");
RootTools.getShell(true).add(command).waitForFinish(); 
CommandCapture command2 = new CommandCapture(0, "chmod 777 /system/xbin/busybox");
RootTools.getShell(true).add(command2).waitForFinish();
install = Runtime.getRuntime().exec("/system/xbin/busybox install " + Environment.getExternalStorageDirectory() + "/Download/" + "xxx.apk /data/app/xxx.apk");
like image 505
Omar Abdan Avatar asked Sep 26 '12 09:09

Omar Abdan


2 Answers

without using busybox

install = Runtime.getRuntime().exec("su");   
DataOutputStream os = new DataOutputStream(install.getOutputStream());  
os.writeBytes("pm install "+APKFile.apk+"\n");  
os.writeBytes("exit\n"); 
os.flush();
install.waitFor();
like image 110
Omar Abdan Avatar answered Nov 11 '22 18:11

Omar Abdan


It looks you use two paths for your busybox binary. First you chmod it in /system/xbin, but then you invoke it from system/bin. Ensure you use right path. And chmod 777 /data/app looks VERY BAD.

like image 33
Marcin Orlowski Avatar answered Nov 11 '22 17:11

Marcin Orlowski