卸载应用后通知接续图标消失

Signed-off-by: MisterE <smart_e@126.com>
This commit is contained in:
MisterE 2024-09-23 17:59:08 +08:00
commit 96a76aa0d3
3 changed files with 43 additions and 1 deletions

View File

@ -84,6 +84,7 @@ public:
int32_t RegisterOffListener(const std::string& type, const sptr<IRemoteObject>& obj);
void NotifyDied(const sptr<IRemoteObject>& obj);
void NotifyDeviceOffline(const std::string& networkId);
void NotifyPackageRemove(const std::string& sinkBundleName);
void OnDeviceScreenOff();
void OnContinueSwitchOff();
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);
break;
case PACKAGE_REMOVED :
HILOGI("PACKAGE_REMOVED");
HILOGI("PACKAGE_REMOVED: %{public}s", want.GetElement().GetBundleName().c_str());
DmsBmStorage::GetInstance()->DeleteStorageDistributeInfo(want.GetElement().GetBundleName());
DMSContinueRecvMgr::GetInstance().NotifyPackageRemove(want.GetElement().GetBundleName());
break;
default:
HILOGW("OnReceiveEvent undefined action");

View File

@ -561,6 +561,46 @@ void DMSContinueRecvMgr::NotifyDeviceOffline(const std::string& networkId)
HILOGI("NotifyDeviceOffline end");
}
void DMSContinueRecvMgr::NotifyPackageRemove(const std::string& sinkBundleName)
{
if (sinkBundleName.empty()) {
HILOGE("NotifyPackageRemove sinkBundleName empty");
return;
}
if(iconInfo_.bundleName != sinkBundleName) {
return;
}
HILOGI("NotifyPackageRemove 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("NotifyPackageRemove end");
}
std::string DMSContinueRecvMgr::GetContinueType(const std::string& bundleName)
{
std::lock_guard<std::mutex> currentIconLock(iconMutex_);