• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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 "installd_client.h"
17 
18 #include "bundle_constants.h"
19 #include "installd_death_recipient.h"
20 #include "system_ability_definition.h"
21 #include "system_ability_helper.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
CreateBundleDir(const std::string & bundleDir)25 ErrCode InstalldClient::CreateBundleDir(const std::string &bundleDir)
26 {
27     if (bundleDir.empty()) {
28         APP_LOGE("bundle dir is empty");
29         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
30     }
31 
32     return CallService(&IInstalld::CreateBundleDir, bundleDir);
33 }
34 
ExtractModuleFiles(const std::string & srcModulePath,const std::string & targetPath,const std::string & targetSoPath,const std::string & cpuAbi)35 ErrCode InstalldClient::ExtractModuleFiles(const std::string &srcModulePath, const std::string &targetPath,
36     const std::string &targetSoPath, const std::string &cpuAbi)
37 {
38     if (srcModulePath.empty() || targetPath.empty()) {
39         APP_LOGE("src module path or target path is empty");
40         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
41     }
42 
43     return CallService(&IInstalld::ExtractModuleFiles, srcModulePath, targetPath, targetSoPath, cpuAbi);
44 }
45 
ExtractFiles(const ExtractParam & extractParam)46 ErrCode InstalldClient::ExtractFiles(const ExtractParam &extractParam)
47 {
48     if (extractParam.srcPath.empty() || extractParam.targetPath.empty()) {
49         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
50     }
51     return CallService(&IInstalld::ExtractFiles, extractParam);
52 }
53 
ExtractHnpFiles(const std::string & hnpPackageInfo,const ExtractParam & extractParam)54 ErrCode InstalldClient::ExtractHnpFiles(const std::string &hnpPackageInfo, const ExtractParam &extractParam)
55 {
56     if (extractParam.srcPath.empty() || extractParam.targetPath.empty() || hnpPackageInfo.empty()) {
57         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
58     }
59     return CallService(&IInstalld::ExtractHnpFiles, hnpPackageInfo, extractParam);
60 }
61 
ProcessBundleInstallNative(const std::string & userId,const std::string & hnpRootPath,const std::string & hapPath,const std::string & cpuAbi,const std::string & packageName)62 ErrCode InstalldClient::ProcessBundleInstallNative(const std::string &userId, const std::string &hnpRootPath,
63     const std::string &hapPath, const std::string &cpuAbi, const std::string &packageName)
64 {
65     return CallService(&IInstalld::ProcessBundleInstallNative, userId, hnpRootPath,
66         hapPath, cpuAbi, packageName);
67 }
68 
ProcessBundleUnInstallNative(const std::string & userId,const std::string & packageName)69 ErrCode InstalldClient::ProcessBundleUnInstallNative(const std::string &userId, const std::string &packageName)
70 {
71     return CallService(&IInstalld::ProcessBundleUnInstallNative, userId, packageName);
72 }
73 
ExecuteAOT(const AOTArgs & aotArgs,std::vector<uint8_t> & pendSignData)74 ErrCode InstalldClient::ExecuteAOT(const AOTArgs &aotArgs, std::vector<uint8_t> &pendSignData)
75 {
76     return CallService(&IInstalld::ExecuteAOT, aotArgs, pendSignData);
77 }
78 
PendSignAOT(const std::string & anFileName,const std::vector<uint8_t> & signData)79 ErrCode InstalldClient::PendSignAOT(const std::string &anFileName, const std::vector<uint8_t> &signData)
80 {
81     return CallService(&IInstalld::PendSignAOT, anFileName, signData);
82 }
83 
StopAOT()84 ErrCode InstalldClient::StopAOT()
85 {
86     return CallService(&IInstalld::StopAOT);
87 }
88 
DeleteUninstallTmpDirs(const std::vector<std::string> & dirs)89 ErrCode InstalldClient::DeleteUninstallTmpDirs(const std::vector<std::string> &dirs)
90 {
91     return CallService(&IInstalld::DeleteUninstallTmpDirs, dirs);
92 }
93 
RenameModuleDir(const std::string & oldPath,const std::string & newPath)94 ErrCode InstalldClient::RenameModuleDir(const std::string &oldPath, const std::string &newPath)
95 {
96     if (oldPath.empty() || newPath.empty()) {
97         APP_LOGE("rename path is empty");
98         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
99     }
100 
101     return CallService(&IInstalld::RenameModuleDir, oldPath, newPath);
102 }
103 
CreateBundleDataDir(const CreateDirParam & createDirParam)104 ErrCode InstalldClient::CreateBundleDataDir(const CreateDirParam &createDirParam)
105 {
106     if (createDirParam.bundleName.empty() || createDirParam.userId < 0
107         || createDirParam.uid < 0 || createDirParam.gid < 0) {
108         APP_LOGE("params are invalid");
109         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
110     }
111 
112     return CallService(&IInstalld::CreateBundleDataDir, createDirParam);
113 }
114 
CreateBundleDataDirWithVector(const std::vector<CreateDirParam> & createDirParams)115 ErrCode InstalldClient::CreateBundleDataDirWithVector(const std::vector<CreateDirParam> &createDirParams)
116 {
117     return ERR_OK;
118 }
119 
RemoveBundleDataDir(const std::string & bundleName,const int userId,bool isAtomicService,const bool async)120 ErrCode InstalldClient::RemoveBundleDataDir(
121     const std::string &bundleName, const int userId, bool isAtomicService, const bool async)
122 {
123     if (bundleName.empty() || userId < 0) {
124         APP_LOGE("params are invalid");
125         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
126     }
127 
128     return CallService(&IInstalld::RemoveBundleDataDir, bundleName, userId, isAtomicService, async);
129 }
130 
RemoveModuleDataDir(const std::string & ModuleName,const int userid)131 ErrCode InstalldClient::RemoveModuleDataDir(const std::string &ModuleName, const int userid)
132 {
133     if (ModuleName.empty() || userid < 0) {
134         APP_LOGE("params are invalid");
135         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
136     }
137 
138     return CallService(&IInstalld::RemoveModuleDataDir, ModuleName, userid);
139 }
140 
RemoveDir(const std::string & dir)141 ErrCode InstalldClient::RemoveDir(const std::string &dir)
142 {
143     if (dir.empty()) {
144         APP_LOGE("dir removed is empty");
145         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
146     }
147 
148     return CallService(&IInstalld::RemoveDir, dir);
149 }
150 
CleanBundleDataDir(const std::string & bundleDir)151 ErrCode InstalldClient::CleanBundleDataDir(const std::string &bundleDir)
152 {
153     if (bundleDir.empty()) {
154         APP_LOGE("bundle dir is empty");
155         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
156     }
157 
158     return CallService(&IInstalld::CleanBundleDataDir, bundleDir);
159 }
160 
CleanBundleDataDirByName(const std::string & bundleName,const int userid,const int appIndex)161 ErrCode InstalldClient::CleanBundleDataDirByName(
162     const std::string &bundleName, const int userid, const int appIndex)
163 {
164     if (bundleName.empty() || userid < 0 || appIndex < 0 || appIndex > Constants::INITIAL_SANDBOX_APP_INDEX) {
165         APP_LOGE("params are invalid");
166         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
167     }
168 
169     return CallService(&IInstalld::CleanBundleDataDirByName, bundleName, userid, appIndex);
170 }
171 
GetBundleStats(const std::string & bundleName,const int32_t userId,std::vector<int64_t> & bundleStats,const int32_t uid,const int32_t appIndex,const uint32_t statFlag,const std::vector<std::string> & moduleNameList)172 ErrCode InstalldClient::GetBundleStats(const std::string &bundleName, const int32_t userId,
173     std::vector<int64_t> &bundleStats, const int32_t uid, const int32_t appIndex,
174     const uint32_t statFlag, const std::vector<std::string> &moduleNameList)
175 {
176     if (bundleName.empty()) {
177         APP_LOGE("bundleName is empty");
178         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
179     }
180     return CallService(&IInstalld::GetBundleStats, bundleName, userId, bundleStats,
181         uid, appIndex, statFlag, moduleNameList);
182 }
183 
GetAllBundleStats(const int32_t userId,std::vector<int64_t> & bundleStats,const std::vector<int32_t> & uids)184 ErrCode InstalldClient::GetAllBundleStats(const int32_t userId,
185     std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids)
186 {
187     if (uids.empty()) {
188         APP_LOGE("uids is empty");
189         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
190     }
191 
192     return CallService(&IInstalld::GetAllBundleStats, userId, bundleStats, uids);
193 }
194 
SetDirApl(const std::string & dir,const std::string & bundleName,const std::string & apl,bool isPreInstallApp,bool debug)195 ErrCode InstalldClient::SetDirApl(const std::string &dir, const std::string &bundleName, const std::string &apl,
196     bool isPreInstallApp, bool debug)
197 {
198     if (dir.empty() || bundleName.empty() || apl.empty()) {
199         APP_LOGE("params are invalid");
200         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
201     }
202 
203     return CallService(&IInstalld::SetDirApl, dir, bundleName, apl, isPreInstallApp, debug);
204 }
205 
GetBundleCachePath(const std::string & dir,std::vector<std::string> & cachePath)206 ErrCode InstalldClient::GetBundleCachePath(const std::string &dir, std::vector<std::string> &cachePath)
207 {
208     if (dir.empty()) {
209         APP_LOGE("params are invalid");
210         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
211     }
212 
213     return CallService(&IInstalld::GetBundleCachePath, dir, cachePath);
214 }
215 
ResetInstalldProxy()216 void InstalldClient::ResetInstalldProxy()
217 {
218     std::lock_guard<std::mutex> lock(mutex_);
219     if ((installdProxy_ != nullptr) && (installdProxy_->AsObject() != nullptr)) {
220         installdProxy_->AsObject()->RemoveDeathRecipient(recipient_);
221     }
222     installdProxy_ = nullptr;
223 }
224 
GetInstalldProxy()225 sptr<IInstalld> InstalldClient::GetInstalldProxy()
226 {
227     std::lock_guard<std::mutex> lock(mutex_);
228     if (installdProxy_ == nullptr) {
229         sptr<IInstalld> tempProxy =
230             iface_cast<IInstalld>(SystemAbilityHelper::GetSystemAbility(INSTALLD_SERVICE_ID));
231         if ((tempProxy == nullptr) || (tempProxy->AsObject() == nullptr)) {
232             APP_LOGE("the installd proxy or remote object is null");
233             return nullptr;
234         }
235         recipient_ = new (std::nothrow) InstalldDeathRecipient();
236         if (recipient_ == nullptr) {
237             APP_LOGE("the death recipient is nullptr");
238             return nullptr;
239         }
240         tempProxy->AsObject()->AddDeathRecipient(recipient_);
241         installdProxy_ = tempProxy;
242     }
243     return installdProxy_;
244 }
245 
ScanDir(const std::string & dir,ScanMode scanMode,ResultMode resultMode,std::vector<std::string> & paths)246 ErrCode InstalldClient::ScanDir(
247     const std::string &dir, ScanMode scanMode, ResultMode resultMode, std::vector<std::string> &paths)
248 {
249     if (dir.empty()) {
250         APP_LOGE("params are invalid");
251         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
252     }
253 
254     return CallService(&IInstalld::ScanDir, dir, scanMode, resultMode, paths);
255 }
256 
MoveFile(const std::string & oldPath,const std::string & newPath)257 ErrCode InstalldClient::MoveFile(const std::string &oldPath, const std::string &newPath)
258 {
259     if (oldPath.empty() || newPath.empty()) {
260         APP_LOGE("params are invalid");
261         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
262     }
263 
264     return CallService(&IInstalld::MoveFile, oldPath, newPath);
265 }
266 
CopyFile(const std::string & oldPath,const std::string & newPath,const std::string & signatureFilePath)267 ErrCode InstalldClient::CopyFile(const std::string &oldPath, const std::string &newPath,
268     const std::string &signatureFilePath)
269 {
270     if (oldPath.empty() || newPath.empty()) {
271         APP_LOGE("params are invalid");
272         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
273     }
274 
275     return CallService(&IInstalld::CopyFile, oldPath, newPath, signatureFilePath);
276 }
277 
Mkdir(const std::string & dir,const int32_t mode,const int32_t uid,const int32_t gid)278 ErrCode InstalldClient::Mkdir(
279     const std::string &dir, const int32_t mode, const int32_t uid, const int32_t gid)
280 {
281     if (dir.empty()) {
282         APP_LOGE("params are invalid");
283         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
284     }
285 
286     return CallService(&IInstalld::Mkdir, dir, mode, uid, gid);
287 }
288 
GetFileStat(const std::string & file,FileStat & fileStat)289 ErrCode InstalldClient::GetFileStat(const std::string &file, FileStat &fileStat)
290 {
291     if (file.empty()) {
292         APP_LOGE("params are invalid");
293         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
294     }
295 
296     return CallService(&IInstalld::GetFileStat, file, fileStat);
297 }
298 
ExtractDiffFiles(const std::string & filePath,const std::string & targetPath,const std::string & cpuAbi)299 ErrCode InstalldClient::ExtractDiffFiles(const std::string &filePath, const std::string &targetPath,
300     const std::string &cpuAbi)
301 {
302     if (filePath.empty() || targetPath.empty() || cpuAbi.empty()) {
303         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
304     }
305     return CallService(&IInstalld::ExtractDiffFiles, filePath, targetPath, cpuAbi);
306 }
307 
ApplyDiffPatch(const std::string & oldSoPath,const std::string & diffFilePath,const std::string & newSoPath,int32_t uid)308 ErrCode InstalldClient::ApplyDiffPatch(const std::string &oldSoPath, const std::string &diffFilePath,
309     const std::string &newSoPath, int32_t uid)
310 {
311     if (oldSoPath.empty() || diffFilePath.empty() || newSoPath.empty()) {
312         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
313     }
314     return CallService(&IInstalld::ApplyDiffPatch, oldSoPath, diffFilePath, newSoPath, uid);
315 }
316 
IsExistDir(const std::string & dir,bool & isExist)317 ErrCode InstalldClient::IsExistDir(const std::string &dir, bool &isExist)
318 {
319     return CallService(&IInstalld::IsExistDir, dir, isExist);
320 }
321 
IsExistFile(const std::string & path,bool & isExist)322 ErrCode InstalldClient::IsExistFile(const std::string &path, bool &isExist)
323 {
324     return CallService(&IInstalld::IsExistFile, path, isExist);
325 }
326 
IsExistApFile(const std::string & path,bool & isExist)327 ErrCode InstalldClient::IsExistApFile(const std::string &path, bool &isExist)
328 {
329     return CallService(&IInstalld::IsExistApFile, path, isExist);
330 }
331 
IsDirEmpty(const std::string & dir,bool & isDirEmpty)332 ErrCode InstalldClient::IsDirEmpty(const std::string &dir, bool &isDirEmpty)
333 {
334     return CallService(&IInstalld::IsDirEmpty, dir, isDirEmpty);
335 }
336 
ObtainQuickFixFileDir(const std::string & dir,std::vector<std::string> & dirVec)337 ErrCode InstalldClient::ObtainQuickFixFileDir(const std::string &dir, std::vector<std::string> &dirVec)
338 {
339     return CallService(&IInstalld::ObtainQuickFixFileDir, dir, dirVec);
340 }
341 
CopyFiles(const std::string & sourceDir,const std::string & destinationDir)342 ErrCode InstalldClient::CopyFiles(const std::string &sourceDir, const std::string &destinationDir)
343 {
344     return CallService(&IInstalld::CopyFiles, sourceDir, destinationDir);
345 }
346 
GetNativeLibraryFileNames(const std::string & filePath,const std::string & cpuAbi,std::vector<std::string> & fileNames)347 ErrCode InstalldClient::GetNativeLibraryFileNames(const std::string &filePath, const std::string &cpuAbi,
348     std::vector<std::string> &fileNames)
349 {
350     return CallService(&IInstalld::GetNativeLibraryFileNames, filePath, cpuAbi, fileNames);
351 }
352 
VerifyCodeSignature(const CodeSignatureParam & codeSignatureParam)353 ErrCode InstalldClient::VerifyCodeSignature(const CodeSignatureParam &codeSignatureParam)
354 {
355     if (codeSignatureParam.modulePath.empty()) {
356         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
357     }
358     return CallService(&IInstalld::VerifyCodeSignature, codeSignatureParam);
359 }
360 
CheckEncryption(const CheckEncryptionParam & checkEncryptionParam,bool & isEncryption)361 ErrCode InstalldClient::CheckEncryption(const CheckEncryptionParam &checkEncryptionParam, bool &isEncryption)
362 {
363     if (checkEncryptionParam.modulePath.empty()) {
364         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
365     }
366     return CallService(&IInstalld::CheckEncryption, checkEncryptionParam, isEncryption);
367 }
368 
MoveFiles(const std::string & srcDir,const std::string & desDir)369 ErrCode InstalldClient::MoveFiles(const std::string &srcDir, const std::string &desDir)
370 {
371     if (srcDir.empty() || desDir.empty()) {
372         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
373     }
374     return CallService(&IInstalld::MoveFiles, srcDir, desDir);
375 }
376 
ExtractDriverSoFiles(const std::string & srcPath,const std::unordered_multimap<std::string,std::string> & dirMap)377 ErrCode InstalldClient::ExtractDriverSoFiles(const std::string &srcPath,
378     const std::unordered_multimap<std::string, std::string> &dirMap)
379 {
380     if (srcPath.empty() || dirMap.empty()) {
381         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
382     }
383     return CallService(&IInstalld::ExtractDriverSoFiles, srcPath, dirMap);
384 }
385 
ExtractEncryptedSoFiles(const std::string & hapPath,const std::string & realSoFilesPath,const std::string & cpuAbi,const std::string & tmpSoPath,int32_t uid)386 ErrCode InstalldClient::ExtractEncryptedSoFiles(const std::string &hapPath, const std::string &realSoFilesPath,
387     const std::string &cpuAbi, const std::string &tmpSoPath, int32_t uid)
388 {
389     if (hapPath.empty() || tmpSoPath.empty() || cpuAbi.empty()) {
390         APP_LOGE("params are invalid");
391         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
392     }
393     return CallService(&IInstalld::ExtractEncryptedSoFiles, hapPath, realSoFilesPath, cpuAbi, tmpSoPath, uid);
394 }
395 
VerifyCodeSignatureForHap(const CodeSignatureParam & codeSignatureParam)396 ErrCode InstalldClient::VerifyCodeSignatureForHap(const CodeSignatureParam &codeSignatureParam)
397 {
398     if (codeSignatureParam.modulePath.empty()) {
399         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
400     }
401     return CallService(&IInstalld::VerifyCodeSignatureForHap, codeSignatureParam);
402 }
403 
DeliverySignProfile(const std::string & bundleName,int32_t profileBlockLength,const unsigned char * profileBlock)404 ErrCode InstalldClient::DeliverySignProfile(const std::string &bundleName, int32_t profileBlockLength,
405     const unsigned char *profileBlock)
406 {
407     if (bundleName.empty() || profileBlock == nullptr) {
408         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
409     }
410     return CallService(&IInstalld::DeliverySignProfile, bundleName, profileBlockLength, profileBlock);
411 }
412 
RemoveSignProfile(const std::string & bundleName)413 ErrCode InstalldClient::RemoveSignProfile(const std::string &bundleName)
414 {
415     if (bundleName.empty()) {
416         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
417     }
418     return CallService(&IInstalld::RemoveSignProfile, bundleName);
419 }
420 
SetEncryptionPolicy(const EncryptionParam & encryptionParam,std::string & keyId)421 ErrCode InstalldClient::SetEncryptionPolicy(const EncryptionParam &encryptionParam, std::string &keyId)
422 {
423     if (encryptionParam.bundleName.empty() && encryptionParam.groupId.empty()) {
424         APP_LOGE("bundleName is empty");
425         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
426     }
427     return CallService(&IInstalld::SetEncryptionPolicy, encryptionParam, keyId);
428 }
429 
RemoveExtensionDir(int32_t userId,const std::vector<std::string> & extensionBundleDirs)430 ErrCode InstalldClient::RemoveExtensionDir(int32_t userId, const std::vector<std::string> &extensionBundleDirs)
431 {
432     if (extensionBundleDirs.empty() || userId < 0) {
433         APP_LOGE("extensionBundleDirs is empty or userId is invalid");
434         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
435     }
436     return CallService(&IInstalld::RemoveExtensionDir, userId, extensionBundleDirs);
437 }
438 
IsExistExtensionDir(int32_t userId,const std::string & extensionBundleDir,bool & isExist)439 ErrCode InstalldClient::IsExistExtensionDir(int32_t userId, const std::string &extensionBundleDir, bool &isExist)
440 {
441     if (extensionBundleDir.empty() || userId < 0) {
442         APP_LOGE("extensionBundleDir is empty or userId is invalid");
443         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
444     }
445     return CallService(&IInstalld::IsExistExtensionDir, userId, extensionBundleDir, isExist);
446 }
447 
CreateExtensionDataDir(const CreateDirParam & createDirParam)448 ErrCode InstalldClient::CreateExtensionDataDir(const CreateDirParam &createDirParam)
449 {
450     if (createDirParam.bundleName.empty() || createDirParam.userId < 0
451         || createDirParam.uid < 0 || createDirParam.gid < 0 || createDirParam.extensionDirs.empty()) {
452         APP_LOGE("params are invalid");
453         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
454     }
455 
456     return CallService(&IInstalld::CreateExtensionDataDir, createDirParam);
457 }
458 
DeleteEncryptionKeyId(const EncryptionParam & encryptionParam)459 ErrCode InstalldClient::DeleteEncryptionKeyId(const EncryptionParam &encryptionParam)
460 {
461     if (encryptionParam.bundleName.empty() && encryptionParam.groupId.empty()) {
462         APP_LOGE("param error");
463         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
464     }
465     return CallService(&IInstalld::DeleteEncryptionKeyId, encryptionParam);
466 }
467 
StartInstalldService()468 bool InstalldClient::StartInstalldService()
469 {
470     return GetInstalldProxy() != nullptr;
471 }
472 
GetExtensionSandboxTypeList(std::vector<std::string> & typeList)473 ErrCode InstalldClient::GetExtensionSandboxTypeList(std::vector<std::string> &typeList)
474 {
475     return CallService(&IInstalld::GetExtensionSandboxTypeList, typeList);
476 }
477 
AddUserDirDeleteDfx(int32_t userId)478 ErrCode InstalldClient::AddUserDirDeleteDfx(int32_t userId)
479 {
480     return CallService(&IInstalld::AddUserDirDeleteDfx, userId);
481 }
482 
GetDiskUsage(const std::string & dir,int64_t & statSize,bool isRealPath)483 ErrCode InstalldClient::GetDiskUsage(const std::string& dir, int64_t &statSize, bool isRealPath)
484 {
485     if (dir.empty()) {
486         APP_LOGE("dir is empty");
487         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
488     }
489     return CallService(&IInstalld::GetDiskUsage, dir, statSize, isRealPath);
490 }
491 
MigrateData(const std::vector<std::string> & sourcePaths,const std::string & destinationPath)492 ErrCode InstalldClient::MigrateData(const std::vector<std::string> &sourcePaths, const std::string &destinationPath)
493 {
494     if (sourcePaths.empty()) {
495         return ERR_BUNDLE_MANAGER_MIGRATE_DATA_SOURCE_PATH_INVALID;
496     }
497     if (destinationPath.empty()) {
498         return ERR_BUNDLE_MANAGER_MIGRATE_DATA_DESTINATION_PATH_INVALID;
499     }
500     return CallService(&IInstalld::MigrateData, sourcePaths, destinationPath);
501 }
502 
GetDiskUsageFromPath(const std::vector<std::string> & path,int64_t & statSize)503 ErrCode InstalldClient::GetDiskUsageFromPath(const std::vector<std::string> &path, int64_t &statSize)
504 {
505     if (path.empty()) {
506         APP_LOGE("path is empty");
507         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
508     }
509     return CallService(&IInstalld::GetDiskUsageFromPath, path, statSize);
510 }
511 
MoveHapToCodeDir(const std::string & originPath,const std::string & targetPath)512 ErrCode InstalldClient::MoveHapToCodeDir(const std::string &originPath, const std::string &targetPath)
513 {
514     if (originPath.empty() || targetPath.empty()) {
515         APP_LOGE("params are invalid");
516         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
517     }
518 
519     return CallService(&IInstalld::MoveHapToCodeDir, originPath, targetPath);
520 }
521 
CreateDataGroupDirs(const std::vector<CreateDirParam> & params)522 ErrCode InstalldClient::CreateDataGroupDirs(const std::vector<CreateDirParam> &params)
523 {
524     if (params.empty()) {
525         APP_LOGE("params are invalid");
526         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
527     }
528     return CallService(&IInstalld::CreateDataGroupDirs, params);
529 }
530 
DeleteDataGroupDirs(const std::vector<std::string> & uuidList,int32_t userId)531 ErrCode InstalldClient::DeleteDataGroupDirs(const std::vector<std::string> &uuidList, int32_t userId)
532 {
533     if (uuidList.empty() || userId < 0) {
534         APP_LOGE("params are invalid");
535         return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
536     }
537     return CallService(&IInstalld::DeleteDataGroupDirs, uuidList, userId);
538 }
539 
BackUpFirstBootLog()540 ErrCode InstalldClient::BackUpFirstBootLog()
541 {
542     return CallService(&IInstalld::BackUpFirstBootLog);
543 }
544 }  // namespace AppExecFwk
545 }  // namespace OHOS
546