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_marshalling_helper.h"
27 #include "rs_trace.h"
28
29 namespace OHOS {
30 namespace Rosen {
31 namespace {
32 static constexpr size_t ASHMEM_SIZE_THRESHOLD = 400 * 1024; // cannot > 500K in TF_ASYNC mode
33 }
34
RSRenderServiceConnectionProxy(const sptr<IRemoteObject> & impl)35 RSRenderServiceConnectionProxy::RSRenderServiceConnectionProxy(const sptr<IRemoteObject>& impl)
36 : IRemoteProxy<RSIRenderServiceConnection>(impl)
37 {
38 }
39
CommitTransaction(std::unique_ptr<RSTransactionData> & transactionData)40 void RSRenderServiceConnectionProxy::CommitTransaction(std::unique_ptr<RSTransactionData>& transactionData)
41 {
42 if (!transactionData) {
43 ROSEN_LOGE("RSRenderServiceConnectionProxy::CommitTransaction transactionData nullptr!");
44 return;
45 }
46 bool isUniMode = RSSystemProperties::GetUniRenderEnabled();
47 transactionData->SetSendingPid(pid_);
48
49 // split to several parcels if parcel size > PARCEL_SPLIT_THRESHOLD during marshalling
50 std::vector<std::shared_ptr<MessageParcel>> parcelVector;
51 auto func = [isUniMode, &parcelVector, &transactionData, this]() -> bool {
52 if (isUniMode) {
53 ++transactionDataIndex_;
54 }
55 transactionData->SetIndex(transactionDataIndex_);
56 std::shared_ptr<MessageParcel> parcel = std::make_shared<MessageParcel>();
57 if (!FillParcelWithTransactionData(transactionData, parcel)) {
58 ROSEN_LOGE("FillParcelWithTransactionData failed!");
59 return false;
60 }
61 parcelVector.emplace_back(parcel);
62 return true;
63 };
64 if (transactionData->IsNeedSync() && transactionData->IsEmpty()) {
65 RS_TRACE_NAME("Commit empty syncTransaction");
66 func();
67 } else {
68 while (transactionData->GetMarshallingIndex() < transactionData->GetCommandCount()) {
69 if (!func()) {
70 return;
71 }
72 }
73 }
74
75 MessageOption option;
76 option.SetFlags(MessageOption::TF_ASYNC);
77 for (const auto& parcel : parcelVector) {
78 MessageParcel reply;
79 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::COMMIT_TRANSACTION);
80 int32_t err = Remote()->SendRequest(code, *parcel, reply, option);
81 if (err != NO_ERROR) {
82 ROSEN_LOGE("RSRenderServiceConnectionProxy::CommitTransaction SendRequest failed, err = %{public}d", err);
83 return;
84 }
85 }
86 }
87
ExecuteSynchronousTask(const std::shared_ptr<RSSyncTask> & task)88 void RSRenderServiceConnectionProxy::ExecuteSynchronousTask(const std::shared_ptr<RSSyncTask>& task)
89 {
90 if (task == nullptr) {
91 return;
92 }
93
94 MessageParcel data;
95 MessageParcel reply;
96 MessageOption option;
97 if (!data.WriteInterfaceToken(RSRenderServiceConnectionProxy::GetDescriptor())) {
98 return;
99 }
100 if (!task->Marshalling(data)) {
101 return;
102 }
103 option.SetFlags(MessageOption::TF_SYNC);
104 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::EXECUTE_SYNCHRONOUS_TASK);
105 int32_t err = Remote()->SendRequest(code, data, reply, option);
106 if (err != NO_ERROR) {
107 return;
108 }
109
110 if (task->CheckHeader(reply)) {
111 task->ReadFromParcel(reply);
112 }
113 }
114
FillParcelWithTransactionData(std::unique_ptr<RSTransactionData> & transactionData,std::shared_ptr<MessageParcel> & data)115 bool RSRenderServiceConnectionProxy::FillParcelWithTransactionData(
116 std::unique_ptr<RSTransactionData>& transactionData, std::shared_ptr<MessageParcel>& data)
117 {
118 // write a flag at the begin of parcel to identify parcel type
119 // 0: indicate normal parcel
120 // 1: indicate ashmem parcel
121 if (!data->WriteInt32(0)) {
122 ROSEN_LOGE("FillParcelWithTransactionData WriteInt32 failed");
123 return false;
124 }
125
126 // 1. marshalling RSTransactionData
127 RS_TRACE_BEGIN("MarshRSTransactionData cmdCount:" + std::to_string(transactionData->GetCommandCount()) +
128 " transactionFlag:[" + std::to_string(pid_) + "," + std::to_string(transactionData->GetIndex()) + "]");
129 bool success = data->WriteParcelable(transactionData.get());
130 RS_TRACE_END();
131 if (!success) {
132 ROSEN_LOGE("FillParcelWithTransactionData data.WriteParcelable failed!");
133 return false;
134 }
135
136 // 2. convert data to new ashmem parcel if size over threshold
137 std::shared_ptr<MessageParcel> ashmemParcel = nullptr;
138 if (data->GetDataSize() > ASHMEM_SIZE_THRESHOLD) {
139 ashmemParcel = RSAshmemHelper::CreateAshmemParcel(data);
140 }
141 if (ashmemParcel != nullptr) {
142 data = ashmemParcel;
143 }
144 return true;
145 }
146
GetUniRenderEnabled()147 bool RSRenderServiceConnectionProxy::GetUniRenderEnabled()
148 {
149 MessageParcel data;
150 MessageParcel reply;
151 MessageOption option;
152
153 option.SetFlags(MessageOption::TF_SYNC);
154 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_UNI_RENDER_ENABLED);
155 int32_t err = Remote()->SendRequest(code, data, reply, option);
156 if (err != NO_ERROR) {
157 return false;
158 }
159 return reply.ReadBool();
160 }
161
CreateNode(const RSDisplayNodeConfig & displayNodeConfig,NodeId nodeId)162 bool RSRenderServiceConnectionProxy::CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId)
163 {
164 MessageParcel data;
165 MessageParcel reply;
166 MessageOption option;
167
168 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
169 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteInterfaceToken err.");
170 return false;
171 }
172 if (!data.WriteUint64(nodeId)) {
173 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteUint64 NodeId err.");
174 return false;
175 }
176 if (!data.WriteUint64(displayNodeConfig.mirrorNodeId)) {
177 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteUint64 Config.MirrorNodeId err.");
178 return false;
179 }
180 if (!data.WriteUint64(displayNodeConfig.screenId)) {
181 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteUint64 Config.ScreenId err.");
182 return false;
183 }
184 if (!data.WriteBool(displayNodeConfig.isMirrored)) {
185 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteBool Config.IsMirrored err.");
186 return false;
187 }
188 option.SetFlags(MessageOption::TF_SYNC);
189 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_DISPLAY_NODE);
190 int32_t err = Remote()->SendRequest(code, data, reply, option);
191 if (err != NO_ERROR) {
192 return false;
193 }
194
195 return reply.ReadBool();
196 }
197
CreateNode(const RSSurfaceRenderNodeConfig & config)198 bool RSRenderServiceConnectionProxy::CreateNode(const RSSurfaceRenderNodeConfig& config)
199 {
200 MessageParcel data;
201 MessageParcel reply;
202 MessageOption option;
203
204 if (!data.WriteUint64(config.id)) {
205 return false;
206 }
207 if (!data.WriteString(config.name)) {
208 return false;
209 }
210 if (!data.WriteString(config.bundleName)) {
211 return false;
212 }
213 option.SetFlags(MessageOption::TF_SYNC);
214 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_NODE);
215 int32_t err = Remote()->SendRequest(code, data, reply, option);
216 if (err != NO_ERROR) {
217 return false;
218 }
219
220 return reply.ReadBool();
221 }
222
CreateNodeAndSurface(const RSSurfaceRenderNodeConfig & config)223 sptr<Surface> RSRenderServiceConnectionProxy::CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config)
224 {
225 MessageParcel data;
226 MessageParcel reply;
227 MessageOption option;
228
229 if (!data.WriteUint64(config.id)) {
230 return nullptr;
231 }
232 if (!data.WriteString(config.name)) {
233 return nullptr;
234 }
235 if (!data.WriteUint8(static_cast<uint8_t>(config.nodeType))) {
236 return nullptr;
237 }
238 if (!data.WriteString(config.bundleName)) {
239 return nullptr;
240 }
241 if (!data.WriteBool(config.isTextureExportNode)) {
242 return nullptr;
243 }
244 if (!data.WriteBool(config.isSync)) {
245 return nullptr;
246 }
247 if (!data.WriteUint8(static_cast<uint8_t>(config.surfaceWindowType))) {
248 return nullptr;
249 }
250 option.SetFlags(MessageOption::TF_SYNC);
251 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_NODE_AND_SURFACE);
252 int32_t err = Remote()->SendRequest(code, data, reply, option);
253 if (err != NO_ERROR) {
254 return nullptr;
255 }
256 sptr<IRemoteObject> surfaceObject = reply.ReadRemoteObject();
257 sptr<IBufferProducer> bp = iface_cast<IBufferProducer>(surfaceObject);
258 if (bp == nullptr) {
259 return nullptr;
260 }
261 sptr<Surface> surface = Surface::CreateSurfaceAsProducer(bp);
262 return surface;
263 }
264
CreateVSyncConnection(const std::string & name,const sptr<VSyncIConnectionToken> & token,uint64_t id,NodeId windowNodeId,bool fromXcomponent)265 sptr<IVSyncConnection> RSRenderServiceConnectionProxy::CreateVSyncConnection(const std::string& name,
266 const sptr<VSyncIConnectionToken>& token,
267 uint64_t id,
268 NodeId windowNodeId,
269 bool fromXcomponent)
270 {
271 if (token == nullptr) {
272 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateVSyncConnection: token is nullptr.");
273 return nullptr;
274 }
275 MessageParcel data;
276 MessageParcel reply;
277 MessageOption option;
278
279 data.WriteString(name);
280 data.WriteRemoteObject(token->AsObject());
281 data.WriteUint64(id);
282 data.WriteUint64(windowNodeId);
283 data.WriteBool(fromXcomponent);
284 option.SetFlags(MessageOption::TF_SYNC);
285 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_VSYNC_CONNECTION);
286 int32_t err = Remote()->SendRequest(code, data, reply, option);
287 if (err != NO_ERROR) {
288 return nullptr;
289 }
290
291 sptr<IRemoteObject> rObj = reply.ReadRemoteObject();
292 if (rObj == nullptr) {
293 return nullptr;
294 }
295 sptr<IVSyncConnection> conn = iface_cast<IVSyncConnection>(rObj);
296 return conn;
297 }
298
CreatePixelMapFromSurface(sptr<Surface> surface,const Rect & srcRect)299 std::shared_ptr<Media::PixelMap> RSRenderServiceConnectionProxy::CreatePixelMapFromSurface(sptr<Surface> surface,
300 const Rect &srcRect)
301 {
302 MessageParcel data;
303 MessageParcel reply;
304 MessageOption option;
305 if (surface == nullptr) {
306 return nullptr;
307 }
308
309 auto producer = surface->GetProducer();
310 if (producer == nullptr) {
311 return nullptr;
312 }
313
314 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
315 return nullptr;
316 }
317 data.WriteRemoteObject(producer->AsObject());
318 data.WriteInt32(srcRect.x);
319 data.WriteInt32(srcRect.y);
320 data.WriteInt32(srcRect.w);
321 data.WriteInt32(srcRect.h);
322 option.SetFlags(MessageOption::TF_SYNC);
323 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_PIXEL_MAP_FROM_SURFACE);
324 int32_t err = Remote()->SendRequest(code, data, reply, option);
325 if (err != NO_ERROR) {
326 ROSEN_LOGE("RSRenderServiceConnectionProxy::CreatePixelMapFromSurface: Send Request err.");
327 return nullptr;
328 }
329
330 std::shared_ptr<Media::PixelMap> pixelMap = nullptr;
331 if (reply.ReadBool()) {
332 pixelMap.reset(Media::PixelMap::Unmarshalling(reply));
333 }
334 return pixelMap;
335 }
336
SetFocusAppInfo(int32_t pid,int32_t uid,const std::string & bundleName,const std::string & abilityName,uint64_t focusNodeId)337 int32_t RSRenderServiceConnectionProxy::SetFocusAppInfo(
338 int32_t pid, int32_t uid, const std::string &bundleName, const std::string &abilityName, uint64_t focusNodeId)
339 {
340 MessageParcel data;
341 MessageParcel reply;
342 MessageOption option;
343
344 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
345 return WRITE_PARCEL_ERR;
346 }
347
348 option.SetFlags(MessageOption::TF_ASYNC);
349 data.WriteInt32(pid);
350 data.WriteInt32(uid);
351 data.WriteString(bundleName);
352 data.WriteString(abilityName);
353 data.WriteUint64(focusNodeId);
354 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_FOCUS_APP_INFO);
355 int32_t err = Remote()->SendRequest(code, data, reply, option);
356 if (err != NO_ERROR) {
357 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: Send Request err.");
358 return RS_CONNECTION_ERROR;
359 }
360 int32_t result = reply.ReadInt32();
361 return result;
362 }
363
GetDefaultScreenId()364 ScreenId RSRenderServiceConnectionProxy::GetDefaultScreenId()
365 {
366 MessageParcel data;
367 MessageParcel reply;
368 MessageOption option;
369
370 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
371 return INVALID_SCREEN_ID;
372 }
373
374 option.SetFlags(MessageOption::TF_SYNC);
375 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_DEFAULT_SCREEN_ID);
376 int32_t err = Remote()->SendRequest(code, data, reply, option);
377 if (err != NO_ERROR) {
378 return INVALID_SCREEN_ID;
379 }
380
381 ScreenId id = reply.ReadUint64();
382 return id;
383 }
384
GetActiveScreenId()385 ScreenId RSRenderServiceConnectionProxy::GetActiveScreenId()
386 {
387 MessageParcel data;
388 MessageParcel reply;
389 MessageOption option;
390
391 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
392 return INVALID_SCREEN_ID;
393 }
394
395 option.SetFlags(MessageOption::TF_SYNC);
396 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_SCREEN_ID);
397 int32_t err = Remote()->SendRequest(code, data, reply, option);
398 if (err != NO_ERROR) {
399 return INVALID_SCREEN_ID;
400 }
401
402 ScreenId id = reply.ReadUint64();
403 return id;
404 }
405
GetAllScreenIds()406 std::vector<ScreenId> RSRenderServiceConnectionProxy::GetAllScreenIds()
407 {
408 MessageParcel data;
409 MessageParcel reply;
410 MessageOption option;
411 std::vector<ScreenId> screenIds;
412
413 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
414 return std::vector<ScreenId>();
415 }
416
417 option.SetFlags(MessageOption::TF_SYNC);
418 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_ALL_SCREEN_IDS);
419 int32_t err = Remote()->SendRequest(code, data, reply, option);
420 if (err != NO_ERROR) {
421 return std::vector<ScreenId>();
422 }
423
424 uint32_t size = reply.ReadUint32();
425 size_t readableSize = reply.GetReadableBytes() / sizeof(ScreenId);
426 size_t len = static_cast<size_t>(size);
427 if (len > readableSize || len > screenIds.max_size()) {
428 RS_LOGE("RSRenderServiceConnectionProxy GetAllScreenIds Failed read vector, size:%{public}zu,"
429 " readableSize:%{public}zu", len, readableSize);
430 return screenIds;
431 }
432 for (uint32_t i = 0; i < size; i++) {
433 screenIds.emplace_back(reply.ReadUint64());
434 }
435
436 return screenIds;
437 }
438
CreateVirtualScreen(const std::string & name,uint32_t width,uint32_t height,sptr<Surface> surface,ScreenId mirrorId,int32_t flags,std::vector<NodeId> whiteList)439 ScreenId RSRenderServiceConnectionProxy::CreateVirtualScreen(
440 const std::string &name,
441 uint32_t width,
442 uint32_t height,
443 sptr<Surface> surface,
444 ScreenId mirrorId,
445 int32_t flags,
446 std::vector<NodeId> whiteList)
447 {
448 MessageParcel data;
449 MessageParcel reply;
450 MessageOption option;
451
452 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
453 return INVALID_SCREEN_ID;
454 }
455
456 option.SetFlags(MessageOption::TF_SYNC);
457 if (!data.WriteString(name)) {
458 return INVALID_SCREEN_ID;
459 }
460 if (!data.WriteUint32(width)) {
461 return INVALID_SCREEN_ID;
462 }
463 if (!data.WriteUint32(height)) {
464 return INVALID_SCREEN_ID;
465 }
466 if (surface != nullptr) {
467 auto producer = surface->GetProducer();
468 if (producer != nullptr) {
469 if (!data.WriteBool(true)) {
470 return INVALID_SCREEN_ID;
471 }
472 if (!data.WriteRemoteObject(producer->AsObject())) {
473 return INVALID_SCREEN_ID;
474 }
475 } else {
476 if (!data.WriteBool(false)) {
477 return INVALID_SCREEN_ID;
478 }
479 }
480 } else {
481 if (!data.WriteBool(false)) {
482 return INVALID_SCREEN_ID;
483 }
484 }
485 if (!data.WriteUint64(mirrorId)) {
486 return INVALID_SCREEN_ID;
487 }
488 if (!data.WriteInt32(flags)) {
489 return INVALID_SCREEN_ID;
490 }
491 if (!data.WriteUInt64Vector(whiteList)) {
492 return INVALID_SCREEN_ID;
493 }
494 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_VIRTUAL_SCREEN);
495 int32_t err = Remote()->SendRequest(code, data, reply, option);
496 if (err != NO_ERROR) {
497 return INVALID_SCREEN_ID;
498 }
499
500 ScreenId id = reply.ReadUint64();
501 return id;
502 }
503
SetVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector)504 int32_t RSRenderServiceConnectionProxy::SetVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector)
505 {
506 MessageParcel data;
507 MessageParcel reply;
508 MessageOption option;
509
510 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
511 return WRITE_PARCEL_ERR;
512 }
513
514 option.SetFlags(MessageOption::TF_ASYNC);
515 data.WriteUint64(id);
516 data.WriteUInt64Vector(blackListVector);
517 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_BLACKLIST);
518 int32_t err = Remote()->SendRequest(code, data, reply, option);
519 if (err != NO_ERROR) {
520 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenBlackList: Send Request err.");
521 return RS_CONNECTION_ERROR;
522 }
523
524 int32_t status = reply.ReadInt32();
525 return status;
526 }
527
AddVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector)528 int32_t RSRenderServiceConnectionProxy::AddVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector)
529 {
530 MessageParcel data;
531 MessageParcel reply;
532 MessageOption option;
533
534 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
535 return WRITE_PARCEL_ERR;
536 }
537
538 option.SetFlags(MessageOption::TF_ASYNC);
539 if (!data.WriteUint64(id)) {
540 return WRITE_PARCEL_ERR;
541 }
542 if (!data.WriteUInt64Vector(blackListVector)) {
543 return WRITE_PARCEL_ERR;
544 }
545 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::ADD_VIRTUAL_SCREEN_BLACKLIST);
546 int32_t err = Remote()->SendRequest(code, data, reply, option);
547 if (err != NO_ERROR) {
548 ROSEN_LOGE("RSRenderServiceConnectionProxy::AddVirtualScreenBlackList: Send Request err.");
549 return RS_CONNECTION_ERROR;
550 }
551
552 int32_t status = reply.ReadInt32();
553 return status;
554 }
555
RemoveVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector)556 int32_t RSRenderServiceConnectionProxy::RemoveVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector)
557 {
558 MessageParcel data;
559 MessageParcel reply;
560 MessageOption option;
561
562 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
563 return WRITE_PARCEL_ERR;
564 }
565
566 option.SetFlags(MessageOption::TF_ASYNC);
567 if (!data.WriteUint64(id)) {
568 return WRITE_PARCEL_ERR;
569 }
570 if (!data.WriteUInt64Vector(blackListVector)) {
571 return WRITE_PARCEL_ERR;
572 }
573 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN_BLACKLIST);
574 int32_t err = Remote()->SendRequest(code, data, reply, option);
575 if (err != NO_ERROR) {
576 ROSEN_LOGE("RSRenderServiceConnectionProxy::RemoveVirtualScreenBlackList: Send Request err.");
577 return RS_CONNECTION_ERROR;
578 }
579
580 int32_t status = reply.ReadInt32();
581 return status;
582 }
583
SetVirtualScreenSecurityExemptionList(ScreenId id,const std::vector<NodeId> & securityExemptionList)584 int32_t RSRenderServiceConnectionProxy::SetVirtualScreenSecurityExemptionList(
585 ScreenId id,
586 const std::vector<NodeId>& securityExemptionList)
587 {
588 MessageParcel data;
589 MessageParcel reply;
590 MessageOption option;
591
592 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
593 return WRITE_PARCEL_ERR;
594 }
595
596 option.SetFlags(MessageOption::TF_SYNC);
597 if (!data.WriteUint64(id)) {
598 return WRITE_PARCEL_ERR;
599 }
600 if (!data.WriteUInt64Vector(securityExemptionList)) {
601 return WRITE_PARCEL_ERR;
602 }
603 uint32_t code = static_cast<uint32_t>(
604 RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION_LIST);
605 int32_t err = Remote()->SendRequest(code, data, reply, option);
606 if (err != NO_ERROR) {
607 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenSecurityExemptionList: Send Request err.");
608 return RS_CONNECTION_ERROR;
609 }
610
611 int32_t status = reply.ReadInt32();
612 return status;
613 }
614
SetCastScreenEnableSkipWindow(ScreenId id,bool enable)615 int32_t RSRenderServiceConnectionProxy::SetCastScreenEnableSkipWindow(ScreenId id, bool enable)
616 {
617 MessageParcel data;
618 MessageParcel reply;
619 MessageOption option;
620
621 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
622 return WRITE_PARCEL_ERR;
623 }
624
625 option.SetFlags(MessageOption::TF_ASYNC);
626 data.WriteUint64(id);
627 data.WriteBool(enable);
628 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_CAST_SCREEN_ENABLE_SKIP_WINDOW);
629 int32_t err = Remote()->SendRequest(code, data, reply, option);
630 if (err != NO_ERROR) {
631 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetCastScreenEnableSkipWindow: Send Request err.");
632 return RS_CONNECTION_ERROR;
633 }
634 int32_t result = reply.ReadInt32();
635 return result;
636 }
637
SetVirtualScreenSurface(ScreenId id,sptr<Surface> surface)638 int32_t RSRenderServiceConnectionProxy::SetVirtualScreenSurface(ScreenId id, sptr<Surface> surface)
639 {
640 if (surface == nullptr) {
641 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenSurface: Send surface is nullptr!");
642 return INVALID_ARGUMENTS;
643 }
644
645 MessageParcel data;
646 MessageParcel reply;
647 MessageOption option;
648
649 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
650 return WRITE_PARCEL_ERR;
651 }
652
653 option.SetFlags(MessageOption::TF_ASYNC);
654 data.WriteUint64(id);
655 auto producer = surface->GetProducer();
656 data.WriteRemoteObject(producer->AsObject());
657 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SURFACE);
658 int32_t err = Remote()->SendRequest(code, data, reply, option);
659 if (err != NO_ERROR) {
660 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenSurface: Send Request err.");
661 return RS_CONNECTION_ERROR;
662 }
663
664 int32_t status = reply.ReadInt32();
665 return status;
666 }
667
RemoveVirtualScreen(ScreenId id)668 void RSRenderServiceConnectionProxy::RemoveVirtualScreen(ScreenId id)
669 {
670 MessageParcel data;
671 MessageParcel reply;
672 MessageOption option;
673 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
674 return;
675 }
676
677 option.SetFlags(MessageOption::TF_ASYNC);
678 data.WriteUint64(id);
679 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN);
680 int32_t err = Remote()->SendRequest(code, data, reply, option);
681 if (err != NO_ERROR) {
682 ROSEN_LOGE("RSRenderServiceConnectionProxy::RemoveVirtualScreen: Send Request err.");
683 return;
684 }
685 }
686
SetScreenChangeCallback(sptr<RSIScreenChangeCallback> callback)687 int32_t RSRenderServiceConnectionProxy::SetScreenChangeCallback(sptr<RSIScreenChangeCallback> callback)
688 {
689 if (callback == nullptr) {
690 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenChangeCallback: callback is nullptr.");
691 return INVALID_ARGUMENTS;
692 }
693
694 MessageParcel data;
695 MessageParcel reply;
696 MessageOption option;
697
698 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
699 return WRITE_PARCEL_ERR;
700 }
701
702 option.SetFlags(MessageOption::TF_ASYNC);
703 data.WriteRemoteObject(callback->AsObject());
704 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CHANGE_CALLBACK);
705 int32_t err = Remote()->SendRequest(code, data, reply, option);
706 if (err != NO_ERROR) {
707 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenChangeCallback: Send Request err.");
708 return RS_CONNECTION_ERROR;
709 }
710 int32_t result = reply.ReadInt32();
711 return result;
712 }
713
SetScreenActiveMode(ScreenId id,uint32_t modeId)714 void RSRenderServiceConnectionProxy::SetScreenActiveMode(ScreenId id, uint32_t modeId)
715 {
716 MessageParcel data;
717 MessageParcel reply;
718 MessageOption option;
719
720 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
721 return;
722 }
723 option.SetFlags(MessageOption::TF_SYNC);
724 data.WriteUint64(id);
725 data.WriteUint32(modeId);
726 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_MODE);
727 int32_t err = Remote()->SendRequest(code, data, reply, option);
728 if (err != NO_ERROR) {
729 return;
730 }
731 }
732
SetScreenRefreshRate(ScreenId id,int32_t sceneId,int32_t rate)733 void RSRenderServiceConnectionProxy::SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate)
734 {
735 MessageParcel data;
736 MessageParcel reply;
737 MessageOption option;
738
739 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
740 ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor");
741 return;
742 }
743 option.SetFlags(MessageOption::TF_SYNC);
744 data.WriteUint64(id);
745 data.WriteInt32(sceneId);
746 data.WriteInt32(rate);
747 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_REFRESH_RATE);
748 int32_t err = Remote()->SendRequest(code, data, reply, option);
749 if (err != NO_ERROR) {
750 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
751 return;
752 }
753 }
754
SetRefreshRateMode(int32_t refreshRateMode)755 void RSRenderServiceConnectionProxy::SetRefreshRateMode(int32_t refreshRateMode)
756 {
757 MessageParcel data;
758 MessageParcel reply;
759 MessageOption option;
760
761 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
762 ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor");
763 return;
764 }
765 option.SetFlags(MessageOption::TF_SYNC);
766 data.WriteInt32(refreshRateMode);
767 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_REFRESH_RATE_MODE);
768 int32_t err = Remote()->SendRequest(code, data, reply, option);
769 if (err != NO_ERROR) {
770 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
771 return;
772 }
773 }
774
SyncFrameRateRange(FrameRateLinkerId id,const FrameRateRange & range,int32_t animatorExpectedFrameRate)775 void RSRenderServiceConnectionProxy::SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range,
776 int32_t animatorExpectedFrameRate)
777 {
778 MessageParcel data;
779 MessageParcel reply;
780 MessageOption option;
781
782 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
783 ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor");
784 return;
785 }
786
787 option.SetFlags(MessageOption::TF_SYNC);
788 data.WriteUint64(id);
789 data.WriteUint32(range.min_);
790 data.WriteUint32(range.max_);
791 data.WriteUint32(range.preferred_);
792 data.WriteUint32(range.type_);
793 data.WriteInt32(animatorExpectedFrameRate);
794 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SYNC_FRAME_RATE_RANGE);
795 int32_t err = Remote()->SendRequest(code, data, reply, option);
796 if (err != NO_ERROR) {
797 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
798 return;
799 }
800 }
801
UnregisterFrameRateLinker(FrameRateLinkerId id)802 void RSRenderServiceConnectionProxy::UnregisterFrameRateLinker(FrameRateLinkerId id)
803 {
804 MessageParcel data;
805 MessageParcel reply;
806 MessageOption option;
807
808 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
809 ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor");
810 return;
811 }
812
813 option.SetFlags(MessageOption::TF_ASYNC);
814 data.WriteUint64(id);
815 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_FRAME_RATE_LINKER);
816 int32_t err = Remote()->SendRequest(code, data, reply, option);
817 if (err != NO_ERROR) {
818 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
819 return;
820 }
821 }
822
GetScreenCurrentRefreshRate(ScreenId id)823 uint32_t RSRenderServiceConnectionProxy::GetScreenCurrentRefreshRate(ScreenId id)
824 {
825 MessageParcel data;
826 MessageParcel reply;
827 MessageOption option;
828
829 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
830 ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor");
831 return SUCCESS;
832 }
833 option.SetFlags(MessageOption::TF_SYNC);
834 data.WriteUint64(id);
835 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CURRENT_REFRESH_RATE);
836 int32_t err = Remote()->SendRequest(code, data, reply, option);
837 if (err != NO_ERROR) {
838 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
839 return SUCCESS;
840 }
841 uint32_t rate = reply.ReadUint32();
842 return rate;
843 }
844
GetCurrentRefreshRateMode()845 int32_t RSRenderServiceConnectionProxy::GetCurrentRefreshRateMode()
846 {
847 MessageParcel data;
848 MessageParcel reply;
849 MessageOption option;
850
851 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
852 ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor");
853 return SUCCESS;
854 }
855 option.SetFlags(MessageOption::TF_SYNC);
856 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_CURRENT_REFRESH_RATE_MODE);
857 int32_t err = Remote()->SendRequest(code, data, reply, option);
858 if (err != NO_ERROR) {
859 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
860 return SUCCESS;
861 }
862 int32_t refreshRateMode = reply.ReadInt32();
863 return refreshRateMode;
864 }
865
GetScreenSupportedRefreshRates(ScreenId id)866 std::vector<int32_t> RSRenderServiceConnectionProxy::GetScreenSupportedRefreshRates(ScreenId id)
867 {
868 MessageParcel data;
869 MessageParcel reply;
870 MessageOption option;
871 std::vector<int32_t> screenSupportedRates;
872
873 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
874 ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor");
875 return screenSupportedRates;
876 }
877 option.SetFlags(MessageOption::TF_SYNC);
878 data.WriteUint64(id);
879 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_REFRESH_RATES);
880 int32_t err = Remote()->SendRequest(code, data, reply, option);
881 if (err != NO_ERROR) {
882 return screenSupportedRates;
883 }
884 uint64_t rateCount = reply.ReadUint64();
885 size_t readableSize = reply.GetReadableBytes();
886 size_t len = static_cast<size_t>(rateCount);
887 if (len > readableSize || len > screenSupportedRates.max_size()) {
888 RS_LOGE("RSRenderServiceConnectionProxy GetScreenSupportedRefreshRates "
889 "fail read vector, size : %{public}zu, readableSize : %{public}zu", len, readableSize);
890 return screenSupportedRates;
891 }
892 screenSupportedRates.resize(rateCount);
893 for (uint64_t rateIndex = 0; rateIndex < rateCount; rateIndex++) {
894 screenSupportedRates[rateIndex] = reply.ReadInt32();
895 }
896 return screenSupportedRates;
897 }
898
GetShowRefreshRateEnabled()899 bool RSRenderServiceConnectionProxy::GetShowRefreshRateEnabled()
900 {
901 MessageParcel data;
902 MessageParcel reply;
903 MessageOption option;
904
905 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
906 ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor");
907 return SUCCESS;
908 }
909 option.SetFlags(MessageOption::TF_SYNC);
910 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SHOW_REFRESH_RATE_ENABLED);
911 int32_t err = Remote()->SendRequest(code, data, reply, option);
912 if (err != NO_ERROR) {
913 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
914 return SUCCESS;
915 }
916 bool enable = reply.ReadBool();
917 return enable;
918 }
919
SetShowRefreshRateEnabled(bool enable)920 void RSRenderServiceConnectionProxy::SetShowRefreshRateEnabled(bool enable)
921 {
922 MessageParcel data;
923 MessageParcel reply;
924 MessageOption option;
925
926 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
927 ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor");
928 return;
929 }
930 option.SetFlags(MessageOption::TF_SYNC);
931 data.WriteBool(enable);
932 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED);
933 int32_t err = Remote()->SendRequest(code, data, reply, option);
934 if (err != NO_ERROR) {
935 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
936 return;
937 }
938 }
939
GetRefreshInfo(pid_t pid)940 std::string RSRenderServiceConnectionProxy::GetRefreshInfo(pid_t pid)
941 {
942 MessageParcel data;
943 MessageParcel reply;
944 MessageOption option;
945
946 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
947 ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor");
948 return "";
949 }
950 option.SetFlags(MessageOption::TF_SYNC);
951 data.WriteInt32(pid);
952 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO);
953 int32_t err = Remote()->SendRequest(code, data, reply, option);
954 if (err != NO_ERROR) {
955 ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err);
956 return "";
957 }
958 std::string enable = reply.ReadString();
959 return enable;
960 }
961
SetVirtualScreenResolution(ScreenId id,uint32_t width,uint32_t height)962 int32_t RSRenderServiceConnectionProxy::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height)
963 {
964 MessageParcel data;
965 MessageParcel reply;
966 MessageOption option;
967
968 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
969 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenResolution: WriteInterfaceToken err.");
970 return WRITE_PARCEL_ERR;
971 }
972 option.SetFlags(MessageOption::TF_SYNC);
973 data.WriteUint64(id);
974 data.WriteUint32(width);
975 data.WriteUint32(height);
976 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_RESOLUTION);
977 int32_t err = Remote()->SendRequest(code, data, reply, option);
978 if (err != NO_ERROR) {
979 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenResolution: Send Request err.");
980 return RS_CONNECTION_ERROR;
981 }
982 int32_t status = reply.ReadInt32();
983 return status;
984 }
985
MarkPowerOffNeedProcessOneFrame()986 void RSRenderServiceConnectionProxy::MarkPowerOffNeedProcessOneFrame()
987 {
988 MessageParcel data;
989 MessageParcel reply;
990 MessageOption option;
991
992 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
993 ROSEN_LOGE("RSRenderServiceConnectionProxy::MarkPowerOffNeedProcessOneFrame: Send Request err.");
994 return;
995 }
996 option.SetFlags(MessageOption::TF_SYNC);
997 uint32_t code =
998 static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::MARK_POWER_OFF_NEED_PROCESS_ONE_FRAME);
999 int32_t err = Remote()->SendRequest(code, data, reply, option);
1000 if (err != NO_ERROR) {
1001 return;
1002 }
1003 }
1004
DisablePowerOffRenderControl(ScreenId id)1005 void RSRenderServiceConnectionProxy::DisablePowerOffRenderControl(ScreenId id)
1006 {
1007 MessageParcel data;
1008 MessageParcel reply;
1009 MessageOption option;
1010
1011 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1012 ROSEN_LOGE("RSRenderServiceConnectionProxy::DisablePowerOffRenderControl: Send Request err.");
1013 return;
1014 }
1015 option.SetFlags(MessageOption::TF_SYNC);
1016 data.WriteUint64(id);
1017 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::DISABLE_RENDER_CONTROL_SCREEN);
1018 int32_t err = Remote()->SendRequest(code, data, reply, option);
1019 if (err != NO_ERROR) {
1020 return;
1021 }
1022 }
1023
SetScreenPowerStatus(ScreenId id,ScreenPowerStatus status)1024 void RSRenderServiceConnectionProxy::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status)
1025 {
1026 MessageParcel data;
1027 MessageParcel reply;
1028 MessageOption option;
1029
1030 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1031 return;
1032 }
1033 option.SetFlags(MessageOption::TF_SYNC);
1034 data.WriteUint64(id);
1035 data.WriteUint32(static_cast<uint32_t>(status));
1036 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_POWER_STATUS);
1037 int32_t err = Remote()->SendRequest(code, data, reply, option);
1038 if (err != NO_ERROR) {
1039 return;
1040 }
1041 }
1042
RegisterApplicationAgent(uint32_t pid,sptr<IApplicationAgent> app)1043 void RSRenderServiceConnectionProxy::RegisterApplicationAgent(uint32_t pid, sptr<IApplicationAgent> app)
1044 {
1045 if (app == nullptr) {
1046 ROSEN_LOGE("RSRenderServiceProxy: callback == nullptr\n");
1047 return;
1048 }
1049
1050 MessageParcel data;
1051 MessageParcel reply;
1052 MessageOption option;
1053 option.SetFlags(MessageOption::TF_ASYNC);
1054 data.WriteUint32(pid);
1055 data.WriteRemoteObject(app->AsObject());
1056 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_APPLICATION_AGENT);
1057 int32_t err = Remote()->SendRequest(code, data, reply, option);
1058 if (err != NO_ERROR) {
1059 ROSEN_LOGE("RSRenderServiceProxy: Remote()->SendRequest() error.\n");
1060 return;
1061 }
1062 }
1063
TakeSurfaceCapture(NodeId id,sptr<RSISurfaceCaptureCallback> callback,const RSSurfaceCaptureConfig & captureConfig,RSSurfaceCapturePermissions)1064 void RSRenderServiceConnectionProxy::TakeSurfaceCapture(NodeId id, sptr<RSISurfaceCaptureCallback> callback,
1065 const RSSurfaceCaptureConfig& captureConfig, RSSurfaceCapturePermissions /* permissions */)
1066 {
1067 if (callback == nullptr) {
1068 ROSEN_LOGE("RSRenderServiceProxy: callback == nullptr\n");
1069 return;
1070 }
1071
1072 MessageParcel data;
1073 MessageParcel reply;
1074 MessageOption option;
1075 option.SetFlags(MessageOption::TF_ASYNC);
1076 if (!data.WriteUint64(id)) {
1077 ROSEN_LOGE("%{public}s write id failed", __func__);
1078 return;
1079 }
1080 if (!data.WriteRemoteObject(callback->AsObject())) {
1081 ROSEN_LOGE("%{public}s write callback failed", __func__);
1082 return;
1083 }
1084 if (!WriteSurfaceCaptureConfig(captureConfig, data)) {
1085 ROSEN_LOGE("%{public}s write captureConfig failed", __func__);
1086 return;
1087 }
1088 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::TAKE_SURFACE_CAPTURE);
1089 int32_t err = Remote()->SendRequest(code, data, reply, option);
1090 if (err != NO_ERROR) {
1091 ROSEN_LOGE("RSRenderServiceProxy: Remote()->SendRequest() error.\n");
1092 return;
1093 }
1094 }
1095
SetWindowFreezeImmediately(NodeId id,bool isFreeze,sptr<RSISurfaceCaptureCallback> callback,const RSSurfaceCaptureConfig & captureConfig)1096 void RSRenderServiceConnectionProxy::SetWindowFreezeImmediately(
1097 NodeId id, bool isFreeze, sptr<RSISurfaceCaptureCallback> callback, const RSSurfaceCaptureConfig& captureConfig)
1098 {
1099 MessageParcel data;
1100 MessageParcel reply;
1101 MessageOption option;
1102 option.SetFlags(MessageOption::TF_ASYNC);
1103 if (!data.WriteUint64(id)) {
1104 ROSEN_LOGE("%{public}s write id failed", __func__);
1105 return;
1106 }
1107 if (!data.WriteBool(isFreeze)) {
1108 ROSEN_LOGE("%{public}s write isFreeze failed", __func__);
1109 return;
1110 }
1111 if (isFreeze) {
1112 if (callback == nullptr) {
1113 ROSEN_LOGE("%{public}s callback == nullptr", __func__);
1114 return;
1115 }
1116 if (!data.WriteRemoteObject(callback->AsObject())) {
1117 ROSEN_LOGE("%{public}s write callback failed", __func__);
1118 return;
1119 }
1120 if (!WriteSurfaceCaptureConfig(captureConfig, data)) {
1121 ROSEN_LOGE("%{public}s write captureConfig failed", __func__);
1122 return;
1123 }
1124 }
1125
1126 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_WINDOW_FREEZE_IMMEDIATELY);
1127 int32_t err = Remote()->SendRequest(code, data, reply, option);
1128 if (err != NO_ERROR) {
1129 ROSEN_LOGE("%{public}s Remote()->SendRequest() error[%{public}d]", __func__, err);
1130 return;
1131 }
1132 }
1133
WriteSurfaceCaptureConfig(const RSSurfaceCaptureConfig & captureConfig,MessageParcel & data)1134 bool RSRenderServiceConnectionProxy::WriteSurfaceCaptureConfig(
1135 const RSSurfaceCaptureConfig& captureConfig, MessageParcel& data)
1136 {
1137 if (!data.WriteFloat(captureConfig.scaleX) || !data.WriteFloat(captureConfig.scaleY) ||
1138 !data.WriteBool(captureConfig.useDma) || !data.WriteBool(captureConfig.useCurWindow) ||
1139 !data.WriteUint8(static_cast<uint8_t>(captureConfig.captureType)) || !data.WriteBool(captureConfig.isSync)) {
1140 return false;
1141 }
1142 return true;
1143 }
1144
GetVirtualScreenResolution(ScreenId id)1145 RSVirtualScreenResolution RSRenderServiceConnectionProxy::GetVirtualScreenResolution(ScreenId id)
1146 {
1147 MessageParcel data;
1148 MessageParcel reply;
1149 MessageOption option;
1150 RSVirtualScreenResolution virtualScreenResolution;
1151
1152 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1153 return virtualScreenResolution;
1154 }
1155 option.SetFlags(MessageOption::TF_SYNC);
1156 data.WriteUint64(id);
1157 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_VIRTUAL_SCREEN_RESOLUTION);
1158 int32_t err = Remote()->SendRequest(code, data, reply, option);
1159 if (err != NO_ERROR) {
1160 return virtualScreenResolution;
1161 }
1162
1163 sptr<RSVirtualScreenResolution> pVirtualScreenResolution(reply.ReadParcelable<RSVirtualScreenResolution>());
1164 if (pVirtualScreenResolution == nullptr) {
1165 return virtualScreenResolution;
1166 }
1167 virtualScreenResolution = *pVirtualScreenResolution;
1168 return virtualScreenResolution;
1169 }
1170
GetScreenActiveMode(ScreenId id)1171 RSScreenModeInfo RSRenderServiceConnectionProxy::GetScreenActiveMode(ScreenId id)
1172 {
1173 MessageParcel data;
1174 MessageParcel reply;
1175 MessageOption option;
1176 RSScreenModeInfo screenModeInfo;
1177
1178 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1179 return screenModeInfo;
1180 }
1181 option.SetFlags(MessageOption::TF_SYNC);
1182 data.WriteUint64(id);
1183 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_ACTIVE_MODE);
1184 int32_t err = Remote()->SendRequest(code, data, reply, option);
1185 if (err != NO_ERROR) {
1186 return screenModeInfo;
1187 }
1188
1189 sptr<RSScreenModeInfo> pScreenModeInfo(reply.ReadParcelable<RSScreenModeInfo>());
1190 if (pScreenModeInfo == nullptr) {
1191 return screenModeInfo;
1192 }
1193 screenModeInfo = *pScreenModeInfo;
1194 return screenModeInfo;
1195 }
1196
GetScreenSupportedModes(ScreenId id)1197 std::vector<RSScreenModeInfo> RSRenderServiceConnectionProxy::GetScreenSupportedModes(ScreenId id)
1198 {
1199 MessageParcel data;
1200 MessageParcel reply;
1201 MessageOption option;
1202 std::vector<RSScreenModeInfo> screenSupportedModes;
1203
1204 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1205 return screenSupportedModes;
1206 }
1207
1208 option.SetFlags(MessageOption::TF_SYNC);
1209 data.WriteUint64(id);
1210 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_MODES);
1211 int32_t err = Remote()->SendRequest(code, data, reply, option);
1212 if (err != NO_ERROR) {
1213 return screenSupportedModes;
1214 }
1215
1216 uint64_t modeCount = reply.ReadUint64();
1217 size_t readableSize = reply.GetReadableBytes();
1218 size_t len = static_cast<size_t>(modeCount);
1219 if (len > readableSize || len > screenSupportedModes.max_size()) {
1220 RS_LOGE("RSRenderServiceConnectionProxy GetScreenSupportedModes Fail read vector, size:%{public}zu,"
1221 "readableSize:%{public}zu", len, readableSize);
1222 return screenSupportedModes;
1223 }
1224 screenSupportedModes.resize(modeCount);
1225 for (uint64_t modeIndex = 0; modeIndex < modeCount; modeIndex++) {
1226 sptr<RSScreenModeInfo> itemScreenMode = reply.ReadParcelable<RSScreenModeInfo>();
1227 if (itemScreenMode == nullptr) {
1228 continue;
1229 } else {
1230 screenSupportedModes[modeIndex] = *itemScreenMode;
1231 }
1232 }
1233 return screenSupportedModes;
1234 }
1235
GetMemoryGraphics()1236 std::vector<MemoryGraphic> RSRenderServiceConnectionProxy::GetMemoryGraphics()
1237 {
1238 MessageParcel data;
1239 MessageParcel reply;
1240 MessageOption option;
1241 std::vector<MemoryGraphic> memoryGraphics;
1242
1243 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1244 return memoryGraphics;
1245 }
1246
1247 option.SetFlags(MessageOption::TF_SYNC);
1248 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHICS);
1249 int32_t err = Remote()->SendRequest(code, data, reply, option);
1250 if (err != NO_ERROR) {
1251 return memoryGraphics;
1252 }
1253
1254 uint64_t count = reply.ReadUint64();
1255 size_t readableSize = reply.GetReadableBytes();
1256 size_t len = static_cast<size_t>(count);
1257 if (len > readableSize || len > memoryGraphics.max_size()) {
1258 RS_LOGE("RSRenderServiceConnectionProxy GetMemoryGraphics Failed to read vector, size:%{public}zu,"
1259 " readableSize:%{public}zu", len, readableSize);
1260 return memoryGraphics;
1261 }
1262 memoryGraphics.resize(count);
1263 for (uint64_t index = 0; index < count; index++) {
1264 sptr<MemoryGraphic> item = reply.ReadParcelable<MemoryGraphic>();
1265 if (item == nullptr) {
1266 continue;
1267 } else {
1268 memoryGraphics[index] = *item;
1269 }
1270 }
1271 return memoryGraphics;
1272 }
1273
GetTotalAppMemSize(float & cpuMemSize,float & gpuMemSize)1274 bool RSRenderServiceConnectionProxy::GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize)
1275 {
1276 MessageParcel data;
1277 MessageParcel reply;
1278 MessageOption option;
1279 MemoryGraphic memoryGraphic;
1280 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1281 return false;
1282 }
1283
1284 option.SetFlags(MessageOption::TF_SYNC);
1285 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_TOTAL_APP_MEM_SIZE);
1286 int32_t err = Remote()->SendRequest(code, data, reply, option);
1287 if (err != NO_ERROR) {
1288 return false;
1289 }
1290
1291 cpuMemSize = reply.ReadFloat();
1292 gpuMemSize = reply.ReadFloat();
1293 return true;
1294 }
1295
GetMemoryGraphic(int pid)1296 MemoryGraphic RSRenderServiceConnectionProxy::GetMemoryGraphic(int pid)
1297 {
1298 MessageParcel data;
1299 MessageParcel reply;
1300 MessageOption option;
1301 MemoryGraphic memoryGraphic;
1302 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1303 return memoryGraphic;
1304 }
1305
1306 option.SetFlags(MessageOption::TF_SYNC);
1307 data.WriteInt32(pid);
1308 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHIC);
1309 int32_t err = Remote()->SendRequest(code, data, reply, option);
1310 if (err != NO_ERROR) {
1311 return memoryGraphic;
1312 }
1313 sptr<MemoryGraphic> pMemoryGraphic(reply.ReadParcelable<MemoryGraphic>());
1314 if (pMemoryGraphic == nullptr) {
1315 return memoryGraphic;
1316 }
1317 memoryGraphic = *pMemoryGraphic;
1318 return memoryGraphic;
1319 }
1320
GetScreenCapability(ScreenId id)1321 RSScreenCapability RSRenderServiceConnectionProxy::GetScreenCapability(ScreenId id)
1322 {
1323 MessageParcel data;
1324 MessageParcel reply;
1325 MessageOption option;
1326 RSScreenCapability screenCapability;
1327 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1328 return screenCapability;
1329 }
1330 option.SetFlags(MessageOption::TF_SYNC);
1331 data.WriteUint64(id);
1332 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CAPABILITY);
1333 int32_t err = Remote()->SendRequest(code, data, reply, option);
1334 if (err != NO_ERROR) {
1335 return screenCapability;
1336 }
1337
1338 sptr<RSScreenCapability> pScreenCapability(reply.ReadParcelable<RSScreenCapability>());
1339 if (pScreenCapability == nullptr) {
1340 return screenCapability;
1341 }
1342 screenCapability = *pScreenCapability;
1343 return screenCapability;
1344 }
1345
GetScreenPowerStatus(ScreenId id)1346 ScreenPowerStatus RSRenderServiceConnectionProxy::GetScreenPowerStatus(ScreenId id)
1347 {
1348 MessageParcel data;
1349 MessageParcel reply;
1350 MessageOption option;
1351 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1352 return INVALID_POWER_STATUS;
1353 }
1354 option.SetFlags(MessageOption::TF_SYNC);
1355 data.WriteUint64(id);
1356 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_POWER_STATUS);
1357 int32_t err = Remote()->SendRequest(code, data, reply, option);
1358 if (err != NO_ERROR) {
1359 return INVALID_POWER_STATUS;
1360 }
1361 return static_cast<ScreenPowerStatus>(reply.ReadUint32());
1362 }
1363
GetScreenData(ScreenId id)1364 RSScreenData RSRenderServiceConnectionProxy::GetScreenData(ScreenId id)
1365 {
1366 MessageParcel data;
1367 MessageParcel reply;
1368 MessageOption option;
1369 RSScreenData screenData;
1370 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1371 return screenData;
1372 }
1373 option.SetFlags(MessageOption::TF_SYNC);
1374 data.WriteUint64(id);
1375 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_DATA);
1376 int32_t err = Remote()->SendRequest(code, data, reply, option);
1377 if (err != NO_ERROR) {
1378 return screenData;
1379 }
1380 sptr<RSScreenData> pScreenData(reply.ReadParcelable<RSScreenData>());
1381 if (pScreenData == nullptr) {
1382 return screenData;
1383 }
1384 screenData = *pScreenData;
1385 return screenData;
1386 }
1387
GetScreenBacklight(ScreenId id)1388 int32_t RSRenderServiceConnectionProxy::GetScreenBacklight(ScreenId id)
1389 {
1390 MessageParcel data;
1391 MessageParcel reply;
1392 MessageOption option;
1393 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1394 return INVALID_BACKLIGHT_VALUE;
1395 }
1396 option.SetFlags(MessageOption::TF_SYNC);
1397 data.WriteUint64(id);
1398 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_BACK_LIGHT);
1399 int32_t err = Remote()->SendRequest(code, data, reply, option);
1400 if (err != NO_ERROR) {
1401 return INVALID_BACKLIGHT_VALUE;
1402 }
1403 int32_t level = reply.ReadInt32();
1404 return level;
1405 }
1406
SetScreenBacklight(ScreenId id,uint32_t level)1407 void RSRenderServiceConnectionProxy::SetScreenBacklight(ScreenId id, uint32_t level)
1408 {
1409 MessageParcel data;
1410 MessageParcel reply;
1411 MessageOption option;
1412 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1413 return;
1414 }
1415 option.SetFlags(MessageOption::TF_SYNC);
1416 data.WriteUint64(id);
1417 data.WriteUint32(level);
1418 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_BACK_LIGHT);
1419 int32_t err = Remote()->SendRequest(code, data, reply, option);
1420 if (err != NO_ERROR) {
1421 return;
1422 }
1423 }
1424
RegisterBufferClearListener(NodeId id,sptr<RSIBufferClearCallback> callback)1425 void RSRenderServiceConnectionProxy::RegisterBufferClearListener(
1426 NodeId id, sptr<RSIBufferClearCallback> callback)
1427 {
1428 if (callback == nullptr) {
1429 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferClearListener: callback is nullptr.");
1430 return;
1431 }
1432
1433 MessageParcel data;
1434 MessageParcel reply;
1435 MessageOption option;
1436
1437 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1438 return;
1439 }
1440 option.SetFlags(MessageOption::TF_SYNC);
1441 data.WriteUint64(id);
1442 data.WriteRemoteObject(callback->AsObject());
1443 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_CLEAR_LISTENER);
1444 int32_t err = Remote()->SendRequest(code, data, reply, option);
1445 if (err != NO_ERROR) {
1446 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferClearListener: Send Request err.");
1447 return;
1448 }
1449 }
1450
RegisterBufferAvailableListener(NodeId id,sptr<RSIBufferAvailableCallback> callback,bool isFromRenderThread)1451 void RSRenderServiceConnectionProxy::RegisterBufferAvailableListener(
1452 NodeId id, sptr<RSIBufferAvailableCallback> callback, bool isFromRenderThread)
1453 {
1454 if (callback == nullptr) {
1455 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferAvailableListener: callback is nullptr.");
1456 return;
1457 }
1458
1459 MessageParcel data;
1460 MessageParcel reply;
1461 MessageOption option;
1462
1463 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1464 return;
1465 }
1466
1467 option.SetFlags(MessageOption::TF_SYNC);
1468 data.WriteUint64(id);
1469 data.WriteRemoteObject(callback->AsObject());
1470 data.WriteBool(isFromRenderThread);
1471 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_AVAILABLE_LISTENER);
1472 int32_t err = Remote()->SendRequest(code, data, reply, option);
1473 if (err != NO_ERROR) {
1474 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferAvailableListener: Send Request err.");
1475 return;
1476 }
1477 }
1478
GetScreenSupportedColorGamuts(ScreenId id,std::vector<ScreenColorGamut> & mode)1479 int32_t RSRenderServiceConnectionProxy::GetScreenSupportedColorGamuts(ScreenId id, std::vector<ScreenColorGamut>& mode)
1480 {
1481 MessageParcel data;
1482 MessageParcel reply;
1483 MessageOption option;
1484 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1485 return RS_CONNECTION_ERROR;
1486 }
1487 option.SetFlags(MessageOption::TF_SYNC);
1488 data.WriteUint64(id);
1489 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_GAMUTS);
1490 int32_t err = Remote()->SendRequest(code, data, reply, option);
1491 if (err != NO_ERROR) {
1492 return RS_CONNECTION_ERROR;
1493 }
1494 int32_t result = reply.ReadInt32();
1495 if (result == SUCCESS) {
1496 mode.clear();
1497 std::vector<uint32_t> modeRecv;
1498 reply.ReadUInt32Vector(&modeRecv);
1499 for (auto i : modeRecv) {
1500 mode.push_back(static_cast<ScreenColorGamut>(i));
1501 }
1502 }
1503 return result;
1504 }
1505
GetScreenSupportedMetaDataKeys(ScreenId id,std::vector<ScreenHDRMetadataKey> & keys)1506 int32_t RSRenderServiceConnectionProxy::GetScreenSupportedMetaDataKeys(
1507 ScreenId id, std::vector<ScreenHDRMetadataKey>& keys)
1508 {
1509 MessageParcel data;
1510 MessageParcel reply;
1511 MessageOption option;
1512 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1513 return RS_CONNECTION_ERROR;
1514 }
1515 option.SetFlags(MessageOption::TF_SYNC);
1516 data.WriteUint64(id);
1517 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_METADATAKEYS);
1518 int32_t err = Remote()->SendRequest(code, data, reply, option);
1519 if (err != NO_ERROR) {
1520 return RS_CONNECTION_ERROR;
1521 }
1522 int32_t result = reply.ReadInt32();
1523 if (result == SUCCESS) {
1524 keys.clear();
1525 std::vector<uint32_t> keyRecv;
1526 reply.ReadUInt32Vector(&keyRecv);
1527 for (auto i : keyRecv) {
1528 keys.push_back(static_cast<ScreenHDRMetadataKey>(i));
1529 }
1530 }
1531 return result;
1532 }
1533
GetScreenColorGamut(ScreenId id,ScreenColorGamut & mode)1534 int32_t RSRenderServiceConnectionProxy::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode)
1535 {
1536 MessageParcel data;
1537 MessageParcel reply;
1538 MessageOption option;
1539 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1540 return RS_CONNECTION_ERROR;
1541 }
1542 option.SetFlags(MessageOption::TF_SYNC);
1543 data.WriteUint64(id);
1544 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT);
1545 int32_t err = Remote()->SendRequest(code, data, reply, option);
1546 if (err != NO_ERROR) {
1547 return RS_CONNECTION_ERROR;
1548 }
1549 int32_t result = reply.ReadInt32();
1550 if (result == SUCCESS) {
1551 mode = static_cast<ScreenColorGamut>(reply.ReadUint32());
1552 }
1553 return result;
1554 }
1555
SetScreenColorGamut(ScreenId id,int32_t modeIdx)1556 int32_t RSRenderServiceConnectionProxy::SetScreenColorGamut(ScreenId id, int32_t modeIdx)
1557 {
1558 MessageParcel data;
1559 MessageParcel reply;
1560 MessageOption option;
1561 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1562 return RS_CONNECTION_ERROR;
1563 }
1564 option.SetFlags(MessageOption::TF_SYNC);
1565 data.WriteUint64(id);
1566 data.WriteInt32(modeIdx);
1567 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT);
1568 int32_t err = Remote()->SendRequest(code, data, reply, option);
1569 if (err != NO_ERROR) {
1570 return RS_CONNECTION_ERROR;
1571 }
1572 int32_t result = reply.ReadInt32();
1573 return result;
1574 }
1575
SetScreenGamutMap(ScreenId id,ScreenGamutMap mode)1576 int32_t RSRenderServiceConnectionProxy::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode)
1577 {
1578 MessageParcel data;
1579 MessageParcel reply;
1580 MessageOption option;
1581 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1582 return RS_CONNECTION_ERROR;
1583 }
1584 option.SetFlags(MessageOption::TF_SYNC);
1585 data.WriteUint64(id);
1586 data.WriteUint32(mode);
1587 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT_MAP);
1588 int32_t err = Remote()->SendRequest(code, data, reply, option);
1589 if (err != NO_ERROR) {
1590 return RS_CONNECTION_ERROR;
1591 }
1592 int32_t result = reply.ReadInt32();
1593 return result;
1594 }
1595
SetScreenCorrection(ScreenId id,ScreenRotation screenRotation)1596 int32_t RSRenderServiceConnectionProxy::SetScreenCorrection(ScreenId id, ScreenRotation screenRotation)
1597 {
1598 MessageParcel data;
1599 MessageParcel reply;
1600 MessageOption option;
1601 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1602 return RS_CONNECTION_ERROR;
1603 }
1604 option.SetFlags(MessageOption::TF_SYNC);
1605 data.WriteUint64(id);
1606 data.WriteUint32(static_cast<uint32_t>(screenRotation));
1607 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CORRECTION);
1608 int32_t err = Remote()->SendRequest(code, data, reply, option);
1609 if (err != NO_ERROR) {
1610 return RS_CONNECTION_ERROR;
1611 }
1612 int32_t result = reply.ReadInt32();
1613 return result;
1614 }
1615
GetScreenGamutMap(ScreenId id,ScreenGamutMap & mode)1616 int32_t RSRenderServiceConnectionProxy::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode)
1617 {
1618 MessageParcel data;
1619 MessageParcel reply;
1620 MessageOption option;
1621 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1622 return RS_CONNECTION_ERROR;
1623 }
1624 option.SetFlags(MessageOption::TF_SYNC);
1625 data.WriteUint64(id);
1626 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT_MAP);
1627 int32_t err = Remote()->SendRequest(code, data, reply, option);
1628 if (err != NO_ERROR) {
1629 return RS_CONNECTION_ERROR;
1630 }
1631 int32_t result = reply.ReadInt32();
1632 if (result == SUCCESS) {
1633 mode = static_cast<ScreenGamutMap>(reply.ReadUint32());
1634 }
1635 return result;
1636 }
1637
GetScreenHDRCapability(ScreenId id,RSScreenHDRCapability & screenHdrCapability)1638 int32_t RSRenderServiceConnectionProxy::GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability)
1639 {
1640 MessageParcel data;
1641 MessageParcel reply;
1642 MessageOption option;
1643 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1644 return RS_CONNECTION_ERROR;
1645 }
1646 option.SetFlags(MessageOption::TF_SYNC);
1647 data.WriteUint64(id);
1648 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_CAPABILITY);
1649 int32_t err = Remote()->SendRequest(code, data, reply, option);
1650 if (err != NO_ERROR) {
1651 return RS_CONNECTION_ERROR;
1652 }
1653 int32_t result = reply.ReadInt32();
1654 if (result != SUCCESS) {
1655 return result;
1656 }
1657 sptr<RSScreenHDRCapability> pScreenCapability = reply.ReadParcelable<RSScreenHDRCapability>();
1658 if (pScreenCapability == nullptr) {
1659 return RS_CONNECTION_ERROR;
1660 }
1661 screenHdrCapability = *pScreenCapability;
1662 return SUCCESS;
1663 }
1664
GetPixelFormat(ScreenId id,GraphicPixelFormat & pixelFormat)1665 int32_t RSRenderServiceConnectionProxy::GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat)
1666 {
1667 MessageParcel data;
1668 MessageParcel reply;
1669 MessageOption option;
1670
1671 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1672 return WRITE_PARCEL_ERR;
1673 }
1674 option.SetFlags(MessageOption::TF_SYNC);
1675 data.WriteUint64(id);
1676 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_PIXEL_FORMAT);
1677 int32_t err = Remote()->SendRequest(code, data, reply, option);
1678 if (err != NO_ERROR) {
1679 return RS_CONNECTION_ERROR;
1680 }
1681 int32_t result = reply.ReadInt32();
1682 if (result == SUCCESS) {
1683 pixelFormat = static_cast<GraphicPixelFormat>(reply.ReadUint32());
1684 }
1685 return result;
1686 }
1687
SetPixelFormat(ScreenId id,GraphicPixelFormat pixelFormat)1688 int32_t RSRenderServiceConnectionProxy::SetPixelFormat(ScreenId id, GraphicPixelFormat pixelFormat)
1689 {
1690 MessageParcel data;
1691 MessageParcel reply;
1692 MessageOption option;
1693
1694 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1695 return WRITE_PARCEL_ERR;
1696 }
1697 option.SetFlags(MessageOption::TF_SYNC);
1698 data.WriteUint64(id);
1699 data.WriteUint32(static_cast<uint32_t>(pixelFormat));
1700 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_PIXEL_FORMAT);
1701 int32_t err = Remote()->SendRequest(code, data, reply, option);
1702 if (err != NO_ERROR) {
1703 return RS_CONNECTION_ERROR;
1704 }
1705 int32_t result = reply.ReadInt32();
1706 return result;
1707 }
1708
GetScreenSupportedHDRFormats(ScreenId id,std::vector<ScreenHDRFormat> & hdrFormats)1709 int32_t RSRenderServiceConnectionProxy::GetScreenSupportedHDRFormats(
1710 ScreenId id, std::vector<ScreenHDRFormat>& hdrFormats)
1711 {
1712 MessageParcel data;
1713 MessageParcel reply;
1714 MessageOption option;
1715 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1716 return RS_CONNECTION_ERROR;
1717 }
1718 option.SetFlags(MessageOption::TF_SYNC);
1719 data.WriteUint64(id);
1720 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_HDR_FORMATS);
1721 int32_t err = Remote()->SendRequest(code, data, reply, option);
1722 if (err != NO_ERROR) {
1723 return RS_CONNECTION_ERROR;
1724 }
1725 int32_t result = reply.ReadInt32();
1726 if (result == SUCCESS) {
1727 hdrFormats.clear();
1728 std::vector<uint32_t> hdrFormatsRecv;
1729 reply.ReadUInt32Vector(&hdrFormatsRecv);
1730 std::transform(hdrFormatsRecv.begin(), hdrFormatsRecv.end(), back_inserter(hdrFormats),
1731 [](uint32_t i) -> ScreenHDRFormat {return static_cast<ScreenHDRFormat>(i);});
1732 }
1733 return result;
1734 }
1735
GetScreenHDRFormat(ScreenId id,ScreenHDRFormat & hdrFormat)1736 int32_t RSRenderServiceConnectionProxy::GetScreenHDRFormat(ScreenId id, ScreenHDRFormat& hdrFormat)
1737 {
1738 MessageParcel data;
1739 MessageParcel reply;
1740 MessageOption option;
1741 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1742 return RS_CONNECTION_ERROR;
1743 }
1744 option.SetFlags(MessageOption::TF_SYNC);
1745 data.WriteUint64(id);
1746 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_FORMAT);
1747 int32_t err = Remote()->SendRequest(code, data, reply, option);
1748 if (err != NO_ERROR) {
1749 return RS_CONNECTION_ERROR;
1750 }
1751 int32_t result = reply.ReadInt32();
1752 if (result == SUCCESS) {
1753 hdrFormat = static_cast<ScreenHDRFormat>(reply.ReadUint32());
1754 }
1755 return result;
1756 }
1757
SetScreenHDRFormat(ScreenId id,int32_t modeIdx)1758 int32_t RSRenderServiceConnectionProxy::SetScreenHDRFormat(ScreenId id, int32_t modeIdx)
1759 {
1760 MessageParcel data;
1761 MessageParcel reply;
1762 MessageOption option;
1763 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1764 return RS_CONNECTION_ERROR;
1765 }
1766 option.SetFlags(MessageOption::TF_SYNC);
1767 data.WriteUint64(id);
1768 data.WriteInt32(modeIdx);
1769 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_HDR_FORMAT);
1770 int32_t err = Remote()->SendRequest(code, data, reply, option);
1771 if (err != NO_ERROR) {
1772 return RS_CONNECTION_ERROR;
1773 }
1774 int32_t result = reply.ReadInt32();
1775 return result;
1776 }
1777
GetScreenSupportedColorSpaces(ScreenId id,std::vector<GraphicCM_ColorSpaceType> & colorSpaces)1778 int32_t RSRenderServiceConnectionProxy::GetScreenSupportedColorSpaces(
1779 ScreenId id, std::vector<GraphicCM_ColorSpaceType>& colorSpaces)
1780 {
1781 MessageParcel data;
1782 MessageParcel reply;
1783 MessageOption option;
1784 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1785 return RS_CONNECTION_ERROR;
1786 }
1787 option.SetFlags(MessageOption::TF_SYNC);
1788 data.WriteUint64(id);
1789 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_COLORSPACES);
1790 int32_t err = Remote()->SendRequest(code, data, reply, option);
1791 if (err != NO_ERROR) {
1792 return RS_CONNECTION_ERROR;
1793 }
1794 int32_t result = reply.ReadInt32();
1795 if (result == SUCCESS) {
1796 colorSpaces.clear();
1797 std::vector<uint32_t> colorSpacesRecv;
1798 reply.ReadUInt32Vector(&colorSpacesRecv);
1799 std::transform(colorSpacesRecv.begin(), colorSpacesRecv.end(), back_inserter(colorSpaces),
1800 [](uint32_t i) -> GraphicCM_ColorSpaceType {return static_cast<GraphicCM_ColorSpaceType>(i);});
1801 }
1802 return result;
1803 }
1804
GetScreenColorSpace(ScreenId id,GraphicCM_ColorSpaceType & colorSpace)1805 int32_t RSRenderServiceConnectionProxy::GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace)
1806 {
1807 MessageParcel data;
1808 MessageParcel reply;
1809 MessageOption option;
1810 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1811 return RS_CONNECTION_ERROR;
1812 }
1813 option.SetFlags(MessageOption::TF_SYNC);
1814 data.WriteUint64(id);
1815 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_COLORSPACE);
1816 int32_t err = Remote()->SendRequest(code, data, reply, option);
1817 if (err != NO_ERROR) {
1818 return RS_CONNECTION_ERROR;
1819 }
1820 int32_t result = reply.ReadInt32();
1821 if (result == SUCCESS) {
1822 colorSpace = static_cast<GraphicCM_ColorSpaceType>(reply.ReadUint32());
1823 }
1824 return result;
1825 }
1826
SetScreenColorSpace(ScreenId id,GraphicCM_ColorSpaceType colorSpace)1827 int32_t RSRenderServiceConnectionProxy::SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace)
1828 {
1829 MessageParcel data;
1830 MessageParcel reply;
1831 MessageOption option;
1832 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1833 return RS_CONNECTION_ERROR;
1834 }
1835 option.SetFlags(MessageOption::TF_SYNC);
1836 data.WriteUint64(id);
1837 data.WriteInt32(colorSpace);
1838 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_COLORSPACE);
1839 int32_t err = Remote()->SendRequest(code, data, reply, option);
1840 if (err != NO_ERROR) {
1841 return RS_CONNECTION_ERROR;
1842 }
1843 int32_t result = reply.ReadInt32();
1844 return result;
1845 }
1846
GetScreenType(ScreenId id,RSScreenType & screenType)1847 int32_t RSRenderServiceConnectionProxy::GetScreenType(ScreenId id, RSScreenType& screenType)
1848 {
1849 MessageParcel data;
1850 MessageParcel reply;
1851 MessageOption option;
1852 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1853 return RS_CONNECTION_ERROR;
1854 }
1855 option.SetFlags(MessageOption::TF_SYNC);
1856 data.WriteUint64(id);
1857 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_TYPE);
1858 int32_t err = Remote()->SendRequest(code, data, reply, option);
1859 if (err != NO_ERROR) {
1860 return RS_CONNECTION_ERROR;
1861 }
1862 int32_t result = reply.ReadInt32();
1863 if (result == SUCCESS) {
1864 screenType = static_cast<RSScreenType>(reply.ReadUint32());
1865 }
1866 return result;
1867 }
1868
GetBitmap(NodeId id,Drawing::Bitmap & bitmap)1869 bool RSRenderServiceConnectionProxy::GetBitmap(NodeId id, Drawing::Bitmap& bitmap)
1870 {
1871 MessageParcel data;
1872 MessageParcel reply;
1873 MessageOption option;
1874 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1875 return false;
1876 }
1877 option.SetFlags(MessageOption::TF_SYNC);
1878 data.WriteUint64(id);
1879 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_BITMAP);
1880 int32_t err = Remote()->SendRequest(code, data, reply, option);
1881 if (err != NO_ERROR) {
1882 return false;
1883 }
1884 bool result = reply.ReadBool();
1885 if (!result || !RSMarshallingHelper::Unmarshalling(reply, bitmap)) {
1886 RS_LOGE("RSRenderServiceConnectionProxy::GetBitmap: Unmarshalling failed");
1887 return false;
1888 }
1889 return true;
1890 }
1891
SetVirtualMirrorScreenCanvasRotation(ScreenId id,bool canvasRotation)1892 bool RSRenderServiceConnectionProxy::SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation)
1893 {
1894 MessageParcel data;
1895 MessageParcel reply;
1896 MessageOption option;
1897 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1898 return false;
1899 }
1900 option.SetFlags(MessageOption::TF_SYNC);
1901 data.WriteUint64(id);
1902 data.WriteBool(canvasRotation);
1903 uint32_t code = static_cast<uint32_t>(
1904 RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_MIRROR_SCREEN_CANVAS_ROTATION);
1905 int32_t err = Remote()->SendRequest(code, data, reply, option);
1906 if (err != NO_ERROR) {
1907 return false;
1908 }
1909 bool result = reply.ReadBool();
1910 return result;
1911 }
1912
SetVirtualMirrorScreenScaleMode(ScreenId id,ScreenScaleMode scaleMode)1913 bool RSRenderServiceConnectionProxy::SetVirtualMirrorScreenScaleMode(ScreenId id, ScreenScaleMode scaleMode)
1914 {
1915 MessageParcel data;
1916 MessageParcel reply;
1917 MessageOption option;
1918 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1919 return false;
1920 }
1921 option.SetFlags(MessageOption::TF_SYNC);
1922 data.WriteUint64(id);
1923 data.WriteUint32(static_cast<uint32_t>(scaleMode));
1924 uint32_t code = static_cast<uint32_t>(
1925 RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_MIRROR_SCREEN_SCALE_MODE);
1926 int32_t err = Remote()->SendRequest(code, data, reply, option);
1927 if (err != NO_ERROR) {
1928 return false;
1929 }
1930 bool result = reply.ReadBool();
1931 return result;
1932 }
1933
SetGlobalDarkColorMode(bool isDark)1934 bool RSRenderServiceConnectionProxy::SetGlobalDarkColorMode(bool isDark)
1935 {
1936 MessageParcel data;
1937 MessageParcel reply;
1938 MessageOption option;
1939 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1940 return false;
1941 }
1942 option.SetFlags(MessageOption::TF_ASYNC);
1943 if (!data.WriteBool(isDark)) {
1944 return false;
1945 }
1946 uint32_t code = static_cast<uint32_t>(
1947 RSIRenderServiceConnectionInterfaceCode::SET_GLOBAL_DARK_COLOR_MODE);
1948 int32_t err = Remote()->SendRequest(code, data, reply, option);
1949 if (err != NO_ERROR) {
1950 return false;
1951 }
1952 return true;
1953 }
1954
GetPixelmap(NodeId id,std::shared_ptr<Media::PixelMap> pixelmap,const Drawing::Rect * rect,std::shared_ptr<Drawing::DrawCmdList> drawCmdList)1955 bool RSRenderServiceConnectionProxy::GetPixelmap(NodeId id, std::shared_ptr<Media::PixelMap> pixelmap,
1956 const Drawing::Rect* rect, std::shared_ptr<Drawing::DrawCmdList> drawCmdList)
1957 {
1958 MessageParcel data;
1959 MessageParcel reply;
1960 MessageOption option;
1961 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1962 return false;
1963 }
1964 option.SetFlags(MessageOption::TF_SYNC);
1965 data.WriteUint64(id);
1966 data.WriteParcelable(pixelmap.get());
1967 RSMarshallingHelper::Marshalling(data, *rect);
1968 RSMarshallingHelper::Marshalling(data, drawCmdList);
1969 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_PIXELMAP);
1970 int32_t err = Remote()->SendRequest(code, data, reply, option);
1971 if (err != NO_ERROR) {
1972 return false;
1973 }
1974 bool result = reply.ReadBool();
1975 if (!result || !RSMarshallingHelper::Unmarshalling(reply, pixelmap)) {
1976 RS_LOGD("RSRenderServiceConnectionProxy::GetPixelmap: GetPixelmap failed");
1977 return false;
1978 }
1979 return true;
1980 }
1981
RegisterTypeface(uint64_t globalUniqueId,std::shared_ptr<Drawing::Typeface> & typeface)1982 bool RSRenderServiceConnectionProxy::RegisterTypeface(uint64_t globalUniqueId,
1983 std::shared_ptr<Drawing::Typeface>& typeface)
1984 {
1985 MessageParcel data;
1986 MessageParcel reply;
1987 MessageOption option;
1988 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
1989 return false;
1990 }
1991 option.SetFlags(MessageOption::TF_SYNC);
1992 uint32_t hash = typeface->GetHash();
1993 data.WriteUint64(globalUniqueId);
1994 data.WriteUint32(hash);
1995
1996 if (hash) { // if adapter does not provide hash, use old path
1997 MessageParcel reply2;
1998 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NEED_REGISTER_TYPEFACE);
1999 int32_t err = Remote()->SendRequest(code, data, reply2, option);
2000 if (err != NO_ERROR) {
2001 RS_LOGW("Check if RegisterTypeface is needed failed, err:%{public}d", err);
2002 return false;
2003 }
2004 if (!reply2.ReadBool()) {
2005 return true; // the hash exists on server, no need to resend full data
2006 }
2007 }
2008
2009 RSMarshallingHelper::Marshalling(data, typeface);
2010
2011 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_TYPEFACE);
2012 int32_t err = Remote()->SendRequest(code, data, reply, option);
2013 if (err != NO_ERROR) {
2014 RS_LOGD("RSRenderServiceConnectionProxy::RegisterTypeface: RegisterTypeface failed");
2015 return false;
2016 }
2017 bool result = reply.ReadBool();
2018 return result;
2019 }
2020
UnRegisterTypeface(uint64_t globalUniqueId)2021 bool RSRenderServiceConnectionProxy::UnRegisterTypeface(uint64_t globalUniqueId)
2022 {
2023 MessageParcel data;
2024 MessageParcel reply;
2025 MessageOption option;
2026 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2027 return false;
2028 }
2029 option.SetFlags(MessageOption::TF_ASYNC);
2030 data.WriteUint64(globalUniqueId);
2031 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_TYPEFACE);
2032 int32_t err = Remote()->SendRequest(code, data, reply, option);
2033 if (err != NO_ERROR) {
2034 RS_LOGD("RSRenderServiceConnectionProxy::UnRegisterTypeface: send request failed");
2035 return false;
2036 }
2037
2038 return true;
2039 }
2040
SetScreenSkipFrameInterval(ScreenId id,uint32_t skipFrameInterval)2041 int32_t RSRenderServiceConnectionProxy::SetScreenSkipFrameInterval(ScreenId id, uint32_t skipFrameInterval)
2042 {
2043 MessageParcel data;
2044 MessageParcel reply;
2045 MessageOption option;
2046 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2047 return RS_CONNECTION_ERROR;
2048 }
2049 option.SetFlags(MessageOption::TF_SYNC);
2050 data.WriteUint64(id);
2051 data.WriteUint32(skipFrameInterval);
2052 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_SKIP_FRAME_INTERVAL);
2053 int32_t err = Remote()->SendRequest(code, data, reply, option);
2054 if (err != NO_ERROR) {
2055 return RS_CONNECTION_ERROR;
2056 }
2057 int32_t result = reply.ReadInt32();
2058 return result;
2059 }
2060
SetVirtualScreenRefreshRate(ScreenId id,uint32_t maxRefreshRate,uint32_t & actualRefreshRate)2061 int32_t RSRenderServiceConnectionProxy::SetVirtualScreenRefreshRate(
2062 ScreenId id, uint32_t maxRefreshRate, uint32_t& actualRefreshRate)
2063 {
2064 MessageParcel data;
2065 MessageParcel reply;
2066 MessageOption option;
2067 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2068 return RS_CONNECTION_ERROR;
2069 }
2070 option.SetFlags(MessageOption::TF_SYNC);
2071 if (!data.WriteUint64(id)) {
2072 return WRITE_PARCEL_ERR;
2073 }
2074 if (!data.WriteUint32(maxRefreshRate)) {
2075 return WRITE_PARCEL_ERR;
2076 }
2077 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_REFRESH_RATE);
2078 int32_t err = Remote()->SendRequest(code, data, reply, option);
2079 if (err != NO_ERROR) {
2080 return RS_CONNECTION_ERROR;
2081 }
2082 int32_t result = reply.ReadInt32();
2083 if (result == SUCCESS) {
2084 actualRefreshRate = reply.ReadUint32();
2085 }
2086 return result;
2087 }
2088
RegisterOcclusionChangeCallback(sptr<RSIOcclusionChangeCallback> callback)2089 int32_t RSRenderServiceConnectionProxy::RegisterOcclusionChangeCallback(sptr<RSIOcclusionChangeCallback> callback)
2090 {
2091 if (callback == nullptr) {
2092 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterOcclusionChangeCallback: callback is nullptr.");
2093 return INVALID_ARGUMENTS;
2094 }
2095 MessageParcel data;
2096 MessageParcel reply;
2097 MessageOption option;
2098 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2099 return RS_CONNECTION_ERROR;
2100 }
2101 option.SetFlags(MessageOption::TF_ASYNC);
2102 data.WriteRemoteObject(callback->AsObject());
2103 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_OCCLUSION_CHANGE_CALLBACK);
2104 int32_t err = Remote()->SendRequest(code, data, reply, option);
2105 if (err != NO_ERROR) {
2106 return RS_CONNECTION_ERROR;
2107 } else {
2108 return SUCCESS;
2109 }
2110 }
2111
RegisterSurfaceOcclusionChangeCallback(NodeId id,sptr<RSISurfaceOcclusionChangeCallback> callback,std::vector<float> & partitionPoints)2112 int32_t RSRenderServiceConnectionProxy::RegisterSurfaceOcclusionChangeCallback(
2113 NodeId id, sptr<RSISurfaceOcclusionChangeCallback> callback, std::vector<float>& partitionPoints)
2114 {
2115 if (callback == nullptr) {
2116 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceOcclusionChangeCallback: callback is nullptr.");
2117 return INVALID_ARGUMENTS;
2118 }
2119
2120 MessageParcel data;
2121 MessageParcel reply;
2122 MessageOption option;
2123 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2124 return RS_CONNECTION_ERROR;
2125 }
2126 option.SetFlags(MessageOption::TF_SYNC);
2127 data.WriteUint64(id);
2128 data.WriteRemoteObject(callback->AsObject());
2129 data.WriteFloatVector(partitionPoints);
2130
2131 uint32_t code = static_cast<uint32_t>(
2132 RSIRenderServiceConnectionInterfaceCode::REGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK);
2133 int32_t err = Remote()->SendRequest(code, data, reply, option);
2134 if (err != NO_ERROR) {
2135 return RS_CONNECTION_ERROR;
2136 }
2137 int32_t result = reply.ReadInt32();
2138 return result;
2139 }
2140
UnRegisterSurfaceOcclusionChangeCallback(NodeId id)2141 int32_t RSRenderServiceConnectionProxy::UnRegisterSurfaceOcclusionChangeCallback(NodeId id)
2142 {
2143 MessageParcel data;
2144 MessageParcel reply;
2145 MessageOption option;
2146 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2147 return RS_CONNECTION_ERROR;
2148 }
2149 option.SetFlags(MessageOption::TF_SYNC);
2150 data.WriteUint64(id);
2151
2152 uint32_t code = static_cast<uint32_t>(
2153 RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK);
2154 int32_t err = Remote()->SendRequest(code, data, reply, option);
2155 if (err != NO_ERROR) {
2156 return RS_CONNECTION_ERROR;
2157 }
2158 int32_t result = reply.ReadInt32();
2159 return result;
2160 }
2161
RegisterHgmConfigChangeCallback(sptr<RSIHgmConfigChangeCallback> callback)2162 int32_t RSRenderServiceConnectionProxy::RegisterHgmConfigChangeCallback(sptr<RSIHgmConfigChangeCallback> callback)
2163 {
2164 MessageParcel data;
2165 MessageParcel reply;
2166 MessageOption option;
2167 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2168 return RS_CONNECTION_ERROR;
2169 }
2170 option.SetFlags(MessageOption::TF_SYNC);
2171 data.WriteRemoteObject(callback->AsObject());
2172 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_HGM_CFG_CALLBACK);
2173 int32_t err = Remote()->SendRequest(code, data, reply, option);
2174 if (err != NO_ERROR) {
2175 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmConfigChangeCallback: Send Request err.");
2176 return RS_CONNECTION_ERROR;
2177 }
2178 int32_t result = reply.ReadInt32();
2179 return result;
2180 }
2181
RegisterHgmRefreshRateModeChangeCallback(sptr<RSIHgmConfigChangeCallback> callback)2182 int32_t RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback(
2183 sptr<RSIHgmConfigChangeCallback> callback)
2184 {
2185 MessageParcel data;
2186 MessageParcel reply;
2187 MessageOption option;
2188 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2189 return RS_CONNECTION_ERROR;
2190 }
2191 option.SetFlags(MessageOption::TF_SYNC);
2192 data.WriteRemoteObject(callback->AsObject());
2193 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REFRESH_RATE_MODE_CHANGE_CALLBACK);
2194 int32_t err = Remote()->SendRequest(code, data, reply, option);
2195 if (err != NO_ERROR) {
2196 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback: Send Request err.");
2197 return RS_CONNECTION_ERROR;
2198 }
2199 int32_t result = reply.ReadInt32();
2200 return result;
2201 }
2202
RegisterHgmRefreshRateUpdateCallback(sptr<RSIHgmConfigChangeCallback> callback)2203 int32_t RSRenderServiceConnectionProxy::RegisterHgmRefreshRateUpdateCallback(
2204 sptr<RSIHgmConfigChangeCallback> callback)
2205 {
2206 MessageParcel data;
2207 MessageParcel reply;
2208 MessageOption option;
2209 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2210 return RS_CONNECTION_ERROR;
2211 }
2212 option.SetFlags(MessageOption::TF_SYNC);
2213 if (callback) {
2214 if (!data.WriteBool(true)) {
2215 return WRITE_PARCEL_ERR;
2216 }
2217 if (!data.WriteRemoteObject(callback->AsObject())) {
2218 return WRITE_PARCEL_ERR;
2219 }
2220 } else {
2221 if (!data.WriteBool(false)) {
2222 return WRITE_PARCEL_ERR;
2223 }
2224 }
2225 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REFRESH_RATE_UPDATE_CALLBACK);
2226 int32_t err = Remote()->SendRequest(code, data, reply, option);
2227 if (err != NO_ERROR) {
2228 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback: Send Request err.");
2229 return RS_CONNECTION_ERROR;
2230 }
2231 int32_t result = reply.ReadInt32();
2232 return result;
2233 }
2234
RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid,sptr<RSIFrameRateLinkerExpectedFpsUpdateCallback> callback)2235 int32_t RSRenderServiceConnectionProxy::RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid,
2236 sptr<RSIFrameRateLinkerExpectedFpsUpdateCallback> callback)
2237 {
2238 MessageParcel data;
2239 MessageParcel reply;
2240 MessageOption option;
2241
2242 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2243 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterFrameRateLinkerCallback: WriteInterfaceToken err.");
2244 return WRITE_PARCEL_ERR;
2245 }
2246 option.SetFlags(MessageOption::TF_SYNC);
2247 if (!data.WriteInt32(dstPid)) {
2248 return WRITE_PARCEL_ERR;
2249 }
2250 if (callback) {
2251 if (!data.WriteBool(true) || !data.WriteRemoteObject(callback->AsObject())) {
2252 return WRITE_PARCEL_ERR;
2253 }
2254 } else {
2255 if (!data.WriteBool(false)) {
2256 return WRITE_PARCEL_ERR;
2257 }
2258 }
2259
2260 uint32_t code = static_cast<uint32_t>(
2261 RSIRenderServiceConnectionInterfaceCode::REGISTER_FRAME_RATE_LINKER_EXPECTED_FPS_CALLBACK);
2262 int32_t err = Remote()->SendRequest(code, data, reply, option);
2263 if (err != NO_ERROR) {
2264 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterFrameRateLinkerExpectedFpsUpdateCallback: "
2265 "Send Request err.");
2266 return RS_CONNECTION_ERROR;
2267 }
2268 int32_t result = reply.ReadInt32();
2269 return result;
2270 }
2271
SetAppWindowNum(uint32_t num)2272 void RSRenderServiceConnectionProxy::SetAppWindowNum(uint32_t num)
2273 {
2274 MessageParcel data;
2275 MessageParcel reply;
2276 MessageOption option;
2277 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2278 return;
2279 }
2280 option.SetFlags(MessageOption::TF_ASYNC);
2281 data.WriteUint32(num);
2282 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_APP_WINDOW_NUM);
2283 int32_t err = Remote()->SendRequest(code, data, reply, option);
2284 if (err != NO_ERROR) {
2285 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetAppWindowNum: Send Request err.");
2286 return;
2287 }
2288 }
2289
SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes)2290 bool RSRenderServiceConnectionProxy::SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes)
2291 {
2292 MessageParcel data;
2293 MessageParcel reply;
2294 MessageOption option;
2295 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2296 return false;
2297 }
2298 option.SetFlags(MessageOption::TF_SYNC);
2299 data.WriteUint32(static_cast<uint32_t>(systemAnimatedScenes));
2300 uint32_t code = static_cast<uint32_t>(
2301 RSIRenderServiceConnectionInterfaceCode::SET_SYSTEM_ANIMATED_SCENES);
2302 int32_t err = Remote()->SendRequest(code, data, reply, option);
2303 if (err != NO_ERROR) {
2304 return false;
2305 }
2306 bool result = reply.ReadBool();
2307 return result;
2308 }
2309
ShowWatermark(const std::shared_ptr<Media::PixelMap> & watermarkImg,bool isShow)2310 void RSRenderServiceConnectionProxy::ShowWatermark(const std::shared_ptr<Media::PixelMap> &watermarkImg, bool isShow)
2311 {
2312 if (watermarkImg == nullptr) {
2313 ROSEN_LOGE("RSRenderServiceConnectionProxy::ShowWatermark: watermarkImg is nullptr.");
2314 return;
2315 }
2316 MessageParcel data;
2317 MessageParcel reply;
2318 MessageOption option;
2319 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2320 return;
2321 }
2322 option.SetFlags(MessageOption::TF_ASYNC);
2323 data.WriteParcelable(watermarkImg.get());
2324 data.WriteBool(isShow);
2325 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SHOW_WATERMARK);
2326 int32_t err = Remote()->SendRequest(code, data, reply, option);
2327 if (err != NO_ERROR) {
2328 ROSEN_LOGE("RSRenderServiceConnectionProxy::ShowWatermark: Send Request err.");
2329 return;
2330 }
2331 }
2332
ResizeVirtualScreen(ScreenId id,uint32_t width,uint32_t height)2333 int32_t RSRenderServiceConnectionProxy::ResizeVirtualScreen(ScreenId id, uint32_t width, uint32_t height)
2334 {
2335 MessageParcel data;
2336 MessageParcel reply;
2337 MessageOption option;
2338
2339 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2340 ROSEN_LOGE("RSRenderServiceConnectionProxy::ResizeVirtualScreen: WriteInterfaceToken err.");
2341 return WRITE_PARCEL_ERR;
2342 }
2343 option.SetFlags(MessageOption::TF_SYNC);
2344 data.WriteUint64(id);
2345 data.WriteUint32(width);
2346 data.WriteUint32(height);
2347 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::RESIZE_VIRTUAL_SCREEN);
2348 int32_t err = Remote()->SendRequest(code, data, reply, option);
2349 if (err != NO_ERROR) {
2350 ROSEN_LOGE("RSRenderServiceConnectionProxy::ResizeVirtualScreen: Send Request err.");
2351 return RS_CONNECTION_ERROR;
2352 }
2353 int32_t status = reply.ReadInt32();
2354 return status;
2355 }
2356
ReportJankStats()2357 void RSRenderServiceConnectionProxy::ReportJankStats()
2358 {
2359 MessageParcel data;
2360 MessageParcel reply;
2361 MessageOption option;
2362 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2363 return;
2364 }
2365 option.SetFlags(MessageOption::TF_ASYNC);
2366 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_JANK_STATS);
2367 int32_t err = Remote()->SendRequest(code, data, reply, option);
2368 if (err != NO_ERROR) {
2369 ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportJankStats: Send Request err.");
2370 return;
2371 }
2372 }
2373
ReportEventResponse(DataBaseRs info)2374 void RSRenderServiceConnectionProxy::ReportEventResponse(DataBaseRs info)
2375 {
2376 MessageParcel data;
2377 MessageParcel reply;
2378 MessageOption option;
2379 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2380 return;
2381 }
2382 ReportDataBaseRs(data, reply, option, info);
2383 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_RESPONSE);
2384 int32_t err = Remote()->SendRequest(code, data, reply, option);
2385 if (err != NO_ERROR) {
2386 ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportEventResponse: Send Request err.");
2387 return;
2388 }
2389 }
2390
ReportEventComplete(DataBaseRs info)2391 void RSRenderServiceConnectionProxy::ReportEventComplete(DataBaseRs info)
2392 {
2393 MessageParcel data;
2394 MessageParcel reply;
2395 MessageOption option;
2396 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2397 return;
2398 }
2399 ReportDataBaseRs(data, reply, option, info);
2400 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_COMPLETE);
2401 int32_t err = Remote()->SendRequest(code, data, reply, option);
2402 if (err != NO_ERROR) {
2403 ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportEventComplete: Send Request err.");
2404 return;
2405 }
2406 }
2407
ReportEventJankFrame(DataBaseRs info)2408 void RSRenderServiceConnectionProxy::ReportEventJankFrame(DataBaseRs info)
2409 {
2410 MessageParcel data;
2411 MessageParcel reply;
2412 MessageOption option;
2413 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2414 return;
2415 }
2416 ReportDataBaseRs(data, reply, option, info);
2417 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_JANK_FRAME);
2418 int32_t err = Remote()->SendRequest(code, data, reply, option);
2419 if (err != NO_ERROR) {
2420 ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportEventJankFrame: Send Request err.");
2421 return;
2422 }
2423 }
2424
ReportDataBaseRs(MessageParcel & data,MessageParcel & reply,MessageOption & option,DataBaseRs info)2425 void RSRenderServiceConnectionProxy::ReportDataBaseRs(
2426 MessageParcel& data, MessageParcel& reply, MessageOption& option, DataBaseRs info)
2427 {
2428 data.WriteInt32(info.appPid);
2429 data.WriteInt32(info.eventType);
2430 data.WriteInt32(info.versionCode);
2431 data.WriteInt64(info.uniqueId);
2432 data.WriteInt64(info.inputTime);
2433 data.WriteInt64(info.beginVsyncTime);
2434 data.WriteInt64(info.endVsyncTime);
2435 data.WriteBool(info.isDisplayAnimator);
2436 data.WriteString(info.sceneId);
2437 data.WriteString(info.versionName);
2438 data.WriteString(info.bundleName);
2439 data.WriteString(info.processName);
2440 data.WriteString(info.abilityName);
2441 data.WriteString(info.pageUrl);
2442 data.WriteString(info.sourceType);
2443 data.WriteString(info.note);
2444 option.SetFlags(MessageOption::TF_ASYNC);
2445 }
2446
ReportGameStateDataRs(MessageParcel & data,MessageParcel & reply,MessageOption & option,GameStateData info)2447 void RSRenderServiceConnectionProxy::ReportGameStateDataRs(
2448 MessageParcel& data, MessageParcel& reply, MessageOption& option, GameStateData info)
2449 {
2450 data.WriteInt32(info.pid);
2451 data.WriteInt32(info.uid);
2452 data.WriteInt32(info.state);
2453 data.WriteInt32(info.renderTid);
2454 data.WriteString(info.bundleName);
2455 option.SetFlags(MessageOption::TF_ASYNC);
2456 }
2457
ReportGameStateData(GameStateData info)2458 void RSRenderServiceConnectionProxy::ReportGameStateData(GameStateData info)
2459 {
2460 MessageParcel data;
2461 MessageParcel reply;
2462 MessageOption option;
2463 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2464 return;
2465 }
2466 ReportGameStateDataRs(data, reply, option, info);
2467 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_GAMESTATE);
2468 int32_t err = Remote()->SendRequest(code, data, reply, option);
2469 if (err != NO_ERROR) {
2470 ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportGameStateData: Send Request err.");
2471 return;
2472 }
2473 }
2474
SetHardwareEnabled(NodeId id,bool isEnabled,SelfDrawingNodeType selfDrawingType,bool dynamicHardwareEnable)2475 void RSRenderServiceConnectionProxy::SetHardwareEnabled(NodeId id, bool isEnabled, SelfDrawingNodeType selfDrawingType,
2476 bool dynamicHardwareEnable)
2477 {
2478 MessageParcel data;
2479 MessageParcel reply;
2480 MessageOption option;
2481 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2482 return;
2483 }
2484 if (!data.WriteUint64(id)) {
2485 return;
2486 }
2487 if (!data.WriteBool(isEnabled)) {
2488 return;
2489 }
2490 if (!data.WriteUint8(static_cast<uint8_t>(selfDrawingType))) {
2491 return;
2492 }
2493 if (!data.WriteBool(dynamicHardwareEnable)) {
2494 return;
2495 }
2496 option.SetFlags(MessageOption::TF_ASYNC);
2497 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_HARDWARE_ENABLED);
2498 int32_t err = Remote()->SendRequest(code, data, reply, option);
2499 if (err != NO_ERROR) {
2500 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetHardwareEnabled: Send Request err.");
2501 return;
2502 }
2503 }
2504
SetHidePrivacyContent(NodeId id,bool needHidePrivacyContent)2505 uint32_t RSRenderServiceConnectionProxy::SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent)
2506 {
2507 MessageParcel data;
2508 MessageParcel reply;
2509 MessageOption option;
2510 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2511 return static_cast<uint32_t>(RSInterfaceErrorCode::WRITE_PARCEL_ERROR);
2512 }
2513 if (!data.WriteUint64(id)) {
2514 return static_cast<uint32_t>(RSInterfaceErrorCode::WRITE_PARCEL_ERROR);
2515 }
2516 if (!data.WriteBool(needHidePrivacyContent)) {
2517 return static_cast<uint32_t>(RSInterfaceErrorCode::WRITE_PARCEL_ERROR);
2518 }
2519 option.SetFlags(MessageOption::TF_SYNC);
2520 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_HIDE_PRIVACY_CONTENT);
2521 int32_t err = Remote()->SendRequest(code, data, reply, option);
2522 if (err != NO_ERROR) {
2523 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetHidePrivacyContent: Send Request err.");
2524 return static_cast<uint32_t>(RSInterfaceErrorCode::UNKNOWN_ERROR);
2525 }
2526 return reply.ReadUint32();
2527 }
2528
NotifyLightFactorStatus(bool isSafe)2529 void RSRenderServiceConnectionProxy::NotifyLightFactorStatus(bool isSafe)
2530 {
2531 MessageParcel data;
2532 MessageParcel reply;
2533 MessageOption option;
2534 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2535 return;
2536 }
2537 if (!data.WriteBool(isSafe)) {
2538 return;
2539 }
2540 option.SetFlags(MessageOption::TF_ASYNC);
2541 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_LIGHT_FACTOR_STATUS);
2542 int32_t err = Remote()->SendRequest(code, data, reply, option);
2543 if (err != NO_ERROR) {
2544 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyLightFactorStatus: Send Request err.");
2545 return;
2546 }
2547 }
2548
NotifyPackageEvent(uint32_t listSize,const std::vector<std::string> & packageList)2549 void RSRenderServiceConnectionProxy::NotifyPackageEvent(uint32_t listSize, const std::vector<std::string>& packageList)
2550 {
2551 MessageParcel data;
2552 MessageParcel reply;
2553 MessageOption option;
2554 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2555 return;
2556 }
2557 if (listSize != packageList.size()) {
2558 ROSEN_LOGE("input size doesn't match");
2559 return;
2560 }
2561 if (!data.WriteUint32(listSize)) {
2562 return;
2563 }
2564 for (auto pkg : packageList) {
2565 if (!data.WriteString(pkg)) {
2566 return;
2567 }
2568 }
2569 option.SetFlags(MessageOption::TF_ASYNC);
2570 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PACKAGE_EVENT);
2571 int32_t err = Remote()->SendRequest(code, data, reply, option);
2572 if (err != NO_ERROR) {
2573 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyPackageEvent: Send Request err.");
2574 return;
2575 }
2576 }
2577
NotifyRefreshRateEvent(const EventInfo & eventInfo)2578 void RSRenderServiceConnectionProxy::NotifyRefreshRateEvent(const EventInfo& eventInfo)
2579 {
2580 MessageParcel data;
2581 MessageParcel reply;
2582 MessageOption option;
2583 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2584 return;
2585 }
2586 if (!data.WriteString(eventInfo.eventName)) {
2587 return;
2588 }
2589 if (!data.WriteBool(eventInfo.eventStatus)) {
2590 return;
2591 }
2592 if (!data.WriteUint32(eventInfo.minRefreshRate)) {
2593 return;
2594 }
2595 if (!data.WriteUint32(eventInfo.maxRefreshRate)) {
2596 return;
2597 }
2598 if (!data.WriteString(eventInfo.description)) {
2599 return;
2600 }
2601 option.SetFlags(MessageOption::TF_ASYNC);
2602 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_REFRESH_RATE_EVENT);
2603 int32_t err = Remote()->SendRequest(code, data, reply, option);
2604 if (err != NO_ERROR) {
2605 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyRefreshRateEvent: Send Request err.");
2606 return;
2607 }
2608 }
2609
NotifyTouchEvent(int32_t touchStatus,int32_t touchCnt)2610 void RSRenderServiceConnectionProxy::NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt)
2611 {
2612 MessageParcel data;
2613 MessageParcel reply;
2614 MessageOption option;
2615 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2616 return;
2617 }
2618 if (!data.WriteInt32(touchStatus)) {
2619 return;
2620 }
2621 if (!data.WriteInt32(touchCnt)) {
2622 return;
2623 }
2624 option.SetFlags(MessageOption::TF_ASYNC);
2625 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_TOUCH_EVENT);
2626 int32_t err = Remote()->SendRequest(code, data, reply, option);
2627 if (err != NO_ERROR) {
2628 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyTouchEvent: Send Request err.");
2629 return;
2630 }
2631 }
2632
NotifyDynamicModeEvent(bool enableDynamicMode)2633 void RSRenderServiceConnectionProxy::NotifyDynamicModeEvent(bool enableDynamicMode)
2634 {
2635 MessageParcel data;
2636 MessageParcel reply;
2637 MessageOption option;
2638 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2639 return;
2640 }
2641 if (!data.WriteBool(enableDynamicMode)) {
2642 return;
2643 }
2644 option.SetFlags(MessageOption::TF_ASYNC);
2645 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_DYNAMIC_MODE_EVENT);
2646 int32_t err = Remote()->SendRequest(code, data, reply, option);
2647 if (err != NO_ERROR) {
2648 ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyDynamicModeEvent: Send Request err.");
2649 return;
2650 }
2651 }
2652
SetCacheEnabledForRotation(bool isEnabled)2653 void RSRenderServiceConnectionProxy::SetCacheEnabledForRotation(bool isEnabled)
2654 {
2655 MessageParcel data;
2656 MessageParcel reply;
2657 MessageOption option;
2658 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2659 return;
2660 }
2661 if (!data.WriteBool(isEnabled)) {
2662 return;
2663 }
2664 option.SetFlags(MessageOption::TF_ASYNC);
2665 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_ROTATION_CACHE_ENABLED);
2666 int32_t err = Remote()->SendRequest(code, data, reply, option);
2667 if (err != NO_ERROR) {
2668 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetCacheEnabledForRotation: Send Request err.");
2669 return;
2670 }
2671 }
2672
SetOnRemoteDiedCallback(const OnRemoteDiedCallback & callback)2673 void RSRenderServiceConnectionProxy::SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback)
2674 {
2675 OnRemoteDiedCallback_ = callback;
2676 }
2677
RunOnRemoteDiedCallback()2678 void RSRenderServiceConnectionProxy::RunOnRemoteDiedCallback()
2679 {
2680 if (OnRemoteDiedCallback_) {
2681 OnRemoteDiedCallback_();
2682 }
2683 }
2684
GetActiveDirtyRegionInfo()2685 std::vector<ActiveDirtyRegionInfo> RSRenderServiceConnectionProxy::GetActiveDirtyRegionInfo()
2686 {
2687 MessageParcel data;
2688 MessageParcel reply;
2689 MessageOption option;
2690 std::vector<ActiveDirtyRegionInfo> activeDirtyRegionInfos;
2691 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2692 return activeDirtyRegionInfos;
2693 }
2694 option.SetFlags(MessageOption::TF_SYNC);
2695 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_DIRTY_REGION_INFO);
2696 int32_t err = Remote()->SendRequest(code, data, reply, option);
2697 if (err != NO_ERROR) {
2698 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetActiveDirtyRegionInfo: Send Request err.");
2699 return activeDirtyRegionInfos;
2700 }
2701 int32_t activeDirtyRegionInfosSize = reply.ReadInt32();
2702 while (activeDirtyRegionInfosSize--) {
2703 activeDirtyRegionInfos.emplace_back(ActiveDirtyRegionInfo(reply.ReadInt64(), reply.ReadInt32(),
2704 reply.ReadInt32(), reply.ReadString()));
2705 }
2706 return activeDirtyRegionInfos;
2707 }
2708
GetGlobalDirtyRegionInfo()2709 GlobalDirtyRegionInfo RSRenderServiceConnectionProxy::GetGlobalDirtyRegionInfo()
2710 {
2711 MessageParcel data;
2712 MessageParcel reply;
2713 MessageOption option;
2714 GlobalDirtyRegionInfo globalDirtyRegionInfo;
2715 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2716 return globalDirtyRegionInfo;
2717 }
2718 option.SetFlags(MessageOption::TF_SYNC);
2719 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_GLOBAL_DIRTY_REGION_INFO);
2720 int32_t err = Remote()->SendRequest(code, data, reply, option);
2721 if (err != NO_ERROR) {
2722 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetGlobalDirtyRegionInfo: Send Request err.");
2723 return globalDirtyRegionInfo;
2724 }
2725 return GlobalDirtyRegionInfo(reply.ReadInt64(), reply.ReadInt32(), reply.ReadInt32(), reply.ReadInt32());
2726 }
2727
GetLayerComposeInfo()2728 LayerComposeInfo RSRenderServiceConnectionProxy::GetLayerComposeInfo()
2729 {
2730 MessageParcel data;
2731 MessageParcel reply;
2732 MessageOption option;
2733 LayerComposeInfo layerComposeInfo;
2734 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2735 return layerComposeInfo;
2736 }
2737 option.SetFlags(MessageOption::TF_SYNC);
2738 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_LAYER_COMPOSE_INFO);
2739 int32_t err = Remote()->SendRequest(code, data, reply, option);
2740 if (err != NO_ERROR) {
2741 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetLayerComposeInfo: Send Request err.");
2742 return layerComposeInfo;
2743 }
2744 return LayerComposeInfo(reply.ReadInt32(), reply.ReadInt32(), reply.ReadInt32());
2745 }
2746
GetHwcDisabledReasonInfo()2747 HwcDisabledReasonInfos RSRenderServiceConnectionProxy::GetHwcDisabledReasonInfo()
2748 {
2749 MessageParcel data;
2750 MessageParcel reply;
2751 MessageOption option;
2752 HwcDisabledReasonInfos hwcDisabledReasonInfos;
2753 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2754 return hwcDisabledReasonInfos;
2755 }
2756 option.SetFlags(MessageOption::TF_SYNC);
2757 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::
2758 GET_HARDWARE_COMPOSE_DISABLED_REASON_INFO);
2759 int32_t err = Remote()->SendRequest(code, data, reply, option);
2760 if (err != NO_ERROR) {
2761 ROSEN_LOGE("RSRenderServiceConnectionProxy::GetHwcDisabledReasonInfo: Send Request err.");
2762 return hwcDisabledReasonInfos;
2763 }
2764 int32_t size = reply.ReadInt32();
2765 size_t readableSize = reply.GetReadableBytes() / (sizeof(HwcDisabledReasonInfo) - HWC_DISABLED_REASON_INFO_OFFSET);
2766 size_t len = static_cast<size_t>(size);
2767 if (len > readableSize || len > hwcDisabledReasonInfos.max_size()) {
2768 RS_LOGE("RSRenderServiceConnectionProxy GetHwcDisabledReasonInfo Failed read vector, size:%{public}zu,"
2769 " readableSize:%{public}zu", len, readableSize);
2770 return hwcDisabledReasonInfos;
2771 }
2772
2773 HwcDisabledReasonInfo hwcDisabledReasonInfo;
2774 while (size--) {
2775 for (int32_t pos = 0; pos < HwcDisabledReasons::DISABLED_REASON_LENGTH; pos++) {
2776 hwcDisabledReasonInfo.disabledReasonStatistics[pos] = reply.ReadInt32();
2777 }
2778 hwcDisabledReasonInfo.pidOfBelongsApp = reply.ReadInt32();
2779 hwcDisabledReasonInfo.nodeName = reply.ReadString();
2780 hwcDisabledReasonInfos.emplace_back(hwcDisabledReasonInfo);
2781 }
2782 return hwcDisabledReasonInfos;
2783 }
2784
SetVmaCacheStatus(bool flag)2785 void RSRenderServiceConnectionProxy::SetVmaCacheStatus(bool flag)
2786 {
2787 MessageParcel data;
2788 MessageParcel reply;
2789 MessageOption option;
2790 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2791 return;
2792 }
2793 if (!data.WriteBool(flag)) {
2794 return;
2795 }
2796 option.SetFlags(MessageOption::TF_ASYNC);
2797 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VMA_CACHE_STATUS);
2798 int32_t err = Remote()->SendRequest(code, data, reply, option);
2799 if (err != NO_ERROR) {
2800 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVmaCacheStatus %d: Send Request err.", flag);
2801 return;
2802 }
2803 }
2804
2805 #ifdef TP_FEATURE_ENABLE
SetTpFeatureConfig(int32_t feature,const char * config,TpFeatureConfigType tpFeatureConfigType)2806 void RSRenderServiceConnectionProxy::SetTpFeatureConfig(int32_t feature, const char* config,
2807 TpFeatureConfigType tpFeatureConfigType)
2808 {
2809 MessageParcel data;
2810 MessageParcel reply;
2811 MessageOption option;
2812
2813 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2814 return;
2815 }
2816
2817 if (!data.WriteInt32(feature)) {
2818 return;
2819 }
2820
2821 if (!data.WriteCString(config)) {
2822 return;
2823 }
2824
2825 if (!data.WriteUint8(static_cast<uint8_t>(tpFeatureConfigType))) {
2826 return;
2827 }
2828
2829 option.SetFlags(MessageOption::TF_SYNC);
2830 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_TP_FEATURE_CONFIG);
2831 int32_t err = Remote()->SendRequest(code, data, reply, option);
2832 if (err != NO_ERROR) {
2833 return;
2834 }
2835 }
2836 #endif
2837
SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus)2838 void RSRenderServiceConnectionProxy::SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus)
2839 {
2840 MessageParcel data;
2841 MessageParcel reply;
2842 MessageOption option;
2843 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2844 return;
2845 }
2846 if (!data.WriteBool(isVirtualScreenUsingStatus)) {
2847 return;
2848 }
2849 option.SetFlags(MessageOption::TF_ASYNC);
2850 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_USING_STATUS);
2851 int32_t err = Remote()->SendRequest(code, data, reply, option);
2852 if (err != NO_ERROR) {
2853 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenUsingStatus: Send Request err.");
2854 return;
2855 }
2856 }
2857
SetCurtainScreenUsingStatus(bool isCurtainScreenOn)2858 void RSRenderServiceConnectionProxy::SetCurtainScreenUsingStatus(bool isCurtainScreenOn)
2859 {
2860 MessageParcel data;
2861 MessageParcel reply;
2862 MessageOption option;
2863 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2864 return;
2865 }
2866 if (!data.WriteBool(isCurtainScreenOn)) {
2867 return;
2868 }
2869 option.SetFlags(MessageOption::TF_ASYNC);
2870 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_CURTAIN_SCREEN_USING_STATUS);
2871 int32_t err = Remote()->SendRequest(code, data, reply, option);
2872 if (err != NO_ERROR) {
2873 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetCurtainScreenUsingStatus: Send Request err.");
2874 return;
2875 }
2876 }
2877
DropFrameByPid(const std::vector<int32_t> pidList)2878 void RSRenderServiceConnectionProxy::DropFrameByPid(const std::vector<int32_t> pidList)
2879 {
2880 MessageParcel data;
2881 MessageParcel reply;
2882 MessageOption option;
2883 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2884 return;
2885 }
2886 if (!data.WriteInt32Vector(pidList)) {
2887 return;
2888 }
2889 option.SetFlags(MessageOption::TF_ASYNC);
2890 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::DROP_FRAME_BY_PID);
2891 int32_t err = Remote()->SendRequest(code, data, reply, option);
2892 if (err != NO_ERROR) {
2893 ROSEN_LOGE("RSRenderServiceConnectionProxy::DropFrameByPid: Send Request err.");
2894 return;
2895 }
2896 }
2897
RegisterUIExtensionCallback(uint64_t userId,sptr<RSIUIExtensionCallback> callback)2898 int32_t RSRenderServiceConnectionProxy::RegisterUIExtensionCallback(
2899 uint64_t userId, sptr<RSIUIExtensionCallback> callback)
2900 {
2901 if (callback == nullptr) {
2902 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterUIExtensionCallback: callback is nullptr.");
2903 return INVALID_ARGUMENTS;
2904 }
2905 MessageParcel data;
2906 MessageParcel reply;
2907 MessageOption option;
2908 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2909 return RS_CONNECTION_ERROR;
2910 }
2911 option.SetFlags(MessageOption::TF_SYNC);
2912 if (data.WriteUint64(userId) && data.WriteRemoteObject(callback->AsObject())) {
2913 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_UIEXTENSION_CALLBACK);
2914 int32_t err = Remote()->SendRequest(code, data, reply, option);
2915 if (err != NO_ERROR) {
2916 return RS_CONNECTION_ERROR;
2917 }
2918 int32_t result = reply.ReadInt32();
2919 return result;
2920 } else {
2921 return RS_CONNECTION_ERROR;
2922 }
2923 }
2924
SetAncoForceDoDirect(bool direct)2925 bool RSRenderServiceConnectionProxy::SetAncoForceDoDirect(bool direct)
2926 {
2927 MessageParcel data;
2928 MessageParcel reply;
2929 MessageOption option;
2930 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2931 return false;
2932 }
2933 option.SetFlags(MessageOption::TF_SYNC);
2934 if (data.WriteBool(direct)) {
2935 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_ANCO_FORCE_DO_DIRECT);
2936 int32_t err = Remote()->SendRequest(code, data, reply, option);
2937 if (err != NO_ERROR) {
2938 return false;
2939 }
2940 bool result = reply.ReadBool();
2941 return result;
2942 } else {
2943 return false;
2944 }
2945 }
2946
RegisterSurfaceBufferCallback(pid_t pid,uint64_t uid,sptr<RSISurfaceBufferCallback> callback)2947 void RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback(
2948 pid_t pid, uint64_t uid, sptr<RSISurfaceBufferCallback> callback)
2949 {
2950 if (callback == nullptr) {
2951 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback callback == nullptr");
2952 return;
2953 }
2954 MessageParcel data;
2955 MessageParcel reply;
2956 MessageOption option;
2957 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2958 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: write token err.");
2959 return;
2960 }
2961 option.SetFlags(MessageOption::TF_ASYNC);
2962 static_assert(std::is_same_v<int32_t, pid_t>, "pid_t is not int32_t on this platform.");
2963 if (!data.WriteInt32(pid)) {
2964 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: write Int32 val err.");
2965 return;
2966 }
2967 if (!data.WriteUint64(uid)) {
2968 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: write Uint64 val err.");
2969 return;
2970 }
2971 if (!data.WriteRemoteObject(callback->AsObject())) {
2972 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: write RemoteObject val err.");
2973 return;
2974 }
2975 uint32_t code = static_cast<uint32_t>(
2976 RSIRenderServiceConnectionInterfaceCode::REGISTER_SURFACE_BUFFER_CALLBACK);
2977 int32_t err = Remote()->SendRequest(code, data, reply, option);
2978 if (err != NO_ERROR) {
2979 ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: Send Request err.");
2980 return;
2981 }
2982 }
2983
UnregisterSurfaceBufferCallback(pid_t pid,uint64_t uid)2984 void RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid)
2985 {
2986 MessageParcel data;
2987 MessageParcel reply;
2988 MessageOption option;
2989 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
2990 ROSEN_LOGE("RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback: write token err.");
2991 return;
2992 }
2993 option.SetFlags(MessageOption::TF_ASYNC);
2994 static_assert(std::is_same_v<int32_t, pid_t>, "pid_t is not int32_t on this platform.");
2995 if (!data.WriteInt32(pid)) {
2996 ROSEN_LOGE("RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback: write Int32 val err.");
2997 return;
2998 }
2999 if (!data.WriteUint64(uid)) {
3000 ROSEN_LOGE("RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback: write Uint64 val err.");
3001 return;
3002 }
3003 uint32_t code = static_cast<uint32_t>(
3004 RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SURFACE_BUFFER_CALLBACK);
3005 int32_t err = Remote()->SendRequest(code, data, reply, option);
3006 if (err != NO_ERROR) {
3007 ROSEN_LOGE("RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback: Send Request err.");
3008 return;
3009 }
3010 }
3011
SetLayerTop(const std::string & nodeIdStr,bool isTop)3012 void RSRenderServiceConnectionProxy::SetLayerTop(const std::string &nodeIdStr, bool isTop)
3013 {
3014 MessageParcel data;
3015 MessageParcel reply;
3016 MessageOption option;
3017 if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
3018 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetLayerTop: write token err.");
3019 return;
3020 }
3021 option.SetFlags(MessageOption::TF_ASYNC);
3022 if (data.WriteString(nodeIdStr) && data.WriteBool(isTop)) {
3023 uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP);
3024 int32_t err = Remote()->SendRequest(code, data, reply, option);
3025 if (err != NO_ERROR) {
3026 ROSEN_LOGE("RSRenderServiceConnectionProxy::SetLayerTop: Send Request err.");
3027 return;
3028 }
3029 }
3030 }
3031 } // namespace Rosen
3032 } // namespace OHOS
3033