From 99f9a38a8b55fadfdbc0a578e7d45818f0407091 Mon Sep 17 00:00:00 2001 From: Bowgo Tsai Date: Tue, 21 Jan 2020 18:31:23 +0800 Subject: [PATCH] fastbootd: exporting more properties Exporting more properties that can be useful for image compatibility check, prior to run fastboot flash. Bug: 74445765 Bug: 144473561 Test: fastboot getvar Change-Id: I2ddfa2c1e9e719e05a3a64b9ca1d608957aebf11 --- fastboot/constants.h | 8 ++++++ fastboot/device/commands.cpp | 10 ++++++- fastboot/device/variables.cpp | 51 +++++++++++++++++++++++++++++++++++ fastboot/device/variables.h | 16 +++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/fastboot/constants.h b/fastboot/constants.h index 5a554a0d2..aefd44878 100644 --- a/fastboot/constants.h +++ b/fastboot/constants.h @@ -47,6 +47,8 @@ #define FB_VAR_VERSION "version" #define FB_VAR_VERSION_BOOTLOADER "version-bootloader" #define FB_VAR_VERSION_BASEBAND "version-baseband" +#define FB_VAR_VERSION_OS "version-os" +#define FB_VAR_VERSION_VNDK "version-vndk" #define FB_VAR_PRODUCT "product" #define FB_VAR_SERIALNO "serialno" #define FB_VAR_SECURE "secure" @@ -69,3 +71,9 @@ #define FB_VAR_SUPER_PARTITION_NAME "super-partition-name" #define FB_VAR_SNAPSHOT_UPDATE_STATUS "snapshot-update-status" #define FB_VAR_CPU_ABI "cpu-abi" +#define FB_VAR_SYSTEM_FINGERPRINT "system-fingerprint" +#define FB_VAR_VENDOR_FINGERPRINT "vendor-fingerprint" +#define FB_VAR_DYNAMIC_PARTITION "dynamic-partition" +#define FB_VAR_FIRST_API_LEVEL "first-api-level" +#define FB_VAR_SECURITY_PATCH_LEVEL "security-patch-level" +#define FB_VAR_TREBLE_ENABLED "treble-enabled" diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp index b7263d945..2c9dec9fc 100644 --- a/fastboot/device/commands.cpp +++ b/fastboot/device/commands.cpp @@ -106,6 +106,8 @@ bool GetVarHandler(FastbootDevice* device, const std::vector& args) {FB_VAR_VERSION, {GetVersion, nullptr}}, {FB_VAR_VERSION_BOOTLOADER, {GetBootloaderVersion, nullptr}}, {FB_VAR_VERSION_BASEBAND, {GetBasebandVersion, nullptr}}, + {FB_VAR_VERSION_OS, {GetOsVersion, nullptr}}, + {FB_VAR_VERSION_VNDK, {GetVndkVersion, nullptr}}, {FB_VAR_PRODUCT, {GetProduct, nullptr}}, {FB_VAR_SERIALNO, {GetSerial, nullptr}}, {FB_VAR_VARIANT, {GetVariant, nullptr}}, @@ -127,7 +129,13 @@ bool GetVarHandler(FastbootDevice* device, const std::vector& args) {FB_VAR_HW_REVISION, {GetHardwareRevision, nullptr}}, {FB_VAR_SUPER_PARTITION_NAME, {GetSuperPartitionName, nullptr}}, {FB_VAR_SNAPSHOT_UPDATE_STATUS, {GetSnapshotUpdateStatus, nullptr}}, - {FB_VAR_CPU_ABI, {GetCpuAbi, nullptr}}}; + {FB_VAR_CPU_ABI, {GetCpuAbi, nullptr}}, + {FB_VAR_SYSTEM_FINGERPRINT, {GetSystemFingerprint, nullptr}}, + {FB_VAR_VENDOR_FINGERPRINT, {GetVendorFingerprint, nullptr}}, + {FB_VAR_DYNAMIC_PARTITION, {GetDynamicPartition, nullptr}}, + {FB_VAR_FIRST_API_LEVEL, {GetFirstApiLevel, nullptr}}, + {FB_VAR_SECURITY_PATCH_LEVEL, {GetSecurityPatchLevel, nullptr}}, + {FB_VAR_TREBLE_ENABLED, {GetTrebleEnabled, nullptr}}}; if (args.size() < 2) { return device->WriteFail("Missing argument"); diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index 10eac01b5..e7d8bc366 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -62,6 +62,18 @@ bool GetBasebandVersion(FastbootDevice* /* device */, const std::vector& /* args */, + std::string* message) { + *message = android::base::GetProperty("ro.build.version.release", ""); + return true; +} + +bool GetVndkVersion(FastbootDevice* /* device */, const std::vector& /* args */, + std::string* message) { + *message = android::base::GetProperty("ro.vndk.version", ""); + return true; +} + bool GetProduct(FastbootDevice* /* device */, const std::vector& /* args */, std::string* message) { *message = android::base::GetProperty("ro.product.device", ""); @@ -458,3 +470,42 @@ bool GetCpuAbi(FastbootDevice* /* device */, const std::vector& /* *message = android::base::GetProperty("ro.product.cpu.abi", ""); return true; } + +bool GetSystemFingerprint(FastbootDevice* /* device */, const std::vector& /* args */, + std::string* message) { + *message = android::base::GetProperty("ro.system.build.fingerprint", ""); + if (message->empty()) { + *message = android::base::GetProperty("ro.build.fingerprint", ""); + } + return true; +} + +bool GetVendorFingerprint(FastbootDevice* /* device */, const std::vector& /* args */, + std::string* message) { + *message = android::base::GetProperty("ro.vendor.build.fingerprint", ""); + return true; +} + +bool GetDynamicPartition(FastbootDevice* /* device */, const std::vector& /* args */, + std::string* message) { + *message = android::base::GetProperty("ro.boot.dynamic_partitions", ""); + return true; +} + +bool GetFirstApiLevel(FastbootDevice* /* device */, const std::vector& /* args */, + std::string* message) { + *message = android::base::GetProperty("ro.product.first_api_level", ""); + return true; +} + +bool GetSecurityPatchLevel(FastbootDevice* /* device */, const std::vector& /* args */, + std::string* message) { + *message = android::base::GetProperty("ro.build.version.security_patch", ""); + return true; +} + +bool GetTrebleEnabled(FastbootDevice* /* device */, const std::vector& /* args */, + std::string* message) { + *message = android::base::GetProperty("ro.treble.enabled", ""); + return true; +} diff --git a/fastboot/device/variables.h b/fastboot/device/variables.h index 90840d6d2..c11e472b7 100644 --- a/fastboot/device/variables.h +++ b/fastboot/device/variables.h @@ -26,6 +26,10 @@ bool GetBootloaderVersion(FastbootDevice* device, const std::vector std::string* message); bool GetBasebandVersion(FastbootDevice* device, const std::vector& args, std::string* message); +bool GetOsVersion(FastbootDevice* device, const std::vector& args, + std::string* message); +bool GetVndkVersion(FastbootDevice* device, const std::vector& args, + std::string* message); bool GetProduct(FastbootDevice* device, const std::vector& args, std::string* message); bool GetSerial(FastbootDevice* device, const std::vector& args, std::string* message); bool GetSecure(FastbootDevice* device, const std::vector& args, std::string* message); @@ -64,6 +68,18 @@ bool GetSuperPartitionName(FastbootDevice* device, const std::vector& args, std::string* message); bool GetCpuAbi(FastbootDevice* device, const std::vector& args, std::string* message); +bool GetSystemFingerprint(FastbootDevice* device, const std::vector& args, + std::string* message); +bool GetVendorFingerprint(FastbootDevice* device, const std::vector& args, + std::string* message); +bool GetDynamicPartition(FastbootDevice* device, const std::vector& args, + std::string* message); +bool GetFirstApiLevel(FastbootDevice* device, const std::vector& args, + std::string* message); +bool GetSecurityPatchLevel(FastbootDevice* device, const std::vector& args, + std::string* message); +bool GetTrebleEnabled(FastbootDevice* device, const std::vector& args, + std::string* message); // Helpers for getvar all. std::vector> GetAllPartitionArgsWithSlot(FastbootDevice* device);