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

Signed-off-by: cq_0418 <chenqian73@huawei.com>
This commit is contained in:
cq_0418 2024-07-26 01:24:58 +00:00 committed by Gitee
commit 58366be2d5
42 changed files with 494 additions and 67 deletions

View File

@ -198,6 +198,14 @@ public:
*/
WMError UnregisterWMSConnectionChangedListener();
/**
* @brief Terminate session by persistentId and start caller.
* @persistentId persistentId to be terminated.
*
* @return WM_OK means Terminate success, others means Terminate failed.
*/
WMError TerminateSessionByPersistentId(int32_t persistentId);
private:
WindowManagerLite();
~WindowManagerLite();

View File

@ -36,6 +36,7 @@ public:
MOCK_METHOD1(ClearMainSessions, WMError(const std::vector<int32_t>& persistentIds));
MOCK_METHOD2(ClearMainSessions, WMError(const std::vector<int32_t>& persistentIds,
std::vector<int32_t>& clearFailedIds));
MOCK_METHOD1(TerminateSessionByPersistentId, WMError(int32_t persistentId));
};
}
} // namespace OHOS

View File

@ -22,6 +22,7 @@ namespace OHOS {
namespace Rosen {
namespace PermissionConstants {
constexpr const char* PERMISSION_MANAGE_MISSION = "ohos.permission.MANAGE_MISSIONS";
constexpr const char* PERMISSION_KILL_APP_PROCESS = "ohos.permission.KILL_APP_PROCESSES";
}
class SessionPermission {
public:
@ -39,6 +40,7 @@ public:
static bool IsStartedByUIExtension();
static bool CheckCallingIsUserTestMode(pid_t pid);
static bool IsBetaVersion();
static bool IsSystemAppCall();
};
} // Rosen
} // OHOS

View File

@ -103,6 +103,12 @@ bool SessionPermission::IsSystemCalling()
return isSystemApp;
}
bool SessionPermission::IsSystemAppCall()
{
uint64_t callingTokenId = IPCSkeleton::GetCallingFullTokenID();
return Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(callingTokenId);
}
bool SessionPermission::IsSACalling()
{
const auto tokenId = IPCSkeleton::GetCallingTokenID();

View File

@ -344,6 +344,31 @@ struct SessionInfo {
bool isAtomicService_ = false;
};
struct SessionDisplayInfo : public Parcelable {
int32_t pid = -1;
uint64_t displayId = 0;
float density = 0.0f;
int32_t orientation = 0;
bool Marshalling(Parcel& parcel) const
{
return parcel.WriteInt32(pid) && parcel.WriteUint64(displayId) && parcel.WriteFloat(density) &&
parcel.WriteInt32(orientation);
}
static SessionDisplayInfo* Unmarshalling(Parcel& parcel)
{
SessionDisplayInfo* info = new SessionDisplayInfo;
bool res = parcel.ReadInt32(info->pid) && parcel.ReadUint64(info->displayId) &&
parcel.ReadFloat(info->density) && parcel.ReadInt32(info->orientation);
if (res) {
return info;
}
delete info;
return nullptr;
}
};
enum class SessionFlag : uint32_t {
SESSION_FLAG_NEED_AVOID = 1,
SESSION_FLAG_PARENT_LIMIT = 1 << 1,

View File

@ -45,8 +45,6 @@ class WindowEventChannel : public WindowEventChannelStub {
public:
explicit WindowEventChannel(sptr<ISessionStage> iSessionStage) : sessionStage_(iSessionStage)
{
dispatchCallback_ =
[this](int32_t eventId, int64_t actionTime) { this->OnDispatchEventProcessed(eventId, actionTime); };
}
~WindowEventChannel() = default;
@ -80,7 +78,6 @@ private:
sptr<ISessionStage> sessionStage_ = nullptr;
bool isUIExtension_ { false };
UIExtensionUsage uiExtensionUsage_ { UIExtensionUsage::EMBEDDED };
std::function<void(int32_t, int64_t)> dispatchCallback_ { nullptr };
};
} // namespace OHOS::Rosen
#endif // OHOS_ROSEN_WINDOW_SCENE_WINDOW_EVENT_CHANNEL_H

View File

@ -120,10 +120,6 @@ WSError WindowEventChannel::TransferPointerEvent(const std::shared_ptr<MMI::Poin
WLOGFI("InputTracking id:%{public}d, Dispatch by skipping receipt, action:%{public}s,"
" persistentId:%{public}d", pointerEvent->GetId(),
pointerEvent->DumpPointerAction(), sessionStage_->GetPersistentId());
} else {
DelayedSingleton<ANRHandler>::GetInstance()->SetSessionStage(pointerEvent->GetId(), sessionStage_);
WLOGFD("Dispatch normally, action:%{public}s, eventId:%{public}d, persistentId:%{public}d",
pointerEvent->DumpPointerAction(), pointerEvent->GetId(), sessionStage_->GetPersistentId());
}
sessionStage_->NotifyPointerEvent(pointerEvent);
return WSError::WS_OK;
@ -161,7 +157,6 @@ WSError WindowEventChannel::TransferKeyEventForConsumed(
keyEvent->GetId(), static_cast<int>(isConsumed));
return WSError::WS_OK;
}
DelayedSingleton<ANRHandler>::GetInstance()->SetSessionStage(keyEvent->GetId(), sessionStage_);
sessionStage_->NotifyKeyEvent(keyEvent, isConsumed);
keyEvent->MarkProcessed();
return WSError::WS_OK;
@ -228,11 +223,6 @@ WSError WindowEventChannel::TransferFocusActiveEvent(bool isFocusActive)
return WSError::WS_OK;
}
void WindowEventChannel::OnDispatchEventProcessed(int32_t eventId, int64_t actionTime)
{
DelayedSingleton<ANRHandler>::GetInstance()->HandleEventConsumed(eventId, actionTime);
}
void WindowEventChannel::PrintKeyEvent(const std::shared_ptr<MMI::KeyEvent>& event)
{
if (event == nullptr) {

View File

@ -232,7 +232,7 @@ public:
void SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func);
WSError TerminateSessionTotal(const sptr<AAFwk::SessionInfo> info, TerminateType terminateType);
void SetTerminateSessionListenerTotal(const NotifyTerminateSessionFuncTotal& func);
WSError Clear();
WSError Clear(bool needStartCaller = false);
WSError SetSessionLabel(const std::string &label);
void SetUpdateSessionLabelListener(const NofitySessionLabelUpdatedFunc& func);
WSError SetSessionIcon(const std::shared_ptr<Media::PixelMap> &icon);

View File

@ -1394,14 +1394,14 @@ void Session::SetUpdateSessionIconListener(const NofitySessionIconUpdatedFunc &f
updateSessionIconFunc_ = func;
}
WSError Session::Clear()
WSError Session::Clear(bool needStartCaller)
{
TLOGI(WmsLogTag::WMS_LIFE, "id: %{public}d", GetPersistentId());
auto task = [this]() {
TLOGI(WmsLogTag::WMS_LIFE, "id:%{public}d, needStartCaller:%{public}u", GetPersistentId(), needStartCaller);
auto task = [this, needStartCaller]() {
isTerminating = true;
SessionInfo info = GetSessionInfo();
if (terminateSessionFuncNew_) {
terminateSessionFuncNew_(info, false, false);
terminateSessionFuncNew_(info, needStartCaller, false);
}
};
PostLifeCycleTask(task, "Clear", LifeCycleTaskType::STOP);

View File

@ -237,6 +237,7 @@ public:
WSError GetSessionSnapshot(const std::string& deviceId, int32_t persistentId,
SessionSnapshot& snapshot, bool isLowResolution) override;
WMError GetSessionSnapshotById(int32_t persistentId, SessionSnapshot& snapshot) override;
WSError GetSessionDisplayInfo(int32_t persistentId, SessionDisplayInfo& sessionDisplayInfo);
WSError GetUIContentRemoteObj(int32_t persistentId, sptr<IRemoteObject>& uiContentRemoteObj) override;
WSError SetSessionContinueState(const sptr<IRemoteObject> &token, const ContinueState& continueState) override;
WSError ClearSession(int32_t persistentId) override;
@ -353,6 +354,7 @@ public:
void UpdateSecSurfaceInfo(std::shared_ptr<RSUIExtensionData> secExtensionData, uint64_t userid);
WSError SetAppForceLandscapeConfig(const std::string& bundleName, const AppForceLandscapeConfig& config);
AppForceLandscapeConfig GetAppForceLandscapeConfig(const std::string& bundleName);
WMError TerminateSessionByPersistentId(int32_t persistentId);
protected:
SceneSessionManager();

View File

@ -45,6 +45,7 @@ public:
const sptr<AAFwk::SessionInfo> info, bool needStartCaller, bool isFromBroker = false) override;
WSError GetSessionSnapshot(const std::string& deviceId, int32_t persistentId,
SessionSnapshot& snapshot, bool isLowResolution) override;
WSError GetSessionDisplayInfo(int32_t persistentId, SessionDisplayInfo& sessionDisplayInfo) override;
WSError SetSessionContinueState(const sptr<IRemoteObject>& token, const ContinueState& continueState) override;
WSError ClearSession(int32_t persistentId) override;
WSError ClearAllSessions() override;
@ -69,6 +70,7 @@ public:
WSError RegisterIAbilityManagerCollaborator(int32_t type,
const sptr<AAFwk::IAbilityManagerCollaborator>& impl) override;
WSError UnregisterIAbilityManagerCollaborator(int32_t type) override;
WMError TerminateSessionByPersistentId(int32_t persistentId) override;
protected:
SceneSessionManagerLite() = default;

View File

@ -53,6 +53,7 @@ public:
void SaveSessionListener(const sptr<ISessionListener>& listener);
void DeleteSessionListener(const sptr<ISessionListener>& listener);
void RecoverSessionManagerService(const sptr<ISessionManagerService>& sessionManagerService);
WMError GetSessionDisplayInfo(int32_t persistentId, SessionDisplayInfo& sessionDisplayInfo);
void RegisterUserSwitchListener(const UserSwitchCallbackFunc& callbackFunc);
void OnWMSConnectionChanged(
int32_t userId, int32_t screenId, bool isConnected, const sptr<ISessionManagerService>& sessionManagerService);

View File

@ -74,6 +74,8 @@ public:
TRANS_ID_RAISE_WINDOW_TO_TOP,
TRANS_ID_REGISTER_COLLABORATOR,
TRANS_ID_UNREGISTER_COLLABORATOR,
TRANS_ID_GET_SESSION_DISPLAY_INFO,
TRANS_ID_TERMINATE_SESSION_BY_PERSISTENT_ID,
};
virtual WSError SetSessionLabel(const sptr<IRemoteObject>& token, const std::string& label) = 0;
@ -106,6 +108,19 @@ public:
virtual WSError RegisterIAbilityManagerCollaborator(int32_t type,
const sptr<AAFwk::IAbilityManagerCollaborator>& impl) = 0;
virtual WSError UnregisterIAbilityManagerCollaborator(int32_t type) = 0;
/**
* @brief Get SessionDisplayInfo by session's persistentId
*
* The data returned includes session's pid, along with some related elements of its screen displayInfo.\n
* It is mainly used for the host security check and info transmission when creating UIExtension.\n
* The caller requires SA permission.\n
*
* @param persistentId session's persistentId
* @param sessionDisplayInfo result data
* @return WSError
* @permission SA permission required
*/
virtual WSError GetSessionDisplayInfo(int32_t persistentId, SessionDisplayInfo& sessionDisplayInfo) = 0;
};
} // namespace OHOS::Rosen
#endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_LITE_INTERFACE_H

View File

@ -54,6 +54,7 @@ public:
WSError ClearAllSessions() override;
void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override;
WSError GetSessionDisplayInfo(int32_t persistentId, SessionDisplayInfo& sessionDisplayInfo) override;
WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
const sptr<IWindowManagerAgent>& windowManagerAgent) override;
WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
@ -68,6 +69,7 @@ public:
WSError RegisterIAbilityManagerCollaborator(int32_t type,
const sptr<AAFwk::IAbilityManagerCollaborator>& impl) override;
WSError UnregisterIAbilityManagerCollaborator(int32_t type) override;
WMError TerminateSessionByPersistentId(int32_t persistentId) override;
private:
template<typename T>

View File

@ -47,6 +47,7 @@ private:
int HandleSetSessionContinueState(MessageParcel& data, MessageParcel& reply);
int HandleTerminateSessionNew(MessageParcel& data, MessageParcel& reply);
int HandleGetSessionSnapshot(MessageParcel& data, MessageParcel& reply);
int HandleGetSessionDisplayInfo(MessageParcel& data, MessageParcel& reply);
int HandleClearSession(MessageParcel& data, MessageParcel& reply);
int HandleClearAllSessions(MessageParcel& data, MessageParcel& reply);
int HandleLockSession(MessageParcel& data, MessageParcel& reply);
@ -66,6 +67,7 @@ private:
int HandleRaiseWindowToTop(MessageParcel& data, MessageParcel& reply);
int HandleRegisterCollaborator(MessageParcel& data, MessageParcel& reply);
int HandleUnregisterCollaborator(MessageParcel& data, MessageParcel& reply);
int HandleTerminateSessionByPersistentId(MessageParcel& data, MessageParcel& reply);
int ProcessRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option);
};

View File

@ -6167,6 +6167,41 @@ WSError SceneSessionManager::GetSessionSnapshot(const std::string& deviceId, int
return taskScheduler_->PostSyncTask(task, "GetSessionSnapshot");
}
WSError SceneSessionManager::GetSessionDisplayInfo(int32_t persistentId,
SessionDisplayInfo& sessionDisplayInfo)
{
TLOGI(WmsLogTag::DEFAULT, "persistentId: %{public}d", persistentId);
if (!SessionPermission::IsSACalling()) {
TLOGE(WmsLogTag::DEFAULT, "Permission denied!");
return WSError::WS_ERROR_INVALID_PERMISSION;
}
auto session = GetSceneSession(persistentId);
if (session == nullptr) {
TLOGE(WmsLogTag::DEFAULT, "Failed to find session with persistentId=%{public}d", persistentId);
return WSError::WS_ERROR_INVALID_SESSION;
}
uint64_t displayId = session->GetSessionInfo().screenId_;
if (displayId == SCREEN_ID_INVALID) {
TLOGE(WmsLogTag::DEFAULT, "Invalid displayId.");
return WSError::WS_ERROR_INVALID_DISPLAY;
}
auto display = SingletonContainer::Get<DisplayManager>().GetDisplayById(displayId);
if (display == nullptr) {
TLOGE(WmsLogTag::DEFAULT, "Failed to get display object with id=%{public}" PRIu64, displayId);
return WSError::WS_ERROR_INVALID_DISPLAY;
}
auto displayInfo = display->GetDisplayInfo();
if (displayInfo == nullptr) {
TLOGE(WmsLogTag::DEFAULT, "Failed to get displayInfo with id=%{public}" PRIu64, displayId);
return WSError::WS_ERROR_INVALID_DISPLAY;
}
sessionDisplayInfo.pid = session->GetCallingPid();
sessionDisplayInfo.displayId = displayId;
sessionDisplayInfo.density = displayInfo->GetVirtualPixelRatio();
sessionDisplayInfo.orientation = static_cast<int32_t>(displayInfo->GetDisplayOrientation());
return WSError::WS_OK;
}
WMError SceneSessionManager::GetSessionSnapshotById(int32_t persistentId, SessionSnapshot& snapshot)
{
if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI() && !SessionPermission::IsShellCall()) {
@ -9815,4 +9850,25 @@ AppForceLandscapeConfig SceneSessionManager::GetAppForceLandscapeConfig(const st
}
return appForceLandscapeMap_[bundleName];
}
WMError SceneSessionManager::TerminateSessionByPersistentId(int32_t persistentId)
{
if (!SessionPermission::VerifyCallingPermission(PermissionConstants::PERMISSION_KILL_APP_PROCESS) ||
!SessionPermission::IsSystemAppCall()) {
TLOGE(WmsLogTag::WMS_LIFE, "The caller has no permission granted.");
return WMError::WM_ERROR_INVALID_PERMISSION;
}
auto sceneSession = GetSceneSession(persistentId);
if (sceneSession == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "Session id:%{public}d is not found.", persistentId);
return WMError::WM_ERROR_INVALID_PARAM;
}
if (!WindowHelper::IsMainWindow(sceneSession->GetWindowType())) {
TLOGE(WmsLogTag::WMS_MAIN, "Session id:%{public}d is not mainWindow.", persistentId);
return WMError::WM_ERROR_INVALID_PERMISSION;
}
sceneSession->Clear(true);
TLOGI(WmsLogTag::WMS_LIFE, "Terminate success, id:%{public}d.", persistentId);
return WMError::WM_OK;
}
} // namespace OHOS::Rosen

View File

@ -107,6 +107,13 @@ WSError SceneSessionManagerLite::GetSessionSnapshot(const std::string& deviceId,
return SceneSessionManager::GetInstance().GetSessionSnapshot(deviceId, persistentId, snapshot, isLowResolution);
}
WSError SceneSessionManagerLite::GetSessionDisplayInfo(int32_t persistentId,
SessionDisplayInfo& sessionDisplayInfo)
{
TLOGD(WmsLogTag::DEFAULT, "run");
return SceneSessionManager::GetInstance().GetSessionDisplayInfo(persistentId, sessionDisplayInfo);
}
WSError SceneSessionManagerLite::PendingSessionToForeground(const sptr<IRemoteObject>& token)
{
WLOGFD("run PendingSessionToForeground");
@ -236,4 +243,9 @@ WSError SceneSessionManagerLite::UnregisterIAbilityManagerCollaborator(int32_t t
{
return SceneSessionManager::GetInstance().UnregisterIAbilityManagerCollaborator(type);
}
WMError SceneSessionManagerLite::TerminateSessionByPersistentId(int32_t persistentId)
{
return SceneSessionManager::GetInstance().TerminateSessionByPersistentId(persistentId);
}
} // namespace OHOS::Rosen

View File

@ -1853,8 +1853,14 @@ void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const
NotifyDisplayStateChange(GetDefaultScreenId(), screenSession->ConvertToDisplayInfo(),
emptyMap, DisplayStateChangeType::UPDATE_ROTATION);
// screenId要在rotation前进行设置
ScreenSettingHelper::SetSettingRotationScreenId(static_cast<int32_t>(displayInfo->GetScreenId()));
ScreenSettingHelper::SetSettingRotation(static_cast<int32_t>(displayInfo->GetRotation()));
int32_t settingScreenId = static_cast<int32_t>(displayInfo->GetScreenId());
int32_t settingRotation = static_cast<int32_t>(displayInfo->GetRotation());
auto task = [settingScreenId, settingRotation]() {
TLOGI(WmsLogTag::DMS, "update screen rotation property in datebase");
ScreenSettingHelper::SetSettingRotationScreenId(settingScreenId);
ScreenSettingHelper::SetSettingRotation(settingRotation);
};
taskScheduler_->PostAsyncTask(task, "UpdateScreenRotationProperty");
}
void ScreenSessionManager::NotifyDisplayChanged(sptr<DisplayInfo> displayInfo, DisplayChangeEvent event)

View File

@ -189,6 +189,18 @@ void SessionManagerLite::DeleteAllSessionListeners()
sessionListeners_.clear();
}
WMError SessionManagerLite::GetSessionDisplayInfo(int32_t persistentId,
SessionDisplayInfo& sessionDisplayInfo)
{
auto sceneSessionManagerLiteProxy = GetSceneSessionManagerLiteProxy();
if (sceneSessionManagerLiteProxy == nullptr) {
TLOGE(WmsLogTag::DEFAULT, "sceneSessionManagerLiteProxy is null");
return WMError::WM_ERROR_SAMGR;
}
return static_cast<WMError>(
sceneSessionManagerLiteProxy->GetSessionDisplayInfo(persistentId, sessionDisplayInfo));
}
void SessionManagerLite::RecoverSessionManagerService(const sptr<ISessionManagerService>& sessionManagerService)
{
{

View File

@ -646,6 +646,35 @@ void SceneSessionManagerLiteProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo
}
}
WSError SceneSessionManagerLiteProxy::GetSessionDisplayInfo(int32_t persistentId,
SessionDisplayInfo& sessionDisplayInfo)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
TLOGE(WmsLogTag::DEFAULT, "WriteInterfaceToken failed");
return WSError::WS_ERROR_INVALID_PARAM;
}
if (!data.WriteInt32(persistentId)) {
TLOGE(WmsLogTag::DEFAULT, "Write persistentId failed");
return WSError::WS_ERROR_INVALID_PARAM;
}
if (Remote()->SendRequest(static_cast<uint32_t>(
SceneSessionManagerLiteMessage::TRANS_ID_GET_SESSION_DISPLAY_INFO),
data, reply, option) != ERR_NONE) {
TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
return WSError::WS_ERROR_IPC_FAILED;
}
sptr<SessionDisplayInfo> info(reply.ReadParcelable<SessionDisplayInfo>());
if (info == nullptr) {
TLOGE(WmsLogTag::DEFAULT, "Failed to read sessionDisplayInfo");
return WSError::WS_ERROR_IPC_FAILED;
}
sessionDisplayInfo = *info;
return static_cast<WSError>(reply.ReadUint32());
}
WMError SceneSessionManagerLiteProxy::RegisterWindowManagerAgent(WindowManagerAgentType type,
const sptr<IWindowManagerAgent>& windowManagerAgent)
{
@ -958,4 +987,26 @@ WSError SceneSessionManagerLiteProxy::UnregisterIAbilityManagerCollaborator(int3
}
return static_cast<WSError>(reply.ReadInt32());
}
WMError SceneSessionManagerLiteProxy::TerminateSessionByPersistentId(int32_t persistentId)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
TLOGE(WmsLogTag::WMS_MAIN, "WriteInterfaceToken failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (!data.WriteInt32(persistentId)) {
TLOGE(WmsLogTag::WMS_MAIN, "Write persistentId failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (Remote()->SendRequest(static_cast<int32_t>(
SceneSessionManagerLiteMessage::TRANS_ID_TERMINATE_SESSION_BY_PERSISTENT_ID),
data, reply, option) != ERR_NONE) {
TLOGE(WmsLogTag::WMS_MAIN, "send request fail");
return WMError::WM_ERROR_IPC_FAILED;
}
return static_cast<WMError>(reply.ReadInt32());
}
} // namespace OHOS::Rosen

View File

@ -71,6 +71,8 @@ int SceneSessionManagerLiteStub::ProcessRemoteRequest(uint32_t code, MessageParc
return HandleTerminateSessionNew(data, reply);
case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_SESSION_SNAPSHOT):
return HandleGetSessionSnapshot(data, reply);
case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_SESSION_DISPLAY_INFO):
return HandleGetSessionDisplayInfo(data, reply);
case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_CONTINUE_STATE):
return HandleSetSessionContinueState(data, reply);
case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_SESSION):
@ -303,6 +305,20 @@ int SceneSessionManagerLiteStub::HandleGetSessionSnapshot(MessageParcel &data, M
return ERR_NONE;
}
int SceneSessionManagerLiteStub::HandleGetSessionDisplayInfo(MessageParcel& data, MessageParcel& reply)
{
TLOGD(WmsLogTag::DEFAULT, "run");
int32_t persistentId = data.ReadInt32();
SessionDisplayInfo sessionDisplayInfo;
WSError ret = GetSessionDisplayInfo(persistentId, sessionDisplayInfo);
if (!reply.WriteParcelable(&sessionDisplayInfo)) {
TLOGE(WmsLogTag::DEFAULT, "Failed to get sessionDisplayInfo");
return ERR_INVALID_DATA;
}
reply.WriteUint32(static_cast<uint32_t>(ret));
return ERR_NONE;
}
int SceneSessionManagerLiteStub::HandleClearSession(MessageParcel &data, MessageParcel &reply)
{
WLOGFD("run HandleClearSession!");
@ -542,4 +558,14 @@ int SceneSessionManagerLiteStub::HandleUnregisterCollaborator(MessageParcel& dat
reply.WriteInt32(static_cast<int32_t>(ret));
return ERR_NONE;
}
int SceneSessionManagerLiteStub::HandleTerminateSessionByPersistentId(MessageParcel& data, MessageParcel& reply)
{
int32_t persistentId = data.ReadInt32();
WMError errCode = TerminateSessionByPersistentId(persistentId);
if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
return ERR_INVALID_DATA;
}
return ERR_NONE;
}
} // namespace OHOS::Rosen

View File

@ -88,6 +88,10 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub {
{
return WSError::WS_OK;
}
WSError GetSessionDisplayInfo(int32_t persistentId, SessionDisplayInfo& sessionDisplayInfo) override
{
return WSError::WS_OK;
}
WSError ClearSession(int32_t persistentId) override
{
return WSError::WS_OK;
@ -161,6 +165,10 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub {
{
return WSError::WS_OK;
}
WMError TerminateSessionByPersistentId(int32_t persistentId) override
{
return WMError::WM_OK;
}
sptr<IRemoteObject> AsObject() override
{
return nullptr;
@ -418,6 +426,20 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetSessionSnapshot, Function | S
EXPECT_EQ(ERR_NONE, res);
}
/**
* @tc.name: HandleGetSessionDisplayInfo
* @tc.desc: test function : HandleGetSessionDisplayInfo
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetSessionDisplayInfo, Function | SmallTest | Level1)
{
MessageParcel data;
MessageParcel reply;
auto res = sceneSessionManagerLiteStub_->
SceneSessionManagerLiteStub::HandleGetSessionDisplayInfo(data, reply);
EXPECT_EQ(ERR_NONE, res);
}
/**
* @tc.name: HandleClearSession
* @tc.desc: test function : HandleClearSession
@ -636,6 +658,22 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleRaiseWindowToTop, Function | Sma
EXPECT_EQ(ERR_NONE, res);
}
/**
* @tc.name: HandleTerminateSessionByPersistentId
* @tc.desc: test function : HandleTerminateSessionByPersistentId
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionManagerLiteStubTest, HandleTerminateSessionByPersistentId, Function | SmallTest | Level1)
{
MessageParcel data;
MessageParcel reply;
int32_t persistentId = 1;
data.WriteInt32(persistentId);
auto res = sceneSessionManagerLiteStub_->
SceneSessionManagerLiteStub::HandleTerminateSessionByPersistentId(data, reply);
EXPECT_EQ(ERR_NONE, res);
}
}
}
}

View File

@ -60,6 +60,19 @@ HWTEST_F(SceneSessionManagerLiteTest, GetInstance, Function | SmallTest | Level1
SceneSessionManagerLite& instance2 = SceneSessionManagerLite::GetInstance();
EXPECT_EQ(&instance1, &instance2);
}
/**
* @tc.name: GetSessionDisplayInfo
* @tc.desc: GetSessionDisplayInfo
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionManagerLiteTest, GetSessionDisplayInfo, Function | SmallTest | Level1)
{
SceneSessionManagerLite& sceneSessionManagerLite = SceneSessionManagerLite::GetInstance();
SessionDisplayInfo sessionDisplayInfo;
auto ret = sceneSessionManagerLite.GetSessionDisplayInfo(0, sessionDisplayInfo);
ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
}
}
}
}

View File

@ -380,6 +380,18 @@ HWTEST_F(SceneSessionManagerTest5, RegisterSessionSnapshotFunc, Function | Small
ssm_->RegisterSessionSnapshotFunc(scensession);
}
/**
* @tc.name: GetSessionDisplayInfo
* @tc.desc: GetSessionDisplayInfo
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionManagerTest5, GetSessionDisplayInfo, Function | SmallTest | Level3)
{
SessionDisplayInfo sessionDisplayInfo;
auto ret = ssm_->GetSessionDisplayInfo(0, sessionDisplayInfo);
ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
}
/**
* @tc.name: RequestAllAppSessionUnfocus
* @tc.desc: RequestAllAppSessionUnfocus

View File

@ -1214,6 +1214,44 @@ HWTEST_F(SceneSessionManagerTest6, DeleteStateDetectTask, Function | SmallTest |
ASSERT_NE(nullptr, ssm_);
ssm_->DeleteStateDetectTask();
}
/**
* @tc.name: TerminateSessionByPersistentId
* @tc.desc: Success to terminate session by persistentId.
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionManagerTest6, TerminateSessionByPersistentId001, Function | SmallTest | Level3)
{
SessionInfo info;
info.abilityName_ = "test1";
info.bundleName_ = "test1";
info.windowType_ = static_cast<uint32_t>(WindowType::APP_WINDOW_BASE);
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
ASSERT_NE(nullptr, sceneSession);
ASSERT_NE(nullptr, ssm_);
ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession));
auto result = ssm_->TerminateSessionByPersistentId(sceneSession->GetPersistentId());
EXPECT_EQ(result, WMError::WM_ERROR_INVALID_PERMISSION);
}
/**
* @tc.name: TerminateSessionByPersistentId
* @tc.desc: Fail to terminate session by persistentId, invalid persistentId.
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionManagerTest6, TerminateSessionByPersistentId002, Function | SmallTest | Level3)
{
SessionInfo info;
info.abilityName_ = "test1";
info.bundleName_ = "test1";
info.windowType_ = static_cast<uint32_t>(WindowType::APP_WINDOW_BASE);
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
ASSERT_NE(nullptr, sceneSession);
ASSERT_NE(nullptr, ssm_);
ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession));
auto result = ssm_->TerminateSessionByPersistentId(INVALID_SESSION_ID);
EXPECT_EQ(result, WMError::WM_ERROR_INVALID_PERMISSION);
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -89,6 +89,24 @@ HWTEST_F(SessionManagerLiteTest, RecoverSessionManagerService, Function | SmallT
ASSERT_EQ(nullptr, sessionManagerLite.sceneSessionManagerLiteProxy_);
ASSERT_EQ(0, ret);
}
/**
* @tc.name: GetSessionDisplayInfo
* @tc.desc: GetSessionDisplayInfo
* @tc.type: FUNC
*/
HWTEST_F(SessionManagerLiteTest, GetSessionDisplayInfo, Function | SmallTest | Level2)
{
SessionManagerLite& sessionManagerLite = SessionManagerLite::GetInstance();
SessionDisplayInfo sessionDisplayInfo;
auto ret = sessionManagerLite.GetSessionDisplayInfo(0, sessionDisplayInfo);
ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
sessionManagerLite.ClearSessionManagerProxy();
sessionManagerLite.Clear();
ASSERT_EQ(nullptr, sessionManagerLite.sceneSessionManagerLiteProxy_);
}
/**
* @tc.name: ReregisterSessionListener
* @tc.desc: normal function

View File

@ -107,22 +107,6 @@ WSError WindowEventChannelTest::TransferAccessibilityDumpChildInfo(bool isChanne
}
namespace {
/**
* @tc.name: OnDispatchEventProcessed
* @tc.desc: normal function OnDispatchEventProcessed
* @tc.type: FUNC
*/
HWTEST_F(WindowEventChannelTest, OnDispatchEventProcessed, Function | SmallTest | Level2)
{
GTEST_LOG_(INFO) << "WindowEventChannelTest: OnDispatchEventProcessed";
int32_t eventId = 12;
int64_t actionTime = 8888;
uint32_t res = 0;
WindowEventChannel::OnDispatchEventProcessed(eventId, actionTime);
ASSERT_EQ(0, res);
GTEST_LOG_(INFO) << "WindowEventChannelTest: OnDispatchEventProcessed";
}
/**
* @tc.name: TransferKeyEvent
* @tc.desc: normal function TransferKeyEvent

View File

@ -67,7 +67,7 @@ public:
PictureInPictureController(sptr<PipOption> pipOption, sptr<Window> mainWindow, uint32_t mainWindowId, napi_env env);
~PictureInPictureController();
WMError StartPictureInPicture(StartPipType startType);
WMError StopPictureInPicture(bool destroyWindow, StopPipType stopPipType);
WMError StopPictureInPicture(bool destroyWindow, StopPipType stopPipType, bool withAnim = true);
WMError StopPictureInPictureFromClient();
WMError DestroyPictureInPictureWindow();
sptr<Window> GetPipWindow() const;
@ -145,7 +145,7 @@ private:
WMError CreatePictureInPictureWindow(StartPipType startType);
WMError ShowPictureInPictureWindow(StartPipType startType);
WMError StartPictureInPictureInner(StartPipType startType);
WMError StopPictureInPictureInner(StopPipType stopType);
WMError StopPictureInPictureInner(StopPipType stopType, bool withAnim);
void UpdateXComponentPositionAndSize();
void UpdatePiPSourceRect() const;
void ResetExtController();

View File

@ -53,6 +53,7 @@ public:
static void DoActionEvent(const std::string& actionName, int32_t status);
static void DoControlEvent(PiPControlType controlType, PiPControlStatus status);
static void AutoStartPipWindow(std::string navigationId);
static void DoDestroy();
private:
// controller in use
static sptr<PictureInPictureController> activeController_;

View File

@ -50,6 +50,7 @@ public:
virtual WMError ClearMainSessions(const std::vector<int32_t>& persistentIds);
virtual WMError ClearMainSessions(const std::vector<int32_t>& persistentIds, std::vector<int32_t>& clearFailedIds);
virtual WMError RaiseWindowToTop(int32_t persistentId);
virtual WMError TerminateSessionByPersistentId(int32_t persistentId);
WMError RegisterWMSConnectionChangedListener(const WMSConnectionChangedCallbackFunc& callbackFunc);
private:

View File

@ -375,6 +375,7 @@ private:
bool IsUserOrientation(Orientation orientation) const;
WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config);
void SetForceSplitEnable(bool isForceSplit, const std::string& homePage = "");
bool IsNotifyInteractiveDuplicative(bool interactive);
static std::recursive_mutex lifeCycleListenerMutex_;
static std::recursive_mutex windowChangeListenerMutex_;
@ -426,6 +427,8 @@ private:
sptr<WindowOption> windowOption_;
std::string restoredRouterStack_; // It was set and get in same thread, which is js thread.
bool hasFirstNotifyInteractive_ = false;
bool interactive_ = true;
};
} // namespace Rosen
} // namespace OHOS

View File

@ -296,9 +296,9 @@ WMError PictureInPictureController::StopPictureInPictureFromClient()
return res;
}
WMError PictureInPictureController::StopPictureInPicture(bool destroyWindow, StopPipType stopPipType)
WMError PictureInPictureController::StopPictureInPicture(bool destroyWindow, StopPipType stopPipType, bool withAnim)
{
TLOGD(WmsLogTag::WMS_PIP, "destroyWindow: %{public}u", destroyWindow);
TLOGD(WmsLogTag::WMS_PIP, "destroyWindow: %{public}u anim: %{public}d", destroyWindow, withAnim);
std::lock_guard<std::mutex> lock(mutex_);
if ((!isStoppedFromClient_ && curState_ == PiPWindowState::STATE_STOPPING) ||
curState_ == PiPWindowState::STATE_STOPPED) {
@ -329,10 +329,10 @@ WMError PictureInPictureController::StopPictureInPicture(bool destroyWindow, Sto
PictureInPictureManager::RemovePipControllerInfo(window_->GetWindowId());
return WMError::WM_OK;
}
return StopPictureInPictureInner(stopPipType);
return StopPictureInPictureInner(stopPipType, withAnim);
}
WMError PictureInPictureController::StopPictureInPictureInner(StopPipType stopType)
WMError PictureInPictureController::StopPictureInPictureInner(StopPipType stopType, bool withAnim)
{
uint32_t templateType = 0;
if (pipOption_ != nullptr) {
@ -349,23 +349,13 @@ WMError PictureInPictureController::StopPictureInPictureInner(StopPipType stopTy
syncTransactionController->OpenSyncTransaction();
}
ResetExtController();
DestroyPictureInPictureWindow();
if (!withAnim) {
DestroyPictureInPictureWindow();
}
if (syncTransactionController) {
syncTransactionController->CloseSyncTransaction();
}
for (auto& listener : pipLifeCycleListeners_) {
listener->OnPictureInPictureStop();
}
curState_ = PiPWindowState::STATE_STOPPED;
std::string navId = pipOption_ == nullptr ? "" : pipOption_->GetNavigationId();
if (!navId.empty() && mainWindow_) {
auto navController = NavigationController::GetNavigationController(
mainWindow_->GetUIContent(), navId);
if (navController) {
navController->DeletePIPMode(handleId_);
TLOGI(WmsLogTag::WMS_PIP, "Delete pip mode id: %{public}d", handleId_);
}
}
SingletonContainer::Get<PiPReporter>().ReportPiPStopWindow(static_cast<int32_t>(stopType),
templateType, PIP_SUCCESS, "pip window stop success");
return WMError::WM_OK;
@ -390,6 +380,19 @@ WMError PictureInPictureController::DestroyPictureInPictureWindow()
PictureInPictureManager::RemoveActiveController(this);
PictureInPictureManager::RemovePipControllerInfo(window_->GetWindowId());
window_ = nullptr;
for (auto& listener : pipLifeCycleListeners_) {
listener->OnPictureInPictureStop();
}
curState_ = PiPWindowState::STATE_STOPPED;
std::string navId = pipOption_ == nullptr ? "" : pipOption_->GetNavigationId();
if (!navId.empty() && mainWindow_) {
auto navController = NavigationController::GetNavigationController(mainWindow_->GetUIContent(), navId);
if (navController) {
navController->DeletePIPMode(handleId_);
TLOGI(WmsLogTag::WMS_PIP, "Delete pip mode id: %{public}d", handleId_);
}
}
return WMError::WM_OK;
}
@ -573,7 +576,7 @@ void PictureInPictureController::DoControlEvent(PiPControlType controlType, PiPC
void PictureInPictureController::RestorePictureInPictureWindow()
{
StopPictureInPicture(true, StopPipType::NULL_STOP);
StopPictureInPicture(true, StopPipType::NULL_STOP, false);
SingletonContainer::Get<PiPReporter>().ReportPiPRestore();
TLOGI(WmsLogTag::WMS_PIP, "restore pip main window finished");
}

View File

@ -36,7 +36,8 @@ namespace {
{ACTION_CLOSE, PictureInPictureManager::DoActionClose},
{ACTION_PRE_RESTORE, PictureInPictureManager::DoPreRestore},
{ACTION_RESTORE, PictureInPictureManager::DoRestore},
{ACTION_LOCATE_SOURCE, PictureInPictureManager::DoLocateSource}
{ACTION_LOCATE_SOURCE, PictureInPictureManager::DoLocateSource},
{ACTION_DESTROY, PictureInPictureManager::DoDestroy}
};
}
@ -231,7 +232,7 @@ void PictureInPictureManager::DoClose(bool destroyWindow, bool byPriority)
} else {
currentStopType = StopPipType::OTHER_PACKAGE_STOP;
}
activeController_->StopPictureInPicture(destroyWindow, currentStopType);
activeController_->StopPictureInPicture(destroyWindow, currentStopType, !byPriority);
}
void PictureInPictureManager::DoActionClose()
@ -240,6 +241,15 @@ void PictureInPictureManager::DoActionClose()
DoClose(true, false);
}
void PictureInPictureManager::DoDestroy()
{
TLOGI(WmsLogTag::WMS_PIP, "called");
if (!HasActiveController()) {
return;
}
activeController_->DestroyPictureInPictureWindow();
}
void PictureInPictureManager::DoActionEvent(const std::string& actionName, int32_t status)
{
TLOGD(WmsLogTag::WMS_PIP, "called");

View File

@ -278,5 +278,14 @@ sptr<IWindowManagerLite> WindowAdapterLite::GetWindowManagerServiceProxy() const
return windowManagerServiceProxy_;
}
WMError WindowAdapterLite::TerminateSessionByPersistentId(int32_t persistentId)
{
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
auto wmsProxy = GetWindowManagerServiceProxy();
CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
return wmsProxy->TerminateSessionByPersistentId(persistentId);
}
} // namespace Rosen
} // namespace OHOS

View File

@ -192,7 +192,6 @@ WMError WindowExtensionSessionImpl::Destroy(bool needNotifyServer, bool needClea
windowExtensionSessionSet_.erase(this);
}
TLOGI(WmsLogTag::WMS_LIFE, "Erase windowExtensionSession in set, id: %{public}d.", GetPersistentId());
DelayedSingleton<ANRHandler>::GetInstance()->OnWindowDestroyed(GetPersistentId());
if (context_) {
context_.reset();
}

View File

@ -638,5 +638,14 @@ void WindowManagerLite::OnWMSConnectionChanged(int32_t userId, int32_t screenId,
pImpl_->NotifyWMSDisconnected(userId, screenId);
}
}
WMError WindowManagerLite::TerminateSessionByPersistentId(int32_t persistentId)
{
if (persistentId == INVALID_SESSION_ID) {
TLOGE(WmsLogTag::WMS_LIFE, "persistentId is invalid.");
return WMError::WM_ERROR_INVALID_PARAM;
}
return SingletonContainer::Get<WindowAdapterLite>().TerminateSessionByPersistentId(persistentId);
}
} // namespace Rosen
} // namespace OHOS

View File

@ -1288,7 +1288,6 @@ WMError WindowSceneSessionImpl::Destroy(bool needNotifyServer, bool needClearLis
std::unique_lock<std::shared_mutex> lock(windowSessionMutex_);
windowSessionMap_.erase(property_->GetWindowName());
}
DelayedSingleton<ANRHandler>::GetInstance()->OnWindowDestroyed(property_->GetPersistentId());
{
std::lock_guard<std::mutex> lock(hostSessionMutex_);
hostSession_ = nullptr;

View File

@ -527,7 +527,6 @@ WMError WindowSessionImpl::Destroy(bool needNotifyServer, bool needClearListener
std::unique_lock<std::shared_mutex> lock(windowSessionMutex_);
windowSessionMap_.erase(property_->GetWindowName());
}
DelayedSingleton<ANRHandler>::GetInstance()->OnWindowDestroyed(GetPersistentId());
NotifyAfterDestroy();
if (needClearListener) {
ClearListenersById(GetPersistentId());
@ -715,6 +714,18 @@ WMError WindowSessionImpl::RequestFocus() const
return SingletonContainer::Get<WindowAdapter>().RequestFocusStatus(GetPersistentId(), true);
}
bool WindowSessionImpl::IsNotifyInteractiveDuplicative(bool interactive)
{
if (interactive == interactive_ && hasFirstNotifyInteractive_) {
return true;
}
hasFirstNotifyInteractive_ = true;
if (interactive_ != interactive) {
interactive_ = interactive;
}
return false;
}
void WindowSessionImpl::NotifyForegroundInteractiveStatus(bool interactive)
{
WLOGFI("NotifyForegroundInteractiveStatus %{public}d", interactive);
@ -722,6 +733,9 @@ void WindowSessionImpl::NotifyForegroundInteractiveStatus(bool interactive)
WLOGFE("session is invalid");
return;
}
if (IsNotifyInteractiveDuplicative(interactive)) {
return;
}
if (state_ == WindowState::STATE_SHOWN) {
if (interactive) {
NotifyAfterResumed();

View File

@ -189,7 +189,7 @@ HWTEST_F(PictureInPictureControllerTest, StopPictureInPicture01, Function | Smal
pipControl->curState_ = PiPWindowState::STATE_STARTED;
ASSERT_EQ(PiPWindowState::STATE_STARTED, pipControl->GetControllerState());
ASSERT_EQ(WMError::WM_OK, pipControl->StopPictureInPicture(true, StopPipType::NULL_STOP));
ASSERT_EQ(PiPWindowState::STATE_STOPPED, pipControl->GetControllerState());
ASSERT_NE(PiPWindowState::STATE_STARTED, pipControl->GetControllerState());
}
/**
@ -807,12 +807,17 @@ HWTEST_F(PictureInPictureControllerTest, DestroyPictureInPictureWindow, Function
sptr<PipOption> option = new (std::nothrow) PipOption();
ASSERT_NE(nullptr, option);
sptr<PictureInPictureController> pipControl =
new (std::nothrow) PictureInPictureController(option, mw, 100, nullptr);
sptr<PictureInPictureController>::MakeSptr(option, mw, 100, nullptr);
pipControl->window_ = nullptr;
ASSERT_EQ(WMError::WM_ERROR_PIP_INTERNAL_ERROR, pipControl->DestroyPictureInPictureWindow());
pipControl->window_ = mw;
sptr<MockWindow> window = sptr<MockWindow>::MakeSptr();
pipControl->window_ = window;
EXPECT_CALL(*(window), Destroy()).Times(1).WillOnce(Return(WMError::WM_DO_NOTHING));
ASSERT_EQ(WMError::WM_ERROR_PIP_DESTROY_FAILED, pipControl->DestroyPictureInPictureWindow());
EXPECT_CALL(*(window), Destroy()).Times(1).WillOnce(Return(WMError::WM_OK));
ASSERT_EQ(WMError::WM_OK, pipControl->DestroyPictureInPictureWindow());
}
@ -853,9 +858,15 @@ HWTEST_F(PictureInPictureControllerTest, StopPictureInPictureInner, Function | S
auto pipControl = sptr<PictureInPictureController>::MakeSptr(option, mw, 100, nullptr);
pipControl->window_ = nullptr;
ASSERT_EQ(WMError::WM_ERROR_PIP_INTERNAL_ERROR, pipControl->StopPictureInPictureInner(StopPipType::NULL_STOP));
ASSERT_EQ(WMError::WM_ERROR_PIP_INTERNAL_ERROR,
pipControl->StopPictureInPictureInner(StopPipType::NULL_STOP, true));
pipControl->mainWindow_ = mw;
ASSERT_EQ(WMError::WM_ERROR_PIP_INTERNAL_ERROR, pipControl->StopPictureInPictureInner(StopPipType::NULL_STOP));
ASSERT_EQ(WMError::WM_ERROR_PIP_INTERNAL_ERROR,
pipControl->StopPictureInPictureInner(StopPipType::NULL_STOP, true));
auto window = sptr<MockWindow>::MakeSptr();
pipControl->window_ = window;
ASSERT_EQ(WMError::WM_OK, pipControl->StopPictureInPictureInner(StopPipType::NULL_STOP, true));
ASSERT_EQ(WMError::WM_OK, pipControl->StopPictureInPictureInner(StopPipType::NULL_STOP, false));
}
}
}

View File

@ -383,6 +383,24 @@ HWTEST_F(PictureInPictureManagerTest, AutoStartPipWindow, Function | SmallTest |
SingletonContainer::Get<PiPReporter>().ReportPiPActionEvent(1, "close");
}
/**
* @tc.name: DoDestroy
* @tc.desc: DoDestroy
* @tc.type: FUNC
*/
HWTEST_F(PictureInPictureManagerTest, DoDestroy, Function | SmallTest | Level2)
{
PictureInPictureManager::activeController_ = nullptr;
ASSERT_FALSE(PictureInPictureManager::HasActiveController());
PictureInPictureManager::DoDestroy();
sptr<PipOption> option = sptr<PipOption>::MakeSptr();
ASSERT_NE(nullptr, option);
sptr<PictureInPictureController> pipController =
sptr<PictureInPictureController>::MakeSptr(option, nullptr, 100, nullptr);
PictureInPictureManager::activeController_ = pipController;
ASSERT_TRUE(PictureInPictureManager::HasActiveController());
PictureInPictureManager::DoDestroy();
}
}
}
}

View File

@ -464,5 +464,35 @@ HWTEST_F(WindowManagerLiteTest, NotifyWMSConnected, Function | SmallTest | Level
auto ret = WindowManagerLite::GetInstance().GetWindowModeType(windowModeType);
EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ret);
}
/**
* @tc.name: TerminateSessionByPersistentId001
* @tc.desc: TerminateSessionByPersistentId001
* @tc.type: FUNC
*/
HWTEST_F(WindowManagerLiteTest, TerminateSessionByPersistentId001, Function | SmallTest | Level2)
{
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
int32_t persistentId = 1;
EXPECT_CALL(m->Mock(), TerminateSessionByPersistentId(_)).Times(1).WillOnce(Return(WMError::WM_OK));
auto errorCode = WindowManagerLite::GetInstance().TerminateSessionByPersistentId(persistentId);
ASSERT_EQ(WMError::WM_OK, errorCode);
}
/**
* @tc.name: TerminateSessionByPersistentId002
* @tc.desc: TerminateSessionByPersistentId002
* @tc.type: FUNC
*/
HWTEST_F(WindowManagerLiteTest, TerminateSessionByPersistentId002, Function | SmallTest | Level2)
{
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
int32_t persistentId = 0;
EXPECT_CALL(m->Mock(), TerminateSessionByPersistentId(_)).Times(1).WillOnce(Return(WMError::WM_OK));
auto errorCode = WindowManagerLite::GetInstance().TerminateSessionByPersistentId(persistentId);
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, errorCode);
}
}
}

View File

@ -46,6 +46,7 @@ public:
virtual WMError ClearMainSessions(const std::vector<int32_t>& persistentIds,
std::vector<int32_t>& clearFailedIds) = 0;
virtual WSError RaiseWindowToTop(int32_t persistentId) { return WSError::WS_OK; }
virtual WMError TerminateSessionByPersistentId(int32_t persistentId) = 0;
};
}
}