mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 06:20:07 +00:00
commit
8386097070
@ -73,7 +73,7 @@ public:
|
|||||||
int32_t CloudSync();
|
int32_t CloudSync();
|
||||||
void FindProvishionInfo(OHOS::sptr<OHOS::AppExecFwk::IBundleMgr> bundleMgr,
|
void FindProvishionInfo(OHOS::sptr<OHOS::AppExecFwk::IBundleMgr> bundleMgr,
|
||||||
AppExecFwk::AppProvisionInfo appProvisionInfo, std::vector<AccountSA::OsAccountInfo> accounts,
|
AppExecFwk::AppProvisionInfo appProvisionInfo, std::vector<AccountSA::OsAccountInfo> accounts,
|
||||||
uint32_t result, const std::string& bundleName);
|
int32_t result, const std::string& bundleName);
|
||||||
void DmsPutBatch(const std::vector<DmsBundleInfo> &dmsBundleInfos);
|
void DmsPutBatch(const std::vector<DmsBundleInfo> &dmsBundleInfos);
|
||||||
bool UpdatePublicRecords(const std::string &localUdid);
|
bool UpdatePublicRecords(const std::string &localUdid);
|
||||||
bool DelDataOfLogoutDev(const std::string &udid, const std::string &uuid);
|
bool DelDataOfLogoutDev(const std::string &udid, const std::string &uuid);
|
||||||
|
@ -84,6 +84,7 @@ public:
|
|||||||
int32_t RegisterOffListener(const std::string& type, const sptr<IRemoteObject>& obj);
|
int32_t RegisterOffListener(const std::string& type, const sptr<IRemoteObject>& obj);
|
||||||
void NotifyDied(const sptr<IRemoteObject>& obj);
|
void NotifyDied(const sptr<IRemoteObject>& obj);
|
||||||
void NotifyDeviceOffline(const std::string& networkId);
|
void NotifyDeviceOffline(const std::string& networkId);
|
||||||
|
void NotifyPackageRemoved(const std::string& sinkBundleName);
|
||||||
void OnDeviceScreenOff();
|
void OnDeviceScreenOff();
|
||||||
void OnContinueSwitchOff();
|
void OnContinueSwitchOff();
|
||||||
std::string GetContinueType(const std::string& bundleName);
|
std::string GetContinueType(const std::string& bundleName);
|
||||||
|
@ -292,7 +292,7 @@ bool BundleManagerInternal::GetAppProvisionInfo4CurrentUser(const std::string &b
|
|||||||
HILOGE("Get userId from active Os AccountIds fail, ret : %{public}d", ret);
|
HILOGE("Get userId from active Os AccountIds fail, ret : %{public}d", ret);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint32_t result = bundleMgr->GetAppProvisionInfo(bundleName, ids[0], appProvisionInfo);
|
ErrCode result = bundleMgr->GetAppProvisionInfo(bundleName, ids[0], appProvisionInfo);
|
||||||
HILOGI("find dst bundle name for diff bundle continue. dst developer id: %{public}s; ",
|
HILOGI("find dst bundle name for diff bundle continue. dst developer id: %{public}s; ",
|
||||||
GetAnonymStr(appProvisionInfo.developerId).c_str());
|
GetAnonymStr(appProvisionInfo.developerId).c_str());
|
||||||
return result == ERR_OK;
|
return result == ERR_OK;
|
||||||
|
@ -81,8 +81,9 @@ void CommonEventListener::OnReceiveEvent(const EventFwk::CommonEventData &eventD
|
|||||||
DmsBmStorage::GetInstance()->SaveStorageDistributeInfo(want.GetElement().GetBundleName(), true);
|
DmsBmStorage::GetInstance()->SaveStorageDistributeInfo(want.GetElement().GetBundleName(), true);
|
||||||
break;
|
break;
|
||||||
case PACKAGE_REMOVED :
|
case PACKAGE_REMOVED :
|
||||||
HILOGI("PACKAGE_REMOVED");
|
HILOGI("PACKAGE_REMOVED: %{public}s", want.GetElement().GetBundleName().c_str());
|
||||||
DmsBmStorage::GetInstance()->DeleteStorageDistributeInfo(want.GetElement().GetBundleName());
|
DmsBmStorage::GetInstance()->DeleteStorageDistributeInfo(want.GetElement().GetBundleName());
|
||||||
|
DMSContinueRecvMgr::GetInstance().NotifyPackageRemoved(want.GetElement().GetBundleName());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
HILOGW("OnReceiveEvent undefined action");
|
HILOGW("OnReceiveEvent undefined action");
|
||||||
|
@ -109,7 +109,7 @@ bool DmsBmStorage::SaveStorageDistributeInfo(const std::string &bundleName, bool
|
|||||||
|
|
||||||
AppExecFwk::AppProvisionInfo appProvisionInfo;
|
AppExecFwk::AppProvisionInfo appProvisionInfo;
|
||||||
std::vector<AccountSA::OsAccountInfo> accounts;
|
std::vector<AccountSA::OsAccountInfo> accounts;
|
||||||
uint32_t result = AccountSA::OsAccountManager::QueryAllCreatedOsAccounts(accounts);
|
ErrCode result = AccountSA::OsAccountManager::QueryAllCreatedOsAccounts(accounts);
|
||||||
if (result == ERR_OK && !accounts.empty()) {
|
if (result == ERR_OK && !accounts.empty()) {
|
||||||
for (auto &account: accounts) {
|
for (auto &account: accounts) {
|
||||||
result = bundleMgr->GetAppProvisionInfo(bundleName, account.GetLocalId(), appProvisionInfo);
|
result = bundleMgr->GetAppProvisionInfo(bundleName, account.GetLocalId(), appProvisionInfo);
|
||||||
@ -442,10 +442,12 @@ bool DmsBmStorage::GetDistributedBundleInfo(const std::string &networkId,
|
|||||||
if (reduRiskEntries.size() > 1) {
|
if (reduRiskEntries.size() > 1) {
|
||||||
HILOGE("Redundant data needs to be deleted.");
|
HILOGE("Redundant data needs to be deleted.");
|
||||||
DelReduData(networkId, reduRiskEntries);
|
DelReduData(networkId, reduRiskEntries);
|
||||||
|
distributeBundleInfo = DmsBundleInfo();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (remoteEntries.empty()) {
|
if (reduRiskEntries.empty()) {
|
||||||
HILOGE("get distributedBundleInfo failed.");
|
HILOGE("get distributedBundleInfo failed.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
HILOGI("end.");
|
HILOGI("end.");
|
||||||
return true;
|
return true;
|
||||||
@ -746,7 +748,7 @@ int32_t DmsBmStorage::CloudSync()
|
|||||||
|
|
||||||
void DmsBmStorage::FindProvishionInfo(OHOS::sptr<OHOS::AppExecFwk::IBundleMgr> bundleMgr,
|
void DmsBmStorage::FindProvishionInfo(OHOS::sptr<OHOS::AppExecFwk::IBundleMgr> bundleMgr,
|
||||||
AppExecFwk::AppProvisionInfo appProvisionInfo, std::vector<AccountSA::OsAccountInfo> accounts,
|
AppExecFwk::AppProvisionInfo appProvisionInfo, std::vector<AccountSA::OsAccountInfo> accounts,
|
||||||
uint32_t result, const std::string& bundleName)
|
int32_t result, const std::string& bundleName)
|
||||||
{
|
{
|
||||||
if (result == ERR_OK && !accounts.empty()) {
|
if (result == ERR_OK && !accounts.empty()) {
|
||||||
for (auto &account: accounts) {
|
for (auto &account: accounts) {
|
||||||
@ -782,7 +784,7 @@ void DmsBmStorage::UpdateDistributedData()
|
|||||||
|
|
||||||
AppExecFwk::AppProvisionInfo appProvisionInfo;
|
AppExecFwk::AppProvisionInfo appProvisionInfo;
|
||||||
std::vector<AccountSA::OsAccountInfo> accounts;
|
std::vector<AccountSA::OsAccountInfo> accounts;
|
||||||
uint32_t result = AccountSA::OsAccountManager::QueryAllCreatedOsAccounts(accounts);
|
int32_t result = AccountSA::OsAccountManager::QueryAllCreatedOsAccounts(accounts);
|
||||||
|
|
||||||
std::vector<DmsBundleInfo> dmsBundleInfos;
|
std::vector<DmsBundleInfo> dmsBundleInfos;
|
||||||
for (const auto &bundleInfo: bundleInfos) {
|
for (const auto &bundleInfo: bundleInfos) {
|
||||||
|
@ -561,6 +561,48 @@ void DMSContinueRecvMgr::NotifyDeviceOffline(const std::string& networkId)
|
|||||||
HILOGI("NotifyDeviceOffline end");
|
HILOGI("NotifyDeviceOffline end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DMSContinueRecvMgr::NotifyPackageRemoved(const std::string& sinkBundleName)
|
||||||
|
{
|
||||||
|
if (sinkBundleName.empty()) {
|
||||||
|
HILOGE("NotifyPackageRemoved sinkBundleName empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (iconInfo_.bundleName != sinkBundleName) {
|
||||||
|
HILOGI("NotifyPackageRemoved current sinkBundleName: %{public}s; removed package: %{public}s.",
|
||||||
|
iconInfo_.bundleName.c_str(), sinkBundleName.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HILOGI("NotifyPackageRemoved begin. sinkBundleName: %{public}s.", sinkBundleName.c_str());
|
||||||
|
std::string senderNetworkId;
|
||||||
|
std::string bundleName;
|
||||||
|
std::string continueType;
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> currentIconLock(iconMutex_);
|
||||||
|
senderNetworkId = iconInfo_.senderNetworkId;
|
||||||
|
bundleName = iconInfo_.bundleName;
|
||||||
|
continueType = iconInfo_.continueType;
|
||||||
|
iconInfo_.senderNetworkId = "";
|
||||||
|
iconInfo_.bundleName = "";
|
||||||
|
iconInfo_.continueType = "";
|
||||||
|
}
|
||||||
|
HILOGI("Saved iconInfo cleared, sinkBundleName: %{public}s.", bundleName.c_str());
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> registerOnListenerMapLock(eventMutex_);
|
||||||
|
auto iterItem = registerOnListener_.find(onType_);
|
||||||
|
if (iterItem == registerOnListener_.end()) {
|
||||||
|
HILOGI("Get iterItem failed from registerOnListener_, nobody registed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::vector<sptr<IRemoteObject>> objs = iterItem->second;
|
||||||
|
for (auto iter : objs) {
|
||||||
|
NotifyRecvBroadcast(iter,
|
||||||
|
currentIconInfo(senderNetworkId, iconInfo_.sourceBundleName, bundleName, continueType),
|
||||||
|
INACTIVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HILOGI("NotifyPackageRemoved end");
|
||||||
|
}
|
||||||
|
|
||||||
std::string DMSContinueRecvMgr::GetContinueType(const std::string& bundleName)
|
std::string DMSContinueRecvMgr::GetContinueType(const std::string& bundleName)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> currentIconLock(iconMutex_);
|
std::lock_guard<std::mutex> currentIconLock(iconMutex_);
|
||||||
|
@ -686,6 +686,55 @@ HWTEST_F(DMSContinueManagerTest, testNotifyDeviceOffline003, TestSize.Level1)
|
|||||||
DTEST_LOG << "DMSContinueManagerTest testNotifyDeviceOffline003 end" << std::endl;
|
DTEST_LOG << "DMSContinueManagerTest testNotifyDeviceOffline003 end" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: NotifyPackageRemoved001
|
||||||
|
* @tc.desc: test NotifyPackageRemoved normal
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DMSContinueManagerTest, notifyPackageRemoved001, TestSize.Level1)
|
||||||
|
{
|
||||||
|
DTEST_LOG << "DMSContinueManagerTest notifyPackageRemoved001 start" << std::endl;
|
||||||
|
sptr<IRemoteObject> obj01(new RemoteOnListenerStubTest());
|
||||||
|
DMSContinueRecvMgr::GetInstance().RegisterOnListener(TYPE, obj01);
|
||||||
|
EXPECT_NE(DMSContinueRecvMgr::GetInstance().registerOnListener_.size(), 0);
|
||||||
|
|
||||||
|
DMSContinueRecvMgr::GetInstance().iconInfo_.bundleName = BUNDLENAME_01;
|
||||||
|
DMSContinueRecvMgr::GetInstance().NotifyPackageRemoved(BUNDLENAME_01);
|
||||||
|
EXPECT_EQ(DMSContinueRecvMgr::GetInstance().iconInfo_.bundleName, "");
|
||||||
|
|
||||||
|
DTEST_LOG << "DMSContinueManagerTest notifyPackageRemoved001 end" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: NotifyPackageRemoved002
|
||||||
|
* @tc.desc: test NotifyPackageRemoved bundleName empty
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DMSContinueManagerTest, notifyPackageRemoved002, TestSize.Level1)
|
||||||
|
{
|
||||||
|
DTEST_LOG << "DMSContinueManagerTest notifyPackageRemoved002 start" << std::endl;
|
||||||
|
DMSContinueRecvMgr::GetInstance().iconInfo_.bundleName = BUNDLENAME_01;
|
||||||
|
DMSContinueRecvMgr::GetInstance().NotifyPackageRemoved("");
|
||||||
|
EXPECT_EQ(DMSContinueRecvMgr::GetInstance().iconInfo_.bundleName, BUNDLENAME_01);
|
||||||
|
|
||||||
|
DTEST_LOG << "DMSContinueManagerTest notifyPackageRemoved002 end" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: NotifyPackageRemoved003
|
||||||
|
* @tc.desc: test NotifyPackageRemoved bundleName not match
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DMSContinueManagerTest, notifyPackageRemoved003, TestSize.Level1)
|
||||||
|
{
|
||||||
|
DTEST_LOG << "DMSContinueManagerTest notifyPackageRemoved003 start" << std::endl;
|
||||||
|
DMSContinueRecvMgr::GetInstance().iconInfo_.bundleName = BUNDLENAME_01;
|
||||||
|
DMSContinueRecvMgr::GetInstance().NotifyPackageRemoved(BUNDLENAME_02);
|
||||||
|
EXPECT_EQ(DMSContinueRecvMgr::GetInstance().iconInfo_.bundleName, BUNDLENAME_01);
|
||||||
|
|
||||||
|
DTEST_LOG << "DMSContinueManagerTest notifyPackageRemoved003 end" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @tc.name: testNotifyDataRecv001
|
* @tc.name: testNotifyDataRecv001
|
||||||
* @tc.desc: NotifyDataRecv
|
* @tc.desc: NotifyDataRecv
|
||||||
|
Loading…
Reference in New Issue
Block a user