blob: 5e2495fe6c51817714cb094287334e012b2d1ae5 [file] [log] [blame]
Ed Coyne7464ac92017-06-08 12:26:48 -07001/*
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 Pursell54a8fe42017-09-29 16:05:26 -070021#include <vector>
Ed Coyne7464ac92017-06-08 12:26:48 -070022
David Pursell1ecfdbd2017-09-27 14:15:21 -070023#include <boot_action/boot_action.h> // libandroidthings native API.
Ed Coyne7464ac92017-06-08 12:26:48 -070024#include <utils/RefBase.h>
25
26namespace android {
27
28class BootAction : public RefBase {
29public:
30 ~BootAction();
Ed Coyne428ed512017-08-14 15:10:06 -070031
32 // libraryPath is a fully qualified path to the target .so library.
David Pursell54a8fe42017-09-29 16:05:26 -070033 bool init(const std::string& libraryPath,
34 const std::vector<ABootActionParameter>& parameters);
Ed Coyne7464ac92017-06-08 12:26:48 -070035
36 // The animation is going to start playing partNumber for the playCount'th
37 // time, update the action as needed.
38 // This is run in the same thread as the boot animation,
39 // you must not block here.
40 void startPart(int partNumber, int playCount);
41
42 // Shutdown the boot action, this will be called shortly before the
43 // process is shut down to allow time for cleanup.
44 void shutdown();
45
46private:
David Pursell1ecfdbd2017-09-27 14:15:21 -070047 typedef bool (*libInit)(const ABootActionParameter* parameters,
48 size_t num_parameters);
Ed Coyne7464ac92017-06-08 12:26:48 -070049 typedef void (*libStartPart)(int partNumber, int playNumber);
50 typedef void (*libShutdown)();
51
Ed Coyne7464ac92017-06-08 12:26:48 -070052 bool loadSymbol(const char* symbol, void** loaded);
Ed Coyne7464ac92017-06-08 12:26:48 -070053
54 void* mLibHandle = nullptr;
55 libInit mLibInit = nullptr;
56 libStartPart mLibStartPart = nullptr;
57 libShutdown mLibShutdown = nullptr;
58};
59
60} // namespace android
61
62
63#endif // _BOOTANIMATION_BOOTACTION_H