• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "vsync_connection_stub.h"
17 #include <unistd.h>
18 #include "graphic_common.h"
19 
20 namespace OHOS {
21 namespace Rosen {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)22 int32_t VSyncConnectionStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
23     MessageParcel &reply, MessageOption &option)
24 {
25     auto remoteDescriptor = data.ReadInterfaceToken();
26     if (GetDescriptor() != remoteDescriptor) {
27         return ERR_INVALID_STATE;
28     }
29 
30     switch (code) {
31         case IVSYNC_CONNECTION_REQUEST_NEXT_VSYNC: {
32             RequestNextVSync();
33             break;
34         }
35         case IVSYNC_CONNECTION_GET_RECEIVE_FD: {
36             int32_t fd = -1;
37             int32_t ret = GetReceiveFd(fd);
38             if (ret != VSYNC_ERROR_OK) {
39                 // check add log
40                 return ret;
41             }
42             reply.WriteFileDescriptor(fd);
43             break;
44         }
45         case IVSYNC_CONNECTION_SET_RATE: {
46             int32_t rate = data.ReadInt32();
47             int32_t ret = SetVSyncRate(rate);
48             if (ret != VSYNC_ERROR_OK) {
49                 // check add log
50                 return ret;
51             }
52             break;
53         }
54         default: {
55             // check add log
56             return VSYNC_ERROR_INVALID_OPERATING;
57         }
58     }
59     return 0;
60 }
61 } // namespace Rosen
62 } // namespace OHOS
63