From d9ba061e772e9f3aae0913e1e8644251608304da Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 2 Aug 2018 11:05:00 -0700 Subject: [PATCH] fastbootd: Add is-userspace variable. Bug: 78793464 Test: fastboot getvar is-userspace returns true for fastbootd fastboot getvar is-userspace returns false or error for bootloader fastboot. Change-Id: I80e1ef6dcf3922e4f555cb2e409e3e098c16fbbc --- fastboot/constants.h | 1 + fastboot/device/commands.cpp | 3 ++- fastboot/device/variables.cpp | 4 ++++ fastboot/device/variables.h | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fastboot/constants.h b/fastboot/constants.h index b780ba575..43daab03b 100644 --- a/fastboot/constants.h +++ b/fastboot/constants.h @@ -57,3 +57,4 @@ #define FB_VAR_SLOT_SUCCESSFUL "slot-successful" #define FB_VAR_SLOT_UNBOOTABLE "slot-unbootable" #define FB_VAR_IS_LOGICAL "is-logical" +#define FB_VAR_IS_USERSPACE "is-userspace" diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp index 053d65447..690bfa8b3 100644 --- a/fastboot/device/commands.cpp +++ b/fastboot/device/commands.cpp @@ -59,7 +59,8 @@ bool GetVarHandler(FastbootDevice* device, const std::vector& args) {FB_VAR_SLOT_SUCCESSFUL, GetSlotSuccessful}, {FB_VAR_SLOT_UNBOOTABLE, GetSlotUnbootable}, {FB_VAR_PARTITION_SIZE, GetPartitionSize}, - {FB_VAR_IS_LOGICAL, GetPartitionIsLogical}}; + {FB_VAR_IS_LOGICAL, GetPartitionIsLogical}, + {FB_VAR_IS_USERSPACE, GetIsUserspace}}; // args[0] is command name, args[1] is variable. auto found_variable = kVariableMap.find(args[1]); diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index 70e4bcc4c..a5dead212 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -165,3 +165,7 @@ bool GetPartitionIsLogical(FastbootDevice* device, const std::vectorWriteFail("Partition not found"); } + +bool GetIsUserspace(FastbootDevice* device, const std::vector& /* args */) { + return device->WriteOkay("yes"); +} diff --git a/fastboot/device/variables.h b/fastboot/device/variables.h index 0c706d7ab..554a080d7 100644 --- a/fastboot/device/variables.h +++ b/fastboot/device/variables.h @@ -36,3 +36,4 @@ bool GetUnlocked(FastbootDevice* device, const std::vector& args); bool GetHasSlot(FastbootDevice* device, const std::vector& args); bool GetPartitionSize(FastbootDevice* device, const std::vector& args); bool GetPartitionIsLogical(FastbootDevice* device, const std::vector& args); +bool GetIsUserspace(FastbootDevice* device, const std::vector& args);