• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <general_test/running_info.h>
18 
19 #include <shared/macros.h>
20 #include <shared/send_message.h>
21 
22 using nanoapp_testing::sendFailureToHost;
23 
24 namespace general_test {
25 
queryByAppId()26 bool RunningInfo::queryByAppId() {
27   return mPlatformInfo.queryByAppId(&mRunningInfo);
28 }
29 
queryByInstanceId()30 bool RunningInfo::queryByInstanceId() {
31   return mPlatformInfo.queryByInstanceId(&mRunningInfo);
32 }
33 
validate(uint32_t appVersion)34 bool RunningInfo::validate(uint32_t appVersion) {
35   bool result;
36   if (mRunningInfo.version != appVersion) {
37     sendFailureToHost("Running info version does not match app version");
38     result = false;
39   } else if (mRunningInfo.appId != NANOAPP_ID) {
40     sendFailureToHost("Running info appId does not match build constant");
41     result = false;
42   } else if (mRunningInfo.version != NANOAPP_VERSION) {
43     sendFailureToHost("Running info version does not match build constant");
44     result = false;
45   } else {
46     result =
47         mPlatformInfo.validate(mRunningInfo.appId, mRunningInfo.instanceId);
48   }
49 
50   return result;
51 }
52 
53 }  // namespace general_test
54