From b299cb7217e7f63d9128a0e595bcc21ab645f41f Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Wed, 17 Feb 2021 13:44:49 -0800 Subject: [PATCH] fastbootd: Add getvar max-fetch-size. Test: run it Test: see follow up CL on fuzzy_fastboot Bug: 173654501 Change-Id: I5ed110c5569d83cbe791d04b4abea3a2af2765a9 --- fastboot/Android.bp | 6 ++++++ fastboot/constants.h | 1 + fastboot/device/commands.cpp | 4 +++- fastboot/device/commands.h | 1 + fastboot/device/variables.cpp | 16 ++++++++++++++++ fastboot/device/variables.h | 2 ++ 6 files changed, 29 insertions(+), 1 deletion(-) diff --git a/fastboot/Android.bp b/fastboot/Android.bp index a1f1c17cb..daff496d9 100644 --- a/fastboot/Android.bp +++ b/fastboot/Android.bp @@ -138,6 +138,12 @@ cc_binary { recovery: true, + product_variables: { + debuggable: { + cppflags: ["-DFB_ENABLE_FETCH"], + }, + }, + srcs: [ "device/commands.cpp", "device/fastboot_device.cpp", diff --git a/fastboot/constants.h b/fastboot/constants.h index ba43ca5bd..4cc154adb 100644 --- a/fastboot/constants.h +++ b/fastboot/constants.h @@ -77,3 +77,4 @@ #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" +#define FB_VAR_MAX_FETCH_SIZE "max-fetch-size" diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp index b2b6a9e5c..3c56f5001 100644 --- a/fastboot/device/commands.cpp +++ b/fastboot/device/commands.cpp @@ -136,7 +136,9 @@ bool GetVarHandler(FastbootDevice* device, const std::vector& args) {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}}}; + {FB_VAR_TREBLE_ENABLED, {GetTrebleEnabled, nullptr}}, + {FB_VAR_MAX_FETCH_SIZE, {GetMaxFetchSize, nullptr}}, + }; if (args.size() < 2) { return device->WriteFail("Missing argument"); diff --git a/fastboot/device/commands.h b/fastboot/device/commands.h index c1324bc40..108ad2f58 100644 --- a/fastboot/device/commands.h +++ b/fastboot/device/commands.h @@ -20,6 +20,7 @@ #include constexpr unsigned int kMaxDownloadSizeDefault = 0x10000000; +constexpr unsigned int kMaxFetchSizeDefault = 0x10000000; class FastbootDevice; diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index e7d8bc366..ee1eed876 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -33,6 +33,12 @@ #include "flashing.h" #include "utility.h" +#ifdef FB_ENABLE_FETCH +static constexpr bool kEnableFetch = true; +#else +static constexpr bool kEnableFetch = false; +#endif + using ::android::hardware::boot::V1_0::BoolResult; using ::android::hardware::boot::V1_0::Slot; using ::android::hardware::boot::V1_1::MergeStatus; @@ -509,3 +515,13 @@ bool GetTrebleEnabled(FastbootDevice* /* device */, const std::vector& /* args */, + std::string* message) { + if (!kEnableFetch) { + *message = "fetch not supported on user builds"; + return false; + } + *message = android::base::StringPrintf("0x%X", kMaxFetchSizeDefault); + return true; +} diff --git a/fastboot/device/variables.h b/fastboot/device/variables.h index c11e472b7..f40a0257e 100644 --- a/fastboot/device/variables.h +++ b/fastboot/device/variables.h @@ -80,6 +80,8 @@ bool GetSecurityPatchLevel(FastbootDevice* device, const std::vector& args, std::string* message); +bool GetMaxFetchSize(FastbootDevice* /* device */, const std::vector& /* args */, + std::string* message); // Helpers for getvar all. std::vector> GetAllPartitionArgsWithSlot(FastbootDevice* device);