天天看點

安卓 (一) 怎麼添加檔案進安卓

  • 安卓環境
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=8.1.0
TARGET_PRODUCT=xxx
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=cortex-a7
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.13.0-32-generic-x86_64-with-Ubuntu-12.04-precise
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=OPM1.171019.011
           
添加檔案方法
1. 添加二進制到 system 目錄
	有兩種方法
		修改 PRODUCT_COPY_FILES 變量 (device/qcom/xxx/xxx.mk)
			PRODUCT_COPY_FILES += device/qcom/xxx/zzz:vendor/bin/zzz 
		修改 PRODUCT_PACKAGES 變量, 并将 檔案做成 包 (device/qcom/common/base.mk vendor/qcom/proprietary/common/config/device-vendor.mk device/qcom/xxx/xxx.mk)
			實際上并不是直接 修改 PRODUCT_PACKAGES 變量, 因為 PRODUCT_PACKAGES 變量 PRODUCT_PACKAGES += $(QQQ)
			然後可以用 QQQ += zzz (zzz 是子產品名)

           
  • 方法1 PRODUCT_COPY_FILES
PRODUCT_COPY_FILES += device/qcom/sw960/media/media_profiles_8909.xml:system/etc/media_profiles.xml \
device/qcom/sw960/media/media_profiles_8909.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_profiles_vendor.xml \
device/qcom/sw960/wearable_core_hardware.xml:system/etc/permissions/wearable_core_hardware.xml

           
  • 方法2 PRODUCT_PACKAGES
# Below projects/packages with LOCAL_MODULEs will be used by                         
# PRODUCT_PACKAGES to build LOCAL_MODULEs that are tagged with                       
# optional tag, which will not be available on target unless                         
# explicitly list here. Where project corresponds to the vars here                   
# in CAPs.


// 二進制可執行檔案 , 腳本檔案

include $(CLEAR_VARS)                                                                
LOCAL_MODULE        := zzz                                                          
LOCAL_MODULE_OWNER  := qcom                                                          
LOCAL_MODULE_TAGS   := optional                                                      
LOCAL_MODULE_CLASS  := EXECUTABLES                                                   
LOCAL_SRC_FILES     := ../../.././target/product/sw960/vendor/bin/zzz               
LOCAL_MODULE_PATH   := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/bin                  
LOCAL_PROPRIETARY_MODULE := true                                                     
include $(BUILD_PREBUILT)

// 源檔案 編譯 // 編譯出  bcom_dev ,并放置到 /system/bin/bcom_dev
LOCAL_PATH := $(call my-dir)                                                        
include $(CLEAR_VARS)                                                               
LOCAL_MODULE_TAGS := optional                                                    
LOCAL_SRC_FILES:= bcom_dev.c ./protocol/message_assemble.c ./protocol/message_recv.c ./protocol/protocol.c
#LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/../*.c)                             
#LOCAL_SRC_FILES :=$(call all-subdir-c-files)                                    
LOCAL_MODULE := bcom_dev                                                         
#LOCAL_SHARED_LIBRARY := liblog                                                  
#LOCAL_LDLIBS    := -llog                                                        
LOCAL_CFLAGS := -I protocol -DQCOM_IAM                                                               
include $(BUILD_EXECUTABLE)



// 庫檔案
include $(CLEAR_VARS)                                                                
LOCAL_MODULE        := gps.default                                                   
LOCAL_MODULE_CLASS  := SHARED_LIBRARIES                                              
LOCAL_MODULE_SUFFIX := .so                                                           
LOCAL_STRIP_MODULE  := false                                                         
LOCAL_MULTILIB      := 32                                                            
LOCAL_MODULE_OWNER  := qcom                                                          
LOCAL_MODULE_TAGS   := optional                                                      
LOCAL_SRC_FILES     := ../../.././target/product/sw960/system/lib/hw/gps.default.so
LOCAL_MODULE_PATH   := $(PRODUCT_OUT)/system/lib/hw                                  
include $(BUILD_PREBUILT)

// 配置檔案
include $(CLEAR_VARS)                                                            
LOCAL_MODULE        := gpsconfig.xml                                             
LOCAL_MODULE_OWNER  := qcom                                                      
LOCAL_MODULE_TAGS   := optional                                                  
LOCAL_MODULE_CLASS  := ETC                                                       
LOCAL_SRC_FILES     := ../../.././target/product/sw960/vendor/etc/gpsconfig.xml  
LOCAL_MODULE_PATH   := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/etc              
include $(BUILD_PREBUILT)