[b]ServiceMananger管理Service需要System权限的问题[/b]
与PC/SC交互时使用Android特有的Binder机制,由SerivceManager负责Service的注册与获取,但是在注册时,需要系统权限,所以在AndroidManifest.xml中加入android:sharedUserId="android.uid.system",此时不能在开发板上安装成功。因为没有对其签名,必须到编译后的源码中去找到
[quote]
out/host/linux-x86/framework/signapk.jar
build\target\product\security\platform.x509.pem
build\target\product\security\platform.pk8
[/quote]
这三个文件并进行签名
但由于该公钥和私钥是只限于原生的Android或者自己编译的系统,其他手机是无法安装的,安装时会提示错误信息。
只能直接放到/system/app/目录下的,绕开签名检查。同时用RootExplorer把该APK的使用者改为System,重启手机,识别不了该apk,logcat打印还是因为签名问题.最终得出结论此方案是不可行的。
[b]关于执行需要root权限的shell命令(比如mount -o remount, rw /system)的问题:[/b]
分析RootExplorer的mount过程:
先看一下进程:
可见rootexplorer在启动了一个同用户级别的shell进程后,通过这个shell进程又启动了一个root级别的shell进程,此时我们就可以用这个shell执行需要root权限的命令了。
参考:
http://blog.youkuaiyun.com/a345017062/article/details/6441986
http://blog.youkuaiyun.com/a345017062/article/details/6442306
ROOT权限获取:
http://bbs.gfan.com/android-3079149-1-1.html
简单的说,就是把zergRush拷贝到系统的临时文件夹下并运行,然后把su拷贝到系统文件夹中,这样就可以以root权限运行程序了。
与PC/SC交互时使用Android特有的Binder机制,由SerivceManager负责Service的注册与获取,但是在注册时,需要系统权限,所以在AndroidManifest.xml中加入android:sharedUserId="android.uid.system",此时不能在开发板上安装成功。因为没有对其签名,必须到编译后的源码中去找到
[quote]
out/host/linux-x86/framework/signapk.jar
build\target\product\security\platform.x509.pem
build\target\product\security\platform.pk8
[/quote]
这三个文件并进行签名
java -jar ${filePath}\signapk.jar platform.x509.pem platform.pk8 source.apk output.apk
但由于该公钥和私钥是只限于原生的Android或者自己编译的系统,其他手机是无法安装的,安装时会提示错误信息。
只能直接放到/system/app/目录下的,绕开签名检查。同时用RootExplorer把该APK的使用者改为System,重启手机,识别不了该apk,logcat打印还是因为签名问题.最终得出结论此方案是不可行的。
[b]关于执行需要root权限的shell命令(比如mount -o remount, rw /system)的问题:[/b]
分析RootExplorer的mount过程:
先看一下进程:
app_78 14887 94 148620 22504 ffffffff afd0c52c S com.speedsoftware.rootexplorer
app_78 14895 14887 804 344 c00a6f28 afd0c3bc S /system/bin/sh
root 14897 14895 812 360 c0123a2c afd0b46c S sh
可见rootexplorer在启动了一个同用户级别的shell进程后,通过这个shell进程又启动了一个root级别的shell进程,此时我们就可以用这个shell执行需要root权限的命令了。
ProcessBuilder pBuilder = new ProcessBuilder("/system/bin/sh");
pBuilder.directory(new File("/"));
try {
process = pBuilder.start();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
BufferedReader error = new BufferedReader(new InputStreamReader(process.getErrorStream()));
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(process.getOutputStream())), true);
out.println(cmd);
String line;
while ((line = input.readLine()) != null) {
Log.e("SystemCmdUtil", "line: "+line);
}
while ((line = error.readLine()) != null) {
Log.e("SystemCmdUtil", "error: "+line);
}
input.close();
out.close();
} catch (Exception e) {
Log.e("SystemCmdUtil", e.getMessage());
}
参考:
http://blog.youkuaiyun.com/a345017062/article/details/6441986
http://blog.youkuaiyun.com/a345017062/article/details/6442306
ROOT权限获取:
http://bbs.gfan.com/android-3079149-1-1.html
简单的说,就是把zergRush拷贝到系统的临时文件夹下并运行,然后把su拷贝到系统文件夹中,这样就可以以root权限运行程序了。