预安装一些应用程序,以便用户无需root即可将其卸载 [英] Pre-install some apps so they can be uninstalled without root by user
问题描述
我(作为AOSP生成器)可以预安装一些应用程序,以便在设备上刻录后轻松卸载(例如常规下载的应用程序)吗?
Can I (As an AOSP builder) pre install some apps so after burning on device, they can easily be uninstalled (like regular downloaded apps)?
我是已经熟悉系统应用程序和priv-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。我知道华为例如使用/ system / delapp安装此类应用程序。但是,我正在寻找一种通用方法或我正在使用的AMLogic平台!
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!
推荐答案
您可以通过配置自己的方法生成包含您的应用程序的 userdata.img
文件,然后可以使用 fastboot flash userdata
。
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
.
userdata.img 中这些应用的
大致如下所示: Android.mk
文件
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)
并将应用添加到 device.mk $ c $中的产品包中c>:
PRODUCT_PACKAGES += myapp1 myapp2 ...
您应该能够在GitHub上找到很多示例,例如> https://github.com/search?l=Makefile&q=TARGET_OUT_DATA+BUILD_PREBUILT&type=Code
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
由于您是从头开始构建映像,因此可以将应用程序放入自定义d irectory下并打包脚本以在启动时安装它们(如果尚未安装)。您可以通过编辑 init.rc
文件来调用该脚本,如下所示:
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
安装脚本可以很简单:
for apkfile in /path/to/custom/apps/*.apk; do
/system/bin/pm install "$apkfile"
done
这篇关于预安装一些应用程序,以便用户无需root即可将其卸载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!