1 /*
2  * Copyright (C) 2019 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 "recovery_ui/stub_ui.h"
18 
19 #include <android-base/logging.h>
20 
21 #include "recovery_ui/device.h"
22 
ShowMenu(const std::vector<std::string> &,const std::vector<std::string> &,size_t,bool,const std::function<int (int,bool)> &)23 size_t StubRecoveryUI::ShowMenu(const std::vector<std::string>& /* headers */,
24                                 const std::vector<std::string>& /* items */,
25                                 size_t /* initial_selection */, bool /* menu_only */,
26                                 const std::function<int(int, bool)>& /*key_handler*/) {
27   while (true) {
28     int key = WaitKey();
29     // Exit the loop in the case of interruption or time out.
30     if (key == static_cast<int>(KeyError::INTERRUPTED) ||
31         key == static_cast<int>(KeyError::TIMED_OUT)) {
32       return static_cast<size_t>(key);
33     }
34   }
35   LOG(FATAL) << "Unreachable key selected in ShowMenu of stub UI";
36 }
37