1 /*
2 * Copyright (c) 2024 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_device_screen_config.h"
17 #include "js_screen_utils.h"
18 #include "window_manager_hilog.h"
19
20 namespace OHOS::Rosen {
21 using namespace AbilityRuntime;
22
CreateDeviceScreenConfig(napi_env env,const DeviceScreenConfig & config)23 napi_value JsDeviceScreenConfig::CreateDeviceScreenConfig(napi_env env, const DeviceScreenConfig& config)
24 {
25 TLOGI(WmsLogTag::DMS, "DeviceScreenConfig rotationPolicy:%{public}s, defaultRotationPolicy:%{public}s.",
26 config.rotationPolicy_.c_str(), config.defaultRotationPolicy_.c_str());
27 napi_value objValue = nullptr;
28 napi_create_object(env, &objValue);
29 if (objValue == nullptr) {
30 TLOGE(WmsLogTag::DMS, "[NAPI]Object is null!");
31 return NapiGetUndefined(env);
32 }
33 napi_set_named_property(env, objValue, "rotationPolicy", CreateJsValue(env, config.rotationPolicy_));
34 napi_set_named_property(env, objValue, "defaultRotationPolicy", CreateJsValue(env, config.defaultRotationPolicy_));
35 napi_set_named_property(env, objValue, "isRightPowerButton", CreateJsValue(env, config.isRightPowerButton_));
36 return objValue;
37 }
38
JsDeviceScreenConfig()39 JsDeviceScreenConfig::JsDeviceScreenConfig()
40 {
41 TLOGD(WmsLogTag::DMS, "Construct JsDeviceScreenConfig");
42 }
43
~JsDeviceScreenConfig()44 JsDeviceScreenConfig::~JsDeviceScreenConfig()
45 {
46 TLOGD(WmsLogTag::DMS, "Destroy JsDeviceScreenConfig");
47 }
48
49 } // namespace OHOS::Rosen
50