2012-09-26 52 views
8

我可以安裝apk在後臺使用busybox rooted設備上?安裝apk在後臺使用busybox

我看到類似的東西,但它不工作

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"); 

回答

1

如果您在根shell中運行su -c pm install myapp.apk,則應該可以在後檯安裝(請注意'pm')部分。這與busybox無關,您可以使用任何shell,您當然不需要更改/data/app的權限。

+0

的路徑感謝ü的回答,但我想從外殼 –

+1

這正是你的鱈魚上面嘗試做安裝APK程序不是:用一個命令('install')和一個參數('xxx.apk')啓動一個shell('busybox')。問題是沒有這樣的'install'命令,你需要使用'pm install'。你從哪裏複製這些代碼?閱讀他們的文檔/自述文件以瞭解它的實際功能。 –

+0

沒有在busybox中安裝命令,只是複製apk並將其放在/ data/app中,當你重新啓動設備安裝開始 –

2

看起來您使用兩個路徑,您的BusyBox的二進制文件。首先你chmod它在/system/xbin,但你從system/bin調用它。確保你使用正確的路徑。和chmod 777 /data/app的搭配看起來很不錯非常壞

+1

好吧,我修正的busybox –

3

不使用的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();