标签:
通常产品厂商在拿到Android源码后会在Android源码基础上进行定制修改,以匹配适应自己的产品。这就引入了产品线的概念。Android系统源码中,产品相关的文件通常保存在 device/company/product目录下其目录的组织结构为
在tiny4412 android 5.0中如下图所示:
(1)vendorsetup.sh中的内容如下
#调用add_lunch_combo函数将full_tiny4412-userdebug #和full_tiny4412-eng添加到系统相关变量中,后续 #lunch提供的菜单就是根据这些变量产生的 #envsetup.sh末尾通过一个for循环来扫描工程中 #所有可用的vendorsetup.sh并执行它们 #默认会扫面/vendor和/device目录 add_lunch_combo full_tiny4412-userdebug add_lunch_combo full_tiny4412-eng
(2)AndroidProducts.mk中内容为
#当运行了lunch函数选择了编译的产品后 #编译系统会在产品所在的目录下寻找 #AndroidProducts.mk文件,这里记录 #着该产品的一些具体的属性,但是 #通常我们在这个文件中做一个转向 PRODUCT_MAKEFILES := $(LOCAL_DIR)/aosp_tiny4412.mk $(LOCAL_DIR)/full_tiny4412.mk
其中full_tiny4412.mk种的内容为
# Launcher, Camera and Gallery ifeq ($(BOARD_USES_LAUNCHER3),true) PRODUCT_PACKAGES += Launcher3 endif #系统要预装的一系列程序 PRODUCT_PACKAGES += Gallery2 # Live Wallpapers PRODUCT_PACKAGES += HoloSpiralWallpaper LiveWallpapers LiveWallpapersPicker MagicSmokeWallpapers VisualizationWallpapers librs_jni #用于重载系统属性 #格式:key=value #这些属性最终会被存储在设备的 #/system/build.prop文件中 PRODUCT_PROPERTY_OVERRIDES := net.dns1=8.8.8.8 net.dns2=8.8.4.4 # Inherit from those products. Most specific first. #继承 aosp_base_telephony.mk 和device/friendly-arm/tiny4412/device.mk #文件中的定义 $(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk) $(call inherit-product, device/friendly-arm/tiny4412/device.mk) #覆盖继承上面两个文件定义的如下几个变量 # Discard inherited values and use our own instead. #产品名称,最终会显示在系统设置中的 #"关于设备的选项中" PRODUCT_NAME := full_tiny4412 #设备名称 PRODUCT_DEVICE := tiny4412 产品生产商 PRODUCT_MANUFACTURER := FriendlyARM (www.arm9.net) #产品所属品牌 PRODUCT_BRAND := Android #产品型号 PRODUCT_MODEL := Full Android on TINY4412
(3)BoardConfig.mk文件解析
# BoardConfig.mk # # Product-specific compile-time definitions. # # Use the non-open-source parts, if they‘re present -include vendor/friendly-arm/tiny4412/BoardConfigVendor.mk #引入BoardConfigCommon.mk # Use the parts that are common between all Exynos4412s include device/friendly-arm/tiny4412/BoardConfigCommon.mk #用来配置SELINUX,SELINUX是android上面的一种安全机制 #我们可以通过配置SELINUX的相关policy,来定制自己的手 #机的一些权限,比如,我们可以完全让root用户没有任何的 #权限和user一样 #配置SELINUX,需要linux内核首先是支持selinux的, #另外需要android的selinux的配置文件sepolicy里面的内容 #然后就是修改BoardConfig.mk #首先会包含厂商定制的sepolicy的文件夹:BOARD_SEPOLICY_DIRS #然后将规则添加到了sepolicy中:BOARD_SEPOLICY_DIRS BOARD_SEPOLICY_DIRS := device/friendly-arm/tiny4412/sepolicy #配置SELINUX BOARD_SEPOLICY_UNION := file_contexts service_contexts app.te boardinit.te bluetooth.te device.te domain.te drmserver.te gpsd.te mediaserver.te system_server.te
接下来分析引入的BoardConfigCommon.mk
# BoardConfigCommon.mk # # Product-specific compile-time definitions. #芯片平台 TARGET_BOARD_PLATFORM := exynos4 #芯片类型 TARGET_SOC := exynos4x12 #CPU配置选项 # CPU options TARGET_CPU_ABI := armeabi-v7a TARGET_CPU_ABI2 := armeabi TARGET_CPU_SMP := true TARGET_ARCH := arm TARGET_ARCH_VARIANT := armv7-a-neon TARGET_ARCH_VARIANT_CPU := cortex-a9 TARGET_CPU_VARIANT := cortex-a9 ARCH_ARM_HAVE_NEON := true ARCH_ARM_HAVE_TLS_REGISTER := true TARGET_GLOBAL_CFLAGS += -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp TARGET_GLOBAL_CPPFLAGS += -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp TARGET_NO_BOOTLOADER := true TARGET_NO_KERNEL := true TARGET_NO_RADIOIMAGE := true TARGET_BOOTLOADER_BOARD_NAME := tiny4412 TARGET_PROVIDES_INIT_RC := true TARGET_PROVIDES_INIT_TARGET_RC := true # Exynos4 support EXYNOS4X12_ENHANCEMENTS := true EXYNOS4_ENHANCEMENTS := true ifeq ($(EXYNOS4X12_ENHANCEMENTS),true) COMMON_GLOBAL_CFLAGS += -DEXYNOS4_ENHANCEMENTS=1 COMMON_GLOBAL_CFLAGS += -DEXYNOS4X12_ENHANCEMENTS=1 endif # Launcher BOARD_USES_LAUNCHER3 := true # Audio BOARD_USES_GENERIC_AUDIO := false BOARD_USES_I2S_AUDIO := true BOARD_USES_PCM_AUDIO := false BOARD_USES_SPDIF_AUDIO := false # ULP, ALP BOARD_USE_ULP_AUDIO := false BOARD_USE_ALP_AUDIO := true #背光配置 # Backlight BOARD_USES_PWMLIGHTS := false #蓝牙配置 # Bluetooth BOARD_HAVE_BLUETOOTH := true BOARD_HAVE_BLUETOOTH_CSR := true BOARD_HAVE_BLUETOOTH_BCM := false BOARD_HAVE_SAMSUNG_BLUETOOTH := false BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/friendly-arm/tiny4412/bluetooth #Wi-Fi配置 # Connectivity - Wi-Fi WPA_SUPPLICANT_VERSION := VER_0_8_X BOARD_WPA_SUPPLICANT_DRIVER := WEXT BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_fawext BOARD_WLAN_DEVICE := fawext #文件系统配置 # Filesystem TARGET_USERIMAGES_USE_EXT4 := true BOARD_SYSTEMIMAGE_PARTITION_SIZE := 629145600 # 600MB BOARD_USERDATAIMAGE_PARTITION_SIZE := 830472192 # 792MB BOARD_CACHEIMAGE_PARTITION_SIZE := 536870912 # 512MB BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4 BOARD_FLASH_BLOCK_SIZE := 4096 #图形配置 # Graphics BOARD_USES_HGL := true BOARD_EGL_CFG := device/friendly-arm/tiny4412/conf/egl.cfg USE_OPENGL_RENDERER := true IGN_EGL_BUFFERCOUNT := true NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3 SCREEN_WIDTH := 800 SCREEN_HEIGHT := 1280 DEFAULT_FB_NUM := 2 # FIMG Acceleration BOARD_USES_FIMGAPI := true BOARD_USES_SKIA_FIMGAPI := true BOARD_USES_SKIAHWJPEG := true COMMON_GLOBAL_CFLAGS += -DSEC_HWJPEG_G2D -DFORCE_SCREENSHOT_CPU_PATH # HWComposer BOARD_USES_HWCOMPOSER := true BOARD_USE_SYSFS_VSYNC_NOTIFICATION := true # TVOut & HDMI # BOARD_USE_SECTVOUT := true # BOARD_USES_SKTEXTBOX := true BOARD_USES_HDMI_SUBTITLES := false BOARD_USES_HDMI := true BOARD_HDMI_STD := STD_1080P BOARD_HDMI_DDC_CH := DDC_CH_I2C_7 BOARD_HDMI_ROTATE := false #Camera配置 # Camera BOARD_CAMERA_HAVE_ISO := true COMMON_GLOBAL_CFLAGS += -DHAVE_ISO COMMON_GLOBAL_CFLAGS += -DSAMSUNG_CAMERA_HARDWARE COMMON_GLOBAL_CFLAGS += -DSAMSUNG_DVFS BOARD_USES_PROPRIETARY_LIBFIMC := true # SEC Camera USE_SEC_CAMERA := false CAMERA_USE_DIGITALZOOM := true # BOARD_USE_S5K3H2 := true #OMX配置 # OMX BOARD_USE_SAMSUNG_COLORFORMAT := true BOARD_NONBLOCK_MODE_PROCESS := true BOARD_USE_STOREMETADATA := true BOARD_USE_METADATABUFFERTYPE := true BOARD_USE_S3D_SUPPORT := true BOARD_USE_DRM := true BOARD_USE_CSC_FIMC := false BOARD_USES_MFC_FPS := true BOARD_USES_FFMPEG := false #V4L2配置 # V4L2 & ION BOARD_USE_V4L2 := false BOARD_USE_V4L2_ION := false BOARD_NO_OVERLAY := false #中兴无线模块配置 # ZTE WIRELESS MODEM BOARD_HAVE_MODEM :=true BOARD_MODEM_VENDOR :=ZTE BOARD_MODEM_ID :=MF210 BOARD_MODEM_HAVE_DATA_DEVICE :=true BOARD_WITH_CALL_FUNCTION:=false
# system.prop for tiny4412 #rild.libpath=/system/lib/libreference-ril.so #rild.libargs=-d /dev/ttyS1 ro.sf.auto_lcd_density=yes # hdmi support persist.demo.hdmirotationlock=1 # disable strict mode persist.sys.strictmode.disable=1 # captive portal server ro.net.captive_server=112.124.9.243 # WCDMA Preferred ro.telephony.default_network=0 telephony.lteOnCdmaDevice=0 ro.product.locale.language=zh ro.product.locale.region=CN # ro.use_data_netmgrd=true # persist.data_netmgrd_nint=8 # ro.ril.def.agps.mode=0 # keyguard.no_require_sim=true
key 158 BACK key 230 SOFT_RIGHT key 60 SOFT_RIGHT key 107 ENDCALL key 62 ENDCALL key 229 MENU key 139 MENU key 59 MENU key 127 SEARCH key 217 SEARCH key 228 POUND key 227 STAR key 231 CALL key 61 CALL key 232 DPAD_CENTER key 108 DPAD_DOWN key 103 DPAD_UP key 102 HOME key 105 DPAD_LEFT key 106 DPAD_RIGHT key 115 VOLUME_UP key 114 VOLUME_DOWN key 116 POWER key 212 CAMERA key 353 DPAD_CENTER
(1)在device目录下添加一个以公司名命名的文件夹,然后再在这个文件夹下为各产品分别建立对应的子文件夹。和此产品相关的所有特定文件都应该优先放置在这里。
(2)在产品目录下建立一个vendorsetup.sh脚本通常为
add_lunch_combo full_xxx_userdebug(或eng)
使得产品可以正确的被添加到编译系统中
(3)在产品目录下添加AndroidProducts.mk文件,用来做产品具体属性配置文件的一个转向。例如
PRODUCT_MAKEFILES := $(LOCAL_DIR)/aosp_tiny4412.mk $(LOCAL_DIR)/full_tiny4412.mk
#将bcmdhd.cal复制到产品系统的system/etc/wifi目录下 PRODUCT_COPY_FILES =+ device/samsung/toro/bcmdhd.cal:system/etc/wifi/bcmdhd.cal
变量 | 描述 |
PRODUCT_NAME | 产品名称,最终会显示在系统设置中的"关于设备"选项中 |
PRODUCT_DEVICE | 设备名称 |
PRODUCT_BRAND | 产品所属品牌 |
PRODUCT_MANUFACTURER | 产品生产商 |
PRODUCT_MODULE | 产品型号 |
PRODUCT_PACKAGES | 产品需要预装的一系列程序,如APKs |
PRODUCT_LOCALES | 所支持的国家语言。格式如下 [两个字节语言码]-[两个字节国家码] 如en_GB de_DE 各语言间以空格分隔 |
PRODUCT_POLICY | 本产品遵循的"策略",如 android.policy_phone android.policy_mid |
PRODUCT_TAGS | 一系列以空格分隔的产品描述标签 |
PRODUCT_PROPERTY_OVERRIDES | 用于重载系统属性 格式:key=value 示例:ro.product.firmware=v0.4rc1 这些属性最终会保存在设备系统/system/build.prop文件中 |
PRODUCT_COPY_FILES | 复制文件到设备系统的指定目录 |
LOCAL_PATH := $(call my-dir) # if some modules are built directly from this directory (not subdirectories), # their rules should be written here. include $(call all-makefiles-under,$(LOCAL_PATH))
标签:
原文地址:http://www.cnblogs.com/CoderTian/p/5933398.html