If I am an OEM making my own firmware and I want an app preinstalled on the device in a way that it can't be deleted, what do I need to do?
For example, suppose I make the ACME Gadget 2000, and when the user takes it out of the box it already has my app of Cats saying funny things, and I don't want the user to be able to delete it, what exactly do I have to do with the APK?
I have a Verizon Motorola Droid X开发者_如何转开发 and it comes with some apps on it that I can't delete. How do they DO that?
Thank you very much.
David
OEM applications that are unremovable are installed to the /system/app
directory (at least in every case I've ever seen, I suppose there may be exceptions). They cannot be uninstalled (sans rooting the device) because the /system
partition is mounted read-only by default. I don't know of any way to design an .apk itself to be uninstallable since there are obviously significant security implications to allowing developers to do this.
Example mount listing from a Samsung Fascinate:
/dev/block/stl9 /system rfs ro,relatime,vfat,log_off,check=no,gid/uid/rwx,iochaset=utf8 0 0
I mean it's a bit tricky but can be done. You have to allocate BroadcastReceiver
, which triggered when occurs android.intent.action.PACKAGE_REMOVED
, like:
<receiver android:name ="com.mydomain.myapplication.PackageReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package" />
</intent-filter>
</receiver>
And then when you will catch this Intent in your BroadcastReceiver
- just cancel it. Well, probably you ought to define intent filter priority in a way to receive broadcast before others.
But problem is in simple fact that package which is going to be removed doesn't receive android.intent.action.PACKAGE_REMOVED
. That means that you have to keep your own separate application/package which will have service observing who's gonna to uninstall your application.
That's general scheme - but in reality how it'd work - I dunno... Try!
精彩评论