1 /*
2 * Copyright (C) 2022 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 "chre/platform/platform_nanoapp.h"
18
19 #include "chre/platform/assert.h"
20
21 namespace chre {
22
~PlatformNanoapp()23 PlatformNanoapp::~PlatformNanoapp() {}
24
start()25 bool PlatformNanoapp::start() {
26 bool success = false;
27
28 if (mAppInfo != nullptr) {
29 success = mAppInfo->entryPoints.start();
30 }
31
32 return success;
33 }
34
handleEvent(uint32_t senderInstanceId,uint16_t eventType,const void * eventData)35 void PlatformNanoapp::handleEvent(uint32_t senderInstanceId, uint16_t eventType,
36 const void *eventData) {
37 mAppInfo->entryPoints.handleEvent(senderInstanceId, eventType, eventData);
38 }
39
end()40 void PlatformNanoapp::end() {
41 mAppInfo->entryPoints.end();
42 }
43
getAppId() const44 uint64_t PlatformNanoapp::getAppId() const {
45 return (mAppInfo != nullptr) ? mAppInfo->appId : mExpectedAppId;
46 }
47
getAppVersion() const48 uint32_t PlatformNanoapp::getAppVersion() const {
49 return (mAppInfo != nullptr) ? mAppInfo->appVersion : mExpectedAppVersion;
50 }
51
getTargetApiVersion() const52 uint32_t PlatformNanoapp::getTargetApiVersion() const {
53 return (mAppInfo != nullptr) ? mAppInfo->targetApiVersion
54 : mExpectedTargetApiVersion;
55 }
isSystemNanoapp() const56 bool PlatformNanoapp::isSystemNanoapp() const {
57 return (mAppInfo != nullptr && mAppInfo->isSystemNanoapp);
58 }
59
isLoaded() const60 bool PlatformNanoappBase::isLoaded() const {
61 return mIsStatic;
62 }
63
loadStatic(const struct chreNslNanoappInfo * appInfo)64 void PlatformNanoappBase::loadStatic(const struct chreNslNanoappInfo *appInfo) {
65 CHRE_ASSERT(!isLoaded());
66 mIsStatic = true;
67 mAppInfo = appInfo;
68 }
69
70 } // namespace chre
71