blob: e7d8bc366ef92ab38c9e6cd81d992a4d2724ce6a [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
36using ::android::hardware::boot::V1_0::BoolResult;
37using ::android::hardware::boot::V1_0::Slot;
David Andersonab8f4662019-10-21 16:45:59 -070038using ::android::hardware::boot::V1_1::MergeStatus;
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -070039using ::android::hardware::fastboot::V1_0::FileSystemType;
40using ::android::hardware::fastboot::V1_0::Result;
41using ::android::hardware::fastboot::V1_0::Status;
David Andersonab8f4662019-10-21 16:45:59 -070042using IBootControl1_1 = ::android::hardware::boot::V1_1::IBootControl;
David Anderson90fe0a42018-11-05 18:01:32 -080043using namespace android::fs_mgr;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070044
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070045constexpr char kFastbootProtocolVersion[] = "0.4";
46
David Anderson1fb3fd72018-08-31 14:40:22 -070047bool GetVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
48 std::string* message) {
49 *message = kFastbootProtocolVersion;
50 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070051}
52
David Anderson1fb3fd72018-08-31 14:40:22 -070053bool GetBootloaderVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
54 std::string* message) {
55 *message = android::base::GetProperty("ro.bootloader", "");
56 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070057}
58
David Anderson1fb3fd72018-08-31 14:40:22 -070059bool GetBasebandVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
60 std::string* message) {
61 *message = android::base::GetProperty("ro.build.expect.baseband", "");
62 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070063}
64
Bowgo Tsai99f9a382020-01-21 18:31:23 +080065bool GetOsVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
66 std::string* message) {
67 *message = android::base::GetProperty("ro.build.version.release", "");
68 return true;
69}
70
71bool GetVndkVersion(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
72 std::string* message) {
73 *message = android::base::GetProperty("ro.vndk.version", "");
74 return true;
75}
76
David Anderson1fb3fd72018-08-31 14:40:22 -070077bool GetProduct(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
78 std::string* message) {
79 *message = android::base::GetProperty("ro.product.device", "");
80 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070081}
82
David Anderson1fb3fd72018-08-31 14:40:22 -070083bool GetSerial(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
84 std::string* message) {
85 *message = android::base::GetProperty("ro.serialno", "");
86 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070087}
88
David Anderson1fb3fd72018-08-31 14:40:22 -070089bool GetSecure(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
90 std::string* message) {
91 *message = android::base::GetBoolProperty("ro.secure", "") ? "yes" : "no";
92 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -070093}
94
Hridya Valsaraju4af80902018-09-26 13:08:16 -070095bool GetVariant(FastbootDevice* device, const std::vector<std::string>& /* args */,
96 std::string* message) {
97 auto fastboot_hal = device->fastboot_hal();
98 if (!fastboot_hal) {
99 *message = "Fastboot HAL not found";
100 return false;
101 }
102
103 Result ret;
104 auto ret_val = fastboot_hal->getVariant([&](std::string device_variant, Result result) {
105 *message = device_variant;
106 ret = result;
107 });
108 if (!ret_val.isOk() || ret.status != Status::SUCCESS) {
109 *message = "Unable to get device variant";
110 return false;
111 }
112
113 return true;
114}
115
Hridya Valsarajua534a5a2018-10-03 15:53:22 -0700116bool GetBatteryVoltageHelper(FastbootDevice* device, int32_t* battery_voltage) {
117 using android::hardware::health::V2_0::HealthInfo;
118 using android::hardware::health::V2_0::Result;
119
120 auto health_hal = device->health_hal();
121 if (!health_hal) {
122 return false;
123 }
124
125 Result ret;
126 auto ret_val = health_hal->getHealthInfo([&](Result result, HealthInfo info) {
127 *battery_voltage = info.legacy.batteryVoltage;
128 ret = result;
129 });
130 if (!ret_val.isOk() || (ret != Result::SUCCESS)) {
131 return false;
132 }
133
134 return true;
135}
136
137bool GetBatterySoCOk(FastbootDevice* device, const std::vector<std::string>& /* args */,
138 std::string* message) {
139 int32_t battery_voltage = 0;
140 if (!GetBatteryVoltageHelper(device, &battery_voltage)) {
141 *message = "Unable to read battery voltage";
142 return false;
143 }
144
145 auto fastboot_hal = device->fastboot_hal();
146 if (!fastboot_hal) {
147 *message = "Fastboot HAL not found";
148 return false;
149 }
150
151 Result ret;
152 auto ret_val = fastboot_hal->getBatteryVoltageFlashingThreshold(
153 [&](int32_t voltage_threshold, Result result) {
154 *message = battery_voltage >= voltage_threshold ? "yes" : "no";
155 ret = result;
156 });
157
158 if (!ret_val.isOk() || ret.status != Status::SUCCESS) {
159 *message = "Unable to get battery voltage flashing threshold";
160 return false;
161 }
162
163 return true;
164}
165
Hridya Valsaraju7c9bbe92018-09-27 10:41:01 -0700166bool GetOffModeChargeState(FastbootDevice* device, const std::vector<std::string>& /* args */,
167 std::string* message) {
168 auto fastboot_hal = device->fastboot_hal();
169 if (!fastboot_hal) {
170 *message = "Fastboot HAL not found";
171 return false;
172 }
173
174 Result ret;
175 auto ret_val =
176 fastboot_hal->getOffModeChargeState([&](bool off_mode_charging_state, Result result) {
177 *message = off_mode_charging_state ? "1" : "0";
178 ret = result;
179 });
180 if (!ret_val.isOk() || (ret.status != Status::SUCCESS)) {
181 *message = "Unable to get off mode charge state";
182 return false;
183 }
184
185 return true;
186}
187
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700188bool GetBatteryVoltage(FastbootDevice* device, const std::vector<std::string>& /* args */,
189 std::string* message) {
Hridya Valsarajua534a5a2018-10-03 15:53:22 -0700190 int32_t battery_voltage = 0;
191 if (GetBatteryVoltageHelper(device, &battery_voltage)) {
192 *message = std::to_string(battery_voltage);
193 return true;
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700194 }
Hridya Valsarajua534a5a2018-10-03 15:53:22 -0700195 *message = "Unable to get battery voltage";
196 return false;
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700197}
198
David Anderson1fb3fd72018-08-31 14:40:22 -0700199bool GetCurrentSlot(FastbootDevice* device, const std::vector<std::string>& /* args */,
200 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700201 std::string suffix = device->GetCurrentSlot();
David Anderson1fb3fd72018-08-31 14:40:22 -0700202 *message = suffix.size() == 2 ? suffix.substr(1) : suffix;
203 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700204}
205
David Anderson1fb3fd72018-08-31 14:40:22 -0700206bool GetSlotCount(FastbootDevice* device, const std::vector<std::string>& /* args */,
207 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700208 auto boot_control_hal = device->boot_control_hal();
209 if (!boot_control_hal) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700210 *message = "0";
211 } else {
212 *message = std::to_string(boot_control_hal->getNumberSlots());
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700213 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700214 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700215}
216
David Anderson1fb3fd72018-08-31 14:40:22 -0700217bool GetSlotSuccessful(FastbootDevice* device, const std::vector<std::string>& args,
218 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700219 if (args.empty()) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700220 *message = "Missing argument";
221 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700222 }
223 Slot slot;
224 if (!GetSlotNumber(args[0], &slot)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700225 *message = "Invalid slot";
226 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700227 }
228 auto boot_control_hal = device->boot_control_hal();
229 if (!boot_control_hal) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700230 *message = "Device has no slots";
231 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700232 }
David Anderson856b7ec2018-08-08 17:58:56 -0700233 if (boot_control_hal->isSlotMarkedSuccessful(slot) != BoolResult::TRUE) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700234 *message = "no";
235 } else {
236 *message = "yes";
David Anderson856b7ec2018-08-08 17:58:56 -0700237 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700238 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700239}
240
David Anderson1fb3fd72018-08-31 14:40:22 -0700241bool GetSlotUnbootable(FastbootDevice* device, const std::vector<std::string>& args,
242 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700243 if (args.empty()) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700244 *message = "Missing argument";
245 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700246 }
247 Slot slot;
248 if (!GetSlotNumber(args[0], &slot)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700249 *message = "Invalid slot";
250 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700251 }
252 auto boot_control_hal = device->boot_control_hal();
253 if (!boot_control_hal) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700254 *message = "Device has no slots";
255 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700256 }
David Anderson856b7ec2018-08-08 17:58:56 -0700257 if (boot_control_hal->isSlotBootable(slot) != BoolResult::TRUE) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700258 *message = "yes";
259 } else {
260 *message = "no";
David Anderson856b7ec2018-08-08 17:58:56 -0700261 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700262 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700263}
264
David Anderson1fb3fd72018-08-31 14:40:22 -0700265bool GetMaxDownloadSize(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
266 std::string* message) {
David Anderson28b81cd2018-09-04 16:51:29 -0700267 *message = android::base::StringPrintf("0x%X", kMaxDownloadSizeDefault);
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 GetUnlocked(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
272 std::string* message) {
Hridya Valsarajudca328d2018-09-24 16:01:35 -0700273 *message = GetDeviceLockStatus() ? "no" : "yes";
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 GetHasSlot(FastbootDevice* device, const std::vector<std::string>& args,
278 std::string* message) {
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700279 if (args.empty()) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700280 *message = "Missing argument";
281 return false;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700282 }
283 std::string slot_suffix = device->GetCurrentSlot();
284 if (slot_suffix.empty()) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700285 *message = "no";
286 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700287 }
David Anderson79ab0e32018-08-14 16:21:50 -0700288 std::string partition_name = args[0] + slot_suffix;
David Andersond25f1c32018-11-09 20:41:33 -0800289 if (FindPhysicalPartition(partition_name) || LogicalPartitionExists(device, partition_name)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700290 *message = "yes";
291 } else {
292 *message = "no";
David Anderson79ab0e32018-08-14 16:21:50 -0700293 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700294 return true;
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700295}
David Anderson12211d12018-07-24 15:21:20 -0700296
David Anderson1fb3fd72018-08-31 14:40:22 -0700297bool GetPartitionSize(FastbootDevice* device, const std::vector<std::string>& args,
298 std::string* message) {
David Anderson12211d12018-07-24 15:21:20 -0700299 if (args.size() < 1) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700300 *message = "Missing argument";
301 return false;
David Anderson12211d12018-07-24 15:21:20 -0700302 }
David Anderson88ef0b12018-08-09 10:40:00 -0700303 // Zero-length partitions cannot be created through device-mapper, so we
304 // special case them here.
305 bool is_zero_length;
David Andersond25f1c32018-11-09 20:41:33 -0800306 if (LogicalPartitionExists(device, args[0], &is_zero_length) && is_zero_length) {
Hridya Valsaraju2a377da2018-10-09 10:03:51 -0700307 *message = "0x0";
David Anderson1fb3fd72018-08-31 14:40:22 -0700308 return true;
David Anderson88ef0b12018-08-09 10:40:00 -0700309 }
310 // Otherwise, open the partition as normal.
David Anderson12211d12018-07-24 15:21:20 -0700311 PartitionHandle handle;
312 if (!OpenPartition(device, args[0], &handle)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700313 *message = "Could not open partition";
314 return false;
David Anderson12211d12018-07-24 15:21:20 -0700315 }
316 uint64_t size = get_block_device_size(handle.fd());
David Anderson47589672018-09-04 16:22:41 -0700317 *message = android::base::StringPrintf("0x%" PRIX64, size);
David Anderson1fb3fd72018-08-31 14:40:22 -0700318 return true;
David Anderson12211d12018-07-24 15:21:20 -0700319}
David Anderson0d4277d2018-07-31 13:27:37 -0700320
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700321bool GetPartitionType(FastbootDevice* device, const std::vector<std::string>& args,
322 std::string* message) {
323 if (args.size() < 1) {
324 *message = "Missing argument";
325 return false;
326 }
Hridya Valsaraju4165e002018-10-09 10:40:35 -0700327
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700328 std::string partition_name = args[0];
David Andersond25f1c32018-11-09 20:41:33 -0800329 if (!FindPhysicalPartition(partition_name) && !LogicalPartitionExists(device, partition_name)) {
Hridya Valsaraju4165e002018-10-09 10:40:35 -0700330 *message = "Invalid partition";
331 return false;
332 }
333
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700334 auto fastboot_hal = device->fastboot_hal();
335 if (!fastboot_hal) {
336 *message = "Fastboot HAL not found";
337 return false;
338 }
339
340 FileSystemType type;
341 Result ret;
342 auto ret_val =
343 fastboot_hal->getPartitionType(args[0], [&](FileSystemType fs_type, Result result) {
344 type = fs_type;
345 ret = result;
346 });
347 if (!ret_val.isOk() || (ret.status != Status::SUCCESS)) {
348 *message = "Unable to retrieve partition type";
349 } else {
350 switch (type) {
351 case FileSystemType::RAW:
352 *message = "raw";
353 return true;
354 case FileSystemType::EXT4:
355 *message = "ext4";
356 return true;
357 case FileSystemType::F2FS:
358 *message = "f2fs";
359 return true;
360 default:
361 *message = "Unknown file system type";
362 }
363 }
364
365 return false;
366}
367
David Anderson1fb3fd72018-08-31 14:40:22 -0700368bool GetPartitionIsLogical(FastbootDevice* device, const std::vector<std::string>& args,
369 std::string* message) {
David Anderson0d4277d2018-07-31 13:27:37 -0700370 if (args.size() < 1) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700371 *message = "Missing argument";
372 return false;
David Anderson0d4277d2018-07-31 13:27:37 -0700373 }
374 // Note: if a partition name is in both the GPT and the super partition, we
375 // return "true", to be consistent with prefering to flash logical partitions
376 // over physical ones.
377 std::string partition_name = args[0];
David Andersond25f1c32018-11-09 20:41:33 -0800378 if (LogicalPartitionExists(device, partition_name)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700379 *message = "yes";
380 return true;
David Anderson0d4277d2018-07-31 13:27:37 -0700381 }
382 if (FindPhysicalPartition(partition_name)) {
David Anderson1fb3fd72018-08-31 14:40:22 -0700383 *message = "no";
384 return true;
David Anderson0d4277d2018-07-31 13:27:37 -0700385 }
David Anderson1fb3fd72018-08-31 14:40:22 -0700386 *message = "Partition not found";
387 return false;
David Anderson0d4277d2018-07-31 13:27:37 -0700388}
David Andersond9ba0612018-08-02 11:05:00 -0700389
David Anderson1fb3fd72018-08-31 14:40:22 -0700390bool GetIsUserspace(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
391 std::string* message) {
392 *message = "yes";
393 return true;
David Andersond9ba0612018-08-02 11:05:00 -0700394}
David Anderson0f626632018-08-31 16:44:25 -0700395
396std::vector<std::vector<std::string>> GetAllPartitionArgsWithSlot(FastbootDevice* device) {
397 std::vector<std::vector<std::string>> args;
398 auto partitions = ListPartitions(device);
399 for (const auto& partition : partitions) {
400 args.emplace_back(std::initializer_list<std::string>{partition});
401 }
402 return args;
403}
404
405std::vector<std::vector<std::string>> GetAllPartitionArgsNoSlot(FastbootDevice* device) {
406 auto partitions = ListPartitions(device);
407
408 std::string slot_suffix = device->GetCurrentSlot();
409 if (!slot_suffix.empty()) {
410 auto names = std::move(partitions);
411 for (const auto& name : names) {
412 std::string slotless_name = name;
413 if (android::base::EndsWith(name, "_a") || android::base::EndsWith(name, "_b")) {
414 slotless_name = name.substr(0, name.rfind("_"));
415 }
416 if (std::find(partitions.begin(), partitions.end(), slotless_name) ==
417 partitions.end()) {
418 partitions.emplace_back(slotless_name);
419 }
420 }
421 }
422
423 std::vector<std::vector<std::string>> args;
424 for (const auto& partition : partitions) {
425 args.emplace_back(std::initializer_list<std::string>{partition});
426 }
427 return args;
428}
David Andersonc091c172018-09-04 18:11:03 -0700429
430bool GetHardwareRevision(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
431 std::string* message) {
432 *message = android::base::GetProperty("ro.revision", "");
433 return true;
434}
David Anderson90fe0a42018-11-05 18:01:32 -0800435
436bool GetSuperPartitionName(FastbootDevice* device, const std::vector<std::string>& /* args */,
437 std::string* message) {
438 uint32_t slot_number = SlotNumberForSlotSuffix(device->GetCurrentSlot());
439 *message = fs_mgr_get_super_partition_name(slot_number);
440 return true;
441}
David Andersonab8f4662019-10-21 16:45:59 -0700442
443bool GetSnapshotUpdateStatus(FastbootDevice* device, const std::vector<std::string>& /* args */,
444 std::string* message) {
445 // Note that we use the HAL rather than mounting /metadata, since we want
446 // our results to match the bootloader.
David Anderson220ddb12019-10-31 18:02:41 -0700447 auto hal = device->boot1_1();
David Andersonab8f4662019-10-21 16:45:59 -0700448 if (!hal) {
449 *message = "not supported";
450 return false;
451 }
452
David Anderson220ddb12019-10-31 18:02:41 -0700453 MergeStatus status = hal->getSnapshotMergeStatus();
David Andersonab8f4662019-10-21 16:45:59 -0700454 switch (status) {
455 case MergeStatus::SNAPSHOTTED:
456 *message = "snapshotted";
457 break;
458 case MergeStatus::MERGING:
459 *message = "merging";
460 break;
461 default:
462 *message = "none";
463 break;
464 }
465 return true;
466}
Bowgo Tsai33da5c92019-11-13 17:13:49 +0800467
468bool GetCpuAbi(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
469 std::string* message) {
470 *message = android::base::GetProperty("ro.product.cpu.abi", "");
471 return true;
472}
Bowgo Tsai99f9a382020-01-21 18:31:23 +0800473
474bool GetSystemFingerprint(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
475 std::string* message) {
476 *message = android::base::GetProperty("ro.system.build.fingerprint", "");
477 if (message->empty()) {
478 *message = android::base::GetProperty("ro.build.fingerprint", "");
479 }
480 return true;
481}
482
483bool GetVendorFingerprint(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
484 std::string* message) {
485 *message = android::base::GetProperty("ro.vendor.build.fingerprint", "");
486 return true;
487}
488
489bool GetDynamicPartition(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
490 std::string* message) {
491 *message = android::base::GetProperty("ro.boot.dynamic_partitions", "");
492 return true;
493}
494
495bool GetFirstApiLevel(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
496 std::string* message) {
497 *message = android::base::GetProperty("ro.product.first_api_level", "");
498 return true;
499}
500
501bool GetSecurityPatchLevel(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
502 std::string* message) {
503 *message = android::base::GetProperty("ro.build.version.security_patch", "");
504 return true;
505}
506
507bool GetTrebleEnabled(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
508 std::string* message) {
509 *message = android::base::GetProperty("ro.treble.enabled", "");
510 return true;
511}