Android What permissions are required to call PowerManager.goToSleep (n) to wake up the device?

Android.permissions.DEVICE_POWER is already installed in the manifest of my application. Still complaining that neither the user nor the process have this permission when I call PowerManager.gotoSleep (n) in action. What other settings are needed for this? Thank you. This is on my Samsung ATT phone.

+6
source share
3 answers

In the old version, I read that this is a permission protected signature, that is, only applications that received signed as system applications.

+2
source

DEVICE_POWER is a permission at level 2 and a protected permission and, therefore, it is not granted to any of the applications that request it through the manifest, in order to get this permission successfully, we need to have a platform certificate in our make file and the general user identifier specified in manifest as a system ...

LOCAL_CERTIFICATE := platform (makefile entry) android.uid.system (shared user id ) 

There is no way around this, I looked around, did not find anything ...

+2
source
 java -jar signapk.jar platform.x509.pem platform.pk8 bin/TestApp-unsigned.apk bin/TestApp.apk 

I had the same issue and it worked for me. Get signapk.jar from https://github.com/appium/sign . the repository also includes an Android test certificate that works, for example. with a rooted corner.

0
source

Source: https://habr.com/ru/post/886203/


All Articles