1 /*
2 * Copyright (c) 2021-2023 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 "rs_render_service_connection_proxy.h"
17
18 #include <algorithm>
19 #include <cstdint>
20 #include <message_option.h>
21 #include <message_parcel.h>
22 #include <vector>
23 #include "platform/common/rs_log.h"
24 #include "platform/common/rs_system_properties.h"
25 #include "transaction/rs_ashmem_helper.h"
26 #include "transaction/rs_hrp_service.h"
27 #include "transaction/rs_marshalling_helper.h"
28 #include "rs_trace.h"
29
30 namespace OHOS {
31 namespace Rosen {
32 namespace {
33 static constexpr size_t ASHMEM_SIZE_THRESHOLD = 200 * 1024; // cannot > 500K in TF_ASYNC mode
34 static constexpr int MAX_RETRY_COUNT = 20;
35 static constexpr int RETRY_WAIT_TIME_US = 1000; // wait 1ms before retry SendRequest
36 static constexpr int MAX_SECURITY_EXEMPTION_LIST_NUMBER = 1024; // securityExemptionList size not exceed 1024
37 static constexpr uint32_t EDID_DATA_MAX_SIZE = 64 * 1024;
38 static constexpr int MAX_VOTER_SIZE = 100; // SetWindowExpectedRefreshRate map size not exceed 100
39 static constexpr int ZERO = 0; // empty map size
40 }
41
RSRenderServiceConnectionProxy(const sptr<IRemoteObject> & impl)42 RSRenderServiceConnectionProxy::RSRenderServiceConnectionProxy(const sptr<IRemoteObject>& impl)
43 : IRemoteProxy<RSIRenderServiceConnection>(impl)
44 {
45 }
46
CommitTransaction(std::unique_ptr<RSTransactionData> & transactionData)47 ErrCode RSRenderServiceConnectionProxy::CommitTransaction(std::unique_ptr<RSTransactionData>& transactionData)
48 {
49 if (!transactionData) {
50 ROSEN_LOGE("RSRenderServiceConnectionProxy::CommitTransaction transactionData nullptr!");
51 return ERR_INVALID_VALUE;
52 }
53 bool isUniMode = RSSystemProperties::GetUniRenderEnabled();
54 transactionData->SetSendingPid(pid_);
55
56 // split to several parcels if parcel size > PARCEL_SPLIT_THRESHOLD during marshalling
57 std::vector<std::shared_ptr<MessageParcel>> parcelVector;
58 auto func = [isUniMode, &parcelVector, &transactionData, this]() -> bool {
59 if (isUniMode) {
60 ++transactionDataIndex_;
61 }
62 transactionData->SetIndex(transactionDataIndex_);
63 std::shared_ptr<MessageParcel> parcel = std::make_shared<MessageParcel>();
64 if (!FillParcelWithTransactionData(transactionData, parcel)) {
65 ROSEN_LOGE("FillParcelWithTransactionData failed!");
66 return false;
67 }
68 parcelVector.emplace_back(parcel);
69 return true;
70 };
71 if (transactionData->IsNeedSync() && transactionData->IsEmpty()) {
72 RS_TRACE_NAME("Commit empty syncTransaction");
73 func();
74 } else {
75 while (transactionData->GetMarshallingIndex() < transactionData->GetCommandCount()) {
76 if (!func()) {
77 return ERR_INVALID_VALUE;
78 }
79 }
80 }
81
82 MessageOption option;
83 option.SetFlags(MessageOption::TF_ASYNC);
84 for (const auto& parcel : parcelVector) {
85 MessageParcel reply;
86 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::COMMIT_TRANSACTION);
87 int retryCount = 0;
88 int32_t err = NO_ERROR;
89 do {
90 err = SendRequest(code, *parcel, reply, option);
91 if (err != NO_ERROR && retryCount < MAX_RETRY_COUNT) {
92 retryCount++;
93 usleep(RETRY_WAIT_TIME_US);
94 } else if (err != NO_ERROR) {
95 ROSEN_LOGE("RSRenderServiceConnectionProxy::CommitTransaction SendRequest failed, "
96 "err = %{public}d, retryCount = %{public}d, data size:%{public}zu", err, retryCount,
97 parcel->GetDataSize());
98 return ERR_INVALID_VALUE;
99 }
100 } while (err != NO_ERROR);
101 }
102 return ERR_OK;
103 }
104
ExecuteSynchronousTask(const std::shared_ptr<RSSyncTask> & task)105 ErrCode RSRenderServiceConnectionProxy::ExecuteSynchronousTask(const std::shared_ptr<RSSyncTask>& task)
106 {
107 if (task == nullptr) {
108 return ERR_INVALID_VALUE;
109 }
110
111 MessageParcel data;
112 MessageParcel reply;
113 MessageOption option;
114 if (!data.WriteInterfaceToken(RSRenderServiceConnectionProxy::GetDescriptor())) {
115 ROSEN_LOGE("ExecuteSynchronousTask WriteInterfaceToken failed");
116 return ERR_INVALID_VALUE;
117 }
118 if (!task->Marshalling(data)) {
119 ROSEN_LOGE("ExecuteSynchronousTask Marshalling failed");
120 return ERR_INVALID_VALUE;
121 }
122 option.SetFlags(MessageOption::TF_SYNC);
123 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::EXECUTE_SYNCHRONOUS_TASK);
124 int32_t err = SendRequest(code, data, reply, option);
125 if (err != NO_ERROR) {
126 return ERR_INVALID_VALUE;
127 }
128
129 if (task->CheckHeader(reply)) {
130 task->ReadFromParcel(reply);
131 }
132 return ERR_OK;
133 }
134
FillParcelWithTransactionData(std::unique_ptr<RSTransactionData> & transactionData,std::shared_ptr<MessageParcel> & data)135 bool RSRenderServiceConnectionProxy::FillParcelWithTransactionData(
136 std::unique_ptr<RSTransactionData>& transactionData, std::shared_ptr<MessageParcel>& data)
137 {
138 // write a flag at the begin of parcel to identify parcel type
139 // 0: indicate normal parcel
140 // 1: indicate ashmem parcel
141 if (!data->WriteInt32(0)) {
142 ROSEN_LOGE("FillParcelWithTransactionData WriteInt32 failed");
143 return false;
144 }
145
146 if (!RSMarshallingHelper::MarshallingTransactionVer(*data)) {
147 ROSEN_LOGE("FillParcelWithTransactionData WriteVersionHeader failed!");
148 return false;
149 }
150
151 {
152 // 1. marshalling RSTransactionData
153 #ifdef RS_ENABLE_VK
154 RS_TRACE_NAME_FMT("MarshRSTransactionData cmdCount: %lu, transactionFlag:[%d,%" PRIu64 "], tid:%d, "
155 "timestamp:%ld", transactionData->GetCommandCount(), pid_, transactionData->GetIndex(),
156 transactionData->GetSendingTid(), transactionData->GetTimestamp());
157 #else
158 RS_TRACE_NAME_FMT("MarshRSTransactionData cmdCount: %lu, transactionFlag:[%d,%" PRIu64 "], timestamp:%ld",
159 transactionData->GetCommandCount(), pid_, transactionData->GetIndex(), transactionData->GetTimestamp());
160 #endif
161 ROSEN_LOGI_IF(DEBUG_PIPELINE,
162 "MarshRSTransactionData cmdCount:%{public}lu transactionFlag:[pid:%{public}d index:%{public}" PRIu64 "]",
163 transactionData->GetCommandCount(), pid_, transactionData->GetIndex());
164 bool success = data->WriteParcelable(transactionData.get());
165 if (!success) {
166 ROSEN_LOGE("FillParcelWithTransactionData data.WriteParcelable failed!");
167 return false;
168 }
169 }
170
171 // 2. convert data to new ashmem parcel if size over threshold
172 std::shared_ptr<MessageParcel> ashmemParcel = nullptr;
173 if (data->GetDataSize() > ASHMEM_SIZE_THRESHOLD) {
174 ashmemParcel = RSAshmemHelper::CreateAshmemParcel(data);
175 }
176 if (ashmemParcel != nullptr) {
177 data = ashmemParcel;
178 }
179 return true;
180 }
181
GetUniRenderEnabled(bool & enable)182 ErrCode RSRenderServiceConnectionProxy::GetUniRenderEnabled(bool& enable)
183 {
184 MessageParcel data;
185 MessageParcel reply;
186 MessageOption option;
187
188 option.SetFlags(MessageOption::TF_SYNC);
189 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_UNI_RENDER_ENABLED);
190 int32_t err = SendRequest(code, data, reply, option);
191 if (err != NO_ERROR) {
192 return false;
193 }
194 if (!reply.ReadBool(enable)) {
195 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetUniRenderEnabled Read enable failed!");
196 return ERR_INVALID_VALUE;
197 }
198 return ERR_OK;
199 }
200
CreateNode(const RSDisplayNodeConfig & displayNodeConfig,NodeId nodeId,bool & success)201 ErrCode RSRenderServiceConnectionProxy::CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId,
202 bool& success)
203 {
204 MessageParcel data;
205 MessageParcel reply;
206 MessageOption option;
207
208 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
209 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteInterfaceToken err.");
210 success = false;
211 return ERR_INVALID_VALUE;
212 }
213 if (!data.WriteUint64(nodeId)) {
214 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteUint64 NodeId err.");
215 success = false;
216 return ERR_INVALID_VALUE;
217 }
218 if (!data.WriteUint64(displayNodeConfig.mirrorNodeId)) {
219 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteUint64 Config.MirrorNodeId err.");
220 success = false;
221 return ERR_INVALID_VALUE;
222 }
223 if (!data.WriteUint64(displayNodeConfig.screenId)) {
224 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteUint64 Config.ScreenId err.");
225 success = false;
226 return ERR_INVALID_VALUE;
227 }
228 if (!data.WriteBool(displayNodeConfig.isMirrored)) {
229 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteBool Config.IsMirrored err.");
230 success = false;
231 return ERR_INVALID_VALUE;
232 }
233 option.SetFlags(MessageOption::TF_SYNC);
234 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_DISPLAY_NODE);
235 int32_t err = SendRequest(code, data, reply, option);
236 if (err != NO_ERROR) {
237 success = false;
238 return ERR_INVALID_VALUE;
239 }
240
241 if (!reply.ReadBool(success)) {
242 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode Read success failed!");
243 return ERR_INVALID_VALUE;
244 }
245 return ERR_OK;
246 }
247
CreateNode(const RSSurfaceRenderNodeConfig & config,bool & success)248 ErrCode RSRenderServiceConnectionProxy::CreateNode(const RSSurfaceRenderNodeConfig& config, bool& success)
249 {
250 MessageParcel data;
251 MessageParcel reply;
252 MessageOption option;
253
254 if (!data.WriteUint64(config.id)) {
255 ROSEN_LOGE("CreateNode: WriteUint64 Config.id err.");
256 success = false;
257 return ERR_INVALID_VALUE;
258 }
259 if (!data.WriteString(config.name)) {
260 ROSEN_LOGE("CreateNode: WriteString Config.name err.");
261 success = false;
262 return ERR_INVALID_VALUE;
263 }
264 option.SetFlags(MessageOption::TF_SYNC);
265 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_NODE);
266 int32_t err = SendRequest(code, data, reply, option);
267 if (err != NO_ERROR) {
268 success = false;
269 return ERR_INVALID_VALUE;
270 }
271
272 if (!reply.ReadBool(success)) {
273 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode Read success failed");
274 return ERR_INVALID_VALUE;
275 }
276 return ERR_OK;
277 }
278
CreateNodeAndSurface(const RSSurfaceRenderNodeConfig & config,sptr<Surface> & sfc,bool unobscured)279 ErrCode RSRenderServiceConnectionProxy::CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config,
280 sptr<Surface>& sfc, bool unobscured)
281 {
282 MessageParcel data;
283 MessageParcel reply;
284 MessageOption option;
285
286 if (!data.WriteUint64(config.id)) {
287 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteUint64 config.id err.");
288 return ERR_INVALID_VALUE;
289 }
290 if (!data.WriteString(config.name)) {
291 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteString config.name err.");
292 return ERR_INVALID_VALUE;
293 }
294 if (!data.WriteUint8(static_cast<uint8_t>(config.nodeType))) {
295 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteUint8 config.nodeType err.");
296 return ERR_INVALID_VALUE;
297 }
298 if (!data.WriteBool(config.isTextureExportNode)) {
299 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteBool config.isTextureExportNode err.");
300 return ERR_INVALID_VALUE;
301 }
302 if (!data.WriteBool(config.isSync)) {
303 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteBool config.isSync err.");
304 return ERR_INVALID_VALUE;
305 }
306 if (!data.WriteUint8(static_cast<uint8_t>(config.surfaceWindowType))) {
307 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteUint8 config.surfaceWindowType err.");
308 return ERR_INVALID_VALUE;
309 }
310 if (!data.WriteBool(unobscured)) {
311 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteBool unobscured err.");
312 return ERR_INVALID_VALUE;
313 }
314 option.SetFlags(MessageOption::TF_SYNC);
315 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_NODE_AND_SURFACE);
316 int32_t err = SendRequest(code, data, reply, option);
317 if (err != NO_ERROR) {
318 return ERR_INVALID_VALUE;
319 }
320 sptr<IRemoteObject> surfaceObject = reply.ReadRemoteObject();
321 sptr<IBufferProducer> bp = iface_cast<IBufferProducer>(surfaceObject);
322 if (bp == nullptr) {
323 return ERR_INVALID_VALUE;
324 }
325 sfc = Surface::CreateSurfaceAsProducer(bp);
326 return ERR_OK;
327 }
328
CreateVSyncConnection(sptr<IVSyncConnection> & vsyncConn,const std::string & name,const sptr<VSyncIConnectionToken> & token,VSyncConnParam vsyncConnParam)329 ErrCode RSRenderServiceConnectionProxy::CreateVSyncConnection(sptr<IVSyncConnection>& vsyncConn,
330 const std::string& name,
331 const sptr<VSyncIConnectionToken>& token,
332 VSyncConnParam vsyncConnParam)
333 {
334 if (token == nullptr) {
335 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateVSyncConnection: token is nullptr.");
336 vsyncConn = nullptr;
337 return ERR_INVALID_VALUE;
338 }
339 MessageParcel data;
340 MessageParcel reply;
341 MessageOption option;
342
343 if (!data.WriteString(name)) {
344 ROSEN_LOGE("CreateVSyncConnection: WriteString name err.");
345 vsyncConn = nullptr;
346 return ERR_INVALID_VALUE;
347 }
348 if (!data.WriteRemoteObject(token->AsObject())) {
349 ROSEN_LOGE("CreateVSyncConnection: WriteRemoteObject token->AsObject() err.");
350 vsyncConn = nullptr;
351 return ERR_INVALID_VALUE;
352 }
353 if (!data.WriteUint64(vsyncConnParam.id)) {
354 ROSEN_LOGE("CreateVSyncConnection: WriteUint64 id err.");
355 vsyncConn = nullptr;
356 return ERR_INVALID_VALUE;
357 }
358 if (!data.WriteUint64(vsyncConnParam.windowNodeId)) {
359 ROSEN_LOGE("CreateVSyncConnection: WriteUint64 windowNodeId err.");
360 vsyncConn = nullptr;
361 return ERR_INVALID_VALUE;
362 }
363 option.SetFlags(MessageOption::TF_SYNC);
364 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_VSYNC_CONNECTION);
365 if (!Remote()) {
366 vsyncConn = nullptr;
367 return ERR_INVALID_VALUE;
368 }
369 int32_t err = SendRequest(code, data, reply, option);
370 if (err != NO_ERROR) {
371 vsyncConn = nullptr;
372 return ERR_INVALID_VALUE;
373 }
374
375 sptr<IRemoteObject> rObj = reply.ReadRemoteObject();
376 if (rObj == nullptr) {
377 vsyncConn = nullptr;
378 return ERR_INVALID_VALUE;
379 }
380 vsyncConn = iface_cast<IVSyncConnection>(rObj);
381 return ERR_OK;
382 }
383
GetPixelMapByProcessId(std::vector<PixelMapInfo> & pixelMapInfoVector,pid_t pid,int32_t & repCode)384 ErrCode RSRenderServiceConnectionProxy::GetPixelMapByProcessId(
385 std::vector<PixelMapInfo>& pixelMapInfoVector, pid_t pid, int32_t& repCode)
386 {
387 MessageParcel data;
388 MessageParcel reply;
389 MessageOption option;
390 if (!data.WriteUint64(pid)) {
391 ROSEN_LOGE("GetPixelMapByProcessId: WriteUint64 pid err.");
392 repCode = WRITE_PARCEL_ERR;
393 return ERR_INVALID_VALUE;
394 }
395 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_PIXELMAP_BY_PROCESSID);
396 int32_t err = SendRequest(code, data, reply, option);
397 if (err != NO_ERROR) {
398 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetPixelMapByProcessId: Send Request err");
399 repCode = RS_CONNECTION_ERROR;
400 return ERR_INVALID_VALUE;
401 }
402 if (!reply.ReadInt32(repCode)) {
403 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetPixelMapByProcessId Read repCode failed");
404 return ERR_INVALID_VALUE;
405 }
406 if (repCode == SUCCESS) {
407 pixelMapInfoVector.clear();
408 if (!RSMarshallingHelper::Unmarshalling(reply, pixelMapInfoVector)) {
409 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetPixelMapByProcessId: Unmarshalling failed");
410 }
411 } else {
412 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetPixelMapByProcessId: Invalid reply");
413 }
414 return ERR_OK;
415 }
416
CreatePixelMapFromSurface(sptr<Surface> surface,const Rect & srcRect,std::shared_ptr<Media::PixelMap> & pixelMap)417 ErrCode RSRenderServiceConnectionProxy::CreatePixelMapFromSurface(sptr<Surface> surface,
418 const Rect &srcRect, std::shared_ptr<Media::PixelMap> &pixelMap)
419 {
420 MessageParcel data;
421 MessageParcel reply;
422 MessageOption option;
423 if (surface == nullptr) {
424 return ERR_INVALID_VALUE;
425 }
426
427 auto producer = surface->GetProducer();
428 if (producer == nullptr) {
429 return ERR_INVALID_VALUE;
430 }
431
432 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
433 ROSEN_LOGE("CreatePixelMapFromSurface: WriteInterfaceToken RSIRenderServiceConnection::GetDescriptor() err.");
434 return ERR_INVALID_VALUE;
435 }
436 if (!data.WriteRemoteObject(producer->AsObject())) {
437 ROSEN_LOGE("CreatePixelMapFromSurface: WriteRemoteObject producer->AsObject() err.");
438 return ERR_INVALID_VALUE;
439 }
440 if (!data.WriteInt32(srcRect.x) || !data.WriteInt32(srcRect.y) ||
441 !data.WriteInt32(srcRect.w) || !data.WriteInt32(srcRect.h)) {
442 ROSEN_LOGE("CreatePixelMapFromSurface: WriteInt32 srcRect err.");
443 return ERR_INVALID_VALUE;
444 }
445 option.SetFlags(MessageOption::TF_SYNC);
446 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_PIXEL_MAP_FROM_SURFACE);
447 int32_t err = SendRequest(code, data, reply, option);
448 if (err != NO_ERROR) {
449 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreatePixelMapFromSurface: Send Request err.");
450 return ERR_INVALID_VALUE;
451 }
452
453 if (reply.ReadBool()) {
454 pixelMap.reset(Media::PixelMap::Unmarshalling(reply));
455 } else {
456 ROSEN_LOGE("CreatePixelMapFromSurface: ReadBool err.");
457 }
458 return ERR_OK;
459 }
460
SetFocusAppInfo(const FocusAppInfo & info,int32_t & repCode)461 ErrCode RSRenderServiceConnectionProxy::SetFocusAppInfo(const FocusAppInfo& info, int32_t& repCode)
462 {
463 MessageParcel data;
464 MessageParcel reply;
465 MessageOption option;
466
467 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
468 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: WriteInterfaceToken err.");
469 repCode = WRITE_PARCEL_ERR;
470 return ERR_INVALID_VALUE;
471 }
472
473 option.SetFlags(MessageOption::TF_ASYNC);
474 if (!data.WriteInt32(info.pid)) {
475 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: WriteInt32 pid err.");
476 repCode = WRITE_PARCEL_ERR;
477 return ERR_INVALID_VALUE;
478 }
479 if (!data.WriteInt32(info.uid)) {
480 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: WriteInt32 uid err.");
481 repCode = WRITE_PARCEL_ERR;
482 return ERR_INVALID_VALUE;
483 }
484 if (!data.WriteString(info.bundleName)) {
485 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: WriteString bundleName err.");
486 repCode = WRITE_PARCEL_ERR;
487 return ERR_INVALID_VALUE;
488 }
489 if (!data.WriteString(info.abilityName)) {
490 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: WriteString abilityName err.");
491 repCode = WRITE_PARCEL_ERR;
492 return ERR_INVALID_VALUE;
493 }
494 if (!data.WriteUint64(info.focusNodeId)) {
495 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: WriteUint64 focusNodeId err.");
496 repCode = WRITE_PARCEL_ERR;
497 return ERR_INVALID_VALUE;
498 }
499 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_FOCUS_APP_INFO);
500 int32_t err = SendRequest(code, data, reply, option);
501 if (err != NO_ERROR) {
502 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: Send Request err.");
503 repCode = RS_CONNECTION_ERROR;
504 return ERR_INVALID_VALUE;
505 }
506 repCode = reply.ReadInt32();
507 return ERR_OK;
508 }
509
GetDefaultScreenId(uint64_t & screenId)510 ErrCode RSRenderServiceConnectionProxy::GetDefaultScreenId(uint64_t& screenId)
511 {
512 MessageParcel data;
513 MessageParcel reply;
514 MessageOption option;
515
516 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
517 ROSEN_LOGE("GetDefaultScreenId: WriteInterfaceToken RSIRenderServiceConnection::GetDescriptor() err.");
518 screenId = INVALID_SCREEN_ID;
519 return ERR_INVALID_VALUE;
520 }
521
522 option.SetFlags(MessageOption::TF_SYNC);
523 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_DEFAULT_SCREEN_ID);
524 int32_t err = SendRequest(code, data, reply, option);
525 if (err != NO_ERROR) {
526 ROSEN_LOGE("%{public}s: sendrequest error : %{public}d", __func__, err);
527 screenId = INVALID_SCREEN_ID;
528 return ERR_INVALID_VALUE;
529 }
530 if (!reply.ReadUint64(screenId)) {
531 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetDefaultScreenId Read id failed");
532 screenId = INVALID_SCREEN_ID;
533 return ERR_INVALID_VALUE;
534 }
535 return ERR_OK;
536 }
537
GetActiveScreenId(uint64_t & screenId)538 ErrCode RSRenderServiceConnectionProxy::GetActiveScreenId(uint64_t& screenId)
539 {
540 MessageParcel data;
541 MessageParcel reply;
542 MessageOption option;
543
544 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
545 ROSEN_LOGE("GetActiveScreenId: WriteInterfaceToken RSIRenderServiceConnection::GetDescriptor() err.");
546 screenId = INVALID_SCREEN_ID;
547 return ERR_INVALID_VALUE;
548 }
549
550 option.SetFlags(MessageOption::TF_SYNC);
551 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_SCREEN_ID);
552 int32_t err = SendRequest(code, data, reply, option);
553 if (err != NO_ERROR) {
554 ROSEN_LOGE("%{public}s: sendrequest error : %{public}d", __func__, err);
555 screenId = INVALID_SCREEN_ID;
556 return ERR_INVALID_VALUE;
557 }
558 if (!reply.ReadUint64(screenId)) {
559 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetActiveScreenId Read id failed");
560 screenId = INVALID_SCREEN_ID;
561 return ERR_INVALID_VALUE;
562 }
563 return ERR_OK;
564 }
565
GetAllScreenIds()566 std::vector<ScreenId> RSRenderServiceConnectionProxy::GetAllScreenIds()
567 {
568 MessageParcel data;
569 MessageParcel reply;
570 MessageOption option;
571 std::vector<ScreenId> screenIds;
572
573 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
574 ROSEN_LOGE("GetAllScreenIds: WriteInterfaceToken RSIRenderServiceConnection::GetDescriptor() err.");
575 return std::vector<ScreenId>();
576 }
577
578 option.SetFlags(MessageOption::TF_SYNC);
579 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_ALL_SCREEN_IDS);
580 int32_t err = SendRequest(code, data, reply, option);
581 if (err != NO_ERROR) {
582 return std::vector<ScreenId>();
583 }
584
585 uint32_t size{0};
586 if (!reply.ReadUint32(size)) {
587 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetAllScreenIds Read size failed");
588 return std::vector<ScreenId>();
589 }
590 size_t readableSize = reply.GetReadableBytes() / sizeof(ScreenId);
591 size_t len = static_cast<size_t>(size);
592 if (len > readableSize || len > screenIds.max_size()) {
593 RS_LOGE("RSRenderServiceConnectionProxy GetAllScreenIds Failed read vector, size:%{public}zu,"
594 " readableSize:%{public}zu", len, readableSize);
595 return screenIds;
596 }
597 for (uint32_t i = 0; i < size; i++) {
598 screenIds.emplace_back(reply.ReadUint64());
599 }
600
601 return screenIds;
602 }
603
CreateVirtualScreen(const std::string & name,uint32_t width,uint32_t height,sptr<Surface> surface,ScreenId mirrorId,int32_t flags,std::vector<NodeId> whiteList)604 ScreenId RSRenderServiceConnectionProxy::CreateVirtualScreen(
605 const std::string &name,
606 uint32_t width,
607 uint32_t height,
608 sptr<Surface> surface,
609 ScreenId mirrorId,
610 int32_t flags,
611 std::vector<NodeId> whiteList)
612 {
613 MessageParcel data;
614 MessageParcel reply;
615 MessageOption option;
616
617 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
618 ROSEN_LOGE("CreateVirtualScreen: WriteInterfaceToken RSIRenderServiceConnection::GetDescriptor() err.");
619 return INVALID_SCREEN_ID;
620 }
621
622 option.SetFlags(MessageOption::TF_SYNC);
623 if (!data.WriteString(name)) {
624 ROSEN_LOGE("CreateVirtualScreen: WriteString name err.");
625 return INVALID_SCREEN_ID;
626 }
627 if (!data.WriteUint32(width)) {
628 ROSEN_LOGE("CreateVirtualScreen: WriteUint32 width err.");
629 return INVALID_SCREEN_ID;
630 }
631 if (!data.WriteUint32(height)) {
632 ROSEN_LOGE("CreateVirtualScreen: WriteUint32 height err.");
633 return INVALID_SCREEN_ID;
634 }
635 if (surface != nullptr) {
636 auto producer = surface->GetProducer();
637 if (producer != nullptr) {
638 if (!data.WriteBool(true)) {
639 ROSEN_LOGE("CreateVirtualScreen: WriteBool [true] err.");
640 return INVALID_SCREEN_ID;
641 }
642 if (!data.WriteRemoteObject(producer->AsObject())) {
643 ROSEN_LOGE("CreateVirtualScreen: WriteRemoteObject producer->AsObject() err.");
644 return INVALID_SCREEN_ID;
645 }
646 } else {
647 if (!data.WriteBool(false)) {
648 ROSEN_LOGE("CreateVirtualScreen: WriteBool [false] err.");
649 return INVALID_SCREEN_ID;
650 }
651 }
652 } else {
653 if (!data.WriteBool(false)) {
654 ROSEN_LOGE("CreateVirtualScreen: WriteBool [false] err.");
655 return INVALID_SCREEN_ID;
656 }
657 }
658 if (!data.WriteUint64(mirrorId)) {
659 ROSEN_LOGE("CreateVirtualScreen: WriteUint64 mirrorId err.");
660 return INVALID_SCREEN_ID;
661 }
662 if (!data.WriteInt32(flags)) {
663 ROSEN_LOGE("CreateVirtualScreen: WriteInt32 flags err.");
664 return INVALID_SCREEN_ID;
665 }
666 if (!data.WriteUInt64Vector(whiteList)) {
667 ROSEN_LOGE("CreateVirtualScreen: WriteUInt64Vector whiteList err.");
668 return INVALID_SCREEN_ID;
669 }
670 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_VIRTUAL_SCREEN);
671 int32_t err = SendRequest(code, data, reply, option);
672 if (err != NO_ERROR) {
673 ROSEN_LOGE("RSRenderServiceConnectionProxy::%{public}s: Send Request err.", __func__);
674 return INVALID_SCREEN_ID;
675 }
676
677 uint64_t id{0};
678 if (!reply.ReadUint64(id)) {
679 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateVirtualScreen Read id failed");
680 return INVALID_SCREEN_ID;
681 }
682 return id;
683 }
684
SetVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector)685 int32_t RSRenderServiceConnectionProxy::SetVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector)
686 {
687 MessageParcel data;
688 MessageParcel reply;
689 MessageOption option;
690
691 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
692 ROSEN_LOGE("SetVirtualScreenBlackList: WriteInterfaceToken GetDescriptor err.");
693 return WRITE_PARCEL_ERR;
694 }
695
696 option.SetFlags(MessageOption::TF_ASYNC);
697 if (!data.WriteUint64(id)) {
698 ROSEN_LOGE("SetVirtualScreenBlackList: WriteUint64 id err.");
699 return WRITE_PARCEL_ERR;
700 }
701 if (!data.WriteUInt64Vector(blackListVector)) {
702 ROSEN_LOGE("SetVirtualScreenBlackList: WriteUInt64Vector blackListVector err.");
703 return WRITE_PARCEL_ERR;
704 }
705 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_BLACKLIST);
706 int32_t err = SendRequest(code, data, reply, option);
707 if (err != NO_ERROR) {
708 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenBlackList: Send Request err.");
709 return RS_CONNECTION_ERROR;
710 }
711
712 int32_t status = reply.ReadInt32();
713 return status;
714 }
715
SetVirtualScreenTypeBlackList(ScreenId id,std::vector<NodeType> & typeBlackListVector,int32_t & repCode)716 ErrCode RSRenderServiceConnectionProxy::SetVirtualScreenTypeBlackList(
717 ScreenId id, std::vector<NodeType>& typeBlackListVector, int32_t& repCode)
718 {
719 MessageParcel data;
720 MessageParcel reply;
721 MessageOption option(MessageOption::TF_ASYNC);
722
723 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
724 ROSEN_LOGE("SetVirtualScreenTypeBlackList: WriteInterfaceToken GetDescriptor err.");
725 repCode = WRITE_PARCEL_ERR;
726 return ERR_INVALID_VALUE;
727 }
728
729 if (!data.WriteUint64(id)) {
730 ROSEN_LOGE("SetVirtualScreenTypeBlackList: WriteUint64 id err.");
731 repCode = WRITE_PARCEL_ERR;
732 return ERR_INVALID_VALUE;
733 }
734 if (!data.WriteUInt8Vector(typeBlackListVector)) {
735 ROSEN_LOGE("SetVirtualScreenTypeBlackList: WriteUInt8Vector typeBlackListVector err.");
736 repCode = WRITE_PARCEL_ERR;
737 return ERR_INVALID_VALUE;
738 }
739 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_TYPE_BLACKLIST);
740 int32_t err = SendRequest(code, data, reply, option);
741 if (err != NO_ERROR) {
742 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenTypeBlackList: Send Request err.");
743 return ERR_INVALID_VALUE;
744 }
745
746 repCode = reply.ReadInt32();
747 return ERR_OK;
748 }
749
AddVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector,int32_t & repCode)750 ErrCode RSRenderServiceConnectionProxy::AddVirtualScreenBlackList(
751 ScreenId id, std::vector<NodeId>& blackListVector, int32_t& repCode)
752 {
753 MessageParcel data;
754 MessageParcel reply;
755 MessageOption option;
756
757 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
758 ROSEN_LOGE("AddVirtualScreenBlackList: WriteInterfaceToken GetDescriptor err.");
759 repCode = WRITE_PARCEL_ERR;
760 return ERR_INVALID_VALUE;
761 }
762
763 option.SetFlags(MessageOption::TF_ASYNC);
764 if (!data.WriteUint64(id)) {
765 ROSEN_LOGE("AddVirtualScreenBlackList: WriteUint64 id err.");
766 repCode = WRITE_PARCEL_ERR;
767 return ERR_INVALID_VALUE;
768 }
769 if (!data.WriteUInt64Vector(blackListVector)) {
770 ROSEN_LOGE("AddVirtualScreenBlackList: WriteUInt64Vector id err.");
771 repCode = WRITE_PARCEL_ERR;
772 return ERR_INVALID_VALUE;
773 }
774 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::ADD_VIRTUAL_SCREEN_BLACKLIST);
775 int32_t err = SendRequest(code, data, reply, option);
776 if (err != NO_ERROR) {
777 ROSEN_LOGE("RSRenderServiceConnectionProxy::AddVirtualScreenBlackList: Send Request err.");
778 return ERR_INVALID_VALUE;
779 }
780
781 repCode = reply.ReadInt32();
782 return ERR_OK;
783 }
784
RemoveVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector,int32_t & repCode)785 ErrCode RSRenderServiceConnectionProxy::RemoveVirtualScreenBlackList(
786 ScreenId id, std::vector<NodeId>& blackListVector, int32_t& repCode)
787 {
788 MessageParcel data;
789 MessageParcel reply;
790 MessageOption option;
791
792 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
793 ROSEN_LOGE("RemoveVirtualScreenBlackList: WriteInterfaceToken GetDescriptor err.");
794 repCode = WRITE_PARCEL_ERR;
795 return ERR_INVALID_VALUE;
796 }
797
798 option.SetFlags(MessageOption::TF_ASYNC);
799 if (!data.WriteUint64(id)) {
800 ROSEN_LOGE("RemoveVirtualScreenBlackList: WriteUint64 id err.");
801 repCode = WRITE_PARCEL_ERR;
802 return ERR_INVALID_VALUE;
803 }
804 if (!data.WriteUInt64Vector(blackListVector)) {
805 ROSEN_LOGE("RemoveVirtualScreenBlackList: WriteUInt64Vector blackListVector err.");
806 repCode = WRITE_PARCEL_ERR;
807 return ERR_INVALID_VALUE;
808 }
809 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN_BLACKLIST);
810 int32_t err = SendRequest(code, data, reply, option);
811 if (err != NO_ERROR) {
812 ROSEN_LOGE("RSRenderServiceConnectionProxy::RemoveVirtualScreenBlackList: Send Request err.");
813 return ERR_INVALID_VALUE;
814 }
815
816 repCode = reply.ReadInt32();
817 return ERR_OK;
818 }
819
SetVirtualScreenSecurityExemptionList(ScreenId id,const std::vector<NodeId> & securityExemptionList)820 int32_t RSRenderServiceConnectionProxy::SetVirtualScreenSecurityExemptionList(
821 ScreenId id,
822 const std::vector<NodeId>& securityExemptionList)
823 {
824 if (securityExemptionList.size() > MAX_SECURITY_EXEMPTION_LIST_NUMBER) {
825 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenSecurityExemptionList: too many lists.");
826 return INVALID_ARGUMENTS;
827 }
828 MessageParcel data;
829 MessageParcel reply;
830 MessageOption option;
831
832 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
833 ROSEN_LOGE("SetVirtualScreenSecurityExemptionList: WriteInterfaceToken GetDescriptor err.");
834 return WRITE_PARCEL_ERR;
835 }
836
837 option.SetFlags(MessageOption::TF_SYNC);
838 if (!data.WriteUint64(id)) {
839 ROSEN_LOGE("SetVirtualScreenSecurityExemptionList: WriteUint64 id err.");
840 return WRITE_PARCEL_ERR;
841 }
842 if (!data.WriteUInt64Vector(securityExemptionList)) {
843 ROSEN_LOGE("SetVirtualScreenSecurityExemptionList: WriteUInt64Vector securityExemptionList err.");
844 return WRITE_PARCEL_ERR;
845 }
846 uint32_t code = static_cast<uint32_t>(
847 RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION_LIST);
848 int32_t err = SendRequest(code, data, reply, option);
849 if (err != NO_ERROR) {
850 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenSecurityExemptionList: Send Request err.");
851 return RS_CONNECTION_ERROR;
852 }
853
854 int32_t status{0};
855 if (!reply.ReadInt32(status)) {
856 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenSecurityExemptionList Read status failed");
857 return READ_PARCEL_ERR;
858 }
859 return status;
860 }
861
SetScreenSecurityMask(ScreenId id,std::shared_ptr<Media::PixelMap> securityMask)862 int32_t RSRenderServiceConnectionProxy::SetScreenSecurityMask(ScreenId id,
863 std::shared_ptr<Media::PixelMap> securityMask)
864 {
865 MessageParcel data;
866 MessageParcel reply;
867 MessageOption option;
868 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
869 ROSEN_LOGE("SetScreenSecurityMask: WriteInterfaceToken GetDescriptor err.");
870 return WRITE_PARCEL_ERR;
871 }
872
873 option.SetFlags(MessageOption::TF_ASYNC);
874 if (!data.WriteUint64(id)) {
875 ROSEN_LOGE("SetScreenSecurityMask: WriteUint64 id err.");
876 return WRITE_PARCEL_ERR;
877 }
878
879 if (securityMask) {
880 if (!data.WriteBool(true) || !data.WriteParcelable(securityMask.get())) {
881 ROSEN_LOGE("SetScreenSecurityMask: WriteBool[true] OR WriteParcelable[securityMask.get()] err.");
882 return WRITE_PARCEL_ERR;
883 }
884 } else {
885 if (!data.WriteBool(false)) {
886 ROSEN_LOGE("SetScreenSecurityMask: WriteBool [false] err.");
887 return WRITE_PARCEL_ERR;
888 }
889 }
890 uint32_t code = static_cast<uint32_t>(
891 RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_SECURITY_MASK);
892 int32_t err = SendRequest(code, data, reply, option);
893 if (err != NO_ERROR) {
894 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenSecurityMask: Send Request err.");
895 return RS_CONNECTION_ERROR;
896 }
897 return SUCCESS;
898 }
899
SetMirrorScreenVisibleRect(ScreenId id,const Rect & mainScreenRect,bool supportRotation)900 int32_t RSRenderServiceConnectionProxy::SetMirrorScreenVisibleRect(
901 ScreenId id, const Rect& mainScreenRect, bool supportRotation)
902 {
903 MessageParcel data;
904 MessageParcel reply;
905 MessageOption option;
906
907 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
908 ROSEN_LOGE("SetMirrorScreenVisibleRect: WriteInterfaceToken GetDescriptor err.");
909 return WRITE_PARCEL_ERR;
910 }
911
912 option.SetFlags(MessageOption::TF_SYNC);
913 if (!data.WriteUint64(id)) {
914 ROSEN_LOGE("SetMirrorScreenVisibleRect: WriteUint64 id err.");
915 return WRITE_PARCEL_ERR;
916 }
917 if (!data.WriteInt32(mainScreenRect.x) || !data.WriteInt32(mainScreenRect.y) ||
918 !data.WriteInt32(mainScreenRect.w) || !data.WriteInt32(mainScreenRect.h)) {
919 ROSEN_LOGE("SetMirrorScreenVisibleRect: WriteInt32 mainScreenRect err.");
920 return WRITE_PARCEL_ERR;
921 }
922 if (!data.WriteBool(supportRotation)) {
923 ROSEN_LOGE("SetMirrorScreenVisibleRect: WriteBool supportRotation err.");
924 return WRITE_PARCEL_ERR;
925 }
926 uint32_t code = static_cast<uint32_t>(
927 RSIRenderServiceConnectionInterfaceCode::SET_MIRROR_SCREEN_VISIBLE_RECT);
928 int32_t err = SendRequest(code, data, reply, option);
929 if (err != NO_ERROR) {
930 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetMirrorScreenVisibleRect: Send Request err.");
931 return RS_CONNECTION_ERROR;
932 }
933
934 int32_t status{0};
935 if (!reply.ReadInt32(status)) {
936 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetMirrorScreenVisibleRect Read status failed");
937 return READ_PARCEL_ERR;
938 }
939 return status;
940 }
941
SetCastScreenEnableSkipWindow(ScreenId id,bool enable)942 int32_t RSRenderServiceConnectionProxy::SetCastScreenEnableSkipWindow(ScreenId id, bool enable)
943 {
944 MessageParcel data;
945 MessageParcel reply;
946 MessageOption option;
947
948 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
949 ROSEN_LOGE("SetCastScreenEnableSkipWindow: WriteInterfaceToken GetDescriptor err.");
950 return WRITE_PARCEL_ERR;
951 }
952
953 option.SetFlags(MessageOption::TF_ASYNC);
954 if (!data.WriteUint64(id)) {
955 ROSEN_LOGE("SetCastScreenEnableSkipWindow: WriteUint64 MessageOption::TF_ASYNC err.");
956 return WRITE_PARCEL_ERR;
957 }
958 if (!data.WriteBool(enable)) {
959 ROSEN_LOGE("SetCastScreenEnableSkipWindow: WriteBool enable err.");
960 return WRITE_PARCEL_ERR;
961 }
962 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_CAST_SCREEN_ENABLE_SKIP_WINDOW);
963 int32_t err = SendRequest(code, data, reply, option);
964 if (err != NO_ERROR) {
965 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetCastScreenEnableSkipWindow: Send Request err.");
966 return RS_CONNECTION_ERROR;
967 }
968 int32_t result = reply.ReadInt32();
969 return result;
970 }
971
SetVirtualScreenSurface(ScreenId id,sptr<Surface> surface)972 int32_t RSRenderServiceConnectionProxy::SetVirtualScreenSurface(ScreenId id, sptr<Surface> surface)
973 {
974 if (surface == nullptr) {
975 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenSurface: Send surface is nullptr!");
976 return INVALID_ARGUMENTS;
977 }
978
979 MessageParcel data;
980 MessageParcel reply;
981 MessageOption option;
982
983 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
984 ROSEN_LOGE("SetVirtualScreenSurface: WriteInterfaceToken GetDescriptor err.");
985 return WRITE_PARCEL_ERR;
986 }
987
988 option.SetFlags(MessageOption::TF_ASYNC);
989 if (!data.WriteUint64(id)) {
990 ROSEN_LOGE("SetVirtualScreenSurface: WriteUint64 MessageOption::TF_ASYNC err.");
991 return WRITE_PARCEL_ERR;
992 }
993 auto producer = surface->GetProducer();
994 if (!data.WriteRemoteObject(producer->AsObject())) {
995 ROSEN_LOGE("SetVirtualScreenSurface: WriteRemoteObject producer->AsObject() err.");
996 return WRITE_PARCEL_ERR;
997 }
998 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SURFACE);
999 int32_t err = SendRequest(code, data, reply, option);
1000 if (err != NO_ERROR) {
1001 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenSurface: Send Request err.");
1002 return RS_CONNECTION_ERROR;
1003 }
1004
1005 int32_t status = reply.ReadInt32();
1006 return status;
1007 }
1008
RemoveVirtualScreen(ScreenId id)1009 void RSRenderServiceConnectionProxy::RemoveVirtualScreen(ScreenId id)
1010 {
1011 MessageParcel data;
1012 MessageParcel reply;
1013 MessageOption option;
1014 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1015 ROSEN_LOGE("RemoveVirtualScreen: WriteInterfaceToken GetDescriptor err.");
1016 return;
1017 }
1018
1019 option.SetFlags(MessageOption::TF_ASYNC);
1020 if (!data.WriteUint64(id)) {
1021 ROSEN_LOGE("RemoveVirtualScreen: WriteUint64 id err.");
1022 return;
1023 }
1024 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN);
1025 int32_t err = SendRequest(code, data, reply, option);
1026 if (err != NO_ERROR) {
1027 ROSEN_LOGE("RSRenderServiceConnectionProxy::RemoveVirtualScreen: Send Request err.");
1028 return;
1029 }
1030 }
1031
1032 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
SetPointerColorInversionConfig(float darkBuffer,float brightBuffer,int64_t interval,int32_t rangeSize)1033 int32_t RSRenderServiceConnectionProxy::SetPointerColorInversionConfig(float darkBuffer,
1034 float brightBuffer, int64_t interval, int32_t rangeSize)
1035 {
1036 MessageParcel data;
1037 MessageParcel reply;
1038 MessageOption option;
1039 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1040 ROSEN_LOGE("SetPointerColorInversionConfig: WriteInterfaceToken GetDescriptor err.");
1041 return WRITE_PARCEL_ERR;
1042 }
1043 option.SetFlags(MessageOption::TF_ASYNC);
1044 if (!data.WriteFloat(darkBuffer)) {
1045 ROSEN_LOGE("SetPointerColorInversionConfig: WriteFloat darkBuffer err.");
1046 return WRITE_PARCEL_ERR;
1047 }
1048 if (!data.WriteFloat(brightBuffer)) {
1049 ROSEN_LOGE("SetPointerColorInversionConfig: WriteFloat brightBuffer err.");
1050 return WRITE_PARCEL_ERR;
1051 }
1052 if (!data.WriteInt64(interval)) {
1053 ROSEN_LOGE("SetPointerColorInversionConfig: WriteInt64 interval err.");
1054 return WRITE_PARCEL_ERR;
1055 }
1056 if (!data.WriteInt32(rangeSize)) {
1057 ROSEN_LOGE("SetPointerColorInversionConfig: WriteInt32 rangeSize err.");
1058 return WRITE_PARCEL_ERR;
1059 }
1060 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_COLOR_INVERSION_CONFIG);
1061 int32_t err = SendRequest(code, data, reply, option);
1062 if (err != NO_ERROR) {
1063 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetPointerColorInversionConfig: Send Request err.");
1064 return RS_CONNECTION_ERROR;
1065 }
1066 int32_t result = reply.ReadInt32();
1067 return result;
1068 }
1069
SetPointerColorInversionEnabled(bool enable)1070 int32_t RSRenderServiceConnectionProxy::SetPointerColorInversionEnabled(bool enable)
1071 {
1072 MessageParcel data;
1073 MessageParcel reply;
1074 MessageOption option;
1075 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1076 ROSEN_LOGE("SetPointerColorInversionEnabled: WriteInterfaceToken GetDescriptor err.");
1077 return WRITE_PARCEL_ERR;
1078 }
1079 option.SetFlags(MessageOption::TF_ASYNC);
1080 if (!data.WriteBool(enable)) {
1081 ROSEN_LOGE("SetPointerColorInversionEnabled: WriteBool enable err.");
1082 return WRITE_PARCEL_ERR;
1083 }
1084 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_COLOR_INVERSION_ENABLED);
1085 int32_t err = SendRequest(code, data, reply, option);
1086 if (err != NO_ERROR) {
1087 ROSEN_LOGE("RSRenderServiceConnectionProxy::DisableCursorInvert: Send Request err.");
1088 return RS_CONNECTION_ERROR;
1089 }
1090 int32_t result = reply.ReadInt32();
1091 return result;
1092 }
1093
RegisterPointerLuminanceChangeCallback(sptr<RSIPointerLuminanceChangeCallback> callback)1094 int32_t RSRenderServiceConnectionProxy::RegisterPointerLuminanceChangeCallback(
1095 sptr<RSIPointerLuminanceChangeCallback> callback)
1096 {
1097 if (callback == nullptr) {
1098 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterPointerLuminanceChangeCallback: callback is nullptr.");
1099 return INVALID_ARGUMENTS;
1100 }
1101
1102 MessageParcel data;
1103 MessageParcel reply;
1104 MessageOption option;
1105
1106 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1107 ROSEN_LOGE("RegisterPointerLuminanceChangeCallback: WriteInterfaceToken GetDescriptor err.");
1108 return WRITE_PARCEL_ERR;
1109 }
1110
1111 option.SetFlags(MessageOption::TF_ASYNC);
1112 if (!data.WriteRemoteObject(callback->AsObject())) {
1113 ROSEN_LOGE("RegisterPointerLuminanceChangeCallback: WriteRemoteObject callback->AsObject() err.");
1114 return WRITE_PARCEL_ERR;
1115 }
1116 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_POINTER_LUMINANCE_CALLBACK);
1117 int32_t err = SendRequest(code, data, reply, option);
1118 if (err != NO_ERROR) {
1119 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterPointerLuminanceChangeCallback: Send Request err.");
1120 return RS_CONNECTION_ERROR;
1121 }
1122 int32_t result = reply.ReadInt32();
1123 return result;
1124 }
1125
UnRegisterPointerLuminanceChangeCallback()1126 int32_t RSRenderServiceConnectionProxy::UnRegisterPointerLuminanceChangeCallback()
1127 {
1128 MessageParcel data;
1129 MessageParcel reply;
1130 MessageOption option;
1131 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1132 ROSEN_LOGE("UnRegisterPointerLuminanceChangeCallback: WriteInterfaceToken GetDescriptor err.");
1133 return WRITE_PARCEL_ERR;
1134 }
1135 option.SetFlags(MessageOption::TF_ASYNC);
1136 uint32_t code = static_cast<uint32_t>(
1137 RSIRenderServiceConnectionInterfaceCode::UNREGISTER_POINTER_LUMINANCE_CALLBACK);
1138 int32_t err = SendRequest(code, data, reply, option);
1139 if (err != NO_ERROR) {
1140 ROSEN_LOGE("RSRenderServiceConnectionProxy::UnRegisterPointerLuminanceChangeCallback: Send Request err.");
1141 return RS_CONNECTION_ERROR;
1142 }
1143 int32_t result = reply.ReadInt32();
1144 return result;
1145 }
1146 #endif
1147
SetScreenChangeCallback(sptr<RSIScreenChangeCallback> callback)1148 int32_t RSRenderServiceConnectionProxy::SetScreenChangeCallback(sptr<RSIScreenChangeCallback> callback)
1149 {
1150 if (callback == nullptr) {
1151 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenChangeCallback: callback is nullptr.");
1152 return INVALID_ARGUMENTS;
1153 }
1154
1155 MessageParcel data;
1156 MessageParcel reply;
1157 MessageOption option;
1158
1159 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1160 ROSEN_LOGE("SetScreenChangeCallback: WriteInterfaceToken GetDescriptor err.");
1161 return WRITE_PARCEL_ERR;
1162 }
1163
1164 option.SetFlags(MessageOption::TF_ASYNC);
1165 if (!data.WriteRemoteObject(callback->AsObject())) {
1166 ROSEN_LOGE("SetScreenChangeCallback: WriteRemoteObject callback->AsObject() err.");
1167 return WRITE_PARCEL_ERR;
1168 }
1169 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CHANGE_CALLBACK);
1170 int32_t err = SendRequest(code, data, reply, option);
1171 if (err != NO_ERROR) {
1172 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenChangeCallback: Send Request err.");
1173 return RS_CONNECTION_ERROR;
1174 }
1175 int32_t result = reply.ReadInt32();
1176 return result;
1177 }
1178
SetScreenSwitchingNotifyCallback(sptr<RSIScreenSwitchingNotifyCallback> callback)1179 int32_t RSRenderServiceConnectionProxy::SetScreenSwitchingNotifyCallback(
1180 sptr<RSIScreenSwitchingNotifyCallback> callback)
1181 {
1182 MessageParcel data;
1183 MessageParcel reply;
1184 MessageOption option;
1185
1186 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1187 ROSEN_LOGE("SetScreenSwitchingNotifyCallback: WriteInterfaceToken GetDescriptor err.");
1188 return WRITE_PARCEL_ERR;
1189 }
1190
1191 option.SetFlags(MessageOption::TF_SYNC);
1192
1193 if (callback) {
1194 if (!data.WriteBool(true) || !data.WriteRemoteObject(callback->AsObject())) {
1195 ROSEN_LOGE("SetScreenSwitchingNotifyCallback: WriteBool[T] OR WriteRemoteObject[CB] err");
1196 return WRITE_PARCEL_ERR;
1197 }
1198 } else {
1199 if (!data.WriteBool(false)) {
1200 ROSEN_LOGE("SetScreenSwitchingNotifyCallback: WriteBool [false] err.");
1201 return WRITE_PARCEL_ERR;
1202 }
1203 }
1204
1205 uint32_t code = static_cast<uint32_t>(
1206 RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_SWITCHING_NOTIFY_CALLBACK);
1207 int32_t err = SendRequest(code, data, reply, option);
1208 if (err != NO_ERROR) {
1209 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenSwitchingNotifyCallback: Send Request err.");
1210 return RS_CONNECTION_ERROR;
1211 }
1212
1213 int32_t result{0};
1214 if (!reply.ReadInt32(result)) {
1215 ROSEN_LOGE(
1216 "RSRenderServiceConnectionProxy::SetScreenSwitchingNotifyCallback Read result failed");
1217 return READ_PARCEL_ERR;
1218 }
1219 return result;
1220 }
1221
SetScreenActiveMode(ScreenId id,uint32_t modeId)1222 void RSRenderServiceConnectionProxy::SetScreenActiveMode(ScreenId id, uint32_t modeId)
1223 {
1224 MessageParcel data;
1225 MessageParcel reply;
1226 MessageOption option;
1227
1228 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1229 ROSEN_LOGE("SetScreenActiveMode: WriteInterfaceToken GetDescriptor err.");
1230 return;
1231 }
1232 option.SetFlags(MessageOption::TF_SYNC);
1233 if (!data.WriteUint64(id)) {
1234 ROSEN_LOGE("SetScreenActiveMode: WriteUint64 id err.");
1235 return;
1236 }
1237 if (!data.WriteUint32(modeId)) {
1238 ROSEN_LOGE("SetScreenActiveMode: WriteUint32 modeId err.");
1239 return;
1240 }
1241 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_MODE);
1242 int32_t err = SendRequest(code, data, reply, option);
1243 if (err != NO_ERROR) {
1244 return;
1245 }
1246 }
1247
SetScreenRefreshRate(ScreenId id,int32_t sceneId,int32_t rate)1248 void RSRenderServiceConnectionProxy::SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate)
1249 {
1250 MessageParcel data;
1251 MessageParcel reply;
1252 MessageOption option;
1253
1254 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1255 ROSEN_LOGE("SetScreenRefreshRate: WriteInterfaceToken GetDescriptor err.");
1256 return;
1257 }
1258 option.SetFlags(MessageOption::TF_SYNC);
1259 if (!data.WriteUint64(id)) {
1260 ROSEN_LOGE("SetScreenRefreshRate: WriteUint64 id err.");
1261 return;
1262 }
1263 if (!data.WriteInt32(sceneId)) {
1264 ROSEN_LOGE("SetScreenRefreshRate: WriteInt32 sceneId err.");
1265 return;
1266 }
1267 if (!data.WriteInt32(rate)) {
1268 ROSEN_LOGE("SetScreenRefreshRate: WriteInt32 rate err.");
1269 return;
1270 }
1271 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_REFRESH_RATE);
1272 int32_t err = SendRequest(code, data, reply, option);
1273 if (err != NO_ERROR) {
1274 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
1275 return;
1276 }
1277 }
1278
SetRefreshRateMode(int32_t refreshRateMode)1279 void RSRenderServiceConnectionProxy::SetRefreshRateMode(int32_t refreshRateMode)
1280 {
1281 MessageParcel data;
1282 MessageParcel reply;
1283 MessageOption option;
1284
1285 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1286 ROSEN_LOGE("SetRefreshRateMode: WriteInterfaceToken GetDescriptor err.");
1287 return;
1288 }
1289 option.SetFlags(MessageOption::TF_SYNC);
1290 if (!data.WriteInt32(refreshRateMode)) {
1291 ROSEN_LOGE("SetRefreshRateMode: WriteInt32 refreshRateMode err.");
1292 return;
1293 }
1294 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_REFRESH_RATE_MODE);
1295 int32_t err = SendRequest(code, data, reply, option);
1296 if (err != NO_ERROR) {
1297 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
1298 return;
1299 }
1300 }
1301
SyncFrameRateRange(FrameRateLinkerId id,const FrameRateRange & range,int32_t animatorExpectedFrameRate)1302 void RSRenderServiceConnectionProxy::SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range,
1303 int32_t animatorExpectedFrameRate)
1304 {
1305 MessageParcel data;
1306 MessageParcel reply;
1307 MessageOption option;
1308
1309 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1310 ROSEN_LOGE("SyncFrameRateRange: WriteInterfaceToken GetDescriptor err.");
1311 return;
1312 }
1313
1314 option.SetFlags(MessageOption::TF_SYNC);
1315 if (!data.WriteUint64(id)) {
1316 ROSEN_LOGE("SyncFrameRateRange: WriteUint64 id err.");
1317 return;
1318 }
1319 if (!data.WriteUint32(range.min_) || !data.WriteUint32(range.max_) ||
1320 !data.WriteUint32(range.preferred_) || !data.WriteUint32(range.type_) ||
1321 !data.WriteUint32(range.componentScene_)) {
1322 ROSEN_LOGE("SyncFrameRateRange: WriteUint32 range err.");
1323 return;
1324 }
1325 if (!data.WriteInt32(animatorExpectedFrameRate)) {
1326 ROSEN_LOGE("SyncFrameRateRange: WriteInt32 animatorExpectedFrameRate err.");
1327 return;
1328 }
1329 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SYNC_FRAME_RATE_RANGE);
1330 int32_t err = SendRequest(code, data, reply, option);
1331 if (err != NO_ERROR) {
1332 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
1333 return;
1334 }
1335 }
UnregisterFrameRateLinker(FrameRateLinkerId id)1336 void RSRenderServiceConnectionProxy::UnregisterFrameRateLinker(FrameRateLinkerId id)
1337 {
1338 MessageParcel data;
1339 MessageParcel reply;
1340 MessageOption option;
1341
1342 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1343 ROSEN_LOGE("UnregisterFrameRateLinker: WriteInterfaceToken GetDescriptor err.");
1344 return;
1345 }
1346
1347 option.SetFlags(MessageOption::TF_ASYNC);
1348 if (!data.WriteUint64(id)) {
1349 ROSEN_LOGE("UnregisterFrameRateLinker: WriteUint64 id err.");
1350 return;
1351 }
1352 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_FRAME_RATE_LINKER);
1353 int32_t err = SendRequest(code, data, reply, option);
1354 if (err != NO_ERROR) {
1355 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
1356 return;
1357 }
1358 }
1359
GetScreenCurrentRefreshRate(ScreenId id)1360 uint32_t RSRenderServiceConnectionProxy::GetScreenCurrentRefreshRate(ScreenId id)
1361 {
1362 MessageParcel data;
1363 MessageParcel reply;
1364 MessageOption option;
1365
1366 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1367 ROSEN_LOGE("GetScreenCurrentRefreshRate: WriteInterfaceToken GetDescriptor err.");
1368 return SUCCESS;
1369 }
1370 option.SetFlags(MessageOption::TF_SYNC);
1371 if (!data.WriteUint64(id)) {
1372 ROSEN_LOGE("GetScreenCurrentRefreshRate: WriteUint64 id err.");
1373 return SUCCESS;
1374 }
1375 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CURRENT_REFRESH_RATE);
1376 int32_t err = SendRequest(code, data, reply, option);
1377 if (err != NO_ERROR) {
1378 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
1379 return SUCCESS;
1380 }
1381 uint32_t rate{0};
1382 if (!reply.ReadUint32(rate)) {
1383 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenCurrentRefreshRate Read rate failed");
1384 return READ_PARCEL_ERR;
1385 }
1386 return rate;
1387 }
1388
GetCurrentRefreshRateMode()1389 int32_t RSRenderServiceConnectionProxy::GetCurrentRefreshRateMode()
1390 {
1391 MessageParcel data;
1392 MessageParcel reply;
1393 MessageOption option;
1394
1395 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1396 ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor");
1397 return SUCCESS;
1398 }
1399 option.SetFlags(MessageOption::TF_SYNC);
1400 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_CURRENT_REFRESH_RATE_MODE);
1401 int32_t err = SendRequest(code, data, reply, option);
1402 if (err != NO_ERROR) {
1403 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
1404 return SUCCESS;
1405 }
1406 int32_t refreshRateMode{0};
1407 if (!reply.ReadInt32(refreshRateMode)) {
1408 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetCurrentRefreshRateMode Read refreshRateMode failed");
1409 return READ_PARCEL_ERR;
1410 }
1411 return refreshRateMode;
1412 }
1413
GetScreenSupportedRefreshRates(ScreenId id)1414 std::vector<int32_t> RSRenderServiceConnectionProxy::GetScreenSupportedRefreshRates(ScreenId id)
1415 {
1416 MessageParcel data;
1417 MessageParcel reply;
1418 MessageOption option;
1419 std::vector<int32_t> screenSupportedRates;
1420
1421 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1422 ROSEN_LOGE("GetScreenSupportedRefreshRates: WriteInterfaceToken GetDescriptor err.");
1423 return screenSupportedRates;
1424 }
1425 option.SetFlags(MessageOption::TF_SYNC);
1426 if (!data.WriteUint64(id)) {
1427 ROSEN_LOGE("GetScreenSupportedRefreshRates: WriteUint64 id err.");
1428 return screenSupportedRates;
1429 }
1430 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_REFRESH_RATES);
1431 int32_t err = SendRequest(code, data, reply, option);
1432 if (err != NO_ERROR) {
1433 return screenSupportedRates;
1434 }
1435 uint64_t rateCount{0};
1436 if (!reply.ReadUint64(rateCount)) {
1437 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenSupportedRefreshRates Read rateCount failed");
1438 return screenSupportedRates;
1439 }
1440 size_t readableSize = reply.GetReadableBytes();
1441 size_t len = static_cast<size_t>(rateCount);
1442 if (len > readableSize || len > screenSupportedRates.max_size()) {
1443 RS_LOGE("RSRenderServiceConnectionProxy GetScreenSupportedRefreshRates "
1444 "fail read vector, size : %{public}zu, readableSize : %{public}zu", len, readableSize);
1445 return screenSupportedRates;
1446 }
1447 screenSupportedRates.resize(rateCount);
1448 for (uint64_t rateIndex = 0; rateIndex < rateCount; rateIndex++) {
1449 screenSupportedRates[rateIndex] = reply.ReadInt32();
1450 }
1451 return screenSupportedRates;
1452 }
1453
GetShowRefreshRateEnabled(bool & enable)1454 ErrCode RSRenderServiceConnectionProxy::GetShowRefreshRateEnabled(bool& enable)
1455 {
1456 MessageParcel data;
1457 MessageParcel reply;
1458 MessageOption option;
1459
1460 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1461 ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor");
1462 return ERR_INVALID_VALUE;
1463 }
1464 option.SetFlags(MessageOption::TF_SYNC);
1465 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SHOW_REFRESH_RATE_ENABLED);
1466 int32_t err = SendRequest(code, data, reply, option);
1467 if (err != NO_ERROR) {
1468 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
1469 return ERR_INVALID_VALUE;
1470 }
1471 if (!reply.ReadBool(enable)) {
1472 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetCurrentRefreshRateMode Read enable failed");
1473 return ERR_INVALID_VALUE;
1474 }
1475 return ERR_OK;
1476 }
1477
SetShowRefreshRateEnabled(bool enabled,int32_t type)1478 void RSRenderServiceConnectionProxy::SetShowRefreshRateEnabled(bool enabled, int32_t type)
1479 {
1480 MessageParcel data;
1481 MessageParcel reply;
1482 MessageOption option;
1483
1484 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1485 ROSEN_LOGE("SetShowRefreshRateEnabled: WriteInterfaceToken GetDescriptor err.");
1486 return;
1487 }
1488 option.SetFlags(MessageOption::TF_SYNC);
1489 if (!data.WriteBool(enabled) || !data.WriteInt32(type)) {
1490 ROSEN_LOGE("SetShowRefreshRateEnabled: WriteBool[enable] OR WriteInt32[type] err.");
1491 return;
1492 }
1493 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED);
1494 int32_t err = SendRequest(code, data, reply, option);
1495 if (err != NO_ERROR) {
1496 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
1497 return;
1498 }
1499 }
1500
GetRealtimeRefreshRate(ScreenId id)1501 uint32_t RSRenderServiceConnectionProxy::GetRealtimeRefreshRate(ScreenId id)
1502 {
1503 MessageParcel data;
1504 MessageParcel reply;
1505 MessageOption option;
1506
1507 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1508 ROSEN_LOGE("GetRealtimeRefreshRate: WriteInterfaceToken GetDescriptor err.");
1509 return SUCCESS;
1510 }
1511 option.SetFlags(MessageOption::TF_SYNC);
1512 if (!data.WriteUint64(id)) {
1513 ROSEN_LOGE("GetRealtimeRefreshRate: WriteUint64 id err.");
1514 return SUCCESS;
1515 }
1516 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_REALTIME_REFRESH_RATE);
1517 int32_t err = SendRequest(code, data, reply, option);
1518 if (err != NO_ERROR) {
1519 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
1520 return SUCCESS;
1521 }
1522 uint32_t rate{0};
1523 if (!reply.ReadUint32(rate)) {
1524 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetRealtimeRefreshRate Read rate failed");
1525 return READ_PARCEL_ERR;
1526 }
1527 return rate;
1528 }
1529
GetRefreshInfo(pid_t pid,std::string & enable)1530 ErrCode RSRenderServiceConnectionProxy::GetRefreshInfo(pid_t pid, std::string& enable)
1531 {
1532 MessageParcel data;
1533 MessageParcel reply;
1534 MessageOption option;
1535
1536 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1537 ROSEN_LOGE("GetRefreshInfo: WriteInterfaceToken GetDescriptor err.");
1538 enable = "";
1539 return ERR_INVALID_VALUE;
1540 }
1541 option.SetFlags(MessageOption::TF_SYNC);
1542 if (!data.WriteInt32(pid)) {
1543 ROSEN_LOGE("GetRefreshInfo: WriteInt32 pid err.");
1544 enable = "";
1545 return ERR_INVALID_VALUE;
1546 }
1547 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO);
1548 int32_t err = SendRequest(code, data, reply, option);
1549 if (err != NO_ERROR) {
1550 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
1551 enable = "";
1552 return ERR_INVALID_VALUE;
1553 }
1554
1555 if (!reply.ReadString(enable)) {
1556 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetRefreshInfo Read enable failed");
1557 return ERR_INVALID_VALUE;
1558 }
1559 return ERR_OK;
1560 }
1561
GetRefreshInfoToSP(NodeId id,std::string & enable)1562 ErrCode RSRenderServiceConnectionProxy::GetRefreshInfoToSP(NodeId id, std::string& enable)
1563 {
1564 MessageParcel data;
1565 MessageParcel reply;
1566 MessageOption option;
1567
1568 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1569 ROSEN_LOGE("GetRefreshInfoToSP: WriteInterfaceToken GetDescriptor err.");
1570 enable = "";
1571 return ERR_INVALID_VALUE;
1572 }
1573 option.SetFlags(MessageOption::TF_SYNC);
1574 if (!data.WriteUint64(id)) {
1575 ROSEN_LOGE("GetRefreshInfoToSP: WriteUint64 id err.");
1576 enable = "";
1577 return ERR_INVALID_VALUE;
1578 }
1579 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO_TO_SP);
1580 int32_t err = SendRequest(code, data, reply, option);
1581 if (err != NO_ERROR) {
1582 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
1583 enable = "";
1584 return ERR_INVALID_VALUE;
1585 }
1586
1587 if (!reply.ReadString(enable)) {
1588 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetRefreshInfo Read enable failed");
1589 return ERR_INVALID_VALUE;
1590 }
1591 return ERR_OK;
1592 }
1593
SetPhysicalScreenResolution(ScreenId id,uint32_t width,uint32_t height)1594 int32_t RSRenderServiceConnectionProxy::SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height)
1595 {
1596 MessageParcel data;
1597 MessageParcel reply;
1598 MessageOption option(MessageOption::TF_SYNC);
1599 if (!data.WriteInterfaceToken(GetDescriptor())) {
1600 ROSEN_LOGE("SetPhysicalScreenResolution: WriteInterfaceToken GetDescriptor err.");
1601 return WRITE_PARCEL_ERR;
1602 }
1603 if (!data.WriteUint64(id)) {
1604 ROSEN_LOGE("SetPhysicalScreenResolution: WriteUint64 id err.");
1605 return WRITE_PARCEL_ERR;
1606 }
1607 if (!data.WriteUint32(width)) {
1608 ROSEN_LOGE("SetPhysicalScreenResolution: WriteUint32 width err.");
1609 return WRITE_PARCEL_ERR;
1610 }
1611 if (!data.WriteUint32(height)) {
1612 ROSEN_LOGE("SetPhysicalScreenResolution: WriteUint32 height err.");
1613 return WRITE_PARCEL_ERR;
1614 }
1615 auto code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_PHYSICAL_SCREEN_RESOLUTION);
1616 if (SendRequest(code, data, reply, option) != ERR_NONE) {
1617 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetPhysicalScreenResolution: SendRequest error.");
1618 return RS_CONNECTION_ERROR;
1619 }
1620 int32_t status{0};
1621 if (!reply.ReadInt32(status)) {
1622 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetPhysicalScreenResolution Read status failed");
1623 return READ_PARCEL_ERR;
1624 }
1625 return status;
1626 }
1627
SetVirtualScreenResolution(ScreenId id,uint32_t width,uint32_t height)1628 int32_t RSRenderServiceConnectionProxy::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height)
1629 {
1630 MessageParcel data;
1631 MessageParcel reply;
1632 MessageOption option;
1633
1634 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1635 ROSEN_LOGE("SetVirtualScreenResolution: WriteInterfaceToken GetDescriptor err.");
1636 return WRITE_PARCEL_ERR;
1637 }
1638 option.SetFlags(MessageOption::TF_SYNC);
1639 if (!data.WriteUint64(id)) {
1640 ROSEN_LOGE("SetVirtualScreenResolution: WriteUint64 id err.");
1641 return WRITE_PARCEL_ERR;
1642 }
1643 if (!data.WriteUint32(width)) {
1644 ROSEN_LOGE("SetVirtualScreenResolution: WriteUint32 width err.");
1645 return WRITE_PARCEL_ERR;
1646 }
1647 if (!data.WriteUint32(height)) {
1648 ROSEN_LOGE("SetVirtualScreenResolution: WriteUint32 height err.");
1649 return WRITE_PARCEL_ERR;
1650 }
1651 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_RESOLUTION);
1652 int32_t err = SendRequest(code, data, reply, option);
1653 if (err != NO_ERROR) {
1654 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenResolution: Send Request err.");
1655 return RS_CONNECTION_ERROR;
1656 }
1657 int32_t status{0};
1658 if (!reply.ReadInt32(status)) {
1659 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenResolution Read status failed");
1660 return READ_PARCEL_ERR;
1661 }
1662 return status;
1663 }
1664
MarkPowerOffNeedProcessOneFrame()1665 ErrCode RSRenderServiceConnectionProxy::MarkPowerOffNeedProcessOneFrame()
1666 {
1667 MessageParcel data;
1668 MessageParcel reply;
1669 MessageOption option;
1670
1671 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1672 ROSEN_LOGE("RSRenderServiceConnectionProxy::MarkPowerOffNeedProcessOneFrame: Send Request err.");
1673 return ERR_INVALID_VALUE;
1674 }
1675 option.SetFlags(MessageOption::TF_SYNC);
1676 uint32_t code =
1677 static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::MARK_POWER_OFF_NEED_PROCESS_ONE_FRAME);
1678 int32_t err = SendRequest(code, data, reply, option);
1679 return err != NO_ERROR ? ERR_INVALID_VALUE : ERR_OK;
1680 }
1681
RepaintEverything()1682 ErrCode RSRenderServiceConnectionProxy::RepaintEverything()
1683 {
1684 MessageParcel data;
1685 MessageParcel reply;
1686 MessageOption option;
1687
1688 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1689 ROSEN_LOGE("RSRenderServiceConnectionProxy::RepaintEverything: Send Request err.");
1690 return ERR_INVALID_VALUE;
1691 }
1692 option.SetFlags(MessageOption::TF_SYNC);
1693 uint32_t code =
1694 static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPAINT_EVERYTHING);
1695 int32_t err = SendRequest(code, data, reply, option);
1696 if (err != NO_ERROR) {
1697 return ERR_INVALID_VALUE;
1698 }
1699 return ERR_OK;
1700 }
1701
ForceRefreshOneFrameWithNextVSync()1702 ErrCode RSRenderServiceConnectionProxy::ForceRefreshOneFrameWithNextVSync()
1703 {
1704 MessageParcel data;
1705 MessageParcel reply;
1706 MessageOption option;
1707
1708 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1709 ROSEN_LOGE("RSRenderServiceConnectionProxy::ForceRefreshOneFrameWithNextVSync: Send Request err.");
1710 return ERR_INVALID_VALUE;
1711 }
1712 option.SetFlags(MessageOption::TF_SYNC);
1713 uint32_t code =
1714 static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::FORCE_REFRESH_ONE_FRAME_WITH_NEXT_VSYNC);
1715 int32_t err = SendRequest(code, data, reply, option);
1716 if (err != NO_ERROR) {
1717 return ERR_INVALID_VALUE;
1718 }
1719 return ERR_OK;
1720 }
1721
DisablePowerOffRenderControl(ScreenId id)1722 void RSRenderServiceConnectionProxy::DisablePowerOffRenderControl(ScreenId id)
1723 {
1724 MessageParcel data;
1725 MessageParcel reply;
1726 MessageOption option;
1727
1728 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1729 ROSEN_LOGE("DisablePowerOffRenderControl: WriteInterfaceToken GetDescriptor err.");
1730 return;
1731 }
1732 option.SetFlags(MessageOption::TF_SYNC);
1733 if (!data.WriteUint64(id)) {
1734 ROSEN_LOGE("DisablePowerOffRenderControl: WriteUint64 id err.");
1735 return;
1736 }
1737 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::DISABLE_RENDER_CONTROL_SCREEN);
1738 int32_t err = SendRequest(code, data, reply, option);
1739 if (err != NO_ERROR) {
1740 return;
1741 }
1742 }
1743
SetScreenPowerStatus(ScreenId id,ScreenPowerStatus status)1744 void RSRenderServiceConnectionProxy::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status)
1745 {
1746 MessageParcel data;
1747 MessageParcel reply;
1748 MessageOption option;
1749
1750 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1751 ROSEN_LOGE("SetScreenPowerStatus: WriteInterfaceToken GetDescriptor err.");
1752 return;
1753 }
1754 option.SetFlags(MessageOption::TF_SYNC);
1755 if (!data.WriteUint64(id)) {
1756 ROSEN_LOGE("SetScreenPowerStatus: WriteUint64 id err.");
1757 return;
1758 }
1759 if (!data.WriteUint32(static_cast<uint32_t>(status))) {
1760 ROSEN_LOGE("SetScreenPowerStatus: WriteUint32 status err.");
1761 return;
1762 }
1763 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_POWER_STATUS);
1764 int32_t err = SendRequest(code, data, reply, option);
1765 if (err != NO_ERROR) {
1766 ROSEN_LOGE("SetScreenPowerStatus: SendRequest failed %{public}d", err);
1767 return;
1768 }
1769 }
1770
RegisterApplicationAgent(uint32_t pid,sptr<IApplicationAgent> app)1771 ErrCode RSRenderServiceConnectionProxy::RegisterApplicationAgent(uint32_t pid, sptr<IApplicationAgent> app)
1772 {
1773 if (app == nullptr) {
1774 ROSEN_LOGE("%{public}s callback == nullptr", __func__);
1775 return ERR_INVALID_VALUE;
1776 }
1777
1778 MessageParcel data;
1779 MessageParcel reply;
1780 MessageOption option;
1781 option.SetFlags(MessageOption::TF_ASYNC);
1782 if (!data.WriteRemoteObject(app->AsObject())) {
1783 ROSEN_LOGE("%{public}s WriteRemoteObject failed", __func__);
1784 return ERR_INVALID_VALUE;
1785 }
1786 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_APPLICATION_AGENT);
1787 int32_t err = SendRequest(code, data, reply, option);
1788 if (err != NO_ERROR) {
1789 ROSEN_LOGE("%{public}s SendRequest() error[%{public}d]", __func__, err);
1790 return ERR_INVALID_VALUE;
1791 }
1792 return ERR_OK;
1793 }
1794
TakeSurfaceCapture(NodeId id,sptr<RSISurfaceCaptureCallback> callback,const RSSurfaceCaptureConfig & captureConfig,const RSSurfaceCaptureBlurParam & blurParam,const Drawing::Rect & specifiedAreaRect,RSSurfaceCapturePermissions)1795 void RSRenderServiceConnectionProxy::TakeSurfaceCapture(NodeId id, sptr<RSISurfaceCaptureCallback> callback,
1796 const RSSurfaceCaptureConfig& captureConfig, const RSSurfaceCaptureBlurParam& blurParam,
1797 const Drawing::Rect& specifiedAreaRect, RSSurfaceCapturePermissions /* permissions */)
1798 {
1799 if (callback == nullptr) {
1800 ROSEN_LOGE("%{public}s callback == nullptr", __func__);
1801 return;
1802 }
1803
1804 MessageParcel data;
1805 MessageParcel reply;
1806 MessageOption option;
1807 option.SetFlags(MessageOption::TF_ASYNC);
1808 if (!data.WriteUint64(id)) {
1809 ROSEN_LOGE("%{public}s write id failed", __func__);
1810 return;
1811 }
1812 if (!data.WriteRemoteObject(callback->AsObject())) {
1813 ROSEN_LOGE("%{public}s write callback failed", __func__);
1814 return;
1815 }
1816 if (!WriteSurfaceCaptureConfig(captureConfig, data)) {
1817 ROSEN_LOGE("%{public}s write captureConfig failed", __func__);
1818 return;
1819 }
1820 if (!WriteSurfaceCaptureBlurParam(blurParam, data)) {
1821 ROSEN_LOGE("%{public}s write blurParam failed", __func__);
1822 return;
1823 }
1824 if (!WriteSurfaceCaptureAreaRect(specifiedAreaRect, data)) {
1825 ROSEN_LOGE("%{public}s write specifiedAreaRect failed", __func__);
1826 return;
1827 }
1828
1829 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::TAKE_SURFACE_CAPTURE);
1830 int32_t err = SendRequest(code, data, reply, option);
1831 if (err != NO_ERROR) {
1832 ROSEN_LOGE("%{public}s SendRequest() error[%{public}d]", __func__, err);
1833 return;
1834 }
1835 }
1836
TakeSurfaceCaptureSoloNode(NodeId id,const RSSurfaceCaptureConfig & captureConfig,RSSurfaceCapturePermissions)1837 std::vector<std::pair<NodeId, std::shared_ptr<Media::PixelMap>>> RSRenderServiceConnectionProxy::TakeSurfaceCaptureSoloNode(
1838 NodeId id, const RSSurfaceCaptureConfig& captureConfig, RSSurfaceCapturePermissions)
1839 {
1840 MessageParcel data;
1841 MessageParcel reply;
1842 MessageOption option;
1843 std::vector<std::pair<NodeId, std::shared_ptr<Media::PixelMap>>> pixelMapIdPairVector;
1844 option.SetFlags(MessageOption::TF_SYNC);
1845 if (!data.WriteUint64(id)) {
1846 ROSEN_LOGE("%{public}s write id failed", __func__);
1847 return pixelMapIdPairVector;
1848 }
1849 if (!WriteSurfaceCaptureConfig(captureConfig, data)) {
1850 ROSEN_LOGE("%{public}s write captureConfig failed", __func__);
1851 return pixelMapIdPairVector;
1852 }
1853 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::TAKE_SURFACE_CAPTURE_SOLO);
1854 int32_t err = SendRequest(code, data, reply, option);
1855 if (err != NO_ERROR) {
1856 ROSEN_LOGE("%{public}s SendRequest() error[%{public}d]", __func__, err);
1857 return pixelMapIdPairVector;
1858 }
1859 if (!RSMarshallingHelper::Unmarshalling(reply, pixelMapIdPairVector)) {
1860 ROSEN_LOGE("RSRenderServiceConnectionProxy::TakeSurfaceCaptureSoloNode Unmarshalling failed");
1861 }
1862 return pixelMapIdPairVector;
1863 }
1864
TakeSelfSurfaceCapture(NodeId id,sptr<RSISurfaceCaptureCallback> callback,const RSSurfaceCaptureConfig & captureConfig)1865 void RSRenderServiceConnectionProxy::TakeSelfSurfaceCapture(NodeId id, sptr<RSISurfaceCaptureCallback> callback,
1866 const RSSurfaceCaptureConfig& captureConfig)
1867 {
1868 if (callback == nullptr) {
1869 ROSEN_LOGE("%{public}s callback == nullptr", __func__);
1870 return;
1871 }
1872
1873 MessageParcel data;
1874 MessageParcel reply;
1875 MessageOption option;
1876 option.SetFlags(MessageOption::TF_ASYNC);
1877 if (!data.WriteUint64(id)) {
1878 ROSEN_LOGE("%{public}s write id failed", __func__);
1879 return;
1880 }
1881 if (!data.WriteRemoteObject(callback->AsObject())) {
1882 ROSEN_LOGE("%{public}s write callback failed", __func__);
1883 return;
1884 }
1885 if (!WriteSurfaceCaptureConfig(captureConfig, data)) {
1886 ROSEN_LOGE("%{public}s write captureConfig failed", __func__);
1887 return;
1888 }
1889 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::TAKE_SELF_SURFACE_CAPTURE);
1890 int32_t err = SendRequest(code, data, reply, option);
1891 if (err != NO_ERROR) {
1892 ROSEN_LOGE("%{public}s SendRequest() error[%{public}d]", __func__, err);
1893 return;
1894 }
1895 }
1896
SetWindowFreezeImmediately(NodeId id,bool isFreeze,sptr<RSISurfaceCaptureCallback> callback,const RSSurfaceCaptureConfig & captureConfig,const RSSurfaceCaptureBlurParam & blurParam)1897 ErrCode RSRenderServiceConnectionProxy::SetWindowFreezeImmediately(NodeId id, bool isFreeze,
1898 sptr<RSISurfaceCaptureCallback> callback, const RSSurfaceCaptureConfig& captureConfig,
1899 const RSSurfaceCaptureBlurParam& blurParam)
1900 {
1901 MessageParcel data;
1902 MessageParcel reply;
1903 MessageOption option;
1904 option.SetFlags(MessageOption::TF_ASYNC);
1905 if (!data.WriteUint64(id)) {
1906 ROSEN_LOGE("%{public}s write id failed", __func__);
1907 return ERR_INVALID_VALUE;
1908 }
1909 if (!data.WriteBool(isFreeze)) {
1910 ROSEN_LOGE("%{public}s write isFreeze failed", __func__);
1911 return ERR_INVALID_VALUE;
1912 }
1913 if (isFreeze) {
1914 if (callback == nullptr) {
1915 ROSEN_LOGE("%{public}s callback == nullptr", __func__);
1916 return ERR_INVALID_VALUE;
1917 }
1918 if (!data.WriteRemoteObject(callback->AsObject())) {
1919 ROSEN_LOGE("%{public}s write callback failed", __func__);
1920 return ERR_INVALID_VALUE;
1921 }
1922 if (!WriteSurfaceCaptureConfig(captureConfig, data)) {
1923 ROSEN_LOGE("%{public}s write captureConfig failed", __func__);
1924 return ERR_INVALID_VALUE;
1925 }
1926 if (!WriteSurfaceCaptureBlurParam(blurParam, data)) {
1927 ROSEN_LOGE("%{public}s write blurParam failed", __func__);
1928 return ERR_INVALID_VALUE;
1929 }
1930 }
1931
1932 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_WINDOW_FREEZE_IMMEDIATELY);
1933 int32_t err = SendRequest(code, data, reply, option);
1934 if (err != NO_ERROR) {
1935 ROSEN_LOGE("%{public}s SendRequest() error[%{public}d]", __func__, err);
1936 return ERR_INVALID_VALUE;
1937 }
1938 return ERR_OK;
1939 }
1940
TaskSurfaceCaptureWithAllWindows(NodeId id,sptr<RSISurfaceCaptureCallback> callback,const RSSurfaceCaptureConfig & captureConfig,bool checkDrmAndSurfaceLock,RSSurfaceCapturePermissions)1941 ErrCode RSRenderServiceConnectionProxy::TaskSurfaceCaptureWithAllWindows(NodeId id,
1942 sptr<RSISurfaceCaptureCallback> callback, const RSSurfaceCaptureConfig& captureConfig,
1943 bool checkDrmAndSurfaceLock, RSSurfaceCapturePermissions /*permissions*/)
1944 {
1945 MessageParcel data;
1946 MessageParcel reply;
1947 MessageOption option;
1948 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1949 ROSEN_LOGE("%{public}s GetDescriptor err", __func__);
1950 return ERR_INVALID_VALUE;
1951 }
1952 option.SetFlags(MessageOption::TF_ASYNC);
1953 if (!data.WriteUint64(id)) {
1954 ROSEN_LOGE("%{public}s write id failed", __func__);
1955 return ERR_INVALID_VALUE;
1956 }
1957 if (!data.WriteBool(checkDrmAndSurfaceLock)) {
1958 ROSEN_LOGE("%{public}s write checkDrmAndSurfaceLock failed", __func__);
1959 return ERR_INVALID_VALUE;
1960 }
1961 if (callback == nullptr) {
1962 ROSEN_LOGE("%{public}s callback == nullptr", __func__);
1963 return ERR_INVALID_VALUE;
1964 }
1965 if (!data.WriteRemoteObject(callback->AsObject())) {
1966 ROSEN_LOGE("%{public}s write callback failed", __func__);
1967 return ERR_INVALID_VALUE;
1968 }
1969 if (!WriteSurfaceCaptureConfig(captureConfig, data)) {
1970 ROSEN_LOGE("%{public}s write captureConfig failed", __func__);
1971 return ERR_INVALID_VALUE;
1972 }
1973 uint32_t code = static_cast<uint32_t>(
1974 RSIRenderServiceConnectionInterfaceCode::TAKE_SURFACE_CAPTURE_WITH_ALL_WINDOWS);
1975 int32_t err = SendRequest(code, data, reply, option);
1976 if (err != NO_ERROR) {
1977 ROSEN_LOGE("%{public}s SendRequest() error[%{public}d]", __func__, err);
1978 return ERR_INVALID_VALUE;
1979 }
1980 return ERR_OK;
1981 }
1982
FreezeScreen(NodeId id,bool isFreeze)1983 ErrCode RSRenderServiceConnectionProxy::FreezeScreen(NodeId id, bool isFreeze)
1984 {
1985 MessageParcel data;
1986 MessageParcel reply;
1987 MessageOption option;
1988 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1989 ROSEN_LOGE("%{public}s GetDescriptor err", __func__);
1990 return ERR_INVALID_VALUE;
1991 }
1992 option.SetFlags(MessageOption::TF_ASYNC);
1993 if (!data.WriteUint64(id)) {
1994 ROSEN_LOGE("%{public}s write id failed", __func__);
1995 return ERR_INVALID_VALUE;
1996 }
1997 if (!data.WriteBool(isFreeze)) {
1998 ROSEN_LOGE("%{public}s write isFreeze failed", __func__);
1999 return ERR_INVALID_VALUE;
2000 }
2001
2002 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::FREEZE_SCREEN);
2003 int32_t err = SendRequest(code, data, reply, option);
2004 if (err != NO_ERROR) {
2005 ROSEN_LOGE("%{public}s SendRequest() error[%{public}d]", __func__, err);
2006 return ERR_INVALID_VALUE;
2007 }
2008 return ERR_OK;
2009 }
2010
TakeUICaptureInRange(NodeId id,sptr<RSISurfaceCaptureCallback> callback,const RSSurfaceCaptureConfig & captureConfig)2011 void RSRenderServiceConnectionProxy::TakeUICaptureInRange(
2012 NodeId id, sptr<RSISurfaceCaptureCallback> callback, const RSSurfaceCaptureConfig& captureConfig)
2013 {
2014 if (callback == nullptr) {
2015 ROSEN_LOGE("%{public}s callback == nullptr", __func__);
2016 return;
2017 }
2018
2019 MessageParcel data;
2020 MessageParcel reply;
2021 MessageOption option;
2022 option.SetFlags(MessageOption::TF_ASYNC);
2023 if (!data.WriteUint64(id)) {
2024 ROSEN_LOGE("%{public}s write id failed", __func__);
2025 return;
2026 }
2027 if (!data.WriteRemoteObject(callback->AsObject())) {
2028 ROSEN_LOGE("%{public}s write callback failed", __func__);
2029 return;
2030 }
2031 if (!WriteSurfaceCaptureConfig(captureConfig, data)) {
2032 ROSEN_LOGE("%{public}s write captureConfig failed", __func__);
2033 return;
2034 }
2035 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::TAKE_UI_CAPTURE_IN_RANGE);
2036 int32_t err = SendRequest(code, data, reply, option);
2037 if (err != NO_ERROR) {
2038 ROSEN_LOGE("%{public}s SendRequest() error[%{public}d]", __func__, err);
2039 return;
2040 }
2041 }
2042
WriteSurfaceCaptureConfig(const RSSurfaceCaptureConfig & captureConfig,MessageParcel & data)2043 bool RSRenderServiceConnectionProxy::WriteSurfaceCaptureConfig(
2044 const RSSurfaceCaptureConfig& captureConfig, MessageParcel& data)
2045 {
2046 if (!data.WriteFloat(captureConfig.scaleX) || !data.WriteFloat(captureConfig.scaleY) ||
2047 !data.WriteBool(captureConfig.useDma) || !data.WriteBool(captureConfig.useCurWindow) ||
2048 !data.WriteUint8(static_cast<uint8_t>(captureConfig.captureType)) || !data.WriteBool(captureConfig.isSync) ||
2049 !data.WriteBool(captureConfig.isHdrCapture) ||
2050 !data.WriteBool(captureConfig.needF16WindowCaptureForScRGB) ||
2051 !data.WriteFloat(captureConfig.mainScreenRect.left_) ||
2052 !data.WriteFloat(captureConfig.mainScreenRect.top_) ||
2053 !data.WriteFloat(captureConfig.mainScreenRect.right_) ||
2054 !data.WriteFloat(captureConfig.mainScreenRect.bottom_) ||
2055 !data.WriteUint64(captureConfig.uiCaptureInRangeParam.endNodeId) ||
2056 !data.WriteBool(captureConfig.uiCaptureInRangeParam.useBeginNodeSize) ||
2057 !data.WriteFloat(captureConfig.specifiedAreaRect.left_) ||
2058 !data.WriteFloat(captureConfig.specifiedAreaRect.top_) ||
2059 !data.WriteFloat(captureConfig.specifiedAreaRect.right_) ||
2060 !data.WriteFloat(captureConfig.specifiedAreaRect.bottom_) ||
2061 !data.WriteUInt64Vector(captureConfig.blackList) ||
2062 !data.WriteUint32(captureConfig.backGroundColor)) {
2063 ROSEN_LOGE("WriteSurfaceCaptureConfig: WriteSurfaceCaptureConfig captureConfig err.");
2064 return false;
2065 }
2066 return true;
2067 }
2068
WriteSurfaceCaptureBlurParam(const RSSurfaceCaptureBlurParam & blurParam,MessageParcel & data)2069 bool RSRenderServiceConnectionProxy::WriteSurfaceCaptureBlurParam(
2070 const RSSurfaceCaptureBlurParam& blurParam, MessageParcel& data)
2071 {
2072 if (!data.WriteBool(blurParam.isNeedBlur) || !data.WriteFloat(blurParam.blurRadius)) {
2073 ROSEN_LOGE("WriteSurfaceCaptureBlurParam: WriteBool OR WriteFloat [blurParam] err.");
2074 return false;
2075 }
2076 return true;
2077 }
2078
WriteSurfaceCaptureAreaRect(const Drawing::Rect & specifiedAreaRect,MessageParcel & data)2079 bool RSRenderServiceConnectionProxy::WriteSurfaceCaptureAreaRect(
2080 const Drawing::Rect& specifiedAreaRect, MessageParcel& data)
2081 {
2082 if (!data.WriteFloat(specifiedAreaRect.left_) || !data.WriteFloat(specifiedAreaRect.top_) ||
2083 !data.WriteFloat(specifiedAreaRect.right_) || !data.WriteFloat(specifiedAreaRect.bottom_)) {
2084 ROSEN_LOGE("WriteSurfaceCaptureAreaRect: WriteFloat specifiedAreaRect err.");
2085 return false;
2086 }
2087 return true;
2088 }
2089
SetHwcNodeBounds(int64_t rsNodeId,float positionX,float positionY,float positionZ,float positionW)2090 ErrCode RSRenderServiceConnectionProxy::SetHwcNodeBounds(int64_t rsNodeId, float positionX, float positionY,
2091 float positionZ, float positionW)
2092 {
2093 MessageParcel data;
2094 MessageParcel reply;
2095 MessageOption option;
2096 option.SetFlags(MessageOption::TF_ASYNC);
2097 if (!data.WriteUint64(rsNodeId)) {
2098 ROSEN_LOGE("SetHwcNodeBounds write id failed");
2099 return ERR_INVALID_VALUE;
2100 }
2101 if (!data.WriteFloat(positionX) || !data.WriteFloat(positionY) || !data.WriteFloat(positionZ) ||
2102 !data.WriteFloat(positionW)) {
2103 ROSEN_LOGE("SetHwcNodeBounds write bound failed");
2104 return ERR_INVALID_VALUE;
2105 }
2106 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_POSITION);
2107 int32_t err = SendRequest(code, data, reply, option);
2108 if (err != NO_ERROR) {
2109 ROSEN_LOGE("SetHwcNodeBounds SendRequest() error[%{public}d]", err);
2110 return ERR_INVALID_VALUE;
2111 }
2112 return ERR_OK;
2113 }
2114
GetVirtualScreenResolution(ScreenId id)2115 RSVirtualScreenResolution RSRenderServiceConnectionProxy::GetVirtualScreenResolution(ScreenId id)
2116 {
2117 MessageParcel data;
2118 MessageParcel reply;
2119 MessageOption option;
2120 RSVirtualScreenResolution virtualScreenResolution;
2121
2122 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2123 ROSEN_LOGE("GetVirtualScreenResolution: WriteInterfaceToken GetDescriptor err.");
2124 return virtualScreenResolution;
2125 }
2126 option.SetFlags(MessageOption::TF_SYNC);
2127 if (!data.WriteUint64(id)) {
2128 ROSEN_LOGE("GetVirtualScreenResolution: WriteUint64 id err.");
2129 return virtualScreenResolution;
2130 }
2131 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_VIRTUAL_SCREEN_RESOLUTION);
2132 int32_t err = SendRequest(code, data, reply, option);
2133 if (err != NO_ERROR) {
2134 return virtualScreenResolution;
2135 }
2136
2137 sptr<RSVirtualScreenResolution> pVirtualScreenResolution(reply.ReadParcelable<RSVirtualScreenResolution>());
2138 if (pVirtualScreenResolution == nullptr) {
2139 return virtualScreenResolution;
2140 }
2141 virtualScreenResolution = *pVirtualScreenResolution;
2142 return virtualScreenResolution;
2143 }
2144
GetScreenActiveMode(uint64_t id,RSScreenModeInfo & screenModeInfo)2145 ErrCode RSRenderServiceConnectionProxy::GetScreenActiveMode(uint64_t id, RSScreenModeInfo& screenModeInfo)
2146 {
2147 MessageParcel data;
2148 MessageParcel reply;
2149 MessageOption option;
2150
2151 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2152 ROSEN_LOGE("GetScreenActiveMode: WriteInterfaceToken GetDescriptor err.");
2153 return ERR_INVALID_VALUE;
2154 }
2155 option.SetFlags(MessageOption::TF_SYNC);
2156 if (!data.WriteUint64(id)) {
2157 ROSEN_LOGE("GetScreenActiveMode: WriteUint64 id err.");
2158 return ERR_INVALID_VALUE;
2159 }
2160 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_ACTIVE_MODE);
2161 int32_t err = SendRequest(code, data, reply, option);
2162 if (err != NO_ERROR) {
2163 ROSEN_LOGE("%{public}s: sendrequest error : %{public}d", __func__, err);
2164 return ERR_INVALID_VALUE;
2165 }
2166
2167 sptr<RSScreenModeInfo> pScreenModeInfo(reply.ReadParcelable<RSScreenModeInfo>());
2168 if (pScreenModeInfo == nullptr) {
2169 ROSEN_LOGE("%{public}s: ScreenModeInfo is null", __func__);
2170 return ERR_INVALID_VALUE;
2171 }
2172 screenModeInfo = *pScreenModeInfo;
2173 return ERR_OK;
2174 }
2175
GetScreenSupportedModes(ScreenId id)2176 std::vector<RSScreenModeInfo> RSRenderServiceConnectionProxy::GetScreenSupportedModes(ScreenId id)
2177 {
2178 MessageParcel data;
2179 MessageParcel reply;
2180 MessageOption option;
2181 std::vector<RSScreenModeInfo> screenSupportedModes;
2182
2183 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2184 ROSEN_LOGE("GetScreenSupportedModes: WriteInterfaceToken GetDescriptor err.");
2185 return screenSupportedModes;
2186 }
2187
2188 option.SetFlags(MessageOption::TF_SYNC);
2189 if (!data.WriteUint64(id)) {
2190 ROSEN_LOGE("GetScreenSupportedModes: WriteUint64 id err.");
2191 return screenSupportedModes;
2192 }
2193 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_MODES);
2194 int32_t err = SendRequest(code, data, reply, option);
2195 if (err != NO_ERROR) {
2196 return screenSupportedModes;
2197 }
2198
2199 uint64_t modeCount{0};
2200 if (!reply.ReadUint64(modeCount)) {
2201 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenSupportedModes Read modeCount failed");
2202 return screenSupportedModes;
2203 }
2204 size_t readableSize = reply.GetReadableBytes();
2205 size_t len = static_cast<size_t>(modeCount);
2206 if (len > readableSize || len > screenSupportedModes.max_size()) {
2207 RS_LOGE("RSRenderServiceConnectionProxy GetScreenSupportedModes Fail read vector, size:%{public}zu,"
2208 "readableSize:%{public}zu", len, readableSize);
2209 return screenSupportedModes;
2210 }
2211 screenSupportedModes.resize(modeCount);
2212 for (uint64_t modeIndex = 0; modeIndex < modeCount; modeIndex++) {
2213 sptr<RSScreenModeInfo> itemScreenMode = reply.ReadParcelable<RSScreenModeInfo>();
2214 if (itemScreenMode == nullptr) {
2215 continue;
2216 } else {
2217 screenSupportedModes[modeIndex] = *itemScreenMode;
2218 }
2219 }
2220 return screenSupportedModes;
2221 }
2222
GetMemoryGraphics(std::vector<MemoryGraphic> & memoryGraphics)2223 ErrCode RSRenderServiceConnectionProxy::GetMemoryGraphics(std::vector<MemoryGraphic>& memoryGraphics)
2224 {
2225 MessageParcel data;
2226 MessageParcel reply;
2227 MessageOption option;
2228
2229 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2230 ROSEN_LOGE("GetMemoryGraphics: WriteInterfaceToken GetDescriptor err.");
2231 return ERR_INVALID_VALUE;
2232 }
2233
2234 option.SetFlags(MessageOption::TF_SYNC);
2235 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHICS);
2236 int32_t err = SendRequest(code, data, reply, option);
2237 if (err != NO_ERROR) {
2238 return ERR_INVALID_VALUE;
2239 }
2240
2241 uint64_t count{0};
2242 if (!reply.ReadUint64(count)) {
2243 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetMemoryGraphics Read count failed");
2244 return ERR_INVALID_VALUE;
2245 }
2246 size_t readableSize = reply.GetReadableBytes();
2247 size_t len = static_cast<size_t>(count);
2248 if (len > readableSize || len > memoryGraphics.max_size()) {
2249 RS_LOGE("RSRenderServiceConnectionProxy GetMemoryGraphics Failed to read vector, size:%{public}zu,"
2250 " readableSize:%{public}zu", len, readableSize);
2251 return ERR_INVALID_VALUE;
2252 }
2253 memoryGraphics.resize(count);
2254 for (uint64_t index = 0; index < count; index++) {
2255 sptr<MemoryGraphic> item = reply.ReadParcelable<MemoryGraphic>();
2256 if (item == nullptr) {
2257 continue;
2258 } else {
2259 memoryGraphics[index] = *item;
2260 }
2261 }
2262 return ERR_OK;
2263 }
2264
GetTotalAppMemSize(float & cpuMemSize,float & gpuMemSize)2265 ErrCode RSRenderServiceConnectionProxy::GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize)
2266 {
2267 MessageParcel data;
2268 MessageParcel reply;
2269 MessageOption option;
2270 MemoryGraphic memoryGraphic;
2271 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2272 ROSEN_LOGE("GetTotalAppMemSize: WriteInterfaceToken GetDescriptor err.");
2273 return ERR_INVALID_VALUE;
2274 }
2275
2276 option.SetFlags(MessageOption::TF_SYNC);
2277 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_TOTAL_APP_MEM_SIZE);
2278 int32_t err = SendRequest(code, data, reply, option);
2279 if (err != NO_ERROR) {
2280 return ERR_INVALID_VALUE;
2281 }
2282
2283 if (!reply.ReadFloat(cpuMemSize) || !reply.ReadFloat(gpuMemSize)) {
2284 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetTotalAppMemSize Read MemSize failed");
2285 return READ_PARCEL_ERR;
2286 }
2287 return ERR_OK;
2288 }
2289
GetMemoryGraphic(int pid,MemoryGraphic & memoryGraphic)2290 ErrCode RSRenderServiceConnectionProxy::GetMemoryGraphic(int pid, MemoryGraphic& memoryGraphic)
2291 {
2292 MessageParcel data;
2293 MessageParcel reply;
2294 MessageOption option;
2295 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2296 ROSEN_LOGE("GetMemoryGraphic: WriteInterfaceToken GetDescriptor err.");
2297 return ERR_INVALID_VALUE;
2298 }
2299
2300 option.SetFlags(MessageOption::TF_SYNC);
2301 if (!data.WriteInt32(pid)) {
2302 ROSEN_LOGE("GetMemoryGraphic: WriteInt32 pid err.");
2303 return ERR_INVALID_VALUE;
2304 }
2305 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHIC);
2306 int32_t err = SendRequest(code, data, reply, option);
2307 if (err != NO_ERROR) {
2308 return ERR_INVALID_VALUE;
2309 }
2310 sptr<MemoryGraphic> pMemoryGraphic(reply.ReadParcelable<MemoryGraphic>());
2311 if (pMemoryGraphic == nullptr) {
2312 return ERR_INVALID_VALUE;
2313 }
2314 memoryGraphic = *pMemoryGraphic;
2315 return ERR_OK;
2316 }
2317
GetScreenCapability(ScreenId id)2318 RSScreenCapability RSRenderServiceConnectionProxy::GetScreenCapability(ScreenId id)
2319 {
2320 MessageParcel data;
2321 MessageParcel reply;
2322 MessageOption option;
2323 RSScreenCapability screenCapability;
2324 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2325 ROSEN_LOGE("GetScreenCapability: WriteInterfaceToken GetDescriptor err.");
2326 return screenCapability;
2327 }
2328 option.SetFlags(MessageOption::TF_SYNC);
2329 if (!data.WriteUint64(id)) {
2330 ROSEN_LOGE("GetScreenCapability: WriteUint64 id err.");
2331 return screenCapability;
2332 }
2333 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CAPABILITY);
2334 int32_t err = SendRequest(code, data, reply, option);
2335 if (err != NO_ERROR) {
2336 return screenCapability;
2337 }
2338
2339 sptr<RSScreenCapability> pScreenCapability(reply.ReadParcelable<RSScreenCapability>());
2340 if (pScreenCapability == nullptr) {
2341 return screenCapability;
2342 }
2343 screenCapability = *pScreenCapability;
2344 return screenCapability;
2345 }
2346
GetScreenPowerStatus(uint64_t screenId,uint32_t & status)2347 ErrCode RSRenderServiceConnectionProxy::GetScreenPowerStatus(uint64_t screenId, uint32_t& status)
2348 {
2349 MessageParcel data;
2350 MessageParcel reply;
2351 MessageOption option;
2352 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2353 ROSEN_LOGE("GetScreenPowerStatus: WriteInterfaceToken GetDescriptor err.");
2354 return ERR_INVALID_VALUE;
2355 }
2356 option.SetFlags(MessageOption::TF_SYNC);
2357 if (!data.WriteUint64(screenId)) {
2358 ROSEN_LOGE("GetScreenPowerStatus: WriteUint64 id err.");
2359 return ERR_INVALID_VALUE;
2360 }
2361 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_POWER_STATUS);
2362 int32_t err = SendRequest(code, data, reply, option);
2363 if (err != NO_ERROR) {
2364 return ERR_INVALID_VALUE;
2365 }
2366 status = reply.ReadUint32();
2367 return ERR_OK;
2368 }
2369
GetScreenData(ScreenId id)2370 RSScreenData RSRenderServiceConnectionProxy::GetScreenData(ScreenId id)
2371 {
2372 MessageParcel data;
2373 MessageParcel reply;
2374 MessageOption option;
2375 RSScreenData screenData;
2376 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2377 ROSEN_LOGE("GetScreenData: WriteInterfaceToken GetDescriptor err.");
2378 return screenData;
2379 }
2380 option.SetFlags(MessageOption::TF_SYNC);
2381 if (!data.WriteUint64(id)) {
2382 ROSEN_LOGE("GetScreenData: WriteUint64 id err.");
2383 return screenData;
2384 }
2385 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_DATA);
2386 int32_t err = SendRequest(code, data, reply, option);
2387 if (err != NO_ERROR) {
2388 return screenData;
2389 }
2390 sptr<RSScreenData> pScreenData(reply.ReadParcelable<RSScreenData>());
2391 if (pScreenData == nullptr) {
2392 return screenData;
2393 }
2394 screenData = *pScreenData;
2395 return screenData;
2396 }
2397
GetScreenBacklight(uint64_t id,int32_t & level)2398 ErrCode RSRenderServiceConnectionProxy::GetScreenBacklight(uint64_t id, int32_t& level)
2399 {
2400 MessageParcel data;
2401 MessageParcel reply;
2402 MessageOption option;
2403 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2404 ROSEN_LOGE("GetScreenBacklight: WriteInterfaceToken GetDescriptor err.");
2405 return ERR_INVALID_VALUE;
2406 }
2407 option.SetFlags(MessageOption::TF_SYNC);
2408 if (!data.WriteUint64(id)) {
2409 ROSEN_LOGE("GetScreenBacklight: WriteUint64 id err.");
2410 return ERR_INVALID_VALUE;
2411 }
2412 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_BACK_LIGHT);
2413 int32_t err = SendRequest(code, data, reply, option);
2414 if (err != NO_ERROR) {
2415 return ERR_INVALID_VALUE;
2416 }
2417 if (!reply.ReadInt32(level)) {
2418 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenBacklight Read level failed");
2419 return ERR_INVALID_VALUE;
2420 }
2421 return ERR_OK;
2422 }
2423
SetScreenBacklight(ScreenId id,uint32_t level)2424 void RSRenderServiceConnectionProxy::SetScreenBacklight(ScreenId id, uint32_t level)
2425 {
2426 MessageParcel data;
2427 MessageParcel reply;
2428 MessageOption option;
2429 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2430 ROSEN_LOGE("SetScreenBacklight: WriteInterfaceToken GetDescriptor err.");
2431 return;
2432 }
2433 option.SetFlags(MessageOption::TF_SYNC);
2434 if (!data.WriteUint64(id)) {
2435 ROSEN_LOGE("SetScreenBacklight: WriteUint64 id err.");
2436 return;
2437 }
2438 if (!data.WriteUint32(level)) {
2439 ROSEN_LOGE("SetScreenBacklight: WriteUint32 level err.");
2440 return;
2441 }
2442 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_BACK_LIGHT);
2443 int32_t err = SendRequest(code, data, reply, option);
2444 if (err != NO_ERROR) {
2445 ROSEN_LOGE("SetScreenBacklight: SendRequest failed");
2446 return;
2447 }
2448 }
2449
RegisterBufferClearListener(NodeId id,sptr<RSIBufferClearCallback> callback)2450 ErrCode RSRenderServiceConnectionProxy::RegisterBufferClearListener(
2451 NodeId id, sptr<RSIBufferClearCallback> callback)
2452 {
2453 if (callback == nullptr) {
2454 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferClearListener: callback is nullptr.");
2455 return ERR_INVALID_VALUE;
2456 }
2457
2458 MessageParcel data;
2459 MessageParcel reply;
2460 MessageOption option;
2461
2462 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2463 ROSEN_LOGE("RegisterBufferClearListener: WriteInterfaceToken GetDescriptor err.");
2464 return ERR_INVALID_VALUE;
2465 }
2466 option.SetFlags(MessageOption::TF_SYNC);
2467 if (!data.WriteUint64(id)) {
2468 ROSEN_LOGE("RegisterBufferClearListener: WriteUint64 id err.");
2469 return ERR_INVALID_VALUE;
2470 }
2471 if (!data.WriteRemoteObject(callback->AsObject())) {
2472 ROSEN_LOGE("RegisterBufferClearListener: WriteRemoteObject callback->AsObject() err.");
2473 return ERR_INVALID_VALUE;
2474 }
2475 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_CLEAR_LISTENER);
2476 int32_t err = SendRequest(code, data, reply, option);
2477 if (err != NO_ERROR) {
2478 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferClearListener: Send Request err.");
2479 return ERR_INVALID_VALUE;
2480 }
2481 return ERR_OK;
2482 }
2483
RegisterBufferAvailableListener(NodeId id,sptr<RSIBufferAvailableCallback> callback,bool isFromRenderThread)2484 ErrCode RSRenderServiceConnectionProxy::RegisterBufferAvailableListener(
2485 NodeId id, sptr<RSIBufferAvailableCallback> callback, bool isFromRenderThread)
2486 {
2487 if (callback == nullptr) {
2488 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferAvailableListener: callback is nullptr.");
2489 return ERR_INVALID_VALUE;
2490 }
2491
2492 MessageParcel data;
2493 MessageParcel reply;
2494 MessageOption option;
2495
2496 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2497 ROSEN_LOGE("RegisterBufferAvailableListener: WriteInterfaceToken GetDescriptor err.");
2498 return ERR_INVALID_VALUE;
2499 }
2500
2501 option.SetFlags(MessageOption::TF_SYNC);
2502 if (!data.WriteUint64(id)) {
2503 ROSEN_LOGE("RegisterBufferAvailableListener: WriteUint64 id err.");
2504 return ERR_INVALID_VALUE;
2505 }
2506 if (!data.WriteRemoteObject(callback->AsObject())) {
2507 ROSEN_LOGE("RegisterBufferAvailableListener: WriteRemoteObject callback->AsObject() err.");
2508 return ERR_INVALID_VALUE;
2509 }
2510 if (!data.WriteBool(isFromRenderThread)) {
2511 ROSEN_LOGE("RegisterBufferAvailableListener: WriteBool isFromRenderThread err.");
2512 return ERR_INVALID_VALUE;
2513 }
2514 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_AVAILABLE_LISTENER);
2515 int32_t err = SendRequest(code, data, reply, option);
2516 if (err != NO_ERROR) {
2517 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferAvailableListener: Send Request err.");
2518 return ERR_INVALID_VALUE;
2519 }
2520 return ERR_OK;
2521 }
2522
GetScreenSupportedColorGamuts(ScreenId id,std::vector<ScreenColorGamut> & mode)2523 int32_t RSRenderServiceConnectionProxy::GetScreenSupportedColorGamuts(ScreenId id, std::vector<ScreenColorGamut>& mode)
2524 {
2525 MessageParcel data;
2526 MessageParcel reply;
2527 MessageOption option;
2528 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2529 ROSEN_LOGE("GetScreenSupportedColorGamuts: WriteInterfaceToken GetDescriptor err.");
2530 return RS_CONNECTION_ERROR;
2531 }
2532 option.SetFlags(MessageOption::TF_SYNC);
2533 if (!data.WriteUint64(id)) {
2534 ROSEN_LOGE("GetScreenSupportedColorGamuts: WriteUint64 id err.");
2535 return WRITE_PARCEL_ERR;
2536 }
2537 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_GAMUTS);
2538 int32_t err = SendRequest(code, data, reply, option);
2539 if (err != NO_ERROR) {
2540 return RS_CONNECTION_ERROR;
2541 }
2542 int32_t result{0};
2543 if (!reply.ReadInt32(result)) {
2544 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenSupportedColorGamuts Read result failed");
2545 return READ_PARCEL_ERR;
2546 }
2547 if (result == SUCCESS) {
2548 mode.clear();
2549 std::vector<uint32_t> modeRecv;
2550 reply.ReadUInt32Vector(&modeRecv);
2551 for (auto i : modeRecv) {
2552 mode.push_back(static_cast<ScreenColorGamut>(i));
2553 }
2554 }
2555 return result;
2556 }
2557
GetScreenSupportedMetaDataKeys(ScreenId id,std::vector<ScreenHDRMetadataKey> & keys)2558 int32_t RSRenderServiceConnectionProxy::GetScreenSupportedMetaDataKeys(
2559 ScreenId id, std::vector<ScreenHDRMetadataKey>& keys)
2560 {
2561 MessageParcel data;
2562 MessageParcel reply;
2563 MessageOption option;
2564 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2565 ROSEN_LOGE("GetScreenSupportedMetaDataKeys: WriteInterfaceToken GetDescriptor err.");
2566 return RS_CONNECTION_ERROR;
2567 }
2568 option.SetFlags(MessageOption::TF_SYNC);
2569 if (!data.WriteUint64(id)) {
2570 ROSEN_LOGE("GetScreenSupportedMetaDataKeys: WriteUint64 id err.");
2571 return WRITE_PARCEL_ERR;
2572 }
2573 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_METADATAKEYS);
2574 int32_t err = SendRequest(code, data, reply, option);
2575 if (err != NO_ERROR) {
2576 return RS_CONNECTION_ERROR;
2577 }
2578 int32_t result{0};
2579 if (!reply.ReadInt32(result)) {
2580 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenSupportedMetaDataKeys Read result failed");
2581 return READ_PARCEL_ERR;
2582 }
2583 if (result == SUCCESS) {
2584 keys.clear();
2585 std::vector<uint32_t> keyRecv;
2586 reply.ReadUInt32Vector(&keyRecv);
2587 for (auto i : keyRecv) {
2588 keys.push_back(static_cast<ScreenHDRMetadataKey>(i));
2589 }
2590 }
2591 return result;
2592 }
2593
GetScreenColorGamut(ScreenId id,ScreenColorGamut & mode)2594 int32_t RSRenderServiceConnectionProxy::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode)
2595 {
2596 MessageParcel data;
2597 MessageParcel reply;
2598 MessageOption option;
2599 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2600 ROSEN_LOGE("GetScreenColorGamut: WriteInterfaceToken GetDescriptor err.");
2601 return RS_CONNECTION_ERROR;
2602 }
2603 option.SetFlags(MessageOption::TF_SYNC);
2604 if (!data.WriteUint64(id)) {
2605 ROSEN_LOGE("GetScreenColorGamut: WriteUint64 id err.");
2606 return WRITE_PARCEL_ERR;
2607 }
2608 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT);
2609 int32_t err = SendRequest(code, data, reply, option);
2610 if (err != NO_ERROR) {
2611 return RS_CONNECTION_ERROR;
2612 }
2613 int32_t result{0};
2614 if (!reply.ReadInt32(result)) {
2615 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenColorGamut Read result failed");
2616 return READ_PARCEL_ERR;
2617 }
2618 if (result == SUCCESS) {
2619 uint32_t readMode{0};
2620 if (!reply.ReadUint32(readMode)) {
2621 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenColorGamut Read mode failed");
2622 return READ_PARCEL_ERR;
2623 }
2624 mode = static_cast<ScreenColorGamut>(readMode);
2625 }
2626 return result;
2627 }
2628
SetScreenColorGamut(ScreenId id,int32_t modeIdx)2629 int32_t RSRenderServiceConnectionProxy::SetScreenColorGamut(ScreenId id, int32_t modeIdx)
2630 {
2631 MessageParcel data;
2632 MessageParcel reply;
2633 MessageOption option;
2634 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2635 ROSEN_LOGE("SetScreenColorGamut: WriteInterfaceToken GetDescriptor err.");
2636 return RS_CONNECTION_ERROR;
2637 }
2638 option.SetFlags(MessageOption::TF_SYNC);
2639 if (!data.WriteUint64(id)) {
2640 ROSEN_LOGE("SetScreenColorGamut: WriteUint64 id err.");
2641 return WRITE_PARCEL_ERR;
2642 }
2643 if (!data.WriteInt32(modeIdx)) {
2644 ROSEN_LOGE("SetScreenColorGamut: WriteInt32 modeIdx err.");
2645 return WRITE_PARCEL_ERR;
2646 }
2647 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT);
2648 int32_t err = SendRequest(code, data, reply, option);
2649 if (err != NO_ERROR) {
2650 return RS_CONNECTION_ERROR;
2651 }
2652 int32_t result{0};
2653 if (!reply.ReadInt32(result)) {
2654 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenColorGamut Read result failed");
2655 return READ_PARCEL_ERR;
2656 }
2657 return result;
2658 }
2659
SetScreenGamutMap(ScreenId id,ScreenGamutMap mode)2660 int32_t RSRenderServiceConnectionProxy::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode)
2661 {
2662 MessageParcel data;
2663 MessageParcel reply;
2664 MessageOption option;
2665 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2666 ROSEN_LOGE("SetScreenGamutMap: WriteInterfaceToken GetDescriptor err.");
2667 return RS_CONNECTION_ERROR;
2668 }
2669 option.SetFlags(MessageOption::TF_SYNC);
2670 if (!data.WriteUint64(id)) {
2671 ROSEN_LOGE("SetScreenGamutMap: WriteUint64 id err.");
2672 return WRITE_PARCEL_ERR;
2673 }
2674 if (!data.WriteUint32(mode)) {
2675 ROSEN_LOGE("SetScreenGamutMap: WriteUint32 mode err.");
2676 return WRITE_PARCEL_ERR;
2677 }
2678 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT_MAP);
2679 int32_t err = SendRequest(code, data, reply, option);
2680 if (err != NO_ERROR) {
2681 return RS_CONNECTION_ERROR;
2682 }
2683 int32_t result{0};
2684 if (!reply.ReadInt32(result)) {
2685 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenGamutMap Read result failed");
2686 return READ_PARCEL_ERR;
2687 }
2688 return result;
2689 }
2690
SetScreenCorrection(ScreenId id,ScreenRotation screenRotation)2691 int32_t RSRenderServiceConnectionProxy::SetScreenCorrection(ScreenId id, ScreenRotation screenRotation)
2692 {
2693 MessageParcel data;
2694 MessageParcel reply;
2695 MessageOption option;
2696 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2697 ROSEN_LOGE("SetScreenCorrection: WriteInterfaceToken GetDescriptor err.");
2698 return RS_CONNECTION_ERROR;
2699 }
2700 option.SetFlags(MessageOption::TF_SYNC);
2701 if (!data.WriteUint64(id)) {
2702 ROSEN_LOGE("SetScreenCorrection: WriteUint64 id err.");
2703 return WRITE_PARCEL_ERR;
2704 }
2705 if (!data.WriteUint32(static_cast<uint32_t>(screenRotation))) {
2706 ROSEN_LOGE("SetScreenCorrection: WriteUint32 screenRotation err.");
2707 return WRITE_PARCEL_ERR;
2708 }
2709 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CORRECTION);
2710 int32_t err = SendRequest(code, data, reply, option);
2711 if (err != NO_ERROR) {
2712 return RS_CONNECTION_ERROR;
2713 }
2714 int32_t result{0};
2715 if (!reply.ReadInt32(result)) {
2716 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenCorrection Read result failed");
2717 return READ_PARCEL_ERR;
2718 }
2719 return result;
2720 }
2721
GetScreenGamutMap(ScreenId id,ScreenGamutMap & mode)2722 int32_t RSRenderServiceConnectionProxy::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode)
2723 {
2724 MessageParcel data;
2725 MessageParcel reply;
2726 MessageOption option;
2727 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2728 ROSEN_LOGE("GetScreenGamutMap: WriteInterfaceToken GetDescriptor err.");
2729 return RS_CONNECTION_ERROR;
2730 }
2731 option.SetFlags(MessageOption::TF_SYNC);
2732 if (!data.WriteUint64(id)) {
2733 ROSEN_LOGE("GetScreenGamutMap: WriteUint64 id err.");
2734 return WRITE_PARCEL_ERR;
2735 }
2736 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT_MAP);
2737 int32_t err = SendRequest(code, data, reply, option);
2738 if (err != NO_ERROR) {
2739 return RS_CONNECTION_ERROR;
2740 }
2741 int32_t result{0};
2742 if (!reply.ReadInt32(result)) {
2743 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenGamutMap Read result failed");
2744 return READ_PARCEL_ERR;
2745 }
2746 if (result == SUCCESS) {
2747 uint32_t readMode{0};
2748 if (!reply.ReadUint32(readMode)) {
2749 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenGamutMap Read mode failed");
2750 return READ_PARCEL_ERR;
2751 }
2752 mode = static_cast<ScreenGamutMap>(readMode);
2753 }
2754 return result;
2755 }
2756
GetScreenHDRCapability(ScreenId id,RSScreenHDRCapability & screenHdrCapability)2757 int32_t RSRenderServiceConnectionProxy::GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability)
2758 {
2759 MessageParcel data;
2760 MessageParcel reply;
2761 MessageOption option;
2762 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2763 ROSEN_LOGE("GetScreenHDRCapability: WriteInterfaceToken GetDescriptor err.");
2764 return RS_CONNECTION_ERROR;
2765 }
2766 option.SetFlags(MessageOption::TF_SYNC);
2767 if (!data.WriteUint64(id)) {
2768 ROSEN_LOGE("GetScreenHDRCapability: WriteUint64 id err.");
2769 return WRITE_PARCEL_ERR;
2770 }
2771 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_CAPABILITY);
2772 int32_t err = SendRequest(code, data, reply, option);
2773 if (err != NO_ERROR) {
2774 return RS_CONNECTION_ERROR;
2775 }
2776 int32_t result{0};
2777 if (!reply.ReadInt32(result)) {
2778 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRCapability Read result failed");
2779 return READ_PARCEL_ERR;
2780 }
2781 if (result != SUCCESS) {
2782 return result;
2783 }
2784 sptr<RSScreenHDRCapability> pScreenCapability = reply.ReadParcelable<RSScreenHDRCapability>();
2785 if (pScreenCapability == nullptr) {
2786 return RS_CONNECTION_ERROR;
2787 }
2788 screenHdrCapability = *pScreenCapability;
2789 return SUCCESS;
2790 }
2791
GetPixelFormat(ScreenId id,GraphicPixelFormat & pixelFormat,int32_t & resCode)2792 ErrCode RSRenderServiceConnectionProxy::GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat, int32_t& resCode)
2793 {
2794 MessageParcel data;
2795 MessageParcel reply;
2796 MessageOption option;
2797
2798 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2799 ROSEN_LOGE("GetPixelFormat: WriteInterfaceToken GetDescriptor err.");
2800 resCode = WRITE_PARCEL_ERR;
2801 return ERR_INVALID_VALUE;
2802 }
2803 option.SetFlags(MessageOption::TF_SYNC);
2804 if (!data.WriteUint64(id)) {
2805 ROSEN_LOGE("GetPixelFormat: WriteUint64 id err.");
2806 resCode = WRITE_PARCEL_ERR;
2807 return ERR_INVALID_VALUE;
2808 }
2809 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_PIXEL_FORMAT);
2810 int32_t err = SendRequest(code, data, reply, option);
2811 if (err != NO_ERROR) {
2812 resCode = RS_CONNECTION_ERROR;
2813 return ERR_INVALID_VALUE;
2814 }
2815 if (!reply.ReadInt32(resCode)) {
2816 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetPixelFormat Read resCode failed");
2817 return READ_PARCEL_ERR;
2818 }
2819 if (resCode == SUCCESS) {
2820 uint32_t readFormat{0};
2821 if (!reply.ReadUint32(readFormat)) {
2822 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetPixelFormat Read readFormat failed");
2823 return READ_PARCEL_ERR;
2824 }
2825 pixelFormat = static_cast<GraphicPixelFormat>(readFormat);
2826 }
2827 return ERR_OK;
2828 }
2829
SetPixelFormat(ScreenId id,GraphicPixelFormat pixelFormat,int32_t & resCode)2830 ErrCode RSRenderServiceConnectionProxy::SetPixelFormat(ScreenId id, GraphicPixelFormat pixelFormat, int32_t& resCode)
2831 {
2832 MessageParcel data;
2833 MessageParcel reply;
2834 MessageOption option;
2835
2836 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2837 ROSEN_LOGE("GetPixelFormat: WriteInterfaceToken GetDescriptor err.");
2838 resCode = WRITE_PARCEL_ERR;
2839 return ERR_INVALID_VALUE;
2840 }
2841 option.SetFlags(MessageOption::TF_SYNC);
2842 if (!data.WriteUint64(id)) {
2843 ROSEN_LOGE("GetPixelFormat: WriteUint64 id err.");
2844 resCode = WRITE_PARCEL_ERR;
2845 return ERR_INVALID_VALUE;
2846 }
2847 if (!data.WriteUint32(static_cast<uint32_t>(pixelFormat))) {
2848 ROSEN_LOGE("GetPixelFormat: WriteUint32 pixelFormat err.");
2849 resCode = WRITE_PARCEL_ERR;
2850 return ERR_INVALID_VALUE;
2851 }
2852 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_PIXEL_FORMAT);
2853 int32_t err = SendRequest(code, data, reply, option);
2854 if (err != NO_ERROR) {
2855 resCode = RS_CONNECTION_ERROR;
2856 return ERR_INVALID_VALUE;
2857 }
2858 resCode = reply.ReadInt32();
2859 return ERR_OK;
2860 }
2861
GetScreenSupportedHDRFormats(ScreenId id,std::vector<ScreenHDRFormat> & hdrFormats,int32_t & resCode)2862 ErrCode RSRenderServiceConnectionProxy::GetScreenSupportedHDRFormats(
2863 ScreenId id, std::vector<ScreenHDRFormat>& hdrFormats, int32_t& resCode)
2864 {
2865 MessageParcel data;
2866 MessageParcel reply;
2867 MessageOption option;
2868 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2869 ROSEN_LOGE("GetScreenSupportedHDRFormats: WriteInterfaceToken GetDescriptor err.");
2870 resCode = RS_CONNECTION_ERROR;
2871 return ERR_INVALID_VALUE;
2872 }
2873 option.SetFlags(MessageOption::TF_SYNC);
2874 if (!data.WriteUint64(id)) {
2875 ROSEN_LOGE("GetScreenSupportedHDRFormats: WriteUint64 id err.");
2876 resCode = WRITE_PARCEL_ERR;
2877 return ERR_INVALID_VALUE;
2878 }
2879 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_HDR_FORMATS);
2880 int32_t err = SendRequest(code, data, reply, option);
2881 if (err != NO_ERROR) {
2882 resCode = RS_CONNECTION_ERROR;
2883 return ERR_INVALID_VALUE;
2884 }
2885 if (!reply.ReadInt32(resCode)) {
2886 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenSupportedHDRFormats Read resCode failed");
2887 return READ_PARCEL_ERR;
2888 }
2889 if (resCode == SUCCESS) {
2890 hdrFormats.clear();
2891 std::vector<uint32_t> hdrFormatsRecv;
2892 reply.ReadUInt32Vector(&hdrFormatsRecv);
2893 std::transform(hdrFormatsRecv.begin(), hdrFormatsRecv.end(), back_inserter(hdrFormats),
2894 [](uint32_t i) -> ScreenHDRFormat {return static_cast<ScreenHDRFormat>(i);});
2895 }
2896 return ERR_OK;
2897 }
2898
GetScreenHDRFormat(ScreenId id,ScreenHDRFormat & hdrFormat,int32_t & resCode)2899 ErrCode RSRenderServiceConnectionProxy::GetScreenHDRFormat(ScreenId id, ScreenHDRFormat& hdrFormat, int32_t& resCode)
2900 {
2901 MessageParcel data;
2902 MessageParcel reply;
2903 MessageOption option;
2904 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2905 ROSEN_LOGE("GetScreenHDRFormat: WriteInterfaceToken GetDescriptor err.");
2906 resCode = RS_CONNECTION_ERROR;
2907 return ERR_INVALID_VALUE;
2908 }
2909 option.SetFlags(MessageOption::TF_SYNC);
2910 if (!data.WriteUint64(id)) {
2911 ROSEN_LOGE("GetScreenHDRFormat: WriteUint64 id err.");
2912 resCode = WRITE_PARCEL_ERR;
2913 return ERR_INVALID_VALUE;
2914 }
2915 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_FORMAT);
2916 int32_t err = SendRequest(code, data, reply, option);
2917 if (err != NO_ERROR) {
2918 resCode = RS_CONNECTION_ERROR;
2919 return ERR_INVALID_VALUE;
2920 }
2921 if (!reply.ReadInt32(resCode)) {
2922 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRFormat Read resCode failed");
2923 return READ_PARCEL_ERR;
2924 }
2925 if (resCode == SUCCESS) {
2926 uint32_t readFormat{0};
2927 if (!reply.ReadUint32(readFormat)) {
2928 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRFormat1 Read readFormat failed");
2929 return READ_PARCEL_ERR;
2930 }
2931 hdrFormat = static_cast<ScreenHDRFormat>(readFormat);
2932 }
2933 return ERR_OK;
2934 }
2935
SetScreenHDRFormat(ScreenId id,int32_t modeIdx,int32_t & resCode)2936 ErrCode RSRenderServiceConnectionProxy::SetScreenHDRFormat(ScreenId id, int32_t modeIdx, int32_t& resCode)
2937 {
2938 MessageParcel data;
2939 MessageParcel reply;
2940 MessageOption option;
2941 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2942 ROSEN_LOGE("SetScreenHDRFormat: WriteInterfaceToken GetDescriptor err.");
2943 resCode = RS_CONNECTION_ERROR;
2944 return ERR_INVALID_VALUE;
2945 }
2946 option.SetFlags(MessageOption::TF_SYNC);
2947 if (!data.WriteUint64(id)) {
2948 ROSEN_LOGE("SetScreenHDRFormat: WriteUint64 id err.");
2949 resCode = WRITE_PARCEL_ERR;
2950 return ERR_INVALID_VALUE;
2951 }
2952 if (!data.WriteInt32(modeIdx)) {
2953 ROSEN_LOGE("SetScreenHDRFormat: WriteInt32 modeIdx err.");
2954 resCode = WRITE_PARCEL_ERR;
2955 return ERR_INVALID_VALUE;
2956 }
2957 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_HDR_FORMAT);
2958 int32_t err = SendRequest(code, data, reply, option);
2959 if (err != NO_ERROR) {
2960 resCode = RS_CONNECTION_ERROR;
2961 return ERR_INVALID_VALUE;
2962 }
2963 resCode = reply.ReadInt32();
2964 return ERR_OK;
2965 }
2966
GetScreenHDRStatus(ScreenId id,HdrStatus & hdrStatus,int32_t & resCode)2967 ErrCode RSRenderServiceConnectionProxy::GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus, int32_t& resCode)
2968 {
2969 MessageParcel data;
2970 MessageParcel reply;
2971 MessageOption option;
2972 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2973 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRStatus WriteInterfaceToken GetDescriptor err.");
2974 return WRITE_PARCEL_ERR;
2975 }
2976 option.SetFlags(MessageOption::TF_SYNC);
2977 if (!data.WriteUint64(id)) {
2978 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRStatus WriteUint64 id err.");
2979 return WRITE_PARCEL_ERR;
2980 }
2981 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_STATUS);
2982 int32_t err = SendRequest(code, data, reply, option);
2983 if (err != NO_ERROR) {
2984 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRStatus SendRequest error(%{public}d)", err);
2985 return RS_CONNECTION_ERROR;
2986 }
2987 if (!reply.ReadInt32(resCode)) {
2988 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRStatus Read resCode failed");
2989 return READ_PARCEL_ERR;
2990 }
2991 if (resCode == SUCCESS) {
2992 uint32_t readHdrStatus{0};
2993 if (!reply.ReadUint32(readHdrStatus)) {
2994 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRStatus Read HDR status failed");
2995 return READ_PARCEL_ERR;
2996 }
2997 hdrStatus = static_cast<HdrStatus>(readHdrStatus);
2998 }
2999 return ERR_OK;
3000 }
3001
GetScreenSupportedColorSpaces(ScreenId id,std::vector<GraphicCM_ColorSpaceType> & colorSpaces,int32_t & resCode)3002 ErrCode RSRenderServiceConnectionProxy::GetScreenSupportedColorSpaces(
3003 ScreenId id, std::vector<GraphicCM_ColorSpaceType>& colorSpaces, int32_t& resCode)
3004 {
3005 MessageParcel data;
3006 MessageParcel reply;
3007 MessageOption option;
3008 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3009 ROSEN_LOGE("GetScreenSupportedColorSpaces: WriteInterfaceToken GetDescriptor err.");
3010 resCode = RS_CONNECTION_ERROR;
3011 return ERR_INVALID_VALUE;
3012 }
3013 option.SetFlags(MessageOption::TF_SYNC);
3014 if (!data.WriteUint64(id)) {
3015 ROSEN_LOGE("GetScreenSupportedColorSpaces: WriteUint64 id err.");
3016 resCode = WRITE_PARCEL_ERR;
3017 return ERR_INVALID_VALUE;
3018 }
3019 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_COLORSPACES);
3020 int32_t err = SendRequest(code, data, reply, option);
3021 if (err != NO_ERROR) {
3022 resCode = RS_CONNECTION_ERROR;
3023 return ERR_INVALID_VALUE;
3024 }
3025 if (!reply.ReadInt32(resCode)) {
3026 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenSupportedColorSpaces Read resCode failed");
3027 return READ_PARCEL_ERR;
3028 }
3029 if (resCode == SUCCESS) {
3030 colorSpaces.clear();
3031 std::vector<uint32_t> colorSpacesRecv;
3032 reply.ReadUInt32Vector(&colorSpacesRecv);
3033 std::transform(colorSpacesRecv.begin(), colorSpacesRecv.end(), back_inserter(colorSpaces),
3034 [](uint32_t i) -> GraphicCM_ColorSpaceType {return static_cast<GraphicCM_ColorSpaceType>(i);});
3035 }
3036 return ERR_OK;
3037 }
3038
GetScreenColorSpace(ScreenId id,GraphicCM_ColorSpaceType & colorSpace,int32_t & resCode)3039 ErrCode RSRenderServiceConnectionProxy::GetScreenColorSpace(
3040 ScreenId id, GraphicCM_ColorSpaceType& colorSpace, int32_t& resCode)
3041 {
3042 MessageParcel data;
3043 MessageParcel reply;
3044 MessageOption option;
3045 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3046 ROSEN_LOGE("GetScreenColorSpace: WriteInterfaceToken GetDescriptor err.");
3047 resCode = RS_CONNECTION_ERROR;
3048 return ERR_INVALID_VALUE;
3049 }
3050 option.SetFlags(MessageOption::TF_SYNC);
3051 if (!data.WriteUint64(id)) {
3052 ROSEN_LOGE("GetScreenColorSpace: WriteUint64 id err.");
3053 resCode = WRITE_PARCEL_ERR;
3054 return ERR_INVALID_VALUE;
3055 }
3056 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_COLORSPACE);
3057 int32_t err = SendRequest(code, data, reply, option);
3058 if (err != NO_ERROR) {
3059 resCode = RS_CONNECTION_ERROR;
3060 return ERR_INVALID_VALUE;
3061 }
3062 if (!reply.ReadInt32(resCode)) {
3063 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenColorSpace Read resCode failed");
3064 return READ_PARCEL_ERR;
3065 }
3066 if (resCode == SUCCESS) {
3067 uint32_t type{0};
3068 if (!reply.ReadUint32(type)) {
3069 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenColorSpace Read type failed");
3070 return READ_PARCEL_ERR;
3071 }
3072 colorSpace = static_cast<GraphicCM_ColorSpaceType>(type);
3073 }
3074 return ERR_OK;
3075 }
3076
SetScreenColorSpace(ScreenId id,GraphicCM_ColorSpaceType colorSpace,int32_t & resCode)3077 ErrCode RSRenderServiceConnectionProxy::SetScreenColorSpace(
3078 ScreenId id, GraphicCM_ColorSpaceType colorSpace, int32_t& resCode)
3079 {
3080 MessageParcel data;
3081 MessageParcel reply;
3082 MessageOption option;
3083 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3084 ROSEN_LOGE("SetScreenColorSpace: WriteInterfaceToken GetDescriptor err.");
3085 resCode = RS_CONNECTION_ERROR;
3086 return ERR_INVALID_VALUE;
3087 }
3088 option.SetFlags(MessageOption::TF_SYNC);
3089 if (!data.WriteUint64(id)) {
3090 ROSEN_LOGE("SetScreenColorSpace: WriteUint64 id err.");
3091 resCode = WRITE_PARCEL_ERR;
3092 return ERR_INVALID_VALUE;
3093 }
3094 if (!data.WriteInt32(colorSpace)) {
3095 ROSEN_LOGE("SetScreenColorSpace: WriteInt32 colorSpace err.");
3096 resCode = WRITE_PARCEL_ERR;
3097 return ERR_INVALID_VALUE;
3098 }
3099 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_COLORSPACE);
3100 int32_t err = SendRequest(code, data, reply, option);
3101 if (err != NO_ERROR) {
3102 resCode = RS_CONNECTION_ERROR;
3103 return ERR_INVALID_VALUE;
3104 }
3105 resCode = reply.ReadInt32();
3106 return ERR_OK;
3107 }
3108
GetScreenType(ScreenId id,RSScreenType & screenType)3109 int32_t RSRenderServiceConnectionProxy::GetScreenType(ScreenId id, RSScreenType& screenType)
3110 {
3111 MessageParcel data;
3112 MessageParcel reply;
3113 MessageOption option;
3114 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3115 ROSEN_LOGE("GetScreenType: WriteInterfaceToken GetDescriptor err.");
3116 return RS_CONNECTION_ERROR;
3117 }
3118 option.SetFlags(MessageOption::TF_SYNC);
3119 if (!data.WriteUint64(id)) {
3120 ROSEN_LOGE("GetScreenType: WriteUint64 id err.");
3121 return WRITE_PARCEL_ERR;
3122 }
3123 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_TYPE);
3124 int32_t err = SendRequest(code, data, reply, option);
3125 if (err != NO_ERROR) {
3126 return RS_CONNECTION_ERROR;
3127 }
3128 int32_t result = reply.ReadInt32();
3129 if (result == SUCCESS) {
3130 uint32_t type{0};
3131 if (!reply.ReadUint32(type)) {
3132 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenType Read type failed");
3133 return READ_PARCEL_ERR;
3134 }
3135 screenType = static_cast<RSScreenType>(type);
3136 }
3137 return result;
3138 }
3139
GetBitmap(NodeId id,Drawing::Bitmap & bitmap,bool & success)3140 ErrCode RSRenderServiceConnectionProxy::GetBitmap(NodeId id, Drawing::Bitmap& bitmap, bool& success)
3141 {
3142 MessageParcel data;
3143 MessageParcel reply;
3144 MessageOption option;
3145 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3146 ROSEN_LOGE("GetBitmap: WriteInterfaceToken GetDescriptor err.");
3147 success = false;
3148 return ERR_INVALID_VALUE;
3149 }
3150 option.SetFlags(MessageOption::TF_SYNC);
3151 if (!data.WriteUint64(id)) {
3152 ROSEN_LOGE("GetBitmap: WriteUint64 id err.");
3153 success = false;
3154 return ERR_INVALID_VALUE;
3155 }
3156 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_BITMAP);
3157 int32_t err = SendRequest(code, data, reply, option);
3158 if (err != NO_ERROR) {
3159 success = false;
3160 return ERR_INVALID_VALUE;
3161 }
3162 bool result{false};
3163 if (!reply.ReadBool(result)) {
3164 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetBitmap Read result failed");
3165 return READ_PARCEL_ERR;
3166 }
3167 if (!result || !RSMarshallingHelper::Unmarshalling(reply, bitmap)) {
3168 RS_LOGE("RSRenderServiceConnectionProxy::GetBitmap: Unmarshalling failed");
3169 success = false;
3170 return ERR_INVALID_VALUE;
3171 }
3172 success = true;
3173 return ERR_OK;
3174 }
3175
SetVirtualMirrorScreenCanvasRotation(ScreenId id,bool canvasRotation)3176 bool RSRenderServiceConnectionProxy::SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation)
3177 {
3178 MessageParcel data;
3179 MessageParcel reply;
3180 MessageOption option;
3181 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3182 ROSEN_LOGE("SetVirtualMirrorScreenCanvasRotation: WriteInterfaceToken GetDescriptor err.");
3183 return false;
3184 }
3185 option.SetFlags(MessageOption::TF_SYNC);
3186 if (!data.WriteUint64(id)) {
3187 ROSEN_LOGE("SetVirtualMirrorScreenCanvasRotation: WriteUint64 id err.");
3188 return false;
3189 }
3190 if (!data.WriteBool(canvasRotation)) {
3191 ROSEN_LOGE("SetVirtualMirrorScreenCanvasRotation: WriteBool canvasRotation err.");
3192 return false;
3193 }
3194 uint32_t code = static_cast<uint32_t>(
3195 RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_MIRROR_SCREEN_CANVAS_ROTATION);
3196 int32_t err = SendRequest(code, data, reply, option);
3197 if (err != NO_ERROR) {
3198 return false;
3199 }
3200 bool result{false};
3201 if (!reply.ReadBool(result)) {
3202 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualMirrorScreenCanvasRotation Read result failed");
3203 return false;
3204 }
3205 return result;
3206 }
3207
SetVirtualScreenAutoRotation(ScreenId id,bool isAutoRotation)3208 int32_t RSRenderServiceConnectionProxy::SetVirtualScreenAutoRotation(ScreenId id, bool isAutoRotation)
3209 {
3210 MessageParcel data;
3211 MessageParcel reply;
3212 MessageOption option;
3213 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3214 ROSEN_LOGE("SetVirtualScreenAutoRotation: WriteInterfaceToken GetDescriptor err.");
3215 return RS_CONNECTION_ERROR;
3216 }
3217 option.SetFlags(MessageOption::TF_SYNC);
3218 if (!data.WriteUint64(id)) {
3219 ROSEN_LOGE("SetVirtualScreenAutoRotation: WriteUint64 id err.");
3220 return WRITE_PARCEL_ERR;
3221 }
3222 if (!data.WriteBool(isAutoRotation)) {
3223 ROSEN_LOGE("SetVirtualScreenAutoRotation: WriteBool isAutoRotation err.");
3224 return WRITE_PARCEL_ERR;
3225 }
3226 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_AUTO_ROTATION);
3227 int32_t err = SendRequest(code, data, reply, option);
3228 if (err != NO_ERROR) {
3229 ROSEN_LOGE("RSRenderServiceConnectionProxy::%{public}s: Send Request err.", __func__);
3230 return RS_CONNECTION_ERROR;
3231 }
3232 int32_t result{-1};
3233 if (!reply.ReadInt32(result)) {
3234 ROSEN_LOGE("RSRenderServiceConnectionProxy::%{public}s Read result failed", __func__);
3235 return READ_PARCEL_ERR;
3236 }
3237 return result;
3238 }
3239
SetVirtualMirrorScreenScaleMode(ScreenId id,ScreenScaleMode scaleMode)3240 bool RSRenderServiceConnectionProxy::SetVirtualMirrorScreenScaleMode(ScreenId id, ScreenScaleMode scaleMode)
3241 {
3242 MessageParcel data;
3243 MessageParcel reply;
3244 MessageOption option;
3245 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3246 ROSEN_LOGE("SetVirtualMirrorScreenScaleMode: WriteInterfaceToken GetDescriptor err.");
3247 return false;
3248 }
3249 option.SetFlags(MessageOption::TF_SYNC);
3250 if (!data.WriteUint64(id)) {
3251 ROSEN_LOGE("SetVirtualMirrorScreenScaleMode: WriteUint64 id err.");
3252 return false;
3253 }
3254 if (!data.WriteUint32(static_cast<uint32_t>(scaleMode))) {
3255 ROSEN_LOGE("SetVirtualMirrorScreenScaleMode: WriteUint32 scaleMode err.");
3256 return false;
3257 }
3258 uint32_t code = static_cast<uint32_t>(
3259 RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_MIRROR_SCREEN_SCALE_MODE);
3260 int32_t err = SendRequest(code, data, reply, option);
3261 if (err != NO_ERROR) {
3262 return false;
3263 }
3264 bool result{false};
3265 if (!reply.ReadBool(result)) {
3266 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualMirrorScreenScaleMode Read result failed");
3267 return false;
3268 }
3269 return result;
3270 }
3271
SetGlobalDarkColorMode(bool isDark)3272 ErrCode RSRenderServiceConnectionProxy::SetGlobalDarkColorMode(bool isDark)
3273 {
3274 MessageParcel data;
3275 MessageParcel reply;
3276 MessageOption option;
3277 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3278 ROSEN_LOGE("SetGlobalDarkColorMode: WriteInterfaceToken GetDescriptor err.");
3279 return ERR_INVALID_VALUE;
3280 }
3281 option.SetFlags(MessageOption::TF_ASYNC);
3282 if (!data.WriteBool(isDark)) {
3283 ROSEN_LOGE("SetGlobalDarkColorMode: WriteBool isDark err.");
3284 return ERR_INVALID_VALUE;
3285 }
3286 uint32_t code = static_cast<uint32_t>(
3287 RSIRenderServiceConnectionInterfaceCode::SET_GLOBAL_DARK_COLOR_MODE);
3288 int32_t err = SendRequest(code, data, reply, option);
3289 if (err != NO_ERROR) {
3290 return ERR_INVALID_VALUE;
3291 }
3292 return ERR_OK;
3293 }
3294
GetPixelmap(NodeId id,std::shared_ptr<Media::PixelMap> pixelmap,const Drawing::Rect * rect,std::shared_ptr<Drawing::DrawCmdList> drawCmdList,bool & success)3295 ErrCode RSRenderServiceConnectionProxy::GetPixelmap(NodeId id, std::shared_ptr<Media::PixelMap> pixelmap,
3296 const Drawing::Rect* rect, std::shared_ptr<Drawing::DrawCmdList> drawCmdList, bool& success)
3297 {
3298 MessageParcel data;
3299 MessageParcel reply;
3300 MessageOption option;
3301 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3302 ROSEN_LOGE("GetPixelmap: WriteInterfaceToken GetDescriptor err.");
3303 success = false;
3304 return ERR_INVALID_VALUE;
3305 }
3306 option.SetFlags(MessageOption::TF_SYNC);
3307 if (!data.WriteUint64(id)) {
3308 ROSEN_LOGE("GetPixelmap: WriteUint64 id err.");
3309 success = false;
3310 return ERR_INVALID_VALUE;
3311 }
3312 if (!data.WriteParcelable(pixelmap.get())) {
3313 ROSEN_LOGE("GetPixelmap: WriteParcelable pixelmap.get() err.");
3314 success = false;
3315 return ERR_INVALID_VALUE;
3316 }
3317 RSMarshallingHelper::Marshalling(data, *rect);
3318 RSMarshallingHelper::Marshalling(data, drawCmdList);
3319 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_PIXELMAP);
3320 int32_t err = SendRequest(code, data, reply, option);
3321 if (err != NO_ERROR) {
3322 success = false;
3323 return ERR_INVALID_VALUE;
3324 }
3325 bool result{false};
3326 if (!reply.ReadBool(result)) {
3327 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetPixelmap Read result failed");
3328 return READ_PARCEL_ERR;
3329 }
3330 if (!result || !RSMarshallingHelper::Unmarshalling(reply, pixelmap)) {
3331 RS_LOGD("RSRenderServiceConnectionProxy::GetPixelmap: GetPixelmap failed");
3332 success = false;
3333 return ERR_INVALID_VALUE;
3334 }
3335 success = true;
3336 return ERR_OK;
3337 }
3338
RegisterTypeface(uint64_t globalUniqueId,std::shared_ptr<Drawing::Typeface> & typeface)3339 bool RSRenderServiceConnectionProxy::RegisterTypeface(uint64_t globalUniqueId,
3340 std::shared_ptr<Drawing::Typeface>& typeface)
3341 {
3342 MessageParcel data;
3343 MessageParcel reply;
3344 MessageOption option;
3345 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3346 ROSEN_LOGE("RegisterTypeface: WriteInterfaceToken GetDescriptor err.");
3347 return false;
3348 }
3349 option.SetFlags(MessageOption::TF_SYNC);
3350 uint32_t hash = typeface->GetHash();
3351 if (!data.WriteUint64(globalUniqueId)) {
3352 ROSEN_LOGE("RegisterTypeface: WriteUint64 globalUniqueId err.");
3353 return false;
3354 }
3355 if (!data.WriteUint32(hash)) {
3356 ROSEN_LOGE("RegisterTypeface: WriteUint32 hash err.");
3357 return false;
3358 }
3359
3360 if (hash) { // if adapter does not provide hash, use old path
3361 MessageParcel reply2;
3362 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NEED_REGISTER_TYPEFACE);
3363 int32_t err = SendRequest(code, data, reply2, option);
3364 if (err != NO_ERROR) {
3365 RS_LOGW("Check if RegisterTypeface is needed failed, err:%{public}d", err);
3366 return false;
3367 }
3368 if (!reply2.ReadBool()) {
3369 return true; // the hash exists on server, no need to resend full data
3370 }
3371 }
3372
3373 RSMarshallingHelper::Marshalling(data, typeface);
3374
3375 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_TYPEFACE);
3376 int32_t err = SendRequest(code, data, reply, option);
3377 if (err != NO_ERROR) {
3378 RS_LOGD("RSRenderServiceConnectionProxy::RegisterTypeface: RegisterTypeface failed");
3379 return false;
3380 }
3381 bool result{false};
3382 if (!reply.ReadBool(result)) {
3383 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTypeface Read result failed");
3384 return false;
3385 }
3386 return result;
3387 }
3388
UnRegisterTypeface(uint64_t globalUniqueId)3389 bool RSRenderServiceConnectionProxy::UnRegisterTypeface(uint64_t globalUniqueId)
3390 {
3391 MessageParcel data;
3392 MessageParcel reply;
3393 MessageOption option;
3394 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3395 ROSEN_LOGE("UnRegisterTypeface: WriteInterfaceToken GetDescriptor err.");
3396 return false;
3397 }
3398 option.SetFlags(MessageOption::TF_ASYNC);
3399 if (!data.WriteUint64(globalUniqueId)) {
3400 ROSEN_LOGE("UnRegisterTypeface: WriteUint64 globalUniqueId err.");
3401 return false;
3402 }
3403 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_TYPEFACE);
3404 int32_t err = SendRequest(code, data, reply, option);
3405 if (err != NO_ERROR) {
3406 RS_LOGD("RSRenderServiceConnectionProxy::UnRegisterTypeface: send request failed");
3407 return false;
3408 }
3409
3410 return true;
3411 }
3412
GetDisplayIdentificationData(ScreenId id,uint8_t & outPort,std::vector<uint8_t> & edidData)3413 int32_t RSRenderServiceConnectionProxy::GetDisplayIdentificationData(ScreenId id, uint8_t& outPort,
3414 std::vector<uint8_t>& edidData)
3415 {
3416 MessageParcel data;
3417 MessageParcel reply;
3418 MessageOption option;
3419 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3420 return RS_CONNECTION_ERROR;
3421 }
3422 if (!data.WriteUint64(id)) {
3423 return WRITE_PARCEL_ERR;
3424 }
3425 option.SetFlags(MessageOption::TF_SYNC);
3426 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_DISPLAY_IDENTIFICATION_DATA);
3427 int32_t err = SendRequest(code, data, reply, option);
3428 if (err != NO_ERROR) {
3429 return RS_CONNECTION_ERROR;
3430 }
3431 int32_t result{0};
3432 if (!reply.ReadInt32(result)) {
3433 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetDisplayIdentificationData Read result failed");
3434 return READ_PARCEL_ERR;
3435 }
3436 if (result != SUCCESS) {
3437 RS_LOGE("RSRenderServiceConnectionProxy::GetDisplayIdentificationData: failed");
3438 return result;
3439 }
3440 if (!reply.ReadUint8(outPort)) {
3441 return READ_PARCEL_ERR;
3442 }
3443 uint32_t edidSize = reply.ReadUint32();
3444 if (edidSize == 0 || edidSize > EDID_DATA_MAX_SIZE) {
3445 RS_LOGE("RSRenderServiceConnectionProxy::GetDisplayIdentificationData: EdidSize failed");
3446 return READ_PARCEL_ERR;
3447 }
3448 edidData.resize(edidSize);
3449 const uint8_t *editpnt = reply.ReadBuffer(edidSize);
3450 if (editpnt == nullptr) {
3451 RS_LOGE("RSRenderServiceConnectionProxy::GetDisplayIdentificationData: ReadBuffer failed");
3452 return READ_PARCEL_ERR;
3453 }
3454 RS_LOGD("RSRenderServiceConnectionProxy::GetDisplayIdentificationData: EdidSize: %{public}u", edidSize);
3455 edidData.assign(editpnt, editpnt + edidSize);
3456
3457 return result;
3458 }
3459
SetScreenSkipFrameInterval(uint64_t id,uint32_t skipFrameInterval,int32_t & resCode)3460 ErrCode RSRenderServiceConnectionProxy::SetScreenSkipFrameInterval(uint64_t id, uint32_t skipFrameInterval,
3461 int32_t& resCode)
3462 {
3463 MessageParcel data;
3464 MessageParcel reply;
3465 MessageOption option;
3466 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3467 ROSEN_LOGE("SetScreenSkipFrameInterval: WriteInterfaceToken GetDescriptor err.");
3468 resCode = RS_CONNECTION_ERROR;
3469 return ERR_INVALID_VALUE;
3470 }
3471 option.SetFlags(MessageOption::TF_SYNC);
3472 if (!data.WriteUint64(id)) {
3473 ROSEN_LOGE("SetScreenSkipFrameInterval: WriteUint64 id err.");
3474 resCode = WRITE_PARCEL_ERR;
3475 return ERR_INVALID_VALUE;
3476 }
3477 if (!data.WriteUint32(skipFrameInterval)) {
3478 ROSEN_LOGE("SetScreenSkipFrameInterval: WriteUint32 skipFrameInterval err.");
3479 resCode = WRITE_PARCEL_ERR;
3480 return ERR_INVALID_VALUE;
3481 }
3482 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_SKIP_FRAME_INTERVAL);
3483 int32_t err = SendRequest(code, data, reply, option);
3484 if (err != NO_ERROR) {
3485 resCode = RS_CONNECTION_ERROR;
3486 return ERR_INVALID_VALUE;
3487 }
3488 if (!reply.ReadInt32(resCode)) {
3489 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetPixelFormat Read result failed");
3490 resCode = READ_PARCEL_ERR;
3491 return ERR_INVALID_VALUE;
3492 }
3493 return ERR_OK;
3494 }
3495
SetVirtualScreenRefreshRate(ScreenId id,uint32_t maxRefreshRate,uint32_t & actualRefreshRate,int32_t & retVal)3496 ErrCode RSRenderServiceConnectionProxy::SetVirtualScreenRefreshRate(
3497 ScreenId id, uint32_t maxRefreshRate, uint32_t& actualRefreshRate, int32_t& retVal)
3498 {
3499 MessageParcel data;
3500 MessageParcel reply;
3501 MessageOption option;
3502 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3503 ROSEN_LOGE("SetVirtualScreenRefreshRate: WriteInterfaceToken GetDescriptor err.");
3504 retVal = RS_CONNECTION_ERROR;
3505 return ERR_INVALID_VALUE;
3506 }
3507 option.SetFlags(MessageOption::TF_SYNC);
3508 if (!data.WriteUint64(id)) {
3509 ROSEN_LOGE("SetVirtualScreenRefreshRate: WriteUint64 id err.");
3510 retVal = WRITE_PARCEL_ERR;
3511 return ERR_INVALID_VALUE;
3512 }
3513 if (!data.WriteUint32(maxRefreshRate)) {
3514 ROSEN_LOGE("SetVirtualScreenRefreshRate: WriteUint32 maxRefreshRate err.");
3515 retVal = WRITE_PARCEL_ERR;
3516 return ERR_INVALID_VALUE;
3517 }
3518 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_REFRESH_RATE);
3519 int32_t err = SendRequest(code, data, reply, option);
3520 if (err != NO_ERROR) {
3521 retVal = RS_CONNECTION_ERROR;
3522 return ERR_INVALID_VALUE;
3523 }
3524 int32_t result{0};
3525 if (!reply.ReadInt32(result)) {
3526 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenRefreshRate Read result failed");
3527 retVal = READ_PARCEL_ERR;
3528 return ERR_INVALID_VALUE;
3529 }
3530 if (result == SUCCESS) {
3531 if (!reply.ReadUint32(actualRefreshRate)) {
3532 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenRefreshRate Read actualRefreshRate failed");
3533 retVal = READ_PARCEL_ERR;
3534 return ERR_INVALID_VALUE;
3535 }
3536 }
3537 retVal = result;
3538 return ERR_OK;
3539 }
3540
SetScreenActiveRect(ScreenId id,const Rect & activeRect,uint32_t & repCode)3541 ErrCode RSRenderServiceConnectionProxy::SetScreenActiveRect(ScreenId id, const Rect& activeRect, uint32_t& repCode)
3542 {
3543 MessageParcel data;
3544 MessageParcel reply;
3545 MessageOption option;
3546 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3547 ROSEN_LOGE("SetScreenActiveRect: WriteInterfaceToken GetDescriptor err.");
3548 repCode = RS_CONNECTION_ERROR;
3549 return ERR_INVALID_VALUE;
3550 }
3551 option.SetFlags(MessageOption::TF_SYNC);
3552 if (!data.WriteUint64(id)) {
3553 ROSEN_LOGE("SetScreenActiveRect: WriteUint64 id err.");
3554 repCode = WRITE_PARCEL_ERR;
3555 return ERR_INVALID_VALUE;
3556 }
3557 if (!data.WriteInt32(activeRect.x) || !data.WriteInt32(activeRect.y) ||
3558 !data.WriteInt32(activeRect.w) || !data.WriteInt32(activeRect.h)) {
3559 ROSEN_LOGE("SetScreenActiveRect: WriteInt32 activeRect err.");
3560 repCode = WRITE_PARCEL_ERR;
3561 return ERR_INVALID_VALUE;
3562 }
3563 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_RECT);
3564 int32_t err = SendRequest(code, data, reply, option);
3565 if (err != NO_ERROR) {
3566 repCode = RS_CONNECTION_ERROR;
3567 return ERR_INVALID_VALUE;
3568 }
3569 if (!reply.ReadUint32(repCode)) {
3570 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenActiveRect Read result failed");
3571 repCode = READ_PARCEL_ERR;
3572 return ERR_INVALID_VALUE;
3573 }
3574 return ERR_OK;
3575 }
3576
SetScreenOffset(ScreenId id,int32_t offSetX,int32_t offSetY)3577 void RSRenderServiceConnectionProxy::SetScreenOffset(ScreenId id, int32_t offSetX, int32_t offSetY)
3578 {
3579 MessageParcel data;
3580 MessageParcel reply;
3581 MessageOption option;
3582 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3583 ROSEN_LOGE("%{public}s: WriteInterfaceToken GetDescriptor err.", __func__);
3584 return;
3585 }
3586 option.SetFlags(MessageOption::TF_SYNC);
3587 if (!data.WriteUint64(id) || !data.WriteInt32(offSetX) || !data.WriteInt32(offSetY)) {
3588 ROSEN_LOGE("%{public}s: write error.", __func__);
3589 return;
3590 }
3591 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_OFFSET);
3592 int32_t err = SendRequest(code, data, reply, option);
3593 if (err != NO_ERROR) {
3594 ROSEN_LOGE("%{public}s: Send Request err.", __func__);
3595 }
3596 }
3597
SetScreenFrameGravity(ScreenId id,int32_t gravity)3598 void RSRenderServiceConnectionProxy::SetScreenFrameGravity(ScreenId id, int32_t gravity)
3599 {
3600 MessageParcel data;
3601 MessageParcel reply;
3602 MessageOption option;
3603 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3604 ROSEN_LOGE("%{public}s: WriteInterfaceToken GetDescriptor err.", __func__);
3605 return;
3606 }
3607 option.SetFlags(MessageOption::TF_ASYNC);
3608
3609 if (!data.WriteUint64(id) || !data.WriteInt32(gravity)) {
3610 ROSEN_LOGE("%{public}s: write error.", __func__);
3611 return;
3612 }
3613 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_FRAME_GRAVITY);
3614 int32_t err = SendRequest(code, data, reply, option);
3615 if (err != NO_ERROR) {
3616 ROSEN_LOGE("%{public}s: Send Request err.", __func__);
3617 }
3618 }
3619
RegisterOcclusionChangeCallback(sptr<RSIOcclusionChangeCallback> callback,int32_t & repCode)3620 ErrCode RSRenderServiceConnectionProxy::RegisterOcclusionChangeCallback(
3621 sptr<RSIOcclusionChangeCallback> callback, int32_t& repCode)
3622 {
3623 if (callback == nullptr) {
3624 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterOcclusionChangeCallback: callback is nullptr.");
3625 repCode = INVALID_ARGUMENTS;
3626 return ERR_INVALID_VALUE;
3627 }
3628 MessageParcel data;
3629 MessageParcel reply;
3630 MessageOption option;
3631 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3632 ROSEN_LOGE("RegisterOcclusionChangeCallback: WriteInterfaceToken GetDescriptor err.");
3633 repCode = RS_CONNECTION_ERROR;
3634 return ERR_INVALID_VALUE;
3635 }
3636 option.SetFlags(MessageOption::TF_ASYNC);
3637 if (!data.WriteRemoteObject(callback->AsObject())) {
3638 ROSEN_LOGE("RegisterOcclusionChangeCallback: WriteRemoteObject callback->AsObject() err.");
3639 repCode = WRITE_PARCEL_ERR;
3640 return ERR_INVALID_VALUE;
3641 }
3642 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_OCCLUSION_CHANGE_CALLBACK);
3643 int32_t err = SendRequest(code, data, reply, option);
3644 if (err != NO_ERROR) {
3645 repCode = RS_CONNECTION_ERROR;
3646 return ERR_INVALID_VALUE;
3647 }
3648 repCode = reply.ReadInt32();
3649 return ERR_OK;
3650 }
3651
RegisterSurfaceOcclusionChangeCallback(NodeId id,sptr<RSISurfaceOcclusionChangeCallback> callback,std::vector<float> & partitionPoints)3652 int32_t RSRenderServiceConnectionProxy::RegisterSurfaceOcclusionChangeCallback(
3653 NodeId id, sptr<RSISurfaceOcclusionChangeCallback> callback, std::vector<float>& partitionPoints)
3654 {
3655 if (callback == nullptr) {
3656 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceOcclusionChangeCallback: callback is nullptr.");
3657 return INVALID_ARGUMENTS;
3658 }
3659
3660 MessageParcel data;
3661 MessageParcel reply;
3662 MessageOption option;
3663 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3664 ROSEN_LOGE("RegisterSurfaceOcclusionChangeCallback: WriteInterfaceToken GetDescriptor err.");
3665 return RS_CONNECTION_ERROR;
3666 }
3667 option.SetFlags(MessageOption::TF_SYNC);
3668 if (!data.WriteUint64(id)) {
3669 ROSEN_LOGE("RegisterSurfaceOcclusionChangeCallback: WriteUint64 id err.");
3670 return WRITE_PARCEL_ERR;
3671 }
3672 if (!data.WriteRemoteObject(callback->AsObject())) {
3673 ROSEN_LOGE("RegisterSurfaceOcclusionChangeCallback: WriteRemoteObject callback->AsObject() err.");
3674 return WRITE_PARCEL_ERR;
3675 }
3676 if (!data.WriteFloatVector(partitionPoints)) {
3677 ROSEN_LOGE("RegisterSurfaceOcclusionChangeCallback: WriteFloatVector partitionPoints err.");
3678 return WRITE_PARCEL_ERR;
3679 }
3680
3681 uint32_t code = static_cast<uint32_t>(
3682 RSIRenderServiceConnectionInterfaceCode::REGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK);
3683 int32_t err = SendRequest(code, data, reply, option);
3684 if (err != NO_ERROR) {
3685 return RS_CONNECTION_ERROR;
3686 }
3687 int32_t result{0};
3688 if (!reply.ReadInt32(result)) {
3689 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenHDRFormat Read result failed");
3690 return READ_PARCEL_ERR;
3691 }
3692 return result;
3693 }
3694
UnRegisterSurfaceOcclusionChangeCallback(NodeId id)3695 int32_t RSRenderServiceConnectionProxy::UnRegisterSurfaceOcclusionChangeCallback(NodeId id)
3696 {
3697 MessageParcel data;
3698 MessageParcel reply;
3699 MessageOption option;
3700 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3701 ROSEN_LOGE("UnRegisterSurfaceOcclusionChangeCallback: WriteInterfaceToken GetDescriptor err.");
3702 return RS_CONNECTION_ERROR;
3703 }
3704 option.SetFlags(MessageOption::TF_SYNC);
3705 if (!data.WriteUint64(id)) {
3706 ROSEN_LOGE("UnRegisterSurfaceOcclusionChangeCallback: WriteUint64 id err.");
3707 return WRITE_PARCEL_ERR;
3708 }
3709
3710 uint32_t code = static_cast<uint32_t>(
3711 RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK);
3712 int32_t err = SendRequest(code, data, reply, option);
3713 if (err != NO_ERROR) {
3714 return RS_CONNECTION_ERROR;
3715 }
3716 int32_t result{0};
3717 if (!reply.ReadInt32(result)) {
3718 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenColorSpace Read result failed");
3719 return READ_PARCEL_ERR;
3720 }
3721 return result;
3722 }
3723
RegisterHgmConfigChangeCallback(sptr<RSIHgmConfigChangeCallback> callback)3724 int32_t RSRenderServiceConnectionProxy::RegisterHgmConfigChangeCallback(sptr<RSIHgmConfigChangeCallback> callback)
3725 {
3726 MessageParcel data;
3727 MessageParcel reply;
3728 MessageOption option;
3729 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3730 ROSEN_LOGE("RegisterHgmConfigChangeCallback: WriteInterfaceToken GetDescriptor err.");
3731 return RS_CONNECTION_ERROR;
3732 }
3733 option.SetFlags(MessageOption::TF_SYNC);
3734 if (!data.WriteRemoteObject(callback->AsObject())) {
3735 ROSEN_LOGE("RegisterHgmConfigChangeCallback: WriteRemoteObject callback->AsObject() err.");
3736 return WRITE_PARCEL_ERR;
3737 }
3738 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_HGM_CFG_CALLBACK);
3739 int32_t err = SendRequest(code, data, reply, option);
3740 if (err != NO_ERROR) {
3741 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmConfigChangeCallback: Send Request err.");
3742 return RS_CONNECTION_ERROR;
3743 }
3744 int32_t result{0};
3745 if (!reply.ReadInt32(result)) {
3746 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmConfigChangeCallback Read result failed");
3747 return READ_PARCEL_ERR;
3748 }
3749 return result;
3750 }
3751
RegisterHgmRefreshRateModeChangeCallback(sptr<RSIHgmConfigChangeCallback> callback)3752 int32_t RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback(
3753 sptr<RSIHgmConfigChangeCallback> callback)
3754 {
3755 MessageParcel data;
3756 MessageParcel reply;
3757 MessageOption option;
3758 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3759 ROSEN_LOGE("RegisterHgmRefreshRateModeChangeCallback: WriteInterfaceToken GetDescriptor err.");
3760 return RS_CONNECTION_ERROR;
3761 }
3762 option.SetFlags(MessageOption::TF_SYNC);
3763 if (!data.WriteRemoteObject(callback->AsObject())) {
3764 ROSEN_LOGE("RegisterHgmRefreshRateModeChangeCallback: WriteRemoteObject callback->AsObject() err.");
3765 return WRITE_PARCEL_ERR;
3766 }
3767 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REFRESH_RATE_MODE_CHANGE_CALLBACK);
3768 int32_t err = SendRequest(code, data, reply, option);
3769 if (err != NO_ERROR) {
3770 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback: Send Request err.");
3771 return RS_CONNECTION_ERROR;
3772 }
3773 int32_t result{0};
3774 if (!reply.ReadInt32(result)) {
3775 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback Read result failed");
3776 return READ_PARCEL_ERR;
3777 }
3778 return result;
3779 }
3780
RegisterHgmRefreshRateUpdateCallback(sptr<RSIHgmConfigChangeCallback> callback)3781 int32_t RSRenderServiceConnectionProxy::RegisterHgmRefreshRateUpdateCallback(
3782 sptr<RSIHgmConfigChangeCallback> callback)
3783 {
3784 MessageParcel data;
3785 MessageParcel reply;
3786 MessageOption option;
3787 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3788 ROSEN_LOGE("RegisterHgmRefreshRateUpdateCallback: WriteInterfaceToken GetDescriptor err.");
3789 return RS_CONNECTION_ERROR;
3790 }
3791 option.SetFlags(MessageOption::TF_SYNC);
3792 if (callback) {
3793 if (!data.WriteBool(true)) {
3794 ROSEN_LOGE("RegisterHgmRefreshRateUpdateCallback: WriteBool [true] err.");
3795 return WRITE_PARCEL_ERR;
3796 }
3797 if (!data.WriteRemoteObject(callback->AsObject())) {
3798 ROSEN_LOGE("RegisterHgmRefreshRateUpdateCallback: WriteRemoteObject callback->AsObject() err.");
3799 return WRITE_PARCEL_ERR;
3800 }
3801 } else {
3802 if (!data.WriteBool(false)) {
3803 ROSEN_LOGE("RegisterHgmRefreshRateUpdateCallback: WriteBool [false] err.");
3804 return WRITE_PARCEL_ERR;
3805 }
3806 }
3807 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REFRESH_RATE_UPDATE_CALLBACK);
3808 int32_t err = SendRequest(code, data, reply, option);
3809 if (err != NO_ERROR) {
3810 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback: Send Request err.");
3811 return RS_CONNECTION_ERROR;
3812 }
3813 int32_t result{0};
3814 if (!reply.ReadInt32(result)) {
3815 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback Read result failed");
3816 return READ_PARCEL_ERR;
3817 }
3818 return result;
3819 }
3820
RegisterFirstFrameCommitCallback(sptr<RSIFirstFrameCommitCallback> callback)3821 int32_t RSRenderServiceConnectionProxy::RegisterFirstFrameCommitCallback(
3822 sptr<RSIFirstFrameCommitCallback> callback)
3823 {
3824 MessageParcel data;
3825 MessageParcel reply;
3826 MessageOption option;
3827 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3828 ROSEN_LOGE("RegisterFirstFrameCommitCallback: WriteInterfaceToken GetDescriptor err.");
3829 return RS_CONNECTION_ERROR;
3830 }
3831 option.SetFlags(MessageOption::TF_SYNC);
3832 if (callback) {
3833 if (!data.WriteBool(true)) {
3834 ROSEN_LOGE("RegisterFirstFrameCommitCallback: WriteBool [true] err.");
3835 return WRITE_PARCEL_ERR;
3836 }
3837 if (!data.WriteRemoteObject(callback->AsObject())) {
3838 ROSEN_LOGE("RegisterFirstFrameCommitCallback: WriteRemoteObject callback->AsObject() err.");
3839 return WRITE_PARCEL_ERR;
3840 }
3841 } else {
3842 if (!data.WriteBool(false)) {
3843 ROSEN_LOGE("RegisterFirstFrameCommitCallback: WriteBool [false] err.");
3844 return WRITE_PARCEL_ERR;
3845 }
3846 }
3847 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::ON_FIRST_FRAME_COMMIT);
3848 int32_t err = SendRequest(code, data, reply, option);
3849 if (err != NO_ERROR) {
3850 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterFirstFrameCommitCallback: Send Request err.");
3851 return RS_CONNECTION_ERROR;
3852 }
3853 int32_t result = reply.ReadInt32();
3854 return result;
3855 }
3856
AvcodecVideoStart(uint64_t uniqueId,std::string & surfaceName,uint32_t fps,uint64_t reportTime)3857 ErrCode RSRenderServiceConnectionProxy::AvcodecVideoStart(
3858 uint64_t uniqueId, std::string& surfaceName, uint32_t fps, uint64_t reportTime)
3859 {
3860 MessageParcel data;
3861 MessageParcel reply;
3862 MessageOption option;
3863
3864 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3865 ROSEN_LOGE("AvcodecVideoStart: WriteInterfaceToken GetDescriptor err.");
3866 return RS_CONNECTION_ERROR;
3867 }
3868 option.SetFlags(MessageOption::TF_SYNC);
3869 if (!data.WriteUint64(uniqueId)) {
3870 ROSEN_LOGE("AvcodecVideoStart: WriteUint64 uniqueId err.");
3871 return ERR_INVALID_VALUE;
3872 }
3873 if (!data.WriteString(surfaceName)) {
3874 ROSEN_LOGE("AvcodecVideoStart: WriteString surfaceName err.");
3875 return ERR_INVALID_VALUE;
3876 }
3877 if (!data.WriteUint32(fps)) {
3878 ROSEN_LOGE("AvcodecVideoStart: WriteUint32 fps err.");
3879 return ERR_INVALID_VALUE;
3880 }
3881 if (!data.WriteUint64(reportTime)) {
3882 ROSEN_LOGE("AvcodecVideoStart: WriteUint64 reportTime err.");
3883 return ERR_INVALID_VALUE;
3884 }
3885 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::AVCODEC_VIDEO_START);
3886 int32_t err = SendRequest(code, data, reply, option);
3887 if (err != NO_ERROR) {
3888 ROSEN_LOGE("RSRenderServiceConnectionProxy::AvcodecVideoStart: Send Request err.");
3889 return RS_CONNECTION_ERROR;
3890 }
3891 int32_t result{0};
3892 if (!reply.ReadInt32(result)) {
3893 ROSEN_LOGE("RSRenderServiceConnectionProxy::AvcodecVideoStart Read result failed");
3894 return READ_PARCEL_ERR;
3895 }
3896 return result;
3897 }
3898
AvcodecVideoStop(uint64_t uniqueId,std::string & surfaceName,uint32_t fps)3899 ErrCode RSRenderServiceConnectionProxy::AvcodecVideoStop(uint64_t uniqueId, std::string& surfaceName, uint32_t fps)
3900 {
3901 MessageParcel data;
3902 MessageParcel reply;
3903 MessageOption option;
3904
3905 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3906 ROSEN_LOGE("AvcodecVideoStop: WriteInterfaceToken GetDescriptor err.");
3907 return RS_CONNECTION_ERROR;
3908 }
3909 option.SetFlags(MessageOption::TF_SYNC);
3910 if (!data.WriteUint64(uniqueId)) {
3911 ROSEN_LOGE("AvcodecVideoStop: WriteUint64 uniqueId err.");
3912 return ERR_INVALID_VALUE;
3913 }
3914 if (!data.WriteString(surfaceName)) {
3915 ROSEN_LOGE("AvcodecVideoStop: WriteString surfaceName err.");
3916 return ERR_INVALID_VALUE;
3917 }
3918 if (!data.WriteUint32(fps)) {
3919 ROSEN_LOGE("AvcodecVideoStop: WriteUint32 fps err.");
3920 return ERR_INVALID_VALUE;
3921 }
3922 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::AVCODEC_VIDEO_STOP);
3923 int32_t err = SendRequest(code, data, reply, option);
3924 if (err != NO_ERROR) {
3925 ROSEN_LOGE("RSRenderServiceConnectionProxy::AvcodecVideoStop: Send Request err.");
3926 return RS_CONNECTION_ERROR;
3927 }
3928 int32_t result{0};
3929 if (!reply.ReadInt32(result)) {
3930 ROSEN_LOGE("RSRenderServiceConnectionProxy::AvcodecVideoStop Read result failed");
3931 return READ_PARCEL_ERR;
3932 }
3933 return result;
3934 }
3935
RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid,sptr<RSIFrameRateLinkerExpectedFpsUpdateCallback> callback)3936 int32_t RSRenderServiceConnectionProxy::RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid,
3937 sptr<RSIFrameRateLinkerExpectedFpsUpdateCallback> callback)
3938 {
3939 MessageParcel data;
3940 MessageParcel reply;
3941 MessageOption option;
3942
3943 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3944 ROSEN_LOGE("RegisterFrameRateLinkerExpectedFpsUpdateCallback: WriteInterfaceToken GetDescriptor err.");
3945 return WRITE_PARCEL_ERR;
3946 }
3947 option.SetFlags(MessageOption::TF_SYNC);
3948 if (!data.WriteInt32(dstPid)) {
3949 ROSEN_LOGE("RegisterFrameRateLinkerExpectedFpsUpdateCallback: WriteInt32 dstPid err.");
3950 return WRITE_PARCEL_ERR;
3951 }
3952 if (callback) {
3953 if (!data.WriteBool(true) || !data.WriteRemoteObject(callback->AsObject())) {
3954 ROSEN_LOGE("RegisterFrameRateLinkerExpectedFpsUpdateCallback: WriteBool[T] OR WriteRemoteObject[CB] err");
3955 return WRITE_PARCEL_ERR;
3956 }
3957 } else {
3958 if (!data.WriteBool(false)) {
3959 ROSEN_LOGE("RegisterFrameRateLinkerExpectedFpsUpdateCallback: WriteBool [false] err.");
3960 return WRITE_PARCEL_ERR;
3961 }
3962 }
3963
3964 uint32_t code = static_cast<uint32_t>(
3965 RSIRenderServiceConnectionInterfaceCode::REGISTER_FRAME_RATE_LINKER_EXPECTED_FPS_CALLBACK);
3966 int32_t err = SendRequest(code, data, reply, option);
3967 if (err != NO_ERROR) {
3968 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterFrameRateLinkerExpectedFpsUpdateCallback: "
3969 "Send Request err.");
3970 return RS_CONNECTION_ERROR;
3971 }
3972 int32_t result{0};
3973 if (!reply.ReadInt32(result)) {
3974 ROSEN_LOGE(
3975 "RSRenderServiceConnectionProxy::RegisterFrameRateLinkerExpectedFpsUpdateCallback Read result failed");
3976 return READ_PARCEL_ERR;
3977 }
3978 return result;
3979 }
3980
SetAppWindowNum(uint32_t num)3981 ErrCode RSRenderServiceConnectionProxy::SetAppWindowNum(uint32_t num)
3982 {
3983 MessageParcel data;
3984 MessageParcel reply;
3985 MessageOption option;
3986 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3987 ROSEN_LOGE("SetAppWindowNum: WriteInterfaceToken GetDescriptor err.");
3988 return ERR_INVALID_VALUE;
3989 }
3990 option.SetFlags(MessageOption::TF_ASYNC);
3991 if (!data.WriteUint32(num)) {
3992 ROSEN_LOGE("SetAppWindowNum: WriteUint32 num err.");
3993 return ERR_INVALID_VALUE;
3994 }
3995 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_APP_WINDOW_NUM);
3996 int32_t err = SendRequest(code, data, reply, option);
3997 if (err != NO_ERROR) {
3998 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetAppWindowNum: Send Request err.");
3999 return ERR_INVALID_VALUE;
4000 }
4001
4002 return ERR_OK;
4003 }
4004
SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes,bool isRegularAnimation,bool & success)4005 ErrCode RSRenderServiceConnectionProxy::SetSystemAnimatedScenes(
4006 SystemAnimatedScenes systemAnimatedScenes, bool isRegularAnimation, bool& success)
4007 {
4008 MessageParcel data;
4009 MessageParcel reply;
4010 MessageOption option;
4011 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4012 ROSEN_LOGE("SetSystemAnimatedScenes: WriteInterfaceToken GetDescriptor err.");
4013 success = false;
4014 return ERR_INVALID_VALUE;
4015 }
4016 option.SetFlags(MessageOption::TF_SYNC);
4017 if (!data.WriteUint32(static_cast<uint32_t>(systemAnimatedScenes))) {
4018 ROSEN_LOGE("SetSystemAnimatedScenes: WriteUint32 systemAnimatedScenes err.");
4019 success = false;
4020 return ERR_INVALID_VALUE;
4021 }
4022 if (!data.WriteBool(isRegularAnimation)) {
4023 ROSEN_LOGE("SetSystemAnimatedScenes: WriteBool isRegularAnimation err.");
4024 success = false;
4025 return ERR_INVALID_VALUE;
4026 }
4027 uint32_t code = static_cast<uint32_t>(
4028 RSIRenderServiceConnectionInterfaceCode::SET_SYSTEM_ANIMATED_SCENES);
4029 int32_t err = SendRequest(code, data, reply, option);
4030 if (err != NO_ERROR) {
4031 success = false;
4032 return ERR_INVALID_VALUE;
4033 }
4034 if (!reply.ReadBool(success)) {
4035 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetSystemAnimatedScenes Read result failed");
4036 success = READ_PARCEL_ERR;
4037 return ERR_INVALID_VALUE;
4038 }
4039 return ERR_OK;
4040 }
4041
SetWatermark(const std::string & name,std::shared_ptr<Media::PixelMap> watermark,bool & success)4042 ErrCode RSRenderServiceConnectionProxy::SetWatermark(const std::string& name,
4043 std::shared_ptr<Media::PixelMap> watermark, bool& success)
4044 {
4045 MessageParcel data;
4046 MessageParcel reply;
4047 MessageOption option;
4048 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4049 ROSEN_LOGE("SetWatermark: WriteInterfaceToken GetDescriptor err.");
4050 success = false;
4051 return ERR_INVALID_VALUE;
4052 }
4053 option.SetFlags(MessageOption::TF_ASYNC);
4054 if (!data.WriteString(name)) {
4055 ROSEN_LOGE("SetWatermark: WriteString name err.");
4056 success = false;
4057 return ERR_INVALID_VALUE;
4058 }
4059 if (!data.WriteParcelable(watermark.get())) {
4060 ROSEN_LOGE("SetWatermark: WriteParcelable watermark.get() err.");
4061 success = false;
4062 return ERR_INVALID_VALUE;
4063 }
4064 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_WATERMARK);
4065 int32_t err = SendRequest(code, data, reply, option);
4066 if (err != NO_ERROR) {
4067 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWatermark: Send Request err.");
4068 success = false;
4069 return ERR_INVALID_VALUE;
4070 }
4071 success = true;
4072 return ERR_OK;
4073 }
4074
ShowWatermark(const std::shared_ptr<Media::PixelMap> & watermarkImg,bool isShow)4075 void RSRenderServiceConnectionProxy::ShowWatermark(const std::shared_ptr<Media::PixelMap> &watermarkImg, bool isShow)
4076 {
4077 if (watermarkImg == nullptr) {
4078 ROSEN_LOGE("RSRenderServiceConnectionProxy::ShowWatermark: watermarkImg is nullptr.");
4079 return;
4080 }
4081 MessageParcel data;
4082 MessageParcel reply;
4083 MessageOption option;
4084 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4085 ROSEN_LOGE("ShowWatermark: WriteInterfaceToken GetDescriptor err.");
4086 return;
4087 }
4088 option.SetFlags(MessageOption::TF_ASYNC);
4089 if (!data.WriteParcelable(watermarkImg.get())) {
4090 ROSEN_LOGE("ShowWatermark: WriteParcelable watermarkImg.get() err.");
4091 return;
4092 }
4093 if (!data.WriteBool(isShow)) {
4094 ROSEN_LOGE("ShowWatermark: WriteBool isShow err.");
4095 return;
4096 }
4097 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SHOW_WATERMARK);
4098 int32_t err = SendRequest(code, data, reply, option);
4099 if (err != NO_ERROR) {
4100 ROSEN_LOGE("RSRenderServiceConnectionProxy::ShowWatermark: Send Request err.");
4101 return;
4102 }
4103 }
4104
ResizeVirtualScreen(ScreenId id,uint32_t width,uint32_t height)4105 int32_t RSRenderServiceConnectionProxy::ResizeVirtualScreen(ScreenId id, uint32_t width, uint32_t height)
4106 {
4107 MessageParcel data;
4108 MessageParcel reply;
4109 MessageOption option;
4110
4111 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4112 ROSEN_LOGE("ResizeVirtualScreen: WriteInterfaceToken GetDescriptor err.");
4113 return WRITE_PARCEL_ERR;
4114 }
4115 option.SetFlags(MessageOption::TF_SYNC);
4116 if (!data.WriteUint64(id)) {
4117 ROSEN_LOGE("ResizeVirtualScreen: WriteUint64 id err.");
4118 return WRITE_PARCEL_ERR;
4119 }
4120 if (!data.WriteUint32(width)) {
4121 ROSEN_LOGE("ResizeVirtualScreen: WriteUint32 width err.");
4122 return WRITE_PARCEL_ERR;
4123 }
4124 if (!data.WriteUint32(height)) {
4125 ROSEN_LOGE("ResizeVirtualScreen: WriteUint32 height err.");
4126 return WRITE_PARCEL_ERR;
4127 }
4128 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::RESIZE_VIRTUAL_SCREEN);
4129 int32_t err = SendRequest(code, data, reply, option);
4130 if (err != NO_ERROR) {
4131 ROSEN_LOGE("RSRenderServiceConnectionProxy::ResizeVirtualScreen: Send Request err.");
4132 return RS_CONNECTION_ERROR;
4133 }
4134 int32_t status{0};
4135 if (!reply.ReadInt32(status)) {
4136 ROSEN_LOGE("RSRenderServiceConnectionProxy::ResizeVirtualScreen Read status failed");
4137 return READ_PARCEL_ERR;
4138 }
4139 return status;
4140 }
4141
ReportJankStats()4142 ErrCode RSRenderServiceConnectionProxy::ReportJankStats()
4143 {
4144 MessageParcel data;
4145 MessageParcel reply;
4146 MessageOption option;
4147 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4148 ROSEN_LOGE("ReportJankStats: WriteInterfaceToken GetDescriptor err.");
4149 return ERR_INVALID_VALUE;
4150 }
4151 option.SetFlags(MessageOption::TF_ASYNC);
4152 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_JANK_STATS);
4153 int32_t err = SendRequest(code, data, reply, option);
4154 if (err != NO_ERROR) {
4155 ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportJankStats: Send Request err.");
4156 return ERR_INVALID_VALUE;
4157 }
4158 return ERR_OK;
4159 }
4160
ReportEventResponse(DataBaseRs info)4161 ErrCode RSRenderServiceConnectionProxy::ReportEventResponse(DataBaseRs info)
4162 {
4163 MessageParcel data;
4164 MessageParcel reply;
4165 MessageOption option;
4166 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4167 ROSEN_LOGE("ReportEventResponse: WriteInterfaceToken GetDescriptor err.");
4168 return ERR_INVALID_VALUE;
4169 }
4170 ReportDataBaseRs(data, reply, option, info);
4171 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_RESPONSE);
4172 int32_t err = SendRequest(code, data, reply, option);
4173 if (err != NO_ERROR) {
4174 ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportEventResponse: Send Request err.");
4175 return ERR_INVALID_VALUE;
4176 }
4177 return ERR_OK;
4178 }
4179
ReportEventComplete(DataBaseRs info)4180 ErrCode RSRenderServiceConnectionProxy::ReportEventComplete(DataBaseRs info)
4181 {
4182 MessageParcel data;
4183 MessageParcel reply;
4184 MessageOption option;
4185 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4186 ROSEN_LOGE("ReportEventComplete: WriteInterfaceToken GetDescriptor err.");
4187 return ERR_INVALID_VALUE;
4188 }
4189 ReportDataBaseRs(data, reply, option, info);
4190 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_COMPLETE);
4191 int32_t err = SendRequest(code, data, reply, option);
4192 if (err != NO_ERROR) {
4193 ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportEventComplete: Send Request err.");
4194 return ERR_INVALID_VALUE;
4195 }
4196 return ERR_OK;
4197 }
4198
ReportEventJankFrame(DataBaseRs info)4199 ErrCode RSRenderServiceConnectionProxy::ReportEventJankFrame(DataBaseRs info)
4200 {
4201 MessageParcel data;
4202 MessageParcel reply;
4203 MessageOption option;
4204 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4205 ROSEN_LOGE("ReportEventJankFrame: WriteInterfaceToken GetDescriptor err.");
4206 return ERR_INVALID_VALUE;
4207 }
4208 ReportDataBaseRs(data, reply, option, info);
4209 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_JANK_FRAME);
4210 int32_t err = SendRequest(code, data, reply, option);
4211 if (err != NO_ERROR) {
4212 ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportEventJankFrame: Send Request err.");
4213 return ERR_INVALID_VALUE;
4214 }
4215 return ERR_OK;
4216 }
4217
ReportRsSceneJankStart(AppInfo info)4218 void RSRenderServiceConnectionProxy::ReportRsSceneJankStart(AppInfo info)
4219 {
4220 MessageParcel data;
4221 MessageParcel reply;
4222 MessageOption option;
4223 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4224 ROSEN_LOGE("ReportRsSceneJankStart: WriteInterfaceToken GetDescriptor err.");
4225 return;
4226 }
4227 WriteAppInfo(data, reply, option, info);
4228 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_RS_SCENE_JANK_START);
4229 int32_t err = SendRequest(code, data, reply, option);
4230 if (err != NO_ERROR) {
4231 ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportRsSceneJankStart: Send Request err.");
4232 return;
4233 }
4234 }
4235
ReportRsSceneJankEnd(AppInfo info)4236 void RSRenderServiceConnectionProxy::ReportRsSceneJankEnd(AppInfo info)
4237 {
4238 MessageParcel data;
4239 MessageParcel reply;
4240 MessageOption option;
4241 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4242 ROSEN_LOGE("ReportRsSceneJankEnd: WriteInterfaceToken GetDescriptor err.");
4243 return;
4244 }
4245 WriteAppInfo(data, reply, option, info);
4246 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_RS_SCENE_JANK_END);
4247 int32_t err = SendRequest(code, data, reply, option);
4248 if (err != NO_ERROR) {
4249 ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportRsSceneJankEnd: Send Request err.");
4250 return;
4251 }
4252 }
4253
ReportDataBaseRs(MessageParcel & data,MessageParcel & reply,MessageOption & option,DataBaseRs info)4254 void RSRenderServiceConnectionProxy::ReportDataBaseRs(
4255 MessageParcel& data, MessageParcel& reply, MessageOption& option, DataBaseRs info)
4256 {
4257 if (!data.WriteInt32(info.appPid)) {
4258 ROSEN_LOGE("ReportDataBaseRs: WriteInt32 info.appPid err.");
4259 return;
4260 }
4261 if (!data.WriteInt32(info.eventType)) {
4262 ROSEN_LOGE("ReportDataBaseRs: WriteInt32 info.eventType err.");
4263 return;
4264 }
4265 if (!data.WriteInt32(info.versionCode)) {
4266 ROSEN_LOGE("ReportDataBaseRs: WriteInt32 info.versionCode err.");
4267 return;
4268 }
4269 if (!data.WriteInt64(info.uniqueId)) {
4270 ROSEN_LOGE("ReportDataBaseRs: WriteInt64 info.uniqueId err.");
4271 return;
4272 }
4273 if (!data.WriteInt64(info.inputTime)) {
4274 ROSEN_LOGE("ReportDataBaseRs: WriteInt64 info.inputTime err.");
4275 return;
4276 }
4277 if (!data.WriteInt64(info.beginVsyncTime) || !data.WriteInt64(info.endVsyncTime)) {
4278 ROSEN_LOGE("ReportDataBaseRs: WriteInt64 info.beginVsyncTime OR info.endVsyncTime err.");
4279 return;
4280 }
4281 if (!data.WriteBool(info.isDisplayAnimator)) {
4282 ROSEN_LOGE("ReportDataBaseRs: WriteBool info.isDisplayAnimator err.");
4283 return;
4284 }
4285 if (!data.WriteString(info.sceneId)) {
4286 ROSEN_LOGE("ReportDataBaseRs: WriteString info.sceneId err.");
4287 return;
4288 }
4289 if (!data.WriteString(info.versionName)) {
4290 ROSEN_LOGE("ReportDataBaseRs: WriteString info.versionName err.");
4291 return;
4292 }
4293 if (!data.WriteString(info.bundleName)) {
4294 ROSEN_LOGE("ReportDataBaseRs: WriteString info.bundleName err.");
4295 return;
4296 }
4297 if (!data.WriteString(info.processName)) {
4298 ROSEN_LOGE("ReportDataBaseRs: WriteString info.processName err.");
4299 return;
4300 }
4301 if (!data.WriteString(info.abilityName)) {
4302 ROSEN_LOGE("ReportDataBaseRs: WriteString info.abilityName err.");
4303 return;
4304 }
4305 if (!data.WriteString(info.pageUrl)) {
4306 ROSEN_LOGE("ReportDataBaseRs: WriteString info.pageUrl err.");
4307 return;
4308 }
4309 if (!data.WriteString(info.sourceType)) {
4310 ROSEN_LOGE("ReportDataBaseRs: WriteString info.sourceType err.");
4311 return;
4312 }
4313 if (!data.WriteString(info.note)) {
4314 ROSEN_LOGE("ReportDataBaseRs: WriteString info.note err.");
4315 return;
4316 }
4317 option.SetFlags(MessageOption::TF_ASYNC);
4318 }
4319
WriteAppInfo(MessageParcel & data,MessageParcel & reply,MessageOption & option,AppInfo info)4320 void RSRenderServiceConnectionProxy::WriteAppInfo(
4321 MessageParcel& data, MessageParcel& reply, MessageOption& option, AppInfo info)
4322 {
4323 if (!data.WriteInt64(info.startTime)) {
4324 ROSEN_LOGE("WriteAppInfo: WriteInt64 info.startTime err.");
4325 return;
4326 }
4327 if (!data.WriteInt64(info.endTime)) {
4328 ROSEN_LOGE("WriteAppInfo: WriteInt64 info.endTime err.");
4329 return;
4330 }
4331 if (!data.WriteInt32(info.pid)) {
4332 ROSEN_LOGE("WriteAppInfo: WriteInt32 info.pid err.");
4333 return;
4334 }
4335 if (!data.WriteString(info.versionName)) {
4336 ROSEN_LOGE("WriteAppInfo: WriteString info.versionName err.");
4337 return;
4338 }
4339 if (!data.WriteInt32(info.versionCode)) {
4340 ROSEN_LOGE("WriteAppInfo: WriteInt32 info.versionCode err.");
4341 return;
4342 }
4343 if (!data.WriteString(info.bundleName)) {
4344 ROSEN_LOGE("WriteAppInfo: WriteString info.bundleName err.");
4345 return;
4346 }
4347 if (!data.WriteString(info.processName)) {
4348 ROSEN_LOGE("WriteAppInfo: WriteString info.processName err.");
4349 return;
4350 }
4351 option.SetFlags(MessageOption::TF_ASYNC);
4352 }
4353
ReportGameStateDataRs(MessageParcel & data,MessageParcel & reply,MessageOption & option,GameStateData info)4354 void RSRenderServiceConnectionProxy::ReportGameStateDataRs(
4355 MessageParcel& data, MessageParcel& reply, MessageOption& option, GameStateData info)
4356 {
4357 if (!data.WriteInt32(info.pid)) {
4358 ROSEN_LOGE("ReportGameStateDataRs: WriteInt32 info.pid err.");
4359 return;
4360 }
4361 if (!data.WriteInt32(info.uid)) {
4362 ROSEN_LOGE("ReportGameStateDataRs: WriteInt32 info.uid err.");
4363 return;
4364 }
4365 if (!data.WriteInt32(info.state)) {
4366 ROSEN_LOGE("ReportGameStateDataRs: WriteInt32 info.state err.");
4367 return;
4368 }
4369 if (!data.WriteInt32(info.renderTid)) {
4370 ROSEN_LOGE("ReportGameStateDataRs: WriteInt32 info.renderTid err.");
4371 return;
4372 }
4373 if (!data.WriteString(info.bundleName)) {
4374 ROSEN_LOGE("ReportGameStateDataRs: WriteString info.bundleName err.");
4375 return;
4376 }
4377 option.SetFlags(MessageOption::TF_ASYNC);
4378 }
4379
ReportGameStateData(GameStateData info)4380 ErrCode RSRenderServiceConnectionProxy::ReportGameStateData(GameStateData info)
4381 {
4382 MessageParcel data;
4383 MessageParcel reply;
4384 MessageOption option;
4385 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4386 ROSEN_LOGE("ReportGameStateData: WriteInterfaceToken GetDescriptor err.");
4387 return ERR_INVALID_VALUE;
4388 }
4389 ReportGameStateDataRs(data, reply, option, info);
4390 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_GAMESTATE);
4391 int32_t err = SendRequest(code, data, reply, option);
4392 if (err != NO_ERROR) {
4393 ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportGameStateData: Send Request err.");
4394 return ERR_INVALID_VALUE;
4395 }
4396 return ERR_OK;
4397 }
4398
SetHardwareEnabled(NodeId id,bool isEnabled,SelfDrawingNodeType selfDrawingType,bool dynamicHardwareEnable)4399 ErrCode RSRenderServiceConnectionProxy::SetHardwareEnabled(NodeId id, bool isEnabled,
4400 SelfDrawingNodeType selfDrawingType, bool dynamicHardwareEnable)
4401 {
4402 MessageParcel data;
4403 MessageParcel reply;
4404 MessageOption option;
4405 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4406 ROSEN_LOGE("SetHardwareEnabled: WriteInterfaceToken GetDescriptor err.");
4407 return ERR_INVALID_VALUE;
4408 }
4409 if (!data.WriteUint64(id)) {
4410 ROSEN_LOGE("SetHardwareEnabled: WriteUint64 id err.");
4411 return ERR_INVALID_VALUE;
4412 }
4413 if (!data.WriteBool(isEnabled)) {
4414 ROSEN_LOGE("SetHardwareEnabled: WriteBool isEnabled err.");
4415 return ERR_INVALID_VALUE;
4416 }
4417 if (!data.WriteUint8(static_cast<uint8_t>(selfDrawingType))) {
4418 ROSEN_LOGE("SetHardwareEnabled: WriteUint8 selfDrawingType err.");
4419 return ERR_INVALID_VALUE;
4420 }
4421 if (!data.WriteBool(dynamicHardwareEnable)) {
4422 ROSEN_LOGE("SetHardwareEnabled: WriteBool dynamicHardwareEnable err.");
4423 return ERR_INVALID_VALUE;
4424 }
4425 option.SetFlags(MessageOption::TF_ASYNC);
4426 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_HARDWARE_ENABLED);
4427 int32_t err = SendRequest(code, data, reply, option);
4428 if (err != NO_ERROR) {
4429 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetHardwareEnabled: Send Request err.");
4430 return ERR_INVALID_VALUE;
4431 }
4432 return ERR_OK;
4433 }
4434
SetHidePrivacyContent(NodeId id,bool needHidePrivacyContent,uint32_t & resCode)4435 ErrCode RSRenderServiceConnectionProxy::SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent, uint32_t& resCode)
4436 {
4437 MessageParcel data;
4438 MessageParcel reply;
4439 MessageOption option;
4440 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4441 ROSEN_LOGE("SetHidePrivacyContent: WriteInterfaceToken GetDescriptor err.");
4442 resCode = static_cast<uint32_t>(RSInterfaceErrorCode::WRITE_PARCEL_ERROR);
4443 return ERR_INVALID_VALUE;
4444 }
4445 if (!data.WriteUint64(id)) {
4446 ROSEN_LOGE("SetHidePrivacyContent: WriteUint64 id err.");
4447 resCode = static_cast<uint32_t>(RSInterfaceErrorCode::WRITE_PARCEL_ERROR);
4448 return ERR_INVALID_VALUE;
4449 }
4450 if (!data.WriteBool(needHidePrivacyContent)) {
4451 ROSEN_LOGE("SetHidePrivacyContent: WriteBool needHidePrivacyContent err.");
4452 resCode = static_cast<uint32_t>(RSInterfaceErrorCode::WRITE_PARCEL_ERROR);
4453 return ERR_INVALID_VALUE;
4454 }
4455 option.SetFlags(MessageOption::TF_SYNC);
4456 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_HIDE_PRIVACY_CONTENT);
4457 int32_t err = SendRequest(code, data, reply, option);
4458 if (err != NO_ERROR) {
4459 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetHidePrivacyContent: Send Request err.");
4460 resCode = static_cast<uint32_t>(RSInterfaceErrorCode::UNKNOWN_ERROR);
4461 return ERR_INVALID_VALUE;
4462 }
4463 resCode = reply.ReadUint32();
4464 return ERR_OK;
4465 }
4466
NotifyLightFactorStatus(int32_t lightFactorStatus)4467 ErrCode RSRenderServiceConnectionProxy::NotifyLightFactorStatus(int32_t lightFactorStatus)
4468 {
4469 MessageParcel data;
4470 MessageParcel reply;
4471 MessageOption option;
4472 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4473 ROSEN_LOGE("NotifyLightFactorStatus: WriteInterfaceToken GetDescriptor err.");
4474 return ERR_INVALID_VALUE;
4475 }
4476 if (!data.WriteInt32(lightFactorStatus)) {
4477 ROSEN_LOGE("NotifyLightFactorStatus: WriteInt32 lightFactorStatus err.");
4478 return ERR_INVALID_VALUE;
4479 }
4480 option.SetFlags(MessageOption::TF_ASYNC);
4481 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_LIGHT_FACTOR_STATUS);
4482 int32_t err = SendRequest(code, data, reply, option);
4483 if (err != NO_ERROR) {
4484 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyLightFactorStatus: Send Request err.");
4485 return ERR_INVALID_VALUE;
4486 }
4487 return ERR_OK;
4488 }
4489
NotifyPackageEvent(uint32_t listSize,const std::vector<std::string> & packageList)4490 void RSRenderServiceConnectionProxy::NotifyPackageEvent(uint32_t listSize, const std::vector<std::string>& packageList)
4491 {
4492 MessageParcel data;
4493 MessageParcel reply;
4494 MessageOption option;
4495 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4496 ROSEN_LOGE("NotifyPackageEvent: WriteInterfaceToken GetDescriptor err.");
4497 return;
4498 }
4499 if (listSize != packageList.size()) {
4500 ROSEN_LOGE("input size doesn't match");
4501 return;
4502 }
4503 if (!data.WriteUint32(listSize)) {
4504 ROSEN_LOGE("NotifyPackageEvent: WriteUint32 listSize err.");
4505 return;
4506 }
4507 for (auto pkg : packageList) {
4508 if (!data.WriteString(pkg)) {
4509 ROSEN_LOGE("NotifyPackageEvent: WriteString pkg err.");
4510 return;
4511 }
4512 }
4513 option.SetFlags(MessageOption::TF_ASYNC);
4514 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PACKAGE_EVENT);
4515 int32_t err = SendRequest(code, data, reply, option);
4516 if (err != NO_ERROR) {
4517 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyPackageEvent: Send Request err.");
4518 return;
4519 }
4520 }
4521
NotifyAppStrategyConfigChangeEvent(const std::string & pkgName,uint32_t listSize,const std::vector<std::pair<std::string,std::string>> & newConfig)4522 void RSRenderServiceConnectionProxy::NotifyAppStrategyConfigChangeEvent(const std::string& pkgName, uint32_t listSize,
4523 const std::vector<std::pair<std::string, std::string>>& newConfig)
4524 {
4525 MessageParcel data;
4526 MessageParcel reply;
4527 MessageOption option;
4528 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4529 return;
4530 }
4531
4532 if (listSize != newConfig.size()) {
4533 ROSEN_LOGE("input size doesn't match");
4534 return;
4535 }
4536
4537 if (!data.WriteString(pkgName) || !data.WriteUint32(listSize)) {
4538 ROSEN_LOGE(
4539 "RSRenderServiceConnectionProxy::NotifyAppStrategyConfigChangeEvent Write pakName or listSize failed.");
4540 return;
4541 }
4542
4543 for (const auto& [key, value] : newConfig) {
4544 if (!data.WriteString(key) || !data.WriteString(value)) {
4545 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyAppStrategyConfigChangeEvent Write key or value failed.");
4546 return;
4547 }
4548 }
4549 option.SetFlags(MessageOption::TF_ASYNC);
4550 uint32_t code = static_cast<uint32_t>(
4551 RSIRenderServiceConnectionInterfaceCode::NOTIFY_APP_STRATEGY_CONFIG_CHANGE_EVENT);
4552 int32_t err = SendRequest(code, data, reply, option);
4553 if (err != NO_ERROR) {
4554 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyAppStrategyConfigChangeEvent: Send Request err.");
4555 return;
4556 }
4557 }
4558
SetWindowExpectedRefreshRate(const std::unordered_map<uint64_t,EventInfo> & eventInfos)4559 void RSRenderServiceConnectionProxy::SetWindowExpectedRefreshRate(
4560 const std::unordered_map<uint64_t, EventInfo>& eventInfos
4561 )
4562 {
4563 auto mapSize = eventInfos.size();
4564 if (mapSize <= ZERO || mapSize > MAX_VOTER_SIZE) {
4565 ROSEN_LOGE("SetWindowExpectedRefreshRate: map size err.");
4566 return;
4567 }
4568
4569 MessageParcel data;
4570 MessageParcel reply;
4571 MessageOption option;
4572 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4573 ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteInterfaceToken GetDescriptor err.");
4574 return;
4575 }
4576 if (!data.WriteUint32(mapSize)) {
4577 ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteUint32 mapSize err.");
4578 return;
4579 }
4580 for (const auto& [key, eventInfo] : eventInfos) {
4581 if (!data.WriteUint64(key)) {
4582 ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteUint64 key err.");
4583 return;
4584 }
4585 if (!eventInfo.Serialize(data)) {
4586 ROSEN_LOGE("SetWindowExpectedRefreshRate: Write eventInfo err.");
4587 return;
4588 }
4589 }
4590 option.SetFlags(MessageOption::TF_ASYNC);
4591 uint32_t code =
4592 static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_WINDOW_ID);
4593 int32_t err = SendRequest(code, data, reply, option);
4594 if (err != NO_ERROR) {
4595 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWindowExpectedRefreshRate: Send Request err.");
4596 return;
4597 }
4598 }
4599
SetWindowExpectedRefreshRate(const std::unordered_map<std::string,EventInfo> & eventInfos)4600 void RSRenderServiceConnectionProxy::SetWindowExpectedRefreshRate(
4601 const std::unordered_map<std::string, EventInfo>& eventInfos
4602 )
4603 {
4604 auto mapSize = eventInfos.size();
4605 if (mapSize <= ZERO || mapSize > MAX_VOTER_SIZE) {
4606 ROSEN_LOGE("SetWindowExpectedRefreshRate: map size err.");
4607 return;
4608 }
4609
4610 MessageParcel data;
4611 MessageParcel reply;
4612 MessageOption option;
4613 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4614 ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteInterfaceToken GetDescriptor err.");
4615 return;
4616 }
4617 if (!data.WriteUint32(mapSize)) {
4618 ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteUint32 mapSize err.");
4619 return;
4620 }
4621 for (const auto& [key, eventInfo] : eventInfos) {
4622 if (!data.WriteString(key)) {
4623 ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteString key err.");
4624 return;
4625 }
4626 if (!eventInfo.Serialize(data)) {
4627 ROSEN_LOGE("SetWindowExpectedRefreshRate: Write eventInfo err.");
4628 return;
4629 }
4630 }
4631 option.SetFlags(MessageOption::TF_ASYNC);
4632 uint32_t code =
4633 static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_VSYNC_NAME);
4634 int32_t err = SendRequest(code, data, reply, option);
4635 if (err != NO_ERROR) {
4636 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWindowExpectedRefreshRate: Send Request err.");
4637 return;
4638 }
4639 }
4640
NotifyRefreshRateEvent(const EventInfo & eventInfo)4641 void RSRenderServiceConnectionProxy::NotifyRefreshRateEvent(const EventInfo& eventInfo)
4642 {
4643 MessageParcel data;
4644 MessageParcel reply;
4645 MessageOption option;
4646 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4647 ROSEN_LOGE("NotifyRefreshRateEvent: WriteInterfaceToken GetDescriptor err.");
4648 return;
4649 }
4650 if (!data.WriteString(eventInfo.eventName)) {
4651 ROSEN_LOGE("NotifyRefreshRateEvent: WriteString eventInfo.eventName err.");
4652 return;
4653 }
4654 if (!data.WriteBool(eventInfo.eventStatus)) {
4655 ROSEN_LOGE("NotifyRefreshRateEvent: WriteBool eventInfo.eventStatus err.");
4656 return;
4657 }
4658 if (!data.WriteUint32(eventInfo.minRefreshRate)) {
4659 ROSEN_LOGE("NotifyRefreshRateEvent: WriteUint32 eventInfo.minRefreshRate err.");
4660 return;
4661 }
4662 if (!data.WriteUint32(eventInfo.maxRefreshRate)) {
4663 ROSEN_LOGE("NotifyRefreshRateEvent: WriteUint32 eventInfo.maxRefreshRate err.");
4664 return;
4665 }
4666 if (!data.WriteString(eventInfo.description)) {
4667 ROSEN_LOGE("NotifyRefreshRateEvent: WriteString eventInfo.description err.");
4668 return;
4669 }
4670 option.SetFlags(MessageOption::TF_ASYNC);
4671 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_REFRESH_RATE_EVENT);
4672 int32_t err = SendRequest(code, data, reply, option);
4673 if (err != NO_ERROR) {
4674 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyRefreshRateEvent: Send Request err.");
4675 return;
4676 }
4677 }
4678
NotifySoftVsyncEvent(uint32_t pid,uint32_t rateDiscount)4679 ErrCode RSRenderServiceConnectionProxy::NotifySoftVsyncEvent(uint32_t pid, uint32_t rateDiscount)
4680 {
4681 MessageParcel data;
4682 MessageParcel reply;
4683 MessageOption option;
4684 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4685 ROSEN_LOGE("NotifySoftVsyncEvent: WriteInterfaceToken GetDescriptor err.");
4686 return ERR_INVALID_VALUE;
4687 }
4688 if (!data.WriteUint32(pid)) {
4689 ROSEN_LOGE("NotifySoftVsyncEvent: WriteUint32 pid err.");
4690 return ERR_INVALID_VALUE;
4691 }
4692 if (!data.WriteUint32(rateDiscount)) {
4693 ROSEN_LOGE("NotifySoftVsyncEvent: WriteUint32 rateDiscount err.");
4694 return ERR_INVALID_VALUE;
4695 }
4696 option.SetFlags(MessageOption::TF_ASYNC);
4697 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SOFT_VSYNC_EVENT);
4698 int32_t err = SendRequest(code, data, reply, option);
4699 if (err != NO_ERROR) {
4700 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifySoftVsyncEvent: Send Request err.");
4701 return ERR_INVALID_VALUE;
4702 }
4703 return ERR_OK;
4704 }
4705
NotifySoftVsyncRateDiscountEvent(uint32_t pid,const std::string & name,uint32_t rateDiscount)4706 bool RSRenderServiceConnectionProxy::NotifySoftVsyncRateDiscountEvent(uint32_t pid, const std::string &name,
4707 uint32_t rateDiscount)
4708 {
4709 MessageParcel data;
4710 MessageParcel reply;
4711 MessageOption option;
4712 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4713 ROSEN_LOGE("NotifySoftVsyncRateDiscountEvent: WriteInterfaceToken GetDescriptor err.");
4714 return false;
4715 }
4716 if (!data.WriteUint32(pid)) {
4717 ROSEN_LOGE("NotifySoftVsyncRateDiscountEvent: WriteUint32 pid err.");
4718 return false;
4719 }
4720 if (!data.WriteString(name)) {
4721 ROSEN_LOGE("NotifySoftVsyncRateDiscountEvent: WriteString rateDiscount err.");
4722 return false;
4723 }
4724 if (!data.WriteUint32(rateDiscount)) {
4725 ROSEN_LOGE("NotifySoftVsyncRateDiscountEvent: WriteUint32 rateDiscount err.");
4726 return false;
4727 }
4728 option.SetFlags(MessageOption::TF_SYNC);
4729 uint32_t code = static_cast<uint32_t>(
4730 RSIRenderServiceConnectionInterfaceCode::NOTIFY_SOFT_VSYNC_RATE_DISCOUNT_EVENT);
4731 int32_t err = SendRequest(code, data, reply, option);
4732 if (err != NO_ERROR) {
4733 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifySoftVsyncRateDiscountEvent: Send Request err.");
4734 return false;
4735 }
4736 bool enable{false};
4737 if (!reply.ReadBool(enable)) {
4738 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifySoftVsyncRateDiscountEvent: Read enable failed");
4739 return false;
4740 }
4741 return enable;
4742 }
4743
NotifyTouchEvent(int32_t touchStatus,int32_t touchCnt)4744 ErrCode RSRenderServiceConnectionProxy::NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt)
4745 {
4746 MessageParcel data;
4747 MessageParcel reply;
4748 MessageOption option;
4749 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4750 ROSEN_LOGE("NotifyTouchEvent: WriteInterfaceToken GetDescriptor err.");
4751 return ERR_INVALID_VALUE;
4752 }
4753 if (!data.WriteInt32(touchStatus)) {
4754 ROSEN_LOGE("NotifyTouchEvent: WriteInt32 touchStatus err.");
4755 return ERR_INVALID_VALUE;
4756 }
4757 if (!data.WriteInt32(touchCnt)) {
4758 ROSEN_LOGE("NotifyTouchEvent: WriteInt32 touchCnt err.");
4759 return ERR_INVALID_VALUE;
4760 }
4761 option.SetFlags(MessageOption::TF_ASYNC);
4762 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_TOUCH_EVENT);
4763 int32_t err = SendRequest(code, data, reply, option);
4764 if (err != NO_ERROR) {
4765 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyTouchEvent: Send Request err.");
4766 return ERR_INVALID_VALUE;
4767 }
4768 return ERR_OK;
4769 }
4770
NotifyDynamicModeEvent(bool enableDynamicMode)4771 void RSRenderServiceConnectionProxy::NotifyDynamicModeEvent(bool enableDynamicMode)
4772 {
4773 MessageParcel data;
4774 MessageParcel reply;
4775 MessageOption option;
4776 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4777 ROSEN_LOGE("NotifyDynamicModeEvent: WriteInterfaceToken GetDescriptor err.");
4778 return;
4779 }
4780 if (!data.WriteBool(enableDynamicMode)) {
4781 ROSEN_LOGE("NotifyDynamicModeEvent: WriteBool enableDynamicMode err.");
4782 return;
4783 }
4784 option.SetFlags(MessageOption::TF_ASYNC);
4785 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_DYNAMIC_MODE_EVENT);
4786 int32_t err = SendRequest(code, data, reply, option);
4787 if (err != NO_ERROR) {
4788 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyDynamicModeEvent: Send Request err.");
4789 return;
4790 }
4791 }
4792
NotifyHgmConfigEvent(const std::string & eventName,bool state)4793 ErrCode RSRenderServiceConnectionProxy::NotifyHgmConfigEvent(const std::string &eventName, bool state)
4794 {
4795 MessageParcel data;
4796 MessageParcel reply;
4797 MessageOption option;
4798 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4799 ROSEN_LOGE("NotifyHgmConfigEvent: GetDescriptor err.");
4800 return ERR_INVALID_VALUE;
4801 }
4802 if (!data.WriteString(eventName)) {
4803 return ERR_INVALID_VALUE;
4804 }
4805 if (!data.WriteBool(state)) {
4806 return ERR_INVALID_VALUE;
4807 }
4808 option.SetFlags(MessageOption::TF_ASYNC);
4809 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_HGMCONFIG_EVENT);
4810 int32_t err = SendRequest(code, data, reply, option);
4811 if (err != NO_ERROR) {
4812 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyHgmConfigEvent: Send Request err.");
4813 return ERR_INVALID_VALUE;
4814 }
4815 return ERR_OK;
4816 }
4817
NotifyXComponentExpectedFrameRate(const std::string & id,int32_t expectedFrameRate)4818 ErrCode RSRenderServiceConnectionProxy::NotifyXComponentExpectedFrameRate(
4819 const std::string& id, int32_t expectedFrameRate)
4820 {
4821 MessageParcel data;
4822 MessageParcel reply;
4823 MessageOption option;
4824 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4825 ROSEN_LOGE("NotifyXComponentExpectedFrameRate: GetDescriptor err.");
4826 return ERR_INVALID_VALUE;
4827 }
4828 if (!data.WriteString(id)) {
4829 return ERR_INVALID_VALUE;
4830 }
4831 if (!data.WriteInt32(expectedFrameRate)) {
4832 return ERR_INVALID_VALUE;
4833 }
4834 option.SetFlags(MessageOption::TF_ASYNC);
4835 uint32_t code = static_cast<uint32_t>(
4836 RSIRenderServiceConnectionInterfaceCode::NOTIFY_XCOMPONENT_EXPECTED_FRAMERATE);
4837 int32_t err = SendRequest(code, data, reply, option);
4838 if (err != NO_ERROR) {
4839 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyXComponentExpectedFrameRate: Send Request err.");
4840 return ERR_INVALID_VALUE;
4841 }
4842 return ERR_OK;
4843 }
4844
SetCacheEnabledForRotation(bool isEnabled)4845 ErrCode RSRenderServiceConnectionProxy::SetCacheEnabledForRotation(bool isEnabled)
4846 {
4847 MessageParcel data;
4848 MessageParcel reply;
4849 MessageOption option;
4850 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4851 ROSEN_LOGE("SetCacheEnabledForRotation: WriteInterfaceToken GetDescriptor err.");
4852 return ERR_INVALID_VALUE;
4853 }
4854 if (!data.WriteBool(isEnabled)) {
4855 ROSEN_LOGE("SetCacheEnabledForRotation: WriteBool isEnabled err.");
4856 return ERR_INVALID_VALUE;
4857 }
4858 option.SetFlags(MessageOption::TF_ASYNC);
4859 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_ROTATION_CACHE_ENABLED);
4860 int32_t err = SendRequest(code, data, reply, option);
4861 if (err != NO_ERROR) {
4862 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetCacheEnabledForRotation: Send Request err.");
4863 return ERR_INVALID_VALUE;
4864 }
4865 return ERR_OK;
4866 }
4867
SetOnRemoteDiedCallback(const OnRemoteDiedCallback & callback)4868 void RSRenderServiceConnectionProxy::SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback)
4869 {
4870 OnRemoteDiedCallback_ = callback;
4871 }
4872
RunOnRemoteDiedCallback()4873 void RSRenderServiceConnectionProxy::RunOnRemoteDiedCallback()
4874 {
4875 if (OnRemoteDiedCallback_) {
4876 OnRemoteDiedCallback_();
4877 }
4878 }
4879
GetActiveDirtyRegionInfo()4880 std::vector<ActiveDirtyRegionInfo> RSRenderServiceConnectionProxy::GetActiveDirtyRegionInfo()
4881 {
4882 MessageParcel data;
4883 MessageParcel reply;
4884 MessageOption option;
4885 std::vector<ActiveDirtyRegionInfo> activeDirtyRegionInfos;
4886 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4887 ROSEN_LOGE("GetActiveDirtyRegionInfo: WriteInterfaceToken GetDescriptor err.");
4888 return activeDirtyRegionInfos;
4889 }
4890 option.SetFlags(MessageOption::TF_SYNC);
4891 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_DIRTY_REGION_INFO);
4892 int32_t err = SendRequest(code, data, reply, option);
4893 if (err != NO_ERROR) {
4894 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetActiveDirtyRegionInfo: Send Request err.");
4895 return activeDirtyRegionInfos;
4896 }
4897 int32_t activeDirtyRegionInfosSize{0};
4898 if (!reply.ReadInt32(activeDirtyRegionInfosSize)) {
4899 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetActiveDirtyRegionInfo Read activeDirtyRegionInfosSize failed");
4900 return activeDirtyRegionInfos;
4901 }
4902 while (activeDirtyRegionInfosSize--) {
4903 int64_t activeDirtyRegionArea{0};
4904 int32_t activeFramesNumber{0};
4905 int32_t pidOfBelongsApp{0};
4906 std::string windowName;
4907 if (!reply.ReadInt64(activeDirtyRegionArea) || !reply.ReadInt32(activeFramesNumber) ||
4908 !reply.ReadInt32(pidOfBelongsApp) || !reply.ReadString(windowName)) {
4909 ROSEN_LOGE(
4910 "RSRenderServiceConnectionProxy::GetActiveDirtyRegionInfo Read parcel failed");
4911 return activeDirtyRegionInfos;
4912 }
4913 activeDirtyRegionInfos.emplace_back(
4914 ActiveDirtyRegionInfo(activeDirtyRegionArea, activeFramesNumber, pidOfBelongsApp, windowName));
4915 }
4916 return activeDirtyRegionInfos;
4917 }
4918
GetGlobalDirtyRegionInfo()4919 GlobalDirtyRegionInfo RSRenderServiceConnectionProxy::GetGlobalDirtyRegionInfo()
4920 {
4921 MessageParcel data;
4922 MessageParcel reply;
4923 MessageOption option;
4924 GlobalDirtyRegionInfo globalDirtyRegionInfo;
4925 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4926 ROSEN_LOGE("GetGlobalDirtyRegionInfo: WriteInterfaceToken GetDescriptor err.");
4927 return globalDirtyRegionInfo;
4928 }
4929 option.SetFlags(MessageOption::TF_SYNC);
4930 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_GLOBAL_DIRTY_REGION_INFO);
4931 int32_t err = SendRequest(code, data, reply, option);
4932 if (err != NO_ERROR) {
4933 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetGlobalDirtyRegionInfo: Send Request err.");
4934 return globalDirtyRegionInfo;
4935 }
4936 int64_t globalDirtyRegionAreas{0};
4937 int32_t globalFramesNumber{0};
4938 int32_t skipProcessFramesNumber{0};
4939 int32_t mostSendingPidWhenDisplayNodeSkip{0};
4940 if (!reply.ReadInt64(globalDirtyRegionAreas) || !reply.ReadInt32(globalFramesNumber) ||
4941 !reply.ReadInt32(skipProcessFramesNumber) || !reply.ReadInt32(mostSendingPidWhenDisplayNodeSkip)) {
4942 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetGlobalDirtyRegionInfo Read parcel failed");
4943 return globalDirtyRegionInfo;
4944 }
4945 return GlobalDirtyRegionInfo(
4946 globalDirtyRegionAreas, globalFramesNumber, skipProcessFramesNumber, mostSendingPidWhenDisplayNodeSkip);
4947 }
4948
GetLayerComposeInfo()4949 LayerComposeInfo RSRenderServiceConnectionProxy::GetLayerComposeInfo()
4950 {
4951 MessageParcel data;
4952 MessageParcel reply;
4953 MessageOption option;
4954 LayerComposeInfo layerComposeInfo;
4955 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4956 ROSEN_LOGE("GetLayerComposeInfo: WriteInterfaceToken GetDescriptor err.");
4957 return layerComposeInfo;
4958 }
4959 option.SetFlags(MessageOption::TF_SYNC);
4960 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_LAYER_COMPOSE_INFO);
4961 int32_t err = SendRequest(code, data, reply, option);
4962 if (err != NO_ERROR) {
4963 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetLayerComposeInfo: Send Request err.");
4964 return layerComposeInfo;
4965 }
4966 int32_t uniformRenderFrameNumber{0};
4967 int32_t offlineComposeFrameNumber{0};
4968 int32_t redrawFrameNumber{0};
4969 if (!reply.ReadInt32(uniformRenderFrameNumber) || !reply.ReadInt32(offlineComposeFrameNumber) ||
4970 !reply.ReadInt32(redrawFrameNumber)) {
4971 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetLayerComposeInfo Read parcel failed");
4972 return layerComposeInfo;
4973 }
4974 return LayerComposeInfo(uniformRenderFrameNumber, offlineComposeFrameNumber, redrawFrameNumber);
4975 }
4976
GetHwcDisabledReasonInfo()4977 HwcDisabledReasonInfos RSRenderServiceConnectionProxy::GetHwcDisabledReasonInfo()
4978 {
4979 MessageParcel data;
4980 MessageParcel reply;
4981 MessageOption option;
4982 HwcDisabledReasonInfos hwcDisabledReasonInfos;
4983 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
4984 ROSEN_LOGE("GetHwcDisabledReasonInfo: WriteInterfaceToken GetDescriptor err.");
4985 return hwcDisabledReasonInfos;
4986 }
4987 option.SetFlags(MessageOption::TF_SYNC);
4988 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::
4989 GET_HARDWARE_COMPOSE_DISABLED_REASON_INFO);
4990 int32_t err = SendRequest(code, data, reply, option);
4991 if (err != NO_ERROR) {
4992 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetHwcDisabledReasonInfo: Send Request err.");
4993 return hwcDisabledReasonInfos;
4994 }
4995 int32_t size{0};
4996 if (!reply.ReadInt32(size)) {
4997 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetHwcDisabledReasonInfo Read size failed");
4998 return hwcDisabledReasonInfos;
4999 }
5000 size_t readableSize = reply.GetReadableBytes() / HWC_DISABLED_REASON_INFO_MINIMUM_SIZE;
5001 size_t len = static_cast<size_t>(size);
5002 if (len > readableSize || len > hwcDisabledReasonInfos.max_size()) {
5003 RS_LOGE("RSRenderServiceConnectionProxy GetHwcDisabledReasonInfo Failed read vector, size:%{public}zu,"
5004 " readableSize:%{public}zu", len, readableSize);
5005 return hwcDisabledReasonInfos;
5006 }
5007
5008 HwcDisabledReasonInfo hwcDisabledReasonInfo;
5009 while (size--) {
5010 for (int32_t pos = 0; pos < HwcDisabledReasons::DISABLED_REASON_LENGTH; pos++) {
5011 hwcDisabledReasonInfo.disabledReasonStatistics[pos] = reply.ReadInt32();
5012 }
5013 hwcDisabledReasonInfo.pidOfBelongsApp = reply.ReadInt32();
5014 hwcDisabledReasonInfo.nodeName = reply.ReadString();
5015 hwcDisabledReasonInfos.emplace_back(hwcDisabledReasonInfo);
5016 }
5017 return hwcDisabledReasonInfos;
5018 }
5019
GetHdrOnDuration(int64_t & hdrOnDuration)5020 ErrCode RSRenderServiceConnectionProxy::GetHdrOnDuration(int64_t& hdrOnDuration)
5021 {
5022 MessageParcel data;
5023 MessageParcel reply;
5024 MessageOption option;
5025 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5026 ROSEN_LOGE("GetHdrOnDuration: WriteInterfaceToken GetDescriptor err.");
5027 return ERR_INVALID_VALUE;
5028 }
5029 option.SetFlags(MessageOption::TF_SYNC);
5030
5031 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_HDR_ON_DURATION);
5032 int32_t err = SendRequest(code, data, reply, option);
5033 if (err != NO_ERROR) {
5034 return ERR_INVALID_VALUE;
5035 }
5036 hdrOnDuration = reply.ReadInt64();
5037 return ERR_OK;
5038 }
5039
SetVmaCacheStatus(bool flag)5040 ErrCode RSRenderServiceConnectionProxy::SetVmaCacheStatus(bool flag)
5041 {
5042 MessageParcel data;
5043 MessageParcel reply;
5044 MessageOption option;
5045 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5046 ROSEN_LOGE("SetVmaCacheStatus: WriteInterfaceToken GetDescriptor err.");
5047 return ERR_INVALID_VALUE;
5048 }
5049 if (!data.WriteBool(flag)) {
5050 ROSEN_LOGE("SetVmaCacheStatus: WriteBool flag err.");
5051 return ERR_INVALID_VALUE;
5052 }
5053 option.SetFlags(MessageOption::TF_ASYNC);
5054 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VMA_CACHE_STATUS);
5055 int32_t err = SendRequest(code, data, reply, option);
5056 if (err != NO_ERROR) {
5057 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVmaCacheStatus %d: Send Request err.", flag);
5058 return ERR_INVALID_VALUE;
5059 }
5060 return ERR_OK;
5061 }
5062
5063 #ifdef TP_FEATURE_ENABLE
SetTpFeatureConfig(int32_t feature,const char * config,TpFeatureConfigType tpFeatureConfigType)5064 EErrCode RSRenderServiceConnectionProxy::SetTpFeatureConfig(int32_t feature, const char* config,
5065 TpFeatureConfigType tpFeatureConfigType)
5066 {
5067 MessageParcel data;
5068 MessageParcel reply;
5069 MessageOption option;
5070
5071 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5072 ROSEN_LOGE("SetTpFeatureConfig: WriteInterfaceToken GetDescriptor err.");
5073 return ERR_INVALID_VALUE;
5074 }
5075
5076 if (!data.WriteInt32(feature)) {
5077 ROSEN_LOGE("SetTpFeatureConfig: WriteInt32 feature err.");
5078 return ERR_INVALID_VALUE;
5079 }
5080
5081 if (!data.WriteCString(config)) {
5082 ROSEN_LOGE("SetTpFeatureConfig: WriteCString config err.");
5083 return ERR_INVALID_VALUE;
5084 }
5085
5086 if (!data.WriteUint8(static_cast<uint8_t>(tpFeatureConfigType))) {
5087 ROSEN_LOGE("SetTpFeatureConfig: WriteUint8 tpFeatureConfigType err.");
5088 return ERR_INVALID_VALUE;
5089 }
5090
5091 option.SetFlags(MessageOption::TF_SYNC);
5092 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_TP_FEATURE_CONFIG);
5093 int32_t err = SendRequest(code, data, reply, option);
5094 if (err != NO_ERROR) {
5095 return ERR_INVALID_VALUE;
5096 }
5097 return ERR_OK;
5098 }
5099 #endif
5100
SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus)5101 void RSRenderServiceConnectionProxy::SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus)
5102 {
5103 MessageParcel data;
5104 MessageParcel reply;
5105 MessageOption option;
5106 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5107 ROSEN_LOGE("SetVirtualScreenUsingStatus: WriteInterfaceToken GetDescriptor err.");
5108 return;
5109 }
5110 if (!data.WriteBool(isVirtualScreenUsingStatus)) {
5111 ROSEN_LOGE("SetVirtualScreenUsingStatus: WriteBool isVirtualScreenUsingStatus err.");
5112 return;
5113 }
5114 option.SetFlags(MessageOption::TF_ASYNC);
5115 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_USING_STATUS);
5116 int32_t err = SendRequest(code, data, reply, option);
5117 if (err != NO_ERROR) {
5118 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenUsingStatus: Send Request err.");
5119 return;
5120 }
5121 }
5122
SetCurtainScreenUsingStatus(bool isCurtainScreenOn)5123 ErrCode RSRenderServiceConnectionProxy::SetCurtainScreenUsingStatus(bool isCurtainScreenOn)
5124 {
5125 MessageParcel data;
5126 MessageParcel reply;
5127 MessageOption option;
5128 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5129 ROSEN_LOGE("SetCurtainScreenUsingStatus: WriteInterfaceToken GetDescriptor err.");
5130 return ERR_INVALID_VALUE;
5131 }
5132 if (!data.WriteBool(isCurtainScreenOn)) {
5133 ROSEN_LOGE("SetCurtainScreenUsingStatus: WriteBool isCurtainScreenOn err.");
5134 return ERR_INVALID_VALUE;
5135 }
5136 option.SetFlags(MessageOption::TF_ASYNC);
5137 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_CURTAIN_SCREEN_USING_STATUS);
5138 int32_t err = SendRequest(code, data, reply, option);
5139 if (err != NO_ERROR) {
5140 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetCurtainScreenUsingStatus: Send Request err.");
5141 return ERR_INVALID_VALUE;
5142 }
5143 return ERR_OK;
5144 }
5145
DropFrameByPid(const std::vector<int32_t> pidList)5146 ErrCode RSRenderServiceConnectionProxy::DropFrameByPid(const std::vector<int32_t> pidList)
5147 {
5148 MessageParcel data;
5149 MessageParcel reply;
5150 MessageOption option;
5151 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5152 ROSEN_LOGE("DropFrameByPid: WriteInterfaceToken GetDescriptor err.");
5153 return ERR_INVALID_VALUE;
5154 }
5155
5156 if (pidList.size() > MAX_DROP_FRAME_PID_LIST_SIZE || !data.WriteInt32Vector(pidList)) {
5157 ROSEN_LOGE("DropFrameByPid: WriteInt32Vector pidList err.");
5158 return ERR_INVALID_VALUE;
5159 }
5160 option.SetFlags(MessageOption::TF_ASYNC);
5161 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::DROP_FRAME_BY_PID);
5162 int32_t err = SendRequest(code, data, reply, option);
5163 if (err != NO_ERROR) {
5164 ROSEN_LOGE("RSRenderServiceConnectionProxy::DropFrameByPid: Send Request err.");
5165 return ERR_INVALID_VALUE;
5166 }
5167 return ERR_OK;
5168 }
5169
RegisterUIExtensionCallback(uint64_t userId,sptr<RSIUIExtensionCallback> callback,bool unobscured)5170 int32_t RSRenderServiceConnectionProxy::RegisterUIExtensionCallback(
5171 uint64_t userId, sptr<RSIUIExtensionCallback> callback, bool unobscured)
5172 {
5173 if (callback == nullptr) {
5174 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterUIExtensionCallback: callback is nullptr.");
5175 return INVALID_ARGUMENTS;
5176 }
5177 MessageParcel data;
5178 MessageParcel reply;
5179 MessageOption option;
5180 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5181 ROSEN_LOGE("RegisterUIExtensionCallback: WriteInterfaceToken GetDescriptor err.");
5182 return RS_CONNECTION_ERROR;
5183 }
5184 option.SetFlags(MessageOption::TF_SYNC);
5185 if (data.WriteUint64(userId) && data.WriteRemoteObject(callback->AsObject()) && data.WriteBool(unobscured)) {
5186 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_UIEXTENSION_CALLBACK);
5187 int32_t err = SendRequest(code, data, reply, option);
5188 if (err != NO_ERROR) {
5189 return RS_CONNECTION_ERROR;
5190 }
5191 int32_t result{0};
5192 if (!reply.ReadInt32(result)) {
5193 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterUIExtensionCallback Read result failed");
5194 return READ_PARCEL_ERR;
5195 }
5196 return result;
5197 } else {
5198 ROSEN_LOGE("RegisterUIExtensionCallback: WriteUint64[userId] OR WriteRemoteObject[callback] err.");
5199 return RS_CONNECTION_ERROR;
5200 }
5201 }
5202
SetVirtualScreenStatus(ScreenId id,VirtualScreenStatus screenStatus,bool & success)5203 ErrCode RSRenderServiceConnectionProxy::SetVirtualScreenStatus(ScreenId id,
5204 VirtualScreenStatus screenStatus, bool& success)
5205 {
5206 MessageParcel data;
5207 MessageParcel reply;
5208 MessageOption option;
5209 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5210 ROSEN_LOGE("SetVirtualScreenStatus: WriteInterfaceToken GetDescriptor err.");
5211 success = false;
5212 return ERR_INVALID_VALUE;
5213 }
5214 option.SetFlags(MessageOption::TF_SYNC);
5215 if (!data.WriteUint64(id)) {
5216 ROSEN_LOGE("SetVirtualScreenStatus: WriteUint64 id err.");
5217 success = false;
5218 return ERR_INVALID_VALUE;
5219 }
5220 if (!data.WriteUint8(static_cast<uint8_t>(screenStatus))) {
5221 ROSEN_LOGE("SetVirtualScreenStatus: WriteUint8 screenStatus err.");
5222 success = false;
5223 return ERR_INVALID_VALUE;
5224 }
5225 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_STATUS);
5226 int32_t err = SendRequest(code, data, reply, option);
5227 if (err != NO_ERROR) {
5228 success = false;
5229 return ERR_INVALID_VALUE;
5230 }
5231 if (!reply.ReadBool(success)) {
5232 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenStatus Read result failed");
5233 return READ_PARCEL_ERR;
5234 }
5235 return ERR_OK;
5236 }
5237
SetAncoForceDoDirect(bool direct,bool & res)5238 ErrCode RSRenderServiceConnectionProxy::SetAncoForceDoDirect(bool direct, bool& res)
5239 {
5240 MessageParcel data;
5241 MessageParcel reply;
5242 MessageOption option;
5243 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5244 ROSEN_LOGE("SetAncoForceDoDirect: WriteInterfaceToken GetDescriptor err.");
5245 res = false;
5246 return ERR_INVALID_VALUE;
5247 }
5248 option.SetFlags(MessageOption::TF_SYNC);
5249 if (data.WriteBool(direct)) {
5250 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_ANCO_FORCE_DO_DIRECT);
5251 int32_t err = SendRequest(code, data, reply, option);
5252 if (err != NO_ERROR) {
5253 res = false;
5254 return ERR_INVALID_VALUE;
5255 }
5256 res = reply.ReadBool();
5257 return ERR_OK;
5258 } else {
5259 ROSEN_LOGE("SetAncoForceDoDirect: WriteBool direct err.");
5260 res = false;
5261 return ERR_INVALID_VALUE;
5262 }
5263 }
5264
SetFreeMultiWindowStatus(bool enable)5265 void RSRenderServiceConnectionProxy::SetFreeMultiWindowStatus(bool enable)
5266 {
5267 MessageParcel data;
5268 MessageParcel reply;
5269 MessageOption option;
5270 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5271 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFreeMultiWindowStatus: write token err.");
5272 return;
5273 }
5274 option.SetFlags(MessageOption::TF_ASYNC);
5275 if (!data.WriteBool(enable)) {
5276 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFreeMultiWindowStatus: write bool val err.");
5277 return;
5278 }
5279 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_FREE_MULTI_WINDOW_STATUS);
5280 int32_t err = SendRequest(code, data, reply, option);
5281 if (err != NO_ERROR) {
5282 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFreeMultiWindowStatus: Send Request err.");
5283 }
5284 }
RegisterTransactionDataCallback(uint64_t token,uint64_t timeStamp,sptr<RSITransactionDataCallback> callback)5285 void RSRenderServiceConnectionProxy::RegisterTransactionDataCallback(uint64_t token,
5286 uint64_t timeStamp, sptr<RSITransactionDataCallback> callback)
5287 {
5288 if (callback == nullptr) {
5289 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback callback == nullptr.");
5290 return;
5291 }
5292 MessageParcel data;
5293 MessageParcel reply;
5294 MessageOption option;
5295 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5296 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback: write token err.");
5297 return;
5298 }
5299 option.SetFlags(MessageOption::TF_ASYNC);
5300 static_assert(std::is_same_v<int32_t, pid_t>, "pid_t is not int32_t on this platform.");
5301 if (!data.WriteUint64(token)) {
5302 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback: write multi token val err.");
5303 return;
5304 }
5305 if (!data.WriteUint64(timeStamp)) {
5306 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback: write timeStamp val err.");
5307 return;
5308 }
5309 if (!data.WriteRemoteObject(callback->AsObject())) {
5310 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback: write Callback val err.");
5311 return;
5312 }
5313 uint32_t code = static_cast<uint32_t>(
5314 RSIRenderServiceConnectionInterfaceCode::REGISTER_TRANSACTION_DATA_CALLBACK);
5315 RS_LOGD("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback: timeStamp: %{public}"
5316 PRIu64 " token: %{public}" PRIu64, timeStamp, token);
5317 int32_t err = SendRequest(code, data, reply, option);
5318 if (err != NO_ERROR) {
5319 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback: Send Request err.");
5320 return;
5321 }
5322 }
5323
RegisterSurfaceBufferCallback(pid_t pid,uint64_t uid,sptr<RSISurfaceBufferCallback> callback)5324 ErrCode RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback(
5325 pid_t pid, uint64_t uid, sptr<RSISurfaceBufferCallback> callback)
5326 {
5327 if (callback == nullptr) {
5328 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback callback == nullptr");
5329 return ERR_INVALID_VALUE;
5330 }
5331 MessageParcel data;
5332 MessageParcel reply;
5333 MessageOption option;
5334 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5335 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: write token err.");
5336 return ERR_INVALID_VALUE;
5337 }
5338 option.SetFlags(MessageOption::TF_ASYNC);
5339 static_assert(std::is_same_v<int32_t, pid_t>, "pid_t is not int32_t on this platform.");
5340 if (!data.WriteInt32(pid)) {
5341 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: write Int32 val err.");
5342 return ERR_INVALID_VALUE;
5343 }
5344 if (!data.WriteUint64(uid)) {
5345 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: write Uint64 val err.");
5346 return ERR_INVALID_VALUE;
5347 }
5348 if (!data.WriteRemoteObject(callback->AsObject())) {
5349 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: write RemoteObject val err.");
5350 return ERR_INVALID_VALUE;
5351 }
5352 uint32_t code = static_cast<uint32_t>(
5353 RSIRenderServiceConnectionInterfaceCode::REGISTER_SURFACE_BUFFER_CALLBACK);
5354 int32_t err = SendRequest(code, data, reply, option);
5355 if (err != NO_ERROR) {
5356 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: Send Request err.");
5357 return ERR_INVALID_VALUE;
5358 }
5359 return ERR_OK;
5360 }
5361
UnregisterSurfaceBufferCallback(pid_t pid,uint64_t uid)5362 ErrCode RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid)
5363 {
5364 MessageParcel data;
5365 MessageParcel reply;
5366 MessageOption option;
5367 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5368 ROSEN_LOGE("RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback: write token err.");
5369 return ERR_INVALID_VALUE;
5370 }
5371 option.SetFlags(MessageOption::TF_ASYNC);
5372 static_assert(std::is_same_v<int32_t, pid_t>, "pid_t is not int32_t on this platform.");
5373 if (!data.WriteInt32(pid)) {
5374 ROSEN_LOGE("RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback: write Int32 val err.");
5375 return ERR_INVALID_VALUE;
5376 }
5377 if (!data.WriteUint64(uid)) {
5378 ROSEN_LOGE("RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback: write Uint64 val err.");
5379 return ERR_INVALID_VALUE;
5380 }
5381 uint32_t code = static_cast<uint32_t>(
5382 RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SURFACE_BUFFER_CALLBACK);
5383 int32_t err = SendRequest(code, data, reply, option);
5384 if (err != NO_ERROR) {
5385 ROSEN_LOGE("RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback: Send Request err.");
5386 return ERR_INVALID_VALUE;
5387 }
5388 return ERR_OK;
5389 }
5390
SetLayerTopForHWC(NodeId nodeId,bool isTop,uint32_t zOrder)5391 ErrCode RSRenderServiceConnectionProxy::SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder)
5392 {
5393 MessageParcel data;
5394 MessageParcel reply;
5395 MessageOption option;
5396 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5397 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetLayerTopForHWC: write token err.");
5398 return ERR_INVALID_VALUE;
5399 }
5400 option.SetFlags(MessageOption::TF_ASYNC);
5401 if (data.WriteUint64(nodeId) && data.WriteBool(isTop) && data.WriteUint32(zOrder)) {
5402 uint32_t code =
5403 static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP_FOR_HARDWARE_COMPOSER);
5404 int32_t err = SendRequest(code, data, reply, option);
5405 if (err != NO_ERROR) {
5406 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetLayerTopForHWC: Send Request err.");
5407 return ERR_INVALID_VALUE;
5408 }
5409 }
5410 return ERR_OK;
5411 }
5412
SetLayerTop(const std::string & nodeIdStr,bool isTop)5413 ErrCode RSRenderServiceConnectionProxy::SetLayerTop(const std::string &nodeIdStr, bool isTop)
5414 {
5415 MessageParcel data;
5416 MessageParcel reply;
5417 MessageOption option;
5418 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5419 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetLayerTop: write token err.");
5420 return ERR_INVALID_VALUE;
5421 }
5422 option.SetFlags(MessageOption::TF_ASYNC);
5423 if (data.WriteString(nodeIdStr) && data.WriteBool(isTop)) {
5424 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP);
5425 int32_t err = SendRequest(code, data, reply, option);
5426 if (err != NO_ERROR) {
5427 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetLayerTop: Send Request err.");
5428 return ERR_INVALID_VALUE;
5429 }
5430 }
5431 return ERR_OK;
5432 }
5433
SetForceRefresh(const std::string & nodeIdStr,bool isForceRefresh)5434 ErrCode RSRenderServiceConnectionProxy::SetForceRefresh(const std::string &nodeIdStr, bool isForceRefresh)
5435 {
5436 MessageParcel data;
5437 MessageParcel reply;
5438 MessageOption option;
5439 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5440 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetForceRefresh: write token err.");
5441 return ERR_INVALID_VALUE;
5442 }
5443 option.SetFlags(MessageOption::TF_ASYNC);
5444 if (data.WriteString(nodeIdStr) && data.WriteBool(isForceRefresh)) {
5445 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_FORCE_REFRESH);
5446 int32_t err = SendRequest(code, data, reply, option);
5447 if (err != NO_ERROR) {
5448 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetForceRefresh: Send Request err.");
5449 return ERR_INVALID_VALUE;
5450 }
5451 }
5452 return ERR_OK;
5453 }
5454
SetColorFollow(const std::string & nodeIdStr,bool isColorFollow)5455 void RSRenderServiceConnectionProxy::SetColorFollow(const std::string &nodeIdStr, bool isColorFollow)
5456 {
5457 MessageParcel data;
5458 MessageParcel reply;
5459 MessageOption option;
5460 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5461 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetColorFollow: write token err.");
5462 return;
5463 }
5464 option.SetFlags(MessageOption::TF_ASYNC);
5465 if (data.WriteString(nodeIdStr) && data.WriteBool(isColorFollow)) {
5466 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_COLOR_FOLLOW);
5467 int32_t err = SendRequest(code, data, reply, option);
5468 if (err != NO_ERROR) {
5469 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetColorFollow: Send Request err.");
5470 return;
5471 }
5472 }
5473 }
5474
SetWindowContainer(NodeId nodeId,bool value)5475 ErrCode RSRenderServiceConnectionProxy::SetWindowContainer(NodeId nodeId, bool value)
5476 {
5477 MessageParcel data;
5478 MessageParcel reply;
5479 MessageOption option;
5480 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5481 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWindowContainer: write token err.");
5482 return ERR_INVALID_VALUE;
5483 }
5484 option.SetFlags(MessageOption::TF_ASYNC);
5485 if (!data.WriteUint64(nodeId)) {
5486 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWindowContainer: write Uint64 val err.");
5487 return ERR_INVALID_VALUE;
5488 }
5489 if (!data.WriteBool(value)) {
5490 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWindowContainer: write Bool val err.");
5491 return ERR_INVALID_VALUE;
5492 }
5493 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_WINDOW_CONTAINER);
5494 int32_t err = SendRequest(code, data, reply, option);
5495 if (err != NO_ERROR) {
5496 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWindowContainer: Send Request err.");
5497 return ERR_INVALID_VALUE;
5498 }
5499 return ERR_OK;
5500 }
5501
RegisterSelfDrawingNodeRectChangeCallback(const RectConstraint & constraint,sptr<RSISelfDrawingNodeRectChangeCallback> callback)5502 int32_t RSRenderServiceConnectionProxy::RegisterSelfDrawingNodeRectChangeCallback(
5503 const RectConstraint& constraint, sptr<RSISelfDrawingNodeRectChangeCallback> callback)
5504 {
5505 if (!callback) {
5506 ROSEN_LOGE("%{public}s callback is nullptr", __func__);
5507 return ERR_INVALID_VALUE;
5508 }
5509 MessageParcel data;
5510 MessageParcel reply;
5511 MessageOption option;
5512
5513 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5514 ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: WriteInterfaceToken GetDescriptor err.");
5515 return WRITE_PARCEL_ERR;
5516 }
5517 option.SetFlags(MessageOption::TF_SYNC);
5518
5519 uint32_t size = constraint.pids.size();
5520 if (!data.WriteUint32(size)) {
5521 ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Write size err.");
5522 return WRITE_PARCEL_ERR;
5523 }
5524 for (int32_t pid : constraint.pids) {
5525 if (!data.WriteInt32(pid)) {
5526 ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Write pid err.");
5527 return WRITE_PARCEL_ERR;
5528 }
5529 }
5530
5531 if (!data.WriteInt32(constraint.range.lowLimit.width) || !data.WriteInt32(constraint.range.lowLimit.height) ||
5532 !data.WriteInt32(constraint.range.highLimit.width) || !data.WriteInt32(constraint.range.highLimit.height)) {
5533 ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Write rectRange err.");
5534 return WRITE_PARCEL_ERR;
5535 }
5536 if (!data.WriteRemoteObject(callback->AsObject())) {
5537 ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: WriteRemoteObject callback->AsObject() err.");
5538 return WRITE_PARCEL_ERR;
5539 }
5540 uint32_t code =
5541 static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK);
5542 int32_t err = SendRequest(code, data, reply, option);
5543 if (err != NO_ERROR) {
5544 ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Send request err.");
5545 return RS_CONNECTION_ERROR;
5546 }
5547 int32_t result{0};
5548 if (!reply.ReadInt32(result)) {
5549 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSelfDrawingNodeRectChangeCallback Read result failed");
5550 return READ_PARCEL_ERR;
5551 }
5552 return result;
5553 }
5554
UnRegisterSelfDrawingNodeRectChangeCallback()5555 int32_t RSRenderServiceConnectionProxy::UnRegisterSelfDrawingNodeRectChangeCallback()
5556 {
5557 MessageParcel data;
5558 MessageParcel reply;
5559 MessageOption option;
5560
5561 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5562 ROSEN_LOGE("UnRegisterSelfDrawingNodeRectChangeCallback: WriteInterfaceToken GetDescriptor err.");
5563 return WRITE_PARCEL_ERR;
5564 }
5565 option.SetFlags(MessageOption::TF_SYNC);
5566
5567 uint32_t code = static_cast<uint32_t>(
5568 RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK);
5569 int32_t err = SendRequest(code, data, reply, option);
5570 if (err != NO_ERROR) {
5571 ROSEN_LOGE("UnRegisterSelfDrawingNodeRectChangeCallback: Send request err.");
5572 return RS_CONNECTION_ERROR;
5573 }
5574 int32_t result{0};
5575 if (!reply.ReadInt32(result)) {
5576 ROSEN_LOGE("RSRenderServiceConnectionProxy::UnRegisterSelfDrawingNodeRectChangeCallback Read result failed");
5577 return READ_PARCEL_ERR;
5578 }
5579 return result;
5580 }
5581
GetHighContrastTextState()5582 bool RSRenderServiceConnectionProxy::GetHighContrastTextState()
5583 {
5584 MessageParcel data;
5585 MessageParcel reply;
5586 MessageOption option;
5587 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_HIGH_CONTRAST_TEXT_STATE);
5588 int32_t err = SendRequest(code, data, reply, option);
5589 if (err != NO_ERROR) {
5590 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetHighContrastTextState: Send Request err.");
5591 return false;
5592 }
5593 return reply.ReadBool();
5594 }
5595
SendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)5596 int32_t RSRenderServiceConnectionProxy::SendRequest(uint32_t code, MessageParcel &data,
5597 MessageParcel &reply, MessageOption &option)
5598 {
5599 if (!Remote()) {
5600 return static_cast<int32_t>(RSInterfaceErrorCode::NULLPTR_ERROR);
5601 }
5602 return Remote()->SendRequest(code, data, reply, option);
5603 }
5604
NotifyScreenSwitched()5605 ErrCode RSRenderServiceConnectionProxy::NotifyScreenSwitched()
5606 {
5607 MessageParcel data;
5608 MessageParcel reply;
5609 MessageOption option;
5610 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5611 ROSEN_LOGE("%{public}s: Write InterfaceToken val err.", __func__);
5612 return ERR_INVALID_VALUE;
5613 }
5614 option.SetFlags(MessageOption::TF_ASYNC);
5615 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SCREEN_SWITCHED);
5616 int32_t err = SendRequest(code, data, reply, option);
5617 if (err != NO_ERROR) {
5618 ROSEN_LOGE("%{public}s: Send Request error.", __func__);
5619 return ERR_INVALID_VALUE;
5620 }
5621 return ERR_OK;
5622 }
5623
5624 #ifdef RS_ENABLE_OVERLAY_DISPLAY
SetOverlayDisplayMode(int32_t mode)5625 ErrCode RSRenderServiceConnectionProxy::SetOverlayDisplayMode(int32_t mode)
5626 {
5627 MessageParcel data;
5628 MessageParcel reply;
5629 MessageOption option;
5630 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5631 ROSEN_LOGE("%{public}s: Write InterfaceToken val err.", __func__);
5632 return ERR_INVALID_VALUE;
5633 }
5634 option.SetFlags(MessageOption::TF_SYNC);
5635 if (!data.WriteInt32(mode)) {
5636 ROSEN_LOGE("%{public}s: Write Int32 val err.", __func__);
5637 return ERR_INVALID_VALUE;
5638 }
5639 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_OVERLAY_DISPLAY_MODE);
5640 int32_t err = SendRequest(code, data, reply, option);
5641 if (err != NO_ERROR) {
5642 ROSEN_LOGE("%{public}s: SendRequest failed. err:%{public}d.", __func__, err);
5643 return ERR_INVALID_VALUE;
5644 }
5645 int32_t result{0};
5646 if (!reply.ReadInt32(result)) {
5647 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetOverlayDisplayMode Read result failed");
5648 return READ_PARCEL_ERR;
5649 }
5650 ROSEN_LOGI("%{public}s: mode:%{public}d, result:%{public}d.", __func__, mode, result);
5651 return result == 0 ? ERR_OK : ERR_INVALID_VALUE;
5652 }
5653 #endif
5654
NotifyPageName(const std::string & packageName,const std::string & pageName,bool isEnter)5655 ErrCode RSRenderServiceConnectionProxy::NotifyPageName(const std::string &packageName,
5656 const std::string &pageName, bool isEnter)
5657 {
5658 MessageParcel data;
5659 MessageParcel reply;
5660 MessageOption option;
5661 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5662 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyPageName: write token err.");
5663 return ERR_INVALID_VALUE;
5664 }
5665 option.SetFlags(MessageOption::TF_ASYNC);
5666 if (data.WriteString(packageName) && data.WriteString(pageName) && data.WriteBool(isEnter)) {
5667 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PAGE_NAME);
5668 int32_t err = SendRequest(code, data, reply, option);
5669 if (err != NO_ERROR) {
5670 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyPageName: Send Request err.");
5671 return ERR_INVALID_VALUE;
5672 }
5673 } else {
5674 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyPageName: write data err.");
5675 return ERR_INVALID_VALUE;
5676 }
5677 return ERR_OK;
5678 }
5679
SetBehindWindowFilterEnabled(bool enabled)5680 ErrCode RSRenderServiceConnectionProxy::SetBehindWindowFilterEnabled(bool enabled)
5681 {
5682 MessageParcel data;
5683 MessageParcel reply;
5684 MessageOption option;
5685 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5686 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetBehindWindowFilterEnabled WriteInterfaceToken err.");
5687 return ERR_INVALID_VALUE;
5688 }
5689 option.SetFlags(MessageOption::TF_SYNC);
5690 if (!data.WriteBool(enabled)) {
5691 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetBehindWindowFilterEnabled WriteBool err.");
5692 return ERR_INVALID_VALUE;
5693 }
5694 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_BEHIND_WINDOW_FILTER_ENABLED);
5695 int32_t err = SendRequest(code, data, reply, option);
5696 if (err != NO_ERROR) {
5697 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetBehindWindowFilterEnabled sendrequest error : %{public}d", err);
5698 return ERR_INVALID_VALUE;
5699 }
5700 return ERR_OK;
5701 }
5702
GetBehindWindowFilterEnabled(bool & enabled)5703 ErrCode RSRenderServiceConnectionProxy::GetBehindWindowFilterEnabled(bool& enabled)
5704 {
5705 MessageParcel data;
5706 MessageParcel reply;
5707 MessageOption option;
5708 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5709 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetBehindWindowFilterEnabled WriteInterfaceToken err.");
5710 return ERR_INVALID_VALUE;
5711 }
5712 option.SetFlags(MessageOption::TF_SYNC);
5713 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_BEHIND_WINDOW_FILTER_ENABLED);
5714 int32_t err = SendRequest(code, data, reply, option);
5715 if (err != NO_ERROR) {
5716 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetBehindWindowFilterEnabled sendrequest error : %{public}d", err);
5717 return ERR_INVALID_VALUE;
5718 }
5719 if (!reply.ReadBool(enabled)) {
5720 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetBehindWindowFilterEnabled ReadBool err.");
5721 return ERR_INVALID_VALUE;
5722 }
5723 return ERR_OK;
5724 }
5725
GetPidGpuMemoryInMB(pid_t pid,float & gpuMemInMB)5726 int32_t RSRenderServiceConnectionProxy::GetPidGpuMemoryInMB(pid_t pid, float &gpuMemInMB)
5727 {
5728 MessageParcel data;
5729 MessageParcel reply;
5730 MessageOption option;
5731
5732 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5733 return RS_CONNECTION_ERROR;
5734 }
5735
5736 if (!data.WriteInt32(pid)) {
5737 return WRITE_PARCEL_ERR;
5738 }
5739
5740 option.SetFlags(MessageOption::TF_SYNC);
5741 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_PID_GPU_MEMORY_IN_MB);
5742 int32_t err = SendRequest(code, data, reply, option);
5743 if (err != NO_ERROR) {
5744 return RS_CONNECTION_ERROR;
5745 }
5746 if (!reply.ReadFloat(gpuMemInMB)) {
5747 return READ_PARCEL_ERR;
5748 }
5749
5750 return err;
5751 }
5752
ProfilerServiceOpenFile(const HrpServiceDirInfo & dirInfo,const std::string & fileName,int32_t flags,int & outFd)5753 RetCodeHrpService RSRenderServiceConnectionProxy::ProfilerServiceOpenFile(const HrpServiceDirInfo& dirInfo,
5754 const std::string& fileName, int32_t flags, int& outFd)
5755 {
5756 const uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::PROFILER_SERVICE_OPEN_FILE);
5757 MessageParcel data;
5758 MessageParcel reply;
5759 MessageOption option;
5760 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5761 ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerServiceOpenFile WriteInterfaceToken err.");
5762 return RET_HRP_SERVICE_ERR_UNKNOWN;
5763 }
5764 option.SetFlags(MessageOption::TF_SYNC);
5765 data.WriteUint32((uint32_t)dirInfo.baseDirType);
5766 data.WriteString(dirInfo.subDir);
5767 data.WriteString(dirInfo.subDir2);
5768 data.WriteString(fileName);
5769 data.WriteInt32(flags);
5770
5771 int32_t err = SendRequest(code, data, reply, option);
5772 if (err != ERR_NONE) {
5773 ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerServiceOpenFile sendrequest error : %{public}d", err);
5774 return RET_HRP_SERVICE_ERR_PROXY_SEND_REQUEST;
5775 }
5776
5777 int32_t retCode = RET_HRP_SERVICE_ERR_UNKNOWN;
5778 if (!reply.ReadInt32(retCode)) {
5779 return RET_HRP_SERVICE_ERR_PROXY_INVALID_RESULT;
5780 }
5781
5782 int retFd = reply.ReadFileDescriptor();
5783 if (retFd == -1) {
5784 return retCode < 0 ? (RetCodeHrpService)retCode : RET_HRP_SERVICE_ERR_INVALID_FILE_DESCRIPTOR;
5785 }
5786
5787 outFd = retFd;
5788 return (RetCodeHrpService)retCode;
5789 }
5790
ProfilerServicePopulateFiles(const HrpServiceDirInfo & dirInfo,uint32_t firstFileIndex,std::vector<HrpServiceFileInfo> & outFiles)5791 RetCodeHrpService RSRenderServiceConnectionProxy::ProfilerServicePopulateFiles(const HrpServiceDirInfo& dirInfo,
5792 uint32_t firstFileIndex, std::vector<HrpServiceFileInfo>& outFiles)
5793 {
5794 const uint32_t code =
5795 static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::PROFILER_SERVICE_POPULATE_FILES);
5796 MessageParcel data;
5797 MessageParcel reply;
5798 MessageOption option;
5799 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5800 ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerServicePopulateFiles WriteInterfaceToken err.");
5801 return RET_HRP_SERVICE_ERR_UNKNOWN;
5802 }
5803 option.SetFlags(MessageOption::TF_SYNC);
5804 data.WriteUint32((uint32_t)dirInfo.baseDirType);
5805 data.WriteString(dirInfo.subDir);
5806 data.WriteString(dirInfo.subDir2);
5807 data.WriteUint32(firstFileIndex);
5808
5809 int32_t err = SendRequest(code, data, reply, option);
5810 if (err != ERR_NONE) {
5811 ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerServicePopulateFiles sendrequest error : %{public}d", err);
5812 return RET_HRP_SERVICE_ERR_PROXY_SEND_REQUEST;
5813 }
5814
5815 int32_t retCode = RET_HRP_SERVICE_ERR_UNKNOWN;
5816 if (!reply.ReadInt32(retCode)) {
5817 return RET_HRP_SERVICE_ERR_PROXY_INVALID_RESULT;
5818 }
5819 if (retCode < RET_HRP_SERVICE_SUCCESS) {
5820 return (RetCodeHrpService)retCode;
5821 }
5822
5823 uint32_t retCount = 0;
5824 if (!reply.ReadUint32(retCount)) {
5825 return RET_HRP_SERVICE_ERR_PROXY_INVALID_RESULT;
5826 }
5827
5828 std::vector<HrpServiceFileInfo> retFiles;
5829 for (uint32_t i = 0; i < retCount; i++) {
5830 HrpServiceFileInfo fi {};
5831 if (!reply.ReadString(fi.name) || !reply.ReadUint32(fi.size) || !reply.ReadBool(fi.isDir) ||
5832 !reply.ReadUint32(fi.accessBits) || !reply.ReadUint64(fi.accessTime.sec) ||
5833 !reply.ReadUint64(fi.accessTime.nsec) || !reply.ReadUint64(fi.modifyTime.sec) ||
5834 !reply.ReadUint64(fi.modifyTime.nsec)) {
5835 return RET_HRP_SERVICE_ERR_PROXY_INVALID_RESULT_DATA;
5836 }
5837 retFiles.emplace_back(fi);
5838 }
5839 outFiles.swap(retFiles);
5840 return (RetCodeHrpService)retCode;
5841 }
5842
ProfilerIsSecureScreen()5843 bool RSRenderServiceConnectionProxy::ProfilerIsSecureScreen()
5844 {
5845 const uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::PROFILER_IS_SECURE_SCREEN);
5846 MessageParcel data;
5847 MessageParcel reply;
5848 MessageOption option;
5849 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5850 ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerIsSecureScreen WriteInterfaceToken err.");
5851 return false;
5852 }
5853 option.SetFlags(MessageOption::TF_SYNC);
5854 int32_t err = SendRequest(code, data, reply, option);
5855 if (err != ERR_NONE) {
5856 ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerIsSecureScreen sendrequest error : %{public}d", err);
5857 return false;
5858 }
5859
5860 bool retValue = false;
5861 if (!reply.ReadBool(retValue)) {
5862 ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerIsSecureScreen ReadBool err.");
5863 return false;
5864 }
5865 return retValue;
5866 }
5867
ClearUifirstCache(NodeId id)5868 void RSRenderServiceConnectionProxy::ClearUifirstCache(NodeId id)
5869 {
5870 MessageParcel data;
5871 MessageParcel reply;
5872 MessageOption option;
5873 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
5874 ROSEN_LOGE("RSRenderServiceConnectionProxy::ClearUifirstCache: write token err.");
5875 return;
5876 }
5877 option.SetFlags(MessageOption::TF_ASYNC);
5878 if (!data.WriteUint64(id)) {
5879 ROSEN_LOGE("ClearUifirstCache: WriteUint64 id err.");
5880 return;
5881 }
5882 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CLEAR_UIFIRST_CACHE);
5883 int32_t err = SendRequest(code, data, reply, option);
5884 if (err != NO_ERROR) {
5885 ROSEN_LOGE("RSRenderServiceConnectionProxy::ClearUifirstCache sendrequest error : %{public}d", err);
5886 return;
5887 }
5888 }
5889
SetGpuCrcDirtyEnabledPidList(const std::vector<int32_t> pidList)5890 ErrCode RSRenderServiceConnectionProxy::SetGpuCrcDirtyEnabledPidList(const std::vector<int32_t> pidList)
5891 {
5892 return ERR_INVALID_VALUE;
5893 }
5894
SetOptimizeCanvasDirtyPidList(const std::vector<int32_t> & pidList)5895 ErrCode RSRenderServiceConnectionProxy::SetOptimizeCanvasDirtyPidList(const std::vector<int32_t>& pidList)
5896 {
5897 return ERR_INVALID_VALUE;
5898 }
5899 } // namespace Rosen
5900 } // namespace OHOS
5901