====== Motorola Common Tree ======
This is the core of the moto-common project. All common configuration is stored here. Let's go over each folder and file one by one in order to understand what's really happening here. Please note that the various configuration options listed below should not be modified directly in device/motorola/common but in your platform or device tree.
===== device/motorola/common/Android.bp =====
This file defines a Soong namespace in order to reduce conflicts with unrelated trees in the source tree. It also imports hardware/google/interfaces and hardware/google/pixel for libperfmgr and the USB HAL.
===== device/motorola/common/Android.mk =====
This file's purpose is also to reduce conflicts by including the subsequent Android.mk files only if PRODUCT_PLATFORM_MOT is true.
===== device/motorola/common/CommonConfig.mk =====
This is the common Board Configuration file for moto-common targets, sensible defaults are set here for platform trees to inherit. Below is a list of changes that are usually required for bringing up a new platform.
* By default ''%%TARGET_NO_RECOVERY%%'' is set to ''%%false%%'' and should be set to ''%%true%%'' if required in either the platform or device tree.
* ''%%SOONG_CONFIG_MOTO_COMMON_USB_USB_CONTROLLER_NAME%%'' should be set to the name of the usb controller of your platform, for lower end Qualcomm SoCs this is usually ''%%4e00000%%'' and is the default, another common value is ''%%a600000%%''.
* ''%%SOONG_CONFIG_MOTO_COMMON_POWER_FB_IDLE_PATH%%'' should be set to the path of the idle_state sysfs node for your platform. The default value for this is ''%%/sys/devices/platform/soc/5e00000.qcom,mdss_mdp/idle_state%%''.
* In the initial stages of bringup for a new platform, SEPolicy definitions are typically incomplete. You can set ''%%BOARD_USE_ENFORCING_SELINUX%%'' to ''%%false%%'' in your platform tree if you wish to develop the SEPolicies further into development.
* If your device uses a fingerprint under display module, you may need to set ''%%TARGET_USES_FINGERPRINT_V2_1%%'' to false in order to exclude the VINTF fragment for ''%%android.hardware.biometrics.fingerprint@2.1::IBiometricsFingerprint/default%%''.
* If your device does NOT have a DTBO partition, please set ''%%BOARD_USES_DTBO%%'' to ''%%false%%''.
* ''%%BOARD_KERNEL_IMAGE_NAME%%'' is set to ''%%Image.gz-dtb%%'' by default, you may want to change this in your platform tree.
* For ease of development, ''%%BOARD_BOOT_HEADER_VERSION%%'' is set to ''%%2%%''. This will allow you quickly get to a working system without fiddling with vendor_boot.
===== device/motorola/common/common-init.mk =====
This file contains statements related to init configuration scripts. Currently as of ''%%c109845e2ec185dff740ed88cc990128d85192bf%%'' this consists of ''%%vendor_modprobe.sh%%'' which is a script that loads vendor kernel modules based on the generated modules.load file. You will not find vendor_modprobe.sh in device/motorola/common as it is instead built from device/qcom/common/vendor/init.
Additionally within common-init.mk, you will also find the selectors that specify the init scripts for the different HALs of the supported fingerprint modules. This is subject to change however as the current implementation of fingerprint support is scattered and requires both the device's vendor to include the HAL itself as well as enabling the init script via the corresponding selector. It's likely that this functionality will be consolidated into vendor/motorola/fingerprint in the future.
===== device/motorola/common-packages.mk =====
This file contains the common packages required by most targets. Here A/B packages are built by default as most targets support A/B partitions and those who don't will not be impacted by their presence. Some NFC packages are also handled here, we will go over NFC support later on.
Here if ''%%TARGET_USES_DYNAMIC_PARTITIONS%%'' is set to ''%%true%%'', the fastbootd package is built.
The common-packages.mk file also makes some assumptions about your platform/device trees.
* ''%%$(DEVICE)FrameworksOverlay%%''
* ''%%$(DEVICE)SettingsOverlay%%''
* ''%%$(DEVICE)SystemUIOverlay%%''
* ''%%PlatformFrameworksOverlay%%''
* ''%%PlatformFrameworksOverlay%%''
* ''%%PlatformFrameworksOverlay%%''
These packages are set to be built automatically, given that they exist.
===== device/motorola/common/common-perm.mk =====
There is nothing to particularly note about this file other than that it copies a common set of permissions to all targets. If NFC support is enabled it also copies the relevant permission files as well.
===== device/motorola/common/common-prop.mk =====
This file contains the set of common properties that are applied to all targets. Among these are Audio and Bluetooth properties, as well as other configurations that pertain to dex2oat and several other system components.
===== device/motorola/common/common-treble.mk =====
common-treble.mk contains mostly all treble related packages, interfaces and configuration. Here it is ensured that all required HALs are built like ''%%android.hardware.audio.service%%'', the camera HALs as well as many other HALs.
The following properties are configurable,
* ''%%TARGET_USES_64BIT_CAMERA%%'' should be set to ''%%false%%'' if your device uses a 32bit camera HAL, since the majority of devices supported by moto-common use a 64bit camera HAL, it is set to ''%%true%%'' by default.
* ''%%TARGET_USES_PN5XX_PN8X_NFC%%'', ''%%TARGET_USES_SN1XX_NFC%%'' and ''%%TARGET_USES_ST_NFC%%'' are properties you can set if your device contains a PN5XX/PN8X, SN1XX, or ST NFC chip.
* If you have a powerhint.json ready or wish to use the Pixel Power HAL, you should set ''%%PRODUCT_USES_PIXEL_POWER_HAL%%'' to ''%%true%%''.
===== device/motorola/common/common.mk =====
In common.mk, you can find various configurations that are not specific to any particular target or module. These include things such as configuring the A/B OTA post-installation settings and setting up other properties based on pre-existing ones. This file also takes care of copying all files from
* ''%%$(COMMON_PATH)/rootdir/vendor%%''
* ''%%$(DEVICE_PATH)/vendor%%''
* ''%%$(PLATFORM_COMMON_PATH)/rootdir/vendor%%''
to ''%%$(TARGET_COPY_OUT_VENDOR)%%'' for you. In order for this to work please set those variables appropriately. For reference see [[https://github.com/moto-common/android_device_motorola_sm4250-common/blob/0b998def14cf57b13ebdd72029469a28c720d8c6/platform.mk#L16|here]] and [[https://github.com/moto-common/android_device_motorola_hanoip/blob/b9dc70894e2a8c36a31cb468fd58761875c2a325/device.mk#L16|here]].
If your device supports dynamic partitions, set ''%%PRODUCT_USE_DYNAMIC_PARTITIONS%%'' to ''%%true%%''.
===== device/motorola/common/proprietary-files.txt =====
This file contains common blobs that are used on all targets, such as the QTI Bluetooth HAL, common sensor libraries and other QTI components.
===== device/motorola/common/fingerprint/ =====
As stated before in the common-init.mk section, selectors are responsible for copying modified fingerprint init scripts that have had their service definitions modified to have the vendor prefix. Those scripts are stored in this folder.
===== device/motorola/common/hardware/firmware,tftp =====
These folders contain modules which create mount point folders and symlinks required by tftp_server in /vendor. Some of these mount point folders include /vendor/firmware_mnt, /vendor/dsp and /vendor/fsg. They are used by various subsystems on all targets.
===== device/motorola/common/hardware/qcom =====
As moto-common matures, thought has been put into supporting other Motorola Devices that do not use Qualcomm SoCs. However support for those devices are in preliminary stages. Most of QCOM specific definitions and configuration is stored in this folder. This includes QCOM display,media,audio,etc HAL configuration.
device/qcom/common is also configured here in product.mk.
===== device/motorola/common/lights =====
This folder contains the Lights AIDL used in order to enable the use of the factory LED contained by most if not all Motorola Devices.
{{:photo_2023-05-03_04-03-25.jpg?200|}}
===== device/motorola/common/power-libperfmgr =====
This folder contains the Google Power AIDL based on libperfmgr. You can view the commit history for changes done vs the vanilla HAL used by Google.
===== device/motorola/common/rootdir =====