mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2025-02-17 04:49:02 +00:00
多任务:协同与任务中心
Signed-off-by: 韦国庆 <weiguoqing2@huawei.com>
This commit is contained in:
parent
c01f4d089d
commit
9772a61cb1
@ -514,13 +514,17 @@ enum {
|
||||
*/
|
||||
MISSION_NOT_FOCUSED = 29360234,
|
||||
/**
|
||||
* Result(29360235) for user is not foreground.
|
||||
* Result(29360235) for bundle is not continuable.
|
||||
*/
|
||||
DMS_NOT_FOREGROUND_USER = 29360235,
|
||||
BUNDLE_NOT_CONTINUABLE = 29360235,
|
||||
/**
|
||||
* Result(29360236) for not get mgr.
|
||||
* Result(29360236) for user is not foreground.
|
||||
*/
|
||||
DMS_NOT_GET_MANAGER = 29360236,
|
||||
DMS_NOT_FOREGROUND_USER = 29360236,
|
||||
/**
|
||||
* Result(29360237) for not get mgr.
|
||||
*/
|
||||
DMS_NOT_GET_MANAGER = 29360237,
|
||||
};
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
||||
|
@ -73,8 +73,8 @@ public:
|
||||
const AccountInfo& accountInfo) = 0;
|
||||
virtual int32_t SendResultFromRemote(OHOS::AAFwk::Want& want, int32_t requestCode,
|
||||
const CallerInfo& callerInfo, const AccountInfo& accountInfo, int32_t resultCode) = 0;
|
||||
virtual int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) = 0;
|
||||
virtual int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId, int32_t missionId,
|
||||
const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) = 0;
|
||||
virtual int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
const std::string& bundleName, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams)
|
||||
{
|
||||
@ -115,12 +115,14 @@ public:
|
||||
return 0;
|
||||
}
|
||||
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
|
||||
virtual int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) = 0;
|
||||
virtual int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag,
|
||||
int32_t callingUid) = 0;
|
||||
virtual int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
|
||||
std::vector<DstbMissionInfo>& missionInfos) = 0;
|
||||
virtual int32_t StopSyncRemoteMissions(const std::string& devId) = 0;
|
||||
virtual int32_t StopSyncRemoteMissions(const std::string& devId, int32_t callingUid) = 0;
|
||||
virtual int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) = 0;
|
||||
virtual int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) = 0;
|
||||
virtual int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj,
|
||||
int32_t callingUid) = 0;
|
||||
virtual int32_t RegisterOnListener(const std::string& type, const sptr<IRemoteObject>& obj, int32_t callingUid)
|
||||
{
|
||||
return 0;
|
||||
@ -136,7 +138,7 @@ public:
|
||||
std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot) = 0;
|
||||
virtual int32_t NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo>& missionInfos,
|
||||
const CallerInfo& callerInfo) = 0;
|
||||
virtual int32_t SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state)
|
||||
virtual int32_t SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state, int32_t callingUid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ public:
|
||||
const AccountInfo& accountInfo) override;
|
||||
int32_t SendResultFromRemote(OHOS::AAFwk::Want& want, int32_t requestCode,
|
||||
const CallerInfo& callerInfo, const AccountInfo& accountInfo, int32_t resultCode) override;
|
||||
int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) override;
|
||||
int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId, int32_t missionId,
|
||||
const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) override;
|
||||
int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
const std::string& bundleName, const sptr<IRemoteObject>& callback,
|
||||
const OHOS::AAFwk::WantParams& wantParams) override;
|
||||
@ -57,9 +57,11 @@ public:
|
||||
int32_t uid, const std::string& sourceDeviceId) override;
|
||||
int32_t NotifyProcessDiedFromRemote(const CallerInfo& callerInfo) override;
|
||||
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
|
||||
int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override;
|
||||
int32_t StopSyncRemoteMissions(const std::string& devId) override;
|
||||
int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) override;
|
||||
int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag,
|
||||
int32_t callingUid) override;
|
||||
int32_t StopSyncRemoteMissions(const std::string& devId, int32_t callingUid) override;
|
||||
int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj,
|
||||
int32_t callingUid) override;
|
||||
int32_t RegisterDSchedEventListener(const DSchedEventType& type, const sptr<IRemoteObject>& obj) override;
|
||||
int32_t UnRegisterDSchedEventListener(const DSchedEventType& type, const sptr<IRemoteObject>& obj) override;
|
||||
int32_t RegisterOnListener(const std::string& type, const sptr<IRemoteObject>& obj, int32_t callingUid) override;
|
||||
@ -74,7 +76,7 @@ public:
|
||||
int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
|
||||
std::vector<DstbMissionInfo>& missionInfos) override;
|
||||
int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) override;
|
||||
int32_t SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state) override;
|
||||
int32_t SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state, int32_t callingUid) override;
|
||||
#endif
|
||||
int32_t StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
|
||||
int32_t callerUid, int32_t callerPid, uint32_t accessToken) override;
|
||||
|
@ -114,8 +114,8 @@ public:
|
||||
const AccountInfo& accountInfo) override;
|
||||
int32_t SendResultFromRemote(OHOS::AAFwk::Want& want, int32_t requestCode,
|
||||
const CallerInfo& callerInfo, const AccountInfo& accountInfo, int32_t resultCode) override;
|
||||
int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) override;
|
||||
int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId, int32_t missionId,
|
||||
const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) override;
|
||||
int32_t ProcessContinueLocalMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
const std::string& bundleName, const sptr<IRemoteObject>& callback,
|
||||
const OHOS::AAFwk::WantParams& wantParams);
|
||||
@ -152,16 +152,18 @@ public:
|
||||
const CallerInfo& callerInfo) override;
|
||||
int32_t GetRemoteMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
|
||||
std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot) override;
|
||||
int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override;
|
||||
int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag,
|
||||
int32_t callingUid) override;
|
||||
int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
|
||||
std::vector<DstbMissionInfo>& missionInfos) override;
|
||||
int32_t StopSyncRemoteMissions(const std::string& devId) override;
|
||||
int32_t StopSyncRemoteMissions(const std::string& devId, int32_t callingUid) override;
|
||||
int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) override;
|
||||
int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) override;
|
||||
int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj,
|
||||
int32_t callingUid) override;
|
||||
int32_t RegisterOnListener(const std::string& type, const sptr<IRemoteObject>& obj, int32_t callingUid) override;
|
||||
int32_t RegisterOffListener(const std::string& type, const sptr<IRemoteObject>& obj, int32_t callingUid) override;
|
||||
int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) override;
|
||||
int32_t SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state) override;
|
||||
int32_t SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state, int32_t callingUid) override;
|
||||
void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
|
||||
#endif
|
||||
int32_t RegisterDSchedEventListener(const DSchedEventType& type, const sptr<IRemoteObject>& obj) override;
|
||||
|
@ -105,6 +105,7 @@ public:
|
||||
void NotifyMissionSnapshotChanged(int32_t missionId);
|
||||
void NotifyMissionSnapshotDestroyed(int32_t missionId);
|
||||
void NotifyRemoteDied(const wptr<IRemoteObject>& remote);
|
||||
void NotifyNetDisconnectOffline();
|
||||
|
||||
private:
|
||||
std::map<std::string, std::shared_ptr<AppExecFwk::EventHandler>> deviceHandle_;
|
||||
|
@ -409,7 +409,8 @@ int32_t DistributedSchedProxy::NotifyProcessDiedFromRemote(const CallerInfo& cal
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
|
||||
int32_t DistributedSchedProxy::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag)
|
||||
int32_t DistributedSchedProxy::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag,
|
||||
int32_t callingUid)
|
||||
{
|
||||
HILOGI("called");
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
@ -426,6 +427,7 @@ int32_t DistributedSchedProxy::StartSyncRemoteMissions(const std::string& devId,
|
||||
PARCEL_WRITE_HELPER(data, String16, Str8ToStr16(devId));
|
||||
PARCEL_WRITE_HELPER(data, Bool, fixConflict);
|
||||
PARCEL_WRITE_HELPER(data, Int64, tag);
|
||||
PARCEL_WRITE_HELPER(data, Int32, callingUid);
|
||||
PARCEL_TRANSACT_SYNC_RET_INT(remote, static_cast<uint32_t>(IDSchedInterfaceCode::START_SYNC_MISSIONS), data, reply);
|
||||
}
|
||||
|
||||
@ -458,7 +460,7 @@ int32_t DistributedSchedProxy::StartSyncMissionsFromRemote(const CallerInfo& cal
|
||||
return DstbMissionInfo::ReadDstbMissionInfosFromParcel(reply, missionInfos) ? ERR_NONE : ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
|
||||
int32_t DistributedSchedProxy::StopSyncRemoteMissions(const std::string& devId)
|
||||
int32_t DistributedSchedProxy::StopSyncRemoteMissions(const std::string& devId, int32_t callingUid)
|
||||
{
|
||||
HILOGI("called");
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
@ -472,6 +474,7 @@ int32_t DistributedSchedProxy::StopSyncRemoteMissions(const std::string& devId)
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
PARCEL_WRITE_HELPER(data, String16, Str8ToStr16(devId));
|
||||
PARCEL_WRITE_HELPER(data, Int32, callingUid);
|
||||
PARCEL_TRANSACT_SYNC_RET_INT(remote, static_cast<uint32_t>(IDSchedInterfaceCode::STOP_SYNC_MISSIONS), data, reply);
|
||||
}
|
||||
|
||||
@ -502,7 +505,7 @@ int32_t DistributedSchedProxy::StopSyncMissionsFromRemote(const CallerInfo& call
|
||||
}
|
||||
|
||||
int32_t DistributedSchedProxy::RegisterMissionListener(const std::u16string& devId,
|
||||
const sptr<IRemoteObject>& obj)
|
||||
const sptr<IRemoteObject>& obj, int32_t callingUid)
|
||||
{
|
||||
HILOGI("RegisterMissionListener called");
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
@ -517,6 +520,7 @@ int32_t DistributedSchedProxy::RegisterMissionListener(const std::u16string& dev
|
||||
}
|
||||
PARCEL_WRITE_HELPER(data, String16, devId);
|
||||
PARCEL_WRITE_HELPER(data, RemoteObject, obj);
|
||||
PARCEL_WRITE_HELPER(data, Int32, callingUid);
|
||||
PARCEL_TRANSACT_SYNC_RET_INT(remote, static_cast<uint32_t>(IDSchedInterfaceCode::REGISTER_MISSION_LISTENER),
|
||||
data, reply);
|
||||
}
|
||||
@ -720,7 +724,8 @@ int32_t DistributedSchedProxy::GetRemoteMissionSnapshotInfo(const std::string& n
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t DistributedSchedProxy::SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state)
|
||||
int32_t DistributedSchedProxy::SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state,
|
||||
int32_t callingUid)
|
||||
{
|
||||
HILOGD("DistributedSchedProxy::SetMissionContinueState called");
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
@ -736,6 +741,7 @@ int32_t DistributedSchedProxy::SetMissionContinueState(int32_t missionId, const
|
||||
}
|
||||
PARCEL_WRITE_HELPER(data, Int32, missionId);
|
||||
PARCEL_WRITE_HELPER(data, Int32, static_cast<int32_t>(state));
|
||||
PARCEL_WRITE_HELPER(data, Int32, callingUid);
|
||||
PARCEL_TRANSACT_SYNC_RET_INT(remote, static_cast<uint32_t>(IDSchedInterfaceCode::SET_MISSION_CONTINUE_STATE),
|
||||
data, reply);
|
||||
}
|
||||
|
@ -114,6 +114,7 @@ const std::string DSCHED_EVENT_KEY = "IDSchedEventListener";
|
||||
const std::string DMSDURATION_SAVETIME = "ohos.dschedule.SaveDataTime";
|
||||
const std::string DMS_CONTINUE_SESSION_ID = "ohos.dms.continueSessionId";
|
||||
const std::string DMS_PERSISTENT_ID = "ohos.dms.persistentId";
|
||||
const std::string DMS_CALLING_UID = "ohos.dms.callingUid";
|
||||
const std::string PKG_NAME = "DBinderBus_Dms_" + std::to_string(getprocpid());
|
||||
const std::string BOOT_COMPLETED_EVENT = "usual.event.BOOT_COMPLETED";
|
||||
const std::string COMMON_EVENT_WIFI_SEMI_STATE = "usual.event.wifi.SEMI_STATE";
|
||||
@ -741,6 +742,10 @@ int32_t DistributedSchedService::GetCallerInfo(const std::string &localDeviceId,
|
||||
int32_t DistributedSchedService::StartRemoteAbility(const OHOS::AAFwk::Want& want,
|
||||
int32_t callerUid, int32_t requestCode, uint32_t accessToken)
|
||||
{
|
||||
if (!MultiUserManager::GetInstance().IsCallerForeground(callerUid)) {
|
||||
HILOGW("The current user is not foreground. callingUid: %{public}d .", callerUid);
|
||||
return DMS_NOT_FOREGROUND_USER;
|
||||
}
|
||||
std::string localDeviceId;
|
||||
std::string deviceId = want.GetElement().GetDeviceID();
|
||||
if (!GetLocalDeviceId(localDeviceId) || !CheckDeviceId(localDeviceId, deviceId)) {
|
||||
@ -1020,7 +1025,6 @@ int32_t DistributedSchedService::ContinueRemoteMission(const std::string& srcDev
|
||||
|
||||
std::string peerUdid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUdidByNetworkId(srcDeviceId);
|
||||
DmsRadar::GetInstance().ClickIconDmsContinue("ContinueMission", ERR_OK, peerUdid, bundleName, bundleName);
|
||||
|
||||
int32_t result = remoteDms->ContinueMission(srcDeviceId, dstDeviceId, missionId, callback, wantParams);
|
||||
HILOGI("ContinueRemoteMission result: %{public}d!", result);
|
||||
return result;
|
||||
@ -1069,6 +1073,10 @@ int32_t DistributedSchedService::ContinueMission(const std::string& srcDeviceId,
|
||||
int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams)
|
||||
{
|
||||
HILOGI("ContinueMission called");
|
||||
OHOS::AAFwk::WantParams originWantParams = wantParams;
|
||||
if (originWantParams.HasParam(DMS_CALLING_UID)) {
|
||||
originWantParams.Remove(DMS_CALLING_UID);
|
||||
}
|
||||
if (srcDeviceId.empty() || dstDeviceId.empty() || callback == nullptr) {
|
||||
HILOGE("srcDeviceId or dstDeviceId or callback is null!");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
@ -1085,14 +1093,14 @@ int32_t DistributedSchedService::ContinueMission(const std::string& srcDeviceId,
|
||||
HILOGE("GetDeviceInfoById failed, dstDeviceId: %{public}s.", GetAnonymStr(dstDeviceId).c_str());
|
||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||
}
|
||||
return ContinueLocalMission(dstDeviceId, missionId, callback, wantParams);
|
||||
return ContinueLocalMission(dstDeviceId, missionId, callback, originWantParams);
|
||||
} else if (dstDeviceId == localDevId) {
|
||||
DmsContinueTime::GetInstance().SetPull(true);
|
||||
if (DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceInfoById(srcDeviceId) == nullptr) {
|
||||
HILOGE("GetDeviceInfoById failed, srcDeviceId: %{public}s.", GetAnonymStr(srcDeviceId).c_str());
|
||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||
}
|
||||
return ContinueRemoteMission(srcDeviceId, dstDeviceId, missionId, callback, wantParams);
|
||||
return ContinueRemoteMission(srcDeviceId, dstDeviceId, missionId, callback, originWantParams);
|
||||
} else {
|
||||
HILOGE("source or target device must be local!");
|
||||
return OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET;
|
||||
@ -1154,6 +1162,10 @@ int32_t DistributedSchedService::ProcessContinueRemoteMission(const std::string&
|
||||
int32_t DistributedSchedService::ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
const std::string& bundleName, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams)
|
||||
{
|
||||
OHOS::AAFwk::WantParams originWantParams = wantParams;
|
||||
if (originWantParams.HasParam(DMS_CALLING_UID)) {
|
||||
originWantParams.Remove(DMS_CALLING_UID);
|
||||
}
|
||||
HILOGI("ContinueMission srcDeviceId: %{public}s. dstDeviceId: %{public}s. bundleName: %{public}s.",
|
||||
GetAnonymStr(srcDeviceId).c_str(), GetAnonymStr(dstDeviceId).c_str(), bundleName.c_str());
|
||||
if (srcDeviceId.empty() || dstDeviceId.empty() || callback == nullptr) {
|
||||
@ -1168,10 +1180,10 @@ int32_t DistributedSchedService::ContinueMission(const std::string& srcDeviceId,
|
||||
DurationStart(srcDeviceId, dstDeviceId);
|
||||
|
||||
if (srcDeviceId == localDevId) {
|
||||
return ProcessContinueLocalMission(srcDeviceId, dstDeviceId, bundleName, callback, wantParams);
|
||||
return ProcessContinueLocalMission(srcDeviceId, dstDeviceId, bundleName, callback, originWantParams);
|
||||
} else if (dstDeviceId == localDevId) {
|
||||
DmsContinueTime::GetInstance().SetPull(true);
|
||||
return ProcessContinueRemoteMission(srcDeviceId, dstDeviceId, bundleName, callback, wantParams);
|
||||
return ProcessContinueRemoteMission(srcDeviceId, dstDeviceId, bundleName, callback, originWantParams);
|
||||
} else {
|
||||
HILOGE("source or target device must be local!");
|
||||
return OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET;
|
||||
@ -1629,6 +1641,10 @@ int32_t DistributedSchedService::GetUidLocked(const std::list<ConnectAbilitySess
|
||||
int32_t DistributedSchedService::ConnectRemoteAbility(const OHOS::AAFwk::Want& want,
|
||||
const sptr<IRemoteObject>& connect, int32_t callerUid, int32_t callerPid, uint32_t accessToken)
|
||||
{
|
||||
if (!MultiUserManager::GetInstance().IsCallerForeground(callerUid)) {
|
||||
HILOGW("The current user is not foreground. callingUid: %{public}d .", callerUid);
|
||||
return DMS_NOT_FOREGROUND_USER;
|
||||
}
|
||||
std::string localDeviceId;
|
||||
std::string remoteDeviceId = want.GetElement().GetDeviceID();
|
||||
if (!GetLocalDeviceId(localDeviceId) || !CheckDeviceId(localDeviceId, remoteDeviceId)) {
|
||||
@ -1999,6 +2015,10 @@ int32_t DistributedSchedService::SaveConnectToken(const OHOS::AAFwk::Want& want,
|
||||
int32_t DistributedSchedService::StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want,
|
||||
const sptr<IRemoteObject>& connect, int32_t callerUid, int32_t callerPid, uint32_t accessToken)
|
||||
{
|
||||
if (!MultiUserManager::GetInstance().IsCallerForeground(callerUid)) {
|
||||
HILOGW("The current user is not foreground. callingUid: %{public}d .", callerUid);
|
||||
return DMS_NOT_FOREGROUND_USER;
|
||||
}
|
||||
if (connect == nullptr) {
|
||||
HILOGE("StartRemoteAbilityByCall connect is null");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
@ -2681,6 +2701,7 @@ void DistributedSchedService::ProcessDeviceOffline(const std::string& deviceId)
|
||||
HILOGE("ProcessDeviceOffline check deviceId failed");
|
||||
return;
|
||||
}
|
||||
DistributedSchedMissionManager::GetInstance().NotifyNetDisconnectOffline();
|
||||
RemoveConnectAbilityInfo(deviceId);
|
||||
ProcessCalleeOffline(deviceId);
|
||||
ProcessFreeInstallOffline(deviceId);
|
||||
@ -2899,8 +2920,12 @@ int32_t DistributedSchedService::GetRemoteMissionSnapshotInfo(const std::string&
|
||||
}
|
||||
|
||||
int32_t DistributedSchedService::RegisterMissionListener(const std::u16string& devId,
|
||||
const sptr<IRemoteObject>& obj)
|
||||
const sptr<IRemoteObject>& obj, int32_t callingUid)
|
||||
{
|
||||
if (!MultiUserManager::GetInstance().IsCallerForeground(callingUid)) {
|
||||
HILOGW("The current user is not foreground. callingUid: %{public}d.", callingUid);
|
||||
return DMS_NOT_FOREGROUND_USER;
|
||||
}
|
||||
return DistributedSchedMissionManager::GetInstance().RegisterMissionListener(devId, obj);
|
||||
}
|
||||
|
||||
@ -2922,13 +2947,22 @@ int32_t DistributedSchedService::UnRegisterMissionListener(const std::u16string&
|
||||
return DistributedSchedMissionManager::GetInstance().UnRegisterMissionListener(devId, obj);
|
||||
}
|
||||
|
||||
int32_t DistributedSchedService::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag)
|
||||
int32_t DistributedSchedService::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag,
|
||||
int32_t callingUid)
|
||||
{
|
||||
if (!MultiUserManager::GetInstance().IsCallerForeground(callingUid)) {
|
||||
HILOGW("The current user is not foreground. callingUid: %{public}d.", callingUid);
|
||||
return DMS_NOT_FOREGROUND_USER;
|
||||
}
|
||||
return DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions(devId, fixConflict, tag);
|
||||
}
|
||||
|
||||
int32_t DistributedSchedService::StopSyncRemoteMissions(const std::string& devId)
|
||||
int32_t DistributedSchedService::StopSyncRemoteMissions(const std::string& devId, int32_t callingUid)
|
||||
{
|
||||
if (!MultiUserManager::GetInstance().IsCallerForeground(callingUid)) {
|
||||
HILOGW("The current user is not foreground. callingUid: %{public}d.", callingUid);
|
||||
return DMS_NOT_FOREGROUND_USER;
|
||||
}
|
||||
return DistributedSchedMissionManager::GetInstance().StopSyncRemoteMissions(devId, false, true);
|
||||
}
|
||||
|
||||
@ -2944,11 +2978,11 @@ int32_t DistributedSchedService::StopSyncMissionsFromRemote(const CallerInfo& ca
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t DistributedSchedService::SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state)
|
||||
int32_t DistributedSchedService::SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state,
|
||||
int32_t callingUid)
|
||||
{
|
||||
int32_t callingUid = IPCSkeleton::GetCallingUid();
|
||||
if (!MultiUserManager::GetInstance().IsCallerForeground(callingUid)) {
|
||||
HILOGW("The current user is not foreground.");
|
||||
HILOGW("The current user is not foreground. callingUid: %{public}d.", callingUid);
|
||||
return DMS_NOT_FOREGROUND_USER;
|
||||
}
|
||||
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
|
||||
|
@ -539,13 +539,12 @@ int32_t DistributedSchedStub::ContinueMissionInner(MessageParcel& data, MessageP
|
||||
HILOGW("read callback failed!");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
int32_t result = ERR_OK;
|
||||
shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
|
||||
if (wantParams == nullptr) {
|
||||
HILOGW("wantParams readParcelable failed!");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
int32_t result = ERR_OK;
|
||||
AAFwk::MissionInfo missionInfo;
|
||||
if (isLocalCalling) {
|
||||
std::string remoteDeviceId = (IPCSkeleton::GetCallingDeviceID() == srcDevId) ? dstDevId : srcDevId;
|
||||
@ -1000,7 +999,12 @@ int32_t DistributedSchedStub::RegisterMissionListenerInner(MessageParcel& data,
|
||||
HILOGW("read IRemoteObject failed!");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
int32_t result = RegisterMissionListener(devId, missionChangedListener);
|
||||
int32_t callingUid = data.ReadInt32();
|
||||
if (callingUid < 0) {
|
||||
HILOGW("read callingUid failed!");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
int32_t result = RegisterMissionListener(devId, missionChangedListener, callingUid);
|
||||
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
|
||||
}
|
||||
|
||||
@ -1190,7 +1194,12 @@ int32_t DistributedSchedStub::StopSyncRemoteMissionsInner(MessageParcel& data, M
|
||||
HILOGW("read deviceId failed!");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
int32_t result = StopSyncRemoteMissions(Str16ToStr8(devId));
|
||||
int32_t callingUid = data.ReadInt32();
|
||||
if (callingUid < 0) {
|
||||
HILOGW("read callingUid failed!");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
int32_t result = StopSyncRemoteMissions(Str16ToStr8(devId), callingUid);
|
||||
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
|
||||
}
|
||||
|
||||
@ -1244,7 +1253,12 @@ int32_t DistributedSchedStub::StartSyncRemoteMissionsInner(MessageParcel& data,
|
||||
string deviceId = Str16ToStr8(devId);
|
||||
bool fixConflict = data.ReadBool();
|
||||
int64_t tag = data.ReadInt64();
|
||||
int32_t result = StartSyncRemoteMissions(deviceId, fixConflict, tag);
|
||||
int32_t callingUid = data.ReadInt32();
|
||||
if (callingUid < 0) {
|
||||
HILOGW("read callingUid failed!");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
int32_t result = StartSyncRemoteMissions(deviceId, fixConflict, tag, callingUid);
|
||||
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
|
||||
}
|
||||
|
||||
@ -1259,8 +1273,10 @@ int32_t DistributedSchedStub::SetMissionContinueStateInner(MessageParcel& data,
|
||||
PARCEL_READ_HELPER(data, Int32, missionId);
|
||||
int32_t state = 0;
|
||||
PARCEL_READ_HELPER(data, Int32, state);
|
||||
int32_t callingUid = 0;
|
||||
PARCEL_READ_HELPER(data, Int32, callingUid);
|
||||
|
||||
int32_t result = SetMissionContinueState(missionId, static_cast<AAFwk::ContinueState>(state));
|
||||
int32_t result = SetMissionContinueState(missionId, static_cast<AAFwk::ContinueState>(state), callingUid);
|
||||
HILOGI("result %{public}d", result);
|
||||
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "multi_user_manager.h"
|
||||
#include "parcel_helper.h"
|
||||
#include "system_ability.h"
|
||||
#include "system_ability_definition.h"
|
||||
@ -39,6 +40,10 @@ const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId";
|
||||
int32_t DmsTokenCallback::SendResult(OHOS::AAFwk::Want& want, int32_t callerUid,
|
||||
int32_t requestCode, uint32_t accessToken, int32_t resultCode)
|
||||
{
|
||||
if (!MultiUserManager::GetInstance().IsCallerForeground(callerUid)) {
|
||||
HILOGW("The current user is not foreground. callingUid: %{public}d .", callerUid);
|
||||
return DMS_NOT_FOREGROUND_USER;
|
||||
}
|
||||
AccessToken::NativeTokenInfo nativeTokenInfo;
|
||||
int32_t ret = AccessToken::AccessTokenKit::GetNativeTokenInfo(IPCSkeleton::GetCallingTokenID(),
|
||||
nativeTokenInfo);
|
||||
|
@ -46,6 +46,7 @@ constexpr int32_t GET_FOREGROUND_SNAPSHOT_DELAY_TIME = 800; // ms
|
||||
const std::string DELETE_DATA_STORAGE = "DeleteDataStorage";
|
||||
constexpr int32_t DELETE_DATA_STORAGE_DELAYED = 60000; // ms
|
||||
const std::string INVAILD_LOCAL_DEVICE_ID = "-1";
|
||||
constexpr int32_t NET_STATE = 0;
|
||||
}
|
||||
namespace Mission {
|
||||
constexpr int32_t GET_MAX_MISSIONS = 20;
|
||||
@ -157,6 +158,26 @@ void DistributedSchedMissionManager::NotifyRemoteDied(const wptr<IRemoteObject>&
|
||||
distributedDataStorage_->NotifyRemoteDied(remote);
|
||||
}
|
||||
|
||||
void DistributedSchedMissionManager::NotifyNetDisconnectOffline()
|
||||
{
|
||||
HILOGD("NotifyNetDisconnectOffline start.");
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(listenDeviceLock_);
|
||||
if (listenDeviceMap_.empty()) {
|
||||
HILOGI("The connect is null!");
|
||||
return;
|
||||
}
|
||||
for (auto& listenDevice : listenDeviceMap_) {
|
||||
std::u16string devId = listenDevice.first;
|
||||
std::set<sptr<IRemoteObject>> listenerSet = listenDevice.second.listenerSet;
|
||||
for (auto connect : listenerSet) {
|
||||
MissionChangedNotify::NotifyNetDisconnect(connect, devId, NET_STATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
HILOGD("NotifyNetDisconnectOffline end.");
|
||||
}
|
||||
|
||||
int32_t DistributedSchedMissionManager::InitDataStorage()
|
||||
{
|
||||
if (distributedDataStorage_ == nullptr) {
|
||||
|
@ -337,7 +337,7 @@ int32_t DMSContinueRecvMgr::DealOnBroadcastBusiness(const std::string& senderNet
|
||||
if (state == ACTIVE
|
||||
&& !IsBundleContinuable(localBundleInfo, abilityInfo.abilityName, continueType, isSameBundle)) {
|
||||
HILOGE("Bundle %{public}s is not continuable", finalBundleName.c_str());
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
return BUNDLE_NOT_CONTINUABLE;
|
||||
}
|
||||
|
||||
int32_t ret = VerifyBroadcastSource(senderNetworkId, bundleName, finalBundleName, continueType, state);
|
||||
|
@ -16,8 +16,10 @@
|
||||
|
||||
#include "adapter/mmi_adapter.h"
|
||||
#include "datashare_manager.h"
|
||||
#include "distributed_sched_service.h"
|
||||
#include "distributed_sched_utils.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "mission/distributed_sched_mission_manager.h"
|
||||
#include "softbus_adapter/softbus_adapter.h"
|
||||
#include "os_account_manager.h"
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "multi_user_manager.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
#define private public
|
||||
@ -86,6 +87,13 @@ public:
|
||||
void DecreaseConnectCount(int32_t uid) const;
|
||||
};
|
||||
|
||||
static bool g_isForeground = true;
|
||||
|
||||
bool MultiUserManager::IsCallerForeground(int32_t callingUid)
|
||||
{
|
||||
return g_isForeground;
|
||||
}
|
||||
|
||||
void AbilityCallCallbackTest::OnAbilityConnectDone(const AppExecFwk::ElementName& element,
|
||||
const sptr<IRemoteObject>& remoteObject, int32_t resultCode)
|
||||
{
|
||||
@ -654,6 +662,30 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_020, TestSize.Level1)
|
||||
DTEST_LOG << "DistributedSchedServiceTest CallAbility_020 end " << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CallAbility_021
|
||||
* @tc.desc: user is not foreground
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedSchedCallTest, CallAbility_021, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedSchedServiceTest CallAbility_021 start " << std::endl;
|
||||
OHOS::AAFwk::Want want;
|
||||
want.SetElementName(MOCK_DEVICE_ID, "ohos.demo.test", "abilityTest");
|
||||
sptr<IRemoteObject> callback = new AbilityCallCallbackTest();
|
||||
int32_t callerPid = MOCK_PID;
|
||||
uint32_t accessToken = 0;
|
||||
|
||||
DTEST_LOG << "DistributedSchedServiceTest mock illegal uid " << std::endl;
|
||||
int32_t illegalUid = -1;
|
||||
g_isForeground = false;
|
||||
int32_t result = DistributedSchedService::GetInstance().StartRemoteAbilityByCall(want,
|
||||
callback, illegalUid, callerPid, accessToken);
|
||||
EXPECT_EQ(result, DMS_NOT_FOREGROUND_USER);
|
||||
|
||||
DTEST_LOG << "DistributedSchedServiceTest CallAbility_021 end " << std::endl;
|
||||
}
|
||||
|
||||
void DistributedSchedCallTest::AddSession(const sptr<IRemoteObject>& connect,
|
||||
const std::string& localDeviceId, const std::string& remoteDeviceId, const AAFwk::Want& want) const
|
||||
{
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "distributed_sched_test_util.h"
|
||||
#include "dtbschedmgr_device_info_storage.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "multi_user_manager.h"
|
||||
#include "parcel_helper.h"
|
||||
#include "test_log.h"
|
||||
|
||||
@ -99,6 +100,13 @@ public:
|
||||
};
|
||||
};
|
||||
|
||||
static bool g_isForeground = true;
|
||||
|
||||
bool MultiUserManager::IsCallerForeground(int32_t callingUid)
|
||||
{
|
||||
return g_isForeground;
|
||||
}
|
||||
|
||||
void AbilityConnectCallbackTest::OnAbilityConnectDone(const AppExecFwk::ElementName& element,
|
||||
const sptr<IRemoteObject>& remoteObject, int32_t resultCode)
|
||||
{
|
||||
@ -726,6 +734,24 @@ HWTEST_F(DistributedSchedConnectTest, ConnectRemoteAbility002, TestSize.Level4)
|
||||
DTEST_LOG << "DistributedSchedServiceTest ConnectRemoteAbility002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ConnectRemoteAbility
|
||||
* @tc.desc: user is not foreground
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5OOKG
|
||||
*/
|
||||
HWTEST_F(DistributedSchedConnectTest, ConnectRemoteAbility006, TestSize.Level4)
|
||||
{
|
||||
DTEST_LOG << "DistributedSchedServiceTest ConnectRemoteAbility006 start" << std::endl;
|
||||
OHOS::AAFwk::Want want;
|
||||
want.SetElementName("123_remote_device_id", "ohos.demo.bundleName", "abilityName");
|
||||
sptr<AbilityConnectCallbackTest> connect(new AbilityConnectCallbackTest());
|
||||
g_isForeground = false;
|
||||
int32_t ret = DistributedSchedService::GetInstance().ConnectRemoteAbility(want, connect, -1, -1, -1);
|
||||
EXPECT_EQ(ret, DMS_NOT_FOREGROUND_USER);
|
||||
DTEST_LOG << "DistributedSchedServiceTest ConnectRemoteAbility006 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ConnectAbilityFromRemote
|
||||
* @tc.desc: connect remote ability whith fake deviceId.
|
||||
@ -1218,6 +1244,7 @@ HWTEST_F(DistributedSchedConnectTest, ProxyCallConnectRemoteAbility001, TestSize
|
||||
DistributedSchedService::GetInstance().GetUidLocked(sessionsList);
|
||||
DTEST_LOG << "DistributedSchedConnectTest GetUidLocked001 end" << std::endl;
|
||||
|
||||
g_isForeground = true;
|
||||
int32_t ret = proxy->ConnectRemoteAbility(want, connect, 0, 0, 0);
|
||||
EXPECT_EQ(ret, DMS_PERMISSION_DENIED);
|
||||
DTEST_LOG << "DistributedSchedServiceTest ProxyCallConnectRemoteAbility001 end" << std::endl;
|
||||
@ -1245,6 +1272,7 @@ HWTEST_F(DistributedSchedConnectTest, ProxyCallConnectRemoteAbility002, TestSize
|
||||
DistributedSchedService::GetInstance().DecreaseConnectLocked(uid);
|
||||
DTEST_LOG << "DistributedSchedConnectTest DecreaseConnectLocked002 end" << std::endl;
|
||||
|
||||
g_isForeground = true;
|
||||
int32_t ret = proxy->ConnectRemoteAbility(want, nullptr, 0, 0, 0);
|
||||
EXPECT_EQ(ret, ERR_NULL_OBJECT);
|
||||
DTEST_LOG << "DistributedSchedServiceTest ProxyCallConnectRemoteAbility002 end" << std::endl;
|
||||
@ -1386,6 +1414,8 @@ HWTEST_F(DistributedSchedConnectTest, ConnectRemoteAbility003, TestSize.Level4)
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
int32_t pid = IPCSkeleton::GetCallingRealPid();
|
||||
int32_t accessToken = IPCSkeleton::GetCallingTokenID();
|
||||
|
||||
g_isForeground = true;
|
||||
int32_t ret = DistributedSchedService::GetInstance().ConnectRemoteAbility(want, connect, uid, pid, accessToken);
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DistributedSchedServiceTest ConnectRemoteAbility003 end" << std::endl;
|
||||
|
@ -1040,7 +1040,8 @@ HWTEST_F(DSchedContinuationTest, ContinueMission_003, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DSchedContinuationTest ContinueMission_003 start" << std::endl;
|
||||
WantParams wantParams;
|
||||
int32_t ret = DistributedSchedService::GetInstance().ContinueMission("string", "string", 1, nullptr, wantParams);
|
||||
int32_t ret = DistributedSchedService::GetInstance().ContinueMission("string", "string", 1,
|
||||
nullptr, wantParams);
|
||||
EXPECT_TRUE(ret != ERR_OK);
|
||||
DTEST_LOG << "DSchedContinuationTest ContinueMission_003 end" << std::endl;
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "iservice_registry.h"
|
||||
#include "mock_form_mgr_service.h"
|
||||
#include "mock_distributed_sched.h"
|
||||
#include "multi_user_manager.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "test_log.h"
|
||||
#include "thread_pool.h"
|
||||
@ -117,6 +118,13 @@ void DistributedSchedServiceFirstTest::TearDown()
|
||||
void DistributedSchedServiceFirstTest::DeviceInitCallBack::OnRemoteDied()
|
||||
{}
|
||||
|
||||
static bool g_isForeground = true;
|
||||
|
||||
bool MultiUserManager::IsCallerForeground(int32_t callingUid)
|
||||
{
|
||||
return g_isForeground;
|
||||
}
|
||||
|
||||
sptr<IDistributedSched> DistributedSchedServiceFirstTest::GetDms()
|
||||
{
|
||||
if (proxy_ != nullptr) {
|
||||
@ -302,6 +310,29 @@ HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteAbility_004, TestSize.Leve
|
||||
DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility_004 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartRemoteAbility_005
|
||||
* @tc.desc: user is not foreground
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteAbility_005, TestSize.Level0)
|
||||
{
|
||||
DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility_005 start" << std::endl;
|
||||
/**
|
||||
* @tc.steps: step1. set want with wrong deviceId
|
||||
* @tc.expected: step2. StartRemoteAbility return INVALID_PARAMETERS_ERR
|
||||
*/
|
||||
AAFwk::Want want;
|
||||
AppExecFwk::ElementName element("123456", "com.ohos.distributedmusicplayer",
|
||||
"com.ohos.distributedmusicplayer.MainAbility");
|
||||
want.SetElement(element);
|
||||
g_isForeground = false;
|
||||
int result = DistributedSchedService::GetInstance().StartRemoteAbility(want, 0, 0, 0);
|
||||
DTEST_LOG << "result:" << result << std::endl;
|
||||
EXPECT_EQ(static_cast<int>(DMS_NOT_FOREGROUND_USER), result);
|
||||
DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility_005 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartRemoteAbility001
|
||||
* @tc.desc: call StartRemoteAbility
|
||||
@ -315,6 +346,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteAbility001, TestSize.Level
|
||||
int32_t callerUid = 0;
|
||||
int32_t requestCode = 0;
|
||||
uint32_t accessToken = 0;
|
||||
g_isForeground = true;
|
||||
int32_t ret = DistributedSchedService::GetInstance().StartRemoteAbility(want, callerUid, requestCode, accessToken);
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility001 end" << std::endl;
|
||||
@ -333,6 +365,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteAbility002, TestSize.Level
|
||||
int32_t callerUid = 1;
|
||||
int32_t requestCode = 0;
|
||||
uint32_t accessToken = 0;
|
||||
g_isForeground = true;
|
||||
int32_t ret = DistributedSchedService::GetInstance().StartRemoteAbility(want, callerUid, requestCode, accessToken);
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility002 end" << std::endl;
|
||||
@ -351,6 +384,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteAbility003, TestSize.Level
|
||||
int32_t callerUid = 0;
|
||||
int32_t requestCode = 1;
|
||||
uint32_t accessToken = 0;
|
||||
g_isForeground = true;
|
||||
int32_t ret = DistributedSchedService::GetInstance().StartRemoteAbility(want, callerUid, requestCode, accessToken);
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility003 end" << std::endl;
|
||||
@ -369,6 +403,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteAbility004, TestSize.Level
|
||||
int32_t callerUid = 0;
|
||||
int32_t requestCode = 0;
|
||||
uint32_t accessToken = 1;
|
||||
g_isForeground = true;
|
||||
int32_t ret = DistributedSchedService::GetInstance().StartRemoteAbility(want, callerUid, requestCode, accessToken);
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility004 end" << std::endl;
|
||||
@ -387,6 +422,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteAbility005, TestSize.Level
|
||||
int32_t callerUid = 1;
|
||||
int32_t requestCode = 1;
|
||||
uint32_t accessToken = 0;
|
||||
g_isForeground = true;
|
||||
int32_t ret = DistributedSchedService::GetInstance().StartRemoteAbility(want, callerUid, requestCode, accessToken);
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility005 end" << std::endl;
|
||||
@ -405,11 +441,30 @@ HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteAbility006, TestSize.Level
|
||||
int32_t callerUid = 1;
|
||||
int32_t requestCode = 1;
|
||||
uint32_t accessToken = 1;
|
||||
g_isForeground = true;
|
||||
int32_t ret = DistributedSchedService::GetInstance().StartRemoteAbility(want, callerUid, requestCode, accessToken);
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility006 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartRemoteAbility007
|
||||
* @tc.desc: user is not foreground
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteAbility007, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility007 start" << std::endl;
|
||||
AAFwk::Want want;
|
||||
int32_t callerUid = 0;
|
||||
int32_t requestCode = 0;
|
||||
uint32_t accessToken = 0;
|
||||
g_isForeground = false;
|
||||
int32_t ret = DistributedSchedService::GetInstance().StartRemoteAbility(want, callerUid, requestCode, accessToken);
|
||||
EXPECT_EQ(ret, DMS_NOT_FOREGROUND_USER);
|
||||
DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility007 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartAbilityFromRemote_001
|
||||
* @tc.desc: call StartAbilityFromRemote with illegal param
|
||||
@ -1226,6 +1281,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, ConnectRemoteAbility001, TestSize.Lev
|
||||
OHOS::AAFwk::Want want;
|
||||
want.SetElementName("123_remote_device_id", "ohos.demo.bundleName", "abilityName");
|
||||
const sptr<IRemoteObject> connect = nullptr;
|
||||
g_isForeground = true;
|
||||
int32_t ret = DistributedSchedService::GetInstance().ConnectRemoteAbility(want, connect, 1, 1, 1);
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DistributedSchedServiceFirstTest ConnectRemoteAbility001 end" << std::endl;
|
||||
@ -1243,6 +1299,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, ConnectRemoteAbility002, TestSize.Lev
|
||||
OHOS::AAFwk::Want want;
|
||||
want.SetElementName("", "ohos.demo.bundleName", "abilityName");
|
||||
const sptr<IRemoteObject> connect = nullptr;
|
||||
g_isForeground = true;
|
||||
int32_t ret = DistributedSchedService::GetInstance().ConnectRemoteAbility(want, connect, 1, 1, 1);
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DistributedSchedServiceFirstTest ConnectRemoteAbility002 end" << std::endl;
|
||||
@ -1523,6 +1580,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteAbilityByCall_001, TestSiz
|
||||
"com.ohos.distributedmusicplayer.MainAbility");
|
||||
want.SetElement(element);
|
||||
sptr<IRemoteObject> connect(new MockDistributedSched());
|
||||
g_isForeground = true;
|
||||
int32_t result = DistributedSchedService::GetInstance().StartRemoteAbilityByCall(want,
|
||||
connect, callerUid, callerPid, accessToken);
|
||||
EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
|
||||
|
@ -24,6 +24,7 @@
|
||||
#undef private
|
||||
#include "mock_distributed_sched.h"
|
||||
#include "mock_remote_stub.h"
|
||||
#include "multi_user_manager.h"
|
||||
#include "parcel_helper.h"
|
||||
#include "test_log.h"
|
||||
#include "token_setproc.h"
|
||||
@ -70,6 +71,13 @@ void DistributedSchedStubTest::SetUp()
|
||||
DistributedSchedUtil::MockProcessAndPermission(FOUNDATION_PROCESS_NAME, PERMS, 1);
|
||||
}
|
||||
|
||||
static bool g_isForeground = true;
|
||||
|
||||
bool MultiUserManager::IsCallerForeground(int32_t callingUid)
|
||||
{
|
||||
return g_isForeground;
|
||||
}
|
||||
|
||||
void DistributedSchedStubTest::WaitHandlerTaskDone(const std::shared_ptr<AppExecFwk::EventHandler> &handler)
|
||||
{
|
||||
DTEST_LOG << "DistributedSchedStubTest::WaitHandlerTaskDone" << std::endl;
|
||||
@ -1440,8 +1448,10 @@ HWTEST_F(DistributedSchedStubTest, SetMissionContinueStateInner_001, TestSize.Le
|
||||
|
||||
int32_t missionId = 0;
|
||||
int32_t state = 0;
|
||||
int32_t callingUid = 0;
|
||||
data.WriteInt32(missionId);
|
||||
data.WriteInt32(state);
|
||||
data.WriteInt32(callingUid);
|
||||
int32_t result = DistributedSchedService::GetInstance().SetMissionContinueStateInner(data, reply);
|
||||
EXPECT_EQ(result, ERR_NONE);
|
||||
DTEST_LOG << "DistributedSchedStubTest SetMissionContinueStateInner_001 end" << std::endl;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "distributed_sched_test_util.h"
|
||||
#include "dms_token_callback.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "multi_user_manager.h"
|
||||
#include "test_log.h"
|
||||
|
||||
using namespace testing;
|
||||
@ -53,6 +54,13 @@ void DmsTokenCallbackTest::SetUp()
|
||||
DistributedSchedUtil::MockProcess(FOUNDATION_PROCESS_NAME);
|
||||
}
|
||||
|
||||
static bool g_isForeground = true;
|
||||
|
||||
bool MultiUserManager::IsCallerForeground(int32_t callingUid)
|
||||
{
|
||||
return g_isForeground;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SendResultTest_001
|
||||
* @tc.desc: call SendResult from distributedsched
|
||||
@ -160,6 +168,28 @@ HWTEST_F(DmsTokenCallbackTest, SendResultTest_005, TestSize.Level3)
|
||||
DTEST_LOG << "DmsTokenCallbackTest SendResultTest_005 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SendResultTest_006
|
||||
* @tc.desc: call SendResult with user is not foreground
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsTokenCallbackTest, SendResultTest_006, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsTokenCallbackTest SendResultTest_006 begin" << std::endl;
|
||||
ASSERT_NE(dmsTokenCallback_, nullptr);
|
||||
AAFwk::Want want;
|
||||
string remoteDeviceId = "remoteDeviceId";
|
||||
want.SetParam("dmsSrcNetworkId", remoteDeviceId);
|
||||
int32_t callerUid = 0;
|
||||
int32_t requestCode = 0;
|
||||
uint32_t accessToken = 0;
|
||||
int32_t resultCode = 0;
|
||||
g_isForeground = false;
|
||||
int32_t result = dmsTokenCallback_->SendResult(want, callerUid, requestCode, accessToken, resultCode);
|
||||
EXPECT_EQ(result, DMS_NOT_FOREGROUND_USER);
|
||||
DTEST_LOG << "DmsTokenCallbackTest SendResultTest_006 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CheckDeviceIdTest_001
|
||||
* @tc.desc: call CheckDeviceId with empty deviceId
|
||||
|
@ -198,7 +198,8 @@ HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions001, TestSize.Level1)
|
||||
{
|
||||
sptr<IDistributedSched> proxy = GetDms();
|
||||
ASSERT_NE(nullptr, proxy);
|
||||
auto ret = proxy->StartSyncRemoteMissions(DEVICE_ID, false, 0);
|
||||
int32_t callingUid = 0;
|
||||
auto ret = proxy->StartSyncRemoteMissions(DEVICE_ID, false, 0, callingUid);
|
||||
EXPECT_NE(ret, ERR_NONE);
|
||||
}
|
||||
|
||||
@ -211,7 +212,8 @@ HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions002, TestSize.Level1)
|
||||
{
|
||||
sptr<IDistributedSched> proxy = GetDms();
|
||||
ASSERT_NE(nullptr, proxy);
|
||||
auto ret = proxy->StartSyncRemoteMissions("", false, 0);
|
||||
int32_t callingUid = 0;
|
||||
auto ret = proxy->StartSyncRemoteMissions("", false, 0, callingUid);
|
||||
EXPECT_NE(ret, ERR_NONE);
|
||||
}
|
||||
|
||||
@ -224,7 +226,8 @@ HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions003, TestSize.Level1)
|
||||
{
|
||||
sptr<IDistributedSched> proxy = GetDms();
|
||||
ASSERT_NE(nullptr, proxy);
|
||||
auto ret = proxy->StartSyncRemoteMissions(localDeviceId_, false, 0);
|
||||
int32_t callingUid = 0;
|
||||
auto ret = proxy->StartSyncRemoteMissions(localDeviceId_, false, 0, callingUid);
|
||||
EXPECT_NE(ret, ERR_NONE);
|
||||
}
|
||||
|
||||
@ -428,7 +431,8 @@ HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions001, TestSize.Level1)
|
||||
{
|
||||
sptr<IDistributedSched> proxy = GetDms();
|
||||
ASSERT_NE(nullptr, proxy);
|
||||
auto ret = proxy->StopSyncRemoteMissions(DEVICE_ID);
|
||||
int32_t callingUid = 0;
|
||||
auto ret = proxy->StopSyncRemoteMissions(DEVICE_ID, callingUid);
|
||||
EXPECT_NE(ret, ERR_NONE);
|
||||
}
|
||||
|
||||
@ -441,7 +445,8 @@ HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions002, TestSize.Level1)
|
||||
{
|
||||
sptr<IDistributedSched> proxy = GetDms();
|
||||
ASSERT_NE(nullptr, proxy);
|
||||
auto ret = proxy->StopSyncRemoteMissions(localDeviceId_);
|
||||
int32_t callingUid = 0;
|
||||
auto ret = proxy->StopSyncRemoteMissions(localDeviceId_, callingUid);
|
||||
EXPECT_NE(ret, ERR_NONE);
|
||||
}
|
||||
|
||||
@ -454,7 +459,8 @@ HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions003, TestSize.Level1)
|
||||
{
|
||||
sptr<IDistributedSched> proxy = GetDms();
|
||||
ASSERT_NE(nullptr, proxy);
|
||||
auto ret = proxy->StopSyncRemoteMissions("");
|
||||
int32_t callingUid = 0;
|
||||
auto ret = proxy->StopSyncRemoteMissions("", callingUid);
|
||||
EXPECT_NE(ret, ERR_NONE);
|
||||
}
|
||||
|
||||
@ -584,13 +590,14 @@ HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener001, TestSize.Level1)
|
||||
{
|
||||
sptr<IDistributedSched> proxy = GetDms();
|
||||
ASSERT_NE(nullptr, proxy);
|
||||
auto ret = proxy->RegisterMissionListener(U16DEVICE_ID, nullptr);
|
||||
int32_t callingUid = 0;
|
||||
auto ret = proxy->RegisterMissionListener(U16DEVICE_ID, nullptr, callingUid);
|
||||
EXPECT_TRUE(ret != ERR_NONE);
|
||||
|
||||
ret = proxy->RegisterMissionListener(u16localDeviceId_, nullptr);
|
||||
ret = proxy->RegisterMissionListener(u16localDeviceId_, nullptr, callingUid);
|
||||
EXPECT_TRUE(ret != ERR_NONE);
|
||||
|
||||
ret = proxy->RegisterMissionListener(u"", nullptr);
|
||||
ret = proxy->RegisterMissionListener(u"", nullptr, callingUid);
|
||||
EXPECT_TRUE(ret != ERR_NONE);
|
||||
}
|
||||
|
||||
@ -604,13 +611,14 @@ HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener002, TestSize.Level1)
|
||||
sptr<IDistributedSched> proxy = GetDms();
|
||||
ASSERT_NE(nullptr, proxy);
|
||||
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
|
||||
auto ret = proxy->RegisterMissionListener(U16DEVICE_ID, listener);
|
||||
int32_t callingUid = 0;
|
||||
auto ret = proxy->RegisterMissionListener(U16DEVICE_ID, listener, callingUid);
|
||||
EXPECT_TRUE(ret != ERR_NONE);
|
||||
|
||||
ret = proxy->RegisterMissionListener(u16localDeviceId_, listener);
|
||||
ret = proxy->RegisterMissionListener(u16localDeviceId_, listener, callingUid);
|
||||
EXPECT_TRUE(ret != ERR_NONE);
|
||||
|
||||
ret = proxy->RegisterMissionListener(u"", listener);
|
||||
ret = proxy->RegisterMissionListener(u"", listener, callingUid);
|
||||
EXPECT_TRUE(ret != ERR_NONE);
|
||||
|
||||
ret = proxy->UnRegisterMissionListener(U16DEVICE_ID, listener);
|
||||
|
@ -97,12 +97,14 @@ int32_t MockDistributedSched::NotifyProcessDiedFromRemote(const CallerInfo& call
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
|
||||
int32_t MockDistributedSched::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag)
|
||||
int32_t MockDistributedSched::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag,
|
||||
int32_t callingUid)
|
||||
{
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t MockDistributedSched::RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj)
|
||||
int32_t MockDistributedSched::RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj,
|
||||
int32_t callingUid)
|
||||
{
|
||||
return ERR_NONE;
|
||||
}
|
||||
@ -143,12 +145,13 @@ int32_t MockDistributedSched::StopSyncMissionsFromRemote(const CallerInfo& calle
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t MockDistributedSched::StopSyncRemoteMissions(const std::string& devId)
|
||||
int32_t MockDistributedSched::StopSyncRemoteMissions(const std::string& devId, int32_t callingUid)
|
||||
{
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t MockDistributedSched::SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state)
|
||||
int32_t MockDistributedSched::SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state,
|
||||
int32_t callingUid)
|
||||
{
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ public:
|
||||
const AccountInfo& accountInfo) override;
|
||||
int32_t SendResultFromRemote(OHOS::AAFwk::Want& want, int32_t requestCode, const CallerInfo& callerInfo,
|
||||
const AccountInfo& accountInfo, int32_t resultCode) override;
|
||||
int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) override;
|
||||
int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId, int32_t missionId,
|
||||
const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) override;
|
||||
int32_t StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId, int32_t callerUid,
|
||||
int32_t status, uint32_t accessToken) override;
|
||||
void NotifyCompleteContinuation(const std::u16string& devId, int32_t sessionId, bool isSuccess) override;
|
||||
@ -51,8 +51,10 @@ public:
|
||||
int32_t uid, const std::string& sourceDeviceId) override;
|
||||
int32_t NotifyProcessDiedFromRemote(const CallerInfo& callerInfo) override;
|
||||
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
|
||||
int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override;
|
||||
int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) override;
|
||||
int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag,
|
||||
int32_t callingUid) override;
|
||||
int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj,
|
||||
int32_t callingUid) override;
|
||||
int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) override;
|
||||
int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions,
|
||||
std::vector<AAFwk::MissionInfo>& missionInfos) override;
|
||||
@ -63,8 +65,9 @@ public:
|
||||
int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
|
||||
std::vector<DstbMissionInfo>& missionInfos) override;
|
||||
int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) override;
|
||||
int32_t StopSyncRemoteMissions(const std::string& devId) override;
|
||||
int32_t SetMissionContinueState(const int32_t missionId, const OHOS::AAFwk::ContinueState &state) override;
|
||||
int32_t StopSyncRemoteMissions(const std::string& devId, int32_t callingUid) override;
|
||||
int32_t SetMissionContinueState(const int32_t missionId, const OHOS::AAFwk::ContinueState &state,
|
||||
int32_t callingUid) override;
|
||||
#endif
|
||||
int32_t StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
|
||||
int32_t callerUid, int32_t callerPid, uint32_t accessToken) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user