mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 06:20:07 +00:00
!962 delete data sync perm for collaboration
Merge pull request !962 from 仝月姣/master
This commit is contained in:
commit
3f77882ca7
@ -1097,6 +1097,9 @@ void DistributedWant::RemoveParam(const std::string& key)
|
||||
|
||||
void DistributedWant::ClearWant(DistributedWant* want)
|
||||
{
|
||||
if (want == nullptr) {
|
||||
return;
|
||||
}
|
||||
want->SetType("");
|
||||
want->SetAction("");
|
||||
want->SetFlags(0);
|
||||
|
@ -1110,6 +1110,9 @@ bool DistributedWantParams::ReadFromParcelWantParamWrapper(Parcel& parcel, const
|
||||
bool DistributedWantParams::ReadFromParcelFD(Parcel& parcel, const std::string& key)
|
||||
{
|
||||
auto messageParcel = static_cast<MessageParcel*>(&parcel);
|
||||
if (messageParcel == nullptr) {
|
||||
return false;
|
||||
}
|
||||
auto fd = messageParcel->ReadFileDescriptor();
|
||||
DistributedWantParams wp;
|
||||
wp.SetParam(TYPE_PROPERTY, AAFwk::String::Box(FD));
|
||||
@ -1122,6 +1125,9 @@ bool DistributedWantParams::ReadFromParcelFD(Parcel& parcel, const std::string&
|
||||
bool DistributedWantParams::ReadFromParcelRemoteObject(Parcel& parcel, const std::string& key)
|
||||
{
|
||||
auto messageParcel = static_cast<MessageParcel*>(&parcel);
|
||||
if (messageParcel == nullptr) {
|
||||
return false;
|
||||
}
|
||||
auto remoteObject = messageParcel->ReadRemoteObject();
|
||||
DistributedWantParams wp;
|
||||
wp.SetParam(TYPE_PROPERTY, AAFwk::String::Box(REMOTE_OBJECT));
|
||||
|
@ -61,7 +61,6 @@ const std::string TAG = "DistributedSchedStub";
|
||||
const std::u16string DMS_STUB_INTERFACE_TOKEN = u"ohos.distributedschedule.accessToken";
|
||||
const std::string EXTRO_INFO_JSON_KEY_ACCESS_TOKEN = "accessTokenID";
|
||||
const std::string EXTRO_INFO_JSON_KEY_REQUEST_CODE = "requestCode";
|
||||
const std::string PERMISSION_DISTRIBUTED_DATASYNC = "ohos.permission.DISTRIBUTED_DATASYNC";
|
||||
const std::string PARAM_FREEINSTALL_APPID = "ohos.freeinstall.params.callingAppId";
|
||||
const std::string PARAM_FREEINSTALL_BUNDLENAMES = "ohos.freeinstall.params.callingBundleNames";
|
||||
const std::string CMPT_PARAM_FREEINSTALL_BUNDLENAMES = "ohos.extra.param.key.allowedBundles";
|
||||
@ -256,11 +255,6 @@ int32_t DistributedSchedStub::StartRemoteAbilityInner(MessageParcel& data, Messa
|
||||
uint32_t accessToken = 0;
|
||||
PARCEL_READ_HELPER(data, Uint32, accessToken);
|
||||
HILOGD("get callerUid = %{public}d, AccessTokenID = %{private}u", callerUid, accessToken);
|
||||
if (DistributedSchedPermission::GetInstance().CheckPermission(accessToken,
|
||||
PERMISSION_DISTRIBUTED_DATASYNC) != ERR_OK) {
|
||||
HILOGE("check data_sync permission failed!");
|
||||
return DMS_PERMISSION_DENIED;
|
||||
}
|
||||
DistributedSchedPermission::GetInstance().MarkUriPermission(*want, accessToken);
|
||||
int32_t result = StartRemoteAbility(*want, callerUid, requestCode, accessToken);
|
||||
ReportEvent(*want, BehaviorEvent::START_REMOTE_ABILITY, result, callerUid);
|
||||
@ -723,11 +717,6 @@ int32_t DistributedSchedStub::ConnectRemoteAbilityInner(MessageParcel& data, Mes
|
||||
PARCEL_READ_HELPER(data, Uint32, accessToken);
|
||||
HILOGD("get callerUid = %{public}d, callerPid = %{public}d, AccessTokenID = %{private}u", callerUid, callerPid,
|
||||
accessToken);
|
||||
if (DistributedSchedPermission::GetInstance().CheckPermission(accessToken,
|
||||
PERMISSION_DISTRIBUTED_DATASYNC) != ERR_OK) {
|
||||
HILOGE("check data_sync permission failed!");
|
||||
return DMS_PERMISSION_DENIED;
|
||||
}
|
||||
int32_t result = ConnectRemoteAbility(*want, connect, callerUid, callerPid, accessToken);
|
||||
ReportEvent(*want, BehaviorEvent::CONNECT_REMOTE_ABILITY, result, callerUid);
|
||||
HILOGI("result = %{public}d", result);
|
||||
@ -747,11 +736,6 @@ int32_t DistributedSchedStub::DisconnectRemoteAbilityInner(MessageParcel& data,
|
||||
uint32_t accessToken = 0;
|
||||
PARCEL_READ_HELPER(data, Uint32, accessToken);
|
||||
HILOGD("get callerUid = %{public}d, AccessTokenID = %{private}u", callerUid, accessToken);
|
||||
if (DistributedSchedPermission::GetInstance().CheckPermission(accessToken,
|
||||
PERMISSION_DISTRIBUTED_DATASYNC) != ERR_OK) {
|
||||
HILOGE("check data_sync permission failed!");
|
||||
return DMS_PERMISSION_DENIED;
|
||||
}
|
||||
int32_t result = DisconnectRemoteAbility(connect, callerUid, accessToken);
|
||||
BehaviorEventParam eventParam = { EventCallingType::LOCAL, BehaviorEvent::DISCONNECT_REMOTE_ABILITY, result };
|
||||
DmsHiSysEventReport::ReportBehaviorEvent(eventParam);
|
||||
@ -1252,11 +1236,6 @@ int32_t DistributedSchedStub::StartRemoteAbilityByCallInner(MessageParcel& data,
|
||||
PARCEL_READ_HELPER(data, Int32, callerPid);
|
||||
uint32_t accessToken = 0;
|
||||
PARCEL_READ_HELPER(data, Uint32, accessToken);
|
||||
if (DistributedSchedPermission::GetInstance().CheckPermission(accessToken,
|
||||
PERMISSION_DISTRIBUTED_DATASYNC) != ERR_OK) {
|
||||
HILOGE("check data_sync permission failed!");
|
||||
return DMS_PERMISSION_DENIED;
|
||||
}
|
||||
int32_t result = StartRemoteAbilityByCall(*want, connect, callerUid, callerPid, accessToken);
|
||||
ReportEvent(*want, BehaviorEvent::START_REMOTE_ABILITY_BYCALL, result, callerUid);
|
||||
HILOGI("result = %{public}d", result);
|
||||
@ -1455,11 +1434,6 @@ int32_t DistributedSchedStub::StartRemoteFreeInstallInner(MessageParcel& data, M
|
||||
HILOGE("read callback failed!");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
if (DistributedSchedPermission::GetInstance().CheckPermission(accessToken,
|
||||
PERMISSION_DISTRIBUTED_DATASYNC) != ERR_OK) {
|
||||
HILOGE("check data_sync permission failed!");
|
||||
return DMS_PERMISSION_DENIED;
|
||||
}
|
||||
int32_t result = StartRemoteFreeInstall(*want, callerUid, requestCode, accessToken, callback);
|
||||
HILOGI("result = %{public}d", result);
|
||||
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
|
||||
@ -1571,11 +1545,6 @@ int32_t DistributedSchedStub::StopRemoteExtensionAbilityInner(MessageParcel& dat
|
||||
int32_t serviceType = 0;
|
||||
PARCEL_READ_HELPER(data, Int32, serviceType);
|
||||
HILOGD("get callerUid = %{private}d, AccessTokenID = %{private}u", callerUid, accessToken);
|
||||
if (DistributedSchedPermission::GetInstance().CheckPermission(accessToken,
|
||||
PERMISSION_DISTRIBUTED_DATASYNC) != ERR_OK) {
|
||||
HILOGE("check data_sync permission failed!");
|
||||
return DMS_PERMISSION_DENIED;
|
||||
}
|
||||
auto result = StopRemoteExtensionAbility(*want, callerUid, accessToken, serviceType);
|
||||
HILOGD("StartRemoteAbilityInner result = %{public}d", result);
|
||||
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
|
||||
|
@ -33,7 +33,6 @@ using namespace OHOS::Security;
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
const std::string TAG = "DmsTokenCallback";
|
||||
const std::string PERMISSION_DISTRIBUTED_DATASYNC = "ohos.permission.DISTRIBUTED_DATASYNC";
|
||||
const std::string FOUNDATION_PROCESS_NAME = "foundation";
|
||||
const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId";
|
||||
|
||||
|
@ -359,6 +359,10 @@ bool DmsBmStorage::CheckSyncData(const std::string &networkId)
|
||||
}
|
||||
HILOGE("uuid: %{public}s", GetAnonymStr(uuid).c_str());
|
||||
std::vector<Entry> newEntries;
|
||||
if (kvStorePtr_ == nullptr) {
|
||||
HILOGE("kvstore is null");
|
||||
return false;
|
||||
}
|
||||
Status status = kvStorePtr_->GetDeviceEntries(uuid, newEntries);
|
||||
if (newEntries.empty() || status != Status::SUCCESS) {
|
||||
HILOGE("CheckSyncData fail: %{public}d", status);
|
||||
@ -402,6 +406,10 @@ void DmsBmStorage::GetEntries(const std::string &networkId, const Key &allEntryK
|
||||
std::promise<OHOS::DistributedKv::Status> &resultStatusSignal, std::vector<Entry> &allEntries)
|
||||
{
|
||||
HILOGI("called.");
|
||||
if (kvStorePtr_ == nullptr) {
|
||||
HILOGE("kvstore is null");
|
||||
return;
|
||||
}
|
||||
kvStorePtr_->GetEntries(allEntryKeyPrefix, networkId,
|
||||
[&resultStatusSignal, &allEntries](Status innerStatus, std::vector<Entry> innerAllEntries) {
|
||||
HILOGI("GetEntries, result = %{public}d", innerStatus);
|
||||
|
@ -59,7 +59,7 @@ bool PublicRecordsInfo::Marshalling(Parcel &parcel) const
|
||||
PublicRecordsInfo *PublicRecordsInfo::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
PublicRecordsInfo *info = new (std::nothrow) PublicRecordsInfo();
|
||||
if (info && !info->ReadFromParcel(parcel)) {
|
||||
if (info != nullptr && !info->ReadFromParcel(parcel)) {
|
||||
APP_LOGW("read from parcel failed");
|
||||
delete info;
|
||||
info = nullptr;
|
||||
@ -152,7 +152,7 @@ bool DmsAbilityInfo::Marshalling(Parcel &parcel) const
|
||||
DmsAbilityInfo *DmsAbilityInfo::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
DmsAbilityInfo *info = new (std::nothrow) DmsAbilityInfo();
|
||||
if (info && !info->ReadFromParcel(parcel)) {
|
||||
if (info != nullptr && !info->ReadFromParcel(parcel)) {
|
||||
APP_LOGW("read from parcel failed");
|
||||
delete info;
|
||||
info = nullptr;
|
||||
@ -270,7 +270,7 @@ bool DmsBundleInfo::Marshalling(Parcel &parcel) const
|
||||
DmsBundleInfo *DmsBundleInfo::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
DmsBundleInfo *info = new (std::nothrow) DmsBundleInfo();
|
||||
if (info && !info->ReadFromParcel(parcel)) {
|
||||
if (info != nullptr && !info->ReadFromParcel(parcel)) {
|
||||
delete info;
|
||||
info = nullptr;
|
||||
}
|
||||
|
@ -383,6 +383,10 @@ int32_t DistributedSchedMissionManager::StartSyncRemoteMissions(const std::strin
|
||||
int32_t DistributedSchedMissionManager::StartSyncRemoteMissions(const std::string& dstDevId,
|
||||
const sptr<IDistributedSched>& remoteDms)
|
||||
{
|
||||
if (remoteDms == nullptr) {
|
||||
HILOGE("remoteDms is null");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
std::vector<DstbMissionInfo> missionInfos;
|
||||
CallerInfo callerInfo;
|
||||
if (!GenerateCallerInfo(callerInfo)) {
|
||||
@ -523,7 +527,7 @@ int32_t DistributedSchedMissionManager::StartSyncMissionsFromRemote(const Caller
|
||||
InitAllSnapshots(missionInfoSet);
|
||||
}
|
||||
};
|
||||
if (!missionHandler_->PostTask(func)) {
|
||||
if (missionHandler_ != nullptr && !missionHandler_->PostTask(func)) {
|
||||
HILOGE("post RegisterMissionListener and InitAllSnapshots Task failed");
|
||||
}
|
||||
return result;
|
||||
@ -542,7 +546,7 @@ void DistributedSchedMissionManager::StopSyncMissionsFromRemote(const std::strin
|
||||
isRegMissionChange_ = false;
|
||||
}
|
||||
};
|
||||
if (!missionHandler_->PostTask(func)) {
|
||||
if (missionHandler_ != nullptr && !missionHandler_->PostTask(func)) {
|
||||
HILOGE("post UnRegisterMissionListener Task failed");
|
||||
}
|
||||
}
|
||||
@ -618,6 +622,10 @@ void DistributedSchedMissionManager::EnqueueCachedSnapshotInfo(const std::string
|
||||
std::string keyInfo = GenerateKeyInfo(deviceId, missionId);
|
||||
auto iter = cachedSnapshotInfos_.find(keyInfo);
|
||||
if (iter != cachedSnapshotInfos_.end()) {
|
||||
if (iter->second == nullptr) {
|
||||
HILOGE("snapshotInfo is null");
|
||||
return;
|
||||
}
|
||||
if (snapshot->GetCreatedTime() < iter->second->GetCreatedTime()) {
|
||||
return;
|
||||
}
|
||||
@ -627,6 +635,10 @@ void DistributedSchedMissionManager::EnqueueCachedSnapshotInfo(const std::string
|
||||
int64_t oldest = -1;
|
||||
auto iterOldest = cachedSnapshotInfos_.end();
|
||||
for (auto iterItem = cachedSnapshotInfos_.begin(); iterItem != cachedSnapshotInfos_.end(); ++iterItem) {
|
||||
if (iterItem->second == nullptr) {
|
||||
HILOGE("snapshotInfo is null");
|
||||
continue;
|
||||
}
|
||||
if (oldest == -1 || iterItem->second->GetLastAccessTime() < oldest) {
|
||||
oldest = iterItem->second->GetLastAccessTime();
|
||||
iterOldest = iterItem;
|
||||
@ -650,6 +662,10 @@ std::unique_ptr<Snapshot> DistributedSchedMissionManager::DequeueCachedSnapshotI
|
||||
auto iter = cachedSnapshotInfos_.find(GenerateKeyInfo(deviceId, missionId));
|
||||
if (iter != cachedSnapshotInfos_.end()) {
|
||||
std::unique_ptr<Snapshot> snapshot = std::move(iter->second);
|
||||
if (snapshot == nullptr) {
|
||||
HILOGE("snapshot is null");
|
||||
return nullptr;
|
||||
}
|
||||
snapshot->UpdateLastAccessTime(GetTickCount());
|
||||
iter->second = nullptr;
|
||||
cachedSnapshotInfos_.erase(iter);
|
||||
@ -778,6 +794,10 @@ void DistributedSchedMissionManager::NotifyLocalMissionsChanged()
|
||||
HILOGI("NotifyMissionsChangedToRemote result = %{public}d", result);
|
||||
}
|
||||
};
|
||||
if (missionChangeHandler_ == nullptr) {
|
||||
HILOGE("missionChangeHandler_ is null");
|
||||
return;
|
||||
}
|
||||
if (!missionChangeHandler_->PostTask(func)) {
|
||||
HILOGE("postTask failed");
|
||||
}
|
||||
@ -792,6 +812,10 @@ void DistributedSchedMissionManager::NotifyMissionSnapshotCreated(int32_t missio
|
||||
HILOGE("mission snapshot changed failed, missionId=%{public}d, errCode=%{public}d", missionId, errCode);
|
||||
}
|
||||
};
|
||||
if (missionChangeHandler_ == nullptr) {
|
||||
HILOGE("missionChangeHandler_ is null");
|
||||
return;
|
||||
}
|
||||
if (!missionChangeHandler_->PostTask(func, GET_FOREGROUND_SNAPSHOT_DELAY_TIME)) {
|
||||
HILOGE("post MissionSnapshotChanged delay Task failed");
|
||||
}
|
||||
@ -806,6 +830,10 @@ void DistributedSchedMissionManager::NotifyMissionSnapshotChanged(int32_t missio
|
||||
HILOGE("mission snapshot changed failed, missionId=%{public}d, errCode=%{public}d", missionId, errCode);
|
||||
}
|
||||
};
|
||||
if (missionChangeHandler_ == nullptr) {
|
||||
HILOGE("missionChangeHandler_ is null");
|
||||
return;
|
||||
}
|
||||
if (!missionChangeHandler_->PostTask(func)) {
|
||||
HILOGE("post MissionSnapshotChanged Task failed");
|
||||
}
|
||||
@ -820,6 +848,10 @@ void DistributedSchedMissionManager::NotifyMissionSnapshotDestroyed(int32_t miss
|
||||
HILOGE("mission snapshot removed failed, missionId=%{public}d, errCode=%{public}d", missionId, errCode);
|
||||
}
|
||||
};
|
||||
if (missionChangeHandler_ == nullptr) {
|
||||
HILOGE("missionChangeHandler_ is null");
|
||||
return;
|
||||
}
|
||||
if (!missionChangeHandler_->PostTask(func)) {
|
||||
HILOGE("post MissionSnapshotDestroyed Task failed");
|
||||
}
|
||||
@ -964,7 +996,9 @@ void DistributedSchedMissionManager::OnMissionListenerDied(const sptr<IRemoteObj
|
||||
++iterItem;
|
||||
continue;
|
||||
}
|
||||
remote->RemoveDeathRecipient(listenerDeath_);
|
||||
if (remote != nullptr) {
|
||||
remote->RemoveDeathRecipient(listenerDeath_);
|
||||
}
|
||||
listenerInfo.Erase(remote);
|
||||
if (listenerInfo.Empty()) {
|
||||
if (listenerInfo.called) {
|
||||
@ -988,7 +1022,7 @@ void DistributedSchedMissionManager::OnRemoteDmsDied(const sptr<IRemoteObject>&
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(remoteDmsLock_);
|
||||
for (auto iter = remoteDmsMap_.begin(); iter != remoteDmsMap_.end(); ++iter) {
|
||||
if (iter->second->AsObject() == remote) {
|
||||
if (iter->second->AsObject() == remote && iter->second->AsObject() != nullptr) {
|
||||
iter->second->AsObject()->RemoveDeathRecipient(remoteDmsRecipient_);
|
||||
devId = iter->first;
|
||||
remoteDmsMap_.erase(iter);
|
||||
|
@ -72,7 +72,7 @@ void DMSContinueRecvMgr::Init()
|
||||
void DMSContinueRecvMgr::UnInit()
|
||||
{
|
||||
HILOGI("UnInit start");
|
||||
if (eventHandler_ != nullptr) {
|
||||
if (eventHandler_ != nullptr && eventHandler_->GetEventRunner() != nullptr) {
|
||||
eventHandler_->GetEventRunner()->Stop();
|
||||
eventThread_.join();
|
||||
eventHandler_ = nullptr;
|
||||
@ -191,7 +191,11 @@ void DMSContinueRecvMgr::StartEvent()
|
||||
eventHandler_ = std::make_shared<OHOS::AppExecFwk::EventHandler>(runner);
|
||||
}
|
||||
eventCon_.notify_one();
|
||||
runner->Run();
|
||||
if (runner != nullptr) {
|
||||
runner->Run();
|
||||
} else {
|
||||
HILOGE("runner is null");
|
||||
}
|
||||
HILOGI("StartEvent end");
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ void DMSContinueSendMgr::UnInit()
|
||||
{
|
||||
HILOGI("UnInit start");
|
||||
MMIAdapter::GetInstance().UnInit();
|
||||
if (eventHandler_ != nullptr) {
|
||||
if (eventHandler_ != nullptr && eventHandler_->GetEventRunner() != nullptr) {
|
||||
eventHandler_->GetEventRunner()->Stop();
|
||||
eventThread_.join();
|
||||
eventHandler_ = nullptr;
|
||||
@ -96,14 +96,20 @@ void DMSContinueSendMgr::UnInit()
|
||||
int32_t DMSContinueSendMgr::GetCurrentMissionId()
|
||||
{
|
||||
HILOGI("GetCurrentMission begin");
|
||||
auto abilityMgr = AAFwk::AbilityManagerClient::GetInstance();
|
||||
if (abilityMgr == nullptr) {
|
||||
HILOGE("abilityMgr is nullptr");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> token;
|
||||
int ret = AAFwk::AbilityManagerClient::GetInstance()->GetTopAbility(token);
|
||||
int ret = abilityMgr->GetTopAbility(token);
|
||||
if (ret != ERR_OK || token == nullptr) {
|
||||
HILOGE("GetTopAbility failed, ret: %{public}d", ret);
|
||||
return INVALID_MISSION_ID;
|
||||
}
|
||||
int32_t missionId = INVALID_MISSION_ID;
|
||||
AAFwk::AbilityManagerClient::GetInstance()->GetMissionIdByToken(token, missionId);
|
||||
abilityMgr->GetMissionIdByToken(token, missionId);
|
||||
return missionId;
|
||||
}
|
||||
|
||||
@ -142,7 +148,7 @@ void DMSContinueSendMgr::NotifyMissionFocused(const int32_t missionId, FocusedRe
|
||||
return;
|
||||
}
|
||||
auto feedfunc = [this, missionId, reason]() {
|
||||
if (reason == FocusedReason::NORMAL) {
|
||||
if (reason == FocusedReason::NORMAL && screenOffHandler_ != nullptr) {
|
||||
screenOffHandler_->ClearScreenOffInfo();
|
||||
}
|
||||
DealFocusedBusiness(missionId);
|
||||
@ -190,7 +196,7 @@ int32_t DMSContinueSendMgr::GetMissionIdByBundleName(const std::string& bundleNa
|
||||
return ERR_OK;
|
||||
}
|
||||
HILOGW("get iterItem failed from focusedMission_, try screenOffHandler_");
|
||||
if (bundleName == screenOffHandler_->GetBundleName()) {
|
||||
if (screenOffHandler_ != nullptr && bundleName == screenOffHandler_->GetBundleName()) {
|
||||
missionId = screenOffHandler_->GetMissionId();
|
||||
HILOGI("get missionId end, missionId: %{public}d", missionId);
|
||||
return ERR_OK;
|
||||
@ -209,7 +215,11 @@ void DMSContinueSendMgr::StartEvent()
|
||||
eventHandler_ = std::make_shared<OHOS::AppExecFwk::EventHandler>(runner);
|
||||
}
|
||||
eventCon_.notify_one();
|
||||
runner->Run();
|
||||
if (runner != nullptr) {
|
||||
runner->Run();
|
||||
} else {
|
||||
HILOGE("runner is null");
|
||||
}
|
||||
HILOGI("StartEvent end");
|
||||
}
|
||||
|
||||
@ -260,10 +270,16 @@ int32_t DMSContinueSendMgr::DealFocusedBusiness(const int32_t missionId)
|
||||
{
|
||||
HILOGI("DealFocusedBusiness start, missionId: %{public}d", missionId);
|
||||
AAFwk::MissionInfo info;
|
||||
int32_t ret = AAFwk::AbilityManagerClient::GetInstance()->GetMissionInfo("", missionId, info);
|
||||
if (ret != ERR_OK) {
|
||||
HILOGE("get missionInfo failed, missionId: %{public}d, ret: %{public}d", missionId, ret);
|
||||
return ret;
|
||||
auto abilityMgr = AAFwk::AbilityManagerClient::GetInstance();
|
||||
if (abilityMgr != nullptr) {
|
||||
int32_t ret = abilityMgr->GetMissionInfo("", missionId, info);
|
||||
if (ret != ERR_OK) {
|
||||
HILOGE("get missionInfo failed, missionId: %{public}d, ret: %{public}d", missionId, ret);
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
HILOGE("abilityMgr is null");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
bool isMissionContinuable = info.continuable;
|
||||
{
|
||||
@ -295,7 +311,7 @@ int32_t DMSContinueSendMgr::DealFocusedBusiness(const int32_t missionId)
|
||||
AddMMIListener();
|
||||
#endif
|
||||
if (!SwitchStatusDependency::GetInstance().IsContinueSwitchOn()) { return DMS_PERMISSION_DENIED;}
|
||||
ret = FocusedBusinessSendEvent(bundleName, abilityName);
|
||||
int32_t ret = FocusedBusinessSendEvent(bundleName, abilityName);
|
||||
HILOGI("DealFocusedBusiness end");
|
||||
return ret;
|
||||
}
|
||||
@ -327,8 +343,14 @@ int32_t DMSContinueSendMgr::FocusedBusinessSendEvent(std::string bundleName, con
|
||||
|
||||
int32_t DMSContinueSendMgr::CheckContinueState(const int32_t missionId)
|
||||
{
|
||||
auto abilityMgr = AAFwk::AbilityManagerClient::GetInstance();
|
||||
if (abilityMgr == nullptr) {
|
||||
HILOGE("abilityMgr is null");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
|
||||
AAFwk::MissionInfo info;
|
||||
int32_t ret = AAFwk::AbilityManagerClient::GetInstance()->GetMissionInfo("", missionId, info);
|
||||
int32_t ret = abilityMgr->GetMissionInfo("", missionId, info);
|
||||
if (ret != ERR_OK) {
|
||||
HILOGE("get missionInfo failed, missionId: %{public}d, ret: %{public}d", missionId, ret);
|
||||
return ERR_OK;
|
||||
@ -390,7 +412,7 @@ int32_t DMSContinueSendMgr::DealUnfocusedBusiness(const int32_t missionId, Unfoc
|
||||
focusedMissionAbility_.erase(missionId);
|
||||
}
|
||||
|
||||
if (reason == UnfocusedReason::NORMAL) {
|
||||
if (reason == UnfocusedReason::NORMAL && screenOffHandler_ != nullptr) {
|
||||
screenOffHandler_->SetScreenOffInfo(missionId, bundleName, bundleNameId, abilityName);
|
||||
}
|
||||
HILOGI("DealUnfocusedBusiness end");
|
||||
@ -399,6 +421,10 @@ int32_t DMSContinueSendMgr::DealUnfocusedBusiness(const int32_t missionId, Unfoc
|
||||
|
||||
int32_t DMSContinueSendMgr::SendScreenOffEvent(uint8_t type)
|
||||
{
|
||||
if (screenOffHandler_ == nullptr) {
|
||||
HILOGE("screenOffHandler_ is nullptr");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
int32_t missionId = screenOffHandler_->GetMissionId();
|
||||
std::string bundleName = screenOffHandler_->GetBundleName();
|
||||
uint16_t bundleNameId = screenOffHandler_->GetAccessTokenId();
|
||||
@ -455,7 +481,7 @@ int32_t DMSContinueSendMgr::GetAbilityNameByMissionId(const int32_t missionId, s
|
||||
return ERR_OK;
|
||||
}
|
||||
HILOGW("get iterItem failed from focusedMissionAbility_, try screenOffHandler_");
|
||||
if (missionId == screenOffHandler_->GetMissionId()) {
|
||||
if (screenOffHandler_ != nullptr && missionId == screenOffHandler_->GetMissionId()) {
|
||||
abilityName = screenOffHandler_->GetAbilityName();
|
||||
HILOGI("get missionId end, abilityName: %{public}s", abilityName.c_str());
|
||||
return ERR_OK;
|
||||
@ -606,7 +632,9 @@ void DMSContinueSendMgr::OnDeviceScreenOff()
|
||||
}
|
||||
int32_t missionId = info_.currentMissionId;
|
||||
auto feedfunc = [this, missionId]() {
|
||||
screenOffHandler_->OnDeviceScreenOff(missionId);
|
||||
if (screenOffHandler_ != nullptr) {
|
||||
screenOffHandler_->OnDeviceScreenOff(missionId);
|
||||
}
|
||||
};
|
||||
if (eventHandler_ == nullptr) {
|
||||
HILOGE("eventHandler_ is nullptr");
|
||||
@ -619,7 +647,9 @@ void DMSContinueSendMgr::OnDeviceScreenOn()
|
||||
{
|
||||
HILOGI("OnDeviceScreenOn called");
|
||||
auto feedfunc = [this]() {
|
||||
screenOffHandler_->OnDeviceScreenOn();
|
||||
if (screenOffHandler_ != nullptr) {
|
||||
screenOffHandler_->OnDeviceScreenOn();
|
||||
}
|
||||
};
|
||||
if (eventHandler_ == nullptr) {
|
||||
HILOGE("eventHandler_ is nullptr");
|
||||
@ -709,7 +739,7 @@ int32_t DMSContinueSendMgr::GetAccessTokenIdSendEvent(std::string bundleName,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (screenOffHandler_->IsDeviceScreenOn()) {
|
||||
if (screenOffHandler_ != nullptr && screenOffHandler_->IsDeviceScreenOn()) {
|
||||
ret = SendSoftbusEvent(bundleNameId, continueTypeId, DMS_UNFOCUSED_TYPE);
|
||||
bool res = (reason != UnfocusedReason::TIMEOUT)
|
||||
? DmsRadar::GetInstance().NormalUnfocusedSendEventRes("SendSoftbusEvent", ret)
|
||||
|
@ -59,6 +59,9 @@ int32_t SnapshotConverter::ConvertToSnapshot(AAFwk::MissionSnapshot& missionSnap
|
||||
int32_t SnapshotConverter::ConvertToSnapshot(AAFwk::MissionSnapshot& missionSnapshot,
|
||||
std::unique_ptr<Snapshot>& snapshot)
|
||||
{
|
||||
if (snapshot == nullptr) {
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
snapshot->version_ = DMS_VERSION;
|
||||
snapshot->orientation_ = 0;
|
||||
std::unique_ptr<Rect> contentInsets = std::make_unique<Rect>(0, 0, 0, 0);
|
||||
@ -92,8 +95,10 @@ int32_t SnapshotConverter::ConvertToSnapshot(AAFwk::MissionSnapshot& missionSnap
|
||||
int32_t SnapshotConverter::ConvertToMissionSnapshot(Snapshot& snapshot,
|
||||
std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot)
|
||||
{
|
||||
missionSnapshot->snapshot = snapshot.pixelMap_;
|
||||
if (missionSnapshot != nullptr) {
|
||||
missionSnapshot->snapshot = snapshot.pixelMap_;
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
||||
|
@ -58,6 +58,10 @@ int32_t SoftbusAdapter::StopSoftbusEvent()
|
||||
static void EventListenerReceived(const EventNotify *eventNotify)
|
||||
{
|
||||
HILOGD("called.");
|
||||
if (eventNotify == nullptr) {
|
||||
HILOGE("eventNotify is null");
|
||||
return;
|
||||
}
|
||||
std::string networkId(eventNotify->senderNetworkId);
|
||||
SoftbusAdapter::GetInstance().OnBroadCastRecv(networkId, eventNotify->data, eventNotify->dataLen);
|
||||
}
|
||||
|
@ -76,6 +76,10 @@ bool DSchedSoftbusSession::OnDisconnect()
|
||||
int32_t DSchedSoftbusSession::OnBytesReceived(std::shared_ptr<DSchedDataBuffer> buffer)
|
||||
{
|
||||
HILOGD("called");
|
||||
if (buffer == nullptr) {
|
||||
HILOGE("buffer is null");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
PackRecvData(buffer);
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -83,6 +87,10 @@ int32_t DSchedSoftbusSession::OnBytesReceived(std::shared_ptr<DSchedDataBuffer>
|
||||
int32_t DSchedSoftbusSession::SendData(std::shared_ptr<DSchedDataBuffer> buffer, int32_t dataType)
|
||||
{
|
||||
HILOGD("called");
|
||||
if (buffer == nullptr) {
|
||||
HILOGE("buffer is null");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
UnPackSendData(buffer, dataType);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -106,10 +106,13 @@ int32_t DSchedTransportSoftbusAdapter::ConnectDevice(const std::string &peerDevi
|
||||
HILOGI("try to connect peer: %{public}s.", GetAnonymStr(peerDeviceId).c_str());
|
||||
{
|
||||
std::lock_guard<std::mutex> sessionLock(sessionMutex_);
|
||||
if (!sessions_.empty()) {
|
||||
for (auto iter = sessions_.begin(); iter != sessions_.end(); iter++) {
|
||||
if (iter->second != nullptr && peerDeviceId == iter->second->GetPeerDeviceId()) {
|
||||
HILOGI("peer device already connected");
|
||||
if (sessions_.empty()) {
|
||||
return INVALID_SESSION_ID;
|
||||
}
|
||||
for (auto iter = sessions_.begin(); iter != sessions_.end(); iter++) {
|
||||
if (iter->second != nullptr && peerDeviceId == iter->second->GetPeerDeviceId()) {
|
||||
HILOGI("peer device already connected");
|
||||
if (sessions_[iter->first] != nullptr) {
|
||||
sessions_[iter->first]->OnConnect();
|
||||
return iter->first;
|
||||
}
|
||||
@ -194,7 +197,7 @@ void DSchedTransportSoftbusAdapter::DisconnectDevice(const std::string &peerDevi
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sessionId != 0 && sessions_[sessionId]->OnDisconnect()) {
|
||||
if (sessionId != 0 && sessions_[sessionId] != nullptr && sessions_[sessionId]->OnDisconnect()) {
|
||||
HILOGI("peer %{public}s shutdown, socket sessionId: %{public}d.",
|
||||
GetAnonymStr(sessions_[sessionId]->GetPeerDeviceId()).c_str(), sessionId);
|
||||
Shutdown(sessionId);
|
||||
@ -221,7 +224,7 @@ void DSchedTransportSoftbusAdapter::OnShutdown(int32_t sessionId, bool isSelfcal
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> sessionLock(sessionMutex_);
|
||||
if (sessions_.empty() || sessions_.count(sessionId) == 0) {
|
||||
if (sessions_.empty() || sessions_.count(sessionId) == 0 || sessions_[sessionId] == nullptr) {
|
||||
HILOGE("error, invalid sessionId %{public}d", sessionId);
|
||||
return;
|
||||
}
|
||||
@ -255,8 +258,10 @@ int32_t DSchedTransportSoftbusAdapter::ReleaseChannel()
|
||||
{
|
||||
std::lock_guard<std::mutex> sessionLock(sessionMutex_);
|
||||
for (auto iter = sessions_.begin(); iter != sessions_.end(); iter++) {
|
||||
HILOGI("shutdown client: %{public}s, socket sessionId: %{public}d.",
|
||||
GetAnonymStr(iter->second->GetPeerDeviceId()).c_str(), iter->first);
|
||||
if (iter->second != nullptr) {
|
||||
HILOGI("shutdown client: %{public}s, socket sessionId: %{public}d.",
|
||||
GetAnonymStr(iter->second->GetPeerDeviceId()).c_str(), iter->first);
|
||||
}
|
||||
Shutdown(iter->first);
|
||||
}
|
||||
sessions_.clear();
|
||||
@ -271,7 +276,7 @@ int32_t DSchedTransportSoftbusAdapter::SendData(int32_t sessionId, int32_t dataT
|
||||
std::shared_ptr<DSchedDataBuffer> dataBuffer)
|
||||
{
|
||||
std::lock_guard<std::mutex> sessionLock(sessionMutex_);
|
||||
if (!sessions_.count(sessionId)) {
|
||||
if (!sessions_.count(sessionId) || sessions_[sessionId] == nullptr) {
|
||||
HILOGE("error, invalid session id %{public}d", sessionId);
|
||||
return INVALID_SESSION_ID;
|
||||
}
|
||||
@ -281,7 +286,12 @@ int32_t DSchedTransportSoftbusAdapter::SendData(int32_t sessionId, int32_t dataT
|
||||
int32_t DSchedTransportSoftbusAdapter::SendBytesBySoftbus(int32_t sessionId,
|
||||
std::shared_ptr<DSchedDataBuffer> dataBuffer)
|
||||
{
|
||||
return SendBytes(sessionId, dataBuffer->Data(), dataBuffer->Size());
|
||||
if (dataBuffer != nullptr) {
|
||||
return SendBytes(sessionId, dataBuffer->Data(), dataBuffer->Size());
|
||||
} else {
|
||||
HILOGE("dataBuffer is nullptr");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
void DSchedTransportSoftbusAdapter::OnBytes(int32_t sessionId, const void *data, uint32_t dataLen)
|
||||
@ -293,7 +303,7 @@ void DSchedTransportSoftbusAdapter::OnBytes(int32_t sessionId, const void *data,
|
||||
HILOGD("start, sessionId: %{public}d", sessionId);
|
||||
{
|
||||
std::lock_guard<std::mutex> sessionLock(sessionMutex_);
|
||||
if (!sessions_.count(sessionId)) {
|
||||
if (!sessions_.count(sessionId) || sessions_[sessionId] == nullptr) {
|
||||
HILOGE("invalid session id %{public}d", sessionId);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user