1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "adapter/preview/external/ability/fa/fa_app_info.h"
17 
18 namespace OHOS::Ace {
Parse(const std::unique_ptr<JsonValue> & root)19 void FaAppInfo::Parse(const std::unique_ptr<JsonValue>& root)
20 {
21     if (!root) {
22         LOGW("The information of fa model application is empty.");
23         return;
24     }
25     auto apiVersion = root->GetValue("apiVersion");
26     if (apiVersion) {
27         minAPIVersion_ = apiVersion->GetUInt("compatible", 0);
28         apiReleaseType_ = apiVersion->GetString("releaseType");
29         targetAPIVersion_ = apiVersion->GetUInt("target", 0);
30     }
31 
32     bundleName_ = root->GetString("bundleName");
33     vendor_ = root->GetString("vendor");
34 
35     auto versionInfo = root->GetValue("version");
36     if (versionInfo) {
37         versionCode_ = versionInfo->GetUInt("code", 0);
38         versionName_ = versionInfo->GetString("name");
39     }
40 }
41 
GetMinAPIVersion() const42 uint32_t FaAppInfo::GetMinAPIVersion() const
43 {
44     return minAPIVersion_;
45 }
46 
GetApiReleaseType() const47 const std::string& FaAppInfo::GetApiReleaseType() const
48 {
49     return apiReleaseType_;
50 }
51 
GetTargetAPIVersion() const52 uint32_t FaAppInfo::GetTargetAPIVersion() const
53 {
54     return targetAPIVersion_;
55 }
56 
GetBundleName() const57 const std::string& FaAppInfo::GetBundleName() const
58 {
59     return bundleName_;
60 }
61 
GetVendor() const62 const std::string& FaAppInfo::GetVendor() const
63 {
64     return vendor_;
65 }
66 
GetVersionCode() const67 uint32_t FaAppInfo::GetVersionCode() const
68 {
69     return versionCode_;
70 }
71 
GetVersionName() const72 const std::string& FaAppInfo::GetVersionName() const
73 {
74     return versionName_;
75 }
76 } // namespace OHOS::Ace
77