开发者

how to get platform certificate to sign an app which does a reboot

开发者 https://www.devze.com 2023-03-09 18:31 出处:网络
The link Get the REBOOT permission in Android app do provide a little info.i am able to sign an app with debug.keystore,but i hav to sign with same key used by the system so that it allows permission

The link Get the REBOOT permission in Android app do provide a little info.i am able to sign an app with debug.keystore,but i hav to sign with same key used by the system so that it allows permission to reboo开发者_如何学Got.where to find the platform/certificate key pairs?


You will not be able to sign using a system signature. It is a very basic security measure.

As CommonsWare said in the answer you linked, you will need a custom firmware for that. A simpler option is to provide the functionality only in rooted phones (See here for a simple way to do it: Can a Device Administration Application on a rooted Android phone programmatically force a shutdown or reboot?).


Check here if you are working on emulator: essentials for creating system apk

If you are working on a real device:

  1. What you need is the vendor signature that's used to sign all the modified Android system inside the device.
  2. You won't have any system signature of any producer unless they publish it.
  3. So, you will not get the signature or the platform files unless you have the vendor/security folder of the rom inside the device.

You should go for rooting method after your application is ready to be installed.

  • Root your phone
  • Open a terminal on your pc, go to platform-tools folder and start adb executable
  • adb push /path/to/your/apk/your_apk.apk /sdcard/Download
  • Go into adb shell
  • su
  • mount -o remount,rw /system
  • cp /sdcard/Download/your_apk.apk /system/app
  • chmod 666 /system/app/your_apk.apk
  • Reboot your phone

You will have an application which is working with system permissions after rebooting.

EDIT: Not sure if it works for 5.0 +, used to work for 5.0 and lower.


Building a APK that should be signed with the platform key

  LOCAL_PATH := $(call my-dir)
  include $(CLEAR_VARS)

  # Build all java files in the java subdirectory
  LOCAL_SRC_FILES := $(call all-subdir-java-files)

  # Name of the APK to build
  LOCAL_PACKAGE_NAME := LocalPackage

  LOCAL_CERTIFICATE := platform

  # Tell it to build an APK
  include $(BUILD_PACKAGE)
0

精彩评论

暂无评论...
验证码 换一张
取 消