mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-27 00:51:35 +00:00
commit
0eb9e2d629
@ -77,7 +77,7 @@ public:
|
||||
|
||||
void RegisterSwitchingToAnotherUserFunction(std::function<void()> && func);
|
||||
void SwitchingCurrentUser();
|
||||
void SwitchUserCallback() override;
|
||||
void SwitchUserCallback(std::vector<int32_t> oldScbPids, int32_t currentScbPid) override;
|
||||
|
||||
protected:
|
||||
ScreenSessionManagerClient() = default;
|
||||
@ -102,9 +102,6 @@ private:
|
||||
std::map<ScreenId, sptr<ScreenSession>> screenSessionMap_;
|
||||
std::function<void()> switchingToAnotherUserFunc_ = nullptr;
|
||||
|
||||
mutable std::mutex displayNodeChildrenMapMutex_;
|
||||
std::map<ScreenId, std::vector<std::shared_ptr<RSBaseNode>>> displayNodeChildrenMap_;
|
||||
|
||||
sptr<IScreenSessionManager> screenSessionManager_;
|
||||
|
||||
IScreenConnectionListener* screenConnectionListener_;
|
||||
|
@ -40,11 +40,11 @@ public:
|
||||
TRANS_ID_SET_DISPLAY_NODE_SCREEN_ID,
|
||||
TRANS_ID_GET_SURFACENODEID_FROM_MISSIONID,
|
||||
TRANS_ID_SET_FOLD_DISPLAY_MODE,
|
||||
TRANS_ID_ON_REMOVE_ALL_DISPLAY_NODE_CHILDREN,
|
||||
TRANS_ID_ON_SWITCH_USER_CMD,
|
||||
TRANS_ID_SET_VIRTUAL_PIXEL_RATIO_SYSTEM,
|
||||
};
|
||||
|
||||
virtual void SwitchUserCallback() = 0;
|
||||
virtual void SwitchUserCallback(std::vector<int32_t> oldScbPids, int32_t currentScbPid) = 0;
|
||||
virtual void OnScreenConnectionChanged(ScreenId screenId, ScreenEvent screenEvent,
|
||||
ScreenId rsId, const std::string& name) = 0;
|
||||
virtual void OnPropertyChanged(ScreenId screenId,
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
: IRemoteProxy<IScreenSessionManagerClient>(impl) {}
|
||||
virtual ~ScreenSessionManagerClientProxy() = default;
|
||||
|
||||
void SwitchUserCallback() override;
|
||||
void SwitchUserCallback(std::vector<int32_t> oldScbPids, int32_t currentScbPid) override;
|
||||
void OnScreenConnectionChanged(ScreenId screenId, ScreenEvent screenEvent,
|
||||
ScreenId rsId, const std::string& name) override;
|
||||
void OnPropertyChanged(ScreenId screenId,
|
||||
|
@ -379,43 +379,25 @@ void ScreenSessionManagerClient::NotifyFoldToExpandCompletion(bool foldToExpand)
|
||||
screenSessionManager_->NotifyFoldToExpandCompletion(foldToExpand);
|
||||
}
|
||||
|
||||
void ScreenSessionManagerClient::SwitchUserCallback()
|
||||
void ScreenSessionManagerClient::SwitchUserCallback(std::vector<int32_t> oldScbPids, int32_t currentScbPid)
|
||||
{
|
||||
if (screenSessionManager_ == nullptr) {
|
||||
WLOGFE("screenSessionManager_ is null");
|
||||
return;
|
||||
}
|
||||
if (switchingToAnotherUserFunc_ != nullptr) {
|
||||
WLOGFE("switch to another user");
|
||||
switchingToAnotherUserFunc_();
|
||||
if (oldScbPids.size() == 0) {
|
||||
WLOGFI("oldScbPids size 0");
|
||||
return;
|
||||
}
|
||||
WLOGFI("remove display node start");
|
||||
std::lock_guard<std::mutex> lock(displayNodeChildrenMapMutex_);
|
||||
displayNodeChildrenMap_.clear();
|
||||
for (const auto& iter : screenSessionMap_) {
|
||||
auto screenSession = GetScreenSession(iter.first);
|
||||
if (screenSession == nullptr) {
|
||||
WLOGFI("screenSession is null");
|
||||
continue;
|
||||
}
|
||||
auto displayNode = screenSessionManager_->GetDisplayNode(iter.first);
|
||||
if (displayNode == nullptr) {
|
||||
WLOGFI("display node is null");
|
||||
continue;
|
||||
}
|
||||
auto nodeChildren = displayNode->GetChildren();
|
||||
std::vector<std::shared_ptr<RSBaseNode>> childrenList;
|
||||
for (auto child : nodeChildren) {
|
||||
auto childNode = RSNodeMap::Instance().GetNode(child);
|
||||
if (childNode != nullptr) {
|
||||
childrenList.push_back(childNode);
|
||||
displayNode->RemoveChild(childNode);
|
||||
}
|
||||
}
|
||||
RSTransaction::FlushImplicitTransaction();
|
||||
displayNodeChildrenMap_.emplace(iter.first, childrenList);
|
||||
displayNode->SetScbNodePid(oldScbPids, currentScbPid);
|
||||
}
|
||||
WLOGFI("remove display node finish");
|
||||
WLOGFI("switch user callback end");
|
||||
}
|
||||
|
||||
void ScreenSessionManagerClient::SwitchingCurrentUser()
|
||||
@ -425,24 +407,7 @@ void ScreenSessionManagerClient::SwitchingCurrentUser()
|
||||
return;
|
||||
}
|
||||
screenSessionManager_->SwitchUser();
|
||||
std::lock_guard<std::mutex> lock(displayNodeChildrenMapMutex_);
|
||||
for (const auto& iter : displayNodeChildrenMap_) {
|
||||
auto screenSession = GetScreenSession(iter.first);
|
||||
if (screenSession == nullptr) {
|
||||
WLOGFI("screenSession is null");
|
||||
continue;
|
||||
}
|
||||
auto displayNode = screenSessionManager_->GetDisplayNode(iter.first);
|
||||
if (displayNode == nullptr) {
|
||||
WLOGFI("display node is null");
|
||||
continue;
|
||||
}
|
||||
for (auto child : iter.second) {
|
||||
displayNode->AddChild(child);
|
||||
}
|
||||
RSTransaction::FlushImplicitTransaction();
|
||||
}
|
||||
WLOGFI("recover display node finish");
|
||||
WLOGFI("switch to current user end");
|
||||
}
|
||||
|
||||
FoldStatus ScreenSessionManagerClient::GetFoldStatus()
|
||||
|
@ -57,7 +57,7 @@ void ScreenSessionManagerClientProxy::OnScreenConnectionChanged(ScreenId screenI
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSessionManagerClientProxy::SwitchUserCallback()
|
||||
void ScreenSessionManagerClientProxy::SwitchUserCallback(std::vector<int32_t> oldScbPids, int32_t currentScbPid)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -66,8 +66,16 @@ void ScreenSessionManagerClientProxy::SwitchUserCallback()
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32Vector(oldScbPids)) {
|
||||
WLOGFE("Write oldScbPids failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(currentScbPid)) {
|
||||
WLOGFE("Write currentScbPid failed");
|
||||
return;
|
||||
}
|
||||
if (Remote()->SendRequest(
|
||||
static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_REMOVE_ALL_DISPLAY_NODE_CHILDREN),
|
||||
static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SWITCH_USER_CMD),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
return;
|
||||
|
@ -48,7 +48,7 @@ const std::map<uint32_t, ScreenSessionManagerClientStub::StubFunc> ScreenSession
|
||||
&ScreenSessionManagerClientStub::HandleOnGetSurfaceNodeIdsFromMissionIdsChanged },
|
||||
{ static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_SET_FOLD_DISPLAY_MODE),
|
||||
&ScreenSessionManagerClientStub::HandleOnUpdateFoldDisplayMode },
|
||||
{ static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_REMOVE_ALL_DISPLAY_NODE_CHILDREN),
|
||||
{ static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SWITCH_USER_CMD),
|
||||
&ScreenSessionManagerClientStub::HandleSwitchUserCallback },
|
||||
{ static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO_SYSTEM),
|
||||
&ScreenSessionManagerClientStub::HandleSetVirtualPixelRatioSystem },
|
||||
@ -74,7 +74,10 @@ int ScreenSessionManagerClientStub::OnRemoteRequest(uint32_t code, MessageParcel
|
||||
int ScreenSessionManagerClientStub::HandleSwitchUserCallback(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
WLOGD("HandleSwitchUserCallback");
|
||||
SwitchUserCallback();
|
||||
std::vector<int32_t> oldScbPids;
|
||||
data.ReadInt32Vector(&oldScbPids);
|
||||
int32_t currentScbPid = data.ReadInt32();
|
||||
SwitchUserCallback(oldScbPids, currentScbPid);
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
|
@ -330,6 +330,8 @@ private:
|
||||
std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_;
|
||||
|
||||
int32_t currentUserId_ { 0 };
|
||||
int32_t currentScbPId_ { -1 };
|
||||
std::vector<int32_t> oldScbPids_ {};
|
||||
mutable std::mutex currentUserIdMutex_;
|
||||
mutable std::mutex displayNodeChildrenMapMutex_;
|
||||
std::map<int32_t, sptr<IScreenSessionManagerClient>> clientProxyMap_;
|
||||
|
@ -72,7 +72,6 @@ const std::string ARG_LOCK_FOLD_DISPLAY_STATUS = "-l";
|
||||
const std::string ARG_UNLOCK_FOLD_DISPLAY_STATUS = "-u";
|
||||
const ScreenId SCREEN_ID_FULL = 0;
|
||||
const ScreenId SCREEN_ID_MAIN = 5;
|
||||
const ScreenId DEFAULT_SCREEN_ID = 0;
|
||||
constexpr int32_t INVALID_UID = -1;
|
||||
constexpr int32_t INVALID_USER_ID = -1;
|
||||
constexpr int32_t BASE_USER_RANGE = 200000;
|
||||
@ -3820,6 +3819,7 @@ void ScreenSessionManager::SwitchUser()
|
||||
return;
|
||||
}
|
||||
auto userId = GetUserIdByCallingUid();
|
||||
auto newScbPid = IPCSkeleton::GetCallingPid();
|
||||
TLOGI(WmsLogTag::DMS, "switch userId:%{public}d, currentId:%{public}d", userId, currentUserId_);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(currentUserIdMutex_);
|
||||
@ -3827,17 +3827,22 @@ void ScreenSessionManager::SwitchUser()
|
||||
TLOGI(WmsLogTag::DMS, "switch user not change");
|
||||
return;
|
||||
}
|
||||
if (clientProxy_ != nullptr) {
|
||||
clientProxy_->SwitchUserCallback();
|
||||
if (clientProxy_) {
|
||||
auto pidIter = std::find(oldScbPids_.begin(), oldScbPids_.end(), currentScbPId_);
|
||||
if (pidIter == oldScbPids_.end() && currentScbPId_ > 0) {
|
||||
oldScbPids_.emplace_back(currentScbPId_);
|
||||
}
|
||||
oldScbPids_.erase(std::remove(oldScbPids_.begin(), oldScbPids_.end(), newScbPid), oldScbPids_.end());
|
||||
clientProxy_->SwitchUserCallback(oldScbPids_, newScbPid);
|
||||
}
|
||||
currentUserId_ = userId;
|
||||
currentScbPId_ = newScbPid;
|
||||
auto it = clientProxyMap_.find(currentUserId_);
|
||||
if (it != clientProxyMap_.end()) {
|
||||
clientProxy_ = it->second;
|
||||
}
|
||||
}
|
||||
MockSessionManagerService::GetInstance().NotifyWMSConnected(currentUserId_,
|
||||
static_cast<int32_t>(defaultScreenId_), false);
|
||||
MockSessionManagerService::GetInstance().NotifyWMSConnected(currentUserId_, GetDefaultScreenId(), false);
|
||||
}
|
||||
|
||||
void ScreenSessionManager::SetClient(const sptr<IScreenSessionManagerClient>& client)
|
||||
@ -3851,17 +3856,24 @@ void ScreenSessionManager::SetClient(const sptr<IScreenSessionManagerClient>& cl
|
||||
return;
|
||||
}
|
||||
auto userId = GetUserIdByCallingUid();
|
||||
auto newScbPid = IPCSkeleton::GetCallingPid();
|
||||
TLOGI(WmsLogTag::DMS, "set client userId:%{public}d", userId);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(currentUserIdMutex_);
|
||||
if (clientProxy_ != nullptr && userId != currentUserId_) {
|
||||
clientProxy_->SwitchUserCallback();
|
||||
auto pidIter = std::find(oldScbPids_.begin(), oldScbPids_.end(), currentScbPId_);
|
||||
if (pidIter == oldScbPids_.end() && currentScbPId_ > 0) {
|
||||
oldScbPids_.emplace_back(currentScbPId_);
|
||||
}
|
||||
oldScbPids_.erase(std::remove(oldScbPids_.begin(), oldScbPids_.end(), newScbPid), oldScbPids_.end());
|
||||
clientProxy_->SwitchUserCallback(oldScbPids_, newScbPid);
|
||||
}
|
||||
currentUserId_ = userId;
|
||||
currentScbPId_ = newScbPid;
|
||||
clientProxy_ = client;
|
||||
clientProxyMap_[currentUserId_] = client;
|
||||
}
|
||||
MockSessionManagerService::GetInstance().NotifyWMSConnected(userId, DEFAULT_SCREEN_ID, true);
|
||||
MockSessionManagerService::GetInstance().NotifyWMSConnected(userId, GetDefaultScreenId(), true);
|
||||
NotifyClientProxyUpdateFoldDisplayMode(GetFoldDisplayMode());
|
||||
SetClientInner();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user