blob: 0cf4699aab19af29b5063522175f3da978700eb3 [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>
David Anderson90fe0a42018-11-05 18:01:32 -080029#include <liblp/liblp.h>
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070030
31#include "fastboot_device.h"
David Anderson12211d12018-07-24 15:21:20 -070032#include "flashing.h"
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070033#include "utility.h"
34
Yifan Hongb299cb72021-02-17 13:44:49 -080035#ifdef FB_ENABLE_FETCH
36static constexpr bool kEnableFetch = true;
37#else
38static constexpr bool kEnableFetch = false;
39#endif
40
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070041using ::android::hardware::boot::V1_0::BoolResult;
42using ::android::hardware::boot::V1_0::Slot;
David Andersonab8f4662019-10-21 16:45:59 -070043using ::android::hardware::boot::V1_1::MergeStatus;
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -070044using ::android::hardware::fastboot::V1_0::FileSystemType;
45using ::android::hardware::fastboot::V1_0::Result;
46using ::android::hardware::fastboot::V1_0::Status;
David Andersonab8f4662019-10-21 16:45:59 -070047using IBootControl1_1 = ::android::hardware::boot::V1_1::IBootControl;
David Anderson90fe0a42018-11-05 18:01:32 -080048using namespace android::fs_mgr;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070049
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070050constexpr char kFastbootProtocolVersion[] = "0.4";
51
David Anderson1fb3fd72018-08-31 14:40:22 -070052bool GetVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
53 std::string* message) {
54 *message = kFastbootProtocolVersion;
55 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070056}
57
David Anderson1fb3fd72018-08-31 14:40:22 -070058bool GetBootloaderVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
59 std::string* message) {
60 *message = android::base::GetProperty("ro.bootloader", "");
61 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070062}
63
David Anderson1fb3fd72018-08-31 14:40:22 -070064bool GetBasebandVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
65 std::string* message) {
66 *message = android::base::GetProperty("ro.build.expect.baseband", "");
67 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070068}
69
Bowgo Tsai99f9a382020-01-21 18:31:23 +080070bool GetOsVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
71 std::string* message) {
72 *message = android::base::GetProperty("ro.build.version.release", "");
73 return true;
74}
75
76bool GetVndkVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
77 std::string* message) {
78 *message = android::base::GetProperty("ro.vndk.version", "");
79 return true;
80}
81
David Anderson1fb3fd72018-08-31 14:40:22 -070082bool GetProduct(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
83 std::string* message) {
84 *message = android::base::GetProperty("ro.product.device", "");
85 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070086}
87
David Anderson1fb3fd72018-08-31 14:40:22 -070088bool GetSerial(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
89 std::string* message) {
90 *message = android::base::GetProperty("ro.serialno", "");
91 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070092}
93
David Anderson1fb3fd72018-08-31 14:40:22 -070094bool GetSecure(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
95 std::string* message) {
96 *message = android::base::GetBoolProperty("ro.secure", "") ? "yes" : "no";
97 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070098}
99
Hridya Valsaraju4af80902018-09-26 13:08:16 -0700100bool GetVariant(FastbootDevice* device, const std::vector<std::string>& /* args */,
101 std::string* message) {
102 auto fastboot_hal = device->fastboot_hal();
103 if (!fastboot_hal) {
104 *message = "Fastboot HAL not found";
105 return false;
106 }
107
108 Result ret;
109 auto ret_val = fastboot_hal->getVariant([&](std::string device_variant, Result result) {
110 *message = device_variant;
111 ret = result;
112 });
113 if (!ret_val.isOk() || ret.status != Status::SUCCESS) {
114 *message = "Unable to get device variant";
115 return false;
116 }
117
118 return true;
119}
120
Hridya Valsarajua534a5a2018-10-03 15:53:22 -0700121bool GetBatteryVoltageHelper(FastbootDevice* device, int32_t* battery_voltage) {
Yifan Hong4cb88dc2021-12-02 18:58:02 -0800122 using aidl::android::hardware::health::HealthInfo;
Hridya Valsarajua534a5a2018-10-03 15:53:22 -0700123
124 auto health_hal = device->health_hal();
125 if (!health_hal) {
126 return false;
127 }
128
Yifan Hong4cb88dc2021-12-02 18:58:02 -0800129 HealthInfo health_info;
130 auto res = health_hal->getHealthInfo(&health_info);
131 if (!res.isOk()) return false;
132 *battery_voltage = health_info.batteryVoltageMillivolts;
Hridya Valsarajua534a5a2018-10-03 15:53:22 -0700133 return true;
134}
135
136bool GetBatterySoCOk(FastbootDevice* device, const std::vector<std::string>& /* args */,
137 std::string* message) {
138 int32_t battery_voltage = 0;
139 if (!GetBatteryVoltageHelper(device, &battery_voltage)) {
140 *message = "Unable to read battery voltage";
141 return false;
142 }
143
144 auto fastboot_hal = device->fastboot_hal();
145 if (!fastboot_hal) {
146 *message = "Fastboot HAL not found";
147 return false;
148 }
149
150 Result ret;
151 auto ret_val = fastboot_hal->getBatteryVoltageFlashingThreshold(
152 [&](int32_t voltage_threshold, Result result) {
153 *message = battery_voltage >= voltage_threshold ? "yes" : "no";
154 ret = result;
155 });
156
157 if (!ret_val.isOk() || ret.status != Status::SUCCESS) {
158 *message = "Unable to get battery voltage flashing threshold";
159 return false;
160 }
161
162 return true;
163}
164
Hridya Valsaraju7c9bbe92018-09-27 10:41:01 -0700165bool GetOffModeChargeState(FastbootDevice* device, const std::vector<std::string>& /* args */,
166 std::string* message) {
167 auto fastboot_hal = device->fastboot_hal();
168 if (!fastboot_hal) {
169 *message = "Fastboot HAL not found";
170 return false;
171 }
172
173 Result ret;
174 auto ret_val =
175 fastboot_hal->getOffModeChargeState([&](bool off_mode_charging_state, Result result) {
176 *message = off_mode_charging_state ? "1" : "0";
177 ret = result;
178 });
179 if (!ret_val.isOk() || (ret.status != Status::SUCCESS)) {
180 *message = "Unable to get off mode charge state";
181 return false;
182 }
183
184 return true;
185}
186
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700187bool GetBatteryVoltage(FastbootDevice* device, const std::vector<std::string>& /* args */,
188 std::string* message) {
Hridya Valsarajua534a5a2018-10-03 15:53:22 -0700189 int32_t battery_voltage = 0;
190 if (GetBatteryVoltageHelper(device, &battery_voltage)) {
191 *message = std::to_string(battery_voltage);
192 return true;
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700193 }
Hridya Valsarajua534a5a2018-10-03 15:53:22 -0700194 *message = "Unable to get battery voltage";
195 return false;
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700196}
197
David Anderson1fb3fd72018-08-31 14:40:22 -0700198bool GetCurrentSlot(FastbootDevice* device, const std::vector<std::string>& /* args */,
199 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700200 std::string suffix = device->GetCurrentSlot();
David Anderson1fb3fd72018-08-31 14:40:22 -0700201 *message = suffix.size() == 2 ? suffix.substr(1) : suffix;
202 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700203}
204
David Anderson1fb3fd72018-08-31 14:40:22 -0700205bool GetSlotCount(FastbootDevice* device, const std::vector<std::string>& /* args */,
206 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700207 auto boot_control_hal = device->boot_control_hal();
208 if (!boot_control_hal) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700209 *message = "0";
210 } else {
211 *message = std::to_string(boot_control_hal->getNumberSlots());
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700212 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700213 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700214}
215
David Anderson1fb3fd72018-08-31 14:40:22 -0700216bool GetSlotSuccessful(FastbootDevice* device, const std::vector<std::string>& args,
217 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700218 if (args.empty()) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700219 *message = "Missing argument";
220 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700221 }
222 Slot slot;
223 if (!GetSlotNumber(args[0], &slot)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700224 *message = "Invalid slot";
225 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700226 }
227 auto boot_control_hal = device->boot_control_hal();
228 if (!boot_control_hal) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700229 *message = "Device has no slots";
230 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700231 }
David Anderson856b7ec2018-08-08 17:58:56 -0700232 if (boot_control_hal->isSlotMarkedSuccessful(slot) != BoolResult::TRUE) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700233 *message = "no";
234 } else {
235 *message = "yes";
David Anderson856b7ec2018-08-08 17:58:56 -0700236 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700237 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700238}
239
David Anderson1fb3fd72018-08-31 14:40:22 -0700240bool GetSlotUnbootable(FastbootDevice* device, const std::vector<std::string>& args,
241 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700242 if (args.empty()) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700243 *message = "Missing argument";
244 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700245 }
246 Slot slot;
247 if (!GetSlotNumber(args[0], &slot)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700248 *message = "Invalid slot";
249 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700250 }
251 auto boot_control_hal = device->boot_control_hal();
252 if (!boot_control_hal) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700253 *message = "Device has no slots";
254 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700255 }
David Anderson856b7ec2018-08-08 17:58:56 -0700256 if (boot_control_hal->isSlotBootable(slot) != BoolResult::TRUE) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700257 *message = "yes";
258 } else {
259 *message = "no";
David Anderson856b7ec2018-08-08 17:58:56 -0700260 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700261 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700262}
263
David Anderson1fb3fd72018-08-31 14:40:22 -0700264bool GetMaxDownloadSize(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
265 std::string* message) {
David Anderson28b81cd2018-09-04 16:51:29 -0700266 *message = android::base::StringPrintf("0x%X", kMaxDownloadSizeDefault);
David Anderson1fb3fd72018-08-31 14:40:22 -0700267 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700268}
269
David Anderson1fb3fd72018-08-31 14:40:22 -0700270bool GetUnlocked(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
271 std::string* message) {
Hridya Valsarajudca328d2018-09-24 16:01:35 -0700272 *message = GetDeviceLockStatus() ? "no" : "yes";
David Anderson1fb3fd72018-08-31 14:40:22 -0700273 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700274}
275
David Anderson1fb3fd72018-08-31 14:40:22 -0700276bool GetHasSlot(FastbootDevice* device, const std::vector<std::string>& args,
277 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700278 if (args.empty()) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700279 *message = "Missing argument";
280 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700281 }
282 std::string slot_suffix = device->GetCurrentSlot();
283 if (slot_suffix.empty()) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700284 *message = "no";
285 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700286 }
David Anderson79ab0e32018-08-14 16:21:50 -0700287 std::string partition_name = args[0] + slot_suffix;
David Andersond25f1c32018-11-09 20:41:33 -0800288 if (FindPhysicalPartition(partition_name) || LogicalPartitionExists(device, partition_name)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700289 *message = "yes";
290 } else {
291 *message = "no";
David Anderson79ab0e32018-08-14 16:21:50 -0700292 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700293 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700294}
David Anderson12211d12018-07-24 15:21:20 -0700295
David Anderson1fb3fd72018-08-31 14:40:22 -0700296bool GetPartitionSize(FastbootDevice* device, const std::vector<std::string>& args,
297 std::string* message) {
David Anderson12211d12018-07-24 15:21:20 -0700298 if (args.size() < 1) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700299 *message = "Missing argument";
300 return false;
David Anderson12211d12018-07-24 15:21:20 -0700301 }
David Anderson88ef0b12018-08-09 10:40:00 -0700302 // Zero-length partitions cannot be created through device-mapper, so we
303 // special case them here.
304 bool is_zero_length;
David Andersond25f1c32018-11-09 20:41:33 -0800305 if (LogicalPartitionExists(device, args[0], &is_zero_length) && is_zero_length) {
Hridya Valsaraju2a377da2018-10-09 10:03:51 -0700306 *message = "0x0";
David Anderson1fb3fd72018-08-31 14:40:22 -0700307 return true;
David Anderson88ef0b12018-08-09 10:40:00 -0700308 }
309 // Otherwise, open the partition as normal.
David Anderson12211d12018-07-24 15:21:20 -0700310 PartitionHandle handle;
311 if (!OpenPartition(device, args[0], &handle)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700312 *message = "Could not open partition";
313 return false;
David Anderson12211d12018-07-24 15:21:20 -0700314 }
315 uint64_t size = get_block_device_size(handle.fd());
David Anderson47589672018-09-04 16:22:41 -0700316 *message = android::base::StringPrintf("0x%" PRIX64, size);
David Anderson1fb3fd72018-08-31 14:40:22 -0700317 return true;
David Anderson12211d12018-07-24 15:21:20 -0700318}
David Anderson0d4277d2018-07-31 13:27:37 -0700319
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700320bool GetPartitionType(FastbootDevice* device, const std::vector<std::string>& args,
321 std::string* message) {
322 if (args.size() < 1) {
323 *message = "Missing argument";
324 return false;
325 }
Hridya Valsaraju4165e002018-10-09 10:40:35 -0700326
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700327 std::string partition_name = args[0];
David Andersond25f1c32018-11-09 20:41:33 -0800328 if (!FindPhysicalPartition(partition_name) && !LogicalPartitionExists(device, partition_name)) {
Hridya Valsaraju4165e002018-10-09 10:40:35 -0700329 *message = "Invalid partition";
330 return false;
331 }
332
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700333 auto fastboot_hal = device->fastboot_hal();
334 if (!fastboot_hal) {
LuK13379dd073e2022-03-02 14:18:27 +0100335 *message = "raw";
336 return true;
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700337 }
338
339 FileSystemType type;
340 Result ret;
341 auto ret_val =
342 fastboot_hal->getPartitionType(args[0], [&](FileSystemType fs_type, Result result) {
343 type = fs_type;
344 ret = result;
345 });
346 if (!ret_val.isOk() || (ret.status != Status::SUCCESS)) {
347 *message = "Unable to retrieve partition type";
348 } else {
349 switch (type) {
350 case FileSystemType::RAW:
351 *message = "raw";
352 return true;
353 case FileSystemType::EXT4:
354 *message = "ext4";
355 return true;
356 case FileSystemType::F2FS:
357 *message = "f2fs";
358 return true;
359 default:
360 *message = "Unknown file system type";
361 }
362 }
363
364 return false;
365}
366
David Anderson1fb3fd72018-08-31 14:40:22 -0700367bool GetPartitionIsLogical(FastbootDevice* device, const std::vector<std::string>& args,
368 std::string* message) {
David Anderson0d4277d2018-07-31 13:27:37 -0700369 if (args.size() < 1) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700370 *message = "Missing argument";
371 return false;
David Anderson0d4277d2018-07-31 13:27:37 -0700372 }
373 // Note: if a partition name is in both the GPT and the super partition, we
374 // return "true", to be consistent with prefering to flash logical partitions
375 // over physical ones.
376 std::string partition_name = args[0];
David Andersond25f1c32018-11-09 20:41:33 -0800377 if (LogicalPartitionExists(device, partition_name)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700378 *message = "yes";
379 return true;
David Anderson0d4277d2018-07-31 13:27:37 -0700380 }
381 if (FindPhysicalPartition(partition_name)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700382 *message = "no";
383 return true;
David Anderson0d4277d2018-07-31 13:27:37 -0700384 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700385 *message = "Partition not found";
386 return false;
David Anderson0d4277d2018-07-31 13:27:37 -0700387}
David Andersond9ba0612018-08-02 11:05:00 -0700388
David Anderson1fb3fd72018-08-31 14:40:22 -0700389bool GetIsUserspace(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
390 std::string* message) {
391 *message = "yes";
392 return true;
David Andersond9ba0612018-08-02 11:05:00 -0700393}
David Anderson0f626632018-08-31 16:44:25 -0700394
395std::vector<std::vector<std::string>> GetAllPartitionArgsWithSlot(FastbootDevice* device) {
396 std::vector<std::vector<std::string>> args;
397 auto partitions = ListPartitions(device);
398 for (const auto& partition : partitions) {
399 args.emplace_back(std::initializer_list<std::string>{partition});
400 }
401 return args;
402}
403
404std::vector<std::vector<std::string>> GetAllPartitionArgsNoSlot(FastbootDevice* device) {
405 auto partitions = ListPartitions(device);
406
407 std::string slot_suffix = device->GetCurrentSlot();
408 if (!slot_suffix.empty()) {
409 auto names = std::move(partitions);
410 for (const auto& name : names) {
411 std::string slotless_name = name;
412 if (android::base::EndsWith(name, "_a") || android::base::EndsWith(name, "_b")) {
413 slotless_name = name.substr(0, name.rfind("_"));
414 }
415 if (std::find(partitions.begin(), partitions.end(), slotless_name) ==
416 partitions.end()) {
417 partitions.emplace_back(slotless_name);
418 }
419 }
420 }
421
422 std::vector<std::vector<std::string>> args;
423 for (const auto& partition : partitions) {
424 args.emplace_back(std::initializer_list<std::string>{partition});
425 }
426 return args;
427}
David Andersonc091c172018-09-04 18:11:03 -0700428
429bool GetHardwareRevision(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
430 std::string* message) {
431 *message = android::base::GetProperty("ro.revision", "");
432 return true;
433}
David Anderson90fe0a42018-11-05 18:01:32 -0800434
435bool GetSuperPartitionName(FastbootDevice* device, const std::vector<std::string>& /* args */,
436 std::string* message) {
437 uint32_t slot_number = SlotNumberForSlotSuffix(device->GetCurrentSlot());
438 *message = fs_mgr_get_super_partition_name(slot_number);
439 return true;
440}
David Andersonab8f4662019-10-21 16:45:59 -0700441
442bool GetSnapshotUpdateStatus(FastbootDevice* device, const std::vector<std::string>& /* args */,
443 std::string* message) {
444 // Note that we use the HAL rather than mounting /metadata, since we want
445 // our results to match the bootloader.
David Anderson220ddb12019-10-31 18:02:41 -0700446 auto hal = device->boot1_1();
David Andersonab8f4662019-10-21 16:45:59 -0700447 if (!hal) {
448 *message = "not supported";
449 return false;
450 }
451
David Anderson220ddb12019-10-31 18:02:41 -0700452 MergeStatus status = hal->getSnapshotMergeStatus();
David Andersonab8f4662019-10-21 16:45:59 -0700453 switch (status) {
454 case MergeStatus::SNAPSHOTTED:
455 *message = "snapshotted";
456 break;
457 case MergeStatus::MERGING:
458 *message = "merging";
459 break;
460 default:
461 *message = "none";
462 break;
463 }
464 return true;
465}
Bowgo Tsai33da5c92019-11-13 17:13:49 +0800466
467bool GetCpuAbi(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
468 std::string* message) {
469 *message = android::base::GetProperty("ro.product.cpu.abi", "");
470 return true;
471}
Bowgo Tsai99f9a382020-01-21 18:31:23 +0800472
473bool GetSystemFingerprint(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
474 std::string* message) {
475 *message = android::base::GetProperty("ro.system.build.fingerprint", "");
476 if (message->empty()) {
477 *message = android::base::GetProperty("ro.build.fingerprint", "");
478 }
479 return true;
480}
481
482bool GetVendorFingerprint(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
483 std::string* message) {
484 *message = android::base::GetProperty("ro.vendor.build.fingerprint", "");
485 return true;
486}
487
488bool GetDynamicPartition(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
489 std::string* message) {
490 *message = android::base::GetProperty("ro.boot.dynamic_partitions", "");
491 return true;
492}
493
494bool GetFirstApiLevel(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
495 std::string* message) {
496 *message = android::base::GetProperty("ro.product.first_api_level", "");
497 return true;
498}
499
500bool GetSecurityPatchLevel(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
501 std::string* message) {
502 *message = android::base::GetProperty("ro.build.version.security_patch", "");
503 return true;
504}
505
506bool GetTrebleEnabled(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
507 std::string* message) {
508 *message = android::base::GetProperty("ro.treble.enabled", "");
509 return true;
510}
Yifan Hongb299cb72021-02-17 13:44:49 -0800511
512bool GetMaxFetchSize(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
513 std::string* message) {
514 if (!kEnableFetch) {
515 *message = "fetch not supported on user builds";
516 return false;
517 }
518 *message = android::base::StringPrintf("0x%X", kMaxFetchSizeDefault);
519 return true;
520}