diff --git a/services/distributeddataservice/app/src/kvstore_data_service.cpp b/services/distributeddataservice/app/src/kvstore_data_service.cpp index 978953627f3955b3e40e2ebf526da53412099333..e9ef6ca75806e62e2efd52bb0fc6f54eea790dc1 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.cpp +++ b/services/distributeddataservice/app/src/kvstore_data_service.cpp @@ -25,6 +25,7 @@ #include #include +#include "accesstoken_kit.h" #include "auth_delegate.h" #include "auto_launch_export.h" #include "bootstrap.h" @@ -35,6 +36,7 @@ #include "dds_trace.h" #include "device_kvstore_impl.h" #include "executor_factory.h" +#include "hap_token_info.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" #include "kvstore_account_observer.h" @@ -61,6 +63,7 @@ namespace OHOS::DistributedKv { using json = nlohmann::json; using namespace std::chrono; using namespace OHOS::DistributedData; +using namespace Security::AccessToken; using KvStoreDelegateManager = DistributedDB::KvStoreDelegateManager; REGISTER_SYSTEM_ABILITY_BY_ID(KvStoreDataService, DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID, true); @@ -650,6 +653,14 @@ Status KvStoreDataService::AppExit(const AppId &appId, pid_t uid, uint32_t token // memory of parameter appId locates in a member of clientDeathObserverMap_ and will be freed after // clientDeathObserverMap_ erase, so we have to take a copy if we want to use this parameter after erase operation. AppId appIdTmp = appId; + + if (appId.appId == "com.ohos.medialibrary.MediaLibraryDataA") { + HapTokenInfo tokenInfo; + AccessTokenKit::GetHapTokenInfo(token, tokenInfo); + ZLOGI("not close bundle:%{public}s, tokenInfo.bundle:%{public}s, uid:%{public}d, token:%{public}u", + appId.appId.c_str(), tokenInfo.bundleName.c_str(), uid, token); + return Status::SUCCESS; + } std::lock_guard lg(clientDeathObserverMutex_); clientDeathObserverMap_.erase(token); diff --git a/services/distributeddataservice/app/test/BUILD.gn b/services/distributeddataservice/app/test/BUILD.gn index fc20044f249dc3cc030e89055a285c6a5aaaae0f..298cda146242487b322d8a5ba103f6aad5bdad38 100644 --- a/services/distributeddataservice/app/test/BUILD.gn +++ b/services/distributeddataservice/app/test/BUILD.gn @@ -87,6 +87,7 @@ ohos_unittest("KvStoreImplLogicalIsolationTest") { configs = [ ":module_private_config" ] external_deps = [ + "access_token:libaccesstoken_sdk", "dataclassification:data_transit_mgr", "deviceauth_standard:deviceauth_sdk", "hiviewdfx_hilog_native:libhilog", @@ -152,6 +153,7 @@ ohos_unittest("KvStoreImplPhysicalIsolationTest") { configs = [ ":module_private_config" ] external_deps = [ + "access_token:libaccesstoken_sdk", "dataclassification:data_transit_mgr", "deviceauth_standard:deviceauth_sdk", "hiviewdfx_hilog_native:libhilog", @@ -217,6 +219,7 @@ ohos_unittest("KvStoreDataServiceTest") { configs = [ ":module_private_config" ] external_deps = [ + "access_token:libaccesstoken_sdk", "dataclassification:data_transit_mgr", "deviceauth_standard:deviceauth_sdk", "hiviewdfx_hilog_native:libhilog", @@ -284,6 +287,7 @@ ohos_unittest("KvStoreBackupTest") { configs = [ ":module_private_config" ] external_deps = [ + "access_token:libaccesstoken_sdk", "dataclassification:data_transit_mgr", "deviceauth_standard:deviceauth_sdk", "hiviewdfx_hilog_native:libhilog", @@ -325,6 +329,7 @@ ohos_unittest("KvStoreFlowCtrlManagerTest") { configs = [ ":module_private_config" ] external_deps = [ + "access_token:libaccesstoken_sdk", "dataclassification:data_transit_mgr", "deviceauth_standard:deviceauth_sdk", "hiviewdfx_hilog_native:libhilog", @@ -384,6 +389,7 @@ ohos_unittest("KvStoreSyncManagerTest") { configs = [ ":module_private_config" ] external_deps = [ + "access_token:libaccesstoken_sdk", "dataclassification:data_transit_mgr", "deviceauth_standard:deviceauth_sdk", "hiviewdfx_hilog_native:libhilog", @@ -466,6 +472,7 @@ ohos_unittest("KvStoreUninstallerTest") { external_deps = [ "ability_base:base", "ability_base:want", + "access_token:libaccesstoken_sdk", "dataclassification:data_transit_mgr", "deviceauth_standard:deviceauth_sdk", "hiviewdfx_hilog_native:libhilog",