SetFoldStatusLocked

Signed-off-by: w30054506 <wangqingjie5@huawei.com>
This commit is contained in:
w30054506 2023-12-18 09:46:04 +08:00
parent 65df1ae659
commit 6422c8707e
12 changed files with 69 additions and 14 deletions

View File

@ -86,6 +86,8 @@ public:
virtual void SetFoldDisplayMode(const FoldDisplayMode);
virtual void SetFoldStatusLocked(bool locked);
virtual sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion();
private:
static inline SingletonDelegator<DisplayManagerAdapter> delegator;

View File

@ -55,6 +55,8 @@ public:
void SetFoldDisplayMode(const FoldDisplayMode);
void SetFoldStatusLocked(bool locked);
sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion();
DMError RegisterDisplayListener(sptr<IDisplayListener> listener);
@ -649,6 +651,16 @@ void DisplayManager::Impl::SetFoldDisplayMode(const FoldDisplayMode mode)
SingletonContainer::Get<DisplayManagerAdapter>().SetFoldDisplayMode(mode);
}
void DisplayManager::SetFoldStatusLocked(bool locked)
{
pImpl_->SetFoldStatusLocked(locked);
}
void DisplayManager::Impl::SetFoldStatusLocked(bool locked)
{
SingletonContainer::Get<DisplayManagerAdapter>().SetFoldStatusLocked(locked);
}
sptr<FoldCreaseRegion> DisplayManager::GetCurrentFoldCreaseRegion()
{
return pImpl_->GetCurrentFoldCreaseRegion();

View File

@ -552,6 +552,13 @@ void DisplayManagerAdapter::SetFoldDisplayMode(const FoldDisplayMode mode)
return displayManagerServiceProxy_->SetFoldDisplayMode(mode);
}
void DisplayManagerAdapter::SetFoldStatusLocked(bool locked)
{
INIT_PROXY_CHECK_RETURN();
return displayManagerServiceProxy_->SetFoldStatusLocked(locked);
}
sptr<FoldCreaseRegion> DisplayManagerAdapter::GetCurrentFoldCreaseRegion()
{
INIT_PROXY_CHECK_RETURN(nullptr);

View File

@ -223,7 +223,7 @@ public:
virtual void SetFoldDisplayMode(const FoldDisplayMode) {}
virtual void LockFoldDisplayStatus(bool locked) {}
virtual void SetFoldStatusLocked(bool locked) {}
virtual sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion() { return nullptr; }

View File

@ -460,6 +460,13 @@ public:
*/
void SetFoldDisplayMode(const FoldDisplayMode mode);
/**
* @brief Locked fold status.
*
* @param mode locked fold status is locked.
*/
void SetFoldStatusLocked(bool locked);
/**
* @brief Get the fold crease region in the current display mode.
*

View File

@ -115,6 +115,12 @@ static napi_value SetFoldDisplayMode(napi_env env, napi_callback_info info)
return (me != nullptr) ? me->OnSetFoldDisplayMode(env, info) : nullptr;
}
static napi_value SetFoldStatusLocked(napi_env env, napi_callback_info info)
{
auto* me = CheckParamsAndGetThis<JsDisplayManager>(env, info);
return (me != nullptr) ? me->OnSetFoldStatusLocked(env, info) : nullptr;
}
static napi_value GetCurrentFoldCreaseRegion(napi_env env, napi_callback_info info)
{
auto* me = CheckParamsAndGetThis<JsDisplayManager>(env, info);
@ -571,6 +577,26 @@ napi_value OnSetFoldDisplayMode(napi_env env, napi_callback_info info)
return NapiGetUndefined(env);
}
napi_value OnSetFoldStatusLocked(napi_env env, napi_callback_info info)
{
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc < ARGC_ONE) {
napi_throw(env, CreateJsError(env, static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_PARAM)));
return NapiGetUndefined(env);
}
bool locked = false;
if (!ConvertFromJsValue(env, argv[0], locked)) {
WLOGFE("[NAPI]Failed to convert parameter to SetFoldStatusLocked");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_PARAM)));
return NapiGetUndefined(env);
}
SingletonContainer::Get<DisplayManager>().SetFoldStatusLocked(locked);
WLOGI("[NAPI]" PRIu64", SetFoldStatusLocked");
return NapiGetUndefined(env);
}
napi_value OnGetCurrentFoldCreaseRegion(napi_env env, napi_callback_info info)
{
size_t argc = 4;
@ -922,6 +948,7 @@ napi_value JsDisplayManagerInit(napi_env env, napi_value exportObj)
BindNativeFunction(env, exportObj, "getFoldStatus", moduleName, JsDisplayManager::GetFoldStatus);
BindNativeFunction(env, exportObj, "getFoldDisplayMode", moduleName, JsDisplayManager::GetFoldDisplayMode);
BindNativeFunction(env, exportObj, "setFoldDisplayMode", moduleName, JsDisplayManager::SetFoldDisplayMode);
BindNativeFunction(env, exportObj, "setFoldStatusLocked", moduleName, JsDisplayManager::SetFoldStatusLocked);
BindNativeFunction(env, exportObj, "getCurrentFoldCreaseRegion", moduleName,
JsDisplayManager::GetCurrentFoldCreaseRegion);
BindNativeFunction(env, exportObj, "on", moduleName, JsDisplayManager::RegisterDisplayManagerCallback);

View File

@ -177,7 +177,7 @@ public:
//Fold Screen
void SetFoldDisplayMode(const FoldDisplayMode displayMode) override;
void LockFoldDisplayStatus(bool locked) override;
void SetFoldStatusLocked(bool locked) override;
FoldDisplayMode GetFoldDisplayMode() override;
@ -247,7 +247,7 @@ private:
int DumpSpecifiedScreenInfo(ScreenId screenId, std::string& dumpInfo);
bool IsValidDigitString(const std::string& idStr) const;
int SetFoldDisplayMode(const std::string& modeParam);
int LockFoldDisplayStatus(const std::string& lockParam);
int SetFoldStatusLocked(const std::string& lockParam);
class ScreenIdManager {
friend class ScreenSessionGroup;

View File

@ -111,7 +111,7 @@ public:
// Fold Screen
void SetFoldDisplayMode(const FoldDisplayMode displayMode) override {}
void LockFoldDisplayStatus(bool locked) override {}
void SetFoldStatusLocked(bool locked) override {}
FoldDisplayMode GetFoldDisplayMode() override { return FoldDisplayMode::UNKNOWN; }

View File

@ -116,7 +116,7 @@ public:
//Fold Screen
void SetFoldDisplayMode(const FoldDisplayMode displayMode) override;
void LockFoldDisplayStatus(bool locked) override;
void SetFoldStatusLocked(bool locked) override;
FoldDisplayMode GetFoldDisplayMode() override;

View File

@ -2738,14 +2738,14 @@ void ScreenSessionManager::SetFoldDisplayMode(const FoldDisplayMode displayMode)
foldScreenController_->SetDisplayMode(displayMode);
}
void ScreenSessionManager::LockFoldDisplayStatus(bool locked)
void ScreenSessionManager::SetFoldStatusLocked(bool locked)
{
if (foldScreenController_ == nullptr) {
WLOGFW("LockFoldDisplayStatus foldScreenController_ is null");
WLOGFW("SetFoldStatusLocked foldScreenController_ is null");
return;
}
if (!SessionPermission::IsSystemCalling()) {
WLOGFE("LockFoldDisplayStatus permission denied!");
WLOGFE("SetFoldStatusLocked permission denied!");
return;
}
foldScreenController_->LockDisplayStatus(locked);
@ -3020,7 +3020,7 @@ int ScreenSessionManager::Dump(int fd, const std::vector<std::u16string>& args)
}
} else if (params.size() == 1 && (params[0] == ARG_LOCK_FOLD_DISPLAY_STATUS
|| params[0] == ARG_UNLOCK_FOLD_DISPLAY_STATUS)) {
int errCode = LockFoldDisplayStatus(params[0]);
int errCode = SetFoldStatusLocked(params[0]);
if (errCode != 0) {
ShowIllegalArgsInfo(dumpInfo);
}
@ -3057,7 +3057,7 @@ int ScreenSessionManager::SetFoldDisplayMode(const std::string& modeParam)
return 0;
}
int ScreenSessionManager::LockFoldDisplayStatus(const std::string& lockParam)
int ScreenSessionManager::SetFoldStatusLocked(const std::string& lockParam)
{
if (lockParam.empty()) {
return -1;
@ -3068,10 +3068,10 @@ int ScreenSessionManager::LockFoldDisplayStatus(const std::string& lockParam)
} else if (lockParam == ARG_UNLOCK_FOLD_DISPLAY_STATUS) {
lockDisplayStatus = false;
} else {
WLOGFW("LockFoldDisplayStatus status not support");
WLOGFW("SetFoldStatusLocked status not support");
return -1;
}
LockFoldDisplayStatus(lockDisplayStatus);
SetFoldStatusLocked(lockDisplayStatus);
return 0;
}

View File

@ -1734,7 +1734,7 @@ void ScreenSessionManagerProxy::SetFoldDisplayMode(const FoldDisplayMode display
}
}
void ScreenSessionManagerProxy::LockFoldDisplayStatus(bool locked)
void ScreenSessionManagerProxy::SetFoldStatusLocked(bool locked)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {

View File

@ -509,7 +509,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
}
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_LOCK_FOLD_DISPLAY_STATUS: {
bool lockDisplayStatus = static_cast<bool>(data.ReadUint32());
LockFoldDisplayStatus(lockDisplayStatus);
SetFoldStatusLocked(lockDisplayStatus);
break;
}
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE: {