0

Was reading over Android system application DEVICE_POWER permission error and How to sign Android app with system signature?

I am still unable to sign my application as a system app. I don't know where /build/target/product/security is.

Do I pull the key off my own device to use for signing my app.

I just want my app to be able to call:

private void screenOff(){
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);

    long time = SystemClock.uptimeMillis() + 1000;
    pm.goToSleep(time);
}

Thanks for your answers.

Community
  • 1
  • 1
mparkes
  • 332
  • 3
  • 12

3 Answers3

3

You can only sign your application as a system app if you are building Android from source for your project. If you're interested in a hack that will only work on your phone see:

How to sign Android app with system signature?

Community
  • 1
  • 1
Kevin Parker
  • 16,975
  • 20
  • 76
  • 105
2

You can't do that.

Only the device manufacturer can sign apps with the system key - the same way only you can sign apps with your key. And each device (at least each manufacturer) has a different system key. None of them will ever give you that key.

The only way to get to that permission is by building your own device firmware (e.g. CyanogenMod so you know that key (/build/target/product/security is part of those sources). But if you do that you still can't distribute your app since only you (+ other people using your firmware) have the right key.

zapl
  • 63,179
  • 10
  • 123
  • 154
  • Great, thanks for the info... My power button is malfunctioning so I was trying to write a quick app to turn the screen off instead of having to wait for a timeout. – mparkes Aug 21 '12 at 05:51
0

I think your need is to have your app to have the permission for DEVICE_POWER. yes , the normal apps cannot have that permission. But you can make your app a privileged one. If you make it a privileged one, in the build, the app will be created in your /system/priv-apps/

to make your app a privileged one, in the Android.mk file , add the below code: LOCAL_PRIVILEGED_MODULE := true

Cheers!!!

JVN
  • 239
  • 2
  • 16