Android What permissions required to call PowerManager.goToSleep(n) put device in sleep mode?
Asked Answered
A

3

10

Already set android.permissions.DEVICE_POWER in manifest of my app. Still complains that neither user nor process have this permission when I call PowerManager.gotoSleep(n) within activity. What other settings are required for this to work? Thanks This is on My Samsung ATT phone

Archery answered 19/4, 2011 at 2:29 Comment(0)
S
3

DEVICE_POWER is a level 2 permission and protected permission and hence it is not provided to any app which request it via manifest, to get this permission successfully we need to have Platform certificate in our make file and shared user id set in manifest as system...

LOCAL_CERTIFICATE := platform (makefile entry)

android.uid.system (shared  user id )

There isnt a way around this i have looked around havent found any ...

Sidney answered 8/6, 2011 at 7:7 Comment(3)
Hi. Do you give me a reference where I can get in details step about this or would you please describe in more details.Scylla
Is there a way to do it on a rooted device?Karlis
@user2103379 check the solution given by "repat" below . cheers.Sidney
S
2

In old version, I read that it is a signature-protected permission, i.e. only apps that got signed as system apps are allowed to.

Shaun answered 19/4, 2011 at 2:36 Comment(4)
What is involved in getting app signed as system app? what if device is rooted? ThanksArchery
this can be answered as on separate question here:Archery
old version means 2.1 or pre 2.1?Archery
Also are there other ways to put device in sleep mode programatically? Like issuing an intent? ThanksArchery
G
1
java -jar signapk.jar platform.x509.pem platform.pk8 bin/TestApp-unsigned.apk bin/TestApp.apk

I had the exact same problem and this worked for me. Get signapk.jar from https://github.com/appium/sign. the repository also includes the Android test certificate, which works e.g. with a rooted nook.

Gabrielgabriela answered 22/10, 2013 at 19:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.