• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_stub.h"
17 #include <memory>
18 #include <mutex>
19 #include "ivsync_connection.h"
20 #ifdef RES_SCHED_ENABLE
21 #include "res_sched_client.h"
22 #include "res_type.h"
23 #include <sched.h>
24 #endif
25 #include "securec.h"
26 #include "sys_binder.h"
27 
28 #include "command/rs_command_factory.h"
29 #include "common/rs_xcollie.h"
30 #include "hgm_frame_rate_manager.h"
31 #include "pipeline/rs_base_render_util.h"
32 #include "pipeline/rs_main_thread.h"
33 #include "pipeline/rs_uni_render_judgement.h"
34 #include "pipeline/rs_unmarshal_thread.h"
35 #include "platform/common/rs_log.h"
36 #include "transaction/rs_ashmem_helper.h"
37 #include "render/rs_typeface_cache.h"
38 #include "rs_trace.h"
39 #include "rs_profiler.h"
40 
41 namespace OHOS {
42 namespace Rosen {
43 namespace {
44 constexpr size_t MAX_DATA_SIZE_FOR_UNMARSHALLING_IN_PLACE = 1024 * 15; // 15kB
45 constexpr size_t FILE_DESCRIPTOR_LIMIT = 15;
46 constexpr size_t MAX_OBJECTNUM = INT_MAX;
47 constexpr size_t MAX_DATA_SIZE = INT_MAX;
48 #ifdef RES_SCHED_ENABLE
49 const uint32_t RS_IPC_QOS_LEVEL = 7;
50 constexpr const char* RS_BUNDLE_NAME = "render_service";
51 #endif
52 static constexpr std::array descriptorCheckList = {
53     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_FOCUS_APP_INFO),
54     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_DEFAULT_SCREEN_ID),
55     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_SCREEN_ID),
56     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_ALL_SCREEN_IDS),
57     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_VIRTUAL_SCREEN),
58     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_RESOLUTION),
59     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SURFACE),
60     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_BLACKLIST),
61     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::ADD_VIRTUAL_SCREEN_BLACKLIST),
62     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN_BLACKLIST),
63     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION_LIST),
64     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN),
65     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CHANGE_CALLBACK),
66     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_MODE),
67     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_REFRESH_RATE),
68     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_REFRESH_RATE_MODE),
69     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SYNC_FRAME_RATE_RANGE),
70     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_FRAME_RATE_LINKER),
71     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CURRENT_REFRESH_RATE),
72     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_CURRENT_REFRESH_RATE_MODE),
73     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_REFRESH_RATES),
74     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SHOW_REFRESH_RATE_ENABLED),
75     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED),
76     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::MARK_POWER_OFF_NEED_PROCESS_ONE_FRAME),
77     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::DISABLE_RENDER_CONTROL_SCREEN),
78     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_POWER_STATUS),
79     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_BACK_LIGHT),
80     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_ACTIVE_MODE),
81     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_MODES),
82     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CAPABILITY),
83     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_POWER_STATUS),
84     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_BACK_LIGHT),
85     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_DATA),
86     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_VIRTUAL_SCREEN_RESOLUTION),
87     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_AVAILABLE_LISTENER),
88     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_CLEAR_LISTENER),
89     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_GAMUTS),
90     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_METADATAKEYS),
91     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT),
92     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT),
93     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT_MAP),
94     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CORRECTION),
95     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_MIRROR_SCREEN_CANVAS_ROTATION),
96     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_MIRROR_SCREEN_SCALE_MODE),
97     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_GLOBAL_DARK_COLOR_MODE),
98     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT_MAP),
99     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_PIXEL_MAP_FROM_SURFACE),
100     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_CAPABILITY),
101     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_PIXEL_FORMAT),
102     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_PIXEL_FORMAT),
103     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_HDR_FORMATS),
104     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_FORMAT),
105     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_HDR_FORMAT),
106     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_COLORSPACES),
107     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_COLORSPACE),
108     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_COLORSPACE),
109     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_TYPE),
110     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_SKIP_FRAME_INTERVAL),
111     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_OCCLUSION_CHANGE_CALLBACK),
112     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_APP_WINDOW_NUM),
113     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SYSTEM_ANIMATED_SCENES),
114     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SHOW_WATERMARK),
115     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::RESIZE_VIRTUAL_SCREEN),
116     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHIC),
117     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHICS),
118     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_TOTAL_APP_MEM_SIZE),
119     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_JANK_STATS),
120     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_BITMAP),
121     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_PIXELMAP),
122     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::EXECUTE_SYNCHRONOUS_TASK),
123     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_LIGHT_FACTOR_STATUS),
124     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PACKAGE_EVENT),
125     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_REFRESH_RATE_EVENT),
126     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_RESPONSE),
127     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_COMPLETE),
128     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_JANK_FRAME),
129     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_GAMESTATE),
130     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_TOUCH_EVENT),
131     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_DYNAMIC_MODE_EVENT),
132     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_HARDWARE_ENABLED),
133     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_HIDE_PRIVACY_CONTENT),
134     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK),
135     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK),
136     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_HGM_CFG_CALLBACK),
137     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_ROTATION_CACHE_ENABLED),
138     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_DEFAULT_DEVICE_ROTATION_OFFSET),
139     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_TP_FEATURE_CONFIG),
140     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_USING_STATUS),
141     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REFRESH_RATE_MODE_CHANGE_CALLBACK),
142     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_CURTAIN_SCREEN_USING_STATUS),
143     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_TYPEFACE),
144     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_TYPEFACE),
145     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REFRESH_RATE_UPDATE_CALLBACK),
146     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_DIRTY_REGION_INFO),
147     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_GLOBAL_DIRTY_REGION_INFO),
148     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_LAYER_COMPOSE_INFO),
149     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_CAST_SCREEN_ENABLE_SKIP_WINDOW),
150     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_UIEXTENSION_CALLBACK),
151     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VMA_CACHE_STATUS),
152     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_ANCO_FORCE_DO_DIRECT),
153     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NEED_REGISTER_TYPEFACE),
154     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_SURFACE_BUFFER_CALLBACK),
155     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SURFACE_BUFFER_CALLBACK),
156     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_DISPLAY_NODE),
157     static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP),
158 };
159 
CopyFileDescriptor(MessageParcel & old,MessageParcel & copied)160 void CopyFileDescriptor(MessageParcel& old, MessageParcel& copied)
161 {
162     binder_size_t* object = reinterpret_cast<binder_size_t*>(old.GetObjectOffsets());
163     binder_size_t* copiedObject = reinterpret_cast<binder_size_t*>(copied.GetObjectOffsets());
164 
165     size_t objectNum = old.GetOffsetsSize();
166     if (objectNum > MAX_OBJECTNUM) {
167         return;
168     }
169 
170     uintptr_t data = old.GetData();
171     uintptr_t copiedData = copied.GetData();
172 
173     for (size_t i = 0; i < objectNum; i++) {
174         const flat_binder_object* flat = reinterpret_cast<flat_binder_object*>(data + object[i]);
175         flat_binder_object* copiedFlat = reinterpret_cast<flat_binder_object*>(copiedData + copiedObject[i]);
176 
177         if (flat->hdr.type == BINDER_TYPE_FD && flat->handle > 0) {
178             int32_t val = dup(flat->handle);
179             if (val < 0) {
180                 ROSEN_LOGW("CopyFileDescriptor dup failed, fd:%{public}d, handle:%{public}" PRIu32, val,
181                     static_cast<uint32_t>(flat->handle));
182             }
183             copiedFlat->handle = static_cast<uint32_t>(val);
184         }
185     }
186 }
187 
CopyParcelIfNeed(MessageParcel & old,pid_t callingPid)188 std::shared_ptr<MessageParcel> CopyParcelIfNeed(MessageParcel& old, pid_t callingPid)
189 {
190     if (RSSystemProperties::GetCacheEnabledForRotation() &&
191         RSMainThread::Instance()->GetDesktopPidForRotationScene() != callingPid) {
192         return nullptr;
193     }
194     auto dataSize = old.GetDataSize();
195     if (dataSize <= MAX_DATA_SIZE_FOR_UNMARSHALLING_IN_PLACE && old.GetOffsetsSize() < FILE_DESCRIPTOR_LIMIT) {
196         return nullptr;
197     }
198     if (dataSize > MAX_DATA_SIZE) {
199         return nullptr;
200     }
201     if (dataSize == 0) {
202         return nullptr;
203     }
204     RS_TRACE_NAME("CopyParcelForUnmarsh: size:" + std::to_string(dataSize));
205     void* base = malloc(dataSize);
206     if (base == nullptr) {
207         RS_LOGE("RSRenderServiceConnectionStub::CopyParcelIfNeed malloc failed");
208         return nullptr;
209     }
210     if (memcpy_s(base, dataSize, reinterpret_cast<void*>(old.GetData()), dataSize) != 0) {
211         RS_LOGE("RSRenderServiceConnectionStub::CopyParcelIfNeed copy parcel data failed");
212         free(base);
213         return nullptr;
214     }
215 
216     auto parcelCopied = RS_PROFILER_COPY_PARCEL(old);
217     if (!parcelCopied->ParseFrom(reinterpret_cast<uintptr_t>(base), dataSize)) {
218         RS_LOGE("RSRenderServiceConnectionStub::CopyParcelIfNeed ParseFrom failed");
219         free(base);
220         return nullptr;
221     }
222 
223     auto objectNum = old.GetOffsetsSize();
224     if (objectNum != 0) {
225         parcelCopied->InjectOffsets(old.GetObjectOffsets(), objectNum);
226         CopyFileDescriptor(old, *parcelCopied);
227     }
228     if (parcelCopied->ReadInt32() != 0) {
229         RS_LOGE("RSRenderServiceConnectionStub::CopyParcelIfNeed parcel data not match");
230         return nullptr;
231     }
232     return parcelCopied;
233 }
234 
CheckCreateNodeAndSurface(pid_t pid,RSSurfaceNodeType nodeType,SurfaceWindowType windowType)235 bool CheckCreateNodeAndSurface(pid_t pid, RSSurfaceNodeType nodeType, SurfaceWindowType windowType)
236 {
237     constexpr int nodeTypeMin = static_cast<int>(RSSurfaceNodeType::DEFAULT);
238     constexpr int nodeTypeMax = static_cast<int>(RSSurfaceNodeType::UI_EXTENSION_SECURE_NODE);
239 
240     int typeNum = static_cast<int>(nodeType);
241     if (typeNum < nodeTypeMin || typeNum > nodeTypeMax) {
242         RS_LOGW("CREATE_NODE_AND_SURFACE invalid RSSurfaceNodeType");
243         return false;
244     }
245     if (windowType != SurfaceWindowType::DEFAULT_WINDOW && windowType != SurfaceWindowType::SYSTEM_SCB_WINDOW) {
246         RS_LOGW("CREATE_NODE_AND_SURFACE invalid SurfaceWindowType");
247         return false;
248     }
249 
250     bool isTokenTypeValid = true;
251     bool isNonSystemAppCalling = false;
252     RSInterfaceCodeAccessVerifierBase::GetAccessType(isTokenTypeValid, isNonSystemAppCalling);
253     if (isNonSystemAppCalling) {
254         if (nodeType != RSSurfaceNodeType::DEFAULT &&
255             nodeType != RSSurfaceNodeType::APP_WINDOW_NODE &&
256             nodeType != RSSurfaceNodeType::SELF_DRAWING_NODE &&
257             nodeType != RSSurfaceNodeType::UI_EXTENSION_COMMON_NODE) {
258             RS_LOGW("CREATE_NODE_AND_SURFACE NonSystemAppCalling invalid RSSurfaceNodeType %{public}d, pid %d",
259                 typeNum, pid);
260             return false;
261         }
262         if (windowType != SurfaceWindowType::DEFAULT_WINDOW) {
263             RS_LOGW("CREATE_NODE_AND_SURFACE NonSystemAppCalling invalid SurfaceWindowType %{public}d, pid %d",
264                 static_cast<int>(windowType), pid);
265             return false;
266         }
267     }
268 
269     return true;
270 }
271 }
272 
SetQos()273 void RSRenderServiceConnectionStub::SetQos()
274 {
275 #ifdef RES_SCHED_ENABLE
276     std::string strBundleName = RS_BUNDLE_NAME;
277     std::string strPid = std::to_string(getpid());
278     std::string strTid = std::to_string(gettid());
279     std::string strQos = std::to_string(RS_IPC_QOS_LEVEL);
280     std::unordered_map<std::string, std::string> mapPayload;
281     mapPayload["pid"] = strPid;
282     mapPayload[strTid] = strQos;
283     mapPayload["bundleName"] = strBundleName;
284     OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(
285         OHOS::ResourceSchedule::ResType::RES_TYPE_THREAD_QOS_CHANGE, 0, mapPayload);
286     struct sched_param param = {0};
287     param.sched_priority = 1;
288     if (sched_setscheduler(0, SCHED_FIFO, &param) != 0) {
289         RS_LOGE("RSRenderServiceConnectionStub Couldn't set SCHED_FIFO.");
290     } else {
291         RS_LOGI("RSRenderServiceConnectionStub set SCHED_FIFO succeed.");
292     }
293 #endif
294 }
295 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)296 int RSRenderServiceConnectionStub::OnRemoteRequest(
297     uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
298 {
299     RS_PROFILER_ON_REMOTE_REQUEST(this, code, data, reply, option);
300     auto tid = gettid();
301     {
302         std::lock_guard<std::mutex> lock(mutex_);
303         if (tids_.find(tid) == tids_.end()) {
304             SetQos();
305             tids_.insert(tid);
306         }
307     }
308     pid_t callingPid = GetCallingPid();
309     if (std::find(std::cbegin(descriptorCheckList), std::cend(descriptorCheckList), code) !=
310         std::cend(descriptorCheckList)) {
311         auto token = data.ReadInterfaceToken();
312         if (token != RSIRenderServiceConnection::GetDescriptor()) {
313             if (code == static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_PIXEL_MAP_FROM_SURFACE)) {
314                 if (!reply.WriteInt32(0)) {
315                     return ERR_INVALID_REPLY;
316                 }
317             }
318             return ERR_INVALID_STATE;
319         }
320     }
321     auto accessible = securityManager_.IsInterfaceCodeAccessible(code);
322     if (!accessible && code != static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::TAKE_SURFACE_CAPTURE)) {
323         RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest no permission code:%{public}d", code);
324         return ERR_INVALID_STATE;
325     }
326     int ret = ERR_NONE;
327     switch (code) {
328         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::COMMIT_TRANSACTION): {
329             bool isTokenTypeValid = true;
330             bool isNonSystemAppCalling = false;
331             RSInterfaceCodeAccessVerifierBase::GetAccessType(isTokenTypeValid, isNonSystemAppCalling);
332             if (!isTokenTypeValid) {
333                 RS_LOGE("RSRenderServiceConnectionStub::COMMIT_TRANSACTION invalid token type");
334                 return ERR_INVALID_STATE;
335             }
336             RS_TRACE_NAME_FMT("Recv Parcel Size:%zu, fdCnt:%zu", data.GetDataSize(), data.GetOffsetsSize());
337             static bool isUniRender = RSUniRenderJudgement::IsUniRender();
338             std::shared_ptr<MessageParcel> parsedParcel;
339             if (data.ReadInt32() == 0) { // indicate normal parcel
340                 if (isUniRender) {
341                     // in uni render mode, if parcel size over threshold,
342                     // Unmarshalling task will be post to RSUnmarshalThread,
343                     // copy the origin parcel to maintain the parcel lifetime
344                     parsedParcel = CopyParcelIfNeed(data, callingPid);
345                 }
346                 if (parsedParcel == nullptr) {
347                     // no need to copy or copy failed, use original parcel
348                     // execute Unmarshalling immediately
349                     auto transactionData = RSBaseRenderUtil::ParseTransactionData(data);
350                     if (transactionData && isNonSystemAppCalling) {
351                         const auto& nodeMap = RSMainThread::Instance()->GetContext().GetNodeMap();
352                         pid_t conflictCommandPid = 0;
353                         std::string commandMapDesc = "";
354                         if (!transactionData->IsCallingPidValid(callingPid, nodeMap, conflictCommandPid,
355                                                                 commandMapDesc)) {
356                             RS_LOGE("RSRenderServiceConnectionStub::COMMIT_TRANSACTION non-system callingPid %{public}d"
357                                     " is denied to access commandPid %{public}d, commandMap = %{public}s",
358                                     callingPid, conflictCommandPid, commandMapDesc.c_str());
359                         }
360                     }
361                     CommitTransaction(transactionData);
362                     break;
363                 }
364             } else {
365                 // indicate ashmem parcel
366                 // should be parsed to normal parcel before Unmarshalling
367                 parsedParcel = RSAshmemHelper::ParseFromAshmemParcel(&data);
368             }
369             if (parsedParcel == nullptr) {
370                 RS_LOGE("RSRenderServiceConnectionStub::COMMIT_TRANSACTION failed: parsed parcel is nullptr");
371                 return ERR_INVALID_DATA;
372             }
373             if (isUniRender) {
374                 // post Unmarshalling task to RSUnmarshalThread
375                 RSUnmarshalThread::Instance().RecvParcel(parsedParcel, isNonSystemAppCalling, callingPid);
376             } else {
377                 // execute Unmarshalling immediately
378                 auto transactionData = RSBaseRenderUtil::ParseTransactionData(*parsedParcel);
379                 if (transactionData && isNonSystemAppCalling) {
380                     const auto& nodeMap = RSMainThread::Instance()->GetContext().GetNodeMap();
381                     pid_t conflictCommandPid = 0;
382                     std::string commandMapDesc = "";
383                     if (!transactionData->IsCallingPidValid(callingPid, nodeMap, conflictCommandPid, commandMapDesc)) {
384                         RS_LOGE("RSRenderServiceConnectionStub::COMMIT_TRANSACTION non-system callingPid %{public}d"
385                                 " is denied to access commandPid %{public}d, commandMap = %{public}s",
386                                 callingPid, conflictCommandPid, commandMapDesc.c_str());
387                     }
388                 }
389                 CommitTransaction(transactionData);
390             }
391             break;
392         }
393         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_UNI_RENDER_ENABLED): {
394             if (!reply.WriteBool(GetUniRenderEnabled())) {
395                 ret = ERR_INVALID_REPLY;
396             }
397             break;
398         }
399         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_NODE): {
400             auto nodeId = data.ReadUint64();
401             RS_PROFILER_PATCH_NODE_ID(data, nodeId);
402             auto surfaceName = data.ReadString();
403             auto bundleName = data.ReadString();
404             RSSurfaceRenderNodeConfig config = {.id = nodeId, .name = surfaceName, .bundleName = bundleName};
405             if (!reply.WriteBool(CreateNode(config))) {
406                 ret = ERR_INVALID_REPLY;
407             }
408             break;
409         }
410         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_NODE_AND_SURFACE): {
411             auto nodeId = data.ReadUint64();
412             if (ExtractPid(nodeId) != callingPid) {
413                 RS_LOGW("CREATE_NODE_AND_SURFACE invalid nodeId[%" PRIu64 "] pid[%d]", nodeId, callingPid);
414                 ret = ERR_INVALID_DATA;
415                 break;
416             }
417             RS_PROFILER_PATCH_NODE_ID(data, nodeId);
418             auto surfaceName = data.ReadString();
419             auto type = static_cast<RSSurfaceNodeType>(data.ReadUint8());
420             auto bundleName = data.ReadString();
421             bool isTextureExportNode = data.ReadBool();
422             bool isSync = data.ReadBool();
423             auto surfaceWindowType = static_cast<SurfaceWindowType>(data.ReadUint8());
424             if (!CheckCreateNodeAndSurface(callingPid, type, surfaceWindowType)) {
425                 ret = ERR_INVALID_DATA;
426                 break;
427             }
428             RSSurfaceRenderNodeConfig config = {
429                 .id = nodeId, .name = surfaceName, .bundleName = bundleName, .nodeType = type,
430                 .isTextureExportNode = isTextureExportNode, .isSync = isSync,
431                 .surfaceWindowType = surfaceWindowType};
432             sptr<Surface> surface = CreateNodeAndSurface(config);
433             if (surface == nullptr) {
434                 ret = ERR_NULL_OBJECT;
435                 break;
436             }
437             auto producer = surface->GetProducer();
438             if (!reply.WriteRemoteObject(producer->AsObject())) {
439                 ret = ERR_INVALID_REPLY;
440             }
441             break;
442         }
443         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_FOCUS_APP_INFO): {
444             int32_t pid = data.ReadInt32();
445             RS_PROFILER_PATCH_PID(data, pid);
446             int32_t uid = data.ReadInt32();
447             std::string bundleName = data.ReadString();
448             std::string abilityName = data.ReadString();
449             uint64_t focusNodeId = data.ReadUint64();
450             RS_PROFILER_PATCH_NODE_ID(data, focusNodeId);
451             int32_t status = SetFocusAppInfo(pid, uid, bundleName, abilityName, focusNodeId);
452             if (!reply.WriteInt32(status)) {
453                 ret = ERR_INVALID_REPLY;
454             }
455             break;
456         }
457         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_DEFAULT_SCREEN_ID): {
458             ScreenId id = GetDefaultScreenId();
459             if (!reply.WriteUint64(id)) {
460                 ret = ERR_INVALID_REPLY;
461             }
462             break;
463         }
464         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_SCREEN_ID): {
465             ScreenId id = GetActiveScreenId();
466             if (!reply.WriteUint64(id)) {
467                 ret = ERR_INVALID_REPLY;
468             }
469             break;
470         }
471         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_ALL_SCREEN_IDS): {
472             std::vector<ScreenId> ids = GetAllScreenIds();
473             if (!reply.WriteUint32(ids.size())) {
474                 ret = ERR_INVALID_REPLY;
475                 break;
476             }
477             for (uint32_t i = 0; i < ids.size(); i++) {
478                 if (!reply.WriteUint64(ids[i])) {
479                     ret = ERR_INVALID_REPLY;
480                     break;
481                 }
482             }
483             break;
484         }
485         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_VIRTUAL_SCREEN): {
486             // read the parcel data.
487             std::string name = data.ReadString();
488             uint32_t width = data.ReadUint32();
489             uint32_t height = data.ReadUint32();
490             sptr<Surface> surface = nullptr;
491             if (data.ReadBool()) {
492                 auto remoteObject = data.ReadRemoteObject();
493                 if (remoteObject != nullptr) {
494                     auto bufferProducer = iface_cast<IBufferProducer>(remoteObject);
495                     surface = Surface::CreateSurfaceAsProducer(bufferProducer);
496                 }
497             }
498             ScreenId mirrorId = data.ReadUint64();
499             int32_t flags = data.ReadInt32();
500             std::vector<NodeId> whiteList;
501             data.ReadUInt64Vector(&whiteList);
502             ScreenId id = CreateVirtualScreen(name, width, height, surface, mirrorId, flags, whiteList);
503             if (!reply.WriteUint64(id)) {
504                 ret = ERR_INVALID_REPLY;
505             }
506             break;
507         }
508         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_BLACKLIST): {
509             // read the parcel data.
510             ScreenId id = data.ReadUint64();
511             std::vector<NodeId> blackListVector;
512             data.ReadUInt64Vector(&blackListVector);
513             int32_t status = SetVirtualScreenBlackList(id, blackListVector);
514             if (!reply.WriteInt32(status)) {
515                 ret = ERR_INVALID_REPLY;
516             }
517             break;
518         }
519         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::ADD_VIRTUAL_SCREEN_BLACKLIST): {
520             // read the parcel data.
521             ScreenId id = data.ReadUint64();
522             std::vector<NodeId> blackListVector;
523             if (!data.ReadUInt64Vector(&blackListVector)) {
524                 ret = ERR_INVALID_REPLY;
525                 break;
526             }
527             int32_t status = AddVirtualScreenBlackList(id, blackListVector);
528             if (!reply.WriteInt32(status)) {
529                 ret = ERR_INVALID_REPLY;
530             }
531             break;
532         }
533         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN_BLACKLIST): {
534             // read the parcel data.
535             ScreenId id = data.ReadUint64();
536             std::vector<NodeId> blackListVector;
537             if (!data.ReadUInt64Vector(&blackListVector)) {
538                 ret = ERR_INVALID_REPLY;
539                 break;
540             }
541             int32_t status = RemoveVirtualScreenBlackList(id, blackListVector);
542             if (!reply.WriteInt32(status)) {
543                 ret = ERR_INVALID_REPLY;
544             }
545             break;
546         }
547         case static_cast<uint32_t>(
548             RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION_LIST): {
549             if (!securityManager_.IsInterfaceCodeAccessible(code)) {
550                 RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest no permission"
551                     "SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION_LIST");
552                 return ERR_INVALID_STATE;
553             }
554             // read the parcel data.
555             ScreenId id = data.ReadUint64();
556             std::vector<NodeId> securityExemptionList;
557             if (!data.ReadUInt64Vector(&securityExemptionList)) {
558                 ret = ERR_INVALID_REPLY;
559                 break;
560             }
561             int32_t status = SetVirtualScreenSecurityExemptionList(id, securityExemptionList);
562             if (!reply.WriteInt32(status)) {
563                 ret = ERR_INVALID_REPLY;
564             }
565             break;
566         }
567         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_CAST_SCREEN_ENABLE_SKIP_WINDOW): {
568             // read the parcel data.
569             ScreenId id = data.ReadUint64();
570             bool enable = data.ReadBool();
571             int32_t result = SetCastScreenEnableSkipWindow(id, enable);
572             if (!reply.WriteInt32(result)) {
573                 ret = ERR_INVALID_REPLY;
574             }
575             break;
576         }
577         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SURFACE): {
578             // read the parcel data.
579             ScreenId id = data.ReadUint64();
580             auto remoteObject = data.ReadRemoteObject();
581             if (remoteObject == nullptr) {
582                 ret = ERR_NULL_OBJECT;
583                 break;
584             }
585             auto bufferProducer = iface_cast<IBufferProducer>(remoteObject);
586             sptr<Surface> surface = Surface::CreateSurfaceAsProducer(bufferProducer);
587             if (surface == nullptr) {
588                 ret = ERR_NULL_OBJECT;
589                 break;
590             }
591             int32_t status = SetVirtualScreenSurface(id, surface);
592             if (!reply.WriteInt32(status)) {
593                 ret = ERR_INVALID_REPLY;
594             }
595             break;
596         }
597         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN): {
598             ScreenId id = data.ReadUint64();
599             RemoveVirtualScreen(id);
600             break;
601         }
602         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CHANGE_CALLBACK): {
603             auto remoteObject = data.ReadRemoteObject();
604             if (remoteObject == nullptr) {
605                 ret = ERR_NULL_OBJECT;
606                 break;
607             }
608             sptr<RSIScreenChangeCallback> cb = iface_cast<RSIScreenChangeCallback>(remoteObject);
609             if (cb == nullptr) {
610                 ret = ERR_NULL_OBJECT;
611                 break;
612             }
613             int32_t status = SetScreenChangeCallback(cb);
614             if (!reply.WriteInt32(status)) {
615                 ret = ERR_INVALID_REPLY;
616             }
617             break;
618         }
619         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_MODE): {
620             ScreenId id = data.ReadUint64();
621             uint32_t modeId = data.ReadUint32();
622             SetScreenActiveMode(id, modeId);
623             break;
624         }
625         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_REFRESH_RATE): {
626             ScreenId id = data.ReadUint64();
627             int32_t sceneId = data.ReadInt32();
628             int32_t rate = data.ReadInt32();
629             SetScreenRefreshRate(id, sceneId, rate);
630             break;
631         }
632         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_REFRESH_RATE_MODE): {
633             int32_t mode = data.ReadInt32();
634             SetRefreshRateMode(mode);
635             break;
636         }
637         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SYNC_FRAME_RATE_RANGE): {
638             FrameRateLinkerId id = data.ReadUint64();
639             if (ExtractPid(id) != callingPid) {
640                 RS_LOGW("The SyncFrameRateRange isn't legal, frameRateLinkerId: %{public}" PRIu64
641                     ", callingPid:%{public}d", id, callingPid);
642                 ret = ERR_INVALID_DATA;
643                 break;
644             }
645             uint32_t min = data.ReadUint32();
646             uint32_t max = data.ReadUint32();
647             uint32_t preferred = data.ReadUint32();
648             uint32_t type = data.ReadUint32();
649             int32_t animatorExpectedFrameRate = data.ReadInt32();
650             SyncFrameRateRange(id, {min, max, preferred, type}, animatorExpectedFrameRate);
651             break;
652         }
653         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_FRAME_RATE_LINKER): {
654             FrameRateLinkerId id = data.ReadUint64();
655             if (ExtractPid(id) != callingPid) {
656                 RS_LOGW("The UnregisterFrameRateLinker isn't legal, frameRateLinkerId: %{public}" PRIu64
657                     ", callingPid:%{public}d", id, callingPid);
658                 ret = ERR_INVALID_DATA;
659                 break;
660             }
661             UnregisterFrameRateLinker(id);
662             break;
663         }
664         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CURRENT_REFRESH_RATE): {
665             ScreenId id = data.ReadUint64();
666             uint32_t refreshRate = GetScreenCurrentRefreshRate(id);
667             if (!reply.WriteUint32(refreshRate)) {
668                 ret = ERR_INVALID_REPLY;
669             }
670             break;
671         }
672         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_CURRENT_REFRESH_RATE_MODE): {
673             int32_t refreshRateMode = GetCurrentRefreshRateMode();
674             if (!reply.WriteInt32(refreshRateMode)) {
675                 ret = ERR_INVALID_REPLY;
676             }
677             break;
678         }
679         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_REFRESH_RATES): {
680             ScreenId id = data.ReadUint64();
681             std::vector<int32_t> rates = GetScreenSupportedRefreshRates(id);
682             if (!reply.WriteUint64(static_cast<uint64_t>(rates.size()))) {
683                 ret = ERR_INVALID_REPLY;
684                 break;
685             }
686             for (auto ratesIter : rates) {
687                 if (!reply.WriteInt32(ratesIter)) {
688                     ret = ERR_INVALID_REPLY;
689                     break;
690                 }
691             }
692             break;
693         }
694         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SHOW_REFRESH_RATE_ENABLED): {
695             bool enable = GetShowRefreshRateEnabled();
696             if (!reply.WriteBool(enable)) {
697                 ret = ERR_INVALID_REPLY;
698             }
699             break;
700         }
701         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED): {
702             bool enable = data.ReadBool();
703             SetShowRefreshRateEnabled(enable);
704             break;
705         }
706         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO): {
707             auto token = data.ReadInterfaceToken();
708             if (token != RSIRenderServiceConnection::GetDescriptor()) {
709                 ret = ERR_INVALID_STATE;
710                 break;
711             }
712             pid_t pid = data.ReadInt32();
713             std::string refreshInfo = GetRefreshInfo(pid);
714             if (!reply.WriteString(refreshInfo)) {
715                 ret = ERR_INVALID_REPLY;
716             }
717             break;
718         }
719         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_RESOLUTION): {
720             ScreenId id = data.ReadUint64();
721             uint32_t width = data.ReadUint32();
722             uint32_t height = data.ReadUint32();
723             int32_t status = SetVirtualScreenResolution(id, width, height);
724             if (!reply.WriteInt32(status)) {
725                 ret = ERR_INVALID_REPLY;
726             }
727             break;
728         }
729         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::MARK_POWER_OFF_NEED_PROCESS_ONE_FRAME): {
730             MarkPowerOffNeedProcessOneFrame();
731             break;
732         }
733         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::DISABLE_RENDER_CONTROL_SCREEN): {
734             ScreenId id = data.ReadUint64();
735             DisablePowerOffRenderControl(id);
736             break;
737         }
738         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_POWER_STATUS): {
739             ScreenId id = data.ReadUint64();
740             uint32_t status = data.ReadUint32();
741             SetScreenPowerStatus(id, static_cast<ScreenPowerStatus>(status));
742             break;
743         }
744         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::TAKE_SURFACE_CAPTURE): {
745             NodeId id = data.ReadUint64();
746             RS_PROFILER_PATCH_NODE_ID(data, id);
747             auto remoteObject = data.ReadRemoteObject();
748             if (remoteObject == nullptr) {
749                 ret = ERR_NULL_OBJECT;
750                 break;
751             }
752             sptr<RSISurfaceCaptureCallback> cb = iface_cast<RSISurfaceCaptureCallback>(remoteObject);
753             if (cb == nullptr) {
754                 ret = ERR_NULL_OBJECT;
755                 break;
756             }
757             RSSurfaceCaptureConfig captureConfig;
758             captureConfig.scaleX = data.ReadFloat();
759             captureConfig.scaleY = data.ReadFloat();
760             captureConfig.useDma = data.ReadBool();
761             captureConfig.useCurWindow = data.ReadBool();
762             captureConfig.captureType = static_cast<SurfaceCaptureType>(data.ReadUint8());
763             captureConfig.isSync = data.ReadBool();
764             RSSurfaceCapturePermissions permissions;
765             permissions.screenCapturePermission = accessible;
766             permissions.isSystemCalling = RSInterfaceCodeAccessVerifierBase::IsSystemCalling(
767                 RSIRenderServiceConnectionInterfaceCodeAccessVerifier::codeEnumTypeName_ + "::TAKE_SURFACE_CAPTURE");
768             // Since GetCallingPid interface always returns 0 in asynchronous binder in Linux kernel system,
769             // we temporarily add a white list to avoid abnormal functionality or abnormal display.
770             // The white list will be removed after GetCallingPid interface can return real PID.
771             permissions.selfCapture = (ExtractPid(id) == callingPid || callingPid == 0);
772             TakeSurfaceCapture(id, cb, captureConfig, permissions);
773             break;
774         }
775         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_APPLICATION_AGENT): {
776             auto pid = data.ReadInt32();
777             RS_PROFILER_PATCH_PID(data, pid);
778             auto remoteObject = data.ReadRemoteObject();
779             if (remoteObject == nullptr) {
780                 ret = ERR_NULL_OBJECT;
781                 break;
782             }
783             sptr<IApplicationAgent> app = iface_cast<IApplicationAgent>(remoteObject);
784             if (app == nullptr) {
785                 ret = ERR_NULL_OBJECT;
786                 break;
787             }
788             RegisterApplicationAgent(pid, app);
789             break;
790         }
791         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_VIRTUAL_SCREEN_RESOLUTION): {
792             ScreenId id = data.ReadUint64();
793             RSVirtualScreenResolution virtualScreenResolution = GetVirtualScreenResolution(id);
794             if (!reply.WriteParcelable(&virtualScreenResolution)) {
795                 ret = ERR_INVALID_REPLY;
796             }
797             break;
798         }
799         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_ACTIVE_MODE): {
800             ScreenId id = data.ReadUint64();
801             RSScreenModeInfo screenModeInfo = GetScreenActiveMode(id);
802             if (!reply.WriteParcelable(&screenModeInfo)) {
803                 ret = ERR_INVALID_REPLY;
804             }
805             break;
806         }
807         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_MODES): {
808             ScreenId id = data.ReadUint64();
809             std::vector<RSScreenModeInfo> screenSupportedModes = GetScreenSupportedModes(id);
810             if (!reply.WriteUint64(static_cast<uint64_t>(screenSupportedModes.size()))) {
811                 ret = ERR_INVALID_REPLY;
812                 break;
813             }
814             for (uint32_t modeIndex = 0; modeIndex < screenSupportedModes.size(); modeIndex++) {
815                 if (!reply.WriteParcelable(&screenSupportedModes[modeIndex])) {
816                     ret = ERR_INVALID_REPLY;
817                     break;
818                 }
819             }
820             break;
821         }
822         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHIC): {
823             auto pid = data.ReadInt32();
824             RS_PROFILER_PATCH_PID(data, pid);
825             MemoryGraphic memoryGraphic = GetMemoryGraphic(pid);
826             if (!reply.WriteParcelable(&memoryGraphic)) {
827                 ret = ERR_INVALID_REPLY;
828             }
829             break;
830         }
831         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHICS): {
832             std::vector<MemoryGraphic> memoryGraphics = GetMemoryGraphics();
833             if (!reply.WriteUint64(static_cast<uint64_t>(memoryGraphics.size()))) {
834                 ret = ERR_INVALID_REPLY;
835                 break;
836             }
837             for (uint32_t index = 0; index < memoryGraphics.size(); index++) {
838                 if (!reply.WriteParcelable(&memoryGraphics[index])) {
839                     ret = ERR_INVALID_REPLY;
840                     break;
841                 }
842             }
843             break;
844         }
845         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_TOTAL_APP_MEM_SIZE): {
846             float cpuMemSize = 0.f;
847             float gpuMemSize = 0.f;
848             GetTotalAppMemSize(cpuMemSize, gpuMemSize);
849             if (!reply.WriteFloat(cpuMemSize) || !reply.WriteFloat(gpuMemSize)) {
850                 ret = ERR_INVALID_REPLY;
851             }
852             break;
853         }
854         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CAPABILITY): {
855             ScreenId id = data.ReadUint64();
856             RSScreenCapability screenCapability = GetScreenCapability(id);
857             if (!reply.WriteParcelable(&screenCapability)) {
858                 ret = ERR_INVALID_REPLY;
859             }
860             break;
861         }
862         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_POWER_STATUS): {
863             ScreenId id = data.ReadUint64();
864             ScreenPowerStatus status = GetScreenPowerStatus(id);
865             if (!reply.WriteUint32(static_cast<uint32_t>(status))) {
866                 ret = ERR_INVALID_REPLY;
867             }
868             break;
869         }
870         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_DATA): {
871             ScreenId id = data.ReadUint64();
872             RSScreenData screenData = GetScreenData(id);
873             if (!reply.WriteParcelable(&screenData)) {
874                 ret = ERR_INVALID_REPLY;
875             }
876             break;
877         }
878         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_BACK_LIGHT): {
879             ScreenId id = data.ReadUint64();
880             int32_t level = GetScreenBacklight(id);
881             if (!reply.WriteInt32(level)) {
882                 ret = ERR_INVALID_REPLY;
883             }
884             break;
885         }
886         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_BACK_LIGHT): {
887             ScreenId id = data.ReadUint64();
888             uint32_t level = data.ReadUint32();
889             SetScreenBacklight(id, level);
890             break;
891         }
892         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_AVAILABLE_LISTENER): {
893             NodeId id = data.ReadUint64();
894             RS_PROFILER_PATCH_NODE_ID(data, id);
895             auto remoteObject = data.ReadRemoteObject();
896             bool isFromRenderThread = data.ReadBool();
897             if (remoteObject == nullptr) {
898                 ret = ERR_NULL_OBJECT;
899                 break;
900             }
901             sptr<RSIBufferAvailableCallback> cb = iface_cast<RSIBufferAvailableCallback>(remoteObject);
902             if (cb == nullptr) {
903                 ret = ERR_NULL_OBJECT;
904                 break;
905             }
906             RegisterBufferAvailableListener(id, cb, isFromRenderThread);
907             break;
908         }
909         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_CLEAR_LISTENER): {
910             NodeId id = data.ReadUint64();
911             RS_PROFILER_PATCH_NODE_ID(data, id);
912             auto remoteObject = data.ReadRemoteObject();
913             if (remoteObject == nullptr) {
914                 ret = ERR_NULL_OBJECT;
915                 break;
916             }
917             sptr<RSIBufferClearCallback> cb = iface_cast<RSIBufferClearCallback>(remoteObject);
918             if (cb == nullptr) {
919                 ret = ERR_NULL_OBJECT;
920                 break;
921             }
922             RegisterBufferClearListener(id, cb);
923             break;
924         }
925         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_GAMUTS): {
926             ScreenId id = data.ReadUint64();
927             std::vector<uint32_t> modeSend;
928             std::vector<ScreenColorGamut> mode;
929             int32_t result = GetScreenSupportedColorGamuts(id, mode);
930             if (!reply.WriteInt32(result)) {
931                 ret = ERR_INVALID_REPLY;
932                 break;
933             }
934             if (result != StatusCode::SUCCESS) {
935                 ret = ERR_UNKNOWN_REASON;
936                 break;
937             }
938             std::copy(mode.begin(), mode.end(), std::back_inserter(modeSend));
939             if (!reply.WriteUInt32Vector(modeSend)) {
940                 ret = ERR_INVALID_REPLY;
941             }
942             break;
943         }
944         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_METADATAKEYS): {
945             ScreenId id = data.ReadUint64();
946             std::vector<uint32_t> keySend;
947             std::vector<ScreenHDRMetadataKey> keys;
948             int32_t result = GetScreenSupportedMetaDataKeys(id, keys);
949             if (!reply.WriteInt32(result)) {
950                 ret = ERR_INVALID_REPLY;
951                 break;
952             }
953             if (result != StatusCode::SUCCESS) {
954                 ret = ERR_UNKNOWN_REASON;
955                 break;
956             }
957             for (auto i : keys) {
958                 keySend.push_back(i);
959             }
960             if (!reply.WriteUInt32Vector(keySend)) {
961                 ret = ERR_INVALID_REPLY;
962             }
963             break;
964         }
965         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT): {
966             ScreenId id = data.ReadUint64();
967             ScreenColorGamut mode;
968             int32_t result = GetScreenColorGamut(id, mode);
969             if (!reply.WriteInt32(result)) {
970                 ret = ERR_INVALID_REPLY;
971                 break;
972             }
973             if (result != StatusCode::SUCCESS) {
974                 ret = ERR_UNKNOWN_REASON;
975                 break;
976             }
977             if (!reply.WriteUint32(mode)) {
978                 ret = ERR_INVALID_REPLY;
979             }
980             break;
981         }
982         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT): {
983             ScreenId id = data.ReadUint64();
984             int32_t modeIdx = data.ReadInt32();
985             int32_t result = SetScreenColorGamut(id, modeIdx);
986             if (!reply.WriteInt32(result)) {
987                 ret = ERR_INVALID_REPLY;
988             }
989             break;
990         }
991         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT_MAP): {
992             ScreenId id = data.ReadUint64();
993             ScreenGamutMap mode = static_cast<ScreenGamutMap>(data.ReadInt32());
994             int32_t result = SetScreenGamutMap(id, mode);
995             if (!reply.WriteInt32(result)) {
996                 ret = ERR_INVALID_REPLY;
997             }
998             break;
999         }
1000         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CORRECTION): {
1001             ScreenId id = data.ReadUint64();
1002             ScreenRotation screenRotation = static_cast<ScreenRotation>(data.ReadInt32());
1003             int32_t result = SetScreenCorrection(id, screenRotation);
1004             if (!reply.WriteInt32(result)) {
1005                 ret = ERR_INVALID_REPLY;
1006             }
1007             break;
1008         }
1009         case static_cast<uint32_t>(
1010             RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_MIRROR_SCREEN_CANVAS_ROTATION): {
1011             ScreenId id = data.ReadUint64();
1012             bool canvasRotation = data.ReadBool();
1013             bool result = SetVirtualMirrorScreenCanvasRotation(id, canvasRotation);
1014             if (!reply.WriteBool(result)) {
1015                 ret = ERR_INVALID_REPLY;
1016             }
1017             break;
1018         }
1019         case static_cast<uint32_t>(
1020             RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_MIRROR_SCREEN_SCALE_MODE): {
1021             ScreenId id = data.ReadUint64();
1022             ScreenScaleMode scaleMode = static_cast<ScreenScaleMode>(data.ReadUint32());
1023             bool result = SetVirtualMirrorScreenScaleMode(id, scaleMode);
1024             if (!reply.WriteBool(result)) {
1025                 ret = ERR_INVALID_REPLY;
1026             }
1027             break;
1028         }
1029         case static_cast<uint32_t>(
1030             RSIRenderServiceConnectionInterfaceCode::SET_GLOBAL_DARK_COLOR_MODE): {
1031             bool isDark = data.ReadBool();
1032             bool result = SetGlobalDarkColorMode(isDark);
1033             if (!reply.WriteBool(result)) {
1034                 ret = ERR_INVALID_REPLY;
1035             }
1036             break;
1037         }
1038         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT_MAP): {
1039             ScreenId id = data.ReadUint64();
1040             ScreenGamutMap mode;
1041             int32_t result = GetScreenGamutMap(id, mode);
1042             if (!reply.WriteInt32(result)) {
1043                 ret = ERR_INVALID_REPLY;
1044                 break;
1045             }
1046             if (result != StatusCode::SUCCESS) {
1047                 ret = ERR_UNKNOWN_REASON;
1048                 break;
1049             }
1050             if (!reply.WriteUint32(mode)) {
1051                 ret = ERR_INVALID_REPLY;
1052             }
1053             break;
1054         }
1055         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_VSYNC_CONNECTION): {
1056             std::string name = data.ReadString();
1057             auto remoteObj = data.ReadRemoteObject();
1058             uint64_t id = data.ReadUint64();
1059             NodeId windowNodeID = data.ReadUint64();
1060             if (remoteObj == nullptr) {
1061                 ret = ERR_NULL_OBJECT;
1062                 break;
1063             }
1064             if (!remoteObj->IsProxyObject()) {
1065                 ret = ERR_UNKNOWN_OBJECT;
1066                 break;
1067             }
1068             auto token = iface_cast<VSyncIConnectionToken>(remoteObj);
1069             if (token == nullptr) {
1070                 ret = ERR_UNKNOWN_OBJECT;
1071                 break;
1072             }
1073             sptr<IVSyncConnection> conn = CreateVSyncConnection(name, token, id, windowNodeID);
1074             if (conn == nullptr) {
1075                 ret = ERR_NULL_OBJECT;
1076                 break;
1077             }
1078 #ifdef ENABLE_IPC_SECURITY_ACCESS_COUNTER
1079             securityUtils_.IncreaseAccessCounter(code);
1080 #endif
1081             if (!reply.WriteRemoteObject(conn->AsObject())) {
1082                 ret = ERR_INVALID_REPLY;
1083             }
1084             break;
1085         }
1086         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_PIXEL_MAP_FROM_SURFACE): {
1087             auto remoteObject = data.ReadRemoteObject();
1088             if (remoteObject == nullptr) {
1089                 if (!reply.WriteInt32(0)) {
1090                     ret = ERR_INVALID_REPLY;
1091                     break;
1092                 }
1093                 ret = ERR_NULL_OBJECT;
1094                 break;
1095             }
1096             auto bufferProducer = iface_cast<IBufferProducer>(remoteObject);
1097             sptr<Surface> surface = Surface::CreateSurfaceAsProducer(bufferProducer);
1098             if (surface == nullptr) {
1099                 if (!reply.WriteInt32(0)) {
1100                     ret = ERR_INVALID_REPLY;
1101                     break;
1102                 }
1103                 ret = ERR_NULL_OBJECT;
1104                 break;
1105             }
1106             auto x = data.ReadInt32();
1107             auto y = data.ReadInt32();
1108             auto w = data.ReadInt32();
1109             auto h = data.ReadInt32();
1110             auto srcRect = Rect {
1111                 .x = x,
1112                 .y = y,
1113                 .w = w,
1114                 .h = h
1115             };
1116             std::shared_ptr<Media::PixelMap> pixelMap = CreatePixelMapFromSurface(surface, srcRect);
1117             if (pixelMap) {
1118                 if (!reply.WriteBool(true)) {
1119                     ret = ERR_INVALID_REPLY;
1120                     break;
1121                 }
1122                 if (!pixelMap->Marshalling(reply)) {
1123                     RS_LOGE("pixelMap Marshalling fail");
1124                     ret = ERR_INVALID_REPLY;
1125                 }
1126             } else {
1127                 if (!reply.WriteBool(false)) {
1128                     ret = ERR_INVALID_REPLY;
1129                     break;
1130                 }
1131             }
1132             break;
1133         }
1134         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_CAPABILITY): {
1135             ScreenId id = data.ReadUint64();
1136             RSScreenHDRCapability screenHDRCapability;
1137             int32_t result = GetScreenHDRCapability(id, screenHDRCapability);
1138             if (!reply.WriteInt32(result)) {
1139                 ret = ERR_INVALID_REPLY;
1140                 break;
1141             }
1142             if (result != StatusCode::SUCCESS) {
1143                 ret = ERR_UNKNOWN_REASON;
1144                 break;
1145             }
1146             if (!reply.WriteParcelable(&screenHDRCapability)) {
1147                 ret = ERR_INVALID_REPLY;
1148             }
1149             break;
1150         }
1151         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_PIXEL_FORMAT): {
1152             ScreenId id = data.ReadUint64();
1153             GraphicPixelFormat pixelFormat;
1154             int32_t result = GetPixelFormat(id, pixelFormat);
1155             if (!reply.WriteInt32(result)) {
1156                 ret = ERR_INVALID_REPLY;
1157                 break;
1158             }
1159             if (result != StatusCode::SUCCESS) {
1160                 break;
1161             }
1162             if (!reply.WriteUint32(static_cast<uint32_t>(pixelFormat))) {
1163                 ret = ERR_INVALID_REPLY;
1164             }
1165             break;
1166         }
1167         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_PIXEL_FORMAT): {
1168             ScreenId id = data.ReadUint64();
1169             GraphicPixelFormat pixelFormat = static_cast<GraphicPixelFormat>(data.ReadInt32());
1170             int32_t result = SetPixelFormat(id, pixelFormat);
1171             if (!reply.WriteInt32(result)) {
1172                 ret = ERR_INVALID_REPLY;
1173             }
1174             break;
1175         }
1176         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_HDR_FORMATS): {
1177             ScreenId id = data.ReadUint64();
1178             std::vector<uint32_t> hdrFormatsSend;
1179             std::vector<ScreenHDRFormat> hdrFormats;
1180             int32_t result = GetScreenSupportedHDRFormats(id, hdrFormats);
1181             if (!reply.WriteInt32(result)) {
1182                 ret = ERR_INVALID_REPLY;
1183                 break;
1184             }
1185             if (result != StatusCode::SUCCESS) {
1186                 break;
1187             }
1188             std::copy(hdrFormats.begin(), hdrFormats.end(), std::back_inserter(hdrFormatsSend));
1189             if (!reply.WriteUInt32Vector(hdrFormatsSend)) {
1190                 ret = ERR_INVALID_REPLY;
1191             }
1192             break;
1193         }
1194         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_FORMAT): {
1195             ScreenId id = data.ReadUint64();
1196             ScreenHDRFormat hdrFormat;
1197             int32_t result = GetScreenHDRFormat(id, hdrFormat);
1198             if (!reply.WriteInt32(result)) {
1199                 ret = ERR_INVALID_REPLY;
1200                 break;
1201             }
1202             if (result != StatusCode::SUCCESS) {
1203                 break;
1204             }
1205             if (!reply.WriteUint32(hdrFormat)) {
1206                 ret = ERR_INVALID_REPLY;
1207             }
1208             break;
1209         }
1210         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_HDR_FORMAT): {
1211             ScreenId id = data.ReadUint64();
1212             int32_t modeIdx = data.ReadInt32();
1213             int32_t result = SetScreenHDRFormat(id, modeIdx);
1214             if (!reply.WriteInt32(result)) {
1215                 ret = ERR_INVALID_REPLY;
1216             }
1217             break;
1218         }
1219         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_COLORSPACES): {
1220             ScreenId id = data.ReadUint64();
1221             std::vector<uint32_t> colorSpacesSend;
1222             std::vector<GraphicCM_ColorSpaceType> colorSpaces;
1223             int32_t result = GetScreenSupportedColorSpaces(id, colorSpaces);
1224             if (!reply.WriteInt32(result)) {
1225                 ret = ERR_INVALID_REPLY;
1226                 break;
1227             }
1228             if (result != StatusCode::SUCCESS) {
1229                 break;
1230             }
1231             std::copy(colorSpaces.begin(), colorSpaces.end(), std::back_inserter(colorSpacesSend));
1232             if (!reply.WriteUInt32Vector(colorSpacesSend)) {
1233                 ret = ERR_INVALID_REPLY;
1234             }
1235             break;
1236         }
1237         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_COLORSPACE): {
1238             ScreenId id = data.ReadUint64();
1239             GraphicCM_ColorSpaceType colorSpace;
1240             int32_t result = GetScreenColorSpace(id, colorSpace);
1241             if (!reply.WriteInt32(result)) {
1242                 ret = ERR_INVALID_REPLY;
1243                 break;
1244             }
1245             if (result != StatusCode::SUCCESS) {
1246                 break;
1247             }
1248             if (!reply.WriteUint32(colorSpace)) {
1249                 ret = ERR_INVALID_REPLY;
1250             }
1251             break;
1252         }
1253         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_COLORSPACE): {
1254             ScreenId id = data.ReadUint64();
1255             GraphicCM_ColorSpaceType colorSpace = static_cast<GraphicCM_ColorSpaceType>(data.ReadInt32());
1256             int32_t result = SetScreenColorSpace(id, colorSpace);
1257             if (!reply.WriteInt32(result)) {
1258                 ret = ERR_INVALID_REPLY;
1259             }
1260             break;
1261         }
1262         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_TYPE): {
1263             ScreenId id = data.ReadUint64();
1264             RSScreenType type;
1265             int32_t result = GetScreenType(id, type);
1266             if (!reply.WriteInt32(result)) {
1267                 ret = ERR_INVALID_REPLY;
1268                 break;
1269             }
1270             if (result != StatusCode::SUCCESS) {
1271                 ret = ERR_UNKNOWN_REASON;
1272                 break;
1273             }
1274             if (!reply.WriteUint32(type)) {
1275                 ret = ERR_INVALID_REPLY;
1276             }
1277             break;
1278         }
1279         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_BITMAP): {
1280             NodeId id = data.ReadUint64();
1281             if (ExtractPid(id) != callingPid) {
1282                 RS_LOGW("The GetBitmap isn't legal, nodeId:%{public}" PRIu64 ", callingPid:%{public}d",
1283                     id, callingPid);
1284                 break;
1285             }
1286             RS_PROFILER_PATCH_NODE_ID(data, id);
1287             Drawing::Bitmap bm;
1288             bool result = GetBitmap(id, bm);
1289             if (!reply.WriteBool(result)) {
1290                 ret = ERR_INVALID_REPLY;
1291                 break;
1292             }
1293             if (result) {
1294                 RSMarshallingHelper::Marshalling(reply, bm);
1295             }
1296             break;
1297         }
1298         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_PIXELMAP): {
1299             NodeId id = data.ReadUint64();
1300             if (ExtractPid(id) != callingPid) {
1301                 RS_LOGW("The GetPixelmap isn't legal, nodeId:%{public}" PRIu64 ", callingPid:%{public}d",
1302                     id, callingPid);
1303                 break;
1304             }
1305             RS_PROFILER_PATCH_NODE_ID(data, id);
1306             std::shared_ptr<Media::PixelMap> pixelmap =
1307                 std::shared_ptr<Media::PixelMap>(data.ReadParcelable<Media::PixelMap>());
1308             Drawing::Rect rect;
1309             RSMarshallingHelper::Unmarshalling(data, rect);
1310             std::shared_ptr<Drawing::DrawCmdList> drawCmdList;
1311             RSMarshallingHelper::Unmarshalling(data, drawCmdList);
1312             bool result = GetPixelmap(id, pixelmap, &rect, drawCmdList);
1313             if (!reply.WriteBool(result)) {
1314                 ret = ERR_INVALID_REPLY;
1315                 break;
1316             }
1317             if (result) {
1318                 RSMarshallingHelper::Marshalling(reply, pixelmap);
1319             }
1320             break;
1321         }
1322         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NEED_REGISTER_TYPEFACE): {
1323             uint64_t uniqueId = data.ReadUint64();
1324             uint32_t hash = data.ReadUint32();
1325             bool ret = !RSTypefaceCache::Instance().HasTypeface(uniqueId, hash);
1326             reply.WriteBool(ret);
1327             break;
1328         }
1329         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_TYPEFACE): {
1330             // timer: 3s
1331             OHOS::Rosen::RSXCollie registerTypefaceXCollie("registerTypefaceXCollie_" + std::to_string(callingPid), 3);
1332             bool result = false;
1333             uint64_t uniqueId = data.ReadUint64();
1334             uint32_t hash = data.ReadUint32();
1335             // safe check
1336             if (ExtractPid(uniqueId) == callingPid) {
1337                 std::shared_ptr<Drawing::Typeface> typeface;
1338                 result = RSMarshallingHelper::Unmarshalling(data, typeface);
1339                 if (result && typeface) {
1340                     typeface->SetHash(hash);
1341                     RegisterTypeface(uniqueId, typeface);
1342                 }
1343             } else {
1344                 RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest callingPid[%{public}d] "
1345                     "no permission REGISTER_TYPEFACE", callingPid);
1346             }
1347             if (!reply.WriteBool(result)) {
1348                 ret = ERR_INVALID_REPLY;
1349             }
1350             break;
1351         }
1352         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_TYPEFACE): {
1353             uint64_t uniqueId = data.ReadUint64();
1354             // safe check
1355             if (ExtractPid(uniqueId) == callingPid) {
1356                 UnRegisterTypeface(uniqueId);
1357             } else {
1358                 RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest callingPid[%{public}d] "
1359                     "no permission UNREGISTER_TYPEFACE", callingPid);
1360             }
1361             break;
1362         }
1363         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_SKIP_FRAME_INTERVAL): {
1364             if (!securityManager_.IsInterfaceCodeAccessible(code)) {
1365                 RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest no permission to access"\
1366                     "SET_SCREEN_SKIP_FRAME_INTERVAL");
1367                 return ERR_INVALID_STATE;
1368             }
1369             ScreenId id = data.ReadUint64();
1370             uint32_t skipFrameInterval = data.ReadUint32();
1371             int32_t result = SetScreenSkipFrameInterval(id, skipFrameInterval);
1372             if (!reply.WriteInt32(result)) {
1373                 ret = ERR_INVALID_REPLY;
1374             }
1375             break;
1376         }
1377         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_OCCLUSION_CHANGE_CALLBACK): {
1378             auto remoteObject = data.ReadRemoteObject();
1379             if (remoteObject == nullptr) {
1380                 ret = ERR_NULL_OBJECT;
1381                 break;
1382             }
1383             sptr<RSIOcclusionChangeCallback> callback = iface_cast<RSIOcclusionChangeCallback>(remoteObject);
1384             if (callback == nullptr) {
1385                 ret = ERR_NULL_OBJECT;
1386                 break;
1387             }
1388             int32_t status = RegisterOcclusionChangeCallback(callback);
1389             if (!reply.WriteInt32(status)) {
1390                 ret = ERR_INVALID_REPLY;
1391             }
1392             break;
1393         }
1394         case static_cast<uint32_t>(
1395             RSIRenderServiceConnectionInterfaceCode::REGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK): {
1396             NodeId id = data.ReadUint64();
1397             RS_PROFILER_PATCH_NODE_ID(data, id);
1398             if (ExtractPid(id) != callingPid) {
1399                 RS_LOGW("The RegisterSurfaceOcclusionChangeCallback isn't legal, nodeId:%{public}" PRIu64 ", "
1400                     "callingPid:%{public}d", id, callingPid);
1401                 ret = ERR_INVALID_DATA;
1402                 break;
1403             }
1404             auto remoteObject = data.ReadRemoteObject();
1405             if (remoteObject == nullptr) {
1406                 ret = ERR_NULL_OBJECT;
1407                 break;
1408             }
1409             sptr<RSISurfaceOcclusionChangeCallback> callback =
1410                 iface_cast<RSISurfaceOcclusionChangeCallback>(remoteObject);
1411             if (callback == nullptr) {
1412                 ret = ERR_NULL_OBJECT;
1413                 break;
1414             }
1415             std::vector<float> partitionPoints;
1416             if (!data.ReadFloatVector(&partitionPoints)) {
1417                 ret = ERR_TRANSACTION_FAILED;
1418                 break;
1419             }
1420             int32_t status = RegisterSurfaceOcclusionChangeCallback(id, callback, partitionPoints);
1421             if (!reply.WriteInt32(status)) {
1422                 ret = ERR_INVALID_REPLY;
1423             }
1424             break;
1425         }
1426         case static_cast<uint32_t>(
1427             RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK): {
1428             NodeId id = data.ReadUint64();
1429             RS_PROFILER_PATCH_NODE_ID(data, id);
1430             if (ExtractPid(id) != callingPid) {
1431                 RS_LOGW("The UnRegisterSurfaceOcclusionChangeCallback isn't legal, nodeId:%{public}" PRIu64 ", "
1432                     "callingPid:%{public}d", id, callingPid);
1433                 ret = ERR_INVALID_DATA;
1434                 break;
1435             }
1436             int32_t status = UnRegisterSurfaceOcclusionChangeCallback(id);
1437             if (!reply.WriteInt32(status)) {
1438                 ret = ERR_INVALID_REPLY;
1439             }
1440             break;
1441         }
1442         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_APP_WINDOW_NUM): {
1443             uint32_t num = data.ReadUint32();
1444             SetAppWindowNum(num);
1445             break;
1446         }
1447         case static_cast<uint32_t>(
1448             RSIRenderServiceConnectionInterfaceCode::SET_SYSTEM_ANIMATED_SCENES): {
1449             uint32_t systemAnimatedScenes = data.ReadUint32();
1450             bool result = SetSystemAnimatedScenes(static_cast<SystemAnimatedScenes>(systemAnimatedScenes));
1451             if (!reply.WriteBool(result)) {
1452                 ret = ERR_INVALID_REPLY;
1453             }
1454             break;
1455         }
1456         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SHOW_WATERMARK): {
1457             std::shared_ptr<Media::PixelMap> watermarkImg =
1458                 std::shared_ptr<Media::PixelMap>(data.ReadParcelable<Media::PixelMap>());
1459             bool isShow = data.ReadBool();
1460             ShowWatermark(watermarkImg, isShow);
1461             break;
1462         }
1463         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::RESIZE_VIRTUAL_SCREEN): {
1464             ScreenId id = data.ReadUint64();
1465             uint32_t width = data.ReadUint32();
1466             uint32_t height = data.ReadUint32();
1467             int32_t status = ResizeVirtualScreen(id, width, height);
1468             if (!reply.WriteInt32(status)) {
1469                 ret = ERR_INVALID_REPLY;
1470             }
1471             break;
1472         }
1473         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_JANK_STATS): {
1474             ReportJankStats();
1475             break;
1476         }
1477         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_RESPONSE): {
1478             DataBaseRs info;
1479             ReadDataBaseRs(info, data);
1480             ReportEventResponse(info);
1481             break;
1482         }
1483         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_COMPLETE): {
1484             DataBaseRs info;
1485             ReadDataBaseRs(info, data);
1486             ReportEventComplete(info);
1487             break;
1488         }
1489         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_JANK_FRAME): {
1490             DataBaseRs info;
1491             ReadDataBaseRs(info, data);
1492             ReportEventJankFrame(info);
1493             break;
1494         }
1495         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_GAMESTATE): {
1496             GameStateData info;
1497             ReadGameStateDataRs(info, data);
1498             ReportGameStateData(info);
1499             break;
1500         }
1501         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::EXECUTE_SYNCHRONOUS_TASK): {
1502             auto type = data.ReadInt16();
1503             auto subType = data.ReadInt16();
1504             if (type != RS_NODE_SYNCHRONOUS_READ_PROPERTY && type != RS_NODE_SYNCHRONOUS_GET_VALUE_FRACTION) {
1505                 ret = ERR_INVALID_STATE;
1506                 break;
1507             }
1508             auto func = RSCommandFactory::Instance().GetUnmarshallingFunc(type, subType);
1509             if (func == nullptr) {
1510                 ret = ERR_INVALID_STATE;
1511                 break;
1512             }
1513             auto command = static_cast<RSSyncTask*>((*func)(data));
1514             if (command == nullptr) {
1515                 ret = ERR_INVALID_STATE;
1516                 break;
1517             }
1518             std::shared_ptr<RSSyncTask> task(command);
1519             ExecuteSynchronousTask(task);
1520             if (!task->Marshalling(reply)) {
1521                 ret = ERR_INVALID_STATE;
1522             }
1523             break;
1524         }
1525         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_HARDWARE_ENABLED) : {
1526             auto id = data.ReadUint64();
1527             if (ExtractPid(id) != callingPid) {
1528                 RS_LOGW("The SetHardwareEnabled isn't legal, nodeId:%{public}" PRIu64 ", callingPid:%{public}d",
1529                     id, callingPid);
1530                 break;
1531             }
1532             auto isEnabled = data.ReadBool();
1533             auto selfDrawingType = static_cast<SelfDrawingNodeType>(data.ReadUint8());
1534             auto dynamicHardwareEnable = data.ReadBool();
1535             SetHardwareEnabled(id, isEnabled, selfDrawingType, dynamicHardwareEnable);
1536             break;
1537         }
1538         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_HIDE_PRIVACY_CONTENT) : {
1539             auto id = data.ReadUint64();
1540             auto isSystemCalling = RSInterfaceCodeAccessVerifierBase::IsSystemCalling(
1541                 RSIRenderServiceConnectionInterfaceCodeAccessVerifier::codeEnumTypeName_ +
1542                 "::SET_HIDE_PRIVACY_CONTENT");
1543             if (!isSystemCalling) {
1544                 if (!reply.WriteUint32(static_cast<uint32_t>(RSInterfaceErrorCode::NONSYSTEM_CALLING))) {
1545                     ret = ERR_INVALID_REPLY;
1546                 }
1547                 break;
1548             }
1549             if (ExtractPid(id) != callingPid) {
1550                 RS_LOGW("The SetHidePrivacyContent isn't legal, nodeId:%{public}" PRIu64 ", callingPid:%{public}d",
1551                     id, callingPid);
1552                 if (!reply.WriteUint32(static_cast<uint32_t>(RSInterfaceErrorCode::NOT_SELF_CALLING))) {
1553                     ret = ERR_INVALID_REPLY;
1554                 }
1555                 break;
1556             }
1557             auto needHidePrivacyContent = data.ReadBool();
1558             if (!reply.WriteUint32(SetHidePrivacyContent(id, needHidePrivacyContent))) {
1559                 ret = ERR_INVALID_REPLY;
1560             }
1561             break;
1562         }
1563         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_LIGHT_FACTOR_STATUS) : {
1564             auto isSafe = data.ReadBool();
1565             NotifyLightFactorStatus(isSafe);
1566             break;
1567         }
1568         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PACKAGE_EVENT) : {
1569             auto listSize = data.ReadUint32();
1570             const uint32_t MAX_LIST_SIZE = 50;
1571             if (listSize > MAX_LIST_SIZE) {
1572                 ret = ERR_INVALID_STATE;
1573                 break;
1574             }
1575             std::vector<std::string> packageList;
1576             for (uint32_t i = 0; i < listSize; i++) {
1577                 packageList.push_back(data.ReadString());
1578             }
1579             NotifyPackageEvent(listSize, packageList);
1580             break;
1581         }
1582         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_REFRESH_RATE_EVENT) : {
1583             EventInfo eventInfo = {
1584                 data.ReadString(), data.ReadBool(), data.ReadUint32(), data.ReadUint32(), data.ReadString(),
1585             };
1586             NotifyRefreshRateEvent(eventInfo);
1587             break;
1588         }
1589         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_DYNAMIC_MODE_EVENT) : {
1590             auto enableDynamicMode = data.ReadBool();
1591             NotifyDynamicModeEvent(enableDynamicMode);
1592             break;
1593         }
1594         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::NOTIFY_TOUCH_EVENT) : {
1595             auto touchStatus = data.ReadInt32();
1596             auto touchCnt = data.ReadInt32();
1597             NotifyTouchEvent(touchStatus, touchCnt);
1598             break;
1599         }
1600         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_HGM_CFG_CALLBACK) : {
1601             auto remoteObject = data.ReadRemoteObject();
1602             if (remoteObject == nullptr) {
1603                 ret = ERR_NULL_OBJECT;
1604                 break;
1605             }
1606             sptr<RSIHgmConfigChangeCallback> callback = iface_cast<RSIHgmConfigChangeCallback>(remoteObject);
1607             if (callback == nullptr) {
1608                 ret = ERR_NULL_OBJECT;
1609                 break;
1610             }
1611             int32_t status = RegisterHgmConfigChangeCallback(callback);
1612             if (!reply.WriteInt32(status)) {
1613                 ret = ERR_INVALID_REPLY;
1614             }
1615             break;
1616         }
1617         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REFRESH_RATE_MODE_CHANGE_CALLBACK) : {
1618             auto remoteObject = data.ReadRemoteObject();
1619             if (remoteObject == nullptr) {
1620                 ret = ERR_NULL_OBJECT;
1621                 break;
1622             }
1623             sptr<RSIHgmConfigChangeCallback> callback =
1624                 iface_cast<RSIHgmConfigChangeCallback>(remoteObject);
1625             if (callback == nullptr) {
1626                 ret = ERR_NULL_OBJECT;
1627                 break;
1628             }
1629             int32_t status = RegisterHgmRefreshRateModeChangeCallback(callback);
1630             if (!reply.WriteInt32(status)) {
1631                 ret = ERR_INVALID_REPLY;
1632             }
1633             break;
1634         }
1635         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REFRESH_RATE_UPDATE_CALLBACK) : {
1636             sptr<RSIHgmConfigChangeCallback> callback = nullptr;
1637             sptr<IRemoteObject> remoteObject = nullptr;
1638             if (data.ReadBool()) {
1639                 remoteObject = data.ReadRemoteObject();
1640             }
1641             if (remoteObject != nullptr) {
1642                 callback = iface_cast<RSIHgmConfigChangeCallback>(remoteObject);
1643             }
1644             int32_t status = RegisterHgmRefreshRateUpdateCallback(callback);
1645             if (!reply.WriteInt32(status)) {
1646                 ret = ERR_INVALID_REPLY;
1647             }
1648             break;
1649         }
1650         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_ROTATION_CACHE_ENABLED) : {
1651             if (!securityManager_.IsInterfaceCodeAccessible(code)) {
1652                 RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest no permission SET_ROTATION_CACHE_ENABLED");
1653                 return ERR_INVALID_STATE;
1654             }
1655             bool isEnabled = false;
1656             if (!data.ReadBool(isEnabled)) {
1657                 ret = IPC_STUB_INVALID_DATA_ERR;
1658                 break;
1659             }
1660             SetCacheEnabledForRotation(isEnabled);
1661             break;
1662         }
1663         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_DEFAULT_DEVICE_ROTATION_OFFSET) : {
1664             uint32_t offset = data.ReadUint32();
1665             SetDefaultDeviceRotationOffset(offset);
1666             break;
1667         }
1668         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_DIRTY_REGION_INFO) : {
1669             const auto& activeDirtyRegionInfos = GetActiveDirtyRegionInfo();
1670             if (!reply.WriteInt32(activeDirtyRegionInfos.size())) {
1671                 ret = ERR_INVALID_REPLY;
1672                 break;
1673             }
1674             for (const auto& activeDirtyRegionInfo : activeDirtyRegionInfos) {
1675                 if (!reply.WriteInt64(activeDirtyRegionInfo.activeDirtyRegionArea) ||
1676                     !reply.WriteInt32(activeDirtyRegionInfo.activeFramesNumber) ||
1677                     !reply.WriteInt32(activeDirtyRegionInfo.pidOfBelongsApp) ||
1678                     !reply.WriteString(activeDirtyRegionInfo.windowName)) {
1679                     ret = ERR_INVALID_REPLY;
1680                     break;
1681                 }
1682             }
1683             break;
1684         }
1685         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_GLOBAL_DIRTY_REGION_INFO) : {
1686             const auto& globalDirtyRegionInfo = GetGlobalDirtyRegionInfo();
1687             if (!reply.WriteInt64(globalDirtyRegionInfo.globalDirtyRegionAreas) ||
1688                 !reply.WriteInt32(globalDirtyRegionInfo.globalFramesNumber) ||
1689                 !reply.WriteInt32(globalDirtyRegionInfo.skipProcessFramesNumber) ||
1690                 !reply.WriteInt32(globalDirtyRegionInfo.mostSendingPidWhenDisplayNodeSkip)) {
1691                 ret = ERR_INVALID_REPLY;
1692             }
1693             break;
1694         }
1695         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_LAYER_COMPOSE_INFO) : {
1696             const auto& LayerComposeInfo = GetLayerComposeInfo();
1697             if (!reply.WriteInt32(LayerComposeInfo.uniformRenderFrameNumber) ||
1698                 !reply.WriteInt32(LayerComposeInfo.offlineComposeFrameNumber) ||
1699                 !reply.WriteInt32(LayerComposeInfo.redrawFrameNumber)) {
1700                 ret = ERR_INVALID_REPLY;
1701             }
1702             break;
1703         }
1704         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::
1705             GET_HARDWARE_COMPOSE_DISABLED_REASON_INFO) : {
1706             const auto& hwcDisabledReasonInfos = GetHwcDisabledReasonInfo();
1707             if (!reply.WriteInt32(hwcDisabledReasonInfos.size())) {
1708                 ret = ERR_INVALID_REPLY;
1709                 break;
1710             }
1711             for (const auto& hwcDisabledReasonInfo : hwcDisabledReasonInfos) {
1712                 for (const auto& disabledReasonCount : hwcDisabledReasonInfo.disabledReasonStatistics) {
1713                     if (!reply.WriteInt32(disabledReasonCount)) {
1714                         ret = ERR_INVALID_REPLY;
1715                         break;
1716                     }
1717                 }
1718                 if (ret == ERR_INVALID_REPLY) {
1719                     break;
1720                 }
1721                 if (!reply.WriteInt32(hwcDisabledReasonInfo.pidOfBelongsApp) ||
1722                     !reply.WriteString(hwcDisabledReasonInfo.nodeName)) {
1723                     ret = ERR_INVALID_REPLY;
1724                     break;
1725                 }
1726             }
1727             break;
1728         }
1729 #ifdef TP_FEATURE_ENABLE
1730         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_TP_FEATURE_CONFIG) : {
1731             int32_t feature = data.ReadInt32();
1732             auto config = data.ReadCString();
1733             SetTpFeatureConfig(feature, config);
1734             break;
1735         }
1736 #endif
1737         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_USING_STATUS) : {
1738             auto isVirtualScreenUsingStatus = data.ReadBool();
1739             SetVirtualScreenUsingStatus(isVirtualScreenUsingStatus);
1740             break;
1741         }
1742 
1743         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_CURTAIN_SCREEN_USING_STATUS) : {
1744             auto isCurtainScreenOn = data.ReadBool();
1745             SetCurtainScreenUsingStatus(isCurtainScreenOn);
1746             break;
1747         }
1748         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_UIEXTENSION_CALLBACK): {
1749             uint64_t userId = data.ReadUint64();
1750             auto remoteObject = data.ReadRemoteObject();
1751             if (remoteObject == nullptr) {
1752                 ret = ERR_NULL_OBJECT;
1753                 break;
1754             }
1755             sptr<RSIUIExtensionCallback> callback = iface_cast<RSIUIExtensionCallback>(remoteObject);
1756             if (callback == nullptr) {
1757                 ret = ERR_NULL_OBJECT;
1758                 break;
1759             }
1760             int32_t status = RegisterUIExtensionCallback(userId, callback);
1761             if (!reply.WriteInt32(status)) {
1762                 ret = ERR_INVALID_REPLY;
1763             }
1764             break;
1765         }
1766         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_ANCO_FORCE_DO_DIRECT) : {
1767             bool direct = data.ReadBool();
1768             bool result = SetAncoForceDoDirect(direct);
1769             reply.WriteBool(result);
1770             break;
1771         }
1772         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_VMA_CACHE_STATUS) : {
1773             bool flag = data.ReadBool();
1774             SetVmaCacheStatus(flag);
1775             break;
1776         }
1777         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::REGISTER_SURFACE_BUFFER_CALLBACK) : {
1778             auto pid = data.ReadInt32();
1779             auto uid = data.ReadUint64();
1780             auto remoteObject = data.ReadRemoteObject();
1781             if (remoteObject == nullptr) {
1782                 ret = ERR_NULL_OBJECT;
1783                 RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest remoteObject == nullptr");
1784                 break;
1785             }
1786             sptr<RSISurfaceBufferCallback> callback = iface_cast<RSISurfaceBufferCallback>(remoteObject);
1787             if (callback == nullptr) {
1788                 ret = ERR_NULL_OBJECT;
1789                 RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest remoteObject cast error");
1790                 break;
1791             }
1792             RegisterSurfaceBufferCallback(pid, uid, callback);
1793             break;
1794         }
1795         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SURFACE_BUFFER_CALLBACK) : {
1796             auto pid = data.ReadInt32();
1797             auto uid = data.ReadUint64();
1798             UnregisterSurfaceBufferCallback(pid, uid);
1799             break;
1800         }
1801         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_DISPLAY_NODE) : {
1802             auto id = data.ReadUint64();
1803             auto mirrorId = data.ReadUint64();
1804             auto screenId = data.ReadUint64();
1805             auto isMirrored = data.ReadBool();
1806             RSDisplayNodeConfig config = {
1807                 .screenId = screenId,
1808                 .isMirrored = isMirrored,
1809                 .mirrorNodeId = mirrorId,
1810                 .isSync = true,
1811             };
1812             reply.WriteBool(CreateNode(config, id));
1813             break;
1814         }
1815         case static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP) : {
1816             std::string nodeIdStr = data.ReadString();
1817             bool isTop = data.ReadBool();
1818             SetLayerTop(nodeIdStr, isTop);
1819             break;
1820         }
1821         default: {
1822             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
1823         }
1824     }
1825 
1826     return ret;
1827 }
1828 
ReadDataBaseRs(DataBaseRs & info,MessageParcel & data)1829 void RSRenderServiceConnectionStub::ReadDataBaseRs(DataBaseRs& info, MessageParcel& data)
1830 {
1831     info.appPid = data.ReadInt32();
1832     info.eventType =  data.ReadInt32();
1833     info.versionCode = data.ReadInt32();
1834     info.uniqueId = data.ReadInt64();
1835     info.inputTime = data.ReadInt64();
1836     info.beginVsyncTime = data.ReadInt64();
1837     info.endVsyncTime = data.ReadInt64();
1838     info.isDisplayAnimator = data.ReadBool();
1839     info.sceneId = data.ReadString();
1840     info.versionName = data.ReadString();
1841     info.bundleName = data.ReadString();
1842     info.processName = data.ReadString();
1843     info.abilityName = data.ReadString();
1844     info.pageUrl = data.ReadString();
1845     info.sourceType = data.ReadString();
1846     info.note = data.ReadString();
1847 }
1848 
ReadGameStateDataRs(GameStateData & info,MessageParcel & data)1849 void RSRenderServiceConnectionStub::ReadGameStateDataRs(GameStateData& info, MessageParcel& data)
1850 {
1851     info.pid = data.ReadInt32();
1852     info.uid =  data.ReadInt32();
1853     info.state = data.ReadInt32();
1854     info.renderTid = data.ReadInt32();
1855     info.bundleName = data.ReadString();
1856 }
1857 
1858 const RSInterfaceCodeSecurityManager RSRenderServiceConnectionStub::securityManager_ = \
1859     RSInterfaceCodeSecurityManager::CreateInstance<RSIRenderServiceConnectionInterfaceCodeAccessVerifier>();
1860 } // namespace Rosen
1861 } // namespace OHOS
1862