当前位置:   article > 正文

Android11(R) system_ext 分区 system_ext_specific 属性

system_ext_specific

android11 开搞

朋友们,最近拿到 androidR 的代码了,让我们来康康有哪些变动,一上来就给我整懵了,编译了 SystemUI 后发现

居然跑到 system\system_ext\priv-app 文件下了,这是什么鬼,又新加分区?之前 Q 版本已经新增了 product 分区,

并且 SystemUI、Launcher3、Settings这些核心应用都存放在此处,现在 R 版本又跑到这个 system_ext 分区下了

关于动态分区之前介绍过 Android10 动态分区介绍

r8XDMR.png

一探究竟

决定编译后 apk 的位置当然是在 Android.mk 或者 Android.bp 中啦,那我们去康康到底配置了啥子属性?

vendor\mediatek\proprietary\packages\apps\SystemUI\Android.bp

system_ext_specific: true,

privileged: true,

vendor\mediatek\proprietary\packages\apps\MtkSettings\Android.bp

system_ext_specific: true,

privileged: true,

packages\apps\Launcher3\Android.mk

LOCAL_PRIVILEGED_MODULE := true

LOCAL_SYSTEM_EXT_MODULE := true

vendor\mediatek\proprietary\packages\apps\Browser\Android.mk

LOCAL_SYSTEM_EXT_MODULE := true

看完上面这些配置可以知道了,

bp 中配置 system_ext_specific: true,就将编译到 system\system_ext\ 中,

privileged: true 决定在 priv-app 文件中,不加 privileged 则编译到 system\system_ext\app\

mk 中配置 LOCAL_SYSTEM_EXT_MODULE := true,就将编译到 system\system_ext\ 中,

LOCAL_PRIVILEGED_MODULE := true 决定在 priv-app 文件中,不加 LOCAL_PRIVILEGED_MODULE 则编译到 system\system_ext\app\

system_ext_specific 和 LOCAL_SYSTEM_EXT_MODULE 的对照关系经过搜索位于

build\soong\androidmk\androidmk\android.go

addStandardProperties(bpparser.BoolType,
		map[string]string{
			// Bool properties
			"LOCAL_IS_HOST_MODULE":             "host",
			"LOCAL_CLANG":                      "clang",
			"LOCAL_FORCE_STATIC_EXECUTABLE":    "static_executable",
			"LOCAL_NATIVE_COVERAGE":            "native_coverage",
			"LOCAL_NO_CRT":                     "nocrt",
			"LOCAL_ALLOW_UNDEFINED_SYMBOLS":    "allow_undefined_symbols",
			"LOCAL_RTTI_FLAG":                  "rtti",
			"LOCAL_PACK_MODULE_RELOCATIONS":    "pack_relocations",
			"LOCAL_TIDY":                       "tidy",
			"LOCAL_USE_CLANG_LLD":              "use_clang_lld",
			"LOCAL_PROPRIETARY_MODULE":         "proprietary",
			"LOCAL_VENDOR_MODULE":              "vendor",
			"LOCAL_ODM_MODULE":                 "device_specific",
			"LOCAL_PRODUCT_MODULE":             "product_specific",
			"LOCAL_SYSTEM_EXT_MODULE":          "system_ext_specific",
			"LOCAL_EXPORT_PACKAGE_RESOURCES":   "export_package_resources",
			"LOCAL_PRIVILEGED_MODULE":          "privileged",
			"LOCAL_AAPT_INCLUDE_ALL_RESOURCES": "aapt_include_all_resources",
			"LOCAL_DONT_MERGE_MANIFESTS":       "dont_merge_manifests",
			"LOCAL_USE_EMBEDDED_NATIVE_LIBS":   "use_embedded_native_libs",
			"LOCAL_USE_EMBEDDED_DEX":           "use_embedded_dex",

			"LOCAL_DEX_PREOPT":                  "dex_preopt.enabled",
			"LOCAL_DEX_PREOPT_APP_IMAGE":        "dex_preopt.app_image",
			"LOCAL_DEX_PREOPT_GENERATE_PROFILE": "dex_preopt.profile_guided",

			"LOCAL_PRIVATE_PLATFORM_APIS": "platform_apis",
			"LOCAL_JETIFIER_ENABLED":      "jetifier",
		})
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34

那么 LOCAL_SYSTEM_EXT_MODULE 这个又是在那里使用的呢?继续在 build 中查找

build\make\core\base_rules.mk

else ifneq ($(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(_path)),)
LOCAL_SYSTEM_EXT_MODULE := true
endif
_path :=

else ifeq (true,$(strip $(LOCAL_SYSTEM_EXT_MODULE)))
  partition_tag := _SYSTEM_EXT
  # A system_ext-specific module could be on the system_ext partition at
  # "system_ext" or the system partition at "system/system_ext".
  actual_partition_tag := $(if $(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)),system_ext,system)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

紧接着查找 TARGET_OUT_SYSTEM_EXT 到

build\make\core\envsetup.mk

TARGET_OUT_SYSTEM_EXT := ( P R O D U C T O U T ) / (PRODUCT_OUT)/ (PRODUCTOUT)/(TARGET_COPY_OUT_SYSTEM_EXT)

TARGET_COPY_OUT_SYSTEM_EXT := $(_system_ext_path_placeholder)

_system_ext_path_placeholder := ||SYSTEM_EXT-PATH-PH||

再接着找 SYSTEM_EXT

build\make\tools\releasetools\check_target_files_vintf.py

# each partition.
DIR_SEARCH_PATHS = {
    '/system': ('SYSTEM',),
    '/vendor': ('VENDOR', 'SYSTEM/vendor'),
    '/product': ('PRODUCT', 'SYSTEM/product'),
    '/odm': ('ODM', 'VENDOR/odm', 'SYSTEM/vendor/odm'),
    '/system_ext': ('SYSTEM_EXT', 'SYSTEM/system_ext'),
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

build\make\target\board\BoardConfigEmuCommon.mk

  ifeq ($(QEMU_USE_SYSTEM_EXT_PARTITIONS),true)
    BOARD_EMULATOR_DYNAMIC_PARTITIONS_PARTITION_LIST := \
        system \
        system_ext \
        product \
        vendor

    TARGET_COPY_OUT_PRODUCT := product
    BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE := ext4
    TARGET_COPY_OUT_SYSTEM_EXT := system_ext
    BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE := ext4
  else
    TARGET_COPY_OUT_PRODUCT := system/product
    TARGET_COPY_OUT_SYSTEM_EXT := system/system_ext
    BOARD_EMULATOR_DYNAMIC_PARTITIONS_PARTITION_LIST := \
        system \
        vendor
  endif
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

build\make\core\board_config.mk

# Now we can substitute with the real value of TARGET_COPY_OUT_SYSTEM_EXT
ifeq ($(TARGET_COPY_OUT_SYSTEM_EXT),$(_system_ext_path_placeholder))
TARGET_COPY_OUT_SYSTEM_EXT := system/system_ext
else ifeq ($(filter system_ext system/system_ext,$(TARGET_COPY_OUT_SYSTEM_EXT)),)
$(error TARGET_COPY_OUT_SYSTEM_EXT must be either 'system_ext' or 'system/system_ext', seeing '$(TARGET_COPY_OUT_SYSTEM_EXT)'.)
endif
PRODUCT_COPY_FILES := $(subst $(_system_ext_path_placeholder),$(TARGET_COPY_OUT_SYSTEM_EXT),$(PRODUCT_COPY_FILES))

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

行了,就先整这么多吧,到这里已经很清楚了。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/228168
推荐阅读
相关标签
  

闽ICP备14008679号