blob: ee1eed876a9fec9e1aa27bc8174d0f92291ef10c [file] [log] [blame]
Hridya Valsaraju31d2c262018-07-20 13:35:50 -07001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "variables.h"
18
David Anderson12211d12018-07-24 15:21:20 -070019#include <inttypes.h>
20
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070021#include <android-base/file.h>
22#include <android-base/logging.h>
23#include <android-base/properties.h>
24#include <android-base/stringprintf.h>
25#include <android-base/strings.h>
David Andersonab8f4662019-10-21 16:45:59 -070026#include <android/hardware/boot/1.1/IBootControl.h>
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070027#include <ext4_utils/ext4_utils.h>
David Anderson90fe0a42018-11-05 18:01:32 -080028#include <fs_mgr.h>
Hridya Valsaraju47658ca2018-09-28 11:41:22 -070029#include <healthhalutils/HealthHalUtils.h>
David Anderson90fe0a42018-11-05 18:01:32 -080030#include <liblp/liblp.h>
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070031
32#include "fastboot_device.h"
David Anderson12211d12018-07-24 15:21:20 -070033#include "flashing.h"
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070034#include "utility.h"
35
Yifan Hongb299cb72021-02-17 13:44:49 -080036#ifdef FB_ENABLE_FETCH
37static constexpr bool kEnableFetch = true;
38#else
39static constexpr bool kEnableFetch = false;
40#endif
41
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070042using ::android::hardware::boot::V1_0::BoolResult;
43using ::android::hardware::boot::V1_0::Slot;
David Andersonab8f4662019-10-21 16:45:59 -070044using ::android::hardware::boot::V1_1::MergeStatus;
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -070045using ::android::hardware::fastboot::V1_0::FileSystemType;
46using ::android::hardware::fastboot::V1_0::Result;
47using ::android::hardware::fastboot::V1_0::Status;
David Andersonab8f4662019-10-21 16:45:59 -070048using IBootControl1_1 = ::android::hardware::boot::V1_1::IBootControl;
David Anderson90fe0a42018-11-05 18:01:32 -080049using namespace android::fs_mgr;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070050
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070051constexpr char kFastbootProtocolVersion[] = "0.4";
52
David Anderson1fb3fd72018-08-31 14:40:22 -070053bool GetVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
54 std::string* message) {
55 *message = kFastbootProtocolVersion;
56 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070057}
58
David Anderson1fb3fd72018-08-31 14:40:22 -070059bool GetBootloaderVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
60 std::string* message) {
61 *message = android::base::GetProperty("ro.bootloader", "");
62 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070063}
64
David Anderson1fb3fd72018-08-31 14:40:22 -070065bool GetBasebandVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
66 std::string* message) {
67 *message = android::base::GetProperty("ro.build.expect.baseband", "");
68 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070069}
70
Bowgo Tsai99f9a382020-01-21 18:31:23 +080071bool GetOsVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
72 std::string* message) {
73 *message = android::base::GetProperty("ro.build.version.release", "");
74 return true;
75}
76
77bool GetVndkVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
78 std::string* message) {
79 *message = android::base::GetProperty("ro.vndk.version", "");
80 return true;
81}
82
David Anderson1fb3fd72018-08-31 14:40:22 -070083bool GetProduct(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
84 std::string* message) {
85 *message = android::base::GetProperty("ro.product.device", "");
86 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070087}
88
David Anderson1fb3fd72018-08-31 14:40:22 -070089bool GetSerial(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
90 std::string* message) {
91 *message = android::base::GetProperty("ro.serialno", "");
92 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070093}
94
David Anderson1fb3fd72018-08-31 14:40:22 -070095bool GetSecure(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
96 std::string* message) {
97 *message = android::base::GetBoolProperty("ro.secure", "") ? "yes" : "no";
98 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070099}
100
Hridya Valsaraju4af80902018-09-26 13:08:16 -0700101bool GetVariant(FastbootDevice* device, const std::vector<std::string>& /* args */,
102 std::string* message) {
103 auto fastboot_hal = device->fastboot_hal();
104 if (!fastboot_hal) {
105 *message = "Fastboot HAL not found";
106 return false;
107 }
108
109 Result ret;
110 auto ret_val = fastboot_hal->getVariant([&](std::string device_variant, Result result) {
111 *message = device_variant;
112 ret = result;
113 });
114 if (!ret_val.isOk() || ret.status != Status::SUCCESS) {
115 *message = "Unable to get device variant";
116 return false;
117 }
118
119 return true;
120}
121
Hridya Valsarajua534a5a2018-10-03 15:53:22 -0700122bool GetBatteryVoltageHelper(FastbootDevice* device, int32_t* battery_voltage) {
123 using android::hardware::health::V2_0::HealthInfo;
124 using android::hardware::health::V2_0::Result;
125
126 auto health_hal = device->health_hal();
127 if (!health_hal) {
128 return false;
129 }
130
131 Result ret;
132 auto ret_val = health_hal->getHealthInfo([&](Result result, HealthInfo info) {
133 *battery_voltage = info.legacy.batteryVoltage;
134 ret = result;
135 });
136 if (!ret_val.isOk() || (ret != Result::SUCCESS)) {
137 return false;
138 }
139
140 return true;
141}
142
143bool GetBatterySoCOk(FastbootDevice* device, const std::vector<std::string>& /* args */,
144 std::string* message) {
145 int32_t battery_voltage = 0;
146 if (!GetBatteryVoltageHelper(device, &battery_voltage)) {
147 *message = "Unable to read battery voltage";
148 return false;
149 }
150
151 auto fastboot_hal = device->fastboot_hal();
152 if (!fastboot_hal) {
153 *message = "Fastboot HAL not found";
154 return false;
155 }
156
157 Result ret;
158 auto ret_val = fastboot_hal->getBatteryVoltageFlashingThreshold(
159 [&](int32_t voltage_threshold, Result result) {
160 *message = battery_voltage >= voltage_threshold ? "yes" : "no";
161 ret = result;
162 });
163
164 if (!ret_val.isOk() || ret.status != Status::SUCCESS) {
165 *message = "Unable to get battery voltage flashing threshold";
166 return false;
167 }
168
169 return true;
170}
171
Hridya Valsaraju7c9bbe92018-09-27 10:41:01 -0700172bool GetOffModeChargeState(FastbootDevice* device, const std::vector<std::string>& /* args */,
173 std::string* message) {
174 auto fastboot_hal = device->fastboot_hal();
175 if (!fastboot_hal) {
176 *message = "Fastboot HAL not found";
177 return false;
178 }
179
180 Result ret;
181 auto ret_val =
182 fastboot_hal->getOffModeChargeState([&](bool off_mode_charging_state, Result result) {
183 *message = off_mode_charging_state ? "1" : "0";
184 ret = result;
185 });
186 if (!ret_val.isOk() || (ret.status != Status::SUCCESS)) {
187 *message = "Unable to get off mode charge state";
188 return false;
189 }
190
191 return true;
192}
193
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700194bool GetBatteryVoltage(FastbootDevice* device, const std::vector<std::string>& /* args */,
195 std::string* message) {
Hridya Valsarajua534a5a2018-10-03 15:53:22 -0700196 int32_t battery_voltage = 0;
197 if (GetBatteryVoltageHelper(device, &battery_voltage)) {
198 *message = std::to_string(battery_voltage);
199 return true;
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700200 }
Hridya Valsarajua534a5a2018-10-03 15:53:22 -0700201 *message = "Unable to get battery voltage";
202 return false;
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700203}
204
David Anderson1fb3fd72018-08-31 14:40:22 -0700205bool GetCurrentSlot(FastbootDevice* device, const std::vector<std::string>& /* args */,
206 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700207 std::string suffix = device->GetCurrentSlot();
David Anderson1fb3fd72018-08-31 14:40:22 -0700208 *message = suffix.size() == 2 ? suffix.substr(1) : suffix;
209 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700210}
211
David Anderson1fb3fd72018-08-31 14:40:22 -0700212bool GetSlotCount(FastbootDevice* device, const std::vector<std::string>& /* args */,
213 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700214 auto boot_control_hal = device->boot_control_hal();
215 if (!boot_control_hal) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700216 *message = "0";
217 } else {
218 *message = std::to_string(boot_control_hal->getNumberSlots());
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700219 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700220 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700221}
222
David Anderson1fb3fd72018-08-31 14:40:22 -0700223bool GetSlotSuccessful(FastbootDevice* device, const std::vector<std::string>& args,
224 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700225 if (args.empty()) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700226 *message = "Missing argument";
227 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700228 }
229 Slot slot;
230 if (!GetSlotNumber(args[0], &slot)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700231 *message = "Invalid slot";
232 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700233 }
234 auto boot_control_hal = device->boot_control_hal();
235 if (!boot_control_hal) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700236 *message = "Device has no slots";
237 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700238 }
David Anderson856b7ec2018-08-08 17:58:56 -0700239 if (boot_control_hal->isSlotMarkedSuccessful(slot) != BoolResult::TRUE) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700240 *message = "no";
241 } else {
242 *message = "yes";
David Anderson856b7ec2018-08-08 17:58:56 -0700243 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700244 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700245}
246
David Anderson1fb3fd72018-08-31 14:40:22 -0700247bool GetSlotUnbootable(FastbootDevice* device, const std::vector<std::string>& args,
248 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700249 if (args.empty()) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700250 *message = "Missing argument";
251 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700252 }
253 Slot slot;
254 if (!GetSlotNumber(args[0], &slot)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700255 *message = "Invalid slot";
256 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700257 }
258 auto boot_control_hal = device->boot_control_hal();
259 if (!boot_control_hal) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700260 *message = "Device has no slots";
261 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700262 }
David Anderson856b7ec2018-08-08 17:58:56 -0700263 if (boot_control_hal->isSlotBootable(slot) != BoolResult::TRUE) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700264 *message = "yes";
265 } else {
266 *message = "no";
David Anderson856b7ec2018-08-08 17:58:56 -0700267 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700268 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700269}
270
David Anderson1fb3fd72018-08-31 14:40:22 -0700271bool GetMaxDownloadSize(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
272 std::string* message) {
David Anderson28b81cd2018-09-04 16:51:29 -0700273 *message = android::base::StringPrintf("0x%X", kMaxDownloadSizeDefault);
David Anderson1fb3fd72018-08-31 14:40:22 -0700274 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700275}
276
David Anderson1fb3fd72018-08-31 14:40:22 -0700277bool GetUnlocked(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
278 std::string* message) {
Hridya Valsarajudca328d2018-09-24 16:01:35 -0700279 *message = GetDeviceLockStatus() ? "no" : "yes";
David Anderson1fb3fd72018-08-31 14:40:22 -0700280 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700281}
282
David Anderson1fb3fd72018-08-31 14:40:22 -0700283bool GetHasSlot(FastbootDevice* device, const std::vector<std::string>& args,
284 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700285 if (args.empty()) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700286 *message = "Missing argument";
287 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700288 }
289 std::string slot_suffix = device->GetCurrentSlot();
290 if (slot_suffix.empty()) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700291 *message = "no";
292 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700293 }
David Anderson79ab0e32018-08-14 16:21:50 -0700294 std::string partition_name = args[0] + slot_suffix;
David Andersond25f1c32018-11-09 20:41:33 -0800295 if (FindPhysicalPartition(partition_name) || LogicalPartitionExists(device, partition_name)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700296 *message = "yes";
297 } else {
298 *message = "no";
David Anderson79ab0e32018-08-14 16:21:50 -0700299 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700300 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700301}
David Anderson12211d12018-07-24 15:21:20 -0700302
David Anderson1fb3fd72018-08-31 14:40:22 -0700303bool GetPartitionSize(FastbootDevice* device, const std::vector<std::string>& args,
304 std::string* message) {
David Anderson12211d12018-07-24 15:21:20 -0700305 if (args.size() < 1) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700306 *message = "Missing argument";
307 return false;
David Anderson12211d12018-07-24 15:21:20 -0700308 }
David Anderson88ef0b12018-08-09 10:40:00 -0700309 // Zero-length partitions cannot be created through device-mapper, so we
310 // special case them here.
311 bool is_zero_length;
David Andersond25f1c32018-11-09 20:41:33 -0800312 if (LogicalPartitionExists(device, args[0], &is_zero_length) && is_zero_length) {
Hridya Valsaraju2a377da2018-10-09 10:03:51 -0700313 *message = "0x0";
David Anderson1fb3fd72018-08-31 14:40:22 -0700314 return true;
David Anderson88ef0b12018-08-09 10:40:00 -0700315 }
316 // Otherwise, open the partition as normal.
David Anderson12211d12018-07-24 15:21:20 -0700317 PartitionHandle handle;
318 if (!OpenPartition(device, args[0], &handle)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700319 *message = "Could not open partition";
320 return false;
David Anderson12211d12018-07-24 15:21:20 -0700321 }
322 uint64_t size = get_block_device_size(handle.fd());
David Anderson47589672018-09-04 16:22:41 -0700323 *message = android::base::StringPrintf("0x%" PRIX64, size);
David Anderson1fb3fd72018-08-31 14:40:22 -0700324 return true;
David Anderson12211d12018-07-24 15:21:20 -0700325}
David Anderson0d4277d2018-07-31 13:27:37 -0700326
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700327bool GetPartitionType(FastbootDevice* device, const std::vector<std::string>& args,
328 std::string* message) {
329 if (args.size() < 1) {
330 *message = "Missing argument";
331 return false;
332 }
Hridya Valsaraju4165e002018-10-09 10:40:35 -0700333
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700334 std::string partition_name = args[0];
David Andersond25f1c32018-11-09 20:41:33 -0800335 if (!FindPhysicalPartition(partition_name) && !LogicalPartitionExists(device, partition_name)) {
Hridya Valsaraju4165e002018-10-09 10:40:35 -0700336 *message = "Invalid partition";
337 return false;
338 }
339
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700340 auto fastboot_hal = device->fastboot_hal();
341 if (!fastboot_hal) {
342 *message = "Fastboot HAL not found";
343 return false;
344 }
345
346 FileSystemType type;
347 Result ret;
348 auto ret_val =
349 fastboot_hal->getPartitionType(args[0], [&](FileSystemType fs_type, Result result) {
350 type = fs_type;
351 ret = result;
352 });
353 if (!ret_val.isOk() || (ret.status != Status::SUCCESS)) {
354 *message = "Unable to retrieve partition type";
355 } else {
356 switch (type) {
357 case FileSystemType::RAW:
358 *message = "raw";
359 return true;
360 case FileSystemType::EXT4:
361 *message = "ext4";
362 return true;
363 case FileSystemType::F2FS:
364 *message = "f2fs";
365 return true;
366 default:
367 *message = "Unknown file system type";
368 }
369 }
370
371 return false;
372}
373
David Anderson1fb3fd72018-08-31 14:40:22 -0700374bool GetPartitionIsLogical(FastbootDevice* device, const std::vector<std::string>& args,
375 std::string* message) {
David Anderson0d4277d2018-07-31 13:27:37 -0700376 if (args.size() < 1) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700377 *message = "Missing argument";
378 return false;
David Anderson0d4277d2018-07-31 13:27:37 -0700379 }
380 // Note: if a partition name is in both the GPT and the super partition, we
381 // return "true", to be consistent with prefering to flash logical partitions
382 // over physical ones.
383 std::string partition_name = args[0];
David Andersond25f1c32018-11-09 20:41:33 -0800384 if (LogicalPartitionExists(device, partition_name)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700385 *message = "yes";
386 return true;
David Anderson0d4277d2018-07-31 13:27:37 -0700387 }
388 if (FindPhysicalPartition(partition_name)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700389 *message = "no";
390 return true;
David Anderson0d4277d2018-07-31 13:27:37 -0700391 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700392 *message = "Partition not found";
393 return false;
David Anderson0d4277d2018-07-31 13:27:37 -0700394}
David Andersond9ba0612018-08-02 11:05:00 -0700395
David Anderson1fb3fd72018-08-31 14:40:22 -0700396bool GetIsUserspace(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
397 std::string* message) {
398 *message = "yes";
399 return true;
David Andersond9ba0612018-08-02 11:05:00 -0700400}
David Anderson0f626632018-08-31 16:44:25 -0700401
402std::vector<std::vector<std::string>> GetAllPartitionArgsWithSlot(FastbootDevice* device) {
403 std::vector<std::vector<std::string>> args;
404 auto partitions = ListPartitions(device);
405 for (const auto& partition : partitions) {
406 args.emplace_back(std::initializer_list<std::string>{partition});
407 }
408 return args;
409}
410
411std::vector<std::vector<std::string>> GetAllPartitionArgsNoSlot(FastbootDevice* device) {
412 auto partitions = ListPartitions(device);
413
414 std::string slot_suffix = device->GetCurrentSlot();
415 if (!slot_suffix.empty()) {
416 auto names = std::move(partitions);
417 for (const auto& name : names) {
418 std::string slotless_name = name;
419 if (android::base::EndsWith(name, "_a") || android::base::EndsWith(name, "_b")) {
420 slotless_name = name.substr(0, name.rfind("_"));
421 }
422 if (std::find(partitions.begin(), partitions.end(), slotless_name) ==
423 partitions.end()) {
424 partitions.emplace_back(slotless_name);
425 }
426 }
427 }
428
429 std::vector<std::vector<std::string>> args;
430 for (const auto& partition : partitions) {
431 args.emplace_back(std::initializer_list<std::string>{partition});
432 }
433 return args;
434}
David Andersonc091c172018-09-04 18:11:03 -0700435
436bool GetHardwareRevision(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
437 std::string* message) {
438 *message = android::base::GetProperty("ro.revision", "");
439 return true;
440}
David Anderson90fe0a42018-11-05 18:01:32 -0800441
442bool GetSuperPartitionName(FastbootDevice* device, const std::vector<std::string>& /* args */,
443 std::string* message) {
444 uint32_t slot_number = SlotNumberForSlotSuffix(device->GetCurrentSlot());
445 *message = fs_mgr_get_super_partition_name(slot_number);
446 return true;
447}
David Andersonab8f4662019-10-21 16:45:59 -0700448
449bool GetSnapshotUpdateStatus(FastbootDevice* device, const std::vector<std::string>& /* args */,
450 std::string* message) {
451 // Note that we use the HAL rather than mounting /metadata, since we want
452 // our results to match the bootloader.
David Anderson220ddb12019-10-31 18:02:41 -0700453 auto hal = device->boot1_1();
David Andersonab8f4662019-10-21 16:45:59 -0700454 if (!hal) {
455 *message = "not supported";
456 return false;
457 }
458
David Anderson220ddb12019-10-31 18:02:41 -0700459 MergeStatus status = hal->getSnapshotMergeStatus();
David Andersonab8f4662019-10-21 16:45:59 -0700460 switch (status) {
461 case MergeStatus::SNAPSHOTTED:
462 *message = "snapshotted";
463 break;
464 case MergeStatus::MERGING:
465 *message = "merging";
466 break;
467 default:
468 *message = "none";
469 break;
470 }
471 return true;
472}
Bowgo Tsai33da5c92019-11-13 17:13:49 +0800473
474bool GetCpuAbi(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
475 std::string* message) {
476 *message = android::base::GetProperty("ro.product.cpu.abi", "");
477 return true;
478}
Bowgo Tsai99f9a382020-01-21 18:31:23 +0800479
480bool GetSystemFingerprint(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
481 std::string* message) {
482 *message = android::base::GetProperty("ro.system.build.fingerprint", "");
483 if (message->empty()) {
484 *message = android::base::GetProperty("ro.build.fingerprint", "");
485 }
486 return true;
487}
488
489bool GetVendorFingerprint(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
490 std::string* message) {
491 *message = android::base::GetProperty("ro.vendor.build.fingerprint", "");
492 return true;
493}
494
495bool GetDynamicPartition(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
496 std::string* message) {
497 *message = android::base::GetProperty("ro.boot.dynamic_partitions", "");
498 return true;
499}
500
501bool GetFirstApiLevel(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
502 std::string* message) {
503 *message = android::base::GetProperty("ro.product.first_api_level", "");
504 return true;
505}
506
507bool GetSecurityPatchLevel(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
508 std::string* message) {
509 *message = android::base::GetProperty("ro.build.version.security_patch", "");
510 return true;
511}
512
513bool GetTrebleEnabled(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
514 std::string* message) {
515 *message = android::base::GetProperty("ro.treble.enabled", "");
516 return true;
517}
Yifan Hongb299cb72021-02-17 13:44:49 -0800518
519bool GetMaxFetchSize(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
520 std::string* message) {
521 if (!kEnableFetch) {
522 *message = "fetch not supported on user builds";
523 return false;
524 }
525 *message = android::base::StringPrintf("0x%X", kMaxFetchSizeDefault);
526 return true;
527}