fix code check

Signed-off-by: qy <qiyi12@huawei.com>
This commit is contained in:
qy 2023-08-14 09:17:30 +08:00
parent c4d8971e32
commit 0c9351deb8
9 changed files with 114 additions and 52 deletions

View File

@ -22,15 +22,15 @@ namespace OHOS {
namespace Media {
class PixelMap : public Parcelable {
public:
int32_t GetWidth()
{
return 0;
}
int32_t GetWidth()
{
return 0;
}
int32_t GetHeight()
{
return 0;
}
int32_t GetHeight()
{
return 0;
}
};
}
}

View File

@ -34,7 +34,7 @@ static int deConstructorCnt = 0;
WindowImpl::WindowImpl(const sptr<WindowOption>& option)
{
if (option != nullptr) {
name_ = option->GetWindowName();
name_ = option->GetWindowName();
} else {
name_ = "main_window";
}
@ -178,7 +178,6 @@ bool WindowImpl::IsMainHandlerAvailable() const
SystemBarProperty WindowImpl::GetSystemBarPropertyByType(WindowType type) const
{
return SystemBarProperty();
}
@ -614,7 +613,7 @@ void WindowImpl::ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& p
{
if (uiContent_ == nullptr) {
WLOGFE("ConsumePointerEvent to uiContent failed,uiContent_ is null");
return;
return;
}
(void)uiContent_->ProcessPointerEvent(pointerEvent);
}
@ -785,7 +784,7 @@ void WindowImpl::SetViewportConfig(const Ace::ViewportConfig& config)
height_ = config.Height();
isUpdate = true;
}
if (abs(density_ - config.Density()) >= 0.000001) {
if (abs(density_ - config.Density()) >= 1e-6) {
density_ = config.Density();
isUpdate = true;
}
@ -795,7 +794,7 @@ void WindowImpl::SetViewportConfig(const Ace::ViewportConfig& config)
}
if (isUpdate) {
UpdateViewportConfig();
}
}
}
void WindowImpl::UpdateViewportConfig()
@ -808,7 +807,6 @@ void WindowImpl::UpdateViewportConfig()
if (uiContent_ != nullptr) {
uiContent_->UpdateViewportConfig(config, WindowSizeChangeReason::UNDEFINED);
}
}
void WindowImpl::SetOrientation(Orientation orientation)

View File

@ -26,16 +26,8 @@ namespace {
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "JsSceneUtils" };
}
bool ConvertSessionInfoFromJs(NativeEngine& engine, NativeObject* jsObject, SessionInfo& sessionInfo)
bool IsJsBundleNameUndefind(NativeEngine& engine, NativeValue* jsBundleName, SessionInfo& sessionInfo)
{
NativeValue* jsBundleName = jsObject->GetProperty("bundleName");
NativeValue* jsModuleName = jsObject->GetProperty("moduleName");
NativeValue* jsAbilityName = jsObject->GetProperty("abilityName");
NativeValue* jsIsSystem = jsObject->GetProperty("isSystem");
NativeValue* jsPersistentId = jsObject->GetProperty("persistentId");
NativeValue* jsCallState = jsObject->GetProperty("callState");
NativeValue* jsSessionType = jsObject->GetProperty("sessionType");
if (jsBundleName->TypeOf() != NATIVE_UNDEFINED) {
std::string bundleName;
if (!ConvertFromJsValue(engine, jsBundleName, bundleName)) {
@ -44,6 +36,11 @@ bool ConvertSessionInfoFromJs(NativeEngine& engine, NativeObject* jsObject, Sess
}
sessionInfo.bundleName_ = bundleName;
}
return true;
}
bool IsJsModuleNameUndefind(NativeEngine& engine, NativeValue* jsModuleName, SessionInfo& sessionInfo)
{
if (jsModuleName->TypeOf() != NATIVE_UNDEFINED) {
std::string moduleName;
if (!ConvertFromJsValue(engine, jsModuleName, moduleName)) {
@ -52,6 +49,11 @@ bool ConvertSessionInfoFromJs(NativeEngine& engine, NativeObject* jsObject, Sess
}
sessionInfo.moduleName_ = moduleName;
}
return true;
}
bool IsJsAbilityUndefind(NativeEngine& engine, NativeValue* jsAbilityName, SessionInfo& sessionInfo)
{
if (jsAbilityName->TypeOf() != NATIVE_UNDEFINED) {
std::string abilityName;
if (!ConvertFromJsValue(engine, jsAbilityName, abilityName)) {
@ -60,6 +62,11 @@ bool ConvertSessionInfoFromJs(NativeEngine& engine, NativeObject* jsObject, Sess
}
sessionInfo.abilityName_ = abilityName;
}
return true;
}
bool IsJsIsSystemUndefind(NativeEngine& engine, NativeValue* jsIsSystem, SessionInfo& sessionInfo)
{
if (jsIsSystem->TypeOf() != NATIVE_UNDEFINED) {
bool isSystem;
if (!ConvertFromJsValue(engine, jsIsSystem, isSystem)) {
@ -68,6 +75,11 @@ bool ConvertSessionInfoFromJs(NativeEngine& engine, NativeObject* jsObject, Sess
}
sessionInfo.isSystem_ = isSystem;
}
return true;
}
bool IsJsPersistentIdUndefind(NativeEngine& engine, NativeValue* jsPersistentId, SessionInfo& sessionInfo)
{
if (jsPersistentId->TypeOf() != NATIVE_UNDEFINED) {
int32_t persistentId;
if (!ConvertFromJsValue(engine, jsPersistentId, persistentId)) {
@ -76,6 +88,11 @@ bool ConvertSessionInfoFromJs(NativeEngine& engine, NativeObject* jsObject, Sess
}
sessionInfo.persistentId_ = persistentId;
}
return true;
}
bool IsJsCallStateUndefind(NativeEngine& engine, NativeValue* jsCallState, SessionInfo& sessionInfo)
{
if (jsCallState->TypeOf() != NATIVE_UNDEFINED) {
int32_t callState;
if (!ConvertFromJsValue(engine, jsCallState, callState)) {
@ -84,6 +101,11 @@ bool ConvertSessionInfoFromJs(NativeEngine& engine, NativeObject* jsObject, Sess
}
sessionInfo.callState_ = static_cast<uint32_t>(callState);
}
return true;
}
bool IsJsSessionTypeUndefind(NativeEngine& engine, NativeValue* jsSessionType, SessionInfo& sessionInfo)
{
if (jsSessionType->TypeOf() != NATIVE_UNDEFINED) {
uint32_t windowType = 0;
if (!ConvertFromJsValue(engine, jsSessionType, windowType)) {
@ -98,6 +120,40 @@ bool ConvertSessionInfoFromJs(NativeEngine& engine, NativeObject* jsObject, Sess
return true;
}
bool ConvertSessionInfoFromJs(NativeEngine& engine, NativeObject* jsObject, SessionInfo& sessionInfo)
{
NativeValue* jsBundleName = jsObject->GetProperty("bundleName");
NativeValue* jsModuleName = jsObject->GetProperty("moduleName");
NativeValue* jsAbilityName = jsObject->GetProperty("abilityName");
NativeValue* jsIsSystem = jsObject->GetProperty("isSystem");
NativeValue* jsPersistentId = jsObject->GetProperty("persistentId");
NativeValue* jsCallState = jsObject->GetProperty("callState");
NativeValue* jsSessionType = jsObject->GetProperty("sessionType");
if (!IsJsBundleNameUndefind(engine, jsBundleName, sessionInfo)) {
return false;
}
if (!IsJsModuleNameUndefind(engine, jsModuleName, sessionInfo)) {
return false;
}
if (!IsJsAbilityUndefind(engine, jsAbilityName, sessionInfo)) {
return false;
}
if (!IsJsIsSystemUndefind(engine, jsIsSystem, sessionInfo)) {
return false;
}
if (!IsJsPersistentIdUndefind(engine, jsPersistentId, sessionInfo)) {
return false;
}
if (!IsJsCallStateUndefind(engine, jsCallState, sessionInfo)) {
return false;
}
if (!IsJsSessionTypeUndefind(engine, jsSessionType, sessionInfo)) {
return false;
}
return true;
}
NativeValue* CreateJsSessionInfo(NativeEngine& engine, const SessionInfo& sessionInfo)
{
NativeValue* objValue = engine.CreateObject();

View File

@ -366,7 +366,8 @@ WSError Session::UpdateRect(const WSRect& rect, SizeChangeReason reason)
}
WSError Session::Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel,
const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig, sptr<WindowSessionProperty> property, sptr<IRemoteObject> token)
const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig,
sptr<WindowSessionProperty> property, sptr<IRemoteObject> token)
{
callingPid_ = IPCSkeleton::GetCallingPid();
callingUid_ = IPCSkeleton::GetCallingUid();
@ -374,7 +375,8 @@ WSError Session::Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWi
}
WSError Session::ConnectImpl(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel,
const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig, sptr<WindowSessionProperty> property, sptr<IRemoteObject> token)
const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig,
sptr<WindowSessionProperty> property, sptr<IRemoteObject> token)
{
WLOGFI("Connect session, id: %{public}d, state: %{public}u", GetPersistentId(),
static_cast<uint32_t>(GetSessionState()));
@ -874,7 +876,7 @@ WSError Session::TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>&
pointerAction == MMI::PointerEvent::POINTER_ACTION_PULL_IN_WINDOW ||
pointerAction == MMI::PointerEvent::POINTER_ACTION_PULL_OUT_WINDOW) {
WLOGFD("Action:%{public}s, eventId:%{public}d, report without timer",
pointerEvent->DumpPointerAction(), pointerEvent->GetId());
pointerEvent->DumpPointerAction(), pointerEvent->GetId());
} else {
DelayedSingleton<ANRManager>::GetInstance()->AddTimer(pointerEvent->GetId(), persistentId_);
}

View File

@ -63,7 +63,7 @@ public:
sptr<SupportedScreenModes> GetActiveScreenMode() const;
ScreenSourceMode GetSourceMode() const;
void SetScreenCombination(ScreenCombination combination);
ScreenCombination GetScreenCombination() const;
ScreenCombination GetScreenCombination() const;
Orientation GetOrientation() const;
void SetOrientation(Orientation orientation);

View File

@ -123,7 +123,8 @@ ScreenProperty ScreenSession::GetScreenProperty() const
return property_;
}
void ScreenSession::UpdatePropertyByActiveMode() {
void ScreenSession::UpdatePropertyByActiveMode()
{
sptr<SupportedScreenModes> mode = GetActiveScreenMode();
if (mode != nullptr) {
auto screeBounds = property_.GetBounds();

View File

@ -1432,7 +1432,8 @@ WSError SceneSessionManager::UpdateBrightness(int32_t persistentId)
WLOGFE("session is invalid");
return WSError::WS_ERROR_NULLPTR;
}
if (!(sceneSession->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW || sceneSession->GetSessionInfo().isSystem_)) {
if (!(sceneSession->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW ||
sceneSession->GetSessionInfo().isSystem_)) {
WLOGW("only app main window can set brightness");
return WSError::WS_DO_NOTHING;
}
@ -1756,6 +1757,28 @@ WSError SceneSessionManager::GetSessionDumpInfo(const std::vector<std::string>&
return WSError::WS_ERROR_INVALID_OPERATION;
}
void FocusIDChange(int32_t persistentId, sptr<SceneSession>& sceneSession)
{
// notify RS
WLOGFD("current focus session: windowId: %{public}d, windowName: %{public}s, bundleName: %{public}s,"
" abilityName: %{public}s, pid: %{public}d, uid: %{public}d", persistentId,
sceneSession->GetWindowSessionProperty()->GetWindowName().c_str(),
sceneSession->GetSessionInfo().bundleName_.c_str(),
sceneSession->GetSessionInfo().abilityName_.c_str(),
sceneSession->GetCallingPid(), sceneSession->GetCallingUid());
uint64_t focusNodeId = 0; // 0 means invalid
if (sceneSession->GetSurfaceNode() == nullptr) {
WLOGFW("focused window surfaceNode is null");
} else {
focusNodeId = sceneSession->GetSurfaceNode()->GetId();
}
FocusAppInfo appInfo = {
sceneSession->GetCallingPid(), sceneSession->GetCallingUid(),
sceneSession->GetSessionInfo().bundleName_,
sceneSession->GetSessionInfo().abilityName_, focusNodeId};
RSInterfaces::GetInstance().SetFocusAppInfo(appInfo);
}
WSError SceneSessionManager::UpdateFocus(int32_t persistentId, bool isFocused)
{
auto task = [this, persistentId, isFocused]() {
@ -1770,25 +1793,7 @@ WSError SceneSessionManager::UpdateFocus(int32_t persistentId, bool isFocused)
if (isFocused) {
SetFocusedSession(persistentId);
UpdateBrightness(focusedSessionId_);
// notify RS
WLOGFD("current focus session: windowId: %{public}d, windowName: %{public}s, bundleName: %{public}s,"
" abilityName: %{public}s, pid: %{public}d, uid: %{public}d", persistentId,
sceneSession->GetWindowSessionProperty()->GetWindowName().c_str(),
sceneSession->GetSessionInfo().bundleName_.c_str(),
sceneSession->GetSessionInfo().abilityName_.c_str(),
sceneSession->GetCallingPid(), sceneSession->GetCallingUid());
uint64_t focusNodeId = 0; // 0 means invalid
if (sceneSession->GetSurfaceNode() == nullptr) {
WLOGFW("focused window surfaceNode is null");
} else {
focusNodeId = sceneSession->GetSurfaceNode()->GetId();
}
FocusAppInfo appInfo = {
sceneSession->GetCallingPid(), sceneSession->GetCallingUid(),
sceneSession->GetSessionInfo().bundleName_, sceneSession->GetSessionInfo().abilityName_,
focusNodeId
};
RSInterfaces::GetInstance().SetFocusAppInfo(appInfo);
FocusIDChange(persistentId, sceneSession);
} else if (persistentId == GetFocusedSession()) {
SetFocusedSession(INVALID_SESSION_ID);
}

View File

@ -24,7 +24,7 @@ namespace Rosen {
class MockScreenManagerServiceProxy : public IRemoteProxy<IMockScreenManagerInterface> {
public:
explicit MockScreenManagerServiceProxy(const sptr<IRemoteObject>& impl) :
IRemoteProxy<IMockScreenManagerInterface>(impl) {};
IRemoteProxy<IMockScreenManagerInterface>(impl) {};
~MockScreenManagerServiceProxy() {};
void GetScreenDumpInfo(const std::vector<std::string>& params, std::string& info) override;

View File

@ -35,7 +35,7 @@ const std::string ARG_DUMP_SCREEN = "-s";
}
WM_IMPLEMENT_SINGLE_INSTANCE(MockScreenManagerService)
bool registerResult = !SceneBoardJudgement::IsSceneBoardEnabled() ? false :
const bool REGISTE_RRESULT = !SceneBoardJudgement::IsSceneBoardEnabled() ? false :
SystemAbility::MakeAndRegisterAbility(&SingletonContainer::Get<MockScreenManagerService>());
MockScreenManagerService::MockScreenManagerService() : SystemAbility(DISPLAY_MANAGER_SERVICE_SA_ID, true)
@ -172,8 +172,8 @@ void MockScreenManagerService::InitScreenSessionManager()
bool MockScreenManagerService::RegisterMockScreenManagerService()
{
WLOGFI("registerResult %{public}d", registerResult);
if (!registerResult) {
WLOGFI("REGISTE_RRESULT %{public}d", REGISTE_RRESULT);
if (!REGISTE_RRESULT) {
!SceneBoardJudgement::IsSceneBoardEnabled() ? false :
SystemAbility::MakeAndRegisterAbility(&SingletonContainer::Get<MockScreenManagerService>());
}