Alistair Strachan | 10c509c | 2018-11-20 18:09:27 -0800 | [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 | |
xunchang | 73c3b39 | 2019-03-20 10:47:41 -0700 | [diff] [blame] | 17 | #include <recovery_ui/device.h> |
| 18 | #include <recovery_ui/screen_ui.h> |
Alistair Strachan | 10c509c | 2018-11-20 18:09:27 -0800 | [diff] [blame] | 19 | |
| 20 | namespace android { |
| 21 | namespace device { |
| 22 | namespace linaro { |
| 23 | namespace hikey { |
| 24 | |
| 25 | class HikeyUI : public ::ScreenRecoveryUI |
| 26 | { |
| 27 | RecoveryUI::KeyAction CheckKey(int key, bool is_long_press) { |
| 28 | // Recovery core can't tolerate using KEY_POWER as an alias for |
| 29 | // KEY_DOWN, and a reboot is always triggered. Remap any power |
| 30 | // key press to KEY_DOWN to allow us to use the power key as |
| 31 | // a regular key. |
| 32 | if (key == KEY_POWER && !is_long_press) { |
| 33 | RecoveryUI::EnqueueKey(KEY_DOWN); |
| 34 | return RecoveryUI::IGNORE; |
| 35 | } |
| 36 | |
| 37 | return RecoveryUI::CheckKey(key, is_long_press); |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | } // namespace hikey |
| 42 | } // namespace linaro |
| 43 | } // namespace device |
| 44 | } // namespace android |
| 45 | |
| 46 | Device *make_device() |
| 47 | { |
| 48 | return new Device(new ::android::device::linaro::hikey::HikeyUI()); |
| 49 | } |