blob: cabbd5f23fa10bf44e6048dfba44659566f7c59a [file] [log] [blame]
Tianjie Xu09a8f762019-06-27 15:01:55 -07001/*
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
23size_t StubRecoveryUI::ShowMenu(const std::vector<std::string>& /* headers */,
24 const std::vector<std::string>& /* items */,
25 size_t /* initial_selection */, bool /* menu_only */,
Tom Marshall292bd232019-01-04 14:37:31 -080026 const std::function<int(int, bool)>& /*key_handler*/,
27 bool /* refreshable */) {
Tianjie Xu09a8f762019-06-27 15:01:55 -070028 while (true) {
Tianjie Xu09a8f762019-06-27 15:01:55 -070029 // Exit the loop in the case of interruption or time out.
Tom Marshall85f19a52020-03-10 20:17:49 +010030 InputEvent evt = WaitInputEvent();
31 if (evt.type() == EventType::EXTRA) {
32 if (evt.key() == static_cast<int>(KeyError::INTERRUPTED) ||
33 evt.key() == static_cast<int>(KeyError::TIMED_OUT))
34 return static_cast<size_t>(evt.key());
Tianjie Xu09a8f762019-06-27 15:01:55 -070035 }
36 }
37 LOG(FATAL) << "Unreachable key selected in ShowMenu of stub UI";
38}