• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "accesstoken_kit.h"
17 #include "hap_token_info.h"
18 #include "ipc_skeleton.h"
19 #include "securec.h"
20 #include "update_helper.h"
21 #include "update_service_stub.h"
22 #include "update_system_event.h"
23 
24 using namespace std;
25 
26 namespace OHOS {
27 namespace UpdateEngine {
28 #define CALL_RESULT_TO_IPC_RESULT(callResult) ((callResult) + CALL_RESULT_OFFSET)
29 
30 #define RETURN_FAIL_WHEN_SERVICE_NULL(service) \
31     ENGINE_CHECK((service) != nullptr, return INT_CALL_IPC_ERR, "service null")
32 
GetNewVersionStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)33 static int32_t GetNewVersionStub(UpdateServiceStub::UpdateServiceStubPtr service,
34     MessageParcel& data, MessageParcel& reply, MessageOption &option)
35 {
36     RETURN_FAIL_WHEN_SERVICE_NULL(service);
37     UpgradeInfo upgradeInfo {};
38     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
39     NewVersionInfo newVersionInfo = {};
40     BusinessError businessError = {};
41     int32_t ret = service->GetNewVersion(upgradeInfo, newVersionInfo, businessError);
42     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to GetNewVersion");
43     UpdateHelper::WriteBusinessError(reply, businessError);
44     UpdateHelper::WriteNewVersionInfo(reply, newVersionInfo);
45     return INT_CALL_SUCCESS;
46 }
47 
GetNewVersionDescriptionStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)48 static int32_t GetNewVersionDescriptionStub(UpdateServiceStub::UpdateServiceStubPtr service,
49     MessageParcel& data, MessageParcel& reply, MessageOption &option)
50 {
51     RETURN_FAIL_WHEN_SERVICE_NULL(service);
52     UpgradeInfo upgradeInfo;
53     VersionDigestInfo versionDigestInfo;
54     DescriptionOptions descriptionOptions;
55     VersionDescriptionInfo newVersionDescriptionInfo;
56     BusinessError businessError;
57     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
58     UpdateHelper::ReadVersionDigestInfo(data, versionDigestInfo);
59     UpdateHelper::ReadDescriptionOptions(data, descriptionOptions);
60 
61     int32_t ret = service->GetNewVersionDescription(upgradeInfo, versionDigestInfo, descriptionOptions,
62         newVersionDescriptionInfo, businessError);
63     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to GetNewVersionDescription");
64     UpdateHelper::WriteBusinessError(reply, businessError);
65     UpdateHelper::WriteVersionDescriptionInfo(reply, newVersionDescriptionInfo);
66     return INT_CALL_SUCCESS;
67 }
68 
GetCurrentVersionStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)69 static int32_t GetCurrentVersionStub(UpdateServiceStub::UpdateServiceStubPtr service,
70     MessageParcel &data, MessageParcel &reply, MessageOption &option)
71 {
72     RETURN_FAIL_WHEN_SERVICE_NULL(service);
73     UpgradeInfo upgradeInfo {};
74     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
75     CurrentVersionInfo currentVersionInfo = {};
76     BusinessError businessError = {};
77     int32_t ret = service->GetCurrentVersionInfo(upgradeInfo, currentVersionInfo, businessError);
78     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to GetCurrentVersion");
79     UpdateHelper::WriteBusinessError(reply, businessError);
80     UpdateHelper::WriteCurrentVersionInfo(reply, currentVersionInfo);
81     return INT_CALL_SUCCESS;
82 }
83 
GetCurrentVersionDescriptionStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)84 static int32_t GetCurrentVersionDescriptionStub(UpdateServiceStub::UpdateServiceStubPtr service,
85     MessageParcel& data, MessageParcel& reply, MessageOption &option)
86 {
87     RETURN_FAIL_WHEN_SERVICE_NULL(service);
88     UpgradeInfo upgradeInfo;
89     DescriptionOptions descriptionOptions;
90     VersionDescriptionInfo currentVersionDescriptionInfo;
91     BusinessError businessError;
92     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
93     UpdateHelper::ReadDescriptionOptions(data, descriptionOptions);
94 
95     int32_t ret = service->GetCurrentVersionDescription(upgradeInfo, descriptionOptions, currentVersionDescriptionInfo,
96         businessError);
97     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to GetCurrentVersionDescription");
98     UpdateHelper::WriteBusinessError(reply, businessError);
99     UpdateHelper::WriteVersionDescriptionInfo(reply, currentVersionDescriptionInfo);
100     return INT_CALL_SUCCESS;
101 }
102 
GetTaskInfoStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)103 static int32_t GetTaskInfoStub(UpdateServiceStub::UpdateServiceStubPtr service,
104     MessageParcel &data, MessageParcel &reply, MessageOption &option)
105 {
106     RETURN_FAIL_WHEN_SERVICE_NULL(service);
107     UpgradeInfo upgradeInfo {};
108     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
109     TaskInfo taskInfo = {};
110     BusinessError businessError = {};
111     int32_t ret = service->GetTaskInfo(upgradeInfo, taskInfo, businessError);
112     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to GetTaskInfo");
113     UpdateHelper::WriteBusinessError(reply, businessError);
114     UpdateHelper::WriteTaskInfo(reply, taskInfo);
115     return INT_CALL_SUCCESS;
116 }
117 
CheckNewVersionStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)118 static int32_t CheckNewVersionStub(UpdateServiceStub::UpdateServiceStubPtr service,
119     MessageParcel& data, MessageParcel& reply, MessageOption &option)
120 {
121     RETURN_FAIL_WHEN_SERVICE_NULL(service);
122     UpgradeInfo upgradeInfo {};
123     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
124     return service->CheckNewVersion(upgradeInfo);
125 }
126 
DownloadVersionStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)127 static int32_t DownloadVersionStub(UpdateServiceStub::UpdateServiceStubPtr service, MessageParcel &data,
128     MessageParcel &reply, MessageOption &option)
129 {
130     RETURN_FAIL_WHEN_SERVICE_NULL(service);
131     UpgradeInfo upgradeInfo;
132     VersionDigestInfo versionDigestInfo;
133     DownloadOptions downloadOptions;
134     BusinessError businessError;
135     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
136     UpdateHelper::ReadVersionDigestInfo(data, versionDigestInfo);
137     UpdateHelper::ReadDownloadOptions(data, downloadOptions);
138     int32_t ret = service->DownloadVersion(upgradeInfo, versionDigestInfo, downloadOptions, businessError);
139     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to DownloadVersion");
140     UpdateHelper::WriteBusinessError(reply, businessError);
141     return INT_CALL_SUCCESS;
142 }
143 
PauseDownloadStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)144 static int32_t PauseDownloadStub(UpdateServiceStub::UpdateServiceStubPtr service,
145     MessageParcel& data, MessageParcel& reply, MessageOption &option)
146 {
147     RETURN_FAIL_WHEN_SERVICE_NULL(service);
148     UpgradeInfo upgradeInfo;
149     VersionDigestInfo versionDigestInfo;
150     PauseDownloadOptions pauseDownloadOptions;
151     BusinessError businessError;
152     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
153     UpdateHelper::ReadVersionDigestInfo(data, versionDigestInfo);
154     UpdateHelper::ReadPauseDownloadOptions(data, pauseDownloadOptions);
155 
156     int32_t ret = service->PauseDownload(upgradeInfo, versionDigestInfo, pauseDownloadOptions, businessError);
157     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to PauseDownload");
158     UpdateHelper::WriteBusinessError(reply, businessError);
159     return INT_CALL_SUCCESS;
160 }
161 
ResumeDownloadStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)162 static int32_t ResumeDownloadStub(UpdateServiceStub::UpdateServiceStubPtr service,
163     MessageParcel& data, MessageParcel& reply, MessageOption &option)
164 {
165     RETURN_FAIL_WHEN_SERVICE_NULL(service);
166     UpgradeInfo upgradeInfo;
167     VersionDigestInfo versionDigestInfo;
168     ResumeDownloadOptions resumeDownloadOptions;
169     BusinessError businessError;
170     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
171     UpdateHelper::ReadVersionDigestInfo(data, versionDigestInfo);
172     UpdateHelper::ReadResumeDownloadOptions(data, resumeDownloadOptions);
173 
174     int32_t ret = service->ResumeDownload(upgradeInfo, versionDigestInfo, resumeDownloadOptions, businessError);
175     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to ResumeDownload");
176     UpdateHelper::WriteBusinessError(reply, businessError);
177     return INT_CALL_SUCCESS;
178 }
179 
DoUpdateStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)180 static int32_t DoUpdateStub(UpdateServiceStub::UpdateServiceStubPtr service,
181     MessageParcel& data, MessageParcel& reply, MessageOption &option)
182 {
183     RETURN_FAIL_WHEN_SERVICE_NULL(service);
184     UpgradeInfo upgradeInfo;
185     VersionDigestInfo versionDigestInfo;
186     UpgradeOptions upgradeOptions;
187     BusinessError businessError;
188     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
189     UpdateHelper::ReadVersionDigestInfo(data, versionDigestInfo);
190     UpdateHelper::ReadUpgradeOptions(data, upgradeOptions);
191 
192     int32_t ret = service->DoUpdate(upgradeInfo, versionDigestInfo, upgradeOptions, businessError);
193     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to DoUpdate");
194     UpdateHelper::WriteBusinessError(reply, businessError);
195     return INT_CALL_SUCCESS;
196 }
197 
ClearErrorStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)198 static int32_t ClearErrorStub(UpdateServiceStub::UpdateServiceStubPtr service,
199     MessageParcel& data, MessageParcel& reply, MessageOption &option)
200 {
201     RETURN_FAIL_WHEN_SERVICE_NULL(service);
202     UpgradeInfo upgradeInfo;
203     VersionDigestInfo versionDigestInfo;
204     ClearOptions clearOptions;
205     BusinessError businessError;
206     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
207     UpdateHelper::ReadVersionDigestInfo(data, versionDigestInfo);
208     UpdateHelper::ReadClearOptions(data, clearOptions);
209 
210     int32_t ret = service->ClearError(upgradeInfo, versionDigestInfo, clearOptions, businessError);
211     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to ClearError");
212     UpdateHelper::WriteBusinessError(reply, businessError);
213     return INT_CALL_SUCCESS;
214 }
215 
TerminateUpgradeStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)216 static int32_t TerminateUpgradeStub(UpdateServiceStub::UpdateServiceStubPtr service, MessageParcel &data,
217     MessageParcel &reply, MessageOption &option)
218 {
219     RETURN_FAIL_WHEN_SERVICE_NULL(service);
220     UpgradeInfo upgradeInfo;
221     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
222 
223     BusinessError businessError;
224     int32_t ret = service->TerminateUpgrade(upgradeInfo, businessError);
225     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to TerminateUpgrade");
226     UpdateHelper::WriteBusinessError(reply, businessError);
227     return INT_CALL_SUCCESS;
228 }
229 
SetUpgradePolicyStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)230 static int32_t SetUpgradePolicyStub(
231     UpdateServiceStub::UpdateServiceStubPtr service, MessageParcel &data, MessageParcel &reply, MessageOption &option)
232 {
233     RETURN_FAIL_WHEN_SERVICE_NULL(service);
234     UpgradeInfo upgradeInfo {};
235     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
236     UpgradePolicy policy = {};
237     UpdateHelper::ReadUpgradePolicy(data, policy);
238     BusinessError businessError = {};
239     int32_t ret = service->SetUpgradePolicy(upgradeInfo, policy, businessError);
240     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to SetUpgradePolicy");
241     UpdateHelper::WriteBusinessError(reply, businessError);
242     return INT_CALL_SUCCESS;
243 }
244 
GetUpgradePolicyStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)245 static int32_t GetUpgradePolicyStub(UpdateServiceStub::UpdateServiceStubPtr service,
246     MessageParcel& data, MessageParcel& reply, MessageOption &option)
247 {
248     RETURN_FAIL_WHEN_SERVICE_NULL(service);
249     UpgradeInfo upgradeInfo {};
250     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
251     UpgradePolicy policy = {};
252     BusinessError businessError = {};
253     int32_t ret = service->GetUpgradePolicy(upgradeInfo, policy, businessError);
254     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to GetUpgradePolicy");
255     UpdateHelper::WriteBusinessError(reply, businessError);
256     UpdateHelper::WriteUpgradePolicy(reply, policy);
257     return INT_CALL_SUCCESS;
258 }
259 
RegisterUpdateCallbackStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)260 static int32_t RegisterUpdateCallbackStub(UpdateServiceStub::UpdateServiceStubPtr service,
261     MessageParcel& data, MessageParcel& reply, MessageOption &option)
262 {
263     ENGINE_LOGI("RegisterUpdateCallbackStub");
264     RETURN_FAIL_WHEN_SERVICE_NULL(service);
265     UpgradeInfo upgradeInfo {};
266     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
267     auto remote = data.ReadRemoteObject();
268     ENGINE_CHECK(remote != nullptr, return INT_CALL_IPC_ERR, "Failed to read remote obj");
269     return service->RegisterUpdateCallback(upgradeInfo, iface_cast<IUpdateCallback>(remote));
270 }
271 
UnregisterUpdateCallbackStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)272 static int32_t UnregisterUpdateCallbackStub(UpdateServiceStub::UpdateServiceStubPtr service,
273     MessageParcel& data, MessageParcel& reply, MessageOption &option)
274 {
275     RETURN_FAIL_WHEN_SERVICE_NULL(service);
276     UpgradeInfo upgradeInfo {};
277     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
278     return service->UnregisterUpdateCallback(upgradeInfo);
279 }
280 
CancelStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)281 static int32_t CancelStub(UpdateServiceStub::UpdateServiceStubPtr service,
282     MessageParcel& data, MessageParcel& reply, MessageOption &option)
283 {
284     RETURN_FAIL_WHEN_SERVICE_NULL(service);
285     UpgradeInfo upgradeInfo {};
286     BusinessError businessError = {};
287     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
288     int32_t ret = service->Cancel(upgradeInfo, data.ReadInt32(), businessError);
289     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to cancel");
290     UpdateHelper::WriteBusinessError(reply, businessError);
291     return INT_CALL_SUCCESS;
292 }
293 
FactoryResetStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)294 static int32_t FactoryResetStub(UpdateServiceStub::UpdateServiceStubPtr service,
295     MessageParcel& data, MessageParcel& reply, MessageOption &option)
296 {
297     RETURN_FAIL_WHEN_SERVICE_NULL(service);
298     SYS_EVENT_SYSTEM_RESET(0, UpdateSystemEvent::RESET_START);
299     BusinessError businessError;
300     int32_t ret = service->FactoryReset(businessError);
301     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to FactoryReset");
302     UpdateHelper::WriteBusinessError(reply, businessError);
303     return INT_CALL_SUCCESS;
304 }
305 
ApplyNewVersionStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)306 static int32_t ApplyNewVersionStub(UpdateServiceStub::UpdateServiceStubPtr service,
307     MessageParcel& data, MessageParcel& reply, MessageOption &option)
308 {
309     RETURN_FAIL_WHEN_SERVICE_NULL(service);
310     UpgradeInfo upgradeInfo;
311     UpdateHelper::ReadUpgradeInfo(data, upgradeInfo);
312     string miscFile = Str16ToStr8(data.ReadString16());
313     string packageName = Str16ToStr8(data.ReadString16());
314     BusinessError businessError;
315     int32_t ret = service->ApplyNewVersion(upgradeInfo, miscFile, packageName, businessError);
316     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to ApplyNewVersion");
317     UpdateHelper::WriteBusinessError(reply, businessError);
318     return INT_CALL_SUCCESS;
319 }
320 
VerifyUpgradePackageStub(UpdateServiceStub::UpdateServiceStubPtr service,MessageParcel & data,MessageParcel & reply,MessageOption & option)321 static int32_t VerifyUpgradePackageStub(UpdateServiceStub::UpdateServiceStubPtr service,
322     MessageParcel& data, MessageParcel& reply, MessageOption &option)
323 {
324     RETURN_FAIL_WHEN_SERVICE_NULL(service);
325     string packagePath = Str16ToStr8(data.ReadString16());
326     string keyPath = Str16ToStr8(data.ReadString16());
327     BusinessError businessError;
328     int32_t ret = service->VerifyUpgradePackage(packagePath, keyPath, businessError);
329     ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to VerifyUpgradePackage");
330     UpdateHelper::WriteBusinessError(reply, businessError);
331     return INT_CALL_SUCCESS;
332 }
333 
IsPermissionGranted(uint32_t code)334 static bool IsPermissionGranted(uint32_t code)
335 {
336     Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID();
337     string permission = "ohos.permission.UPDATE_SYSTEM";
338     if (code == IUpdateService::FACTORY_RESET) {
339         permission = "ohos.permission.FACTORY_RESET";
340     }
341     int verifyResult = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, permission);
342     bool isPermissionGranted = verifyResult == Security::AccessToken::PERMISSION_GRANTED;
343     if (!isPermissionGranted) {
344         ENGINE_LOGE("%{public}s not granted, code:%{public}d", permission.c_str(), code);
345     }
346     return isPermissionGranted;
347 }
348 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)349 int32_t UpdateServiceStub::OnRemoteRequest(uint32_t code,
350     MessageParcel& data, MessageParcel& reply, MessageOption &option)
351 {
352     if (data.ReadInterfaceToken() != GetDescriptor()) {
353         ENGINE_LOGI("UpdateServiceStub ReadInterfaceToken fail");
354         return CALL_RESULT_TO_IPC_RESULT(INT_CALL_IPC_ERR);
355     }
356     static std::map<uint32_t, UpdateServiceStub::RequestFuncType> requestFuncMap = {
357         {IUpdateService::CHECK_VERSION, CheckNewVersionStub},
358         {IUpdateService::DOWNLOAD, DownloadVersionStub},
359         {IUpdateService::PAUSE_DOWNLOAD, PauseDownloadStub},
360         {IUpdateService::RESUME_DOWNLOAD, ResumeDownloadStub},
361         {IUpdateService::UPGRADE, DoUpdateStub},
362         {IUpdateService::CLEAR_ERROR, ClearErrorStub},
363         {IUpdateService::TERMINATE_UPGRADE, TerminateUpgradeStub},
364         {IUpdateService::SET_POLICY, SetUpgradePolicyStub},
365         {IUpdateService::GET_POLICY, GetUpgradePolicyStub},
366         {IUpdateService::GET_NEW_VERSION, GetNewVersionStub},
367         {IUpdateService::GET_NEW_VERSION_DESCRIPTION, GetNewVersionDescriptionStub},
368         {IUpdateService::GET_CURRENT_VERSION, GetCurrentVersionStub},
369         {IUpdateService::GET_CURRENT_VERSION_DESCRIPTION, GetCurrentVersionDescriptionStub},
370         {IUpdateService::GET_TASK_INFO, GetTaskInfoStub},
371         {IUpdateService::REGISTER_CALLBACK, RegisterUpdateCallbackStub},
372         {IUpdateService::UNREGISTER_CALLBACK, UnregisterUpdateCallbackStub},
373         {IUpdateService::CANCEL, CancelStub},
374         {IUpdateService::FACTORY_RESET, FactoryResetStub},
375         {IUpdateService::APPLY_NEW_VERSION, ApplyNewVersionStub},
376         {IUpdateService::VERIFY_UPGRADE_PACKAGE, VerifyUpgradePackageStub},
377     };
378 
379     ENGINE_LOGI("UpdateServiceStub func code %{public}u", code);
380     auto iter = requestFuncMap.find(code);
381     if (iter == requestFuncMap.end()) {
382         ENGINE_LOGE("UpdateServiceStub OnRemoteRequest code %{public}u not found", code);
383         return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
384     }
385 
386     if (!IsPermissionGranted(code)) {
387         UpgradeInfo tmpInfo;
388         UpdateHelper::ReadUpgradeInfo(data, tmpInfo);
389         SYS_EVENT_VERIFY_FAILED(0, UpdateHelper::BuildEventDevId(tmpInfo),
390             UpdateSystemEvent::EVENT_PERMISSION_VERIFY_FAILED);
391         return CALL_RESULT_TO_IPC_RESULT(INT_APP_NOT_GRANTED);
392     }
393     return CALL_RESULT_TO_IPC_RESULT(iter->second(this, data, reply, option));
394 }
395 } // namespace UpdateEngine
396 } // namespace OHOS