• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 "ipc/installd_proxy.h"
17 
18 #include "ipc_types.h"
19 
20 #include "app_log_wrapper.h"
21 #include "bundle_constants.h"
22 #include "parcel_macro.h"
23 #include "string_ex.h"
24 
25 namespace OHOS {
26 namespace AppExecFwk {
27 namespace {
28 constexpr int32_t WAIT_TIME = 3000;
29 }
30 
InstalldProxy(const sptr<IRemoteObject> & object)31 InstalldProxy::InstalldProxy(const sptr<IRemoteObject> &object) : IRemoteProxy<IInstalld>(object)
32 {
33     APP_LOGI("installd proxy instance is created");
34 }
35 
~InstalldProxy()36 InstalldProxy::~InstalldProxy()
37 {
38     APP_LOGI("installd proxy instance is destroyed");
39 }
40 
CreateBundleDir(const std::string & bundleDir)41 ErrCode InstalldProxy::CreateBundleDir(const std::string &bundleDir)
42 {
43     MessageParcel data;
44     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
45     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(bundleDir));
46 
47     MessageParcel reply;
48     MessageOption option;
49     return TransactInstalldCmd(InstalldInterfaceCode::CREATE_BUNDLE_DIR, data, reply, option);
50 }
51 
ExtractModuleFiles(const std::string & srcModulePath,const std::string & targetPath,const std::string & targetSoPath,const std::string & cpuAbi)52 ErrCode InstalldProxy::ExtractModuleFiles(const std::string &srcModulePath, const std::string &targetPath,
53     const std::string &targetSoPath, const std::string &cpuAbi)
54 {
55     MessageParcel data;
56     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
57     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(srcModulePath));
58     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(targetPath));
59     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(targetSoPath));
60     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(cpuAbi));
61 
62     MessageParcel reply;
63     MessageOption option;
64     return TransactInstalldCmd(InstalldInterfaceCode::EXTRACT_MODULE_FILES, data, reply, option);
65 }
66 
ExtractFiles(const ExtractParam & extractParam)67 ErrCode InstalldProxy::ExtractFiles(const ExtractParam &extractParam)
68 {
69     MessageParcel data;
70     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
71     if (!data.WriteParcelable(&extractParam)) {
72         APP_LOGE("WriteParcelable extractParam failed.");
73         return ERR_APPEXECFWK_PARCEL_ERROR;
74     }
75 
76     MessageParcel reply;
77     MessageOption option;
78     return TransactInstalldCmd(InstalldInterfaceCode::EXTRACT_FILES, data, reply, option);
79 }
80 
ExecuteAOT(const AOTArgs & aotArgs)81 ErrCode InstalldProxy::ExecuteAOT(const AOTArgs &aotArgs)
82 {
83     MessageParcel data;
84     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
85     if (!data.WriteParcelable(&aotArgs)) {
86         APP_LOGE("WriteParcelable aotArgs failed");
87         return ERR_APPEXECFWK_PARCEL_ERROR;
88     }
89 
90     MessageParcel reply;
91     MessageOption option;
92     return TransactInstalldCmd(InstalldInterfaceCode::EXECUTE_AOT, data, reply, option);
93 }
94 
RenameModuleDir(const std::string & oldPath,const std::string & newPath)95 ErrCode InstalldProxy::RenameModuleDir(const std::string &oldPath, const std::string &newPath)
96 {
97     MessageParcel data;
98     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
99     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(oldPath));
100     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(newPath));
101 
102     MessageParcel reply;
103     MessageOption option;
104     return TransactInstalldCmd(InstalldInterfaceCode::RENAME_MODULE_DIR, data, reply, option);
105 }
106 
CreateBundleDataDir(const CreateDirParam & createDirParam)107 ErrCode InstalldProxy::CreateBundleDataDir(const CreateDirParam &createDirParam)
108 {
109     MessageParcel data;
110     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
111     if (!data.WriteParcelable(&createDirParam)) {
112         APP_LOGE("WriteParcelable createDirParam failed.");
113         return ERR_APPEXECFWK_PARCEL_ERROR;
114     }
115 
116     MessageParcel reply;
117     MessageOption option;
118     return TransactInstalldCmd(InstalldInterfaceCode::CREATE_BUNDLE_DATA_DIR, data, reply, option);
119 }
120 
RemoveBundleDataDir(const std::string & bundleName,const int userid)121 ErrCode InstalldProxy::RemoveBundleDataDir(const std::string &bundleName, const int userid)
122 {
123     MessageParcel data;
124     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
125     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(bundleName));
126     INSTALLD_PARCEL_WRITE(data, Int32, userid);
127 
128     MessageParcel reply;
129     MessageOption option;
130     return TransactInstalldCmd(InstalldInterfaceCode::REMOVE_BUNDLE_DATA_DIR, data, reply, option);
131 }
132 
RemoveModuleDataDir(const std::string & ModuleName,const int userid)133 ErrCode InstalldProxy::RemoveModuleDataDir(const std::string &ModuleName, const int userid)
134 {
135     MessageParcel data;
136     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
137     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(ModuleName));
138     INSTALLD_PARCEL_WRITE(data, Int32, userid);
139 
140     MessageParcel reply;
141     MessageOption option;
142     return TransactInstalldCmd(InstalldInterfaceCode::REMOVE_MODULE_DATA_DIR, data, reply, option);
143 }
144 
RemoveDir(const std::string & dir)145 ErrCode InstalldProxy::RemoveDir(const std::string &dir)
146 {
147     MessageParcel data;
148     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
149     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(dir));
150 
151     MessageParcel reply;
152     MessageOption option(MessageOption::TF_SYNC);
153     return TransactInstalldCmd(InstalldInterfaceCode::REMOVE_DIR, data, reply, option);
154 }
155 
CleanBundleDataDir(const std::string & bundleDir)156 ErrCode InstalldProxy::CleanBundleDataDir(const std::string &bundleDir)
157 {
158     MessageParcel data;
159     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
160     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(bundleDir));
161 
162     MessageParcel reply;
163     MessageOption option(MessageOption::TF_SYNC, WAIT_TIME);
164     return TransactInstalldCmd(InstalldInterfaceCode::CLEAN_BUNDLE_DATA_DIR, data, reply, option);
165 }
166 
GetBundleStats(const std::string & bundleName,const int32_t userId,std::vector<int64_t> & bundleStats)167 ErrCode InstalldProxy::GetBundleStats(
168     const std::string &bundleName, const int32_t userId, std::vector<int64_t> &bundleStats)
169 {
170     MessageParcel data;
171     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
172     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(bundleName));
173     INSTALLD_PARCEL_WRITE(data, Int32, userId);
174     MessageParcel reply;
175     MessageOption option(MessageOption::TF_SYNC);
176     auto ret = TransactInstalldCmd(InstalldInterfaceCode::GET_BUNDLE_STATS, data, reply, option);
177     if (ret == ERR_OK) {
178         if (reply.ReadInt64Vector(&bundleStats)) {
179             return ERR_OK;
180         } else {
181             return ERR_APPEXECFWK_PARCEL_ERROR;
182         }
183     }
184     return ret;
185 }
186 
SetDirApl(const std::string & dir,const std::string & bundleName,const std::string & apl,bool isPreInstallApp,bool debug)187 ErrCode InstalldProxy::SetDirApl(const std::string &dir, const std::string &bundleName, const std::string &apl,
188     bool isPreInstallApp, bool debug)
189 {
190     MessageParcel data;
191     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
192     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(dir));
193     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(bundleName));
194     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(apl));
195     INSTALLD_PARCEL_WRITE(data, Bool, isPreInstallApp);
196     INSTALLD_PARCEL_WRITE(data, Bool, debug);
197 
198     MessageParcel reply;
199     MessageOption option(MessageOption::TF_SYNC);
200     return TransactInstalldCmd(InstalldInterfaceCode::SET_DIR_APL, data, reply, option);
201 }
202 
GetBundleCachePath(const std::string & dir,std::vector<std::string> & cachePath)203 ErrCode InstalldProxy::GetBundleCachePath(const std::string &dir, std::vector<std::string> &cachePath)
204 {
205     MessageParcel data;
206     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
207     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(dir));
208     MessageParcel reply;
209     MessageOption option(MessageOption::TF_SYNC);
210     auto ret = TransactInstalldCmd(InstalldInterfaceCode::GET_BUNDLE_CACHE_PATH, data, reply, option);
211     if (ret == ERR_OK) {
212         if (reply.ReadStringVector(&cachePath)) {
213             return ERR_OK;
214         } else {
215             return ERR_APPEXECFWK_PARCEL_ERROR;
216         }
217     }
218     return ret;
219 }
220 
ScanDir(const std::string & dir,ScanMode scanMode,ResultMode resultMode,std::vector<std::string> & paths)221 ErrCode InstalldProxy::ScanDir(
222     const std::string &dir, ScanMode scanMode, ResultMode resultMode, std::vector<std::string> &paths)
223 {
224     MessageParcel data;
225     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
226     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(dir));
227     INSTALLD_PARCEL_WRITE(data, Int32, static_cast<int32_t>(scanMode));
228     INSTALLD_PARCEL_WRITE(data, Int32, static_cast<int32_t>(resultMode));
229 
230     MessageParcel reply;
231     MessageOption option(MessageOption::TF_SYNC);
232     auto ret = TransactInstalldCmd(InstalldInterfaceCode::SCAN_DIR, data, reply, option);
233     if (ret != ERR_OK) {
234         return ret;
235     }
236 
237     if (!reply.ReadStringVector(&paths)) {
238         return ERR_APPEXECFWK_PARCEL_ERROR;
239     }
240 
241     return ERR_OK;
242 }
243 
MoveFile(const std::string & oldPath,const std::string & newPath)244 ErrCode InstalldProxy::MoveFile(const std::string &oldPath, const std::string &newPath)
245 {
246     MessageParcel data;
247     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
248     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(oldPath));
249     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(newPath));
250 
251     MessageParcel reply;
252     MessageOption option(MessageOption::TF_SYNC);
253     return TransactInstalldCmd(InstalldInterfaceCode::MOVE_FILE, data, reply, option);
254 }
255 
CopyFile(const std::string & oldPath,const std::string & newPath,const std::string & signatureFilePath)256 ErrCode InstalldProxy::CopyFile(const std::string &oldPath, const std::string &newPath,
257     const std::string &signatureFilePath)
258 {
259     MessageParcel data;
260     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
261     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(oldPath));
262     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(newPath));
263     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(signatureFilePath));
264 
265     MessageParcel reply;
266     MessageOption option(MessageOption::TF_SYNC);
267     return TransactInstalldCmd(InstalldInterfaceCode::COPY_FILE, data, reply, option);
268 }
269 
Mkdir(const std::string & dir,const int32_t mode,const int32_t uid,const int32_t gid)270 ErrCode InstalldProxy::Mkdir(
271     const std::string &dir, const int32_t mode, const int32_t uid, const int32_t gid)
272 {
273     MessageParcel data;
274     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
275     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(dir));
276     INSTALLD_PARCEL_WRITE(data, Int32, mode);
277     INSTALLD_PARCEL_WRITE(data, Int32, uid);
278     INSTALLD_PARCEL_WRITE(data, Int32, gid);
279 
280     MessageParcel reply;
281     MessageOption option(MessageOption::TF_SYNC);
282     return TransactInstalldCmd(InstalldInterfaceCode::MKDIR, data, reply, option);
283 }
284 
GetFileStat(const std::string & file,FileStat & fileStat)285 ErrCode InstalldProxy::GetFileStat(const std::string &file, FileStat &fileStat)
286 {
287     MessageParcel data;
288     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
289     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(file));
290 
291     MessageParcel reply;
292     MessageOption option(MessageOption::TF_SYNC);
293     auto ret = TransactInstalldCmd(InstalldInterfaceCode::GET_FILE_STAT, data, reply, option);
294     if (ret != ERR_OK) {
295         APP_LOGE("TransactInstalldCmd failed");
296         return ret;
297     }
298 
299     std::unique_ptr<FileStat> info(reply.ReadParcelable<FileStat>());
300     if (info == nullptr) {
301         APP_LOGE("readParcelableInfo failed");
302         return ERR_APPEXECFWK_INSTALL_INSTALLD_SERVICE_ERROR;
303     }
304 
305     fileStat = *info;
306     return ERR_OK;
307 }
308 
ExtractDiffFiles(const std::string & filePath,const std::string & targetPath,const std::string & cpuAbi)309 ErrCode InstalldProxy::ExtractDiffFiles(const std::string &filePath, const std::string &targetPath,
310     const std::string &cpuAbi)
311 {
312     MessageParcel data;
313     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
314     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(filePath));
315     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(targetPath));
316     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(cpuAbi));
317 
318     MessageParcel reply;
319     MessageOption option(MessageOption::TF_SYNC);
320     return TransactInstalldCmd(InstalldInterfaceCode::EXTRACT_DIFF_FILES, data, reply, option);
321 }
322 
ApplyDiffPatch(const std::string & oldSoPath,const std::string & diffFilePath,const std::string & newSoPath)323 ErrCode InstalldProxy::ApplyDiffPatch(const std::string &oldSoPath, const std::string &diffFilePath,
324     const std::string &newSoPath)
325 {
326     MessageParcel data;
327     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
328     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(oldSoPath));
329     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(diffFilePath));
330     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(newSoPath));
331 
332     MessageParcel reply;
333     MessageOption option(MessageOption::TF_SYNC);
334     return TransactInstalldCmd(InstalldInterfaceCode::APPLY_DIFF_PATCH, data, reply, option);
335 }
336 
IsExistDir(const std::string & dir,bool & isExist)337 ErrCode InstalldProxy::IsExistDir(const std::string &dir, bool &isExist)
338 {
339     MessageParcel data;
340     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
341     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(dir));
342 
343     MessageParcel reply;
344     MessageOption option(MessageOption::TF_SYNC);
345     auto ret = TransactInstalldCmd(InstalldInterfaceCode::IS_EXIST_DIR, data, reply, option);
346     if (ret != ERR_OK) {
347         APP_LOGE("TransactInstalldCmd failed");
348         return ret;
349     }
350     isExist = reply.ReadBool();
351     return ERR_OK;
352 }
353 
IsExistFile(const std::string & path,bool & isExist)354 ErrCode InstalldProxy::IsExistFile(const std::string &path, bool &isExist)
355 {
356     MessageParcel data;
357     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
358     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(path));
359 
360     MessageParcel reply;
361     MessageOption option(MessageOption::TF_SYNC);
362     auto ret = TransactInstalldCmd(InstalldInterfaceCode::IS_EXIST_FILE, data, reply, option);
363     if (ret != ERR_OK) {
364         APP_LOGE("TransactInstalldCmd failed");
365         return ret;
366     }
367     isExist = reply.ReadBool();
368     return ERR_OK;
369 }
370 
IsDirEmpty(const std::string & dir,bool & isDirEmpty)371 ErrCode InstalldProxy::IsDirEmpty(const std::string &dir, bool &isDirEmpty)
372 {
373     MessageParcel data;
374     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
375     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(dir));
376 
377     MessageParcel reply;
378     MessageOption option(MessageOption::TF_SYNC);
379     auto ret = TransactInstalldCmd(InstalldInterfaceCode::IS_DIR_EMPTY, data, reply, option);
380     if (ret != ERR_OK) {
381         APP_LOGE("TransactInstalldCmd failed");
382         return ret;
383     }
384     isDirEmpty = reply.ReadBool();
385     return ERR_OK;
386 }
387 
ObtainQuickFixFileDir(const std::string & dir,std::vector<std::string> & dirVec)388 ErrCode InstalldProxy::ObtainQuickFixFileDir(const std::string &dir, std::vector<std::string> &dirVec)
389 {
390     MessageParcel data;
391     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
392     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(dir));
393 
394     MessageParcel reply;
395     MessageOption option(MessageOption::TF_SYNC);
396     auto ret = TransactInstalldCmd(InstalldInterfaceCode::OBTAIN_QUICK_FIX_DIR, data, reply, option);
397     if (ret != ERR_OK) {
398         APP_LOGE("TransactInstalldCmd failed");
399         return ret;
400     }
401     if (!reply.ReadStringVector(&dirVec)) {
402         return ERR_APPEXECFWK_PARCEL_ERROR;
403     }
404     return ERR_OK;
405 }
406 
CopyFiles(const std::string & sourceDir,const std::string & destinationDir)407 ErrCode InstalldProxy::CopyFiles(const std::string &sourceDir, const std::string &destinationDir)
408 {
409     MessageParcel data;
410     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
411     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(sourceDir));
412     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(destinationDir));
413 
414     MessageParcel reply;
415     MessageOption option(MessageOption::TF_SYNC);
416     auto ret = TransactInstalldCmd(InstalldInterfaceCode::COPY_FILES, data, reply, option);
417     if (ret != ERR_OK) {
418         APP_LOGE("TransactInstalldCmd failed");
419         return ret;
420     }
421     return ERR_OK;
422 }
423 
GetNativeLibraryFileNames(const std::string & filePath,const std::string & cpuAbi,std::vector<std::string> & fileNames)424 ErrCode InstalldProxy::GetNativeLibraryFileNames(const std::string &filePath, const std::string &cpuAbi,
425     std::vector<std::string> &fileNames)
426 {
427     MessageParcel data;
428     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
429     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(filePath));
430     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(cpuAbi));
431 
432     MessageParcel reply;
433     MessageOption option(MessageOption::TF_SYNC);
434     auto ret = TransactInstalldCmd(InstalldInterfaceCode::GET_NATIVE_LIBRARY_FILE_NAMES, data, reply, option);
435     if (ret != ERR_OK) {
436         APP_LOGE("TransactInstalldCmd failed");
437         return ret;
438     }
439     if (!reply.ReadStringVector(&fileNames)) {
440         APP_LOGE("ReadStringVector failed");
441         return ERR_APPEXECFWK_PARCEL_ERROR;
442     }
443     return ERR_OK;
444 }
445 
VerifyCodeSignature(const std::string & modulePath,const std::string & cpuAbi,const std::string & targetSoPath,const std::string & signatureFileDir)446 ErrCode InstalldProxy::VerifyCodeSignature(const std::string &modulePath, const std::string &cpuAbi,
447     const std::string &targetSoPath, const std::string &signatureFileDir)
448 {
449     MessageParcel data;
450     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
451     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(modulePath));
452     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(cpuAbi));
453     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(targetSoPath));
454     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(signatureFileDir));
455 
456     MessageParcel reply;
457     MessageOption option(MessageOption::TF_SYNC);
458     auto ret = TransactInstalldCmd(InstalldInterfaceCode::VERIFY_CODE_SIGNATURE, data, reply, option);
459     if (ret != ERR_OK) {
460         APP_LOGE("TransactInstalldCmd failed");
461         return ret;
462     }
463     return ERR_OK;
464 }
465 
MoveFiles(const std::string & srcDir,const std::string & desDir)466 ErrCode InstalldProxy::MoveFiles(const std::string &srcDir, const std::string &desDir)
467 {
468     MessageParcel data;
469     INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
470     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(srcDir));
471     INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(desDir));
472 
473     MessageParcel reply;
474     MessageOption option(MessageOption::TF_SYNC);
475     auto ret = TransactInstalldCmd(InstalldInterfaceCode::MOVE_FILES, data, reply, option);
476     if (ret != ERR_OK) {
477         APP_LOGE("TransactInstalldCmd failed");
478         return ret;
479     }
480     return ERR_OK;
481 }
482 
TransactInstalldCmd(InstalldInterfaceCode code,MessageParcel & data,MessageParcel & reply,MessageOption & option)483 ErrCode InstalldProxy::TransactInstalldCmd(InstalldInterfaceCode code, MessageParcel &data, MessageParcel &reply,
484     MessageOption &option)
485 {
486     sptr<IRemoteObject> remote = Remote();
487     if (remote == nullptr) {
488         APP_LOGE("fail to send %{public}u cmd to service due to remote object is null", code);
489         return ERR_APPEXECFWK_INSTALL_INSTALLD_SERVICE_ERROR;
490     }
491 
492     if (remote->SendRequest(static_cast<uint32_t>(code), data, reply, option) != OHOS::NO_ERROR) {
493         APP_LOGE("fail to send %{public}u request to service due to transact error", code);
494         return ERR_APPEXECFWK_INSTALL_INSTALLD_SERVICE_ERROR;
495     }
496     return reply.ReadInt32();
497 }
498 }  // namespace AppExecFwk
499 }  // namespace OHOS