1 /*
2 * Copyright (c) 2021 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 "napi_common_start_options.h"
17
18 #include "hilog_wrapper.h"
19 #include "napi_common_util.h"
20 #include "int_wrapper.h"
21
22 namespace OHOS {
23 namespace AppExecFwk {
24 EXTERN_C_START
25
UnwrapStartOptions(napi_env env,napi_value param,AAFwk::StartOptions & startOptions)26 bool UnwrapStartOptions(napi_env env, napi_value param, AAFwk::StartOptions &startOptions)
27 {
28 HILOG_INFO("%{public}s called.", __func__);
29
30 if (!IsTypeForNapiValue(env, param, napi_object)) {
31 HILOG_INFO("%{public}s called. Params is invalid.", __func__);
32 return false;
33 }
34
35 int32_t windowMode = 0;
36 if (UnwrapInt32ByPropertyName(env, param, "windowMode", windowMode)) {
37 startOptions.SetWindowMode(windowMode);
38 }
39
40 int32_t displayId = 0;
41 if (UnwrapInt32ByPropertyName(env, param, "displayId", displayId)) {
42 HILOG_INFO("get display id ok displayId %{public}d", displayId);
43 startOptions.SetDisplayID(displayId);
44 }
45
46 return true;
47 }
48 EXTERN_C_END
49 } // namespace AppExecFwk
50 } // namespace OHOS
51