Damien Bargiacchi | 565ba02 | 2016-08-11 15:29:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | #ifndef HEALTHD_ANIMATION_H |
| 18 | #define HEALTHD_ANIMATION_H |
| 19 | |
| 20 | #include <inttypes.h> |
Yifan Hong | abda715 | 2020-08-05 16:15:15 -0700 | [diff] [blame] | 21 | |
Damien Bargiacchi | 565ba02 | 2016-08-11 15:29:50 -0700 | [diff] [blame] | 22 | #include <string> |
| 23 | |
Tao Bao | 777af95 | 2018-10-22 12:34:22 -0700 | [diff] [blame] | 24 | class GRSurface; |
Damien Bargiacchi | 565ba02 | 2016-08-11 15:29:50 -0700 | [diff] [blame] | 25 | struct GRFont; |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | #define CENTER_VAL INT_MAX |
| 30 | |
| 31 | struct animation { |
| 32 | struct frame { |
| 33 | int disp_time; |
| 34 | int min_level; |
| 35 | int max_level; |
| 36 | |
| 37 | GRSurface* surface; |
| 38 | }; |
| 39 | |
| 40 | struct text_field { |
| 41 | std::string font_file; |
| 42 | int pos_x; |
| 43 | int pos_y; |
| 44 | int color_r; |
| 45 | int color_g; |
| 46 | int color_b; |
| 47 | int color_a; |
| 48 | |
| 49 | GRFont* font; |
| 50 | }; |
| 51 | |
Yifan Hong | 082d295 | 2019-01-28 12:55:54 -0800 | [diff] [blame] | 52 | // When libminui loads PNG images: |
| 53 | // - When treating paths as relative paths, it adds ".png" suffix. |
| 54 | // - When treating paths as absolute paths, it doesn't add the suffix. Hence, the suffix |
| 55 | // is added here. |
Yifan Hong | abda715 | 2020-08-05 16:15:15 -0700 | [diff] [blame] | 56 | // If |backup_root| is provided, additionally check if file under |root| is accessbile or not. |
| 57 | // If not accessbile, use |backup_root| instead. |
| 58 | // Require that |root| starts and ends with "/". If |backup_root| is provided, require that |
| 59 | // |backup_root| starts and ends with "/". |
| 60 | void set_resource_root(const std::string& root, const std::string& backup_root = ""); |
Yifan Hong | 082d295 | 2019-01-28 12:55:54 -0800 | [diff] [blame] | 61 | |
Damien Bargiacchi | 565ba02 | 2016-08-11 15:29:50 -0700 | [diff] [blame] | 62 | std::string animation_file; |
| 63 | std::string fail_file; |
| 64 | |
| 65 | text_field text_clock; |
| 66 | text_field text_percent; |
| 67 | |
| 68 | bool run; |
| 69 | |
Yifan Hong | 7dcf7b0 | 2019-10-08 17:27:11 -0700 | [diff] [blame] | 70 | frame* frames = nullptr; |
Damien Bargiacchi | 565ba02 | 2016-08-11 15:29:50 -0700 | [diff] [blame] | 71 | int cur_frame; |
| 72 | int num_frames; |
| 73 | int first_frame_repeats; // Number of times to repeat the first frame in the current cycle |
| 74 | |
| 75 | int cur_cycle; |
| 76 | int num_cycles; // Number of cycles to complete before blanking the screen |
| 77 | |
| 78 | int cur_level; // current battery level being animated (0-100) |
| 79 | int cur_status; // current battery status - see BatteryService.h for BATTERY_STATUS_* |
Yifan Hong | 7dcf7b0 | 2019-10-08 17:27:11 -0700 | [diff] [blame] | 80 | |
| 81 | ~animation() { delete frames; } |
Damien Bargiacchi | 565ba02 | 2016-08-11 15:29:50 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | } |
| 85 | |
| 86 | #endif // HEALTHD_ANIMATION_H |