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 "camera_host_callback_stub.h"
17 #include <hdf_log.h>
18 #include <hdf_base.h>
19 #include <hdf_sbuf_ipc.h>
20 #include "camera_host_callback.h"
21 #include "cmd_common.h"
22
23 namespace OHOS::Camera {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)24 int32_t CameraHostCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
25 MessageOption &option)
26 {
27 HDF_LOGE("%s: CameraHostCallbackStub::OnRemoteRequest entry!", __func__);
28 switch (code) {
29 case CMD_CAMERA_HOST_CALLBACK_ON_STATUS: {
30 if (data.ReadInterfaceToken() != CameraHostCallbackStub::GetDescriptor()) {
31 HDF_LOGE("%{public}s: invalid interface descriptor.", __func__);
32 return INVALID_ARGUMENT;
33 }
34
35 std::string cameraId = data.ReadString();
36 CameraStatus status = static_cast<CameraStatus>(data.ReadInt32());
37 OnCameraStatus(cameraId, status);
38 break;
39 }
40 case CMD_CAMERA_HOST_CALLBACK_ON_FLASHLIGHT_STATUS: {
41 if (data.ReadInterfaceToken() != CameraHostCallbackStub::GetDescriptor()) {
42 HDF_LOGE("%{public}s: invalid interface descriptor.", __func__);
43 return INVALID_ARGUMENT;
44 }
45
46 std::string cameraId = data.ReadString();
47 FlashlightStatus status = static_cast<FlashlightStatus>(data.ReadInt32());
48 OnFlashlightStatus(cameraId, status);
49 break;
50 }
51 case CMD_CAMERA_HOST_CALLBACK_ON_CAMERA_EVENT: {
52 if (data.ReadInterfaceToken() != CameraHostCallbackStub::GetDescriptor()) {
53 HDF_LOGE("%{public}s: invalid interface descriptor.", __func__);
54 return INVALID_ARGUMENT;
55 }
56
57 std::string cameraId = data.ReadString();
58 CameraEvent event = static_cast<CameraEvent>(data.ReadInt32());
59 OnCameraEvent(cameraId, event);
60 break;
61 }
62 default: {
63 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
64 }
65 }
66 return 0;
67 }
68 }
69