1 /*
2 * Copyright (c) 2021-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 "hcamera_service_callback_stub.h"
17 #include "camera_log.h"
18 #include "camera_service_ipc_interface_code.h"
19
20 namespace OHOS {
21 namespace CameraStandard {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)22 int HCameraServiceCallbackStub::OnRemoteRequest(
23 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
24 {
25 int errCode = -1;
26
27 if (data.ReadInterfaceToken() != GetDescriptor()) {
28 return errCode;
29 }
30 switch (code) {
31 case CAMERA_CALLBACK_STATUS_CHANGED:
32 errCode = HCameraServiceCallbackStub::HandleOnCameraStatusChanged(data);
33 break;
34
35 case CAMERA_CALLBACK_FLASHLIGHT_STATUS_CHANGED:
36 errCode = HCameraServiceCallbackStub::HandleOnFlashlightStatusChanged(data);
37 break;
38
39 default:
40 MEDIA_ERR_LOG("HCameraServiceCallbackStub request code %{public}u not handled", code);
41 errCode = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
42 break;
43 }
44
45 return errCode;
46 }
47
HandleOnCameraStatusChanged(MessageParcel & data)48 int HCameraServiceCallbackStub::HandleOnCameraStatusChanged(MessageParcel& data)
49 {
50 std::string cameraId = data.ReadString();
51 int32_t status = data.ReadInt32();
52 MEDIA_INFO_LOG("HCameraServiceCallbackStub::HandleOnCameraStatusChanged called, cameraId = %{public}s, "
53 "status = %{public}d", cameraId.c_str(), status);
54 return OnCameraStatusChanged(cameraId, (CameraStatus)status);
55 }
56
HandleOnFlashlightStatusChanged(MessageParcel & data)57 int HCameraServiceCallbackStub::HandleOnFlashlightStatusChanged(MessageParcel& data)
58 {
59 std::string cameraId = data.ReadString();
60 int32_t status = data.ReadInt32();
61
62 return OnFlashlightStatusChanged(cameraId, (FlashStatus)status);
63 }
64
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)65 int HCameraMuteServiceCallbackStub::OnRemoteRequest(
66 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
67 {
68 int errCode = -1;
69
70 if (data.ReadInterfaceToken() != GetDescriptor()) {
71 return errCode;
72 }
73 switch (code) {
74 case static_cast<uint32_t>(CameraMuteServiceCallbackInterfaceCode::CAMERA_CALLBACK_MUTE_MODE):
75 errCode = HCameraMuteServiceCallbackStub::HandleOnCameraMute(data);
76 break;
77 default:
78 MEDIA_ERR_LOG("HCameraMuteServiceCallbackStub request code %{public}u not handled", code);
79 errCode = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
80 break;
81 }
82
83 return errCode;
84 }
85
HandleOnCameraMute(MessageParcel & data)86 int HCameraMuteServiceCallbackStub::HandleOnCameraMute(MessageParcel& data)
87 {
88 bool muteMode = data.ReadBool();
89
90 return OnCameraMute(muteMode);
91 }
92 } // namespace CameraStandard
93 } // namespace OHOS
94