add permisison check

Signed-off-by: m00579239 <majiajun@huawei.com>
Change-Id: I2697b3f1e51b6c02a77a2bb4e3c3f645e2aa6bf4
This commit is contained in:
m00579239
2022-06-29 21:09:30 +08:00
parent 3571f23f8b
commit de46dfa985
16 changed files with 27 additions and 757 deletions
@@ -47,11 +47,8 @@ public:
void DeviceOffline(const std::string& deviceId);
void ProcessConnectDied(const sptr<IRemoteObject>& connect);
int32_t GetLocalMissionInfos(int32_t numMissions, std::vector<DstbMissionInfo>& missionInfos);
bool AllowMissionUid(int32_t uid);
int32_t RegisterMissionListener(const sptr<DistributedMissionChangeListener>& listener);
int32_t UnRegisterMissionListener(const sptr<DistributedMissionChangeListener>& listener);
int32_t GetOsdSwitch();
void OnOsdEventOccur(int32_t flag);
int32_t GetLocalMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
AAFwk::MissionSnapshot& missionSnapshot);
int32_t ReleaseAbility(const sptr<IRemoteObject>& connect, const AppExecFwk::ElementName &element);
@@ -93,10 +93,6 @@ public:
std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot) = 0;
virtual int32_t NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo>& missionInfos,
const CallerInfo& callerInfo) = 0;
virtual int32_t CheckSupportOsd(const std::string& deviceId) = 0;
virtual void GetCachedOsdSwitch(std::vector<std::u16string>& deviceIds, std::vector<int32_t>& values) = 0;
virtual int32_t GetOsdSwitchValueFromRemote() = 0;
virtual int32_t UpdateOsdSwitchValueFromRemote(int32_t switchVal, const std::string& sourceDeviceId) = 0;
#endif
virtual int32_t StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
int32_t callerUid, int32_t callerPid, uint32_t accessToken) = 0;
@@ -63,10 +63,6 @@ public:
std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot) override;
int32_t NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo>& missionInfos,
const CallerInfo& callerInfo) override;
int32_t CheckSupportOsd(const std::string& deviceId) override;
void GetCachedOsdSwitch(std::vector<std::u16string>& deviceIds, std::vector<int32_t>& values) override;
int32_t GetOsdSwitchValueFromRemote() override;
int32_t UpdateOsdSwitchValueFromRemote(int32_t switchVal, const std::string& sourceDeviceId) override;
int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
std::vector<DstbMissionInfo>& missionInfos) override;
int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) override;
@@ -100,10 +100,6 @@ public:
void DumpSessionsLocked(const std::list<ConnectAbilitySession>& sessionsList, std::string& info);
void DumpElementLocked(const std::list<AppExecFwk::ElementName>& elementsList, std::string& info);
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
int32_t CheckSupportOsd(const std::string& deviceId) override;
void GetCachedOsdSwitch(std::vector<std::u16string>& deviceIds, std::vector<int32_t>& values) override;
int32_t GetOsdSwitchValueFromRemote() override;
int32_t UpdateOsdSwitchValueFromRemote(int32_t switchVal, const std::string& sourceDeviceId) 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;
@@ -39,17 +39,13 @@ private:
int32_t StartContinuationInner(MessageParcel& data, MessageParcel& reply);
int32_t NotifyCompleteContinuationInner(MessageParcel& data, MessageParcel& reply);
int32_t NotifyContinuationResultFromRemoteInner(MessageParcel& data, MessageParcel& reply);
bool CheckDmsRequestPermission();
int32_t ConnectRemoteAbilityInner(MessageParcel& data, MessageParcel& reply);
int32_t DisconnectRemoteAbilityInner(MessageParcel& data, MessageParcel& reply);
int32_t ConnectAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply);
int32_t DisconnectAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply);
int32_t NotifyProcessDiedFromRemoteInner(MessageParcel& data, MessageParcel& reply);
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
int32_t CheckSupportOsdInner(MessageParcel& data, MessageParcel& reply);
int32_t GetCachedOsdSwitchInner(MessageParcel& data, MessageParcel& reply);
int32_t GetMissionInfosInner(MessageParcel& data, MessageParcel& reply);
int32_t GetOsdSwitchValueFromRemoteInner(MessageParcel& data, MessageParcel& reply);
int32_t GetRemoteMissionSnapshotInfoInner(MessageParcel& data, MessageParcel& reply);
int32_t RegisterMissionListenerInner(MessageParcel& data, MessageParcel& reply);
int32_t UnRegisterMissionListenerInner(MessageParcel& data, MessageParcel& reply);
@@ -58,11 +54,7 @@ private:
int32_t StopSyncRemoteMissionsInner(MessageParcel& data, MessageParcel& reply);
int32_t StopSyncMissionsFromRemoteInner(MessageParcel& data, MessageParcel& reply);
int32_t NotifyMissionsChangedFromRemoteInner(MessageParcel& data, MessageParcel& reply);
int32_t NotifyOsdSwitchChangedInner(MessageParcel& data, MessageParcel& reply);
int32_t UpdateOsdSwitchValueFromRemoteInner(MessageParcel& data, MessageParcel& reply);
#endif
bool CheckCallingUid();
bool EnforceInterfaceToken(MessageParcel& data);
int32_t StartRemoteAbilityByCallInner(MessageParcel& data, MessageParcel& reply);
int32_t ReleaseRemoteAbilityInner(MessageParcel& data, MessageParcel& reply);
int32_t StartAbilityByCallFromRemoteInner(MessageParcel& data, MessageParcel& reply);
@@ -72,8 +64,11 @@ private:
int32_t NotifyCompleteFreeInstallFromRemoteInner(MessageParcel& data, MessageParcel& reply);
int32_t RegisterDistributedComponentListenerInner(MessageParcel& data, MessageParcel& reply);
int32_t GetDistributedComponentListInner(MessageParcel& data, MessageParcel& reply);
bool CheckDmsRequestPermission();
bool CheckCallingUid();
bool EnforceInterfaceToken(MessageParcel& data);
bool CallerInfoUnmarshalling(CallerInfo& callerInfo, MessageParcel& data);
using DistributedSchedFunc = int32_t(DistributedSchedStub::*)(MessageParcel& data, MessageParcel& reply);
std::map<uint32_t, DistributedSchedFunc> remoteFuncsMap_;
std::map<uint32_t, DistributedSchedFunc> localFuncsMap_;
@@ -100,14 +100,6 @@ public:
int32_t NotifyMissionsChangedToRemote(const std::vector<DstbMissionInfo>& missionInfos);
int32_t NotifyMissionsChangedFromRemote(const CallerInfo& callerInfo,
const std::vector<DstbMissionInfo>& missionInfos);
int32_t CheckSupportOsd(const std::string& deviceId);
int32_t CheckOsdSwitch(const std::string& deviceId);
void GetCachedOsdSwitch(std::vector<std::u16string>& deviceIds, std::vector<int32_t>& values);
int32_t GetOsdSwitchValueFromRemote();
int32_t UpdateOsdSwitchValueFromRemote(int32_t switchVal, const std::string& deviceId);
int32_t UpdateSwitchValueToRemote();
void UpdateConnCapSupportOsd(const std::string& deviceId);
void NotifyOsdSwitchChanged(bool needNotifyChanged);
void OnRemoteDmsDied(const wptr<IRemoteObject>& remote);
void NotifyDmsProxyProcessDied();
void OnDnetDied();
@@ -130,7 +122,6 @@ private:
{
return devId + "_" + std::to_string(missionId);
}
bool AllowMissionUid(int32_t uid);
int32_t StartSyncRemoteMissions(const std::string& dstDevId, const std::string& localDevId);
int32_t StartSyncRemoteMissions(const std::string& dstDevId, const sptr<IDistributedSched>& remoteDms);
void CleanMissionResources(const std::string& dstDevId);
@@ -142,16 +133,6 @@ private:
std::vector<DstbMissionInfo>& missionInfos);
void RebornMissionCache(const std::string& deviceId, const std::vector<DstbMissionInfo>& missionInfos);
void CleanMissionCache(const std::string& deviceId);
void UpdateSwitchValueToRemoteInner(std::set<std::string>& remoteSyncDeviceSet,
const std::string& localNetworkId);
void TryUpdateSwitchValueToRemote(const std::string& localNetworkId,
const std::string& destUuid, int32_t retryTime);
bool IsValidOsdSwitchValue(int32_t osdSwitchVal);
bool IsConnCapSupportOsd(const std::string& deviceId);
bool GetConnCapSupportOsd(const std::string& deviceId);
bool GetConnCapSupportOsdInnerLocked(const std::string& deviceId);
bool PreCheckSupportOsd(const std::string& deviceId);
void NotifyOsdSwitchChanged(bool needNotifyChanged, const std::string& deviceId, int32_t switchVal);
void OnMissionListenerDied(const sptr<IRemoteObject>& remote);
void OnRemoteDmsDied(const sptr<IRemoteObject>& remote);
void RetryRegisterMissionChange(int32_t retryTimes);
@@ -189,9 +170,6 @@ private:
std::mutex remoteDmsLock_;
std::shared_ptr<AppExecFwk::EventHandler> missionHandler_;
std::shared_ptr<AppExecFwk::EventHandler> updateHandler_;
std::mutex osdSwitchLock_;
std::map<std::string, int32_t> osdSwitchValueMap_; // key is uuid
std::map<std::string, bool> connCapSupportOsdMap_; // key is networkId
};
}
}
@@ -30,8 +30,6 @@ public:
static void NotifyMissionsChanged(const sptr<IRemoteObject>& remoteObject, const std::u16string& deviceId);
static void NotifyNetDisconnect(const sptr<IRemoteObject>& remoteObject, const std::u16string& deviceId,
int32_t state);
static void NotifyOsdSwitchChanged(const sptr<IRemoteObject>& remoteObject, const std::u16string& deviceId,
bool isSwitchOn);
};
} // namespace DistributedSchedule
} // namespace OHOS
@@ -315,15 +315,6 @@ int32_t DistributedSchedAdapter::GetLocalMissionInfos(int32_t numMissions,
return MissionInfoConverter::ConvertToDstbMissionInfos(amsMissions, missionInfos);
}
bool DistributedSchedAdapter::AllowMissionUid(int32_t uid)
{
if (uid < 0) {
HILOGE("AllowMissionUid invalid params!");
return false;
}
return true;
}
int32_t DistributedSchedAdapter::RegisterMissionListener(const sptr<DstbMissionChangeListener>& listener)
{
HILOGD("called.");
@@ -387,15 +378,6 @@ int32_t DistributedSchedAdapter::GetLocalMissionSnapshotInfo(const std::string&
HILOGD("pixelMap size:%{public}d", missionSnapshot.snapshot->GetCapacity());
return ERR_OK;
}
int32_t DistributedSchedAdapter::GetOsdSwitch()
{
return MISSION_OSD_ENABLED;
}
#endif
void DistributedSchedAdapter::OnOsdEventOccur(int32_t flag)
{
}
} // namespace DistributedSchedule
} // namespace OHOS
@@ -519,73 +519,6 @@ int32_t DistributedSchedProxy::NotifyMissionsChangedFromRemote(const std::vector
return result;
}
int32_t DistributedSchedProxy::CheckSupportOsd(const std::string& deviceId)
{
HILOGI("CheckSupportOsd is called");
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
HILOGE("CheckSupportOsd remote service is null");
return ERR_NULL_OBJECT;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) {
return ERR_FLATTEN_OBJECT;
}
PARCEL_WRITE_HELPER(data, String, deviceId);
return remote->SendRequest(CHECK_SUPPORTED_OSD, data, reply, option);
}
void DistributedSchedProxy::GetCachedOsdSwitch(std::vector<std::u16string>& deviceIds, std::vector<int32_t>& values)
{
HILOGI("GetCachedOsdSwitch is called");
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
HILOGE("GetCachedOsdSwitch remote service is null");
return;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) {
return;
}
int32_t error = remote->SendRequest(GET_CACHED_SUPPORTED_OSD, data, reply, option);
if (error != ERR_NONE) {
HILOGE("%{public}s transact failed, error: %{public}d", __func__, error);
return;
}
PARCEL_READ_HELPER_NORET(reply, String16Vector, &deviceIds);
PARCEL_READ_HELPER_NORET(reply, Int32Vector, &values);
return;
}
int32_t DistributedSchedProxy::GetOsdSwitchValueFromRemote()
{
HILOGI("GetOsdSwitchValueFromRemote is called");
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
HILOGE("GetOsdSwitchValueFromRemote remote service is null");
return ERR_NULL_OBJECT;
}
MessageParcel data;
if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) {
return ERR_FLATTEN_OBJECT;
}
MessageParcel reply;
MessageOption option { MessageOption::TF_SYNC, WAIT_TIME };
int32_t error = remote->SendRequest(CHECK_SUPPORT_OSD_FROM_REMOTE, data, reply, option);
if (error != ERR_NONE) {
HILOGE("%{public}s transact failed, error: %{public}d", __func__, error);
return error;
}
int32_t result = reply.ReadInt32();
HILOGD("%{public}s get result from server data = %{public}d", __func__, result);
return result;
}
int32_t DistributedSchedProxy::GetRemoteMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
std::unique_ptr<MissionSnapshot>& missionSnapshot)
{
@@ -619,33 +552,6 @@ int32_t DistributedSchedProxy::GetRemoteMissionSnapshotInfo(const std::string& n
missionSnapshot = std::move(missionSnapshotPtr);
return ERR_NONE;
}
int32_t DistributedSchedProxy::UpdateOsdSwitchValueFromRemote(int32_t switchVal,
const std::string& sourceDeviceId)
{
HILOGD("called");
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
HILOGE("remote service is null");
return ERR_NULL_OBJECT;
}
MessageParcel data;
if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) {
return ERR_FLATTEN_OBJECT;
}
PARCEL_WRITE_HELPER(data, Int32, switchVal);
PARCEL_WRITE_HELPER(data, String, sourceDeviceId);
MessageParcel reply;
MessageOption option { MessageOption::TF_SYNC, WAIT_TIME };
int32_t error = remote->SendRequest(NOTIFY_SWITCH_CHANGED_FROM_REMOTE, data, reply, option);
if (error != ERR_NONE) {
HILOGE("%{public}s transact failed, error: %{public}d", __func__, error);
return error;
}
int32_t result = reply.ReadInt32();
HILOGD("%{public}s get result from server data = %{public}d", __func__, result);
return result;
}
#endif
bool DistributedSchedProxy::CallerInfoMarshalling(const CallerInfo& callerInfo, MessageParcel& data)
@@ -1588,21 +1588,6 @@ int32_t DistributedSchedService::GetRemoteMissionSnapshotInfo(const std::string&
.GetRemoteMissionSnapshotInfo(networkId, missionId, missionSnapshot);
}
int32_t DistributedSchedService::CheckSupportOsd(const std::string& deviceId)
{
return DistributedSchedMissionManager::GetInstance().CheckSupportOsd(deviceId);
}
void DistributedSchedService::GetCachedOsdSwitch(std::vector<std::u16string>& deviceIds, std::vector<int32_t>& values)
{
return DistributedSchedMissionManager::GetInstance().GetCachedOsdSwitch(deviceIds, values);
}
int32_t DistributedSchedService::GetOsdSwitchValueFromRemote()
{
return DistributedSchedMissionManager::GetInstance().GetOsdSwitchValueFromRemote();
}
int32_t DistributedSchedService::RegisterMissionListener(const std::u16string& devId,
const sptr<IRemoteObject>& obj)
{
@@ -1636,13 +1621,6 @@ int32_t DistributedSchedService::StopSyncMissionsFromRemote(const CallerInfo& ca
DistributedSchedMissionManager::GetInstance().StopSyncMissionsFromRemote(callerInfo.sourceDeviceId);
return ERR_NONE;
}
int32_t DistributedSchedService::UpdateOsdSwitchValueFromRemote(int32_t switchVal,
const std::string& sourceDeviceId)
{
return DistributedSchedMissionManager::GetInstance()
.UpdateOsdSwitchValueFromRemote(switchVal, sourceDeviceId);
}
#endif
void CallerDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
@@ -62,15 +62,12 @@ DistributedSchedStub::DistributedSchedStub()
localFuncsMap_[DISCONNECT_REMOTE_ABILITY] = &DistributedSchedStub::DisconnectRemoteAbilityInner;
// request codes for mission manager
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
localFuncsMap_[CHECK_SUPPORTED_OSD] = &DistributedSchedStub::CheckSupportOsdInner;
localFuncsMap_[GET_REMOTE_MISSION_SNAPSHOT_INFO] = &DistributedSchedStub::GetRemoteMissionSnapshotInfoInner;
localFuncsMap_[REGISTER_MISSION_LISTENER] = &DistributedSchedStub::RegisterMissionListenerInner;
localFuncsMap_[UNREGISTER_MISSION_LISTENER] = &DistributedSchedStub::UnRegisterMissionListenerInner;
localFuncsMap_[GET_MISSION_INFOS] = &DistributedSchedStub::GetMissionInfosInner;
localFuncsMap_[START_SYNC_MISSIONS] = &DistributedSchedStub::StartSyncRemoteMissionsInner;
localFuncsMap_[STOP_SYNC_MISSIONS] = &DistributedSchedStub::StopSyncRemoteMissionsInner;
localFuncsMap_[SWITCH_CHANGED] = &DistributedSchedStub::NotifyOsdSwitchChangedInner;
localFuncsMap_[GET_CACHED_SUPPORTED_OSD] = &DistributedSchedStub::GetCachedOsdSwitchInner;
#endif
remoteFuncsMap_[START_ABILITY_FROM_REMOTE] = &DistributedSchedStub::StartAbilityFromRemoteInner;
remoteFuncsMap_[SEND_RESULT_FROM_REMOTE] = &DistributedSchedStub::SendResultFromRemoteInner;
@@ -81,13 +78,11 @@ DistributedSchedStub::DistributedSchedStub()
remoteFuncsMap_[NOTIFY_PROCESS_DIED_FROM_REMOTE] = &DistributedSchedStub::NotifyProcessDiedFromRemoteInner;
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
// request codes for mission manager
remoteFuncsMap_[CHECK_SUPPORT_OSD_FROM_REMOTE] = &DistributedSchedStub::GetOsdSwitchValueFromRemoteInner;
remoteFuncsMap_[START_SYNC_MISSIONS_FROM_REMOTE] =
&DistributedSchedStub::StartSyncMissionsFromRemoteInner;
remoteFuncsMap_[STOP_SYNC_MISSIONS_FROM_REMOTE] =
&DistributedSchedStub::StopSyncMissionsFromRemoteInner;
remoteFuncsMap_[NOTIFY_MISSIONS_CHANGED_FROM_REMOTE] = &DistributedSchedStub::NotifyMissionsChangedFromRemoteInner;
remoteFuncsMap_[NOTIFY_SWITCH_CHANGED_FROM_REMOTE] = &DistributedSchedStub::UpdateOsdSwitchValueFromRemoteInner;
#endif
remoteFuncsMap_[CONTINUE_MISSION] = &DistributedSchedStub::ContinueMissionInner;
// request codes for call ability
@@ -528,6 +523,9 @@ bool DistributedSchedStub::EnforceInterfaceToken(MessageParcel& data)
int32_t DistributedSchedStub::GetMissionInfosInner(MessageParcel& data, MessageParcel& reply)
{
HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
return DMS_PERMISSION_DENIED;
}
std::u16string deviceId = data.ReadString16();
int32_t numMissions = 0;
PARCEL_READ_HELPER(data, Int32, numMissions);
@@ -613,6 +611,10 @@ int32_t DistributedSchedStub::UnRegisterMissionListenerInner(MessageParcel& data
int32_t DistributedSchedStub::StartSyncMissionsFromRemoteInner(MessageParcel& data, MessageParcel& reply)
{
if (!CheckCallingUid()) {
HILOGW("request DENIED!");
return DMS_PERMISSION_DENIED;
}
CallerInfo callerInfo;
if (!CallerInfoUnmarshalling(callerInfo, data)) {
HILOGW("read callerInfo failed!");
@@ -635,6 +637,9 @@ int32_t DistributedSchedStub::StartSyncMissionsFromRemoteInner(MessageParcel& da
int32_t DistributedSchedStub::StopSyncRemoteMissionsInner(MessageParcel& data, MessageParcel& reply)
{
HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
return DMS_PERMISSION_DENIED;
}
u16string devId = data.ReadString16();
if (devId.empty()) {
HILOGW("read deviceId failed!");
@@ -646,6 +651,10 @@ int32_t DistributedSchedStub::StopSyncRemoteMissionsInner(MessageParcel& data, M
int32_t DistributedSchedStub::StopSyncMissionsFromRemoteInner(MessageParcel& data, MessageParcel& reply)
{
if (!CheckCallingUid()) {
HILOGW("request DENIED!");
return DMS_PERMISSION_DENIED;
}
CallerInfo callerInfo;
if (!CallerInfoUnmarshalling(callerInfo, data)) {
HILOGW("read callerInfo failed!");
@@ -655,33 +664,12 @@ int32_t DistributedSchedStub::StopSyncMissionsFromRemoteInner(MessageParcel& dat
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
}
int32_t DistributedSchedStub::CheckSupportOsdInner(MessageParcel& data, MessageParcel& reply)
{
HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
int64_t begin = GetTickCount();
std::u16string deviceId = data.ReadString16();
std::string u8DeviceId = Str16ToStr8(deviceId);
int32_t result = CheckSupportOsd(u8DeviceId);
HILOGI("result = %{public}d, deviceId = %{public}s spend %{public}" PRId64 " ms",
result, DnetworkAdapter::AnonymizeDeviceId(u8DeviceId).c_str(), GetTickCount() - begin);
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
}
int32_t DistributedSchedStub::GetCachedOsdSwitchInner(MessageParcel& data, MessageParcel& reply)
{
HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
std::vector<std::u16string> deviceIds;
std::vector<int32_t> values;
int64_t begin = GetTickCount();
GetCachedOsdSwitch(deviceIds, values);
HILOGI("spend %{public}" PRId64 " ms", GetTickCount() - begin);
PARCEL_WRITE_HELPER(reply, String16Vector, deviceIds);
PARCEL_WRITE_HELPER(reply, Int32Vector, values);
return ERR_NONE;
}
int32_t DistributedSchedStub::NotifyMissionsChangedFromRemoteInner(MessageParcel& data, MessageParcel& reply)
{
if (!CheckCallingUid()) {
HILOGW("request DENIED!");
return DMS_PERMISSION_DENIED;
}
int32_t version = data.ReadInt32();
HILOGD("version is %{public}d", version);
std::vector<DstbMissionInfo> missionInfos;
@@ -697,33 +685,11 @@ int32_t DistributedSchedStub::NotifyMissionsChangedFromRemoteInner(MessageParcel
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
}
int32_t DistributedSchedStub::GetOsdSwitchValueFromRemoteInner(MessageParcel& data, MessageParcel& reply)
{
int32_t result = GetOsdSwitchValueFromRemote();
HILOGI("result = %{public}d", result);
PARCEL_WRITE_HELPER(reply, Int32, result);
return ERR_NONE;
}
int32_t DistributedSchedStub::NotifyOsdSwitchChangedInner(MessageParcel& data, MessageParcel& reply)
{
int32_t result = DistributedSchedMissionManager::GetInstance().UpdateSwitchValueToRemote();
HILOGI("result: %{public}d!", result);
return ERR_NONE;
}
int32_t DistributedSchedStub::UpdateOsdSwitchValueFromRemoteInner(MessageParcel& data, MessageParcel& reply)
{
int32_t switchVal = data.ReadInt32();
std::string srcUuid = data.ReadString();
int32_t result = UpdateOsdSwitchValueFromRemote(switchVal, srcUuid);
HILOGD("srcUuid: %s, result: %d!",
srcUuid.c_str(), result);
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
}
int32_t DistributedSchedStub::StartSyncRemoteMissionsInner(MessageParcel& data, MessageParcel& reply)
{
if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
return DMS_PERMISSION_DENIED;
}
HILOGI("[PerformanceTest], IPC end = %{public}" PRId64, GetTickCount());
u16string devId = data.ReadString16();
if (devId.empty()) {
@@ -38,16 +38,11 @@ namespace DistributedSchedule {
namespace {
const std::string TAG = "DistributedSchedMissionManager";
constexpr size_t MAX_CACHED_ITEM = 10;
constexpr int32_t FIRST_APPLICATION_UID = 10000;
constexpr int32_t MULTIUSER_HAP_PER_USER_RANGE = 100000;
constexpr int32_t MAX_RETRY_TIMES = 15;
constexpr int32_t RETRY_DELAYED = 2000;
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
constexpr int32_t REGISTER_MISSION_LISTENER = 0;
constexpr int32_t UNREGISTER_MISSION_LISTENER = 1;
constexpr int64_t DELAY_TIME = 300;
const std::string INVAILD_LOCAL_DEVICE_ID = "-1";
}
namespace Mission {
@@ -76,10 +71,6 @@ int32_t DistributedSchedMissionManager::GetMissionInfos(const std::string& devic
int32_t numMissions, std::vector<AAFwk::MissionInfo>& missionInfos)
{
HILOGI("start!");
if (!AllowMissionUid(IPCSkeleton::GetCallingUid())) {
HILOGE("permission denied!");
return ERR_PERMISSION_DENIED;
}
if (!IsDeviceIdValidated(deviceId)) {
return INVALID_PARAMETERS_ERR;
}
@@ -220,10 +211,6 @@ int32_t DistributedSchedMissionManager::RemoveSnapshotInfo(const std::string& de
int32_t DistributedSchedMissionManager::GetRemoteMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot)
{
if (!AllowMissionUid(IPCSkeleton::GetCallingUid())) {
HILOGE("permission denied!");
return DMS_PERMISSION_DENIED;
}
std::string uuid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUuidByNetworkId(networkId);
if (uuid.empty()) {
HILOGE("uuid is empty!");
@@ -287,46 +274,8 @@ void DistributedSchedMissionManager::DeviceOfflineNotify(const std::string& devi
remoteDmsMap_.erase(iter);
}
}
int64_t begin = GetTickCount();
{
std::lock_guard<std::mutex> autoLock(osdSwitchLock_);
connCapSupportOsdMap_.erase(deviceId);
}
HILOGI("DeviceOfflineNotify erase value for deviceId: %{public}s spend %{public}" PRId64 " ms",
DnetworkAdapter::AnonymizeDeviceId(deviceId).c_str(), GetTickCount() - begin);
}
void DistributedSchedMissionManager::UpdateConnCapSupportOsd(const std::string& deviceId)
{
HILOGI("UpdateConnCapSupportOsd begin, deviceId is %{public}s",
HILOGI("DeviceOfflineNotify erase value for deviceId: %{public}s",
DnetworkAdapter::AnonymizeDeviceId(deviceId).c_str());
bool isSupportOsd = IsConnCapSupportOsd(deviceId);
bool needNotifyChanged = false;
int32_t switchVal = MISSION_OSD_NOT_SUPPORTED;
{
std::string uuid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUuidByNetworkId(deviceId);
std::lock_guard<std::mutex> autoLock(osdSwitchLock_);
auto iter = connCapSupportOsdMap_.find(deviceId);
if (iter != connCapSupportOsdMap_.end()) {
needNotifyChanged = (iter->second != isSupportOsd);
} else {
needNotifyChanged = true;
}
connCapSupportOsdMap_[deviceId] = isSupportOsd;
HILOGI("UpdateConnCapSupportOsd end, isSupportOsd is %{public}d", isSupportOsd);
auto iterOsdSwitch = osdSwitchValueMap_.find(uuid);
if (isSupportOsd && iterOsdSwitch == osdSwitchValueMap_.end()) {
HILOGI("UpdateConnCapSupportOsd can not find osd switch value!");
return;
}
switchVal = isSupportOsd ? iterOsdSwitch->second : MISSION_OSD_NOT_SUPPORTED;
}
NotifyOsdSwitchChanged(needNotifyChanged, deviceId, switchVal);
}
bool DistributedSchedMissionManager::IsConnCapSupportOsd(const std::string& deviceId)
{
return true;
}
void DistributedSchedMissionManager::DeleteDataStorage(const std::string& deviceId, bool isDelayed)
@@ -368,10 +317,6 @@ int32_t DistributedSchedMissionManager::RegisterMissionListener(const std::u16st
if (listener == nullptr) {
return INVALID_PARAMETERS_ERR;
}
if (!AllowMissionUid(IPCSkeleton::GetCallingUid())) {
HILOGE("permission denied!");
return DMS_PERMISSION_DENIED;
}
std::string localDeviceId;
std::string remoteDeviceId = Str16ToStr8(devId);
if (!DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId)
@@ -395,11 +340,6 @@ int32_t DistributedSchedMissionManager::RegisterMissionListener(const std::u16st
return ERR_NONE;
}
}
if (CheckOsdSwitch(remoteDeviceId) != MISSION_OSD_ENABLED) {
NotifyOsdSwitchChanged(true, remoteDeviceId, MISSION_OSD_NOT_SUPPORTED);
return MISSION_OSD_NOT_SUPPORTED;
}
return ERR_NONE;
}
@@ -460,10 +400,6 @@ int32_t DistributedSchedMissionManager::UnRegisterMissionListener(const std::u16
if (listener == nullptr) {
return INVALID_PARAMETERS_ERR;
}
if (!AllowMissionUid(IPCSkeleton::GetCallingUid())) {
HILOGE("permission denied!");
return DMS_PERMISSION_DENIED;
}
std::string localDeviceId;
if (!DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId)
|| localDeviceId == Str16ToStr8(devId)) {
@@ -549,11 +485,6 @@ int32_t DistributedSchedMissionManager::StartSyncRemoteMissions(const std::strin
HILOGI("begin, dstDevId is %{public}s, local deviceId is %{public}s",
DnetworkAdapter::AnonymizeDeviceId(dstDevId).c_str(),
DnetworkAdapter::AnonymizeDeviceId(localDeviceId).c_str());
if (dstDevId != INVAILD_LOCAL_DEVICE_ID && dstDevId != localDeviceId &&
CheckOsdSwitch(dstDevId) != MISSION_OSD_ENABLED) {
NotifyOsdSwitchChanged(true, dstDevId, MISSION_OSD_NOT_SUPPORTED);
return MISSION_OSD_NOT_SUPPORTED;
}
auto ret = StartSyncRemoteMissions(dstDevId, localDeviceId);
if (ret != ERR_NONE) {
HILOGE("StartSyncRemoteMissions failed, %{public}d", ret);
@@ -570,13 +501,6 @@ int32_t DistributedSchedMissionManager::StartSyncMissionsFromRemote(const Caller
{
std::lock_guard<std::mutex> autoLock(remoteSyncDeviceLock_);
remoteSyncDeviceSet_.emplace(deviceId);
if (remoteSyncDeviceSet_.size() == 1) {
DistributedSchedAdapter::GetInstance().OnOsdEventOccur(REGISTER_MISSION_LISTENER);
}
}
if (GetOsdSwitchValueFromRemote() != MISSION_OSD_ENABLED) {
HILOGI("osd function is disable!");
return ERR_NONE;
}
int32_t result = DistributedSchedAdapter::GetInstance().GetLocalMissionInfos(Mission::GET_MAX_MISSIONS,
missionInfos);
@@ -606,7 +530,6 @@ void DistributedSchedMissionManager::StopSyncMissionsFromRemote(const std::strin
auto func = [this]() {
int32_t ret = DistributedSchedAdapter::GetInstance().UnRegisterMissionListener(missonChangeListener_);
if (ret == ERR_OK) {
DistributedSchedAdapter::GetInstance().OnOsdEventOccur(UNREGISTER_MISSION_LISTENER);
isRegMissionChange_ = false;
}
};
@@ -972,156 +895,6 @@ std::shared_ptr<AppExecFwk::EventHandler> DistributedSchedMissionManager::FetchD
return handler;
}
bool DistributedSchedMissionManager::GetConnCapSupportOsd(const std::string& deviceId)
{
HILOGI("GetConnCapSupportOsd begin, deviceId is %{public}s",
DnetworkAdapter::AnonymizeDeviceId(deviceId).c_str());
std::lock_guard<std::mutex> autoLock(osdSwitchLock_);
return GetConnCapSupportOsdInnerLocked(deviceId);
}
bool DistributedSchedMissionManager::GetConnCapSupportOsdInnerLocked(const std::string& deviceId)
{
bool connCapSupportOsd = false;
auto iter = connCapSupportOsdMap_.find(deviceId);
if (iter != connCapSupportOsdMap_.end()) {
connCapSupportOsd = iter->second;
HILOGI("CheckSupportOsd find connCapSupportOsd is %{public}d", connCapSupportOsd);
} else {
HILOGI("CheckSupportOsd can not find connCapSupportOsd, try to get it!");
connCapSupportOsd = IsConnCapSupportOsd(deviceId);
connCapSupportOsdMap_[deviceId] = connCapSupportOsd;
}
return connCapSupportOsd;
}
bool DistributedSchedMissionManager::PreCheckSupportOsd(const std::string& deviceId)
{
if (!AllowMissionUid(IPCSkeleton::GetCallingUid())) {
HILOGE("CheckSupportOsd permission denied!");
return false;
}
if (!IsDeviceIdValidated(deviceId)) {
HILOGE("DeviceId is inValidated!");
return false;
}
if (!GetConnCapSupportOsd(deviceId)) {
HILOGI("CheckSupportOsd conn cap not support osd!");
return false;
}
return true;
}
int32_t DistributedSchedMissionManager::CheckSupportOsd(const std::string& deviceId)
{
HILOGI("CheckSupportOsd start, deviceId: %{public}s!",
DnetworkAdapter::AnonymizeDeviceId(deviceId).c_str());
if (!PreCheckSupportOsd(deviceId)) {
return MISSION_OSD_NOT_SUPPORTED;
}
int64_t begin = GetTickCount();
{
std::string uuid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUuidByNetworkId(deviceId);
std::lock_guard<std::mutex> autoLock(osdSwitchLock_);
auto iter = osdSwitchValueMap_.find(uuid);
if (iter != osdSwitchValueMap_.end()) {
HILOGI("CheckSupportOsd find value spend %{public}" PRId64 " ms", GetTickCount() - begin);
return iter->second;
}
}
HILOGI("CheckSupportOsd can not find value spend %{public}" PRId64 " ms", GetTickCount() - begin);
sptr<IDistributedSched> remoteDms = GetRemoteDms(deviceId);
if (remoteDms == nullptr) {
HILOGE("CheckSupportOsd DMS get remoteDms failed");
return MISSION_OSD_NOT_SUPPORTED;
}
begin = GetTickCount();
int32_t osdSwitchVal = remoteDms->GetOsdSwitchValueFromRemote();
HILOGI("[PerformanceTest] GetOsdSwitchValueFromRemote osdSwitch:%d, spend %{public}" PRId64 " ms",
osdSwitchVal, GetTickCount() - begin);
if (osdSwitchVal == IPC_STUB_UNKNOW_TRANS_ERR) {
HILOGI("GetOsdSwitchValueFromRemote destUuid: %{public}s does not support osd result: %{public}d",
DnetworkAdapter::AnonymizeDeviceId(deviceId).c_str(), osdSwitchVal);
osdSwitchVal = MISSION_OSD_NOT_SUPPORTED;
}
if (!IsValidOsdSwitchValue(osdSwitchVal)) {
HILOGE("CheckSupportOsd osdSwitch %{public}d is invalid!", osdSwitchVal);
return MISSION_OSD_NOT_SUPPORTED;
}
begin = GetTickCount();
std::string uuid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUuidByNetworkId(deviceId);
std::lock_guard<std::mutex> autoLock(osdSwitchLock_);
osdSwitchValueMap_[uuid] = osdSwitchVal;
HILOGI("CheckSupportOsd insert value spend %{public}" PRId64 " ms", GetTickCount() - begin);
return osdSwitchVal;
}
int32_t DistributedSchedMissionManager::CheckOsdSwitch(const std::string& deviceId)
{
HILOGI("CheckOsdSwitch start, deviceId: %{public}s!",
DnetworkAdapter::AnonymizeDeviceId(deviceId).c_str());
if (!PreCheckSupportOsd(deviceId)) {
return MISSION_OSD_NOT_SUPPORTED;
}
int64_t begin = GetTickCount();
{
std::string uuid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUuidByNetworkId(deviceId);
std::lock_guard<std::mutex> autoLock(osdSwitchLock_);
auto iter = osdSwitchValueMap_.find(uuid);
if (iter != osdSwitchValueMap_.end()) {
HILOGI("CheckOsdSwitch find value spend %{public}" PRId64 " ms", GetTickCount() - begin);
return iter->second;
}
}
HILOGI("CheckOsdSwitch can not find value spend %{public}" PRId64 " ms", GetTickCount() - begin);
return MISSION_OSD_ENABLED;
}
void DistributedSchedMissionManager::GetCachedOsdSwitch(std::vector<std::u16string>& deviceIds,
std::vector<int32_t>& values)
{
HILOGI("GetCachedOsdSwitch start");
if (!AllowMissionUid(IPCSkeleton::GetCallingUid())) {
HILOGE("GetCachedOsdSwitch permission denied!");
return;
}
std::lock_guard<std::mutex> autoLock(osdSwitchLock_);
for (const auto& [uuid, value] : osdSwitchValueMap_) {
std::string deviceId = DtbschedmgrDeviceInfoStorage::GetInstance().GetNetworkIdByUuid(uuid);
deviceIds.emplace_back(Str8ToStr16(deviceId));
bool connCapSupportOsd = GetConnCapSupportOsdInnerLocked(deviceId);
values.emplace_back(connCapSupportOsd ? value : MISSION_OSD_NOT_SUPPORTED);
}
}
int32_t DistributedSchedMissionManager::GetOsdSwitchValueFromRemote()
{
HILOGI("GetOsdSwitchValueFromRemote start!");
return DistributedSchedAdapter::GetInstance().GetOsdSwitch();
}
bool DistributedSchedMissionManager::AllowMissionUid(int32_t uid)
{
int32_t appId = uid % MULTIUSER_HAP_PER_USER_RANGE;
if (appId < FIRST_APPLICATION_UID) {
return true;
}
std::lock_guard<std::mutex> autoLock(allowMissionUidsLock_);
if (allowMissionUids_.count(appId) == 0) {
int64_t begin = GetTickCount();
bool ret = DistributedSchedAdapter::GetInstance().AllowMissionUid(uid);
HILOGI("AllowMissionUid ret:%{public}s, spend %{public}" PRId64 " ms!",
(ret ? "succ" : "fail"), GetTickCount() - begin);
if (!ret) {
HILOGW("AllowMissionUid failed!");
return false;
}
allowMissionUids_.insert(appId);
}
return true;
}
void DistributedSchedMissionManager::RemoteDmsDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
{
HILOGI("OnRemoteDied received died notify!");
@@ -1166,139 +939,6 @@ void DistributedSchedMissionManager::RetryStartSyncRemoteMissions(const std::str
}
}
int32_t DistributedSchedMissionManager::UpdateOsdSwitchValueFromRemote(int32_t switchVal,
const std::string& deviceId)
{
HILOGI("UpdateOsdSwitchValueFromRemote notify start, switchVal: %{public}d, deviceId: %{public}s!",
switchVal, DnetworkAdapter::AnonymizeDeviceId(deviceId).c_str());
bool needNotifyChanged = false;
bool connCap = false;
int64_t begin = GetTickCount();
{
std::string uuid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUuidByNetworkId(deviceId);
std::lock_guard<std::mutex> autoLock(osdSwitchLock_);
auto iter = osdSwitchValueMap_.find(uuid);
if (iter != osdSwitchValueMap_.end()) {
needNotifyChanged = (iter->second != switchVal);
} else {
needNotifyChanged = true;
}
osdSwitchValueMap_[uuid] = switchVal;
connCap = GetConnCapSupportOsdInnerLocked(deviceId);
}
HILOGI("UpdateOsdSwitchValueFromRemote update value spend %{public}" PRId64 " ms", GetTickCount() - begin);
NotifyOsdSwitchChanged(needNotifyChanged, deviceId, connCap ? switchVal : MISSION_OSD_NOT_SUPPORTED);
HILOGD("UpdateOsdSwitchValueFromRemote end!");
return ERR_NONE;
}
void DistributedSchedMissionManager::NotifyOsdSwitchChanged(bool needNotifyChanged, const std::string& deviceId,
int32_t switchVal)
{
std::lock_guard<std::mutex> autoLock(listenDeviceLock_);
if (!needNotifyChanged) {
HILOGI("NotifyOsdSwitchChanged no need to notify!");
return;
}
auto iter = listenDeviceMap_.find(Str8ToStr16(deviceId));
if (iter == listenDeviceMap_.end()) {
HILOGI("NotifyOsdSwitchChanged notify no listener!");
return;
}
auto& listenerSet = iter->second.listenerSet;
auto notifyChanged = [listenerSet, deviceId, switchVal, this] () {
HILOGI("NotifyOsdSwitchChanged %{public}s!",
DnetworkAdapter::AnonymizeDeviceId(deviceId).c_str());
bool isSwitchOn = (switchVal == MISSION_OSD_ENABLED);
for (const auto& listener : listenerSet) {
MissionChangedNotify::NotifyOsdSwitchChanged(listener, Str8ToStr16(deviceId), isSwitchOn);
}
};
if (missionHandler_ != nullptr && !missionHandler_->PostTask(notifyChanged)) {
HILOGE("NotifyOsdSwitchChanged PostTask failed!");
}
}
int32_t DistributedSchedMissionManager::UpdateSwitchValueToRemote()
{
auto callback = [this] () {
std::string localNetworkId;
if (!DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localNetworkId)) {
HILOGE("UpdateSwitchValueToRemote get local uuid failed!");
return;
}
std::set<std::string> remoteSyncDeviceSet;
DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceIdSet(remoteSyncDeviceSet);
UpdateSwitchValueToRemoteInner(remoteSyncDeviceSet, localNetworkId);
};
if (updateHandler_ == nullptr) {
HILOGE("UpdateSwitchValueToRemote updateHandler_ is nullptr");
return ERR_NULL_OBJECT;
}
if (!updateHandler_->PostTask(callback)) {
HILOGE("UpdateSwitchValueToRemote PostTask failed!");
return ERR_NULL_OBJECT;
}
return ERR_NONE;
}
void DistributedSchedMissionManager::UpdateSwitchValueToRemoteInner(std::set<std::string>& remoteSyncDeviceSet,
const std::string& localNetworkId)
{
HILOGD("UpdateSwitchValueToRemote Start");
for (auto iter = remoteSyncDeviceSet.begin(); iter != remoteSyncDeviceSet.end(); iter++) {
TryUpdateSwitchValueToRemote(localNetworkId, *iter, 0);
}
}
void DistributedSchedMissionManager::TryUpdateSwitchValueToRemote(const std::string& localNetworkId,
const std::string& destUuid, int32_t retryTime)
{
std::lock_guard<std::mutex> autoLock(remoteSyncDeviceLock_);
auto handler = FetchDeviceHandler(destUuid);
auto callback = [retryTime, localNetworkId, destUuid, this] () {
sptr<IDistributedSched> remoteDms = GetRemoteDms(destUuid);
int32_t result = ERR_FLATTEN_OBJECT;
if (remoteDms != nullptr) {
int64_t begin = GetTickCount();
int32_t switchVal = DistributedSchedAdapter::GetInstance().GetOsdSwitch();
HILOGI("TryUpdateSwitchValueToRemote switchVal: %{public}d, destUuid: %{public}s retry:%{public}d",
switchVal, DnetworkAdapter::AnonymizeDeviceId(destUuid).c_str(), retryTime);
if (!IsValidOsdSwitchValue(switchVal)) {
HILOGI("UpdateSwitchValueToRemote invalid switch value %{public}d!", switchVal);
return;
}
result = remoteDms->UpdateOsdSwitchValueFromRemote(switchVal, localNetworkId);
HILOGI("[PerformanceTest] TryUpdateSwitchValueToRemote ret:%d, spend %{public}" PRId64 " ms",
result, GetTickCount() - begin);
} else {
HILOGE("TryUpdateSwitchValueToRemote DMS get remoteDms failed");
}
if (result == IPC_STUB_UNKNOW_TRANS_ERR) {
HILOGI("TryUpdateSwitchValueToRemote destUuid: %{public}s does not support osd result: %{public}d",
DnetworkAdapter::AnonymizeDeviceId(destUuid).c_str(), result);
return;
}
if (result != ERR_NONE) {
TryUpdateSwitchValueToRemote(localNetworkId, destUuid, retryTime + 1);
HILOGI("DMS TryUpdateSwitchValueToRemote retry");
}
HILOGI("DMS TryUpdateSwitchValueToRemote result:%{public}d", result);
};
if (handler != nullptr && retryTime < MAX_RETRY_TIMES) {
handler->PostTask(callback, DELAY_TIME);
}
}
bool DistributedSchedMissionManager::IsValidOsdSwitchValue(int32_t osdSwitchVal)
{
return osdSwitchVal == MISSION_OSD_NOT_SUPPORTED || osdSwitchVal == MISSION_OSD_NOT_ENABLED ||
osdSwitchVal == MISSION_OSD_ENABLED || osdSwitchVal == MISSION_OSD_CCM_NOT_SUPPORTED ||
osdSwitchVal == MISSION_OSD_WIFI_OFF || osdSwitchVal == MISSION_OSD_CHILDMODE_ON ||
osdSwitchVal == MISSION_OSD_CLOUD_SWITCH_OFF;
}
void DistributedSchedMissionManager::OnMissionListenerDied(const sptr<IRemoteObject>& remote)
{
HILOGI("OnMissionListenerDied");
@@ -1464,7 +1104,6 @@ void DistributedSchedMissionManager::OnDnetDied()
}
remoteSyncDeviceSet_.clear();
DistributedSchedAdapter::GetInstance().UnRegisterMissionListener(missonChangeListener_);
DistributedSchedAdapter::GetInstance().OnOsdEventOccur(UNREGISTER_MISSION_LISTENER);
isRegMissionChange_ = false;
};
if (missionHandler_ != nullptr) {
@@ -25,7 +25,6 @@ namespace {
constexpr int32_t CODE_NOTIFY_MISSION = 0;
constexpr int32_t NOTIFY_SNAP_SHOT = 1;
constexpr int32_t NOTIFY_NET_DISCONNECT = 2;
constexpr int32_t CODE_NOTIFY_SWITCH = 4;
const std::u16string DESCRIPTOR = u"ohos.aafwk.RemoteMissionListener";
const std::string TAG = "MissionChangedNotify";
@@ -106,31 +105,5 @@ void MissionChangedNotify::NotifyNetDisconnect(const sptr<IRemoteObject>& remote
}
HILOGI("NotifyNetDisconnect finished!");
}
void MissionChangedNotify::NotifyOsdSwitchChanged(const sptr<IRemoteObject>& remoteObject,
const std::u16string& deviceId, bool isSwitchOn)
{
HILOGI("NotifyOsdSwitchChanged start!");
if (remoteObject == nullptr) {
HILOGE("NotifyOsdSwitchChanged remote service is null!");
return;
}
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC);
if (!data.WriteInterfaceToken(DESCRIPTOR)) {
HILOGE("NotifyOsdSwitchChanged write interface token failed!");
return;
}
PARCEL_WRITE_HELPER_NORET(data, String, Str16ToStr8(deviceId));
PARCEL_WRITE_HELPER_NORET(data, Bool, isSwitchOn);
HILOGI("[PerformanceTest] NotifyOsdSwitchChanged called, IPC begin = %{public}" PRId64, GetTickCount());
int32_t error = remoteObject->SendRequest(CODE_NOTIFY_SWITCH, data, reply, option);
if (error != ERR_NONE) {
HILOGE("NotifyOsdSwitchChanged fail, error: %{public}d", error);
return;
}
HILOGI("NotifyOsdSwitchChanged finished!");
}
} // namespace DistributedSchedule
} // namespace OHOS
@@ -297,7 +297,7 @@ HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener002, TestSize.Level1)
EXPECT_TRUE(ret != ERR_NONE);
ret = proxy->UnRegisterMissionListener(U16DEVICE_ID, listener);
EXPECT_TRUE(ret == ERR_NONE);
EXPECT_TRUE(ret != ERR_NONE);
ret = proxy->UnRegisterMissionListener(u16localDeviceId_, listener);
EXPECT_TRUE(ret != ERR_NONE);
@@ -375,109 +375,5 @@ HWTEST_F(DMSMissionManagerTest, testFetchCachedRemoteMissions001, TestSize.Level
auto ret = DistributedSchedMissionManager::GetInstance().FetchCachedRemoteMissions(DEVICE_ID, 0, infos);
EXPECT_TRUE(ret != ERR_NONE);
}
/**
* @tc.name: testFetchCachedRemoteMissions001
* @tc.desc: test check support osd fake device, return error code
* @tc.type: FUNC
* @tc.require:AR000GK67M
*/
HWTEST_F(DMSMissionManagerTest, testCheckSupportOsd001, TestSize.Level1)
{
auto ret = DistributedSchedMissionManager::GetInstance().CheckSupportOsd(DEVICE_ID);
EXPECT_TRUE(ret != ERR_NONE);
}
/**
* @tc.name: testFetchCachedRemoteMissions002
* @tc.desc: test check support osd fake device, return error code
* @tc.type: FUNC
* @tc.require:AR000GK67M
*/
HWTEST_F(DMSMissionManagerTest, testCheckSupportOsd002, TestSize.Level1)
{
auto ret = DistributedSchedMissionManager::GetInstance().CheckSupportOsd(DEVICE_ID);
EXPECT_TRUE(ret != ERR_NONE);
ret = DistributedSchedMissionManager::GetInstance().CheckSupportOsd("");
EXPECT_TRUE(ret != ERR_NONE);
}
/**
* @tc.name: GetOsdSwitchValueFromRemote001
* @tc.desc: test GetOsdSwitchValueFromRemote, return error code
* @tc.type: FUNC
* @tc.require:AR000GK67M
*/
HWTEST_F(DMSMissionManagerTest, GetOsdSwitchValueFromRemote001, TestSize.Level1)
{
auto ret = DistributedSchedMissionManager::GetInstance().GetOsdSwitchValueFromRemote();
EXPECT_TRUE(ret != ERR_NONE);
}
/**
* @tc.name: testUpdateOsdSwitchValueFromRemote001
* @tc.desc: test UpdateOsdSwitchValueFromRemote fake device, return error code
* @tc.type: FUNC
* @tc.require:AR000GK67M
*/
HWTEST_F(DMSMissionManagerTest, testUpdateOsdSwitchValueFromRemote001, TestSize.Level1)
{
auto ret = DistributedSchedMissionManager::GetInstance().UpdateOsdSwitchValueFromRemote(0, DEVICE_ID);
EXPECT_TRUE(ret == ERR_NONE);
}
/**
* @tc.name: testUpdateOsdSwitchValueFromRemote002
* @tc.desc: test UpdateOsdSwitchValueFromRemote fake device, return error code
* @tc.type: FUNC
* @tc.require:AR000GK67M
*/
HWTEST_F(DMSMissionManagerTest, testUpdateOsdSwitchValueFromRemote002, TestSize.Level1)
{
auto ret = DistributedSchedMissionManager::GetInstance().UpdateOsdSwitchValueFromRemote(0, DEVICE_ID);
EXPECT_TRUE(ret == ERR_NONE);
ret = DistributedSchedMissionManager::GetInstance().UpdateOsdSwitchValueFromRemote(1, DEVICE_ID);
EXPECT_TRUE(ret == ERR_NONE);
}
/**
* @tc.name: testUpdateOsdSwitchValueFromRemote003
* @tc.desc: test UpdateOsdSwitchValueFromRemote fake device, return error code
* @tc.type: FUNC
* @tc.require:AR000GK67M
*/
HWTEST_F(DMSMissionManagerTest, testUpdateOsdSwitchValueFromRemote003, TestSize.Level1)
{
auto ret = DistributedSchedMissionManager::GetInstance().UpdateOsdSwitchValueFromRemote(0, "");
EXPECT_TRUE(ret == ERR_NONE);
ret = DistributedSchedMissionManager::GetInstance().UpdateOsdSwitchValueFromRemote(1, "");
EXPECT_TRUE(ret == ERR_NONE);
}
/**
* @tc.name: testUpdateSwitchValueToRemote001
* @tc.desc: test UpdateSwitchValueToRemote, return error code
* @tc.type: FUNC
* @tc.require:AR000GK67M
*/
HWTEST_F(DMSMissionManagerTest, testUpdateSwitchValueToRemote001, TestSize.Level1)
{
auto ret = DistributedSchedMissionManager::GetInstance().UpdateSwitchValueToRemote();
EXPECT_TRUE(ret != ERR_NONE);
}
/**
* @tc.name: testUpdateSwitchValueToRemote002
* @tc.desc: test check support osd fake device, return error code
* @tc.type: FUNC
* @tc.require:AR000GK67M
*/
HWTEST_F(DMSMissionManagerTest, testUpdateSwitchValueToRemote002, TestSize.Level1)
{
auto ret = DistributedSchedMissionManager::GetInstance().UpdateSwitchValueToRemote();
EXPECT_TRUE(ret != ERR_NONE);
ret = DistributedSchedMissionManager::GetInstance().UpdateSwitchValueToRemote();
EXPECT_TRUE(ret != ERR_NONE);
}
} // namespace DistributedSchedule
} // namespace OHOS
@@ -125,22 +125,6 @@ int32_t MockDistributedSched::NotifyMissionsChangedFromRemote(const std::vector<
return ERR_NONE;
}
int32_t MockDistributedSched::CheckSupportOsd(const std::string& deviceId)
{
return ERR_NONE;
}
void MockDistributedSched::GetCachedOsdSwitch(std::vector<std::u16string>& deviceIds,
std::vector<int32_t>& values)
{
return;
}
int32_t MockDistributedSched::GetOsdSwitchValueFromRemote()
{
return ERR_NONE;
}
int32_t MockDistributedSched::GetMissionInfos(const std::string& deviceId, int32_t numMissions,
std::vector<MissionInfo>& missionInfos)
{
@@ -162,12 +146,6 @@ int32_t MockDistributedSched::StopSyncRemoteMissions(const std::string& devId)
{
return ERR_NONE;
}
int32_t MockDistributedSched::UpdateOsdSwitchValueFromRemote(int32_t switchVal,
const std::string& sourceDeviceId)
{
return ERR_NONE;
}
#endif
int32_t MockDistributedSched::StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want,
@@ -60,10 +60,6 @@ public:
std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot) override;
int32_t NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo>& missionInfos,
const CallerInfo& callerInfo) override;
int32_t CheckSupportOsd(const std::string& deviceId) override;
void GetCachedOsdSwitch(std::vector<std::u16string>& deviceIds, std::vector<int32_t>& values) override;
int32_t GetOsdSwitchValueFromRemote() override;
int32_t UpdateOsdSwitchValueFromRemote(int32_t switchVal, const std::string& sourceDeviceId) override;
int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
std::vector<DstbMissionInfo>& missionInfos) override;
int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) override;