Tianjie Xu | 09a8f76 | 2019-06-27 15:01:55 -0700 | [diff] [blame] | 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 | |
| 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 */, |
Tom Marshall | 292bd23 | 2019-01-04 14:37:31 -0800 | [diff] [blame] | 26 | const std::function<int(int, bool)>& /*key_handler*/, |
| 27 | bool /* refreshable */) { |
Tianjie Xu | 09a8f76 | 2019-06-27 15:01:55 -0700 | [diff] [blame] | 28 | while (true) { |
Tianjie Xu | 09a8f76 | 2019-06-27 15:01:55 -0700 | [diff] [blame] | 29 | // Exit the loop in the case of interruption or time out. |
Tom Marshall | 85f19a5 | 2020-03-10 20:17:49 +0100 | [diff] [blame] | 30 | 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 Xu | 09a8f76 | 2019-06-27 15:01:55 -0700 | [diff] [blame] | 35 | } |
| 36 | } |
| 37 | LOG(FATAL) << "Unreachable key selected in ShowMenu of stub UI"; |
| 38 | } |