问题
Can I (As an AOSP builder) pre install some apps so after burning on device, they can easily be uninstalled (like regular downloaded apps)?
I am already familiar with system apps and priv-apps but as they lie in system partition they can not be removed! (only disabled in settings menu)
P.S. I know huawei for example uses /system/delapp to install such apps. But I seek for a general way or for AMLogic platform specifically which I am working on!
回答1:
You can do that by configuring your build to produce a userdata.img
file with your app(s) included, which you can then flash with fastboot flash userdata
.
The Android.mk
file for these apps that go in userdata.img
roughly looks like the following:
include $(CLEAR_VARS)
LOCAL_MODULE := myapp1
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/app
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
And add the apps to product packages in device.mk
:
PRODUCT_PACKAGES += myapp1 myapp2 ...
You should be able to find plenty of examples on GitHub, e.g., https://github.com/search?l=Makefile&q=TARGET_OUT_DATA+BUILD_PREBUILT&type=Code
Since you are building the image from scratch, you can put your apps in a custom directory under and package a script to install them on boot time if they are not already installed. You can invoke that script by editing the init.rc
file as follows:
on property:dev.bootcomplete=1
exec - system system -- /system/bin/sh /path/to/installer/script.sh
The installer script can be as simple as:
for apkfile in /path/to/custom/apps/*.apk; do
/system/bin/pm install "$apkfile"
done
来源:https://stackoverflow.com/questions/53415804/pre-install-some-apps-so-they-can-be-uninstalled-without-root-by-user