Ed Coyne | 7464ac9 | 2017-06-08 12:26:48 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 _BOOTANIMATION_BOOTACTION_H |
| 18 | #define _BOOTANIMATION_BOOTACTION_H |
| 19 | |
| 20 | #include <string> |
David Pursell | 54a8fe4 | 2017-09-29 16:05:26 -0700 | [diff] [blame] | 21 | #include <vector> |
Ed Coyne | 7464ac9 | 2017-06-08 12:26:48 -0700 | [diff] [blame] | 22 | |
Mickey Keeley | 47d2c02 | 2018-04-30 11:39:30 -0700 | [diff] [blame] | 23 | #include "BootParameters.h" |
| 24 | |
David Pursell | 1ecfdbd | 2017-09-27 14:15:21 -0700 | [diff] [blame] | 25 | #include <boot_action/boot_action.h> // libandroidthings native API. |
Ed Coyne | 7464ac9 | 2017-06-08 12:26:48 -0700 | [diff] [blame] | 26 | #include <utils/RefBase.h> |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | class BootAction : public RefBase { |
| 31 | public: |
| 32 | ~BootAction(); |
Ed Coyne | 428ed51 | 2017-08-14 15:10:06 -0700 | [diff] [blame] | 33 | |
| 34 | // libraryPath is a fully qualified path to the target .so library. |
David Pursell | 54a8fe4 | 2017-09-29 16:05:26 -0700 | [diff] [blame] | 35 | bool init(const std::string& libraryPath, |
Mickey Keeley | 47d2c02 | 2018-04-30 11:39:30 -0700 | [diff] [blame] | 36 | const std::unique_ptr<BootParameters>& bootParameters); |
Ed Coyne | 7464ac9 | 2017-06-08 12:26:48 -0700 | [diff] [blame] | 37 | |
| 38 | // The animation is going to start playing partNumber for the playCount'th |
| 39 | // time, update the action as needed. |
| 40 | // This is run in the same thread as the boot animation, |
| 41 | // you must not block here. |
| 42 | void startPart(int partNumber, int playCount); |
| 43 | |
| 44 | // Shutdown the boot action, this will be called shortly before the |
| 45 | // process is shut down to allow time for cleanup. |
| 46 | void shutdown(); |
| 47 | |
| 48 | private: |
David Pursell | 1ecfdbd | 2017-09-27 14:15:21 -0700 | [diff] [blame] | 49 | typedef bool (*libInit)(const ABootActionParameter* parameters, |
Mickey Keeley | 47d2c02 | 2018-04-30 11:39:30 -0700 | [diff] [blame] | 50 | size_t numParameters); |
Ed Coyne | 7464ac9 | 2017-06-08 12:26:48 -0700 | [diff] [blame] | 51 | typedef void (*libStartPart)(int partNumber, int playNumber); |
| 52 | typedef void (*libShutdown)(); |
| 53 | |
Ed Coyne | 7464ac9 | 2017-06-08 12:26:48 -0700 | [diff] [blame] | 54 | bool loadSymbol(const char* symbol, void** loaded); |
Ed Coyne | 7464ac9 | 2017-06-08 12:26:48 -0700 | [diff] [blame] | 55 | |
| 56 | void* mLibHandle = nullptr; |
| 57 | libInit mLibInit = nullptr; |
| 58 | libStartPart mLibStartPart = nullptr; |
| 59 | libShutdown mLibShutdown = nullptr; |
Mickey Keeley | 47d2c02 | 2018-04-30 11:39:30 -0700 | [diff] [blame] | 60 | |
| 61 | // Called only if the boot is silent. |
| 62 | libInit mLibSilentBoot = nullptr; |
Ed Coyne | 7464ac9 | 2017-06-08 12:26:48 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | } // namespace android |
| 66 | |
| 67 | |
| 68 | #endif // _BOOTANIMATION_BOOTACTION_H |