mparkes
mparkes

Reputation: 332

How do I sign an Android application as a system app to use DEVICE_POWER permission

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.

Upvotes: 0

Views: 3509

Answers (3)

JVN
JVN

Reputation: 239

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

Upvotes: 0

zapl
zapl

Reputation: 63955

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.

Upvotes: 2

Kevin Parker
Kevin Parker

Reputation: 17206

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?

Upvotes: 3

Related Questions