From 5b3edfaf9d2f2a855fb0b08534416564ed3995c6 Mon Sep 17 00:00:00 2001 From: Pierre-Hugues Husson Date: Wed, 24 Aug 2022 04:46:10 -0400 Subject: [PATCH] Fix switching from b slot to a slot -- Fixes https://github.com/phhusson/treble_experimentations/issues/2408 --- ota/phh-ota.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ota/phh-ota.cpp b/ota/phh-ota.cpp index e90106a..0a4c7d5 100644 --- a/ota/phh-ota.cpp +++ b/ota/phh-ota.cpp @@ -41,11 +41,9 @@ int main(int argc, char **argv) { } if(argc>=2 && strcmp(argv[1], "new-slot") == 0) { std::string current_slot; - std::string next_slot; - if(!android::base::ReadFileToString("/metadata/phh/img", ¤t_slot)) { - next_slot = "a"; - } else { - if(current_slot.c_str()[0] == 'a') + std::string next_slot = "a"; + if(android::base::ReadFileToString("/metadata/phh/img", ¤t_slot) && + current_slot.c_str()[0] == 'a') { next_slot = "b"; }