• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #define LOG_TAG "KvStoreDataServiceMgr"
16 #include "kvstore_data_service_mgr.h"
17 #include "log_print.h"
18 #include "system_ability_definition.h"
19 #include "iservice_registry.h"
20 namespace OHOS::DistributedKv {
ClearAppStorage(const std::string & bundleName,int32_t userId,int32_t appIndex,int32_t tokenId)21 int32_t KvStoreDataServiceMgr::ClearAppStorage(const std::string &bundleName, int32_t userId, int32_t appIndex,
22     int32_t tokenId)
23 {
24     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
25     if (samgr == nullptr) {
26         ZLOGE("KvStoreDataServiceMgr get samgr fail.");
27         return ERROR;
28     }
29 
30     auto remote = samgr->CheckSystemAbility(DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID);
31     sptr<IKvStoreDataService> ability = iface_cast<IKvStoreDataService>(remote);
32     if (ability == nullptr) {
33         ZLOGE("KvStoreDataServiceMgr initialize proxy failed.");
34         return ERROR;
35     }
36     return ability->ClearAppStorage(bundleName, userId, appIndex, tokenId);
37 }
38 }
39