mirror of
https://gitee.com/openharmony/accessibility
synced 2025-02-17 06:57:49 +00:00
commit
3b11f8ef6e
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "accessibility_gesture_inject_path_parcel.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
class AccessibilityGestureInjectPathParcelTest : public ::testing::Test {
|
||||
public:
|
||||
AccessibilityGestureInjectPathParcelTest()
|
||||
{}
|
||||
~AccessibilityGestureInjectPathParcelTest()
|
||||
{}
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AccessibilityGestureInjectPathParcelTest Start";
|
||||
}
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AccessibilityGestureInjectPathParcelTest End";
|
||||
}
|
||||
void SetUp()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AccessibilityGestureInjectPathParcelTest SetUp() Start";
|
||||
AccessibilityGestureInjectPath gestureInfo;
|
||||
gestureInfoParcel_ = std::make_shared<AccessibilityGestureInjectPathParcel>(gestureInfo);
|
||||
GTEST_LOG_(INFO) << "AccessibilityGestureInjectPathParcelTest SetUp() End";
|
||||
};
|
||||
void TearDown()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AccessibilityGestureInjectPathParcelTest TearDown()";
|
||||
gestureInfoParcel_ = nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<AccessibilityGestureInjectPathParcel> gestureInfoParcel_ = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number: Gesture_Info_Marshalling_001
|
||||
* @tc.name: Gesture_Info_Marshalling
|
||||
* @tc.desc: Test function Marshalling
|
||||
*/
|
||||
HWTEST_F(AccessibilityGestureInjectPathParcelTest, Gesture_Info_Marshalling_001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Gesture_Info_Marshalling_001 start";
|
||||
if (!GesturgestureInfoParcel_e_Info) {
|
||||
GTEST_LOG_(INFO) << "captionPropertyParcel_ is null";
|
||||
return;
|
||||
}
|
||||
|
||||
Parcel parcel;
|
||||
bool ret = GesturgestureInfoParcel_e_Info->Marshalling(parcel);
|
||||
EXPECT_EQ(ret, true);
|
||||
GTEST_LOG_(INFO) << "Gesture_Info_Marshalling_001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: Gesture_Info_Unmarshalling_001
|
||||
* @tc.name: Gesture_Info_Unmarshalling
|
||||
* @tc.desc: Test function Unmarshalling
|
||||
*/
|
||||
HWTEST_F(AccessibilityGestureInjectPathParcelTest, Gesture_Info_Unmarshalling_001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Gesture_Info_Unmarshalling_001 start";
|
||||
if (!GesturgestureInfoParcel_e_Info) {
|
||||
GTEST_LOG_(INFO) << "GesturgestureInfoParcel_e_Info is null";
|
||||
return;
|
||||
}
|
||||
|
||||
Parcel parcel;
|
||||
sptr<AccessibilityGestureInjectPathParcel> gestureInfoParcel = GesturgestureInfoParcel_e_Info->Unmarshalling(parcel);
|
||||
EXPECT_EQ(true, gestureInfoParcel == nullptr);
|
||||
GTEST_LOG_(INFO) << "Gesture_Info_Unmarshalling_001 end";
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "accessibility_ability_info_parcel.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
AccessibilityAbilityInfoParcelTest::AccessibilityAbilityInfoParcelTest(
|
||||
const AccessibilityAbilityInfo &accessibilityAbilityInfo)
|
||||
: AccessibilityAbilityInfo(accessibilityAbilityInfo)
|
||||
{
|
||||
}
|
||||
|
||||
bool AccessibilityAbilityInfoParcelTest::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, moduleName_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, name_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, description_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, label_);
|
||||
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, capabilities_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, staticCapabilities_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, rationale_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, abilityTypes_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, eventTypes_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, settingsAbility_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(StringVector, parcel, &targetBundleNames_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, needHide_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityAbilityInfoParcelTest::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, moduleName_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, name_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, description_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, label_);
|
||||
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, capabilities_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, staticCapabilities_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, rationale_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, abilityTypes_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, eventTypes_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, settingsAbility_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(StringVector, parcel, targetBundleNames_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, needHide_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<AccessibilityAbilityInfoParcelTest> AccessibilityAbilityInfoParcelTest::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
sptr<AccessibilityAbilityInfoParcelTest> info = new(std::nothrow) AccessibilityAbilityInfoParcelTest();
|
||||
if (info == nullptr) {
|
||||
HILOG_ERROR("Failed to create info.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!info->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("ReadFromParcel AccessibilityAbilityInfo failed.");
|
||||
info = nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "accessibility_caption_parcel.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
CaptionPropertyParcelTest::CaptionPropertyParcelTest(const CaptionProperty &property)
|
||||
: CaptionProperty(property)
|
||||
{
|
||||
}
|
||||
|
||||
bool CaptionPropertyParcelTest::ReadFromParcel(Parcel& parcel)
|
||||
{
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontFamily_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, fontScale_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, fontColor_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontEdgeType_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, backgroundColor_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, windowColor_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CaptionPropertyParcelTest::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontFamily_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, fontScale_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, fontColor_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontEdgeType_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, backgroundColor_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, windowColor_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<CaptionPropertyParcelTest> CaptionPropertyParcelTest::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sptr<CaptionPropertyParcelTest> captionProperty = new(std::nothrow) CaptionPropertyParcelTest();
|
||||
if (captionProperty == nullptr) {
|
||||
HILOG_ERROR("Failed to create captionProperty.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!captionProperty->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("read from parcel failed");
|
||||
return nullptr;
|
||||
}
|
||||
return captionProperty;
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,637 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "accessibility_element_info_parcel.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
/* AccessibilityElementInfoParcelTest Parcel struct */
|
||||
AccessibilityElementInfoParcelTest::AccessibilityElementInfoParcelTest(const AccessibilityElementInfo &elementInfo)
|
||||
: AccessibilityElementInfo(elementInfo)
|
||||
{
|
||||
}
|
||||
|
||||
bool AccessibilityElementInfoParcelTest::ReadFromParcelFirstPart(Parcel &parcel)
|
||||
{
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, pageId_);
|
||||
int32_t textMoveStep = STEP_CHARACTER;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, textMoveStep);
|
||||
textMoveStep_ = static_cast<TextMoveUnit>(textMoveStep);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, itemCounts_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, elementId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, parentId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, belongTreeId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, childTreeId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, childWindowId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, parentWindowId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, componentType_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, text_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, hintText_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityText_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, contentDescription_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, resourceName_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64Vector, parcel, &childNodeIds_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, childCount_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, textType_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Float, parcel, offset_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityElementInfoParcelTest::ReadFromParcelSecondPart(Parcel &parcel)
|
||||
{
|
||||
int32_t operationsSize = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, operationsSize);
|
||||
bool verifyResult = ContainerSecurityVerify(parcel, operationsSize, operations_.max_size());
|
||||
if (!verifyResult || operationsSize < 0 || operationsSize > INT32_MAX) {
|
||||
return false;
|
||||
}
|
||||
for (int32_t i = 0; i < operationsSize; i++) {
|
||||
sptr<AccessibleActionParcel> accessibleOperation = parcel.ReadStrongParcelable<AccessibleActionParcel>();
|
||||
if (accessibleOperation == nullptr) {
|
||||
HILOG_ERROR("ReadStrongParcelable<accessibleOperation> failed");
|
||||
return false;
|
||||
}
|
||||
operations_.emplace_back(*accessibleOperation);
|
||||
}
|
||||
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, textLengthLimit_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, navDestinationId_);
|
||||
sptr<RectParcel> rect = parcel.ReadStrongParcelable<RectParcel>();
|
||||
if (rect == nullptr) {
|
||||
return false;
|
||||
}
|
||||
bounds_ = *rect;
|
||||
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, checkable_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, checked_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, focusable_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, focused_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, visible_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityFocused_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, selected_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, clickable_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, longClickable_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, enable_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isPassword_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, scrollable_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, editable_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, popupSupported_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, multiLine_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, deletable_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, hint_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isEssential_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, currentIndex_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, beginIndex_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, endIndex_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityElementInfoParcelTest::ReadFromParcelThirdPart(Parcel &parcel)
|
||||
{
|
||||
sptr<RangeInfoParcel> rangeInfo = parcel.ReadStrongParcelable<RangeInfoParcel>();
|
||||
if (rangeInfo == nullptr) {
|
||||
return false;
|
||||
}
|
||||
rangeInfo_ = *rangeInfo;
|
||||
|
||||
sptr<GridInfoParcel> grid = parcel.ReadStrongParcelable<GridInfoParcel>();
|
||||
if (grid == nullptr) {
|
||||
return false;
|
||||
}
|
||||
grid_ = *grid;
|
||||
|
||||
sptr<GridItemInfoParcel> gridItem = parcel.ReadStrongParcelable<GridItemInfoParcel>();
|
||||
if (gridItem == nullptr) {
|
||||
return false;
|
||||
}
|
||||
gridItem_ = *gridItem;
|
||||
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, liveRegion_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, contentInvalid_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, error_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, labeled_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, beginSelected_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, endSelected_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, inputType_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, validElement_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, inspectorKey_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, pagePath_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityGroup_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityLevel_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, zIndex_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Float, parcel, opacity_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, backgroundColor_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, backgroundImage_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, blur_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, hitTestBehavior_);
|
||||
|
||||
sptr<ExtraElementInfoParcel> extraElementInfo = parcel.ReadStrongParcelable<ExtraElementInfoParcel>();
|
||||
if (extraElementInfo == nullptr) {
|
||||
return false;
|
||||
}
|
||||
extraElementInfo_ = *extraElementInfo;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityElementInfoParcelTest::ReadFromParcelFourthPart(Parcel &parcel)
|
||||
{
|
||||
int32_t spanListSize = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, spanListSize);
|
||||
if (!ContainerSecurityVerify(parcel, spanListSize, spanList_.max_size())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < spanListSize; i++) {
|
||||
sptr<SpanInfoParcel> spanList = parcel.ReadStrongParcelable<SpanInfoParcel>();
|
||||
if (spanList == nullptr) {
|
||||
HILOG_ERROR("ReadStrongParcelable<spanList> failed");
|
||||
return false;
|
||||
}
|
||||
spanList_.emplace_back(*spanList);
|
||||
}
|
||||
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isActive_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityVisible_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityElementInfoParcelTest::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
if (!ReadFromParcelFirstPart(parcel)) {
|
||||
return false;
|
||||
}
|
||||
if (!ReadFromParcelSecondPart(parcel)) {
|
||||
return false;
|
||||
}
|
||||
if (!ReadFromParcelThirdPart(parcel)) {
|
||||
return false;
|
||||
}
|
||||
if (!ReadFromParcelFourthPart(parcel)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityElementInfoParcelTest::MarshallingFirstPart(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, pageId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(textMoveStep_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, itemCounts_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, elementId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, parentId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, belongTreeId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, childTreeId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, childWindowId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, parentWindowId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, componentType_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, text_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, hintText_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityText_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, contentDescription_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, resourceName_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64Vector, parcel, childNodeIds_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, childCount_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, textType_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Float, parcel, offset_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, operations_.size());
|
||||
for (auto &operations : operations_) {
|
||||
AccessibleActionParcel action(operations);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &action);
|
||||
}
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, textLengthLimit_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, navDestinationId_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityElementInfoParcelTest::MarshallingSecondPart(Parcel &parcel) const
|
||||
{
|
||||
RectParcel boundsParcel(bounds_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &boundsParcel);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, checkable_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, checked_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, focusable_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, focused_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, visible_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityFocused_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, selected_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, clickable_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, longClickable_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, enable_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isPassword_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, scrollable_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, editable_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, popupSupported_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, multiLine_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, deletable_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, hint_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isEssential_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, currentIndex_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, beginIndex_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, endIndex_);
|
||||
RangeInfoParcel rangeInfoParcel(rangeInfo_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &rangeInfoParcel);
|
||||
GridInfoParcel gridParcel(grid_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &gridParcel);
|
||||
GridItemInfoParcel gridItemParcel(gridItem_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &gridItemParcel);
|
||||
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, liveRegion_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, contentInvalid_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, error_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, labeled_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, beginSelected_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, endSelected_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, inputType_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, validElement_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, inspectorKey_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, pagePath_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityGroup_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityLevel_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, zIndex_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Float, parcel, opacity_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, backgroundColor_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, backgroundImage_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, blur_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, hitTestBehavior_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityElementInfoParcelTest::MarshallingThirdPart(Parcel &parcel) const
|
||||
{
|
||||
ExtraElementInfoParcel extraElementInfoParcel(extraElementInfo_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &extraElementInfoParcel);
|
||||
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, spanList_.size());
|
||||
for (auto &span : spanList_) {
|
||||
SpanInfoParcel spanList(span);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &spanList);
|
||||
}
|
||||
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isActive_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityVisible_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityElementInfoParcelTest::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!MarshallingFirstPart(parcel)) {
|
||||
return false;
|
||||
}
|
||||
if (!MarshallingSecondPart(parcel)) {
|
||||
return false;
|
||||
}
|
||||
if (!MarshallingThirdPart(parcel)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<AccessibilityElementInfoParcelTest> AccessibilityElementInfoParcelTest::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sptr<AccessibilityElementInfoParcelTest> accessibilityInfo = new(std::nothrow) AccessibilityElementInfoParcelTest();
|
||||
if (accessibilityInfo == nullptr) {
|
||||
HILOG_ERROR("Failed to create accessibilityInfo.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!accessibilityInfo->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("read from parcel failed");
|
||||
return nullptr;
|
||||
}
|
||||
return accessibilityInfo;
|
||||
}
|
||||
|
||||
AccessibleActionParcel::AccessibleActionParcel(const AccessibleAction &action)
|
||||
: AccessibleAction(action)
|
||||
{
|
||||
}
|
||||
|
||||
bool AccessibleActionParcel::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
int32_t type = ActionType::ACCESSIBILITY_ACTION_INVALID;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, type);
|
||||
actionType_ = static_cast<ActionType>(type);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, description_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibleActionParcel::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(actionType_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, description_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<AccessibleActionParcel> AccessibleActionParcel::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sptr<AccessibleActionParcel> accessibleOperation = new(std::nothrow) AccessibleActionParcel();
|
||||
if (accessibleOperation == nullptr) {
|
||||
HILOG_ERROR("Failed to create accessibleOperation.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!accessibleOperation->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("read from parcel failed");
|
||||
return nullptr;
|
||||
}
|
||||
return accessibleOperation;
|
||||
}
|
||||
|
||||
RangeInfoParcel::RangeInfoParcel(const RangeInfo &rangeInfo)
|
||||
: RangeInfo(rangeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
bool RangeInfoParcel::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Double, parcel, min_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Double, parcel, max_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Double, parcel, current_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RangeInfoParcel::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Double, parcel, min_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Double, parcel, max_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Double, parcel, current_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<RangeInfoParcel> RangeInfoParcel::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sptr<RangeInfoParcel> rangeInfo = new(std::nothrow) RangeInfoParcel();
|
||||
if (rangeInfo == nullptr) {
|
||||
HILOG_ERROR("Failed to create rangeInfo.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!rangeInfo->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("read from parcel failed");
|
||||
return nullptr;
|
||||
}
|
||||
return rangeInfo;
|
||||
}
|
||||
|
||||
GridInfoParcel::GridInfoParcel(const GridInfo &gridInfo)
|
||||
: GridInfo(gridInfo)
|
||||
{
|
||||
}
|
||||
|
||||
bool GridInfoParcel::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rowCount_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, columnCount_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, selectionMode_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GridInfoParcel::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rowCount_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, columnCount_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, selectionMode_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<GridInfoParcel> GridInfoParcel::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sptr<GridInfoParcel> grid = new(std::nothrow) GridInfoParcel();
|
||||
if (grid == nullptr) {
|
||||
HILOG_ERROR("Failed to create grid.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!grid->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("read from parcel failed");
|
||||
return nullptr;
|
||||
}
|
||||
return grid;
|
||||
}
|
||||
|
||||
GridItemInfoParcel::GridItemInfoParcel(const GridItemInfo &itemInfo)
|
||||
: GridItemInfo(itemInfo)
|
||||
{
|
||||
}
|
||||
|
||||
bool GridItemInfoParcel::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, heading_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, columnIndex_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rowIndex_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, columnSpan_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rowSpan_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, selected_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GridItemInfoParcel::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, heading_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, columnIndex_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rowIndex_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, columnSpan_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rowSpan_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, selected_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<GridItemInfoParcel> GridItemInfoParcel::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sptr<GridItemInfoParcel> gridItem = new(std::nothrow) GridItemInfoParcel();
|
||||
if (gridItem == nullptr) {
|
||||
HILOG_ERROR("Failed to create gridItem.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!gridItem->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("read from parcel failed");
|
||||
return nullptr;
|
||||
}
|
||||
return gridItem;
|
||||
}
|
||||
|
||||
RectParcel::RectParcel(const Rect &rect)
|
||||
: Rect(rect)
|
||||
{
|
||||
}
|
||||
|
||||
bool RectParcel::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, leftTopX_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, leftTopY_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rightBottomX_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rightBottomY_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RectParcel::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, leftTopX_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, leftTopY_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rightBottomX_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rightBottomY_);
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<RectParcel> RectParcel::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sptr<RectParcel> rect = new(std::nothrow) RectParcel();
|
||||
if (rect == nullptr) {
|
||||
HILOG_ERROR("Failed to create rect.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!rect->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("read from parcel failed");
|
||||
return nullptr;
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
ExtraElementInfoParcel::ExtraElementInfoParcel(const ExtraElementInfo &extraElementInfo)
|
||||
: ExtraElementInfo(extraElementInfo)
|
||||
{
|
||||
}
|
||||
|
||||
bool ExtraElementInfoParcel::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
int32_t mapValueStr = 0;
|
||||
int32_t mapValueInt = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, mapValueStr);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, mapValueInt);
|
||||
HILOG_DEBUG("ReadFromParcel: size is map, mapValueStr: %{public}d,mapValueInt: %{public}d",
|
||||
mapValueStr, mapValueInt);
|
||||
|
||||
if (!ContainerSecurityVerify(parcel, mapValueStr, extraElementValueStr_.max_size())) {
|
||||
HILOG_INFO("extraElementValueStr : ExtraElementInfoParcel verify is false");
|
||||
return false;
|
||||
}
|
||||
for (int32_t i = 0; i < mapValueStr; i++) {
|
||||
std::string tempMapKey;
|
||||
std::string tempMapVal;
|
||||
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, tempMapKey);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, tempMapVal);
|
||||
HILOG_INFO("ReadFromParcel: extraElementValueStr's tempMapKey: %{public}s, tempMapVal: %{public}s",
|
||||
tempMapKey.c_str(), tempMapVal.c_str());
|
||||
extraElementValueStr_[tempMapKey] = tempMapVal;
|
||||
}
|
||||
|
||||
if (!ContainerSecurityVerify(parcel, mapValueInt, extraElementValueInt_.max_size())) {
|
||||
HILOG_INFO("extraElementValueInt : ExtraElementInfoParcel verify is false");
|
||||
return false;
|
||||
}
|
||||
for (int32_t i = 0; i < mapValueInt; i++) {
|
||||
std::string tempMapKey;
|
||||
int32_t tempMapVal;
|
||||
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, tempMapKey);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, tempMapVal);
|
||||
HILOG_INFO("ReadFromParcel: extraElementValueInt's tempMapKey: %{public}s, tempMapVal: %{public}d",
|
||||
tempMapKey.c_str(), tempMapVal);
|
||||
extraElementValueInt_[tempMapKey] = tempMapVal;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ExtraElementInfoParcel::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, extraElementValueStr_.size());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, extraElementValueInt_.size());
|
||||
for (auto iterStr = extraElementValueStr_.begin(); iterStr != extraElementValueStr_.end(); ++iterStr) {
|
||||
std::string tempMapKey;
|
||||
std::string tempMapVal;
|
||||
tempMapKey = iterStr->first;
|
||||
tempMapVal = iterStr->second;
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, tempMapKey);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, tempMapVal);
|
||||
}
|
||||
|
||||
for (auto iterInt = extraElementValueInt_.begin(); iterInt != extraElementValueInt_.end(); ++iterInt) {
|
||||
std::string tempMapKey;
|
||||
int32_t tempMapVal;
|
||||
tempMapKey = iterInt->first;
|
||||
tempMapVal = iterInt->second;
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, tempMapKey);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, tempMapVal);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<ExtraElementInfoParcel> ExtraElementInfoParcel::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
sptr<ExtraElementInfoParcel> extraElementInfo = new(std::nothrow) ExtraElementInfoParcel();
|
||||
if (extraElementInfo == nullptr) {
|
||||
HILOG_ERROR("Failed to create extraElementInfo.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!extraElementInfo->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("read from parcel failed");
|
||||
return nullptr;
|
||||
}
|
||||
return extraElementInfo;
|
||||
}
|
||||
|
||||
SpanInfoParcel::SpanInfoParcel(const SpanInfo &spanInfo)
|
||||
: SpanInfo(spanInfo)
|
||||
{
|
||||
}
|
||||
|
||||
bool SpanInfoParcel::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, spanId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, spanText_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityText_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityDescription_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityLevel_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SpanInfoParcel::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, spanId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, spanText_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityText_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityDescription_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, accessibilityLevel_);
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<SpanInfoParcel> SpanInfoParcel::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sptr<SpanInfoParcel> spanInfo = new(std::nothrow) SpanInfoParcel();
|
||||
if (spanInfo == nullptr) {
|
||||
HILOG_ERROR("Failed to create spanInfo.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!spanInfo->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("read from parcel failed");
|
||||
return nullptr;
|
||||
}
|
||||
return spanInfo;
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,295 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "accessibility_element_operator_callback_proxy.h"
|
||||
#include "accessibility_element_info_parcel.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
constexpr int32_t IPC_MEMORY_SIZE = 500 * 1024; // default size is 200 * 1024B, batch query need more memory
|
||||
constexpr int32_t SINGLE_TRANSMIT = -2;
|
||||
constexpr int32_t MULTI_TRANSMIT_FINISH = -1;
|
||||
constexpr int32_t DATA_NUMBER_ONE_TIME = 400;
|
||||
|
||||
AccessibilityElementOperatorCallbackProxyTest::AccessibilityElementOperatorCallbackProxyTest(
|
||||
const sptr<IRemoteObject> &impl) : IRemoteProxy<IAccessibilityElementOperatorCallback>(impl)
|
||||
{}
|
||||
|
||||
AccessibilityElementOperatorCallbackProxyTest::~AccessibilityElementOperatorCallbackProxyTest()
|
||||
{}
|
||||
|
||||
bool AccessibilityElementOperatorCallbackProxyTest::WriteInterfaceToken(MessageParcel &data)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
if (!data.WriteInterfaceToken(AccessibilityElementOperatorCallbackProxyTest::GetDescriptor())) {
|
||||
HILOG_ERROR("write interface token failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityElementOperatorCallbackProxyTest::SendTransactCmd(AccessibilityInterfaceCode code,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
sptr<IRemoteObject> remoteObj = Remote();
|
||||
if (remoteObj == nullptr) {
|
||||
HILOG_ERROR("fail to send transact cmd %{public}d due to remote object", code);
|
||||
return false;
|
||||
}
|
||||
int32_t ret = remoteObj->SendRequest(static_cast<uint32_t>(code), data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
HILOG_ERROR("receive error transact code %{public}d in transact cmd %{public}d", ret, code);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t AccessibilityElementOperatorCallbackProxyTest::GetTransmitFlag(int32_t time, int32_t leftSize)
|
||||
{
|
||||
int32_t flag = time;
|
||||
if (time == 0 && leftSize <= DATA_NUMBER_ONE_TIME) {
|
||||
flag = SINGLE_TRANSMIT;
|
||||
} else if (leftSize <= DATA_NUMBER_ONE_TIME) {
|
||||
flag = MULTI_TRANSMIT_FINISH;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
void AccessibilityElementOperatorCallbackProxyTest::SetSearchElementInfoByAccessibilityIdResult(
|
||||
const std::vector<AccessibilityElementInfo> &infos, const int32_t requestId)
|
||||
{
|
||||
HILOG_DEBUG("infos size %{public}zu, resquestId %{public}d", infos.size(), requestId);
|
||||
int32_t leftSize = static_cast<int32_t>(infos.size());
|
||||
int32_t time = 0;
|
||||
int32_t index = 0;
|
||||
while (leftSize >= 0) {
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption type = MessageOption::TF_SYNC;
|
||||
if (leftSize <= DATA_NUMBER_ONE_TIME) {
|
||||
type = MessageOption::TF_ASYNC;
|
||||
}
|
||||
MessageOption option(type);
|
||||
data.SetMaxCapacity(IPC_MEMORY_SIZE);
|
||||
|
||||
// when infos size is a multi of 800, do not send the last empty reply
|
||||
if (leftSize == 0 && time > 0) {
|
||||
return;
|
||||
}
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t flag = GetTransmitFlag(time, leftSize);
|
||||
if (!data.WriteInt32(flag)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t writeSize = (leftSize <= DATA_NUMBER_ONE_TIME) ? leftSize : DATA_NUMBER_ONE_TIME;
|
||||
if (!data.WriteInt32(writeSize)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < writeSize; ++i) {
|
||||
AccessibilityElementInfoParcel infoParcel(infos[index]);
|
||||
index++;
|
||||
if (!data.WriteParcelable(&infoParcel)) {
|
||||
HILOG_ERROR("accessibility element info failed index %{public}d", index);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(AccessibilityInterfaceCode::SET_RESULT_BY_ACCESSIBILITY_ID, data, reply, option)) {
|
||||
HILOG_ERROR("set search element info by accessibility id result failed");
|
||||
return;
|
||||
}
|
||||
|
||||
leftSize -= DATA_NUMBER_ONE_TIME;
|
||||
time++;
|
||||
if (static_cast<RetError>(reply.ReadInt32()) != RET_OK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityElementOperatorCallbackProxyTest::SetSearchElementInfoByTextResult(
|
||||
const std::vector<AccessibilityElementInfo> &infos, const int32_t requestId)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("connection write token failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(infos.size())) {
|
||||
HILOG_ERROR("write infos's size failed");
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto &info : infos) {
|
||||
AccessibilityElementInfoParcel infoParcel(info);
|
||||
if (!data.WriteParcelable(&infoParcel)) {
|
||||
HILOG_ERROR("write accessibility element info failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("connection write request id failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(AccessibilityInterfaceCode::SET_RESULT_BY_TEXT,
|
||||
data, reply, option)) {
|
||||
HILOG_ERROR("set search element info by text result failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityElementOperatorCallbackProxyTest::SetFindFocusedElementInfoResult(
|
||||
const AccessibilityElementInfo &info, const int32_t requestId)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
AccessibilityElementInfoParcel infoParcel(info);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("connection write token failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&infoParcel)) {
|
||||
HILOG_ERROR("connection write info failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("connection write request id failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(AccessibilityInterfaceCode::SET_RESULT_FOCUSED_INFO,
|
||||
data, reply, option)) {
|
||||
HILOG_ERROR("set find focused element info result failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityElementOperatorCallbackProxyTest::SetFocusMoveSearchResult(const AccessibilityElementInfo &info,
|
||||
const int32_t requestId)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
AccessibilityElementInfoParcel infoParcel(info);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("connection write token failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&infoParcel)) {
|
||||
HILOG_ERROR("connection write info failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("connection write requestId failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(AccessibilityInterfaceCode::SET_RESULT_FOCUS_MOVE,
|
||||
data, reply, option)) {
|
||||
HILOG_ERROR("set focus move search result failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityElementOperatorCallbackProxyTest::SetExecuteActionResult(const bool succeeded, const int32_t requestId)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("connection write token failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteBool(succeeded)) {
|
||||
HILOG_ERROR("connection write failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("connection write request id failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(AccessibilityInterfaceCode::SET_RESULT_PERFORM_ACTION,
|
||||
data, reply, option)) {
|
||||
HILOG_ERROR("set execute action result failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityElementOperatorCallbackProxyTest::SetCursorPositionResult(const int32_t cursorPosition,
|
||||
const int32_t requestId)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("connection write token failed");
|
||||
return;
|
||||
}
|
||||
HILOG_INFO(" [cursorPosition:%{public}d]", cursorPosition);
|
||||
if (!data.WriteInt32(cursorPosition)) {
|
||||
HILOG_ERROR("connection write failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("connection write request id failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(AccessibilityInterfaceCode::SET_RESULT_CURSOR_RESULT,
|
||||
data, reply, option)) {
|
||||
HILOG_ERROR("set cursor position result failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "accessibility_element_operator_callback_stub.h"
|
||||
#include "accessibility_element_info_parcel.h"
|
||||
#include "accessibility_ipc_interface_code.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel_util.h"
|
||||
|
||||
#define SWITCH_BEGIN(code) switch (code) {
|
||||
#define SWITCH_CASE(case_code, func) case case_code:\
|
||||
{\
|
||||
result_code = func(data, reply);\
|
||||
break;\
|
||||
}
|
||||
|
||||
#define SWITCH_END() default:\
|
||||
{\
|
||||
result_code = ERR_CODE_DEFAULT;\
|
||||
HILOG_WARN("AccessibilityElementOperatorCallbackStubTest::OnRemoteRequest, default case, need check."); \
|
||||
break;\
|
||||
}\
|
||||
}
|
||||
|
||||
#define ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_STUB_CASES() \
|
||||
SWITCH_CASE( \
|
||||
AccessibilityInterfaceCode::SET_RESULT_BY_ACCESSIBILITY_ID, HandleSetSearchElementInfoByAccessibilityIdResult)\
|
||||
SWITCH_CASE(AccessibilityInterfaceCode::SET_RESULT_BY_TEXT, HandleSetSearchElementInfoByTextResult)\
|
||||
SWITCH_CASE(AccessibilityInterfaceCode::SET_RESULT_FOCUSED_INFO, HandleSetFindFocusedElementInfoResult)\
|
||||
SWITCH_CASE(AccessibilityInterfaceCode::SET_RESULT_FOCUS_MOVE, HandleSetFocusMoveSearchResult)\
|
||||
SWITCH_CASE(AccessibilityInterfaceCode::SET_RESULT_PERFORM_ACTION, HandleSetExecuteActionResult)\
|
||||
SWITCH_CASE(AccessibilityInterfaceCode::SET_RESULT_CURSOR_RESULT, HandleSetCursorPositionResult)\
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
constexpr int32_t SINGLE_TRANSMIT = -2;
|
||||
constexpr int32_t MULTI_TRANSMIT_FINISH = -1;
|
||||
constexpr int32_t ERR_CODE_DEFAULT = -1000;
|
||||
|
||||
void StoreElementData::WriteData(std::vector<AccessibilityElementInfo> &infos)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
storeData_.insert(storeData_.end(), infos.begin(), infos.end());
|
||||
}
|
||||
|
||||
void StoreElementData::Clear()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
storeData_.clear();
|
||||
}
|
||||
|
||||
std::vector<AccessibilityElementInfo> StoreElementData::ReadData()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
return storeData_;
|
||||
}
|
||||
|
||||
size_t StoreElementData::Size()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
return storeData_.size();
|
||||
}
|
||||
|
||||
AccessibilityElementOperatorCallbackStubTest::AccessibilityElementOperatorCallbackStubTest()
|
||||
{
|
||||
}
|
||||
|
||||
StoreElementData AccessibilityElementOperatorCallbackStubTest::storeElementData;
|
||||
|
||||
AccessibilityElementOperatorCallbackStubTest::~AccessibilityElementOperatorCallbackStubTest()
|
||||
{
|
||||
}
|
||||
|
||||
int AccessibilityElementOperatorCallbackStubTest::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
HILOG_DEBUG("cmd = %{public}u, flags= %{public}d", code, option.GetFlags());
|
||||
std::u16string descriptor = AccessibilityElementOperatorCallbackStubTest::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (descriptor != remoteDescriptor) {
|
||||
HILOG_ERROR("AccessibilityElementOperatorCallbackStubTest::OnRemoteRequest"
|
||||
"local descriptor is not equal to remote");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
ErrCode result_code = ERR_NONE;
|
||||
SWITCH_BEGIN(code)
|
||||
ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_STUB_CASES()
|
||||
SWITCH_END()
|
||||
|
||||
if (result_code != ERR_CODE_DEFAULT) {
|
||||
return result_code;
|
||||
}
|
||||
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
ErrCode AccessibilityElementOperatorCallbackStubTest::HandleSetSearchElementInfoByAccessibilityIdResult(
|
||||
MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
int32_t flag = data.ReadInt32();
|
||||
if (flag == SINGLE_TRANSMIT || flag == 0) {
|
||||
storeElementData.Clear();
|
||||
}
|
||||
|
||||
int32_t accessibilityInfosize = data.ReadInt32();
|
||||
std::vector<AccessibilityElementInfo> tmpData;
|
||||
bool verifyResult = ContainerSecurityVerify(data, accessibilityInfosize, tmpData.max_size());
|
||||
if (!verifyResult || accessibilityInfosize < 0 || accessibilityInfosize > INT32_MAX) {
|
||||
return TRANSACTION_ERR;
|
||||
}
|
||||
for (int32_t i = 0; i < accessibilityInfosize; i++) {
|
||||
sptr<AccessibilityElementInfoParcel> accessibilityInfo =
|
||||
data.ReadStrongParcelable<AccessibilityElementInfoParcel>();
|
||||
if (accessibilityInfo == nullptr) {
|
||||
HILOG_ERROR("ReadStrongParcelable<accessibilityInfo> failed");
|
||||
storeElementData.Clear();
|
||||
reply.WriteInt32(RET_ERR_FAILED);
|
||||
return TRANSACTION_ERR;
|
||||
}
|
||||
tmpData.push_back(*accessibilityInfo);
|
||||
}
|
||||
|
||||
storeElementData.WriteData(tmpData); // get all data and push once
|
||||
int32_t requestId = data.ReadInt32();
|
||||
if (flag == SINGLE_TRANSMIT || flag == MULTI_TRANSMIT_FINISH) {
|
||||
reply.WriteInt32(0);
|
||||
HILOG_DEBUG("infos size %{public}zu, requestId %{public}d", storeElementData.Size(), requestId);
|
||||
SetSearchElementInfoByAccessibilityIdResult(storeElementData.ReadData(), requestId);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
reply.WriteInt32(0);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityElementOperatorCallbackStubTest::HandleSetSearchElementInfoByTextResult(
|
||||
MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
std::vector<AccessibilityElementInfo> infos {};
|
||||
int32_t accessibilityInfosize = data.ReadInt32();
|
||||
bool verifyResult = ContainerSecurityVerify(data, accessibilityInfosize, infos.max_size());
|
||||
if (!verifyResult || accessibilityInfosize < 0 || accessibilityInfosize > INT32_MAX) {
|
||||
return TRANSACTION_ERR;
|
||||
}
|
||||
for (int32_t i = 0; i < accessibilityInfosize; i++) {
|
||||
sptr<AccessibilityElementInfoParcel> accessibilityInfo =
|
||||
data.ReadStrongParcelable<AccessibilityElementInfoParcel>();
|
||||
if (accessibilityInfo == nullptr) {
|
||||
HILOG_ERROR("ReadStrongParcelable<accessibilityInfo> failed");
|
||||
return TRANSACTION_ERR;
|
||||
}
|
||||
infos.emplace_back(*accessibilityInfo);
|
||||
}
|
||||
int32_t requestId = data.ReadInt32();
|
||||
|
||||
SetSearchElementInfoByTextResult(infos, requestId);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityElementOperatorCallbackStubTest::HandleSetFindFocusedElementInfoResult(MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
sptr<AccessibilityElementInfoParcel> info = data.ReadStrongParcelable<AccessibilityElementInfoParcel>();
|
||||
if (info == nullptr) {
|
||||
HILOG_ERROR("ReadStrongParcelable<AccessibilityElementInfo> failed");
|
||||
return TRANSACTION_ERR;
|
||||
}
|
||||
|
||||
int32_t requestId = data.ReadInt32();
|
||||
|
||||
SetFindFocusedElementInfoResult(*info, requestId);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityElementOperatorCallbackStubTest::HandleSetFocusMoveSearchResult(MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
sptr<AccessibilityElementInfoParcel> info = data.ReadStrongParcelable<AccessibilityElementInfoParcel>();
|
||||
if (info == nullptr) {
|
||||
HILOG_ERROR("ReadStrongParcelable<AccessibilityElementInfo> failed");
|
||||
return TRANSACTION_ERR;
|
||||
}
|
||||
|
||||
int32_t requestId = data.ReadInt32();
|
||||
|
||||
SetFocusMoveSearchResult(*info, requestId);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityElementOperatorCallbackStubTest::HandleSetExecuteActionResult(MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
bool succeeded = data.ReadBool();
|
||||
int32_t requestId = data.ReadInt32();
|
||||
|
||||
SetExecuteActionResult(succeeded, requestId);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityElementOperatorCallbackStubTest::HandleSetCursorPositionResult(MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
int32_t cursorPosition = data.ReadInt32();
|
||||
int32_t requestId = data.ReadInt32();
|
||||
HILOG_INFO("[cursorPosition:%{public}d]", cursorPosition);
|
||||
SetCursorPositionResult(cursorPosition, requestId);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "accessibility_enable_ability_lists_observer_proxy.h"
|
||||
#include "accessibility_ipc_interface_code.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
AccessiAccessibilityEnableAbilityListsObserverProxyTestbilityElementOperatorCallbackStubTest::AccessiAccessibilityEnableAbilityListsObserverProxyTestbilityElementOperatorCallbackStubTest(
|
||||
const sptr<IRemoteObject> &impl) : IRemoteProxy<IAccessibilityEnableAbilityListsObserver>(impl)
|
||||
{}
|
||||
|
||||
AccessiAccessibilityEnableAbilityListsObserverProxyTestbilityElementOperatorCallbackStubTest::~AccessiAccessibilityEnableAbilityListsObserverProxyTestbilityElementOperatorCallbackStubTest()
|
||||
{}
|
||||
|
||||
bool AccessiAccessibilityEnableAbilityListsObserverProxyTestbilityElementOperatorCallbackStubTest::WriteInterfaceToken(MessageParcel &data)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
if (!data.WriteInterfaceToken(AccessiAccessibilityEnableAbilityListsObserverProxyTestbilityElementOperatorCallbackStubTest::GetDescriptor())) {
|
||||
HILOG_ERROR("write interface token failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccessiAccessibilityEnableAbilityListsObserverProxyTestbilityElementOperatorCallbackStubTest::OnAccessibilityEnableAbilityListsChanged()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC | MessageOption::TF_ASYNC_WAKEUP_LATER);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("write interface token failed");
|
||||
return;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("fail to send transact cmd due to remote object");
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t result = remote->SendRequest(static_cast<uint32_t>(
|
||||
AccessibilityInterfaceCode::ON_ACCESSIBILITY_ENABLE_ABILITY_LISTS_CHANGED),
|
||||
data, reply, option);
|
||||
if (result != NO_ERROR) {
|
||||
HILOG_ERROR("OnAccessibilityEnableAbilityListsChanged fail, error: %{public}d", result);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessiAccessibilityEnableAbilityListsObserverProxyTestbilityElementOperatorCallbackStubTest::OnAccessibilityInstallAbilityListsChanged()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC | MessageOption::TF_ASYNC_WAKEUP_LATER);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("write interface token failed");
|
||||
return;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("fail to send transact cmd due to remote object");
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t result = remote->SendRequest(static_cast<uint32_t>(
|
||||
AccessibilityInterfaceCode::ON_ACCESSIBILITY_INSTALL_ABILITY_LISTS_CHANGED),
|
||||
data, reply, option);
|
||||
if (result != NO_ERROR) {
|
||||
HILOG_ERROR("OnAccessibilityInstallAbilityListsChanged fail, error: %{public}d", result);
|
||||
}
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "accessibility_enable_ability_lists_observer_stub.h"
|
||||
#include "accessibility_ipc_interface_code.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
AccessibilityEnableAbilityListsObserverStubTest::AccessibilityEnableAbilityListsObserverStubTest()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
}
|
||||
|
||||
int AccessibilityEnableAbilityListsObserverStubTest::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
HILOG_DEBUG("cmd = %{public}d, flags = %{public}d", code, option.GetFlags());
|
||||
std::u16string descriptor = AccessibilityEnableAbilityListsObserverStubTest::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (descriptor != remoteDescriptor) {
|
||||
HILOG_INFO("local descriptor is not equal to remote");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (code == static_cast<uint32_t>(
|
||||
AccessibilityInterfaceCode::ON_ACCESSIBILITY_ENABLE_ABILITY_LISTS_CHANGED)) {
|
||||
return HandleOnAccessibilityEnableAbilityListsChanged(data, reply);
|
||||
}
|
||||
if (code == static_cast<uint32_t>(
|
||||
AccessibilityInterfaceCode::ON_ACCESSIBILITY_INSTALL_ABILITY_LISTS_CHANGED)) {
|
||||
return HandleOnAccessibilityInstallAbilityListsChanged(data, reply);
|
||||
}
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
ErrCode AccessibilityEnableAbilityListsObserverStubTest::HandleOnAccessibilityEnableAbilityListsChanged(
|
||||
MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
OnAccessibilityEnableAbilityListsChanged();
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityEnableAbilityListsObserverStubTest::HandleOnAccessibilityInstallAbilityListsChanged(
|
||||
MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
OnAccessibilityInstallAbilityListsChanged();
|
||||
return NO_ERROR;
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "accessibility_event_info_parcel.h"
|
||||
#include "accessibility_element_info_parcel.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
AccessibilityEventInfoParcelTest::AccessibilityEventInfoParcelTest(const AccessibilityEventInfo &eventInfo)
|
||||
: AccessibilityEventInfo(eventInfo)
|
||||
{
|
||||
}
|
||||
|
||||
bool AccessibilityEventInfoParcelTest::ReadFromParcelFirstPart(Parcel &parcel)
|
||||
{
|
||||
uint32_t eventType = TYPE_VIEW_INVALID;
|
||||
uint32_t gestureType = GESTURE_INVALID;
|
||||
int32_t triggerAction = ACCESSIBILITY_ACTION_INVALID;
|
||||
int32_t textMoveStep = STEP_CHARACTER;
|
||||
int32_t windowContentChangeTypes = CONTENT_CHANGE_TYPE_INVALID;
|
||||
int32_t windowChangeTypes = WINDOW_UPDATE_INVALID;
|
||||
int32_t category = CATEGORY_INVALID;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, eventType);
|
||||
eventType_ = static_cast<EventType>(eventType);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, gestureType);
|
||||
gestureType_ = static_cast<GestureType>(gestureType);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, triggerAction);
|
||||
triggerAction_ = static_cast<ActionType>(triggerAction);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, timeStamp_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, textMoveStep);
|
||||
textMoveStep_ = static_cast<TextMoveUnit>(textMoveStep);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowContentChangeTypes);
|
||||
windowContentChangeTypes_ = static_cast<WindowsContentChangeTypes>(windowContentChangeTypes);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowChangeTypes);
|
||||
windowChangeTypes_ = static_cast<WindowUpdateType>(windowChangeTypes);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, category);
|
||||
category_ = static_cast<NotificationCategory>(category);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, pageId_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityEventInfoParcelTest::ReadFromParcelSecondPart(Parcel &parcel)
|
||||
{
|
||||
int64_t componentId = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, componentId);
|
||||
SetSource(componentId);
|
||||
int32_t windowId = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowId);
|
||||
SetWindowId(windowId);
|
||||
int32_t currentIndex = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, currentIndex);
|
||||
SetCurrentIndex(currentIndex);
|
||||
int32_t beginIndex = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, beginIndex);
|
||||
SetBeginIndex(beginIndex);
|
||||
int32_t endIndex = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, endIndex);
|
||||
SetEndIndex(endIndex);
|
||||
int32_t contentSize = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, contentSize);
|
||||
std::string content;
|
||||
if (!ContainerSecurityVerify(parcel, contentSize, contents_.max_size())) {
|
||||
return false;
|
||||
}
|
||||
for (auto i = 0 ; i < contentSize; i++) {
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, content);
|
||||
AddContent(content);
|
||||
}
|
||||
std::string componentType;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, componentType);
|
||||
SetComponentType(componentType);
|
||||
std::string description;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, description);
|
||||
SetDescription(description);
|
||||
std::string beforeText;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, beforeText);
|
||||
SetBeforeText(beforeText);
|
||||
std::string latestConent;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, latestConent);
|
||||
SetLatestContent(latestConent);
|
||||
int64_t elementId = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, elementId);
|
||||
|
||||
int32_t itemCounts = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, itemCounts);
|
||||
SetItemCounts(itemCounts);
|
||||
sptr<AccessibilityElementInfoParcel> elementInfoParcel =
|
||||
parcel.ReadStrongParcelable<AccessibilityElementInfoParcel>();
|
||||
if (elementInfoParcel == nullptr) {
|
||||
HILOG_ERROR("ReadStrongParcelable elementInfo failed.");
|
||||
return false;
|
||||
}
|
||||
SetElementInfo(*elementInfoParcel);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityEventInfoParcelTest::ReadFromParcelThirdPart(Parcel &parcel)
|
||||
{
|
||||
std::string textAnnouncedForAccessibility;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, textAnnouncedForAccessibility);
|
||||
SetTextAnnouncedForAccessibility(textAnnouncedForAccessibility);
|
||||
|
||||
std::string inspectorKey;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, inspectorKey);
|
||||
SetInspectorKey(inspectorKey);
|
||||
|
||||
int32_t requestFocusElementId = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, requestFocusElementId);
|
||||
SetRequestFocusElementId(requestFocusElementId);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityEventInfoParcelTest::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
if (!ReadFromParcelFirstPart(parcel)) {
|
||||
return false;
|
||||
}
|
||||
if (!ReadFromParcelSecondPart(parcel)) {
|
||||
return false;
|
||||
}
|
||||
if (!ReadFromParcelThirdPart(parcel)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityEventInfoParcelTest::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, static_cast<uint32_t>(eventType_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, static_cast<uint32_t>(gestureType_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(triggerAction_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, timeStamp_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(textMoveStep_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(windowContentChangeTypes_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(windowChangeTypes_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(category_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, pageId_);
|
||||
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, GetViewId());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetWindowId());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetCurrentIndex());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetBeginIndex());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetEndIndex());
|
||||
auto contentList = GetContentList();
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, contentList.size());
|
||||
for (auto &content : contentList) {
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, content);
|
||||
}
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, GetComponentType());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, GetDescription());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, GetBeforeText());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, GetLatestContent());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, GetAccessibilityId());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetItemCounts());
|
||||
AccessibilityElementInfoParcel elementInfoParcel(elementInfo_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &elementInfoParcel);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, GetTextAnnouncedForAccessibility());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, GetInspectorKey());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetRequestFocusElementId());
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<AccessibilityEventInfoParcelTest> AccessibilityEventInfoParcelTest::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sptr<AccessibilityEventInfoParcelTest> accessibilityEventInfo = new(std::nothrow) AccessibilityEventInfoParcelTest();
|
||||
if (accessibilityEventInfo == nullptr) {
|
||||
HILOG_ERROR("Failed to create accessibilityEventInfo.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!accessibilityEventInfo->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("read from parcel failed");
|
||||
return nullptr;
|
||||
}
|
||||
return accessibilityEventInfo;
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "accessibility_gesture_inject_path_parcel.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
AccessibilityGestureInjectPathParcelTest::AccessibilityGestureInjectPathParcelTest(
|
||||
const AccessibilityGestureInjectPath &gesturePath)
|
||||
: AccessibilityGestureInjectPath(gesturePath)
|
||||
{
|
||||
}
|
||||
|
||||
bool AccessibilityGestureInjectPathParcelTest::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, durationTime_);
|
||||
int32_t positionSize = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, positionSize);
|
||||
bool verifyResult = ContainerSecurityVerify(parcel, positionSize, positions_.max_size());
|
||||
if (!verifyResult || positionSize < 0 || positionSize > INT32_MAX) {
|
||||
return false;
|
||||
}
|
||||
for (auto i = 0; i < positionSize; i++) {
|
||||
AccessibilityGesturePosition position;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Float, parcel, position.positionX_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Float, parcel, position.positionY_);
|
||||
AddPosition(position);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityGestureInjectPathParcelTest::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, durationTime_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, positions_.size());
|
||||
for (auto &position : positions_) {
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Float, parcel, position.positionX_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Float, parcel, position.positionY_);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<AccessibilityGestureInjectPathParcelTest> AccessibilityGestureInjectPathParcelTest::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
sptr<AccessibilityGestureInjectPathParcelTest> path = new(std::nothrow) AccessibilityGestureInjectPathParcelTest();
|
||||
if (path == nullptr) {
|
||||
HILOG_ERROR("Failed to create path.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!path->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("ReadFromParcel AccessibilityGestureInjectPathParcelTest failed.");
|
||||
path = nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "accessibility_window_info_parcel.h"
|
||||
#include "accessibility_element_info_parcel.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
AccessibilityWindowInfoParcelTest::AccessibilityWindowInfoParcelTest(const AccessibilityWindowInfo &accessibilityWindowInfo)
|
||||
: AccessibilityWindowInfo(accessibilityWindowInfo)
|
||||
{
|
||||
}
|
||||
|
||||
bool AccessibilityWindowInfoParcelTest::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
int32_t accessibilityWindowType = TYPE_WINDOW_INVALID;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, accessibilityWindowType);
|
||||
accessibilityWindowType_ = static_cast<AccessibilityWindowType>(accessibilityWindowType);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, windowType_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, windowMode_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowLayer_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, active_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, focused_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityFocused_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isDecorEnable_);
|
||||
sptr<RectParcel> boundsInScreen = parcel.ReadStrongParcelable<RectParcel>();
|
||||
if (boundsInScreen == nullptr) {
|
||||
HILOG_ERROR("ReadStrongParcelable boundsInScreen failed.");
|
||||
return false;
|
||||
}
|
||||
boundsInScreen_ = *boundsInScreen;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityWindowInfoParcelTest::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(accessibilityWindowType_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, windowType_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, windowMode_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowLayer_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, active_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, focused_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityFocused_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isDecorEnable_);
|
||||
RectParcel rectParcel(boundsInScreen_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &rectParcel);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
sptr<AccessibilityWindowInfoParcelTest> AccessibilityWindowInfoParcelTest::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
sptr<AccessibilityWindowInfoParcelTest> info = new(std::nothrow) AccessibilityWindowInfoParcelTest();
|
||||
if (info == nullptr) {
|
||||
HILOG_ERROR("Failed to create info.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!info->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("ReadFromParcel failed.");
|
||||
info = nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
Loading…
x
Reference in New Issue
Block a user