!10730 相机折叠模式

Merge pull request !10730 from 金童/camera1112
This commit is contained in:
openharmony_ci 2024-11-18 08:17:33 +00:00 committed by Gitee
commit 722822d0ba
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
13 changed files with 164 additions and 40 deletions

View File

@ -138,6 +138,7 @@ enum class DisplayManagerMessage : unsigned int {
TRANS_ID_GET_DISPLAY_CAPTURE, TRANS_ID_GET_DISPLAY_CAPTURE,
TRANS_ID_GET_PRIMARY_DISPLAY_INFO, TRANS_ID_GET_PRIMARY_DISPLAY_INFO,
TRANS_ID_GET_DISPLAY_SNAPSHOT_WITH_OPTION, TRANS_ID_GET_DISPLAY_SNAPSHOT_WITH_OPTION,
TRANS_ID_SET_CAMERA_STATUS,
}; };
} }
#endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_CODE_H #endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_CODE_H

View File

@ -41,6 +41,7 @@ const std::string ON_SCREEN_EXTEND_CHANGE = "screenExtendChange";
const std::string ON_HOVER_STATUS_CHANGE_CALLBACK = "hoverStatusChange"; const std::string ON_HOVER_STATUS_CHANGE_CALLBACK = "hoverStatusChange";
const std::string ON_SCREEN_CAPTURE_NOTIFY = "screenCaptureNotify"; const std::string ON_SCREEN_CAPTURE_NOTIFY = "screenCaptureNotify";
const std::string ON_SUPER_FOLD_STATUS_CHANGE_CALLBACK = "superFoldStatusChange"; const std::string ON_SUPER_FOLD_STATUS_CHANGE_CALLBACK = "superFoldStatusChange";
const std::string ON_CAMERA_FOLD_STATUS_CHANGE_CALLBACK = "cameraStatusChange";
constexpr size_t ARGC_ONE = 1; constexpr size_t ARGC_ONE = 1;
} // namespace } // namespace

View File

@ -92,12 +92,12 @@ napi_value JsScreenSessionManager::Init(napi_env env, napi_value exportObj)
JsScreenSessionManager::SetScreenOffDelayTime); JsScreenSessionManager::SetScreenOffDelayTime);
BindNativeFunction(env, exportObj, "notifyFoldToExpandCompletion", moduleName, BindNativeFunction(env, exportObj, "notifyFoldToExpandCompletion", moduleName,
JsScreenSessionManager::NotifyFoldToExpandCompletion); JsScreenSessionManager::NotifyFoldToExpandCompletion);
BindNativeFunction(env, exportObj, "getFoldStatus", moduleName, BindNativeFunction(env, exportObj, "getFoldStatus", moduleName, JsScreenSessionManager::GetFoldStatus);
JsScreenSessionManager::GetFoldStatus);
BindNativeFunction(env, exportObj, "getScreenSnapshot", moduleName, BindNativeFunction(env, exportObj, "getScreenSnapshot", moduleName,
JsScreenSessionManager::GetScreenSnapshot); JsScreenSessionManager::GetScreenSnapshot);
BindNativeFunction(env, exportObj, "getDeviceScreenConfig", moduleName, BindNativeFunction(env, exportObj, "getDeviceScreenConfig", moduleName,
JsScreenSessionManager::GetDeviceScreenConfig); JsScreenSessionManager::GetDeviceScreenConfig);
BindNativeFunction(env, exportObj, "setCameraStatus", moduleName, JsScreenSessionManager::SetCameraStatus);
return NapiGetUndefined(env); return NapiGetUndefined(env);
} }
@ -247,6 +247,13 @@ void JsScreenSessionManager::OnScreenConnected(const sptr<ScreenSession>& screen
} }
} }
napi_value JsScreenSessionManager::SetCameraStatus(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::DMS, "[NAPI]SetCameraStatus");
JsScreenSessionManager* me = CheckParamsAndGetThis<JsScreenSessionManager>(env, info);
return (me != nullptr) ? me->OnSetCameraStatus(env, info) : nullptr;
}
void JsScreenSessionManager::OnScreenDisconnected(const sptr<ScreenSession>& screenSession) void JsScreenSessionManager::OnScreenDisconnected(const sptr<ScreenSession>& screenSession)
{ {
if (screenConnectionCallback_ == nullptr) { if (screenConnectionCallback_ == nullptr) {
@ -677,4 +684,41 @@ napi_value JsScreenSessionManager::OnGetDeviceScreenConfig(napi_env env, const n
} }
return jsDeviceScreenConfigObj; return jsDeviceScreenConfigObj;
} }
napi_value JsScreenSessionManager::OnSetCameraStatus(napi_env env, const napi_callback_info info)
{
WLOGFD("[NAPI]OnSetCameraStatus");
size_t argc = 2;
napi_handle_scope scope = nullptr;
napi_open_handle_scope(env, &scope);
napi_value argv[2] = {nullptr, nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc < 2) { // 2: params num
TLOGE(WmsLogTag::DMS, "[NAPI]Argc is invalid: %{public}zu", argc);
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
napi_close_handle_scope(env, scope);
return NapiGetUndefined(env);
}
int32_t cameraStatus;
int32_t cameraPosition;
if (!ConvertFromJsValue(env, argv[0], cameraStatus)) {
TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to cameraStatus");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
napi_close_handle_scope(env, scope);
return NapiGetUndefined(env);
}
if (!ConvertFromJsValue(env, argv[1], cameraPosition)) {
TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to cameraPosition");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
napi_close_handle_scope(env, scope);
return NapiGetUndefined(env);
}
ScreenSessionManagerClient::GetInstance().SetCameraStatus(cameraStatus, cameraPosition);
napi_close_handle_scope(env, scope);
return NapiGetUndefined(env);
}
} // namespace OHOS::Rosen } // namespace OHOS::Rosen

View File

@ -51,6 +51,7 @@ private:
static napi_value UpdateAvailableArea(napi_env env, napi_callback_info info); static napi_value UpdateAvailableArea(napi_env env, napi_callback_info info);
static napi_value SetScreenOffDelayTime(napi_env env, napi_callback_info info); static napi_value SetScreenOffDelayTime(napi_env env, napi_callback_info info);
static napi_value NotifyFoldToExpandCompletion(napi_env env, napi_callback_info info); static napi_value NotifyFoldToExpandCompletion(napi_env env, napi_callback_info info);
static napi_value SetCameraStatus(napi_env env, napi_callback_info info);
static napi_value GetFoldStatus(napi_env env, napi_callback_info info); static napi_value GetFoldStatus(napi_env env, napi_callback_info info);
static napi_value GetScreenSnapshot(napi_env env, napi_callback_info info); static napi_value GetScreenSnapshot(napi_env env, napi_callback_info info);
static napi_value GetDeviceScreenConfig(napi_env env, napi_callback_info info); static napi_value GetDeviceScreenConfig(napi_env env, napi_callback_info info);
@ -64,6 +65,7 @@ private:
napi_value OnNotifyScreenLockEvent(napi_env env, const napi_callback_info info); napi_value OnNotifyScreenLockEvent(napi_env env, const napi_callback_info info);
napi_value OnUpdateAvailableArea(napi_env env, const napi_callback_info info); napi_value OnUpdateAvailableArea(napi_env env, const napi_callback_info info);
napi_value OnSetScreenOffDelayTime(napi_env env, const napi_callback_info info); napi_value OnSetScreenOffDelayTime(napi_env env, const napi_callback_info info);
napi_value OnSetCameraStatus(napi_env env, napi_callback_info info);
napi_value OnNotifyFoldToExpandCompletion(napi_env env, const napi_callback_info info); napi_value OnNotifyFoldToExpandCompletion(napi_env env, const napi_callback_info info);
napi_value OnGetFoldStatus(napi_env env, const napi_callback_info info); napi_value OnGetFoldStatus(napi_env env, const napi_callback_info info);
napi_value OnGetScreenSnapshot(napi_env env, const napi_callback_info info); napi_value OnGetScreenSnapshot(napi_env env, const napi_callback_info info);

View File

@ -65,10 +65,10 @@ private:
FoldStatus GetNextFoldState(float angle, int hall); FoldStatus GetNextFoldState(float angle, int hall);
void UpdateSwitchScreenBoundaryForLargeFoldDevice(float, int); void UpdateSwitchScreenBoundaryForLargeFoldDevice(float, int);
void SetCameraFoldStrategy(float angle); void SetCameraFoldStrategy(float angle);
void SetCameraStatusChange(float angle, int hall); void SetCameraRotationStatusChange(float angle, int hall);
sptr<ApplicationStatePocketObserver> applicationStateObserver_; sptr<ApplicationStatePocketObserver> applicationStateObserver_;
bool isInCameraFoldStrategy_ = false; bool isInCameraFoldStrategy_ = false;
bool isCameraStatus_ = false; bool isCameraRotationStrategy_ = false;
std::vector<std::string> hallSwitchPackageNameList_; std::vector<std::string> hallSwitchPackageNameList_;
int allowUserSensorForLargeFoldDevice = 0; int allowUserSensorForLargeFoldDevice = 0;
bool TriggerTentExit(float angle, int hall); bool TriggerTentExit(float angle, int hall);

View File

@ -284,7 +284,10 @@ public:
DMError GetAvailableArea(DisplayId displayId, DMRect& area) override; DMError GetAvailableArea(DisplayId displayId, DMRect& area) override;
void NotifyAvailableAreaChanged(DMRect area); void NotifyAvailableAreaChanged(DMRect area);
void NotifyFoldToExpandCompletion(bool foldToExpand) override; void NotifyFoldToExpandCompletion(bool foldToExpand) override;
void SetCameraStatus(int32_t cameraStatus, int32_t cameraPosition) override;
bool GetSnapshotArea(Media::Rect &rect, DmErrorCode* errorCode, ScreenId &screenId); bool GetSnapshotArea(Media::Rect &rect, DmErrorCode* errorCode, ScreenId &screenId);
int32_t GetCameraStatus();
int32_t GetCameraPosition();
VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId) override; VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId) override;
DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) override; DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) override;
@ -516,6 +519,8 @@ private:
std::atomic<bool> isScreenLockSuspend_ = false; std::atomic<bool> isScreenLockSuspend_ = false;
std::atomic<bool> gotScreenlockFingerprint_ = false; std::atomic<bool> gotScreenlockFingerprint_ = false;
std::atomic<bool> isPhyScreenConnected_ = false; std::atomic<bool> isPhyScreenConnected_ = false;
int32_t cameraStatus_ = {0};
int32_t cameraPosition_ = {0};
// Fold Screen // Fold Screen
std::map<ScreenId, ScreenProperty> phyScreenPropMap_; std::map<ScreenId, ScreenProperty> phyScreenPropMap_;

View File

@ -167,6 +167,7 @@ public:
virtual void UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation) {} virtual void UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation) {}
virtual void UpdateAvailableArea(ScreenId screenId, DMRect area) {} virtual void UpdateAvailableArea(ScreenId screenId, DMRect area) {}
virtual int32_t SetScreenOffDelayTime(int32_t delay) { return 0; } virtual int32_t SetScreenOffDelayTime(int32_t delay) { return 0; }
virtual void SetCameraStatus(int32_t cameraStatus, int32_t cameraPosition) {}
virtual uint32_t GetCurvedCompressionArea() { return 0; } virtual uint32_t GetCurvedCompressionArea() { return 0; }
virtual ScreenProperty GetPhyScreenProperty(ScreenId screenId) { return ScreenProperty(); } virtual ScreenProperty GetPhyScreenProperty(ScreenId screenId) { return ScreenProperty(); }
virtual void NotifyDisplayChangeInfoChanged(const sptr<DisplayChangeInfo>& info) {} virtual void NotifyDisplayChangeInfoChanged(const sptr<DisplayChangeInfo>& info) {}

View File

@ -148,6 +148,8 @@ public:
sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion() override; sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion() override;
void SetCameraStatus(int32_t cameraStatus, int32_t cameraPosition) override;
// unique screen // unique screen
DMError MakeUniqueScreen(const std::vector<ScreenId>& screenIds) override; DMError MakeUniqueScreen(const std::vector<ScreenId>& screenIds) override;

View File

@ -25,6 +25,7 @@
#include "window_manager_hilog.h" #include "window_manager_hilog.h"
#include "app_mgr_client.h" #include "app_mgr_client.h"
#include "screen_session_manager/include/screen_rotation_property.h" #include "screen_session_manager/include/screen_rotation_property.h"
#include "screen_session_manager.h"
#ifdef POWER_MANAGER_ENABLE #ifdef POWER_MANAGER_ENABLE
#include <power_mgr_client.h> #include <power_mgr_client.h>
@ -34,7 +35,6 @@ namespace OHOS::Rosen {
using OHOS::AppExecFwk::AppStateData; using OHOS::AppExecFwk::AppStateData;
using OHOS::AppExecFwk::ApplicationState; using OHOS::AppExecFwk::ApplicationState;
namespace { namespace {
const std::string CAMERA_NAME = "camera";
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "SingleDisplaySensorPocketFoldStateManager"}; constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "SingleDisplaySensorPocketFoldStateManager"};
constexpr float ANGLE_MIN_VAL = 0.0F; constexpr float ANGLE_MIN_VAL = 0.0F;
constexpr float ALTA_HALF_FOLDED_MAX_THRESHOLD = 140.0F; constexpr float ALTA_HALF_FOLDED_MAX_THRESHOLD = 140.0F;
@ -51,6 +51,8 @@ constexpr float TENT_MODE_EXIT_MIN_THRESHOLD = 5.0F;
constexpr float TENT_MODE_EXIT_MAX_THRESHOLD = 175.0F; constexpr float TENT_MODE_EXIT_MAX_THRESHOLD = 175.0F;
constexpr float HOVER_STATUS_EXIT_MIN_THRESHOLD = 5.0F; constexpr float HOVER_STATUS_EXIT_MIN_THRESHOLD = 5.0F;
constexpr float HOVER_STATUS_EXIT_MAX_THRESHOLD = 175.0F; constexpr float HOVER_STATUS_EXIT_MAX_THRESHOLD = 175.0F;
constexpr int32_t CAMERA_STATUS_UNAVAILABLE = 3;
constexpr int32_t CAMERA_POSITION_FRONT = 2;
} // namespace } // namespace
SingleDisplaySensorPocketFoldStateManager::SingleDisplaySensorPocketFoldStateManager() SingleDisplaySensorPocketFoldStateManager::SingleDisplaySensorPocketFoldStateManager()
@ -68,10 +70,10 @@ void SingleDisplaySensorPocketFoldStateManager::HandleAngleChange(float angle, i
SetCameraFoldStrategy(angle); SetCameraFoldStrategy(angle);
if (isInCameraFoldStrategy_) { if (isInCameraFoldStrategy_) {
HandleSensorChange(FoldStatus::FOLDED, angle, foldScreenPolicy); HandleSensorChange(FoldStatus::FOLDED, angle, foldScreenPolicy);
SetCameraStatusChange(angle, hall); SetCameraRotationStatusChange(angle, hall);
return; return;
} }
SetCameraStatusChange(angle, hall); SetCameraRotationStatusChange(angle, hall);
if (IsTentMode()) { if (IsTentMode()) {
return TentModeHandleSensorChange(angle, hall, foldScreenPolicy); return TentModeHandleSensorChange(angle, hall, foldScreenPolicy);
} }
@ -85,10 +87,10 @@ void SingleDisplaySensorPocketFoldStateManager::HandleHallChange(float angle, in
SetCameraFoldStrategy(angle); SetCameraFoldStrategy(angle);
if (isInCameraFoldStrategy_) { if (isInCameraFoldStrategy_) {
HandleSensorChange(FoldStatus::FOLDED, angle, foldScreenPolicy); HandleSensorChange(FoldStatus::FOLDED, angle, foldScreenPolicy);
SetCameraStatusChange(angle, hall); SetCameraRotationStatusChange(angle, hall);
return; return;
} }
SetCameraStatusChange(angle, hall); SetCameraRotationStatusChange(angle, hall);
if (IsTentMode()) { if (IsTentMode()) {
return TentModeHandleSensorChange(angle, hall, foldScreenPolicy); return TentModeHandleSensorChange(angle, hall, foldScreenPolicy);
} }
@ -108,66 +110,70 @@ void SingleDisplaySensorPocketFoldStateManager::UpdateSwitchScreenBoundaryForLar
void SingleDisplaySensorPocketFoldStateManager::SetCameraFoldStrategy(float angle) void SingleDisplaySensorPocketFoldStateManager::SetCameraFoldStrategy(float angle)
{ {
FoldStatus currentState = GetCurrentState(); FoldStatus currentState = GetCurrentState();
int32_t cameraStatus = ScreenSessionManager::GetInstance().GetCameraStatus();
int32_t cameraPosition = ScreenSessionManager::GetInstance().GetCameraPosition();
if (angle >= CAMERA_MAX_VAL) { if (angle >= CAMERA_MAX_VAL) {
if (isInCameraFoldStrategy_ != false) { if (isInCameraFoldStrategy_ != false) {
isInCameraFoldStrategy_ = false; isInCameraFoldStrategy_ = false;
TLOGI(WmsLogTag::DMS, "Disable CameraFoldStrategy."); TLOGI(WmsLogTag::DMS, "Disable CameraFoldStrategy, angle: %{public}f, currentFoldState: %{public}d, "
"cameraStatus: %{public}d, cameraPosition: %{public}d. ",
angle, currentState, cameraStatus, cameraPosition);
} }
return; return;
} }
if (applicationStateObserver_ == nullptr) { if ((cameraStatus == CAMERA_STATUS_UNAVAILABLE) && (cameraPosition == CAMERA_POSITION_FRONT) &&
return; (currentState == FoldStatus::FOLDED)) {
}
if (applicationStateObserver_->GetForegroundApp().empty()) {
return;
}
if (applicationStateObserver_->GetForegroundApp().find(CAMERA_NAME) != std::string::npos &&
currentState == FoldStatus::FOLDED) {
if (isInCameraFoldStrategy_ != true) { if (isInCameraFoldStrategy_ != true) {
isInCameraFoldStrategy_ = true; isInCameraFoldStrategy_ = true;
TLOGI(WmsLogTag::DMS, "Enable CameraFoldStrategy."); TLOGI(WmsLogTag::DMS, "Enable CameraFoldStrategy, angle: %{public}f, currentFoldState: %{public}d, "
"cameraStatus: %{public}d, cameraPosition: %{public}d. ",
angle, currentState, cameraStatus, cameraPosition);
} }
} }
} }
void SingleDisplaySensorPocketFoldStateManager::SetCameraStatusChange(float angle, int hall) void SingleDisplaySensorPocketFoldStateManager::SetCameraRotationStatusChange(float angle, int hall)
{ {
FoldStatus currentState = GetCurrentState();
int32_t cameraStatus = ScreenSessionManager::GetInstance().GetCameraStatus();
int32_t cameraPosition = ScreenSessionManager::GetInstance().GetCameraPosition();
if (hall == HALL_FOLDED_THRESHOLD) { if (hall == HALL_FOLDED_THRESHOLD) {
if (isCameraStatus_) { if (isCameraRotationStrategy_) {
TLOGI(WmsLogTag::DMS, "hall is %{public}d, exit cemera status", hall); TLOGI(WmsLogTag::DMS, "hall is %{public}d, exit cemera status", hall);
ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus::CAMERA_STATUS_CANCEL); ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus::CAMERA_STATUS_CANCEL);
isCameraStatus_ = false; isCameraRotationStrategy_ = false;
} }
return; return;
} }
if ((std::isless(angle, HOVER_STATUS_EXIT_MIN_THRESHOLD)) || if ((std::isless(angle, HOVER_STATUS_EXIT_MIN_THRESHOLD)) ||
(std::isgreater(angle, HOVER_STATUS_EXIT_MAX_THRESHOLD))) { (std::isgreater(angle, HOVER_STATUS_EXIT_MAX_THRESHOLD))) {
if (isCameraStatus_) { if (isCameraRotationStrategy_) {
TLOGI(WmsLogTag::DMS, "angle is:%{public}f, exit camera status", angle); TLOGI(WmsLogTag::DMS, "angle is:%{public}f, exit camera status", angle);
ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus::CAMERA_STATUS_CANCEL); ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus::CAMERA_STATUS_CANCEL);
isCameraStatus_ = false; isCameraRotationStrategy_ = false;
} }
return; return;
} }
if (applicationStateObserver_ == nullptr) { if ((angle > ANGLE_MIN_VAL) && (cameraStatus == CAMERA_STATUS_UNAVAILABLE) &&
return; (cameraPosition == CAMERA_POSITION_FRONT) && (currentState == FoldStatus::FOLDED)) {
} if (!isCameraRotationStrategy_) {
TLOGI(WmsLogTag::DMS, "angle is:%{public}f , currentFoldState is:%{public}d, "
if ((angle > ANGLE_MIN_VAL) && (angle < CAMERA_MAX_VAL) && "cameraStatus is:%{public}d, cameraPosition is:%{public}d, enter camera rotation status.",
(applicationStateObserver_->GetForegroundApp().find(CAMERA_NAME) != std::string::npos)) { angle, static_cast<int32_t>(currentState), cameraStatus, cameraPosition);
if (!isCameraStatus_) {
TLOGI(WmsLogTag::DMS, "angle is:%{public}f and is camera app, into camera status", angle);
ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus::CAMERA_STATUS); ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus::CAMERA_STATUS);
isCameraStatus_ = true; isCameraRotationStrategy_ = true;
} }
} else { } else {
if (isCameraStatus_) { if (isCameraRotationStrategy_) {
TLOGI(WmsLogTag::DMS, "angle is:%{public}f or is not camera app, exit camera status", angle); TLOGI(WmsLogTag::DMS, "angle is:%{public}f , currentFoldState is:%{public}d, "
"cameraStatus is:%{public}d, cameraPosition is:%{public}d, exit camera rotation status.",
angle, static_cast<int32_t>(currentState), cameraStatus, cameraPosition);
ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus::CAMERA_STATUS_CANCEL); ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus::CAMERA_STATUS_CANCEL);
isCameraStatus_ = false; isCameraRotationStrategy_ = false;
} }
} }
} }

View File

@ -2087,6 +2087,17 @@ int32_t ScreenSessionManager::SetScreenOffDelayTime(int32_t delay)
return screenOffDelay_; return screenOffDelay_;
} }
void ScreenSessionManager::SetCameraStatus(int32_t cameraStatus, int32_t cameraPosition)
{
if ((cameraStatus_ == cameraStatus) && (cameraPosition_ = cameraPosition)) {
return; // no need to update
}
cameraStatus_ = cameraStatus;
cameraPosition_ = cameraPosition;
TLOGI(WmsLogTag::DMS, "SetCameraStatus, cameraStatus:%{public}d, cameraPosition:%{public}d",
cameraStatus, cameraPosition);
}
bool ScreenSessionManager::IsScreenLockSuspend(void) bool ScreenSessionManager::IsScreenLockSuspend(void)
{ {
return isScreenLockSuspend_; return isScreenLockSuspend_;
@ -6482,4 +6493,14 @@ void ScreenSessionManager::OnSuperFoldStatusChange(ScreenId screenId, SuperFoldS
} }
clientProxy_->OnSuperFoldStatusChanged(screenId, superFoldStatus); clientProxy_->OnSuperFoldStatusChanged(screenId, superFoldStatus);
} }
int32_t ScreenSessionManager::GetCameraStatus()
{
return cameraStatus_;
}
int32_t ScreenSessionManager::GetCameraPosition()
{
return cameraPosition_;
}
} // namespace OHOS::Rosen } // namespace OHOS::Rosen

View File

@ -2793,6 +2793,37 @@ int32_t ScreenSessionManagerProxy::SetScreenOffDelayTime(int32_t delay)
return reply.ReadInt32(); return reply.ReadInt32();
} }
void ScreenSessionManagerProxy::SetCameraStatus(int32_t cameraStatus, int32_t cameraPosition)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("SetCameraStatus: remote is null");
return;
}
MessageOption option(MessageOption::TF_SYNC);
MessageParcel reply;
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return;
}
if (!data.WriteInt32(cameraStatus)) {
WLOGFE("Write cameraStatus failed");
return;
}
if (!data.WriteInt32(cameraPosition)) {
WLOGFE("Write cameraPosition failed");
return;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_CAMERA_STATUS),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
return;
}
}
DMError ScreenSessionManagerProxy::GetAvailableArea(DisplayId displayId, DMRect& area) DMError ScreenSessionManagerProxy::GetAvailableArea(DisplayId displayId, DMRect& area)
{ {
sptr<IRemoteObject> remote = Remote(); sptr<IRemoteObject> remote = Remote();

View File

@ -67,6 +67,7 @@ public:
void OnUpdateFoldDisplayMode(FoldDisplayMode displayMode) override; void OnUpdateFoldDisplayMode(FoldDisplayMode displayMode) override;
void UpdateAvailableArea(ScreenId screenId, DMRect area); void UpdateAvailableArea(ScreenId screenId, DMRect area);
int32_t SetScreenOffDelayTime(int32_t delay); int32_t SetScreenOffDelayTime(int32_t delay);
void SetCameraStatus(int32_t cameraStatus, int32_t cameraPosition);
void NotifyFoldToExpandCompletion(bool foldToExpand); void NotifyFoldToExpandCompletion(bool foldToExpand);
FoldStatus GetFoldStatus(); FoldStatus GetFoldStatus();
std::shared_ptr<Media::PixelMap> GetScreenSnapshot(ScreenId screenId, float scaleX, float scaleY); std::shared_ptr<Media::PixelMap> GetScreenSnapshot(ScreenId screenId, float scaleX, float scaleY);

View File

@ -418,6 +418,15 @@ int32_t ScreenSessionManagerClient::SetScreenOffDelayTime(int32_t delay)
return screenSessionManager_->SetScreenOffDelayTime(delay); return screenSessionManager_->SetScreenOffDelayTime(delay);
} }
void ScreenSessionManagerClient::SetCameraStatus(int32_t cameraStatus, int32_t cameraPosition)
{
if (!screenSessionManager_) {
WLOGFE("screenSessionManager_ is null");
return;
}
return screenSessionManager_->SetCameraStatus(cameraStatus, cameraPosition);
}
void ScreenSessionManagerClient::NotifyFoldToExpandCompletion(bool foldToExpand) void ScreenSessionManagerClient::NotifyFoldToExpandCompletion(bool foldToExpand)
{ {
if (!screenSessionManager_) { if (!screenSessionManager_) {