• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 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 "boomerang_callback_proxy.h"
17 
18 #include <message_parcel.h>
19 
20 #include "iremote_object.h"
21 #include "message_option.h"
22 
23 #include "boomerang_client.h"
24 #include "devicestatus_common.h"
25 #include "devicestatus_define.h"
26 
27 #undef LOG_TAG
28 #define LOG_TAG "BoomerangCallbackProxy"
29 
30 namespace OHOS {
31 namespace Msdp {
32 namespace DeviceStatus {
33 
OnScreenshotResult(const BoomerangData & screentshotData)34 void BoomerangCallbackProxy::OnScreenshotResult(const BoomerangData& screentshotData)
35 {
36     sptr<IRemoteObject> remote = Remote();
37     CHKPV(remote);
38     MessageParcel data;
39     MessageParcel reply;
40     MessageOption option;
41 
42     if (!data.WriteInterfaceToken(BoomerangCallbackProxy::GetDescriptor())) {
43         FI_HILOGE("Write descriptor failed");
44         return;
45     }
46     WRITEINT32(data, static_cast<int32_t>(screentshotData.type));
47     WRITEINT32(data, static_cast<int32_t>(screentshotData.status));
48 
49     int32_t ret = remote->SendRequest(static_cast<int32_t>(IRemoteBoomerangCallback::SCREENSHOT),
50         data, reply, option);
51     if (ret != RET_OK) {
52         FI_HILOGE("SendRequest is failed, error code:%{public}d", ret);
53         return;
54     }
55 }
56 
OnEncodeImageResult(std::shared_ptr<Media::PixelMap> pixelMap)57 void BoomerangCallbackProxy::OnEncodeImageResult(std::shared_ptr<Media::PixelMap> pixelMap)
58 {
59     sptr<IRemoteObject> remote = Remote();
60     CHKPV(remote);
61     MessageParcel data;
62     MessageParcel reply;
63     MessageOption option;
64 
65     if (!data.WriteInterfaceToken(BoomerangCallbackProxy::GetDescriptor())) {
66         FI_HILOGE("Write descriptor failed");
67         return;
68     }
69     pixelMap->Marshalling(data);
70     int32_t ret = remote->SendRequest(static_cast<int32_t>(IRemoteBoomerangCallback::ENCODE_IMAGE),
71         data, reply, option);
72     if (ret != RET_OK) {
73         FI_HILOGE("SendRequest is failed, error code:%{public}d", ret);
74         return;
75     }
76 }
77 
OnNotifyMetadata(const std::string & metadata)78 void BoomerangCallbackProxy::OnNotifyMetadata(const std::string& metadata)
79 {
80     sptr<IRemoteObject> remote = Remote();
81     CHKPV(remote);
82     MessageParcel data;
83     MessageParcel reply;
84     MessageOption option;
85 
86     if (!data.WriteInterfaceToken(BoomerangCallbackProxy::GetDescriptor())) {
87         FI_HILOGE("Write descriptor failed");
88         return;
89     }
90     WRITESTRING(data, metadata);
91 
92     int32_t ret = remote->SendRequest(static_cast<int32_t>(IRemoteBoomerangCallback::NOTIFY_METADATA),
93         data, reply, option);
94     if (ret != RET_OK) {
95         FI_HILOGE("SendRequest is failed, error code:%{public}d", ret);
96         return;
97     }
98 }
99 } // namespace DeviceStatus
100 } // namespace Msdp
101 } // namespace OHOS
102