Android system prefabricated without source code apk

1. Environment

Qualcomm 865 Android10

2. Prefabrication related steps

1. Create a folder under packages/apps with the name of the APK that needs to be preset. Take the preset APK named TestDataDir as an example

2. Put TestDataDir.apk in the packages/apps/TestDataDir directory

3. Create a file Android.mk in the packages/apps/TestDataDir directory, the file content is as follows:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

# 模块名称
LOCAL_MODULE :=TestDataDir
# 定义编译完成之后的类型:除了APPS,还有ETC,EXECUTABLES(.bin)SHARED_LIBRARIES(.so)等选择值
LOCAL_MODULE_CLASS :=APPS
# APK文件
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
#或者LOCAL_SRC_FILES := TestDataDir.apk

# 定义app签名可用选择项platform,shared,media,签名,如无需重签名,则直接设置为PRESIGNED使用已有签名;需要重签,则设置为对应签名的值。
LOCAL_CERTIFICATE := PRESIGNED


# 不管是user 还是eng 版本都会编译此app ;
# LOCAL_MODULE_TAGS := optiona


# 目标编译后的输出目录
#LOCAL_MODULE_PATH := $(TARGET_OUT)/priv-app
# APK预置的so
# ifeq ($(strip $(TARGET_ARCH)), arm64)
#     LOCAL_PREBUILT_JNI_LIBS := libs/arm64-v8a/libjni_jpeg.so
# else ifeq ($(strip $(TARGET_ARCH)), x86_64)
#     LOCAL_PREBUILT_JNI_LIBS := libs/x86_64/libjni_jpeg.so
# else ifeq ($(strip $(TARGET_ARCH)),arm)
#     LOCAL_PREBUILT_JNI_LIBS := libs/armeabi-v7a/libjni_jpeg.so
# else
#     LOCAL_PREBUILT_JNI_LIBS := libs/x86/libjni_jpeg.so
# endif

# true--将apk编进“/system/priv-app/目录”;如果为false,或者不加这句话,就会编进“/system/app”
#LOCAL_PRIVILEGED_MODULE := true


include $(BUILD_PREBUILT)


#注: 使用LOCAL_PREBUILT_JNI_LIBS列出所有so的路径,@标识符会将apk中的so抽离出来build进system/lib或者system/lib64中
# 例如:LOCAL_PREBUILT_JNI_LIBS:= \
# @lib/armeabi/libtest.so  \
# @lib/armeabi/libtest2.so

4. Add TestDataDir in build/make/target/product/handheld_product.mk

 5. Add TestDataDir in the following file (if there is no whitelist configuration file in the system, this step can be omitted)

device/qcom/kona/apps_white_list.txt

device/qcom/qssi/apps_white_list.txt

6. Compile and verify

3. Detailed explanation of some parameters

1. LOCAL_CERTIFICATE := platform/shared/media (Note, Android.mk fills in which of the three platforms/shared/media is determined according to AndroidManifest.xml):

(1)platform签名: 
AndroidManifest.xml的manifest节点中添加 android:sharedUserId=”android.uid.system”, 
Android.mk中增加  LOCAL_CERTIFICATE := platform 
(2)shared签名: 
AndroidManifest.xml的manifest节点中增加android:sharedUserId=”android.uid.shared”, 
Android.mk中增加LOCAL_CERTIFICATE := shared 
(3)media签名: 
AndroidManifest.xml的manifest节点中增加 android:sharedUserId=”android.media”, 
Android.mk中增加 LOCAL_CERTIFICATE := media 

2、include $(BUILD_PACKAGE)

include $(BUILD_PREBUILT)                #这种方式把文件当成编译项目,
include $(BUILD_PACKAGE)                 #是用来编译生成apk。
include $(BUILD_STATIC_LIBRARY)          #表示编译成静态库
include $(BUILD_SHARED_LIBRARY)          #表示编译成动态库
include $(BUILD_EXECUTABLE)              #表示编译成可执行程序
include $(BUILD_STATIC_JAVA_LIBRARY)     #表示编译生成静态jar包

3. Common functions

$(call all-java-files-under, <src>)    #获取指定目录下的所有java文件。
 
$(call all-c-files-under, <src>)    #获取指定目录下的所有c文件。
 
$(call all-Iaidl-files-under, <src>)    #获取指定目录下的所有AIDL文件。
 
$(call all-makefiles-under, <folder>)    #获取指定目录下的所有Make文件。
 
#获取Build输入的目标文件夹路径。 
$(call intermediates-dir-for, <class>, <app_name>, <host or target>, <common?>) 
   
#在LOCAL_PATH的所有子目录中查找.mk文件,不包括当前目录 
$(call first-makefiles-under,$(LOCAL_PATH)) 

Guess you like

Origin blog.csdn.net/banzhuantuqiang/article/details/131538131