!1179 appId校验及应用卸载使接续图标消失合入商分

Merge pull request !1179 from 皇甫毅/OpenHarmony-5.0.1-Release
This commit is contained in:
openharmony_ci 2024-11-19 06:48:57 +00:00 committed by Gitee
commit f5b8c1cbb8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 95 additions and 2 deletions

View File

@ -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);

View File

@ -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");

View File

@ -898,7 +898,7 @@ int32_t DSchedContinue::PackDataCmd(std::shared_ptr<DSchedContinueDataCmd>& cmd,
int32_t DSchedContinue::CheckStartPermission(std::shared_ptr<DSchedContinueDataCmd> cmd) int32_t DSchedContinue::CheckStartPermission(std::shared_ptr<DSchedContinueDataCmd> cmd)
{ {
if (cmd->srcBundleName_ == cmd->dstBundleName_) { if (cmd->srcBundleName_ == cmd->dstBundleName_) {
return DistributedSchedService::GetInstance().CheckTargetPermission4DiffBundle(cmd->want_, cmd->callerInfo_, return DistributedSchedService::GetInstance().CheckTargetPermission(cmd->want_, cmd->callerInfo_,
cmd->accountInfo_, START_PERMISSION, true); cmd->accountInfo_, START_PERMISSION, true);
} else { } else {
if (!BundleManagerInternal::IsSameDeveloperId(cmd->dstBundleName_, cmd->srcDeveloperId_)) { if (!BundleManagerInternal::IsSameDeveloperId(cmd->dstBundleName_, cmd->srcDeveloperId_)) {

View File

@ -575,6 +575,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_);

View File

@ -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