xref: /aosp_15_r20/bootable/recovery/recovery_ui/stub_ui.cpp (revision e7c364b630b241adcb6c7726a21055250b91fdac)
1*e7c364b6SAndroid Build Coastguard Worker /*
2*e7c364b6SAndroid Build Coastguard Worker  * Copyright (C) 2019 The Android Open Source Project
3*e7c364b6SAndroid Build Coastguard Worker  *
4*e7c364b6SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*e7c364b6SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*e7c364b6SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*e7c364b6SAndroid Build Coastguard Worker  *
8*e7c364b6SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*e7c364b6SAndroid Build Coastguard Worker  *
10*e7c364b6SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*e7c364b6SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*e7c364b6SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*e7c364b6SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*e7c364b6SAndroid Build Coastguard Worker  * limitations under the License.
15*e7c364b6SAndroid Build Coastguard Worker  */
16*e7c364b6SAndroid Build Coastguard Worker 
17*e7c364b6SAndroid Build Coastguard Worker #include "recovery_ui/stub_ui.h"
18*e7c364b6SAndroid Build Coastguard Worker 
19*e7c364b6SAndroid Build Coastguard Worker #include <android-base/logging.h>
20*e7c364b6SAndroid Build Coastguard Worker 
21*e7c364b6SAndroid Build Coastguard Worker #include "recovery_ui/device.h"
22*e7c364b6SAndroid Build Coastguard Worker 
ShowMenu(const std::vector<std::string> &,const std::vector<std::string> &,size_t,bool,const std::function<int (int,bool)> &)23*e7c364b6SAndroid Build Coastguard Worker size_t StubRecoveryUI::ShowMenu(const std::vector<std::string>& /* headers */,
24*e7c364b6SAndroid Build Coastguard Worker                                 const std::vector<std::string>& /* items */,
25*e7c364b6SAndroid Build Coastguard Worker                                 size_t /* initial_selection */, bool /* menu_only */,
26*e7c364b6SAndroid Build Coastguard Worker                                 const std::function<int(int, bool)>& /*key_handler*/) {
27*e7c364b6SAndroid Build Coastguard Worker   while (true) {
28*e7c364b6SAndroid Build Coastguard Worker     int key = WaitKey();
29*e7c364b6SAndroid Build Coastguard Worker     // Exit the loop in the case of interruption or time out.
30*e7c364b6SAndroid Build Coastguard Worker     if (key == static_cast<int>(KeyError::INTERRUPTED) ||
31*e7c364b6SAndroid Build Coastguard Worker         key == static_cast<int>(KeyError::TIMED_OUT)) {
32*e7c364b6SAndroid Build Coastguard Worker       return static_cast<size_t>(key);
33*e7c364b6SAndroid Build Coastguard Worker     }
34*e7c364b6SAndroid Build Coastguard Worker   }
35*e7c364b6SAndroid Build Coastguard Worker   LOG(FATAL) << "Unreachable key selected in ShowMenu of stub UI";
36*e7c364b6SAndroid Build Coastguard Worker }
37