7

I'm implementing a demo on silently uninstall an app from device.

In adb shell, I can use pm uninstall packagename to do the task, but when I wrote code, I got some permission denied error.

I've been googling for a while, and found that to get DELETE_PACKAGES permission, I have to sign my app with the same certificate as the system does.

So, can anyone give me some tips on how to do this? Or, is there anyway I can do to make my app running as system service?

PearsonArtPhoto
  • 38,970
  • 17
  • 111
  • 142
Void Main
  • 2,241
  • 3
  • 27
  • 36

4 Answers4

5

You can't do this, unless you are building your own firmware (ROM). If you are, just take the key that signs the ROM and sign your apk with it. If you have a rooted phone, you can also copy the apk in /system/app to get the permission.

Nikolay Elenkov
  • 52,576
  • 10
  • 84
  • 84
  • thanks, but I'm not building my own firmware. can I build my app with source? – Void Main Mar 16 '12 at 03:26
  • 2
    You could, but if the ROM on the device is not signed with the same key, it won't work. If you are using stock firmware (from a carrier, etc.), the only way is to root the phone and copy it `/system/app`. Or you could ask them (nicely!) to sign it for you :) – Nikolay Elenkov Mar 16 '12 at 03:36
  • alright, copy it to /system/app sounds like a good choice, thanks! – Void Main Mar 16 '12 at 03:37
  • Does copying to /system/app really give access to all system permissions? I'm not seeing this: http://stackoverflow.com/questions/24296286/can-you-get-android-system-permissions-on-a-stock-image-w-root – davidgyoung Jun 19 '14 at 03:38
  • 3
    signatureOrSystem level only.Also on 4.4+ you need to be in /system/priv-app for this tovwork. – Nikolay Elenkov Jun 19 '14 at 05:13
2

Far better than a silent uninstall is somehow bricking the app. There's a few ways that this could be done, but basically keep track of the first day they used it, and make the program not work. Alternatively, it could be set up to work until a certain day, after which it will no longer work. This question answers how to do this.

Community
  • 1
  • 1
PearsonArtPhoto
  • 38,970
  • 17
  • 111
  • 142
1

If your application is not located at "/system/app",permission "DELETE_PACKAGES" would not work. Compile your app with source code or try "root" ;)

Clover
  • 46
  • 2
  • hi clover, I decided to compile my app with source code, and I got this error: java.security.cert.CertificateParsingException: signed fields invalid, what's wrong here? – Void Main Mar 16 '12 at 03:22
  • I added this line in my Android.mk file, LOCAL_CERTIFICATE := platform; and used mmm packages/app/test/ to build this app. – Void Main Mar 16 '12 at 03:25
  • Did your app uses certificate action?You know I've never seen this exception before.Or change platform to shared and try to "make" source code~ – Clover Mar 19 '12 at 01:20
-3

I have experience about how get one application permission to read browser bookmark

  1. Open the AndroidManifest.xml of That application that you want to add permission to it.

2.Somewhere between

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
</manifest> 

add this code

<uses-permission android:name="..." />

3.For fill the ... go here For example the following code will permit to app to get bookmark history

Alireza.Heidari
  • 737
  • 1
  • 8
  • 11
  • This question looks like it's about granting restricted system permissions rather than normal public permissions. – Sam Apr 27 '15 at 11:26