Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

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

like image 259
Androider Avatar asked Apr 19 '11 02:04

Androider


People also ask

How do I prevent an Android device from going to sleep programmatically?

Using android:keepScreenOn="true" is equivalent to using FLAG_KEEP_SCREEN_ON . You can use whichever approach is best for your app. The advantage of setting the flag programmatically in your activity is that it gives you the option of programmatically clearing the flag later and thereby allowing the screen to turn off.


1 Answers

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 ...

like image 95
amIT Avatar answered Nov 11 '22 13:11

amIT