简体   繁体   English

授予Android应用(.apk)文件根访问权限

[英]Give Android applciation (.apk) file root access

I develope application in which i execute command which need to root access. 我开发的应用程序在其中执行需要root访问权限的命令。

I also used java Process to execute command but it also not working. 我也使用java进程执行命令,但是它也不起作用。

For that i use c api using JNI ( NDK ) but it also not have access as root. 为此,我使用使用JNI(NDK)的c api,但它也没有以root身份访问。 because it having same permission as application. 因为它具有与应用程序相同的权限。

My device as root access that's why it execute command in adb shell. 我的设备作为root用户访问权限,这就是为什么它在adb shell中执行命令。 but not from application. 但不是来自应用程序。

is there any way to give root permission to application ? 有什么办法可以授予应用程序root权限?

Please give solution ... 请给解决方案...

For give application system permission. 用于授予应用程序系统权限。

you need to sign application with the platform signature. 您需要使用平台签名对应用程序进行签名。 You need to use keys located in <root-of-android-source-tree>/build/target/product/security/ and add android:sharedUserId="android.uid.system" in your AndroidManifest.xml file. 您需要使用位于<root-of-android-source-tree>/build/target/product/security/ android:sharedUserId="android.uid.system"并在AndroidManifest.xml文件中添加android:sharedUserId="android.uid.system"

Steps : 脚步 :

sign application with the platform certificate and run it with the system sharedUserId. 使用平台证书签署应用程序,然后使用系统sharedUserId运行它。 These are the steps: 这些步骤是:

  • Build and flash to your Dream your own Android using http://source.android.com/documentation/building-for-dream . 使用http://source.android.com/documentation/building-for-dream将自己的Android生成并刷新到Dream。 Use the mkkey.sh script on http://pdk.android.com/online-pdk/guide/release_keys.html to create new certificates, including x509 certificates before you do 'make'. 在执行“ make”操作之前,请使用http://pdk.android.com/online-pdk/guide/release_keys.html上的mkkey.sh脚本创建新证书,包括x509证书。
  • In the AndroidManifest.xml of your application: under the <manifest> element, add the attribute android:sharedUserId="android.uid.system" . 在应用程序的AndroidManifest.xml中: <manifest>元素下,添加属性android:sharedUserId="android.uid.system"
  • Export an unsigned version of your Android application using Eclipse: right-click on the project >> Android Tools >> Export Unsigned Application Package. 使用Eclipse导出未签名版本的Android应用程序:右键单击项目>> Android Tools >>导出未签名应用程序包。
  • Use <root-of-android-source-tree>/out/host/<your-host>/framework/signapk.jar to sign your app using platform.x509.pem and platform.pk8 in <root-of-android-source-tree>/build/target/product/security generated earlier: 使用<root-of-android-source-tree>/out/host/<your-host>/framework/signapk.jar<root-of-android-source-tree>/build/target/product/security使用platform.x509.pemplatform.pk8对应用进行<root-of-android-source-tree>/build/target/product/security之前生成的:

     java -jar signapk.jar platform.x509.pem platform.pk8 YourApp-unsigned.apk YourApp-signed.apk. 
  • Install the app to your device: 将应用程序安装到您的设备上:

     adb install YourApp-signed.apk 
  • Run your app 运行你的应用
  • Use adb shell ps to confirm that your app is running as system. 使用adb shell ps确认您的应用程序正在作为系统运行。

谈论根访问权限时,您必须在清单文件链接中提供权限,然后在根电话中安装该应用程序之后,su应用程序将要求进行根访问权限

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM