我在市场上有一个应用程序,只适用于根植设备。我已经在根本无根的G1,MT3G和Cliq上广泛测试了该应用程序,没有任何错误。我收到来自植入设备的人的低收视率,说应用程序告诉他们他们没有植根(当然,他们通常不会留下重要的信息,如电话和什么光盘)Android:应用程序无法在某些根植设备上工作...为什么?
这里是产生错误的代码...任何人都可以看出问题可能是什么?
final Button button = (Button) findViewById(R.id.******);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String command1 = "mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system";
String command2 = "cp -f /sdcard/******* /etc/";
String command3 = "dos2unix -u /etc/*****";
String command4 = "mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system";
execCommandLine1(command1);
execCommandLine1(command2);
execCommandLine1(command3);
execCommandLine1(command4);
}
void execCommandLine1(String command)
{
Runtime runtime = Runtime.getRuntime();
Process proc = null;
OutputStreamWriter osw = null;
try
{
proc = runtime.exec("su");
osw = new OutputStreamWriter(proc.getOutputStream());
osw.write(command);
osw.flush();
osw.close();
}
catch (IOException ex)
{
Log.e("execCommandLine()", "Command resulted in an IO Exception: " + command);
return;
}
finally
{
if (osw != null)
{
try
{
osw.close();
}
catch (IOException e){}
}
}
try
{
proc.waitFor();
}
catch (InterruptedException e){}
if (proc.exitValue() != 0)
{
**// Error Dialog that is being erroneously displayed**
}
else {
// Success Dialog
}
}
而错误是......什么? – CommonsWare 2010-10-12 21:26:05
我想某些设备在'/ dev/block/mtdblock3'可能没有'/ system'文件系统,或者它们没有安装'dos2unix'或者路径中。 – 2010-10-12 21:33:03
@CommonsWare我的错误对话框正显示在一些有根的设备上......指示(proc.exitValue()!= 0)不应该发生在根源电话上,除非我的命令或我的方式有问题正在执行它们 – 2010-10-12 21:44:15