From 38b68c6a0e4810b188ac875733d8f480d5e2cf8f Mon Sep 17 00:00:00 2001 From: Yi-Yo Chiang Date: Tue, 22 Nov 2022 17:32:21 +0800 Subject: [PATCH] fastbootd: Add getvar is-force-debuggable Export ro.force.debuggable property so that the user can check image compatibility prior to running fastboot flash. For example, if is-force-debuggable is yes, then the "system" and "vendor" build fingerprint must match. Bug: 191649082 Test: fastboot getvar is-force-debuggable Change-Id: I772d98253f58ba208d5803e18b589ff693deebd0 --- fastboot/constants.h | 1 + fastboot/device/commands.cpp | 1 + fastboot/device/variables.cpp | 6 ++++++ fastboot/device/variables.h | 2 ++ 4 files changed, 10 insertions(+) diff --git a/fastboot/constants.h b/fastboot/constants.h index f6fc74eda..ad169d1dc 100644 --- a/fastboot/constants.h +++ b/fastboot/constants.h @@ -64,6 +64,7 @@ #define FB_VAR_SLOT_UNBOOTABLE "slot-unbootable" #define FB_VAR_IS_LOGICAL "is-logical" #define FB_VAR_IS_USERSPACE "is-userspace" +#define FB_VAR_IS_FORCE_DEBUGGABLE "is-force-debuggable" #define FB_VAR_HW_REVISION "hw-revision" #define FB_VAR_VARIANT "variant" #define FB_VAR_OFF_MODE_CHARGE_STATE "off-mode-charge" diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp index f8befd3b8..e929f42c2 100644 --- a/fastboot/device/commands.cpp +++ b/fastboot/device/commands.cpp @@ -131,6 +131,7 @@ const std::unordered_map kVariableMap = { {FB_VAR_PARTITION_TYPE, {GetPartitionType, GetAllPartitionArgsWithSlot}}, {FB_VAR_IS_LOGICAL, {GetPartitionIsLogical, GetAllPartitionArgsWithSlot}}, {FB_VAR_IS_USERSPACE, {GetIsUserspace, nullptr}}, + {FB_VAR_IS_FORCE_DEBUGGABLE, {GetIsForceDebuggable, nullptr}}, {FB_VAR_OFF_MODE_CHARGE_STATE, {GetOffModeChargeState, nullptr}}, {FB_VAR_BATTERY_VOLTAGE, {GetBatteryVoltage, nullptr}}, {FB_VAR_BATTERY_SOC_OK, {GetBatterySoCOk, nullptr}}, diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index 5f99656a1..d2a794715 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -379,6 +379,12 @@ bool GetIsUserspace(FastbootDevice* /* device */, const std::vector return true; } +bool GetIsForceDebuggable(FastbootDevice* /* device */, const std::vector& /* args */, + std::string* message) { + *message = android::base::GetBoolProperty("ro.force.debuggable", false) ? "yes" : "no"; + return true; +} + std::vector> GetAllPartitionArgsWithSlot(FastbootDevice* device) { std::vector> args; auto partitions = ListPartitions(device); diff --git a/fastboot/device/variables.h b/fastboot/device/variables.h index aa4d9fc40..3b2d48447 100644 --- a/fastboot/device/variables.h +++ b/fastboot/device/variables.h @@ -54,6 +54,8 @@ bool GetPartitionIsLogical(FastbootDevice* device, const std::vector& args, std::string* message); +bool GetIsForceDebuggable(FastbootDevice* device, const std::vector& args, + std::string* message); bool GetHardwareRevision(FastbootDevice* device, const std::vector& args, std::string* message); bool GetVariant(FastbootDevice* device, const std::vector& args, std::string* message);