mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-27 17:11:51 +00:00
fix
Signed-off-by: z30042987 <zhouminghui8@huawei.com>
This commit is contained in:
parent
5b621f4cdf
commit
ac9ceafdae
@ -62,6 +62,7 @@ public:
|
||||
virtual std::vector<DisplayId> GetAllDisplayIds();
|
||||
virtual std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId, DmErrorCode* errorCode = nullptr);
|
||||
virtual DMError DisableDisplaySnapshot(bool disableOrNot);
|
||||
virtual DMError HasImmersiveWindow(bool& immersive);
|
||||
virtual DMError HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow);
|
||||
virtual bool WakeUpBegin(PowerStateChangeReason reason);
|
||||
virtual bool WakeUpEnd();
|
||||
|
@ -146,4 +146,10 @@ sptr<CutoutInfo> Display::GetCutoutInfo() const
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().GetCutoutInfo(GetId());
|
||||
}
|
||||
|
||||
DMError Display::HasImmersiveWindow(bool& immersive)
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().HasImmersiveWindow(immersive);
|
||||
}
|
||||
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -415,6 +415,13 @@ DMError DisplayManagerAdapter::HasPrivateWindow(DisplayId displayId, bool& hasPr
|
||||
return displayManagerServiceProxy_->HasPrivateWindow(displayId, hasPrivateWindow);
|
||||
}
|
||||
|
||||
DMError DisplayManagerAdapter::HasImmersiveWindow(bool& immersive)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
|
||||
return displayManagerServiceProxy_->HasImmersiveWindow(immersive);
|
||||
}
|
||||
|
||||
sptr<DisplayInfo> DisplayManagerAdapter::GetDisplayInfo(DisplayId displayId)
|
||||
{
|
||||
if (displayId == DISPLAY_ID_INVALID) {
|
||||
|
@ -79,6 +79,7 @@ public:
|
||||
TRANS_ID_SET_SCREEN_ROTATION_LOCKED,
|
||||
TRANS_ID_HAS_PRIVATE_WINDOW,
|
||||
TRANS_ID_GET_CUTOUT_INFO,
|
||||
TRANS_ID_HAS_IMMERSIVE_WINDOW,
|
||||
TRANS_ID_ADD_SURFACE_NODE,
|
||||
TRANS_ID_REMOVE_SURFACE_NODE,
|
||||
TRANS_ID_SCREEN_STOP_MIRROR,
|
||||
@ -164,6 +165,8 @@ public:
|
||||
|
||||
virtual sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion() { return nullptr; }
|
||||
|
||||
virtual DMError HasImmersiveWindow(bool& immersive) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; }
|
||||
|
||||
// unique screen
|
||||
virtual DMError MakeUniqueScreen(const std::vector<ScreenId>& screenIds) { return DMError::DM_OK; }
|
||||
};
|
||||
|
@ -134,6 +134,15 @@ public:
|
||||
* @return Cutout info of the display.
|
||||
*/
|
||||
sptr<CutoutInfo> GetCutoutInfo() const;
|
||||
|
||||
/**
|
||||
* @brief Judge if current display has immersive window.
|
||||
* @param immersive The flag to represent if current display has immersive window.
|
||||
*
|
||||
* @return DM error codes.
|
||||
*/
|
||||
DMError HasImmersiveWindow(bool& immersive);
|
||||
|
||||
protected:
|
||||
// No more methods or variables can be defined here.
|
||||
Display(const std::string& name, sptr<DisplayInfo> info);
|
||||
|
@ -93,6 +93,7 @@ enum class DMError : int32_t {
|
||||
DM_ERROR_INVALID_CALLING = 200,
|
||||
DM_ERROR_INVALID_PERMISSION = 201,
|
||||
DM_ERROR_NOT_SYSTEM_APP = 202,
|
||||
DM_ERROR_DEVICE_NOT_SUPPORT = 801,
|
||||
DM_ERROR_UNKNOWN = -1,
|
||||
};
|
||||
|
||||
@ -130,6 +131,7 @@ const std::map<DMError, DmErrorCode> DM_JS_TO_ERROR_CODE_MAP {
|
||||
{DMError::DM_ERROR_INVALID_CALLING, DmErrorCode::DM_ERROR_INVALID_CALLING },
|
||||
{DMError::DM_ERROR_NOT_SYSTEM_APP, DmErrorCode::DM_ERROR_NOT_SYSTEM_APP },
|
||||
{DMError::DM_ERROR_UNKNOWN, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL },
|
||||
{DMError::DM_ERROR_DEVICE_NOT_SUPPORT, DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT },
|
||||
};
|
||||
|
||||
using DisplayStateCallback = std::function<void(DisplayState)>;
|
||||
|
@ -81,6 +81,13 @@ napi_value JsDisplay::GetCutoutInfo(napi_env env, napi_callback_info info)
|
||||
return (me != nullptr) ? me->OnGetCutoutInfo(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsDisplay::HasImmersiveWindow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
WLOGI("HasImmersiveWindow is called");
|
||||
JsDisplay* me = CheckParamsAndGetThis<JsDisplay>(env, info);
|
||||
return (me != nullptr) ? me->OnHasImmersiveWindow(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_valuetype GetType(napi_env env, napi_value value)
|
||||
{
|
||||
napi_valuetype res = napi_undefined;
|
||||
@ -116,6 +123,35 @@ napi_value JsDisplay::OnGetCutoutInfo(napi_env env, napi_callback_info info)
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value JsDisplay::OnHasImmersiveWindow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
WLOGI("OnHasImmersiveWindow is called");
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[this](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
bool immersive = false;
|
||||
DmErrorCode ret = DM_JS_TO_ERROR_CODE_MAP.at(display_->HasImmersiveWindow(immersive));
|
||||
if (ret == DmErrorCode::DM_OK) {
|
||||
task.Resolve(env, CreateJsValue(env, immersive));
|
||||
WLOGI("JsDisplay::OnHasImmersiveWindow success - immersive window exists: %{public}d", immersive);
|
||||
} else {
|
||||
task.Reject(env, CreateJsError(env,
|
||||
static_cast<int32_t>(ret), "JsDisplay::OnHasImmersiveWindow failed."));
|
||||
}
|
||||
};
|
||||
size_t argc = 4;
|
||||
napi_value argv[4] = {nullptr};
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
napi_value lastParam = nullptr;
|
||||
if (argc >= ARGC_ONE && argv[ARGC_ONE - 1] != nullptr &&
|
||||
GetType(env, argv[ARGC_ONE - 1]) == napi_function) {
|
||||
lastParam = argv[ARGC_ONE - 1];
|
||||
}
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("JsDisplay::OnHasImmersiveWindow",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeReference> FindJsDisplayObject(DisplayId displayId)
|
||||
{
|
||||
WLOGI("[NAPI]Try to find display %{public}" PRIu64" in g_JsDisplayMap", displayId);
|
||||
@ -241,6 +277,7 @@ napi_value CreateJsDisplayObject(napi_env env, sptr<Display>& display)
|
||||
std::unique_ptr<JsDisplay> jsDisplay = std::make_unique<JsDisplay>(display);
|
||||
napi_wrap(env, objValue, jsDisplay.release(), JsDisplay::Finalizer, nullptr, nullptr);
|
||||
BindNativeFunction(env, objValue, "getCutoutInfo", "JsDisplay", JsDisplay::GetCutoutInfo);
|
||||
BindNativeFunction(env, objValue, "hasImmersiveWindow", "JsDisplay", JsDisplay::HasImmersiveWindow);
|
||||
std::shared_ptr<NativeReference> jsDisplayRef;
|
||||
napi_ref result = nullptr;
|
||||
napi_create_reference(env, objValue, 1, &result);
|
||||
|
@ -40,9 +40,12 @@ public:
|
||||
~JsDisplay();
|
||||
static void Finalizer(napi_env env, void* data, void* hint);
|
||||
static napi_value GetCutoutInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value HasImmersiveWindow(napi_env env, napi_callback_info info);
|
||||
|
||||
private:
|
||||
sptr<Display> display_ = nullptr;
|
||||
napi_value OnGetCutoutInfo(napi_env env, napi_callback_info info);
|
||||
napi_value OnHasImmersiveWindow(napi_env env, napi_callback_info info);
|
||||
};
|
||||
enum class DisplayStateMode : uint32_t {
|
||||
STATE_UNKNOWN = 0,
|
||||
|
@ -317,6 +317,7 @@ private:
|
||||
void AddClientDeathRecipient(const sptr<ISessionStage>& sessionStage, const sptr<SceneSession>& sceneSession);
|
||||
void DestroySpecificSession(const sptr<IRemoteObject>& remoteObject);
|
||||
void CleanUserMap();
|
||||
void UpdateImmersiveState();
|
||||
void EraseSceneSessionMapById(int32_t persistentId);
|
||||
WSError GetAbilityInfosFromBundleInfo(std::vector<AppExecFwk::BundleInfo> &bundleInfos,
|
||||
std::vector<AppExecFwk::AbilityInfo> &abilityInfos);
|
||||
|
@ -167,7 +167,9 @@ public:
|
||||
const std::vector<sptr<ScreenInfo>>& screenInfos, ScreenGroupChangeEvent groupEvent);
|
||||
void OnScreenshot(sptr<ScreenshotInfo> info);
|
||||
sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) override;
|
||||
DMError HasImmersiveWindow(bool& immersive) override;
|
||||
void SetDisplayBoundary(const sptr<ScreenSession> screenSession);
|
||||
void SetImmersiveState(bool immersive);
|
||||
|
||||
//Fold Screen
|
||||
void SetFoldDisplayMode(const FoldDisplayMode displayMode) override;
|
||||
@ -267,6 +269,7 @@ private:
|
||||
bool screenPrivacyStates = false;
|
||||
bool keyguardDrawnDone_ = true;
|
||||
bool needScreenOnWhenKeyguardNotify_ = false;
|
||||
bool isImmersive_ = false;
|
||||
|
||||
//Fold Screen
|
||||
std::map<ScreenId, ScreenProperty> phyScreenPropMap_;
|
||||
|
@ -94,6 +94,7 @@ public:
|
||||
virtual DMError SetScreenRotationLocked(bool isLocked) override;
|
||||
virtual DMError IsScreenRotationLocked(bool& isLocked) override;
|
||||
virtual sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) override;
|
||||
virtual DMError HasImmersiveWindow(bool& immersive) override;
|
||||
|
||||
virtual DMError HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow) override;
|
||||
|
||||
|
@ -1153,6 +1153,7 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptr<SceneSessi
|
||||
return WSError::WS_OK;
|
||||
};
|
||||
|
||||
UpdateImmersiveState();
|
||||
taskScheduler_->PostAsyncTask(task);
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
@ -1292,6 +1293,7 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(
|
||||
if (listenerController_ != nullptr) {
|
||||
NotifySessionForCallback(scnSession, needRemoveSession);
|
||||
}
|
||||
UpdateImmersiveState();
|
||||
return WSError::WS_OK;
|
||||
};
|
||||
|
||||
@ -2956,6 +2958,7 @@ WSError SceneSessionManager::UpdateWindowMode(int32_t persistentId, int32_t wind
|
||||
return WSError::WS_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
WindowMode mode = static_cast<WindowMode>(windowMode);
|
||||
UpdateImmersiveState();
|
||||
return sceneSession->UpdateWindowMode(mode);
|
||||
}
|
||||
|
||||
@ -3122,6 +3125,7 @@ void SceneSessionManager::OnSessionStateChange(int32_t persistentId, const Sessi
|
||||
default:
|
||||
break;
|
||||
}
|
||||
UpdateImmersiveState();
|
||||
}
|
||||
|
||||
void SceneSessionManager::ProcessSubSessionForeground(sptr<SceneSession>& sceneSession)
|
||||
@ -5183,4 +5187,40 @@ WSError SceneSessionManager::UpdateMaximizeMode(int32_t persistentId, bool isMax
|
||||
taskScheduler_->PostAsyncTask(task);
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
void SceneSessionManager::UpdateImmersiveState() {
|
||||
std::shared_lock<std::shared_mutex> lock(sceneSessionMapMutex_);
|
||||
for (auto item = sceneSessionMap_.begin(); item != sceneSessionMap_.end(); ++item) {
|
||||
auto sceneSession = item->second;
|
||||
if (sceneSession == nullptr) {
|
||||
WLOGFE("Session is nullptr");
|
||||
continue;
|
||||
}
|
||||
if (!WindowHelper::IsMainWindow(sceneSession->GetWindowType())) {
|
||||
continue;
|
||||
}
|
||||
auto state = sceneSession->GetSessionState();
|
||||
if (state != SessionState::STATE_FOREGROUND && state != SessionState::STATE_ACTIVE) {
|
||||
continue;
|
||||
}
|
||||
if (sceneSession->GetWindowMode() != WindowMode::WINDOW_MODE_FULLSCREEN) {
|
||||
continue;
|
||||
}
|
||||
auto property = sceneSession->GetSessionProperty();
|
||||
if (property == nullptr) {
|
||||
WLOGFE("Property is nullptr");
|
||||
continue;
|
||||
}
|
||||
auto sysBarProperty = property->GetSystemBarProperty();
|
||||
if (sysBarProperty[WindowType::WINDOW_TYPE_STATUS_BAR].enable_ == false) {
|
||||
WLOGFD("Current window is immersive");
|
||||
ScreenSessionManager::GetInstance().SetImmersiveState(true);
|
||||
return;
|
||||
} else {
|
||||
WLOGFD("Current window is not immersive");
|
||||
break;
|
||||
}
|
||||
}
|
||||
ScreenSessionManager::GetInstance().SetImmersiveState(false);
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -2232,6 +2232,12 @@ sptr<CutoutInfo> ScreenSessionManager::GetCutoutInfo(DisplayId displayId)
|
||||
return screenCutoutController_ ? screenCutoutController_->GetScreenCutoutInfo(displayId) : nullptr;
|
||||
}
|
||||
|
||||
DMError ScreenSessionManager::HasImmersiveWindow(bool& immersive)
|
||||
{
|
||||
immersive = isImmersive_;
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
void ScreenSessionManager::SetDisplayBoundary(const sptr<ScreenSession> screenSession)
|
||||
{
|
||||
if (screenSession && screenCutoutController_) {
|
||||
@ -2422,4 +2428,10 @@ void ScreenSessionManager::NotifyDisplayModeChanged(FoldDisplayMode displayMode)
|
||||
agent->NotifyDisplayModeChanged(displayMode);
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSessionManager::SetImmersiveState(bool immersive)
|
||||
{
|
||||
isImmersive_ = immersive;
|
||||
}
|
||||
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -1247,6 +1247,33 @@ sptr<CutoutInfo> ScreenSessionManagerProxy::GetCutoutInfo(DisplayId displayId)
|
||||
sptr<CutoutInfo> info = reply.ReadParcelable<CutoutInfo>();
|
||||
return info;
|
||||
}
|
||||
|
||||
DMError ScreenSessionManagerProxy::HasImmersiveWindow(bool& immersive)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("remote is nullptr");
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
|
||||
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_HAS_IMMERSIVE_WINDOW),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("SendRequest failed");
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
DMError ret = static_cast<DMError>(reply.ReadInt32());
|
||||
immersive = reply.ReadBool();
|
||||
return ret;
|
||||
}
|
||||
|
||||
DMError OHOS::Rosen::ScreenSessionManagerProxy::HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
|
@ -374,6 +374,13 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
||||
reply.WriteBool(hasPrivateWindow);
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_HAS_IMMERSIVE_WINDOW: {
|
||||
bool immersive = false;
|
||||
DMError ret = HasImmersiveWindow(immersive);
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
reply.WriteBool(immersive);
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_DUMP_ALL_SCREEN: {
|
||||
std::string dumpInfo;
|
||||
DumpAllScreensInfo(dumpInfo);
|
||||
|
Loading…
Reference in New Issue
Block a user