!7559 支持应用启动时指定窗口以全屏模式启动和显示

Merge pull request !7559 from 韦国宁/master
This commit is contained in:
openharmony_ci 2024-07-27 07:00:14 +00:00 committed by Gitee
commit 874a4f4c18
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
17 changed files with 150 additions and 12 deletions

View File

@ -255,6 +255,17 @@ void JsRootSceneSession::PendingSessionActivationInner(std::shared_ptr<SessionIn
taskScheduler_->PostMainThreadTask(task, "PendingSessionActivationInner");
}
static int32_t GetRealCallerSessionId(const sptr<SceneSession>& sceneSession)
{
int32_t realCallerSessionId = SceneSessionManager::GetInstance().GetFocusedSessionId();
if (realCallerSessionId == sceneSession->GetPersistentId()) {
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]caller is self, switch to self caller.");
realCallerSessionId = sceneSession->GetSessionInfo().callerPersistentId_;
}
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]caller session: %{public}d.", realCallerSessionId);
return realCallerSessionId;
}
void JsRootSceneSession::PendingSessionActivation(SessionInfo& info)
{
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]bundleName %{public}s, moduleName %{public}s, abilityName %{public}s, "
@ -271,16 +282,7 @@ void JsRootSceneSession::PendingSessionActivation(SessionInfo& info)
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]session: %{public}d isNeedBackToOther: %{public}d",
sceneSession->GetPersistentId(), isNeedBackToOther);
if (isNeedBackToOther) {
int32_t realCallerSessionId = SceneSessionManager::GetInstance().GetFocusedSessionId();
if (realCallerSessionId == sceneSession->GetPersistentId()) {
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]caller is self, switch to self caller.");
auto scnSession = SceneSessionManager::GetInstance().GetSceneSession(realCallerSessionId);
if (scnSession != nullptr) {
realCallerSessionId = scnSession->GetSessionInfo().callerPersistentId_;
}
}
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]caller session: %{public}d.", realCallerSessionId);
info.callerPersistentId_ = realCallerSessionId;
info.callerPersistentId_ = GetRealCallerSessionId(sceneSession);
VerifyCallerToken(info);
} else {
info.callerPersistentId_ = 0;
@ -311,6 +313,9 @@ void JsRootSceneSession::PendingSessionActivation(SessionInfo& info)
PendingSessionActivationInner(sessionInfo);
};
sceneSession->PostLifeCycleTask(task, "PendingSessionActivation", LifeCycleTaskType::START);
if (info.fullScreenStart_) {
sceneSession->NotifySessionFullScreen(true);
}
}
void JsRootSceneSession::VerifyCallerToken(SessionInfo& info)

View File

@ -2100,6 +2100,9 @@ void JsSceneSession::PendingSessionActivation(SessionInfo& info)
PendingSessionActivationInner(sessionInfo);
};
sceneSession->PostLifeCycleTask(task, "PendingSessionActivation", LifeCycleTaskType::START);
if (info.fullScreenStart_) {
sceneSession->NotifySessionFullScreen(true);
}
}
void JsSceneSession::PendingSessionActivationInner(std::shared_ptr<SessionInfo> sessionInfo)

View File

@ -73,6 +73,7 @@ public:
virtual void NotifyDisplayMove(DisplayId from, DisplayId to) = 0;
virtual WSError SwitchFreeMultiWindow(bool enable) = 0;
virtual WSError GetUIContentRemoteObj(sptr<IRemoteObject>& uiContentRemoteObj) = 0;
virtual void NotifySessionFullScreen(bool fullScreen) {}
// **Non** IPC interface
virtual void NotifyBackpressedEvent(bool& isConsumed) {}

View File

@ -53,6 +53,7 @@ enum class SessionStageInterfaceCode {
TRANS_ID_GET_UI_CONTENT_REMOTE_OBJ,
TRANS_ID_NOTIFY_KEYBOARD_INFO_CHANGE,
TRANS_ID_NOTIFY_DENSITY_FOLLOW_HOST,
TRANS_ID_NOTIFY_SESSION_FULLSCREEN,
};
} // namespace Rosen
} // namespace OHOS

View File

@ -66,6 +66,7 @@ public:
WSError SwitchFreeMultiWindow(bool enable) override;
WSError GetUIContentRemoteObj(sptr<IRemoteObject>& uiContentRemoteObj) override;
void NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo& keyboardPanelInfo) override;
void NotifySessionFullScreen(bool fullScreen) override;
private:
static inline BrokerDelegator<SessionStageProxy> delegator_;

View File

@ -66,6 +66,7 @@ private:
int HandleSwitchFreeMultiWindow(MessageParcel& data, MessageParcel& reply);
int HandleGetUIContentRemoteObj(MessageParcel& data, MessageParcel& reply);
int HandleNotifyKeyboardPanelInfoChange(MessageParcel& data, MessageParcel& reply);
int HandleNotifySessionFullScreen(MessageParcel& data, MessageParcel& reply);
};
} // namespace OHOS::Rosen
#endif // OHOS_WINDOW_SCENE_SESSION_STAGE_STUB_H

View File

@ -585,6 +585,31 @@ void SessionStageProxy::NotifySessionForeground(uint32_t reason, bool withAnima
}
}
void SessionStageProxy::NotifySessionFullScreen(bool fullScreen)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
return;
}
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC);
if (!data.WriteInterfaceToken(GetDescriptor())) {
TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
return;
}
if (!data.WriteBool(fullScreen)) {
TLOGE(WmsLogTag::WMS_LAYOUT, "Write fullScreen failed");
return;
}
if (remote->SendRequest(
static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FULLSCREEN),
data, reply, option) != ERR_NONE) {
TLOGE(WmsLogTag::WMS_LAYOUT, "Send Request failed");
}
}
void SessionStageProxy::NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits)
{
MessageParcel data;

View File

@ -100,6 +100,8 @@ int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messag
return HandleGetUIContentRemoteObj(data, reply);
case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_INFO_CHANGE):
return HandleNotifyKeyboardPanelInfoChange(data, reply);
case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FULLSCREEN):
return HandleNotifySessionFullScreen(data, reply);
default:
WLOGFE("Failed to find function handler!");
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
@ -325,6 +327,14 @@ int SessionStageStub::HandleNotifySessionForeground(MessageParcel& data, Message
return ERR_NONE;
}
int SessionStageStub::HandleNotifySessionFullScreen(MessageParcel& data, MessageParcel& reply)
{
TLOGD(WmsLogTag::WMS_LAYOUT, "called");
bool fullScreen = data.ReadBool();
NotifySessionFullScreen(fullScreen);
return ERR_NONE;
}
int SessionStageStub::HandleNotifySessionBackground(MessageParcel& data, MessageParcel& reply)
{
WLOGFD("HandleNotifySessionBackground");

View File

@ -308,6 +308,7 @@ public:
void RemoveExtWindowFlags(int32_t extPersistentId);
void ClearExtWindowFlags();
void NotifyDisplayMove(DisplayId from, DisplayId to);
void NotifySessionFullScreen(bool fullScreen);
void SetSessionState(SessionState state) override;
void UpdateSessionState(SessionState state) override;

View File

@ -2696,6 +2696,9 @@ static SessionInfo MakeSessionInfoDuringPendingActivation(const sptr<AAFwk::Sess
info.screenId_ = static_cast<uint64_t>(info.want->GetIntParam(AAFwk::Want::PARAM_RESV_DISPLAY_ID, -1));
TLOGI(WmsLogTag::WMS_LIFE, "want: screenId %{public}" PRIu64, info.screenId_);
}
if (info.windowMode == static_cast<int32_t>(WindowMode::WINDOW_MODE_FULLSCREEN)) {
info.fullScreenStart_ = true;
}
TLOGI(WmsLogTag::WMS_LIFE, "bundleName:%{public}s, moduleName:%{public}s, "
"abilityName:%{public}s, appIndex:%{public}d, affinity:%{public}s. "
"callState:%{public}d, want persistentId:%{public}d, "
@ -3558,6 +3561,15 @@ void SceneSession::NotifySessionBackground(uint32_t reason, bool withAnimation,
return sessionStage_->NotifySessionBackground(reason, withAnimation, isFromInnerkits);
}
void SceneSession::NotifySessionFullScreen(bool fullScreen)
{
if (!sessionStage_) {
TLOGE(WmsLogTag::WMS_LAYOUT, "sessionStage is null");
return;
}
sessionStage_->NotifySessionFullScreen(fullScreen);
}
WSError SceneSession::UpdatePiPRect(const Rect& rect, SizeChangeReason reason)
{
if (!WindowHelper::IsPipWindow(GetWindowType())) {

View File

@ -61,6 +61,7 @@ public:
MOCK_METHOD2(NotifyDisplayMove, void(DisplayId from, DisplayId to));
MOCK_METHOD1(SwitchFreeMultiWindow, WSError(bool enable));
MOCK_METHOD1(GetUIContentRemoteObj, WSError(sptr<IRemoteObject>& uiContentRemoteObj));
MOCK_METHOD1(NotifySessionFullScreen, void(bool fullScreen));
};
} // namespace Rosen
} // namespace OHOS

View File

@ -714,6 +714,31 @@ HWTEST_F(SceneSessionTest2, NotifySessionForeground, Function | SmallTest | Leve
ASSERT_EQ(ret, 1);
}
/**
* @tc.name: NotifySessionFullScreen01
* @tc.desc: NotifySessionFullScreen
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionTest2, NotifySessionFullScreen, Function | SmallTest | Level2)
{
SessionInfo info;
info.abilityName_ = "FullScreen01";
info.bundleName_ = "IsFloatingWindowAppType";
info.windowType_ = 1;
sptr<SceneSession::SpecificSessionCallback> specificCallback =
new (std::nothrow) SceneSession::SpecificSessionCallback();
EXPECT_NE(specificCallback, nullptr);
sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
EXPECT_NE(sceneSession, nullptr);
sptr<SessionStageMocker> mockSessionStage = new (std::nothrow) SessionStageMocker();
ASSERT_NE(mockSessionStage, nullptr);
bool fullScreen = true;
int ret = 1;
sceneSession->sessionStage_ = mockSessionStage;
sceneSession->NotifySessionFullScreen(fullScreen);
ASSERT_EQ(ret, 1);
}
/**
* @tc.name: NotifySessionBackground01
* @tc.desc: NotifySessionBackground

View File

@ -281,6 +281,18 @@ HWTEST_F(SessionStageProxyTest, NotifySessionBackground, Function | SmallTest |
sessionStage_->NotifySessionBackground(reason, withAnimation, isFromInnerkits);
}
/**
* @tc.name: NotifySessionFullScreen
* @tc.desc: test function : NotifySessionFullScreen
* @tc.type: FUNC
*/
HWTEST_F(SessionStageProxyTest, NotifySessionFullScreen, Function | SmallTest | Level1)
{
bool fullScreen = true;
ASSERT_TRUE(sessionStage_ != nullptr);
sessionStage_->NotifySessionFullScreen(fullScreen);
}
/**
* @tc.name: NotifyWindowVisibility
* @tc.desc: test function : NotifyWindowVisibility

View File

@ -298,6 +298,21 @@ HWTEST_F(SessionStageStubTest, HandleNotifySessionForeground, Function | SmallTe
ASSERT_EQ(0, sessionStageStub_->HandleNotifySessionForeground(data, reply));
}
/**
* @tc.name: NotifySessionFullScreen
* @tc.desc: test function : NotifySessionFullScreen
* @tc.type: FUNC
*/
HWTEST_F(SessionStageStubTest, HandleNotifySessionFullScreen, Function | SmallTest | Level1)
{
MessageParcel data;
MessageParcel reply;
data.WriteBool(true);
ASSERT_TRUE(sessionStageStub_ != nullptr);
ASSERT_EQ(0, sessionStageStub_->HandleNotifySessionFullScreen(data, reply));
}
/**
* @tc.name: NotifySessionBackground
* @tc.desc: test function : NotifySessionBackground

View File

@ -160,6 +160,7 @@ public:
virtual WMError SetImmersiveModeEnabledState(bool enable) override;
virtual bool GetImmersiveModeEnabledState() const override;
uint32_t GetStatusBarHeight() override;
void NotifySessionFullScreen(bool fullScreen) override;
protected:
void DestroySubWindow();

View File

@ -1678,8 +1678,8 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status)
}
if (WindowHelper::IsMainWindow(GetType()) &&
windowSystemConfig_.uiType_ != "phone" &&
windowSystemConfig_.uiType_ != "pad") {
((windowSystemConfig_.uiType_ != "phone" && windowSystemConfig_.uiType_ != "pad") ||
IsFreeMultiWindowMode())) {
if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) {
TLOGE(WmsLogTag::WMS_IMMS, "fullscreen window mode is not supported");
return WMError::WM_ERROR_INVALID_WINDOW;
@ -3068,6 +3068,12 @@ void WindowSceneSessionImpl::NotifySessionForeground(uint32_t reason, bool withA
Show(reason, withAnimation);
}
void WindowSceneSessionImpl::NotifySessionFullScreen(bool fullScreen)
{
TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}u", GetWindowId());
SetLayoutFullScreen(fullScreen);
}
void WindowSceneSessionImpl::NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits)
{
WLOGFI("NotifySessionBackground");

View File

@ -875,6 +875,24 @@ HWTEST_F(WindowSceneSessionImplTest2, NotifySessionBackground, Function | SmallT
windowSceneSession->NotifySessionBackground(reason, withAnimation, isFromInnerkits);
}
/**
* @tc.name: NotifySessionFullScreen
* @tc.desc: NotifySessionFullScreen
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest2, NotifySessionFullScreen, Function | SmallTest | Level2)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
ASSERT_NE(nullptr, option);
option->SetWindowName("NotifySessionFullScreen");
option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE);
sptr<WindowSceneSessionImpl> windowSceneSession = new (std::nothrow) WindowSceneSessionImpl(option);
ASSERT_NE(nullptr, windowSceneSession);
bool fullScreen = true;
windowSceneSession->NotifySessionFullScreen(fullScreen);
}
/**
* @tc.name: NotifyPrepareClosePiPWindow01
* @tc.desc: NotifyPrepareClosePiPWindow