Merge branch 'master' of gitee.com:openharmony/ability_dmsfwk into master

Signed-off-by: baishunqin <baishunqin@huawei.com>
This commit is contained in:
baishunqin 2025-01-02 02:17:45 +00:00 committed by Gitee
commit 4174516b6c
34 changed files with 1267 additions and 110 deletions

View File

@ -252,7 +252,7 @@ std::string Base64Encode(const unsigned char *toEncode, unsigned int len)
unsigned char charArray3[3];
unsigned char charArray4[4];
while (length--) {
while (length > 0) {
charArray3[i++] = *(toEncode++);
if (i == sizeof(charArray3)) {
charArray4[INDEX_FIRST] = (charArray3[INDEX_FIRST] & PARAM_FC) >> OFFSET2;
@ -266,6 +266,7 @@ std::string Base64Encode(const unsigned char *toEncode, unsigned int len)
}
i = 0;
}
length--;
}
if (i > 0) {

View File

@ -33,6 +33,7 @@ declare_args() {
dmsfwk_av_enable_surface_cache = false
dmsfwk_av_trans_stream_debug = false
dmsfwk_av_trans_pixel_map_debug = false
dmsfwk_continuous_task_enable = false
if (defined(global_parts_info)) {
if (defined(global_parts_info.multimedia_image_framework)) {
dmsfwk_mission_manager = true
@ -52,6 +53,9 @@ declare_args() {
if (defined(global_parts_info.multimodalinput_input)) {
dmsfwk_mmi_listener = true
}
if (defined(global_parts_info.resourceschedule_background_task_mgr)) {
dmsfwk_continuous_task_enable = true
}
}
if (!defined(global_parts_info) ||
defined(global_parts_info.distributedhardware_device_manager)) {

View File

@ -31,9 +31,12 @@ config("common_public_config") {
ohos_shared_library("common_sdk") {
branch_protector_ret = "pac_ret"
sanitize = {
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
debug = false
integer_overflow = true
ubsan = true
}
sources = [
@ -46,6 +49,12 @@ ohos_shared_library("common_sdk") {
"//foundation/ability/dmsfwk/services/dtbschedmgr/test/resource:coverage_flags",
]
ldflags = [
"-fpie",
"-Wl,-z,relro",
"-Wl,-z,now",
]
deps = [ "../../innerkits/continuation_manager:continuation_manager" ]
external_deps = [

View File

@ -29,9 +29,12 @@ config("continuation_manager_public_config") {
ohos_shared_library("continuation_manager") {
branch_protector_ret = "pac_ret"
sanitize = {
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
debug = false
integer_overflow = true
ubsan = true
}
sources = [
@ -45,6 +48,12 @@ ohos_shared_library("continuation_manager") {
"//foundation/ability/dmsfwk/services/dtbschedmgr/test/resource:coverage_flags",
]
ldflags = [
"-fpie",
"-Wl,-z,relro",
"-Wl,-z,now",
]
external_deps = [
"c_utils:utils",
"hilog:libhilog",

View File

@ -33,9 +33,12 @@ config("dms_sdk_public_config") {
ohos_shared_library("distributed_sdk") {
branch_protector_ret = "pac_ret"
sanitize = {
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
debug = false
integer_overflow = true
ubsan = true
}
sources = [
@ -51,6 +54,12 @@ ohos_shared_library("distributed_sdk") {
"${dms_path}/services/dtbschedmgr/test/resource:coverage_flags",
]
ldflags = [
"-fpie",
"-Wl,-z,relro",
"-Wl,-z,now",
]
external_deps = [
"c_utils:utils",
"device_info_manager:distributed_device_profile_common",

View File

@ -69,6 +69,11 @@ void JsAbilityConnectionSessionListener::CallJsMethod(const EventCallbackInfo& c
void JsAbilityConnectionSessionListener::CallJsMethodInner(const EventCallbackInfo& callbackInfo)
{
if (callbackRef_ == nullptr) {
HILOGE("callbackRef_ is nullptr");
return;
}
napi_value method = callbackRef_->GetNapiValue();
if (method == nullptr) {
HILOGE("Failed to get method from object");

View File

@ -30,9 +30,12 @@ config("continuationmanager_napi_public_config") {
ohos_shared_library("continuationmanager_napi") {
branch_protector_ret = "pac_ret"
sanitize = {
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
debug = false
integer_overflow = true
ubsan = true
}
sources = [
@ -46,6 +49,12 @@ ohos_shared_library("continuationmanager_napi") {
"//foundation/ability/dmsfwk/services/dtbschedmgr/test/resource:coverage_flags",
]
ldflags = [
"-fpie",
"-Wl,-z,relro",
"-Wl,-z,now",
]
deps = [
"${dms_path}/common:distributed_sched_utils",
"../../../innerkits/common:common_sdk",

View File

@ -33,9 +33,12 @@ config("distributed_ability_manager_config") {
ohos_shared_library("distributed_ability_manager_svr") {
branch_protector_ret = "pac_ret"
sanitize = {
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
debug = false
integer_overflow = true
ubsan = true
}
install_enable = true
@ -59,7 +62,12 @@ ohos_shared_library("distributed_ability_manager_svr") {
"//foundation/ability/dmsfwk/services/dtbschedmgr/test/resource:coverage_flags",
]
ldflags = [ "-rdynamic" ]
ldflags = [
"-rdynamic",
"-fpie",
"-Wl,-z,relro",
"-Wl,-z,now",
]
deps = [
"../../interfaces/innerkits/common:common_sdk",

View File

@ -1212,24 +1212,5 @@ HWTEST_F(DistributedAbilityManagerServiceTest, HandleNotifierDied_002, TestSize.
EXPECT_NE(dtbabilitymgrService_, nullptr);
DTEST_LOG << "DistributedAbilityManagerServiceTest HandleNotifierDied_002 end" << std::endl;
}
/**
* @tc.name: HandleDeviceConnect_003
* @tc.desc: test HandleDeviceConnect
* @tc.type: FUNC
*/
HWTEST_F(DistributedAbilityManagerServiceTest, HandleDeviceConnect_003, TestSize.Level3)
{
DTEST_LOG << "DistributedAbilityManagerServiceTest HandleDeviceConnect_003 start" << std::endl;
ASSERT_NE(nullptr, dtbabilitymgrService_);
std::vector<ContinuationResult> continuationResults;
dtbabilitymgrService_->OnStart();
int32_t ret = dtbabilitymgrService_->HandleDeviceConnect(nullptr, continuationResults);
EXPECT_EQ(ret, false);
ret = dtbabilitymgrService_->HandleDeviceDisconnect(nullptr, continuationResults);
EXPECT_EQ(ret, false);
DTEST_LOG << "DistributedAbilityManagerServiceTest HandleDeviceConnect_003 end" << std::endl;
}
}
}

View File

@ -48,7 +48,8 @@ public:
int32_t AcceptConnect(int32_t sessionId, const std::string& token);
int32_t Reject(const std::string& token, const std::string& reason);
int32_t NotifyCollabResult(int32_t sessionId, int32_t result, const std::string& peerServerName);
int32_t NotifyCollabResult(int32_t sessionId, int32_t result, const std::string& peerServerName,
const std::string& dmsServerToken);
int32_t NotifyDisconnect(int32_t sessionId);
int32_t SendMessage(int32_t sessionId, const std::string& msg);

View File

@ -25,7 +25,8 @@ public:
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedCollab.IAbilityConnectionManager");
virtual ~IAbilityConnectionManager() {};
virtual int32_t NotifyCollabResult(int32_t sessionId, int32_t result, const std::string& peerSocketName) = 0;
virtual int32_t NotifyCollabResult(int32_t sessionId, int32_t result, const std::string& peerSocketName,
const std::string& dmsServerToken) = 0;
virtual int32_t NotifyDisconnect(int32_t sessionId) = 0;
enum class Message {

View File

@ -26,7 +26,8 @@ public:
AbilityConnectionManagerListener() = default;
~AbilityConnectionManagerListener() = default;
int32_t NotifyCollabResult(int32_t sessionId, int32_t result, const std::string& peerServerName) override;
int32_t NotifyCollabResult(int32_t sessionId, int32_t result, const std::string& peerServerName,
const std::string& dmsServerToken) override;
int32_t NotifyDisconnect(int32_t sessionId) override;
};
} // namespace DistributedCollab

View File

@ -84,7 +84,7 @@ public:
int32_t Disconnect();
int32_t AcceptConnect(const std::string& token);
int32_t HandleCollabResult(int32_t result, const std::string& peerSocketName);
int32_t HandleCollabResult(int32_t result, const std::string& peerSocketName, const std::string& dmsServerToken);
int32_t HandleDisconnect();
int32_t SendMessage(const std::string& msg, const MessageType& messageType = MessageType::MESSAGE_NORMAL);
@ -135,6 +135,7 @@ private:
int32_t ConfigEngineParam(std::shared_ptr<T> &engine, const SurfaceParams& param);
void UpdateTransChannelStatus(int32_t channelId, bool isConnect);
int32_t GetTransChannelInfo(const TransChannelType& type, TransChannelInfo& info);
bool IsStreamBytesChannel(const int32_t channelId);
void ExeuteConnectCallback(const ConnectResult& result);
int32_t ExeuteEventCallback(const std::string& eventType, const EventCallbackInfo& info);

View File

@ -146,7 +146,7 @@ int32_t AbilityConnectionManager::DestroySession(int32_t sessionId)
return INVALID_PARAMETERS_ERR;
}
connectionSesion->Release();
connectionSesion->Disconnect();
connectionSesion->UnInit();
std::unique_lock<std::shared_mutex> writeLock(sessionMutex_);
@ -210,7 +210,7 @@ int32_t AbilityConnectionManager::Reject(const std::string& token, const std::st
}
int32_t AbilityConnectionManager::NotifyCollabResult(int32_t sessionId, int32_t result,
const std::string& peerServerName)
const std::string& peerServerName, const std::string& dmsServerToken)
{
HILOGD("called, sessionId is %{public}d", sessionId);
auto connectionSesion = GetAbilityConnectionSession(sessionId);
@ -219,7 +219,7 @@ int32_t AbilityConnectionManager::NotifyCollabResult(int32_t sessionId, int32_t
return INVALID_PARAMETERS_ERR;
}
return connectionSesion->HandleCollabResult(result, peerServerName);
return connectionSesion->HandleCollabResult(result, peerServerName, dmsServerToken);
}
int32_t AbilityConnectionManager::NotifyDisconnect(int32_t sessionId)

View File

@ -25,9 +25,10 @@ const std::string TAG = "AbilityConnectionManagerListener";
}
int32_t AbilityConnectionManagerListener::NotifyCollabResult(int32_t sessionId,
int32_t result, const std::string& peerServerName)
int32_t result, const std::string& peerServerName, const std::string& dmsServerToken)
{
return AbilityConnectionManager::GetInstance().NotifyCollabResult(sessionId, result, peerServerName);
return AbilityConnectionManager::GetInstance().NotifyCollabResult(sessionId,
result, peerServerName, dmsServerToken);
}
int32_t AbilityConnectionManagerListener::NotifyDisconnect(int32_t sessionId)

View File

@ -79,7 +79,9 @@ int32_t AbilityConnectionManagerStub::NotifyCollabResultInner(MessageParcel& dat
PARCEL_READ_HELPER(data, Bool, startResult);
std::string peerSocketName = "";
PARCEL_READ_HELPER(data, String, peerSocketName);
int32_t result = NotifyCollabResult(sessionId, startResult, peerSocketName);
std::string dmsServerToken = "";
PARCEL_READ_HELPER(data, String, dmsServerToken);
int32_t result = NotifyCollabResult(sessionId, startResult, peerSocketName, dmsServerToken);
HILOGI("result = %{public}d", result);
PARCEL_WRITE_HELPER(reply, Int32, result);
return ERR_NONE;

View File

@ -39,7 +39,6 @@ constexpr const char* EVENT_RECEIVE_DATA = "receiveData";
constexpr const char* EVENT_RECEIVE_IMAGE = "receiveImage";
constexpr int32_t DSCHED_COLLAB_PROTOCOL_VERSION = 1;
static constexpr uint16_t PROTOCOL_VERSION = 1;
constexpr int32_t CONNECTION_TIMEOUT = 20000;
constexpr int32_t CHANNEL_NAME_LENGTH = 48;
constexpr int32_t VIDEO_BIT_RATE = 640000;
constexpr int32_t VIDEO_FRAME_RATE = 30;
@ -153,15 +152,15 @@ int32_t AbilityConnectionSession::Connect(ConnectCallback& callback)
sessionStatus_ = SessionStatus::CONNECTING;
connectCallback_ = callback;
}
direction_ = CollabrateDirection::COLLABRATE_SOURCE;
SetTimeOut(CONNECTION_TIMEOUT);
DistributedClient dmsClient;
int32_t ret = dmsClient.CollabMission(sessionId_, localSocketName_, localInfo_, peerInfo_, connectOption_);
if (ret != ERR_OK) {
HILOGE("collab mission start failed.");
ExeuteConnectCallback(new ConnectResult(false));
ConnectResult connectResult;
connectResult.isConnected = false;
ExeuteConnectCallback(connectResult);
}
return ret;
}
@ -203,39 +202,57 @@ int32_t AbilityConnectionSession::AcceptConnect(const std::string& token)
return ERR_OK;
}
int32_t AbilityConnectionSession::HandleCollabResult(int32_t result, const std::string& peerSocketName)
int32_t AbilityConnectionSession::HandleCollabResult(int32_t result, const std::string& peerSocketName,
const std::string& dmsServerToken)
{
HILOGD("called.");
if (result != ERR_OK) {
HILOGE("collab result is failed, ret = %{public}d", result);
ExeuteConnectCallback(new ConnectResult(false));
ConnectResult connectResult;
connectResult.isConnected = false;
ExeuteConnectCallback(connectResult);
return INVALID_PARAMETERS_ERR;
}
dmsServerToken_ = dmsServerToken;
peerSocketName_ = peerSocketName;
if (InitChannels() != ERR_OK) {
DistributedClient dmsClient;
dmsClient.NotifyCloseCollabSession(dmsServerToken_);
ExeuteConnectCallback(new ConnectResult(false));
ConnectResult connectResult;
connectResult.isConnected = false;
ExeuteConnectCallback(connectResult);
return INVALID_PARAMETERS_ERR;
}
if (ConnectChannels() != ERR_OK) {
DistributedClient dmsClient;
dmsClient.NotifyCloseCollabSession(dmsServerToken_);
ExeuteConnectCallback(new ConnectResult(false));
ConnectResult connectResult;
connectResult.isConnected = false;
ExeuteConnectCallback(connectResult);
return INVALID_PARAMETERS_ERR;
}
std::unique_lock<std::shared_mutex> sessionStatusWriteLock(sessionMutex_);
sessionStatus_ = SessionStatus::CONNECTED;
ExeuteConnectCallback(new ConnectResult(true));
ConnectResult connectResult;
connectResult.isConnected = true;
ExeuteConnectCallback(connectResult);
return ERR_OK;
}
int32_t AbilityConnectionSession::HandleDisconnect()
{
HILOGD("called.");
{
std::shared_lock<std::shared_mutex> sessionStatusReadLock(sessionMutex_);
if (sessionStatus_ == SessionStatus::UNCONNECTED) {
HILOGI("The session resource has been released.");
return ERR_OK;
}
}
EventCallbackInfo callbackInfo;
callbackInfo.sessionId = sessionId_;
callbackInfo.reason = DisconnectReason::PEER_APP_EXIT;
@ -617,13 +634,14 @@ int32_t AbilityConnectionSession::InitChannels()
return ret;
}
ret = CreateChannel(channelName, ChannelDataType::BYTES, TransChannelType::STREAM_CHANNEL_BYTES);
std::string streamChannelName = channelName + "stream";
ret = CreateChannel(streamChannelName, ChannelDataType::BYTES, TransChannelType::STREAM_CHANNEL_BYTES);
if (ret != ERR_OK) {
HILOGE("init bytes channel failed!");
return INVALID_PARAMETERS_ERR;
}
ret = CreateChannel(channelName, ChannelDataType::VIDEO_STREAM, TransChannelType::STREAM_CHANNEL);
ret = CreateChannel(streamChannelName, ChannelDataType::VIDEO_STREAM, TransChannelType::STREAM_CHANNEL);
if (ret != ERR_OK) {
HILOGE("init bytes channel failed!");
return INVALID_PARAMETERS_ERR;
@ -645,12 +663,11 @@ int32_t AbilityConnectionSession::CreateChannel(const std::string& channelName,
return INVALID_PARAMETERS_ERR;
}
int32_t ret = channelManager.RegisterChannelListener(channelId, channelListener_);
if (ret != ERR_OK) {
if (channelManager.RegisterChannelListener(channelId, channelListener_) != ERR_OK) {
HILOGE("register channel listener failed, channelId is %{public}d", channelId);
return INVALID_PARAMETERS_ERR;
}
std::unique_lock<std::shared_mutex> channelWriteLock(transChannelMutex_);
TransChannelInfo channelInfo = {channelId, dataType, channelType, false};
transChannels_.emplace(channelType, channelInfo);
@ -944,6 +961,11 @@ void AbilityConnectionSession::OnBytesReceived(int32_t channelId, const std::sha
return;
}
if (IsStreamBytesChannel(channelId)) {
HILOGE("is stream bytes channel, no need to send.");
return;
}
EventCallbackInfo callbackInfo;
callbackInfo.sessionId = sessionId_;
callbackInfo.data = dataBuffer;
@ -951,6 +973,18 @@ void AbilityConnectionSession::OnBytesReceived(int32_t channelId, const std::sha
ExeuteEventCallback(EVENT_RECEIVE_DATA, callbackInfo);
}
bool AbilityConnectionSession::IsStreamBytesChannel(const int32_t channelId)
{
TransChannelInfo transChannelInfo;
int32_t ret = GetTransChannelInfo(TransChannelType::STREAM_CHANNEL_BYTES, transChannelInfo);
if (ret != ERR_OK) {
HILOGE("stream bytes channel not exit!");
return false;
}
return transChannelInfo.channelId == channelId;
}
bool AbilityConnectionSession::IsVaildChannel(const int32_t channelId)
{
HILOGD("called");

View File

@ -85,20 +85,27 @@ config("distributed_sched_config") {
if (dmsfwk_sync_data_on_package_event) {
defines += [ "DMS_SYNC_DATA_ON_PACKAGE_EVENT" ]
}
if (dmsfwk_continuous_task_enable) {
defines += [ "BGTASKMGR_CONTINUOUS_TASK_ENABLE" ]
}
}
ohos_shared_library("distributedschedsvr") {
branch_protector_ret = "pac_ret"
sanitize = {
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
debug = false
integer_overflow = true
ubsan = true
}
install_enable = true
cflags = [ "-fpie" ]
if (!dmsfwk_softbus_adapter_common) {
cflags = [
cflags += [
"-DDMSFWK_SAME_ACCOUNT",
"-DDMSFWK_INTERACTIVE_ADAPTER",
"-DDMSFWK_ALL_CONNECT_MGR",
@ -188,6 +195,11 @@ ohos_shared_library("distributedschedsvr") {
"//foundation/ability/dmsfwk/services/dtbschedmgr/test/resource:coverage_flags",
]
ldflags = [
"-Wl,-z,relro",
"-Wl,-z,now",
]
deps = [ "${dms_path}/common:distributed_sched_utils" ]
external_deps = [
@ -241,6 +253,10 @@ ohos_shared_library("distributedschedsvr") {
sources += [ "src/form_mgr_death_recipient.cpp" ]
}
if (dmsfwk_continuous_task_enable) {
external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
}
if (dmsfwk_mission_manager) {
sources += [
"src/mission/bluetooth_state_adapter.cpp",

View File

@ -17,6 +17,9 @@
#define OHOS_ABILITY_STATE_OBSERVER_H
#include "application_state_observer_stub.h"
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
#include "background_task_mgr_helper.h"
#endif
namespace OHOS {
namespace DistributedSchedule {

View File

@ -75,7 +75,6 @@ private:
void RemoveTimeout(const std::string &collabToken);
bool IsSessionExists(const DSchedCollabInfo &info);
std::string GenerateCollabToken(const std::string &sourceDeviceId);
bool CheckBackgroundPermissions();
class SoftbusListener : public IDataListener {
void OnBind(int32_t socket, PeerSocketInfo info);

View File

@ -84,7 +84,7 @@ public:
void NotifyDied(const sptr<IRemoteObject>& obj);
void NotifyDeviceOffline(const std::string& networkId);
void NotifyPackageRemoved(const std::string& sinkBundleName);
void NotifyIconDisappear(uint16_t bundleNameId, const currentIconInfo& continueInfo, const int32_t state);
void NotifyIconDisappear(uint16_t bundleNameId, const std::string &senderNetworkId, const int32_t state);
int32_t NotifyDockDisplay(uint16_t bundleNameId, const currentIconInfo& continueInfo, const int32_t state);
void OnDeviceScreenOff();
void OnContinueSwitchOff();

View File

@ -33,13 +33,32 @@ void AbilityLifecycleObserver::OnForegroundApplicationChanged(const AppExecFwk::
void AbilityLifecycleObserver::OnAbilityStateChanged(const AppExecFwk::AbilityStateData& abilityStateData)
{
HILOGI("called, abilityState: %{public}d", abilityStateData.abilityState);
if (abilityStateData.abilityState == static_cast<int32_t>(SliteAbilityState::STATE_BACKGROUND)) {
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
if (abilityStateData.abilityState == static_cast<int32_t>(SliteAbilityState::STATE_BACKGROUND)) {
std::vector<std::shared_ptr<BackgroundTaskMgr::ContinuousTaskCallbackInfo>> continuousTasksInfos;
int32_t result = BackgroundTaskMgr::BackgroundTaskMgrHelper::GetContinuousTaskApps(continuousTasksInfos);
if (result != ERR_OK) {
HILOGE("failed to GetContinuousTaskApps, err: %{public}d", result);
return;
}
for (auto continuousTasksInfo : continuousTasksInfos) {
if (continuousTasksInfo == nullptr) {
continue;
}
if (continuousTasksInfo->GetCreatorPid() == abilityStateData.pid) {
HILOGW("called, find the pid in continuous tasks");
return;
}
}
HILOGW("called, can't find the pid in continuous tasks");
DSchedCollabManager::GetInstance().ReleaseAbilityLink(abilityStateData.bundleName, abilityStateData.pid);
} else if (abilityStateData.abilityState == static_cast<int32_t>(SliteAbilityState::STATE_FOREGROUND) ||
abilityStateData.abilityState == static_cast<int32_t>(SliteAbilityState::STATE_INITIAL)) {
DSchedCollabManager::GetInstance().CancleReleaseAbilityLink(abilityStateData.bundleName, abilityStateData.pid);
}
#else
HILOGE("failed to check continuousTaskApps");
#endif
HILOGI("end.");
}

View File

@ -562,6 +562,7 @@ int32_t DSchedCollab::ExeSrcClientNotify(const int32_t &result)
PARCEL_WRITE_HELPER(data, Int32, collabInfo_.srcCollabSessionId_);
PARCEL_WRITE_HELPER(data, Int32, result);
PARCEL_WRITE_HELPER(data, String, collabInfo_.sinkInfo_.socketName_);
PARCEL_WRITE_HELPER(data, String, collabInfo_.collabToken_);
MessageParcel reply;
MessageOption option;
int32_t ret = collabInfo_.srcClientCB_->SendRequest(NOTIFY_COLLAB_PREPARE_RESULT, data, reply, option);

View File

@ -451,15 +451,13 @@ void DSchedCollabManager::HandleReleaseAbilityLink(const std::string &bundleName
continue;
}
dSchedCollabInfo = iter->second->GetCollabInfo();
if (bundleName == dSchedCollabInfo.srcInfo_.bundleName_ && pid == dSchedCollabInfo.srcInfo_.pid_ &&
CheckBackgroundPermissions() == true) {
if (bundleName == dSchedCollabInfo.srcInfo_.bundleName_ && pid == dSchedCollabInfo.srcInfo_.pid_) {
HILOGI("source ability been background, collabInfo: %{public}s", dSchedCollabInfo.ToString().c_str());
PrivilegeShutdown(static_cast<uint64_t>(dSchedCollabInfo.srcInfo_.accessToken_),
pid, dSchedCollabInfo.sinkInfo_.deviceId_.c_str());
iter->second->PostEndTask();
}
if (bundleName == dSchedCollabInfo.srcInfo_.bundleName_ && pid == dSchedCollabInfo.sinkInfo_.pid_ &&
CheckBackgroundPermissions() == true) {
if (bundleName == dSchedCollabInfo.srcInfo_.bundleName_ && pid == dSchedCollabInfo.sinkInfo_.pid_) {
HILOGI("sink ability been background, collabInfo: %{public}s", dSchedCollabInfo.ToString().c_str());
iter->second->PostEndTask();
}
@ -467,11 +465,6 @@ void DSchedCollabManager::HandleReleaseAbilityLink(const std::string &bundleName
return;
}
bool DSchedCollabManager::CheckBackgroundPermissions()
{
return false;
}
int32_t DSchedCollabManager::CancleReleaseAbilityLink(const std::string &bundleName, const int32_t &pid)
{
HILOGW("called");

View File

@ -35,12 +35,12 @@ const string TAG = "DistributedDataChangeListener";
struct KeyInfo {
string uuid;
int32_t missionId = 0;
static constexpr int32_t MAX_SPLIT_VARS = 2;
static constexpr int32_t maxSplitVars = 2;
static unique_ptr<KeyInfo> ParseInfo(const std::string& strKey)
{
vector<string> strVector;
SplitStr(strKey, "_", strVector);
if (strVector.size() != MAX_SPLIT_VARS) {
if (strVector.size() != maxSplitVars) {
HILOGI("ParseInfo key invalid!");
return nullptr;
}

View File

@ -338,23 +338,20 @@ int32_t DMSContinueRecvMgr::DealOnBroadcastBusiness(const std::string& senderNet
if (!GetFinalBundleName(distributedBundleInfo, finalBundleName, localBundleInfo, continueType)) {
HILOGE("The app is not installed on the local device.");
NotifyIconDisappear(bundleNameId,
currentIconInfo(senderNetworkId, bundleName, finalBundleName, continueType), state);
NotifyIconDisappear(bundleNameId, senderNetworkId, state);
return INVALID_PARAMETERS_ERR;
}
HILOGI("got finalBundleName: %{public}s", finalBundleName.c_str());
if (localBundleInfo.applicationInfo.bundleType != AppExecFwk::BundleType::APP) {
HILOGE("The bundleType must be app, but it is %{public}d", localBundleInfo.applicationInfo.bundleType);
NotifyIconDisappear(bundleNameId,
currentIconInfo(senderNetworkId, bundleName, finalBundleName, continueType), state);
NotifyIconDisappear(bundleNameId, senderNetworkId, state);
return INVALID_PARAMETERS_ERR;
}
if (state == ACTIVE
&& !IsBundleContinuable(localBundleInfo, abilityInfo.abilityName, abilityInfo.moduleName, continueType)) {
HILOGE("Bundle %{public}s is not continuable", finalBundleName.c_str());
NotifyIconDisappear(bundleNameId,
currentIconInfo(senderNetworkId, bundleName, finalBundleName, continueType), state);
NotifyIconDisappear(bundleNameId, senderNetworkId, state);
return BUNDLE_NOT_CONTINUABLE;
}
@ -371,11 +368,11 @@ int32_t DMSContinueRecvMgr::DealOnBroadcastBusiness(const std::string& senderNet
return ERR_OK;
}
void DMSContinueRecvMgr::NotifyIconDisappear(uint16_t bundleNameId, const currentIconInfo& continueInfo,
void DMSContinueRecvMgr::NotifyIconDisappear(uint16_t bundleNameId, const std::string &senderNetworkId,
const int32_t state)
{
if (state == ACTIVE && continueInfo.senderNetworkId == iconInfo_.senderNetworkId) {
NotifyDockDisplay(bundleNameId, continueInfo, INACTIVE);
if (state == ACTIVE && senderNetworkId == iconInfo_.senderNetworkId) {
NotifyDockDisplay(bundleNameId, iconInfo_, INACTIVE);
}
}

View File

@ -374,8 +374,9 @@ bool MultiUserManager::IsUserForeground(int32_t accountId)
}
if (!accounts.empty() && accounts[0].localId == accountId) {
isForeground = true;
HILOGD("Current account. accounts[0].localId: %{public}d.", accounts[0].localId);
}
HILOGD("Current account. accounts[0].localId: %{public}d, accountId: %{public}d.", accounts[0].localId, accountId);
HILOGD("Current account. accountId: %{public}d.", accountId);
return isForeground;
}

View File

@ -215,8 +215,12 @@ void DSchedSoftbusSession::AssembleNoFrag(std::shared_ptr<DSchedDataBuffer> buff
return;
}
std::shared_ptr<DSchedDataBuffer> postData = std::make_shared<DSchedDataBuffer>(headerPara.dataLen);
int32_t ret = memcpy_s(postData->Data(), postData->Size(), buffer->Data() + BINARY_HEADER_FRAG_LEN,
buffer->Size() - BINARY_HEADER_FRAG_LEN);
if (buffer->Size() < BINARY_HEADER_FRAG_LEN) {
HILOGE("buffer size unusual, size = %{public}zu", buffer->Size());
return;
}
uint32_t dataSize = static_cast<uint32_t>(buffer->Size() - BINARY_HEADER_FRAG_LEN);
int32_t ret = memcpy_s(postData->Data(), postData->Size(), buffer->Data() + BINARY_HEADER_FRAG_LEN, dataSize);
if (ret != ERR_OK) {
HILOGE("memcpy failed, ret: %{public}d, sessionId: %{public}d, peerNetworkId: %{public}s.",
ret, sessionId_, GetAnonymStr(peerDeviceId_).c_str());
@ -234,8 +238,13 @@ void DSchedSoftbusSession::AssembleFrag(std::shared_ptr<DSchedDataBuffer> buffer
offset_ = 0;
totalLen_ = headerPara.totalLen;
packBuffer_ = std::make_shared<DSchedDataBuffer>(headerPara.totalLen);
if (buffer->Size() < BINARY_HEADER_FRAG_LEN) {
HILOGE("buffer size unusual, size = %{public}zu", buffer->Size());
return;
}
uint32_t dataSize = static_cast<uint32_t>(buffer->Size() - BINARY_HEADER_FRAG_LEN);
int32_t ret = memcpy_s(packBuffer_->Data(), packBuffer_->Size(), buffer->Data() + BINARY_HEADER_FRAG_LEN,
buffer->Size() - BINARY_HEADER_FRAG_LEN);
dataSize);
if (ret != ERR_OK) {
HILOGE("FRAG_START memcpy fail, ret: %{public}d, sessionId: %{public}d peerNetworkId: %{public}s.",
ret, sessionId_, GetAnonymStr(peerDeviceId_).c_str());

View File

@ -34,7 +34,7 @@ namespace {
const std::u16string DMS_STUB_INTERFACE_TOKEN = u"ohos.distributedschedule.accessToken";
const std::u16string MOCK_INVALID_DESCRIPTOR = u"invalid descriptor";
constexpr const char* FOUNDATION_PROCESS_NAME = "foundation";
constexpr int32_t CAllING_UID = 10001;
constexpr int32_t UID = 10001;
const char *PERMS[] = {
"ohos.permission.DISTRIBUTED_DATASYNC"
};
@ -43,7 +43,7 @@ const char *PERMS[] = {
void DistributedSchedUidTest::SetUpTestCase()
{
DTEST_LOG << "DistributedSchedUidTest::SetUpTestCase" << std::endl;
setuid(CAllING_UID);
setuid(UID);
}
void DistributedSchedUidTest::TearDownTestCase()

View File

@ -1406,8 +1406,7 @@ HWTEST_F(DMSContinueManagerTest, NotifyIconDisappear_001, TestSize.Level1)
int32_t state = 0;
recvMgr->iconInfo_.senderNetworkId = senderNetworkId;
recvMgr->registerOnListener_.clear();
recvMgr->NotifyIconDisappear(bundleNameId,
currentIconInfo(senderNetworkId, bundleName, finalBundleName, continueType), state);
recvMgr->NotifyIconDisappear(bundleNameId, senderNetworkId, state);
EXPECT_EQ(recvMgr->registerOnListener_.empty(), true);
DTEST_LOG << "DMSContinueManagerTest NotifyIconDisappear_001 end" << std::endl;
}

View File

@ -29,7 +29,7 @@ public:
class MockRemoteStub : public IRemoteStub<MockRemoteInterface> {
public:
~MockRemoteStub() = default;
virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
MessageOption& option) override;
};
}

View File

@ -44,9 +44,9 @@ uint32_t GetU32Data(const char* ptr)
return (ptr[POS_0] << OFFSET_24) | (ptr[POS_1] << OFFSET_16) | (ptr[POS_2] << OFFSET_8) | ptr[POS_3];
}
bool DoSomethingInterestingWithMyAPI_DistributedWant_001(const uint8_t* data, size_t size)
bool DoSomethingInterestingWithMyApiDistributedWant001(const uint8_t* data, size_t size)
{
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
if (data == nullptr || size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return false;
}
@ -68,9 +68,9 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_001(const uint8_t* data, si
return true;
}
bool DoSomethingInterestingWithMyAPI_DistributedWant_002(const uint8_t* data, size_t size)
bool DoSomethingInterestingWithMyApiDistributedWant002(const uint8_t* data, size_t size)
{
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
if (data == nullptr || size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return false;
}
@ -86,9 +86,9 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_002(const uint8_t* data, si
return true;
}
bool DoSomethingInterestingWithMyAPI_DistributedWant_003(const uint8_t* data, size_t size)
bool DoSomethingInterestingWithMyApiDistributedWant003(const uint8_t* data, size_t size)
{
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
if (data == nullptr || size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return false;
}
@ -108,9 +108,9 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_003(const uint8_t* data, si
return true;
}
bool DoSomethingInterestingWithMyAPI_DistributedWant_004(const uint8_t* data, size_t size)
bool DoSomethingInterestingWithMyApiDistributedWant004(const uint8_t* data, size_t size)
{
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
if (data == nullptr || size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return false;
}
@ -134,9 +134,9 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_004(const uint8_t* data, si
return true;
}
bool DoSomethingInterestingWithMyAPI_DistributedWant_005(const uint8_t* data, size_t size)
bool DoSomethingInterestingWithMyApiDistributedWant005(const uint8_t* data, size_t size)
{
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
if (data == nullptr || size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return false;
}
@ -163,9 +163,9 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_005(const uint8_t* data, si
return true;
}
bool DoSomethingInterestingWithMyAPI_DistributedWant_006(const uint8_t* data, size_t size)
bool DoSomethingInterestingWithMyApiDistributedWant006(const uint8_t* data, size_t size)
{
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
if (data == nullptr || size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return false;
}
@ -209,11 +209,11 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_006(const uint8_t* data, si
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_001(data, size);
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_002(data, size);
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_003(data, size);
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_004(data, size);
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_005(data, size);
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_006(data, size);
OHOS::DoSomethingInterestingWithMyApiDistributedWant001(data, size);
OHOS::DoSomethingInterestingWithMyApiDistributedWant002(data, size);
OHOS::DoSomethingInterestingWithMyApiDistributedWant003(data, size);
OHOS::DoSomethingInterestingWithMyApiDistributedWant004(data, size);
OHOS::DoSomethingInterestingWithMyApiDistributedWant005(data, size);
OHOS::DoSomethingInterestingWithMyApiDistributedWant006(data, size);
return 0;
}

View File

@ -54,9 +54,9 @@ uint32_t GetU32Data(const char* ptr)
return (ptr[POS_0] << OFFSET_24) | (ptr[POS_1] << OFFSET_16) | (ptr[POS_2] << OFFSET_8) | ptr[POS_3];
}
bool DoSomethingInterestingWithMyAPI_DistributedWantParams_001(const uint8_t* data, size_t size)
bool DoSomethingInterestingWithMyApiDistributedWantParams001(const uint8_t* data, size_t size)
{
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
if (data == nullptr || size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return false;
}
@ -78,9 +78,9 @@ bool DoSomethingInterestingWithMyAPI_DistributedWantParams_001(const uint8_t* da
return true;
}
bool DoSomethingInterestingWithMyAPI_DistributedWantParams_002(const uint8_t* data, size_t size)
bool DoSomethingInterestingWithMyApiDistributedWantParams002(const uint8_t* data, size_t size)
{
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
if (data == nullptr || size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return false;
}
@ -122,9 +122,9 @@ bool DoSomethingInterestingWithMyAPI_DistributedWantParams_002(const uint8_t* da
return true;
}
bool DoSomethingInterestingWithMyAPI_DistributedWantParams_003(const uint8_t* data, size_t size)
bool DoSomethingInterestingWithMyApiDistributedWant003(const uint8_t* data, size_t size)
{
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
if (data == nullptr || size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return false;
}
@ -178,9 +178,9 @@ bool DoSomethingInterestingWithMyAPI_DistributedWantParams_003(const uint8_t* da
return true;
}
bool DoSomethingInterestingWithMyAPI_DistributedWantParams_004(const uint8_t* data, size_t size)
bool DoSomethingInterestingWithMyApiDistributedWantParams004(const uint8_t* data, size_t size)
{
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
if (data == nullptr || size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return false;
}
@ -206,9 +206,9 @@ bool DoSomethingInterestingWithMyAPI_DistributedWantParams_004(const uint8_t* da
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
OHOS::DoSomethingInterestingWithMyAPI_DistributedWantParams_001(data, size);
OHOS::DoSomethingInterestingWithMyAPI_DistributedWantParams_002(data, size);
OHOS::DoSomethingInterestingWithMyAPI_DistributedWantParams_003(data, size);
OHOS::DoSomethingInterestingWithMyAPI_DistributedWantParams_004(data, size);
OHOS::DoSomethingInterestingWithMyApiDistributedWantParams001(data, size);
OHOS::DoSomethingInterestingWithMyApiDistributedWantParams002(data, size);
OHOS::DoSomethingInterestingWithMyApiDistributedWant003(data, size);
OHOS::DoSomethingInterestingWithMyApiDistributedWantParams004(data, size);
return 0;
}