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 "display_device_callback_stub.h"
17 
OnRemoteRequest(uint32_t code,OHOS::MessageParcel & data,OHOS::MessageParcel & reply,OHOS::MessageOption & option)18 int32_t DisplayDeviceCallbackStub::OnRemoteRequest(
19     uint32_t code, OHOS::MessageParcel &data, OHOS::MessageParcel &reply, OHOS::MessageOption &option)
20 {
21     DISPLAY_START;
22     DISPLAY_LOG("OnRemoteRequest receive code = %{public}u", code);
23     switch (code) {
24         case DSP_CMD_REGHOTPLUGCALLBACK: {
25             if (data.ReadInterfaceToken() != DisplayDeviceCallbackStub::GetDescriptor()) {
26                 return HDF_ERR_INVALID_PARAM;
27             }
28             uint32_t outputId = data.ReadInt32();
29             bool connected = data.ReadBool();
30             DISPLAY_LOG("call OnHotplugIn id : %{public}d; connected : %{public}d", outputId, connected);
31             OnHotplugIn(outputId, connected);
32             break;
33         }
34         case DSP_CMD_REGDISPLAYVBLANKCALLBACK: {
35             if (data.ReadInterfaceToken() != DisplayDeviceCallbackStub::GetDescriptor()) {
36                 return HDF_ERR_INVALID_PARAM;
37             }
38             unsigned int sequence = data.ReadUint32();
39             uint64_t ns = data.ReadUint64();
40             DISPLAY_LOG(" call VBlankCallback id : %{public}u connected", sequence);
41             OnVBlankCallback(sequence, ns);
42             break;
43         }
44         case DSP_CMD_REGDISPLAYREFRESHCALLBACK: {
45             if (data.ReadInterfaceToken() != DisplayDeviceCallbackStub::GetDescriptor()) {
46                 return HDF_ERR_INVALID_PARAM;
47             }
48             uint32_t devId = data.ReadUint32();
49             DISPLAY_LOG(" call VBlankCallback devId : %{public}d", devId);
50             OnRefreshCallback(devId);
51             break;
52         }
53         default:
54             break;
55     }
56     DISPLAY_END;
57     return 0;
58 }
59