From a6759d5d66a71442434b814d562aefbf40eb0567 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Tue, 26 Jul 2022 16:17:59 -0700 Subject: [PATCH] Return empty suffix for invalid slots Old HIDL HAL returns empty suffix, we should maintain this behavior in AIDL. Test: bootctl get-suffix 9, make sure result is empty Bug: 219966986 Change-Id: Ia01c6bda899f3c5e0cdd1007cb051f7558f2e911 --- boot/aidl/default/BootControl.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/boot/aidl/default/BootControl.cpp b/boot/aidl/default/BootControl.cpp index 4e3c21b8a4..b73c94dbfc 100644 --- a/boot/aidl/default/BootControl.cpp +++ b/boot/aidl/default/BootControl.cpp @@ -84,10 +84,12 @@ ScopedAStatus BootControl::getSnapshotMergeStatus(MergeStatus* _aidl_return) { ScopedAStatus BootControl::getSuffix(int32_t in_slot, std::string* _aidl_return) { if (!impl_.IsValidSlot(in_slot)) { - return ScopedAStatus::fromServiceSpecificErrorWithMessage( - INVALID_SLOT, (std::string("Invalid slot ") + std::to_string(in_slot)).c_str()); + // Old HIDL hal returns empty string for invalid slots. We should maintain this behavior in + // AIDL for compatibility. + _aidl_return->clear(); + } else { + *_aidl_return = impl_.GetSuffix(in_slot); } - *_aidl_return = impl_.GetSuffix(in_slot); return ScopedAStatus::ok(); }