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 "display_power_callback_proxy.h"
17
18 #include "display_common.h"
19
20 namespace OHOS {
21 namespace DisplayPowerMgr {
OnDisplayStateChanged(uint32_t displayId,DisplayState state)22 void DisplayPowerCallbackProxy::OnDisplayStateChanged(uint32_t displayId, DisplayState state)
23 {
24 sptr<IRemoteObject> remote = Remote();
25 RETURN_IF(remote == nullptr);
26
27 MessageParcel data;
28 MessageParcel reply;
29 MessageOption option;
30
31 if (!data.WriteInterfaceToken(DisplayPowerCallbackProxy::GetDescriptor())) {
32 DISPLAY_HILOGE(MODULE_INNERKIT,
33 "DisplayPowerCallbackProxy::%{public}s write descriptor failed!", __func__);
34 return;
35 }
36
37 WRITE_PARCEL_NO_RET(data, Uint32, displayId);
38 WRITE_PARCEL_NO_RET(data, Uint32, static_cast<uint32_t>(state));
39
40 int ret = remote->SendRequest(static_cast<int>(IDisplayPowerCallback::ON_DISPLAY_STATE_CHANGED),
41 data, reply, option);
42 if (ret != ERR_OK) {
43 DISPLAY_HILOGE(MODULE_INNERKIT,
44 "PowerMgrProxy::%{public}s SendRequest is failed, error code: %d", __func__, ret);
45 return;
46 }
47
48 return;
49 }
50 } // namespace DisplayPowerMgr
51 } // namespace OHOS