ServiceMananger管理Service需要System权限的问题

与PC/SC交互时使用Android特有的Binder机制,由SerivceManager负责Service的注册与获取,但是在注册时,需要系统权限,所以在AndroidManifest.xml中加入android:sharedUserId="android.uid.system",此时不能在开发板上安装成功。因为没有对其签名,必须到编译后的源码中去找到
引用
out/host/linux-x86/framework/signapk.jar
build\target\product\security\platform.x509.pem
build\target\product\security\platform.pk8

这三个文件并进行签名
java -jar ${filePath}\signapk.jar platform.x509.pem platform.pk8 source.apk output.apk


但由于该公钥和私钥是只限于原生的Android或者自己编译的系统,其他手机是无法安装的,安装时会提示错误信息。

只能直接放到/system/app/目录下的,绕开签名检查。同时用RootExplorer把该APK的使用者改为System,重启手机,识别不了该apk,logcat打印还是因为签名问题.最终得出结论此方案是不可行的。


关于执行需要root权限的shell命令(比如mount -o remount, rw /system)的问题:
分析RootExplorer的mount过程:

先看一下进程:

app_78    14887 94    148620 22504 ffffffff afd0c52c S com.speedsoftware.rootexplorerapp_78    14895 14887 804    344   c00a6f28 afd0c3bc S /system/bin/shroot      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.csdn.net/a345017062/article/details/6441986
http://blog.csdn.net/a345017062/article/details/6442306

ROOT权限获取:
http://bbs.gfan.com/android-3079149-1-1.html

简单的说,就是把zergRush拷贝到系统的临时文件夹下并运行,然后把su拷贝到系统文件夹中,这样就可以以root权限运行程序了。

更多相关文章

  1. Android系统信息与安全机制
  2. Android调用系统分享,资源未找到问题
  3. android系统权限关机重启
  4. Android模拟、实现、触发系统按键事件的方法
  5. android 日期时间格式转换;软键盘显示消失;获取系统title
  6. Android进程和线程
  7. Android内核的根文件系统
  8. Android P 系统应用无法对外置SD卡进行读写

随机推荐

  1. android Immutable bitmap passed to Can
  2. Android涂鸦简单制作
  3. Android第九课 Toast 用法注意事项
  4. Android SSL BKS证书的生成过程
  5. 安卓模拟器设置网速和延迟
  6. 短视频app开源源码android 给图片加文字
  7. 在PC上体验Android
  8. OpenERP Android(安卓)DEMO工程发布下载
  9. 【Android View】Android中View对触摸事
  10. 模拟器无法启动,卡在android字样的界面上