安全扫描项修改

Change-Id: Iccf64bb80d5649a771fecc75fba4d1628595e2a6
Signed-off-by: zhengjiangliang <zhengjiangliang@huawei.com>
This commit is contained in:
zhengjiangliang 2022-10-26 16:13:02 +08:00
parent 8ede99ac11
commit 3e593c9861
24 changed files with 66 additions and 66 deletions

View File

@ -31,7 +31,7 @@ namespace {
}
class Screen::Impl : public RefBase {
public:
Impl(sptr<ScreenInfo> info)
explicit Impl(sptr<ScreenInfo> info)
{
screenInfo_ = info;
}

View File

@ -30,7 +30,7 @@ namespace {
}
class ScreenGroup::Impl : public RefBase {
public:
Impl(sptr<ScreenGroupInfo> info)
explicit Impl(sptr<ScreenGroupInfo> info)
{
screenGroupInfo_ = info;
}

View File

@ -642,7 +642,7 @@ std::map<DisplayId, sptr<DisplayInfo>> AbstractDisplayController::GetAllDisplayI
ScreenId screenGroupId = info->GetScreenGroupId();
std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
std::lock_guard<std::recursive_mutex> lock(mutex_);
for (auto& iter : abstractDisplayMap_) {
for (const auto& iter : abstractDisplayMap_) {
sptr<AbstractDisplay> display = iter.second;
if (display->GetAbstractScreenGroupId() == screenGroupId) {
displayInfoMap.insert(std::make_pair(display->GetId(), display->ConvertToDisplayInfo()));

View File

@ -62,7 +62,7 @@ bool CheckCallingPermission(const std::string &permission)
return true;
}
void SetErrorInfo(napi_env env, Rosen::DmErrorCode wret, std::string errMessage, napi_value result[], int count)
void SetErrorInfo(napi_env env, Rosen::DmErrorCode wret, const std::string errMessage, napi_value result[], int count)
{
if (count != 2 || result == nullptr) { // input param number is 2
GNAPI_LOG("Error, input param number must be 2");

View File

@ -58,7 +58,7 @@ napi_status SetMemberUint32(napi_env env, napi_value result, const char *key, ui
napi_status SetMemberUndefined(napi_env env, napi_value result, const char *key);
bool CheckCallingPermission(const std::string &permission);
void SetErrorInfo(napi_env env, Rosen::DmErrorCode wret, std::string errMessage,
void SetErrorInfo(napi_env env, Rosen::DmErrorCode wret, const std::string errMessage,
napi_value result[], int count);
void ProcessPromise(napi_env env, Rosen::DmErrorCode wret, napi_deferred deferred,
napi_value result[], int count);
@ -67,7 +67,7 @@ bool NAPICall(napi_env env, napi_status status);
template<typename ParamT>
napi_value AsyncProcess(napi_env env,
std::string funcname,
const std::string funcname,
void(*async)(napi_env env, std::unique_ptr<ParamT>& param),
napi_value(*resolve)(napi_env env, std::unique_ptr<ParamT>& param),
napi_ref& callbackRef,

View File

@ -162,7 +162,7 @@ NativeValue* CreateJsBoundingRectsArrayObject(NativeEngine& engine, std::vector<
NativeValue* arrayValue = engine.CreateArray(boundingRects.size());
NativeArray* array = ConvertNativeValueTo<NativeArray>(arrayValue);
size_t i = 0;
for (auto& rect : boundingRects) {
for (const auto& rect : boundingRects) {
array->SetElement(i++, CreateJsRectObject(engine, rect));
}
return arrayValue;

View File

@ -288,7 +288,7 @@ NativeValue* CreateJsScreenModeArrayObject(NativeEngine& engine, std::vector<spt
return arrayValue;
}
NativeValue* CreateJsScreenModeObject(NativeEngine& engine, sptr<SupportedScreenModes>& mode)
NativeValue* CreateJsScreenModeObject(NativeEngine& engine, const sptr<SupportedScreenModes>& mode)
{
WLOGFI("JsScreen::CreateJsScreenMode is called");
NativeValue* objValue = engine.CreateObject();

View File

@ -26,7 +26,7 @@ namespace OHOS {
namespace Rosen {
NativeValue* CreateJsScreenObject(NativeEngine& engine, sptr<Screen>& screen);
NativeValue* CreateJsScreenModeArrayObject(NativeEngine& engine, std::vector<sptr<SupportedScreenModes>> screenModes);
NativeValue* CreateJsScreenModeObject(NativeEngine &engine, sptr<SupportedScreenModes>& mode);
NativeValue* CreateJsScreenModeObject(NativeEngine &engine, const sptr<SupportedScreenModes>& mode);
class JsScreen final {
public:
explicit JsScreen(const sptr<Screen>& screen);

View File

@ -411,7 +411,7 @@ NativeValue* OnMakeExpand(NativeEngine& engine, NativeCallbackInfo& info)
return result;
}
int32_t GetExpandOptionFromJs(NativeEngine& engine, NativeObject* optionObject, ExpandOption& option)
static int32_t GetExpandOptionFromJs(NativeEngine& engine, NativeObject* optionObject, ExpandOption& option)
{
NativeValue* screedIdValue = optionObject->GetProperty("screenId");
NativeValue* startXValue = optionObject->GetProperty("startX");

View File

@ -462,8 +462,7 @@ NativeValue* JsWindowManager::OnCreateWindow(NativeEngine& engine, NativeCallbac
}
NativeValue* callback = nullptr;
if (info.argc > 1) {
callback = (info.argc == 1) ? nullptr :
(info.argv[1]->TypeOf() == NATIVE_FUNCTION ? info.argv[1] : nullptr); // 1: index of callback
callback = info.argv[1]->TypeOf() == NATIVE_FUNCTION ? info.argv[1] : nullptr; // 1: index of callback
}
AsyncTask::CompleteCallback complete =
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {

View File

@ -43,18 +43,19 @@ public:
static NativeValue* SetWindowLayoutMode(NativeEngine* engine, NativeCallbackInfo* info);
private:
NativeValue* OnCreate(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnCreateWindow(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnFindWindow(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnFindWindowSync(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnMinimizeAll(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnToggleShownStateForAllAppWindows(NativeEngine& engine, NativeCallbackInfo& info);
static NativeValue* OnCreate(NativeEngine& engine, NativeCallbackInfo& info);
static NativeValue* OnCreateWindow(NativeEngine& engine, NativeCallbackInfo& info);
static NativeValue* OnFindWindow(NativeEngine& engine, NativeCallbackInfo& info);
static NativeValue* OnFindWindowSync(NativeEngine& engine, NativeCallbackInfo& info);
static NativeValue* OnMinimizeAll(NativeEngine& engine, NativeCallbackInfo& info);
static NativeValue* OnToggleShownStateForAllAppWindows(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnRegisterWindowMangerCallback(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnUnregisterWindowManagerCallback(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnGetTopWindow(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnGetLastWindow(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnSetWindowLayoutMode(NativeEngine& engine, NativeCallbackInfo& info);
bool ParseConfigOption(NativeEngine& engine, NativeObject* jsObject, WindowOption& option, void*& contextPtr);
static NativeValue* OnGetTopWindow(NativeEngine& engine, NativeCallbackInfo& info);
static NativeValue* OnGetLastWindow(NativeEngine& engine, NativeCallbackInfo& info);
static NativeValue* OnSetWindowLayoutMode(NativeEngine& engine, NativeCallbackInfo& info);
static bool ParseConfigOption(
NativeEngine& engine, NativeObject* jsObject, WindowOption& option, void*& contextPtr);
std::unique_ptr<JsWindowRegisterManager> registerManager_ = nullptr;
};
} // namespace Rosen

View File

@ -116,9 +116,9 @@ public:
static NativeValue* SetBackdropBlurStyle(NativeEngine* engine, NativeCallbackInfo* info);
private:
std::string GetWindowName();
bool ParseScaleOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans);
bool ParseRotateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans);
bool ParseTranslateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans);
static bool ParseScaleOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans);
static bool ParseRotateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans);
static bool ParseTranslateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans);
NativeValue* LoadContentScheduleOld(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* LoadContentScheduleNew(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnShow(NativeEngine& engine, NativeCallbackInfo& info);

View File

@ -112,7 +112,7 @@ std::vector<sptr<Window>> WindowImpl::GetSubWindow(uint32_t parentId)
void WindowImpl::UpdateConfigurationForAll(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
{
for (auto& winPair : windowMap_) {
for (const auto& winPair : windowMap_) {
auto window = winPair.second.second;
window->UpdateConfiguration(configuration);
}
@ -320,7 +320,7 @@ WMError WindowImpl::Create(uint32_t parentId, const std::shared_ptr<AbilityRunti
}
// check parent id, if create sub window and there is not exist parent Window, then return
if (parentId != INVALID_WINDOW_ID) {
for (auto& winPair : windowMap_) {
for (const auto& winPair : windowMap_) {
if (winPair.second.first == parentId) {
property_->SetParentId(parentId);
break;

View File

@ -366,7 +366,7 @@ void WindowTestUtils::UpdateSplitRects(const sptr<Window>& window)
}
}
void WindowTestUtils::UpdateLimitDisplayRect(Rect& avoidRect)
void WindowTestUtils::UpdateLimitDisplayRect(const Rect& avoidRect)
{
if (((avoidRect.posX_ == 0) && (avoidRect.posY_ == 0) &&
(avoidRect.width_ == 0) && (avoidRect.height_ == 0))) {

View File

@ -82,10 +82,10 @@ public:
static uint32_t GetMaxTileWinNum();
private:
void UpdateLimitDisplayRect(Rect& avoidRect);
void UpdateLimitDisplayRect(const Rect& avoidRect);
void UpdateLimitSplitRects(int32_t divPos);
void UpdateLimitSplitRect(Rect& limitSplitRect);
AvoidPosType GetAvoidPosType(const Rect& rect);
static AvoidPosType GetAvoidPosType(const Rect& rect);
AvoidArea avoidArea_;
};
} // namespace ROSEN

View File

@ -73,7 +73,7 @@ bool PerformReporter::report()
std::ostringstream oss;
oss << tag_ << ": ";
auto maxSplit = 0;
for (auto& iter: timeSplitCount_) {
for (const auto& iter: timeSplitCount_) {
if (iter.first != BARRIER) {
oss << "BELLOW" << iter.first << "(ms): " << iter.second << ", ";
maxSplit = iter.first;

View File

@ -192,7 +192,7 @@ void Region::MakeBound()
{
if (rects_.size()) {
bound_ = rects_[0];
for (auto& r : rects_) {
for (const auto& r : rects_) {
bound_.left_ = std::min(r.left_, bound_.left_);
bound_.top_ = std::min(r.top_, bound_.top_);
bound_.right_ = std::max(r.right_, bound_.right_);

View File

@ -85,8 +85,6 @@ WindowImpl::WindowImpl(const sptr<WindowOption>& option)
}
name_ = option->GetWindowName();
struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
rsSurfaceNodeConfig.SurfaceNodeName = property_->GetWindowName();
surfaceNode_ = CreateSurfaceNode(property_->GetWindowName(), option->GetWindowType());
moveDragProperty_ = new (std::nothrow) MoveDragProperty();
@ -199,7 +197,7 @@ std::vector<sptr<Window>> WindowImpl::GetSubWindow(uint32_t parentId)
void WindowImpl::UpdateConfigurationForAll(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
{
for (auto& winPair : windowMap_) {
for (const auto& winPair : windowMap_) {
auto window = winPair.second.second;
window->UpdateConfiguration(configuration);
}
@ -704,7 +702,7 @@ void WindowImpl::MapFloatingWindowToAppIfNeeded()
return;
}
for (auto& winPair : windowMap_) {
for (const auto& winPair : windowMap_) {
auto win = winPair.second.second;
if (win->GetType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW &&
context_.get() == win->GetContext().get()) {
@ -723,7 +721,7 @@ void WindowImpl::MapDialogWindowToAppIfNeeded()
return;
}
for (auto& winPair : windowMap_) {
for (const auto& winPair : windowMap_) {
auto win = winPair.second.second;
if (win->GetType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW &&
context_.get() == win->GetContext().get()) {
@ -814,7 +812,7 @@ bool WindowImpl::IsAppMainOrSubOrFloatingWindow()
}
if (WindowHelper::IsAppFloatingWindow(GetType())) {
for (auto& winPair : windowMap_) {
for (const auto& winPair : windowMap_) {
auto win = winPair.second.second;
if (win != nullptr && win->GetType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW &&
context_.get() == win->GetContext().get()) {
@ -2415,7 +2413,9 @@ void WindowImpl::ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& p
return;
}
}
SingletonContainer::Get<WindowAdapter>().ProcessPointDown(property_->GetWindowId());
if (property_ != nullptr) {
SingletonContainer::Get<WindowAdapter>().ProcessPointDown(property_->GetWindowId());
}
}
// If point event type is up, should reset start move flag

View File

@ -348,7 +348,7 @@ void DisplayGroupController::ProcessNotCrossNodesOnDestroyedDisplay(DisplayId di
WindowRootNodeType::APP_WINDOW_NODE,
WindowRootNodeType::BELOW_WINDOW_NODE
};
for (auto& type : rootNodeType) {
for (const auto& type : rootNodeType) {
auto nodesVec = *(displayGroupWindowTree_[displayId][type]);
for (auto node : nodesVec) {
WLOGFD("node on destroied display, windowId: %{public}d, isShowingOnMulti: %{public}d",

View File

@ -1067,7 +1067,7 @@ WMError WindowController::SetWindowLayoutMode(WindowLayoutMode mode)
WMError res = WMError::WM_OK;
auto displayIds = windowRoot_->GetAllDisplayIds();
for (auto displayId : displayIds) {
WMError res = windowRoot_->SetWindowLayoutMode(displayId, mode);
res = windowRoot_->SetWindowLayoutMode(displayId, mode);
if (res != WMError::WM_OK) {
return res;
}

View File

@ -193,8 +193,8 @@ WMError WindowDumper::DumpSpecifiedWindowInfo(uint32_t windowId, const std::vect
std::vector<Rect> touchHotAreas;
node->GetTouchHotAreas(touchHotAreas);
int index = 0;
for (const auto& rect : touchHotAreas) {
oss << "[ " << rect.posX_ << ", " << rect.posY_ << ", " << rect.width_ << ", " << rect.height_ << " ]";
for (const auto& area : touchHotAreas) {
oss << "[ " << area.posX_ << ", " << area.posY_ << ", " << area.width_ << ", " << area.height_ << " ]";
index++;
if (index < static_cast<int32_t>(touchHotAreas.size())) {
oss <<", ";

View File

@ -660,16 +660,16 @@ void WindowManagerService::CancelStartingWindow(sptr<IRemoteObject> abilityToken
WMError WindowManagerService::CreateWindow(sptr<IWindow>& window, sptr<WindowProperty>& property,
const std::shared_ptr<RSSurfaceNode>& surfaceNode, uint32_t& windowId, sptr<IRemoteObject> token)
{
if (!window || property == nullptr || surfaceNode == nullptr || !window->AsObject()) {
WLOGFE("window is invalid");
return WMError::WM_ERROR_NULLPTR;
}
bool isSystemWindowExceptAlarmWindow = property->GetWindowType() != WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW &&
WindowHelper::IsSystemWindow(property->GetWindowType());
if (isSystemWindowExceptAlarmWindow && !Permission::IsSystemCalling()) {
WLOGFE("create system window permission denied!");
return WMError::WM_ERROR_INVALID_PERMISSION;
}
if (!window || property == nullptr || surfaceNode == nullptr || !window->AsObject()) {
WLOGFE("window is invalid");
return WMError::WM_ERROR_NULLPTR;
}
int pid = IPCSkeleton::GetCallingPid();
int uid = IPCSkeleton::GetCallingUid();
WMError ret = PostSyncTask([this, pid, uid, &window, &property, &surfaceNode, &windowId, &token]() {
@ -682,6 +682,10 @@ WMError WindowManagerService::CreateWindow(sptr<IWindow>& window, sptr<WindowPro
WMError WindowManagerService::AddWindow(sptr<WindowProperty>& property)
{
if (property == nullptr) {
WLOGFE("property is nullptr");
return WMError::WM_ERROR_NULLPTR;
}
bool isSystemWindowExceptAlarmWindow = property->GetWindowType() != WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW &&
WindowHelper::IsSystemWindow(property->GetWindowType());
if ((isSystemWindowExceptAlarmWindow ||
@ -691,10 +695,6 @@ WMError WindowManagerService::AddWindow(sptr<WindowProperty>& property)
return WMError::WM_ERROR_INVALID_PERMISSION;
}
return PostSyncTask([this, &property]() {
if (property == nullptr) {
WLOGFE("property is nullptr");
return WMError::WM_ERROR_NULLPTR;
}
windowShowPerformReport_->start();
Rect rect = property->GetRequestRect();
uint32_t windowId = property->GetWindowId();
@ -1002,16 +1002,16 @@ WMError WindowManagerService::SetWindowLayoutMode(WindowLayoutMode mode)
WMError WindowManagerService::UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action,
bool isAsyncTask)
{
if (windowProperty == nullptr) {
WLOGFE("windowProperty is nullptr");
return WMError::WM_ERROR_NULLPTR;
}
if ((windowProperty->GetWindowFlags() == static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE) ||
action == PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY) &&
!Permission::IsSystemCalling()) {
WLOGFE("SetForbidSplitMove or SetShowWhenLocked or SetTranform or SetTurnScreenOn permission denied!");
return WMError::WM_ERROR_INVALID_PERMISSION;
}
if (windowProperty == nullptr) {
WLOGFE("windowProperty is nullptr");
return WMError::WM_ERROR_NULLPTR;
}
if (action == PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY) {
return PostSyncTask([this, windowProperty, action]() mutable {

View File

@ -451,16 +451,16 @@ void WindowNodeContainer::UpdateWindowTree(sptr<WindowNode>& node)
}
auto position = parentNode->children_.end();
int splitWindowCnt = 0;
for (auto iter = parentNode->children_.begin(); iter < parentNode->children_.end(); ++iter) {
for (auto child = parentNode->children_.begin(); child < parentNode->children_.end(); ++child) {
if (node->GetWindowType() == WindowType::WINDOW_TYPE_DOCK_SLICE && splitWindowCnt == SPLIT_WINDOWS_CNT) {
position = iter;
position = child;
break;
}
if (WindowHelper::IsSplitWindowMode((*iter)->GetWindowMode())) {
if (WindowHelper::IsSplitWindowMode((*child)->GetWindowMode())) {
splitWindowCnt++;
}
if ((*iter)->priority_ > node->priority_) {
position = iter;
if ((*child)->priority_ > node->priority_) {
position = child;
break;
}
}
@ -624,7 +624,7 @@ sptr<WindowNode> WindowNodeContainer::FindRoot(WindowType type) const
sptr<WindowNode> WindowNodeContainer::FindWindowNodeById(uint32_t id) const
{
std::vector<sptr<WindowNode>> rootNodes = { aboveAppWindowNode_, appWindowNode_, belowAppWindowNode_ };
for (auto& rootNode : rootNodes) {
for (const auto& rootNode : rootNodes) {
for (auto& node : rootNode->children_) {
if (node->GetWindowId() == id) {
return node;
@ -871,7 +871,7 @@ std::unordered_map<WindowType, SystemBarProperty> WindowNodeContainer::GetExpect
};
std::vector<sptr<WindowNode>> rootNodes = { aboveAppWindowNode_, appWindowNode_, belowAppWindowNode_ };
for (auto& node : rootNodes) {
for (const auto& node : rootNodes) {
for (auto iter = node->children_.rbegin(); iter < node->children_.rend(); ++iter) {
auto& sysBarPropMapNode = (*iter)->GetSystemBarProperty();
if (IsAboveSystemBarNode(*iter)) {
@ -1795,7 +1795,7 @@ void WindowNodeContainer::TraverseWindowTree(const WindowNodeOperationFunc& func
std::reverse(rootNodes.begin(), rootNodes.end());
}
for (auto& node : rootNodes) {
for (const auto& node : rootNodes) {
if (isFromTopToBottom) {
for (auto iter = node->children_.rbegin(); iter != node->children_.rend(); ++iter) {
if (TraverseFromTopToBottom(*iter, func)) {

View File

@ -1216,7 +1216,7 @@ std::string WindowRoot::GenAllWindowsLogInfo() const
continue;
}
std::vector<DisplayId>& displayIdVec = const_cast<WindowRoot*>(this)->displayIdMap_[elem.first];
for (auto& displayId : displayIdVec) {
for (const auto& displayId : displayIdVec) {
os << "Display " << displayId << ":";
}
elem.second->TraverseWindowTree(func, true);
@ -1316,7 +1316,7 @@ std::map<DisplayId, Rect> WindowRoot::GetAllDisplayRectsByDisplayInfo(
{
std::map<DisplayId, Rect> displayRectMap;
for (auto& iter : displayInfoMap) {
for (const auto& iter : displayInfoMap) {
auto id = iter.first;
auto info = iter.second;
Rect displayRect = { info->GetOffsetX(), info->GetOffsetY(), info->GetWidth(), info->GetHeight() };
@ -1712,7 +1712,7 @@ bool WindowRoot::IsAppWindowExceed() const
sptr<WindowNode> WindowRoot::GetWindowNodeByAbilityToken(const sptr<IRemoteObject>& abilityToken)
{
for (auto& iter : windowNodeMap_) {
for (const auto& iter : windowNodeMap_) {
if (iter.second != nullptr && iter.second->abilityToken_ == abilityToken) {
return iter.second;
}