Pre-install some apps so they can be uninstalled w

2019-06-24 10:02发布

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条回答
霸刀☆藐视天下
2楼-- · 2019-06-24 10:11

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
查看更多
登录 后发表回答