80,362
社区成员
发帖
与我相关
我的任务
分享
try{
process = Runtime.getRuntime().exec("/system/xbin/su"); //ran as root
outstr = new DataOutputStream(process.getOutputStream());
instr = new DataInputStream(process.getInputStream());
outstr.writeBytes("/system/bin/chmod 777 /dev/i2c-0" + " \n"); //modify the device properties
outstr.writeBytes(" exit \n");
outstr.flush();
process.waitFor();
}catch(Exception e){
System.out.println("set mac error!");
}
试了一下子,运行命令不成功,不知道是root的问题还是什么问题[/quote]
代码贴错了[/quote]
apk好像没有权限执行etcfg eth0 hwaddr xxx。你把这个命令做成服务放在init.rc里面,apk通过ctrl.start来启动这个服务吧
try{
process = Runtime.getRuntime().exec("/system/xbin/su"); //ran as root
outstr = new DataOutputStream(process.getOutputStream());
instr = new DataInputStream(process.getInputStream());
outstr.writeBytes("/system/bin/chmod 777 /dev/i2c-0" + " \n"); //modify the device properties
outstr.writeBytes(" exit \n");
outstr.flush();
process.waitFor();
}catch(Exception e){
System.out.println("set mac error!");
}
试了一下子,运行命令不成功,不知道是root的问题还是什么问题[/quote]
代码贴错了
是用户空间,不知能实现否。
或者有其它方法实现吗?[/quote]
是驱动的,如果不在驱动中解决那最好了。
看来只有用笨办法了,串口中netcfg eth0 hwaddr xxx
然后再做成apk,让用户自己去定义吧。
这个方法问题是android应用中如何去执行命令,
试了一下子,运行命令不成功,不知道是root的问题还是什么问题