• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "js_application_quick_fix_info.h"
17 
18 #include "js_runtime_utils.h"
19 
20 namespace OHOS {
21 namespace AbilityRuntime {
CreateJsApplicationQuickFixInfo(NativeEngine & engine,const AAFwk::ApplicationQuickFixInfo & appQuickFixInfo)22 NativeValue *CreateJsApplicationQuickFixInfo(
23     NativeEngine &engine, const AAFwk::ApplicationQuickFixInfo &appQuickFixInfo)
24 {
25     NativeValue *objValue = engine.CreateObject();
26     NativeObject *object = ConvertNativeValueTo<NativeObject>(objValue);
27     object->SetProperty("bundleName", CreateJsValue(engine, appQuickFixInfo.bundleName));
28     object->SetProperty("bundleVersionCode", CreateJsValue(engine, appQuickFixInfo.bundleVersionCode));
29     object->SetProperty("bundleVersionName", CreateJsValue(engine, appQuickFixInfo.bundleVersionName));
30     object->SetProperty("quickFixVersionCode", CreateJsValue(engine, appQuickFixInfo.appqfInfo.versionCode));
31     object->SetProperty("quickFixVersionName", CreateJsValue(engine, appQuickFixInfo.appqfInfo.versionName));
32     object->SetProperty(
33         "hapModuleQuickFixInfo", CreateJsHapModuleQuickFixInfoArray(engine, appQuickFixInfo.appqfInfo.hqfInfos));
34     return objValue;
35 }
36 
CreateJsHapModuleQuickFixInfoArray(NativeEngine & engine,const std::vector<AppExecFwk::HqfInfo> & hqfInfos)37 NativeValue *CreateJsHapModuleQuickFixInfoArray(NativeEngine &engine, const std::vector<AppExecFwk::HqfInfo> &hqfInfos)
38 {
39     NativeValue *arrayValue = engine.CreateArray(hqfInfos.size());
40     NativeArray *array = ConvertNativeValueTo<NativeArray>(arrayValue);
41     uint32_t index = 0;
42     for (const auto &hqfInfo : hqfInfos) {
43         NativeValue *objValue = engine.CreateObject();
44         NativeObject *object = ConvertNativeValueTo<NativeObject>(objValue);
45         object->SetProperty("moduleName", CreateJsValue(engine, hqfInfo.moduleName));
46         object->SetProperty("originHapHash", CreateJsValue(engine, hqfInfo.hapSha256));
47         object->SetProperty("quickFixFilePath", CreateJsValue(engine, hqfInfo.hqfFilePath));
48         array->SetElement(index++, objValue);
49     }
50     return arrayValue;
51 }
52 } // namespace AbilityRuntime
53 } // namespace OHOS
54