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_proxy.h"
17 #include "camera_log.h"
18 #include "camera_service_ipc_interface_code.h"
19
20 namespace OHOS {
21 namespace CameraStandard {
HCameraServiceCallbackProxy(const sptr<IRemoteObject> & impl)22 HCameraServiceCallbackProxy::HCameraServiceCallbackProxy(const sptr<IRemoteObject> &impl)
23 : IRemoteProxy<ICameraServiceCallback>(impl) { }
24
OnCameraStatusChanged(const std::string & cameraId,const CameraStatus status,const std::string & bundleName)25 int32_t HCameraServiceCallbackProxy::OnCameraStatusChanged(const std::string& cameraId, const CameraStatus status,
26 const std::string& bundleName)
27 {
28 MessageParcel data;
29 MessageParcel reply;
30 MessageOption option;
31 option.SetFlags(option.TF_ASYNC);
32
33 data.WriteInterfaceToken(GetDescriptor());
34 data.WriteString(cameraId);
35 data.WriteInt32(status);
36 data.WriteString(bundleName);
37
38 int error = Remote()->SendRequest(
39 static_cast<uint32_t>(CameraServiceCallbackInterfaceCode::CAMERA_CALLBACK_STATUS_CHANGED),
40 data, reply, option);
41 CHECK_ERROR_PRINT_LOG(error != ERR_NONE,
42 "HCameraServiceCallbackProxy OnCameraStatusChanged failed, error: %{public}d", error);
43 return error;
44 }
45
OnFlashlightStatusChanged(const std::string & cameraId,const FlashStatus status)46 int32_t HCameraServiceCallbackProxy::OnFlashlightStatusChanged(const std::string& cameraId, const FlashStatus status)
47 {
48 MessageParcel data;
49 MessageParcel reply;
50 MessageOption option;
51 option.SetFlags(option.TF_ASYNC);
52 int error = ERR_NONE;
53
54 data.WriteInterfaceToken(GetDescriptor());
55 data.WriteString(cameraId);
56 data.WriteInt32(status);
57 error = Remote()->SendRequest(
58 static_cast<uint32_t>(CameraServiceCallbackInterfaceCode::CAMERA_CALLBACK_FLASHLIGHT_STATUS_CHANGED),
59 data, reply, option);
60 CHECK_ERROR_PRINT_LOG(error != ERR_NONE,
61 "HCameraServiceCallbackProxy OnFlashlightStatus failed, error: %{public}d", error);
62 return error;
63 }
64
HCameraMuteServiceCallbackProxy(const sptr<IRemoteObject> & impl)65 HCameraMuteServiceCallbackProxy::HCameraMuteServiceCallbackProxy(const sptr<IRemoteObject> &impl)
66 : IRemoteProxy<ICameraMuteServiceCallback>(impl) { }
67
OnCameraMute(bool muteMode)68 int32_t HCameraMuteServiceCallbackProxy::OnCameraMute(bool muteMode)
69 {
70 MessageParcel data;
71 MessageParcel reply;
72 MessageOption option;
73 option.SetFlags(option.TF_ASYNC);
74
75 data.WriteInterfaceToken(GetDescriptor());
76 data.WriteBool(muteMode);
77
78 int error = Remote()->SendRequest(
79 static_cast<uint32_t>(CameraMuteServiceCallbackInterfaceCode::CAMERA_CALLBACK_MUTE_MODE),
80 data, reply, option);
81 CHECK_ERROR_PRINT_LOG(error != ERR_NONE,
82 "HCameraServiceCallbackProxy OnCameraMute failed, error: %{public}d", error);
83 return error;
84 }
85
HTorchServiceCallbackProxy(const sptr<IRemoteObject> & impl)86 HTorchServiceCallbackProxy::HTorchServiceCallbackProxy(const sptr<IRemoteObject> &impl)
87 : IRemoteProxy<ITorchServiceCallback>(impl) { }
88
OnTorchStatusChange(const TorchStatus status)89 int32_t HTorchServiceCallbackProxy::OnTorchStatusChange(const TorchStatus status)
90 {
91 MessageParcel data;
92 MessageParcel reply;
93 MessageOption option;
94 option.SetFlags(option.TF_ASYNC);
95 int error = ERR_NONE;
96
97 data.WriteInterfaceToken(GetDescriptor());
98 data.WriteInt32(status);
99 error = Remote()->SendRequest(
100 static_cast<uint32_t>(TorchServiceCallbackInterfaceCode::TORCH_CALLBACK_TORCH_STATUS_CHANGE),
101 data, reply, option);
102 CHECK_ERROR_PRINT_LOG(error != ERR_NONE,
103 "HCameraServiceCallbackProxy OnTorchStatusChange failed, error: %{public}d", error);
104 return error;
105 }
106
HFoldServiceCallbackProxy(const sptr<IRemoteObject> & impl)107 HFoldServiceCallbackProxy::HFoldServiceCallbackProxy(const sptr<IRemoteObject> &impl)
108 : IRemoteProxy<IFoldServiceCallback>(impl) { }
109
OnFoldStatusChanged(const FoldStatus status)110 int32_t HFoldServiceCallbackProxy::OnFoldStatusChanged(const FoldStatus status)
111 {
112 MessageParcel data;
113 MessageParcel reply;
114 MessageOption option;
115 option.SetFlags(option.TF_ASYNC);
116 int error = ERR_NONE;
117
118 data.WriteInterfaceToken(GetDescriptor());
119 data.WriteInt32(status);
120 error = Remote()->SendRequest(
121 static_cast<uint32_t>(FoldServiceCallbackInterfaceCode::FOLD_CALLBACK_FOLD_STATUS_CHANGE),
122 data, reply, option);
123 CHECK_ERROR_PRINT_LOG(error != ERR_NONE,
124 "HCameraServiceCallbackProxy OnFoldStatusChanged failed, error: %{public}d", error);
125 return error;
126 }
127 } // namespace CameraStandard
128 } // namespace OHOS
129