mirror of
https://github.com/openharmony/accessibility.git
synced 2026-08-25 11:51:38 -04:00
corresponding to d.ts,change gesture injection processing
Signed-off-by: Mupceet <laiguizhong@huawei.com>
This commit is contained in:
@@ -61,7 +61,6 @@
|
||||
"name": "//foundation/barrierfree/accessibility/interfaces/innerkits/aafwk:accessibleability",
|
||||
"header": {
|
||||
"header_files": [
|
||||
"accessibility_gesture_result_listener.h",
|
||||
"accessibility_ui_test_ability.h",
|
||||
"accessible_ability_client.h",
|
||||
"accessible_ability_listener.h"
|
||||
|
||||
@@ -76,14 +76,10 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Sends simulate gestures to the screen.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param gesturePath The gesture which need to send.
|
||||
* @param listener The listener of the gesture.
|
||||
* @return Return true if the gesture sends successfully, else return false.
|
||||
*/
|
||||
virtual bool InjectGesture(const uint32_t sequence,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath,
|
||||
const std::shared_ptr<AccessibilityGestureResultListener>& listener) override;
|
||||
virtual bool InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains elementInfo of the accessible root node.
|
||||
|
||||
@@ -64,11 +64,10 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Send simulate gesture to aams.
|
||||
* @param sequenceNum The sequence of gesture.
|
||||
* @param gesturePath The path of gesture.
|
||||
* @return Return true if gesture injection is successfully, otherwise return false.
|
||||
*/
|
||||
void SendSimulateGesture(const int32_t sequenceNum,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath);
|
||||
bool SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath);
|
||||
|
||||
/**
|
||||
* @brief execute the action on the component.
|
||||
|
||||
@@ -80,14 +80,6 @@ public:
|
||||
*/
|
||||
virtual void OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int32_t sequence) override;
|
||||
|
||||
/**
|
||||
* @brief Called when need to notify the result of simulation gesture.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param completedSuccessfully The result of gesture completion.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnGestureInjectResult(const int32_t sequence, const bool completedSuccessfully) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains elementInfo of focus.
|
||||
* @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
|
||||
@@ -108,14 +100,10 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Sends simulate gestures to the screen.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param gesturePath The gesture which need to send.
|
||||
* @param listener The listener of the gesture.
|
||||
* @return Return true if the gesture sends successfully, else return false.
|
||||
*/
|
||||
virtual bool InjectGesture(const uint32_t sequence,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath,
|
||||
const std::shared_ptr<AccessibilityGestureResultListener> &listener) override;
|
||||
virtual bool InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains elementInfo of the accessible root node.
|
||||
@@ -282,19 +270,10 @@ private:
|
||||
AccessibleAbilityClientImpl &client_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Dispatch the result of simulate gesture.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param result The result of gesture completion.
|
||||
* @return
|
||||
*/
|
||||
void DispatchGestureInjectResult(uint32_t sequence, bool result);
|
||||
|
||||
sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr;
|
||||
sptr<IAccessibleAbilityManagerService> serviceProxy_ = nullptr;
|
||||
std::shared_ptr<AccessibleAbilityListener> listener_ = nullptr;
|
||||
std::shared_ptr<AccessibleAbilityChannelClient> channelClient_ = nullptr;
|
||||
std::map<uint32_t, std::shared_ptr<AccessibilityGestureResultListener>> gestureResultListenerInfos_;
|
||||
};
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -129,9 +129,7 @@ bool AccessibilityUITestAbilityImpl::GetFocusByElementInfo(const AccessibilityEl
|
||||
return aaClient->GetFocusByElementInfo(sourceInfo, focusType, elementInfo);
|
||||
}
|
||||
|
||||
bool AccessibilityUITestAbilityImpl::InjectGesture(const uint32_t sequence,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath,
|
||||
const std::shared_ptr<AccessibilityGestureResultListener> &listener)
|
||||
bool AccessibilityUITestAbilityImpl::InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath)
|
||||
{
|
||||
HILOG_INFO();
|
||||
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
|
||||
@@ -139,7 +137,7 @@ bool AccessibilityUITestAbilityImpl::InjectGesture(const uint32_t sequence,
|
||||
HILOG_ERROR("aaClient is nullptr");
|
||||
return false;
|
||||
}
|
||||
return aaClient->InjectGesture(sequence, gesturePath, listener);
|
||||
return aaClient->InjectGesture(gesturePath);
|
||||
}
|
||||
|
||||
bool AccessibilityUITestAbilityImpl::GetRoot(AccessibilityElementInfo &elementInfo)
|
||||
|
||||
@@ -96,14 +96,15 @@ bool AccessibleAbilityChannelClient::FindFocusedElementInfo(int32_t accessibilit
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccessibleAbilityChannelClient::SendSimulateGesture(const int32_t sequenceNum,
|
||||
bool AccessibleAbilityChannelClient::SendSimulateGesture(
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath)
|
||||
{
|
||||
HILOG_INFO("[channelId:%{public}d]", channelId_);
|
||||
if (proxy_) {
|
||||
proxy_->SendSimulateGesture(sequenceNum, gesturePath);
|
||||
return proxy_->SendSimulateGesture(gesturePath);
|
||||
} else {
|
||||
HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -170,16 +170,6 @@ void AccessibleAbilityClientImpl::OnKeyPressEvent(const MMI::KeyEvent &keyEvent,
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientImpl::OnGestureInjectResult(const int32_t sequence, const bool completedSuccessfully)
|
||||
{
|
||||
HILOG_INFO("sequence[%{public}d] completedSuccessfully[%{public}d]", sequence, completedSuccessfully);
|
||||
if (!channelClient_) {
|
||||
HILOG_ERROR("The channel is invalid.");
|
||||
return;
|
||||
}
|
||||
DispatchGestureInjectResult(sequence, completedSuccessfully);
|
||||
}
|
||||
|
||||
bool AccessibleAbilityClientImpl::GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo)
|
||||
{
|
||||
HILOG_INFO("focusType[%{public}d]", focusType);
|
||||
@@ -219,11 +209,9 @@ bool AccessibleAbilityClientImpl::GetFocusByElementInfo(const AccessibilityEleme
|
||||
return channelClient_->FindFocusedElementInfo(windowId, elementId, focusType, elementInfo);
|
||||
}
|
||||
|
||||
bool AccessibleAbilityClientImpl::InjectGesture(const uint32_t sequence,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath,
|
||||
const std::shared_ptr<AccessibilityGestureResultListener> &listener)
|
||||
bool AccessibleAbilityClientImpl::InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath)
|
||||
{
|
||||
HILOG_INFO("sequence[%{public}d]", sequence);
|
||||
HILOG_INFO();
|
||||
|
||||
if (!gesturePath) {
|
||||
HILOG_ERROR("The gesturePath is null.");
|
||||
@@ -242,12 +230,7 @@ bool AccessibleAbilityClientImpl::InjectGesture(const uint32_t sequence,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (listener) {
|
||||
gestureResultListenerInfos_.insert(make_pair(sequence, listener));
|
||||
}
|
||||
|
||||
channelClient_->SendSimulateGesture(sequence, gesturePath);
|
||||
return true;
|
||||
return channelClient_->SendSimulateGesture(gesturePath);
|
||||
}
|
||||
|
||||
bool AccessibleAbilityClientImpl::GetRoot(AccessibilityElementInfo &elementInfo)
|
||||
@@ -559,31 +542,5 @@ void AccessibleAbilityClientImpl::ResetAAClient(const wptr<IRemoteObject> &remot
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientImpl::DispatchGestureInjectResult(uint32_t sequence, bool result)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
if (gestureResultListenerInfos_.empty()) {
|
||||
HILOG_ERROR("There is no information of gestureResultListener");
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<AccessibilityGestureResultListener> gestureResultListener = nullptr;
|
||||
auto it = gestureResultListenerInfos_.find(sequence);
|
||||
if (it != gestureResultListenerInfos_.end()) {
|
||||
HILOG_DEBUG("gestureResultListenerInfo has been found.");
|
||||
gestureResultListener = gestureResultListenerInfos_[sequence];
|
||||
gestureResultListenerInfos_.erase(it);
|
||||
}
|
||||
|
||||
if (!gestureResultListener) {
|
||||
HILOG_ERROR("There is no gestureResultListenerInfo in gestureResultListenerInfos_[%{public}d", sequence);
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("sequence[%{public}d] result[%{public}d]", sequence, result);
|
||||
gestureResultListener->OnGestureInjectResult(sequence, result);
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
@@ -47,9 +47,7 @@ public:
|
||||
MOCK_METHOD1(ExecuteCommonAction, bool(const int32_t action));
|
||||
|
||||
MOCK_METHOD2(SetOnKeyPressEventResult, void(const bool handled, const int32_t sequence));
|
||||
MOCK_METHOD2(
|
||||
SendSimulateGesture, void(const int32_t sequenceNum,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
|
||||
MOCK_METHOD1(SendSimulateGesture, bool(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
|
||||
};
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -47,8 +47,7 @@ public:
|
||||
MOCK_METHOD2(GetWindowsByDisplayId, bool(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows));
|
||||
MOCK_METHOD1(ExecuteCommonAction, bool(const int32_t action));
|
||||
MOCK_METHOD2(SetOnKeyPressEventResult, void(const bool handled, const int32_t sequence));
|
||||
MOCK_METHOD2(SendSimulateGesture, void(const int32_t sequenceNum,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
|
||||
MOCK_METHOD1(SendSimulateGesture, bool(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
|
||||
MOCK_METHOD1(SetEventTypeFilter, bool(const uint32_t filter));
|
||||
MOCK_METHOD1(SetTargetBundleName, bool(const std::vector<std::string> &targetBundleNames));
|
||||
};
|
||||
|
||||
@@ -124,11 +124,11 @@ void AccessibleAbilityChannelProxy::SetOnKeyPressEventResult(const bool handled,
|
||||
(void)sequence;
|
||||
}
|
||||
|
||||
void AccessibleAbilityChannelProxy::SendSimulateGesture(const int32_t sequenceNum,
|
||||
bool AccessibleAbilityChannelProxy::SendSimulateGesture(
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
{
|
||||
(void)sequenceNum;
|
||||
(void)gesturePath;
|
||||
return true;
|
||||
}
|
||||
|
||||
MockAccessibleAbilityChannelProxy::MockAccessibleAbilityChannelProxy(const sptr<IRemoteObject>& object)
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace Accessibility {
|
||||
namespace {
|
||||
const std::string TEST = "test";
|
||||
constexpr int32_t FOCUS_TYPE = 1;
|
||||
constexpr uint32_t SEQUENCE = 1;
|
||||
} // namespace
|
||||
|
||||
class AccessibilityUITestAbilityImplTest : public ::testing::Test {
|
||||
@@ -171,8 +170,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, InjectGesture_001, TestSize.Level1)
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
|
||||
std::shared_ptr<AccessibilityGestureResultListener> listener = nullptr;
|
||||
EXPECT_FALSE(instance_->InjectGesture(SEQUENCE, gesturePath, listener));
|
||||
EXPECT_FALSE(instance_->InjectGesture(gesturePath));
|
||||
|
||||
GTEST_LOG_(INFO) << "InjectGesture_001 end";
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace {
|
||||
constexpr int32_t SEQUENCE = 1;
|
||||
constexpr int32_t ACCESSIBILITY_WINDOW_ID = 1;
|
||||
constexpr int32_t FOCUS_TYPE = 1;
|
||||
constexpr int32_t SEQUENCE_NUM = 1;
|
||||
constexpr int32_t ELEMENT_ID = 1;
|
||||
constexpr int32_t ACTION = 1;
|
||||
constexpr int32_t DIRECTION = 1;
|
||||
@@ -120,7 +119,7 @@ HWTEST_F(AccessibleAbilityChannelClientTest, SendSimulateGesture_001, TestSize.L
|
||||
}
|
||||
|
||||
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
|
||||
instance_->SendSimulateGesture(SEQUENCE_NUM, gesturePath);
|
||||
instance_->SendSimulateGesture(gesturePath);
|
||||
GTEST_LOG_(INFO) << "SendSimulateGesture_001 end";
|
||||
}
|
||||
|
||||
|
||||
@@ -107,30 +107,6 @@ HWTEST_F(AccessibleAbilityClientImplTest, OnAccessibilityEvent_001, TestSize.Lev
|
||||
GTEST_LOG_(INFO) << "OnAccessibilityEvent_001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: OnGestureInjectResult_001
|
||||
* @tc.name: OnGestureInjectResult
|
||||
* @tc.desc: Test function OnGestureInjectResult
|
||||
*/
|
||||
HWTEST_F(AccessibleAbilityClientImplTest, OnGestureInjectResult_001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "OnGestureInjectResult_001 start";
|
||||
std::shared_ptr<AccessibleAbilityListener> listener = std::make_shared<MockAccessibleAbilityListener>();
|
||||
instance_->RegisterAbilityListener(listener);
|
||||
|
||||
sptr<MockAccessibleAbilityChannelStub> stub = new MockAccessibleAbilityChannelStub();
|
||||
sptr<IAccessibleAbilityChannel> channel = new MockAccessibleAbilityChannelProxy(stub->AsObject());
|
||||
|
||||
int32_t channelId = 1;
|
||||
instance_->Init(channel, channelId);
|
||||
if (!instance_) {
|
||||
GTEST_LOG_(INFO) << "Cann't get AccessibleAbilityClientImpl instance_";
|
||||
return;
|
||||
}
|
||||
instance_->OnGestureInjectResult(SEQUENCE, true);
|
||||
GTEST_LOG_(INFO) << "OnGestureInjectResult_001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetFocus_001
|
||||
* @tc.name: GetFocus
|
||||
@@ -254,8 +230,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_001, TestSize.Level1)
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
|
||||
std::shared_ptr<AccessibilityGestureResultListener> listener = nullptr;
|
||||
EXPECT_FALSE(instance_->InjectGesture(SEQUENCE, gesturePath, listener));
|
||||
EXPECT_FALSE(instance_->InjectGesture(gesturePath));
|
||||
|
||||
GTEST_LOG_(INFO) << "InjectGesture_001 end";
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef ACCESSIBILITY_GESTURE_RESULT_LISTENER_H
|
||||
#define ACCESSIBILITY_GESTURE_RESULT_LISTENER_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
class AccessibilityGestureResultListener {
|
||||
public:
|
||||
/**
|
||||
* @brief Destruct
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual ~AccessibilityGestureResultListener() = default;
|
||||
|
||||
/**
|
||||
* @brief Called when the gesture is finished.
|
||||
* @param sequence
|
||||
* @param result Return true if the gesture which is listened is injected successfully, else return false.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnGestureInjectResult(uint32_t sequence, bool result) = 0;
|
||||
};
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif // ACCESSIBILITY_GESTURE_RESULT_LISTENER_H
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include "accessibility_gesture_inject_path.h"
|
||||
#include "accessibility_gesture_result_listener.h"
|
||||
#include "accessibility_window_info.h"
|
||||
#include "accessible_ability_listener.h"
|
||||
|
||||
@@ -80,14 +79,10 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Sends simulate gestures to the screen.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param gesturePath The gesture which need to send.
|
||||
* @param listener The listener of the gesture.
|
||||
* @return Return true if the gesture sends successfully, else return false.
|
||||
*/
|
||||
virtual bool InjectGesture(const uint32_t sequence,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath,
|
||||
const std::shared_ptr<AccessibilityGestureResultListener> &listener) = 0;
|
||||
virtual bool InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath) = 0;
|
||||
|
||||
/**
|
||||
* @brief Obtains elementInfo of the accessible root node.
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "accessibility_element_info.h"
|
||||
#include "accessibility_event_info.h"
|
||||
#include "accessibility_gesture_inject_path.h"
|
||||
#include "accessibility_gesture_result_listener.h"
|
||||
#include "accessibility_window_info.h"
|
||||
#include "accessible_ability_listener.h"
|
||||
#include "iremote_object.h"
|
||||
@@ -71,14 +70,10 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Sends simulate gestures to the screen.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param gesturePath The gesture which need to send.
|
||||
* @param listener The listener of the gesture.
|
||||
* @return Return true if the gesture sends successfully, else return false.
|
||||
*/
|
||||
virtual bool InjectGesture(const uint32_t sequence,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath,
|
||||
const std::shared_ptr<AccessibilityGestureResultListener> &listener) = 0;
|
||||
virtual bool InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath) = 0;
|
||||
|
||||
/**
|
||||
* @brief Obtains elementInfo of the accessible root node.
|
||||
|
||||
@@ -1446,8 +1446,7 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Get content list
|
||||
* @param contentList Outgoing parameter
|
||||
* The list of content
|
||||
* @param contentList(out) The list of content
|
||||
* @return -
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
|
||||
+1
-12
@@ -52,12 +52,6 @@ namespace {
|
||||
std::promise<void> complete_;
|
||||
};
|
||||
|
||||
class AccessibilityGestureResultListenerForBenchmark : public AccessibilityGestureResultListener {
|
||||
public:
|
||||
virtual ~AccessibilityGestureResultListenerForBenchmark() = default;
|
||||
void OnGestureInjectResult(uint32_t sequence, bool result) override {}
|
||||
};
|
||||
|
||||
class AccessibleAbilityClientTest : public benchmark::Fixture {
|
||||
public:
|
||||
AccessibleAbilityClientTest()
|
||||
@@ -174,19 +168,14 @@ namespace {
|
||||
BENCHMARK_F(AccessibleAbilityClientTest, InjectGestureTestCase)(
|
||||
benchmark::State &state)
|
||||
{
|
||||
uint32_t sequence = 0;
|
||||
while (state.KeepRunning()) {
|
||||
sequence++;
|
||||
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath =
|
||||
std::make_shared<AccessibilityGestureInjectPath>();
|
||||
int64_t durationTime = 20;
|
||||
gesturePath->SetDurationTime(durationTime);
|
||||
AccessibilityGesturePosition position = {200.0f, 200.0f};
|
||||
gesturePath->AddPosition(position);
|
||||
|
||||
std::shared_ptr<AccessibilityGestureResultListenerForBenchmark> listener =
|
||||
std::make_shared<AccessibilityGestureResultListenerForBenchmark>();
|
||||
AccessibilityUITestAbility::GetInstance()->InjectGesture(sequence, gesturePath, listener);
|
||||
AccessibilityUITestAbility::GetInstance()->InjectGesture(gesturePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-3
@@ -36,9 +36,14 @@ export default class AccessibilityExtensionContext extends ExtensionContext {
|
||||
getWindows(callback: AsyncCallback<Array<AccessibilityElement>>): void;
|
||||
getWindows(displayId: number, callback: AsyncCallback<Array<AccessibilityElement>>): void;
|
||||
getWindows(displayId?: number): Promise<Array<AccessibilityElement>>;
|
||||
|
||||
gestureInject(gesturePath: GesturePath, listener: Callback<boolean>, callback: AsyncCallback<boolean>): void;
|
||||
gestureInject(gesturePath: GesturePath, listener: Callback<boolean>): Promise<boolean>;
|
||||
/**
|
||||
* Inject gesture path events.
|
||||
* @param gesturePath Indicates the gesture path.
|
||||
* @param listener It is used to receive the result of gesture injection,
|
||||
* true means success, otherwise means failure.
|
||||
*/
|
||||
injectGesture(gesturePath: GesturePath): Promise<void>;
|
||||
injectGesture(gesturePath: GesturePath, callback: AsyncCallback<void>): void;
|
||||
}
|
||||
|
||||
declare interface AccessibilityElement {
|
||||
|
||||
+3
-3
@@ -50,9 +50,9 @@ class AccessibilityExtensionContext extends ExtensionContext {
|
||||
return this.__context_impl__.executeCommonAction(action, callback);
|
||||
}
|
||||
|
||||
gestureInject(gesture, listener, callback) {
|
||||
console.log('gestureInject');
|
||||
return this.__context_impl__.gestureInject(gesture, listener, callback);
|
||||
injectGesture(gesture, callback) {
|
||||
console.log('injectGesture');
|
||||
return this.__context_impl__.injectGesture(gesture, callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-10
@@ -21,7 +21,6 @@
|
||||
#include "accessibility_element_info.h"
|
||||
#include "accessibility_event_info.h"
|
||||
#include "accessibility_gesture_inject_path.h"
|
||||
#include "accessibility_gesture_result_listener.h"
|
||||
#include "accessibility_window_info.h"
|
||||
#include "extension_context.h"
|
||||
|
||||
@@ -52,24 +51,17 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Sends simulate gestures to the screen.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param gesturePath The gesture which need to send.
|
||||
* @param listener The listener of the gesture.
|
||||
* @return Return true if the gesture sends successfully, else return false.
|
||||
*/
|
||||
bool InjectGesture(const uint32_t sequence, const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath,
|
||||
const std::shared_ptr<AccessibilityGestureResultListener> &listener);
|
||||
bool InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath);
|
||||
|
||||
/**
|
||||
* @brief Sends simulate gestures to the screen.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param gesturePaths The gesture which need to send.
|
||||
* @param listener The listener of the gesture.
|
||||
* @return Return true if the gesture sends successfully, else return false.
|
||||
*/
|
||||
bool InjectGesture(const uint32_t sequence,
|
||||
const std::vector<std::shared_ptr<AccessibilityGestureInjectPath>> &gesturePaths,
|
||||
const std::shared_ptr<AccessibilityGestureResultListener> &listener);
|
||||
bool InjectGesture(const std::vector<std::shared_ptr<AccessibilityGestureInjectPath>> &gesturePaths);
|
||||
|
||||
/**
|
||||
* @brief Obtains elementInfo of the accessible root node.
|
||||
|
||||
-18
@@ -17,7 +17,6 @@
|
||||
#define NAPI_ACCESSIBILITY_EXTENSION_CONTEXT_H
|
||||
|
||||
#include "accessibility_extension_context.h"
|
||||
#include "accessibility_gesture_result_listener.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "native_engine/native_engine.h"
|
||||
@@ -26,25 +25,8 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
class NAccessibilityGestureResultListener : public AccessibilityGestureResultListener {
|
||||
public:
|
||||
NAccessibilityGestureResultListener() = default;
|
||||
virtual ~NAccessibilityGestureResultListener() = default;
|
||||
|
||||
void OnGestureInjectResult(uint32_t sequence, bool result) override;
|
||||
};
|
||||
|
||||
struct NAccessibilityGestureResultListenerInfo {
|
||||
napi_env env_;
|
||||
napi_ref callback_;
|
||||
std::shared_ptr<AccessibilityGestureResultListener> listener_ = nullptr;
|
||||
};
|
||||
|
||||
NativeValue* CreateJsAccessibilityExtensionContext(
|
||||
NativeEngine& engine, std::shared_ptr<AccessibilityExtensionContext> context);
|
||||
|
||||
static uint32_t gestureInjectSequence = 0;
|
||||
static std::map<uint32_t, std::shared_ptr<NAccessibilityGestureResultListenerInfo>> jsGestureResultListenerInfos {};
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif // NAPI_ACCESSIBILITY_EXTENSION_CONTEXT_H
|
||||
+4
-7
@@ -44,9 +44,7 @@ bool AccessibilityExtensionContext::GetFocusByElementInfo(const AccessibilityEle
|
||||
return aaClient->GetFocusByElementInfo(sourceInfo, focusType, elementInfo);
|
||||
}
|
||||
|
||||
bool AccessibilityExtensionContext::InjectGesture(const uint32_t sequence,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath,
|
||||
const std::shared_ptr<AccessibilityGestureResultListener> &listener)
|
||||
bool AccessibilityExtensionContext::InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
|
||||
@@ -54,12 +52,11 @@ bool AccessibilityExtensionContext::InjectGesture(const uint32_t sequence,
|
||||
HILOG_ERROR("aaClient is nullptr");
|
||||
return false;
|
||||
}
|
||||
return aaClient->InjectGesture(sequence, gesturePath, listener);
|
||||
return aaClient->InjectGesture(gesturePath);
|
||||
}
|
||||
|
||||
bool AccessibilityExtensionContext::InjectGesture(const uint32_t sequence,
|
||||
const std::vector<std::shared_ptr<AccessibilityGestureInjectPath>> &gesturePaths,
|
||||
const std::shared_ptr<AccessibilityGestureResultListener> &listener)
|
||||
bool AccessibilityExtensionContext::InjectGesture(
|
||||
const std::vector<std::shared_ptr<AccessibilityGestureInjectPath>> &gesturePaths)
|
||||
{
|
||||
HILOG_DEBUG("This method is temporarily not implemented!");
|
||||
return false;
|
||||
|
||||
+7
-87
@@ -536,7 +536,7 @@ private:
|
||||
{
|
||||
HILOG_INFO();
|
||||
// Only support two or three params
|
||||
if (info.argc != ARGS_SIZE_TWO && info.argc != ARGS_SIZE_THREE) {
|
||||
if (info.argc != ARGS_SIZE_ONE && info.argc != ARGS_SIZE_TWO) {
|
||||
HILOG_ERROR("Not enough params");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
@@ -550,25 +550,8 @@ private:
|
||||
ConvertGesturePathsJSToNAPI(reinterpret_cast<napi_env>(&engine), nGesturePaths,
|
||||
gesturePath, gesturePathArray, isParameterArray);
|
||||
|
||||
// Unwrap callback
|
||||
if (info.argv[PARAM1]->TypeOf() != NATIVE_FUNCTION) {
|
||||
HILOG_ERROR("The type of params is %{public}d.", info.argv[PARAM1]->TypeOf());
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
// Create callback info
|
||||
std::shared_ptr<NAccessibilityGestureResultListenerInfo> pCallbackInfo =
|
||||
std::make_shared<NAccessibilityGestureResultListenerInfo>();
|
||||
pCallbackInfo->env_ = reinterpret_cast<napi_env>(&engine);
|
||||
NAPI_CALL(reinterpret_cast<napi_env>(&engine), napi_create_reference(reinterpret_cast<napi_env>(&engine),
|
||||
reinterpret_cast<napi_value>(info.argv[PARAM1]), 1, &pCallbackInfo->callback_));
|
||||
pCallbackInfo->listener_ = std::make_shared<NAccessibilityGestureResultListener>();
|
||||
// Save callback info
|
||||
gestureInjectSequence++;
|
||||
jsGestureResultListenerInfos[gestureInjectSequence] = pCallbackInfo;
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[weak = context_, sequence = gestureInjectSequence, gesturePath, gesturePathArray,
|
||||
isParameterArray, listener = pCallbackInfo->listener_](
|
||||
[weak = context_, gesturePath, gesturePathArray, isParameterArray](
|
||||
NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
@@ -578,19 +561,19 @@ private:
|
||||
}
|
||||
bool ret = false;
|
||||
if (isParameterArray) {
|
||||
ret = context->InjectGesture(sequence, gesturePathArray, listener);
|
||||
ret = context->InjectGesture(gesturePathArray);
|
||||
} else {
|
||||
ret = context->InjectGesture(sequence, gesturePath, listener);
|
||||
ret = context->InjectGesture(gesturePath);
|
||||
}
|
||||
if (ret) {
|
||||
task.Resolve(engine, engine.CreateBoolean(ret));
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
HILOG_ERROR("Gesture inject failed. ret: %{public}d.", ret);
|
||||
task.Reject(engine, CreateJsError(engine, RESULT_ERROR, "Gesture inject failed."));
|
||||
}
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == ARGS_SIZE_TWO) ? nullptr : info.argv[PARAM2];
|
||||
NativeValue* lastParam = (info.argc == ARGS_SIZE_ONE) ? nullptr : info.argv[PARAM1];
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule("NAccessibilityExtensionContext::OnGestureInject",
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
@@ -620,72 +603,9 @@ NativeValue* CreateJsAccessibilityExtensionContext(
|
||||
BindNativeFunction(engine, *object, "getWindowRootElement", NAccessibilityExtensionContext::GetWindowRootElement);
|
||||
BindNativeFunction(engine, *object, "getWindows", NAccessibilityExtensionContext::GetWindows);
|
||||
BindNativeFunction(engine, *object, "executeCommonAction", NAccessibilityExtensionContext::ExecuteCommonAction);
|
||||
BindNativeFunction(engine, *object, "gestureInject", NAccessibilityExtensionContext::InjectGesture);
|
||||
BindNativeFunction(engine, *object, "injectGesture", NAccessibilityExtensionContext::InjectGesture);
|
||||
|
||||
return objValue;
|
||||
}
|
||||
|
||||
void NAccessibilityGestureResultListener::OnGestureInjectResult(uint32_t sequence, bool result)
|
||||
{
|
||||
HILOG_INFO();
|
||||
|
||||
if (jsGestureResultListenerInfos.empty()) {
|
||||
HILOG_ERROR("There is no information of jsGestureResultListenerInfos");
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<NAccessibilityGestureResultListenerInfo> callbackInfo = nullptr;
|
||||
auto it = jsGestureResultListenerInfos.find(sequence);
|
||||
if (it != jsGestureResultListenerInfos.end()) {
|
||||
HILOG_DEBUG("callbackInfo has been found.");
|
||||
callbackInfo = jsGestureResultListenerInfos[sequence];
|
||||
jsGestureResultListenerInfos.erase(it);
|
||||
}
|
||||
|
||||
if (!callbackInfo) {
|
||||
HILOG_ERROR("callbackInfo is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
StateCallbackInfo *data = new(std::nothrow) StateCallbackInfo();
|
||||
if (!data) {
|
||||
HILOG_ERROR("Failed to create data.");
|
||||
return;
|
||||
}
|
||||
uv_work_t *work = new(std::nothrow) uv_work_t;
|
||||
if (!work) {
|
||||
HILOG_ERROR("Failed to create work.");
|
||||
delete data;
|
||||
data = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
data->env_ = callbackInfo->env_;
|
||||
data->state_ = result;
|
||||
data->ref_ = callbackInfo->callback_;
|
||||
work->data = static_cast<void*>(data);
|
||||
|
||||
uv_loop_s *loop = nullptr;
|
||||
napi_get_uv_event_loop(callbackInfo->env_, &loop);
|
||||
uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
[](uv_work_t *work, int status) {
|
||||
StateCallbackInfo *callbackInfo = static_cast<StateCallbackInfo*>(work->data);
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_value napiResult = 0;
|
||||
napi_value callResult = 0;
|
||||
napi_get_undefined(callbackInfo->env_, &undefined);
|
||||
napi_get_boolean(callbackInfo->env_, callbackInfo->state_, &napiResult);
|
||||
napi_get_reference_value(callbackInfo->env_, callbackInfo->ref_, &callback);
|
||||
napi_call_function(callbackInfo->env_, undefined, callback, ARGS_SIZE_ONE, &napiResult, &callResult);
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#include <time.h>
|
||||
#include "accessibility_event_transmission.h"
|
||||
#include "i_accessible_ability_client.h"
|
||||
#include "event_handler.h"
|
||||
#include "event_runner.h"
|
||||
#include "accessibility_gesture_inject_path.h"
|
||||
@@ -32,7 +31,6 @@ const int64_t DOUBLE_TAP_MIN_TIME = 50000; // microsecond
|
||||
|
||||
struct SendEventArgs {
|
||||
std::shared_ptr<MMI::PointerEvent> event_;
|
||||
bool isLastEvent_;
|
||||
};
|
||||
|
||||
class TouchEventInjector;
|
||||
@@ -53,7 +51,6 @@ private:
|
||||
class TouchEventInjector : public EventTransmission, public AppExecFwk::EventHandler {
|
||||
public:
|
||||
static constexpr uint32_t SEND_TOUCH_EVENT_MSG = 1;
|
||||
static constexpr uint32_t GESTURE_INJECT_EVENT_MSG = 2;
|
||||
|
||||
/**
|
||||
* @brief A constructor used to create a TouchEventInjector instance.
|
||||
@@ -98,42 +95,12 @@ public:
|
||||
*/
|
||||
void SendPointerEvent(MMI::PointerEvent &event);
|
||||
|
||||
/**
|
||||
* @brief Get current gesture service.
|
||||
* @param
|
||||
* @return the corresponding AccessibleAbility
|
||||
*/
|
||||
sptr<IAccessibleAbilityClient> GetCurrentGestureService()
|
||||
{
|
||||
return currentGestureService_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sequence of gesture.
|
||||
* @param
|
||||
* @return the sequence of gesture
|
||||
*/
|
||||
int32_t GetSequence()
|
||||
{
|
||||
return sequence_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inject simulated gestures.
|
||||
* @param gesturePath the gesture path
|
||||
* @param service the corresponding AccessibleAbility
|
||||
* @param sequence the sequence of gesture
|
||||
* @return
|
||||
*/
|
||||
void InjectEvents(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath,
|
||||
const sptr<IAccessibleAbilityClient> &service, int32_t sequence);
|
||||
|
||||
/**
|
||||
* @brief Parsing inject simulated gestures.
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void InjectGesturePathInner();
|
||||
void InjectEvents(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath);
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -168,33 +135,34 @@ private:
|
||||
|
||||
/**
|
||||
* @brief Parse taps events.
|
||||
* @param
|
||||
* @param startTime the start time of gesture injection
|
||||
* @param gesturePath the gesture path
|
||||
* @return
|
||||
*/
|
||||
void ParseTapsEvents(int64_t startTime);
|
||||
void ParseTapsEvents(int64_t startTime, const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath);
|
||||
|
||||
/**
|
||||
* @brief Parse move events.
|
||||
* @param
|
||||
* @param startTime the start time of gesture injection
|
||||
* @param gesturePath the gesture path
|
||||
* @return
|
||||
*/
|
||||
void ParseMovesEvents(int64_t startTime);
|
||||
void ParseMovesEvents(int64_t startTime, const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath);
|
||||
|
||||
/**
|
||||
* @brief Parse touchevents from gesturepath.
|
||||
* @param
|
||||
* @param startTime the start time of gesture injection
|
||||
* @param gesturePath the gesture path
|
||||
* @return
|
||||
*/
|
||||
void ParseTouchEventsFromGesturePath(int64_t startTime);
|
||||
void ParseTouchEventsFromGesturePath(int64_t startTime,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath);
|
||||
|
||||
int32_t sequence_ = -1;
|
||||
bool isGestureUnderway_ = false;
|
||||
bool isDestroyEvent_ = false;
|
||||
sptr<IAccessibleAbilityClient> currentGestureService_ = nullptr;
|
||||
std::shared_ptr<TouchInjectHandler> handler_ = nullptr;
|
||||
std::shared_ptr<AppExecFwk::EventRunner> runner_ = nullptr;
|
||||
std::vector<std::shared_ptr<MMI::PointerEvent>> injectedEvents_;
|
||||
std::shared_ptr<AccessibilityGestureInjectPath> gesturePositions_ = nullptr;
|
||||
};
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -56,8 +56,7 @@ public:
|
||||
|
||||
void SetOnKeyPressEventResult(const bool handled, const int32_t sequence) override;
|
||||
|
||||
void SendSimulateGesture(const int32_t requestId,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
|
||||
bool SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
|
||||
|
||||
bool SetEventTypeFilter(const uint32_t filter) override;
|
||||
|
||||
@@ -83,7 +82,7 @@ private:
|
||||
std::vector<AccessibilityWindowInfo> &windows);
|
||||
void InnerExecuteCommonAction(const int32_t action);
|
||||
void InnerSetOnKeyPressEventResult(const bool handled, const int32_t sequence);
|
||||
void InnerSendSimulateGesturePath(const int32_t requestId,
|
||||
void InnerSendSimulateGesturePath(std::promise<bool> &syncPromise,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath);
|
||||
void InnerSetEventTypeFilter(std::promise<bool> &syncPromise, const uint32_t filter);
|
||||
void InnerSetTargetBundleName(std::promise<bool> &syncPromise, const std::vector<std::string> &targetBundleNames);
|
||||
|
||||
@@ -47,8 +47,6 @@ public:
|
||||
|
||||
bool OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int32_t sequence);
|
||||
|
||||
void OnGestureInjectResult(const int32_t sequence, const bool completedSuccessfully);
|
||||
|
||||
void SetAbilityInfoEventTypeFilter(const uint32_t eventTypes);
|
||||
|
||||
void SetAbilityInfoTargetBundleName(const std::vector<std::string> &targetBundleNames);
|
||||
|
||||
@@ -41,14 +41,6 @@ void TouchInjectHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &eve
|
||||
case TouchEventInjector::SEND_TOUCH_EVENT_MSG:
|
||||
parameters = event->GetSharedObject<SendEventArgs>();
|
||||
server_.SendPointerEvent(*parameters->event_);
|
||||
if (parameters->isLastEvent_) {
|
||||
if (server_.GetCurrentGestureService()) {
|
||||
server_.GetCurrentGestureService()->OnGestureInjectResult(server_.GetSequence(), true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TouchEventInjector::GESTURE_INJECT_EVENT_MSG:
|
||||
server_.InjectGesturePathInner();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -129,7 +121,6 @@ void TouchEventInjector::CancelInjectedEvents()
|
||||
if (handler_->HasInnerEvent(SEND_TOUCH_EVENT_MSG)) {
|
||||
handler_->RemoveEvent(SEND_TOUCH_EVENT_MSG);
|
||||
CancelGesture();
|
||||
currentGestureService_->OnGestureInjectResult(sequence_, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,36 +146,26 @@ int64_t TouchEventInjector::GetSystemTime()
|
||||
return microsecond;
|
||||
}
|
||||
|
||||
void TouchEventInjector::InjectEvents(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath,
|
||||
const sptr<IAccessibleAbilityClient> &service, int32_t sequence)
|
||||
{
|
||||
sequence_ = sequence;
|
||||
currentGestureService_ = service;
|
||||
gesturePositions_ = gesturePath;
|
||||
handler_->SendEvent(GESTURE_INJECT_EVENT_MSG, 0, 0);
|
||||
}
|
||||
|
||||
void TouchEventInjector::InjectGesturePathInner()
|
||||
void TouchEventInjector::InjectEvents(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
int64_t curTime = GetSystemTime();
|
||||
if (isDestroyEvent_ || !GetNext()) {
|
||||
currentGestureService_->OnGestureInjectResult(sequence_, false);
|
||||
HILOG_WARN("Inject gesture fail");
|
||||
return;
|
||||
}
|
||||
CancelInjectedEvents();
|
||||
CancelGesture();
|
||||
|
||||
ParseTouchEventsFromGesturePath(curTime);
|
||||
ParseTouchEventsFromGesturePath(curTime, gesturePath);
|
||||
|
||||
if (injectedEvents_.empty()) {
|
||||
currentGestureService_->OnGestureInjectResult(sequence_, false);
|
||||
HILOG_WARN("No injected events");
|
||||
return;
|
||||
}
|
||||
for (size_t i = 0; i < injectedEvents_.size(); i++) {
|
||||
std::shared_ptr<SendEventArgs> parameters = std::make_shared<SendEventArgs>();
|
||||
parameters->isLastEvent_ = (i == injectedEvents_.size() - 1) ? true : false;
|
||||
parameters->event_ = injectedEvents_[i];
|
||||
if (injectedEvents_[i]) {
|
||||
int64_t timeout = (injectedEvents_[i]->GetActionTime() - curTime) / MS_TO_US;
|
||||
@@ -198,17 +179,22 @@ void TouchEventInjector::InjectGesturePathInner()
|
||||
injectedEvents_.clear();
|
||||
}
|
||||
|
||||
void TouchEventInjector::ParseTapsEvents(int64_t startTime)
|
||||
void TouchEventInjector::ParseTapsEvents(int64_t startTime,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
const std::vector<AccessibilityGesturePosition> &positions = gesturePositions_->GetPositions();
|
||||
if (!gesturePath) {
|
||||
HILOG_ERROR("gesturePath is null.");
|
||||
return;
|
||||
}
|
||||
const std::vector<AccessibilityGesturePosition> &positions = gesturePath->GetPositions();
|
||||
size_t positionSize = positions.size();
|
||||
if (!positionSize) {
|
||||
HILOG_WARN("PositionSize is zero.");
|
||||
return;
|
||||
}
|
||||
int64_t durationTime = gesturePositions_->GetDurationTime();
|
||||
int64_t durationTime = gesturePath->GetDurationTime();
|
||||
if (durationTime < 0) {
|
||||
HILOG_WARN("DurationTime is wrong.");
|
||||
return;
|
||||
@@ -239,17 +225,22 @@ void TouchEventInjector::ParseTapsEvents(int64_t startTime)
|
||||
}
|
||||
}
|
||||
|
||||
void TouchEventInjector::ParseMovesEvents(int64_t startTime)
|
||||
void TouchEventInjector::ParseMovesEvents(int64_t startTime,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
std::vector<AccessibilityGesturePosition> positions = gesturePositions_->GetPositions();
|
||||
size_t positionSize = positions.size();
|
||||
if (positionSize < MOVE_GESTURE_MIN_PATH_COUNT) {
|
||||
HILOG_WARN("PositionSize is zero.");
|
||||
if (!gesturePath) {
|
||||
HILOG_ERROR("gesturePath is null.");
|
||||
return;
|
||||
}
|
||||
int64_t durationTime = gesturePositions_->GetDurationTime();
|
||||
std::vector<AccessibilityGesturePosition> positions = gesturePath->GetPositions();
|
||||
size_t positionSize = positions.size();
|
||||
if (positionSize < MOVE_GESTURE_MIN_PATH_COUNT) {
|
||||
HILOG_WARN("PositionSize is wrong.");
|
||||
return;
|
||||
}
|
||||
int64_t durationTime = gesturePath->GetDurationTime();
|
||||
if (durationTime < 0) {
|
||||
HILOG_WARN("DurationTime is wrong.");
|
||||
return;
|
||||
@@ -288,14 +279,15 @@ void TouchEventInjector::ParseMovesEvents(int64_t startTime)
|
||||
}
|
||||
}
|
||||
|
||||
void TouchEventInjector::ParseTouchEventsFromGesturePath(int64_t startTime)
|
||||
void TouchEventInjector::ParseTouchEventsFromGesturePath(int64_t startTime,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
if (!gesturePositions_) {
|
||||
HILOG_ERROR("gesturePositions_ is null.");
|
||||
if (!gesturePath) {
|
||||
HILOG_ERROR("gesturePath is null.");
|
||||
return;
|
||||
}
|
||||
const std::vector<AccessibilityGesturePosition> &positions = gesturePositions_->GetPositions();
|
||||
const std::vector<AccessibilityGesturePosition> &positions = gesturePath->GetPositions();
|
||||
if (positions.size() == 0) {
|
||||
HILOG_ERROR("position size is 0.");
|
||||
return;
|
||||
@@ -303,9 +295,9 @@ void TouchEventInjector::ParseTouchEventsFromGesturePath(int64_t startTime)
|
||||
if ((positions.size() == 1) ||
|
||||
((positions[0].positionX_ == positions[1].positionX_) &&
|
||||
(positions[0].positionY_ == positions[1].positionY_))) {
|
||||
ParseTapsEvents(startTime);
|
||||
ParseTapsEvents(startTime, gesturePath);
|
||||
} else {
|
||||
ParseMovesEvents(startTime);
|
||||
ParseMovesEvents(startTime, gesturePath);
|
||||
}
|
||||
}
|
||||
} // namespace Accessibility
|
||||
|
||||
@@ -440,40 +440,41 @@ void AccessibleAbilityChannel::InnerSetOnKeyPressEventResult(const bool handled,
|
||||
keyEventFilter->SetServiceOnKeyEventResult(connection_, handled, sequence);
|
||||
}
|
||||
|
||||
void AccessibleAbilityChannel::SendSimulateGesture(const int32_t requestId,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
bool AccessibleAbilityChannel::SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
{
|
||||
HILOG_INFO();
|
||||
if (!eventHandler_) {
|
||||
HILOG_ERROR("eventHandler_ is nullptr");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
std::promise<bool> syncPromise;
|
||||
std::future syncFuture = syncPromise.get_future();
|
||||
std::function<void()> task = std::bind(&AccessibleAbilityChannel::InnerSendSimulateGesturePath,
|
||||
this, requestId, gesturePath);
|
||||
this, std::ref(syncPromise), gesturePath);
|
||||
eventHandler_->PostTask(task, TASK_SEND_SIMULATE_GESTURE_PATH);
|
||||
bool ret = syncFuture.get();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AccessibleAbilityChannel::InnerSendSimulateGesturePath(const int32_t requestId,
|
||||
void AccessibleAbilityChannel::InnerSendSimulateGesturePath(std::promise<bool> &syncPromise,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
sptr<IAccessibleAbilityClient> abilityClient = connection_.GetAbilityClient();
|
||||
if (!abilityClient) {
|
||||
return;
|
||||
}
|
||||
if (!(connection_.GetAbilityInfo().GetCapabilityValues() & Capability::CAPABILITY_GESTURE)) {
|
||||
HILOG_ERROR("AccessibleAbilityChannel::SendSimulateGesture failed: no capability");
|
||||
abilityClient->OnGestureInjectResult(requestId, false);
|
||||
syncPromise.set_value(false);
|
||||
return;
|
||||
}
|
||||
|
||||
sptr<TouchEventInjector> touchEventInjector =
|
||||
Singleton<AccessibleAbilityManagerService>::GetInstance().GetTouchEventInjector();
|
||||
if (!touchEventInjector) {
|
||||
abilityClient->OnGestureInjectResult(requestId, false);
|
||||
HILOG_ERROR("touchEventInjector is null");
|
||||
syncPromise.set_value(false);
|
||||
return;
|
||||
}
|
||||
touchEventInjector->InjectEvents(gesturePath, abilityClient, requestId);
|
||||
touchEventInjector->InjectEvents(gesturePath);
|
||||
syncPromise.set_value(true);
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannel::SetEventTypeFilter(const uint32_t filter)
|
||||
|
||||
@@ -248,15 +248,6 @@ bool AccessibleAbilityConnection::OnKeyPressEvent(const MMI::KeyEvent &keyEvent,
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccessibleAbilityConnection::OnGestureInjectResult(const int32_t sequence, const bool completedSuccessfully)
|
||||
{
|
||||
if (!abilityClient_) {
|
||||
HILOG_ERROR("OnGestureInjectResult failed");
|
||||
return;
|
||||
}
|
||||
abilityClient_->OnGestureInjectResult(sequence, completedSuccessfully);
|
||||
}
|
||||
|
||||
void AccessibleAbilityConnection::SetAbilityInfoEventTypeFilter(const uint32_t eventTypes)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
@@ -221,16 +221,6 @@ public:
|
||||
testDisplayId_ = DisplayId;
|
||||
}
|
||||
|
||||
int GetTestGestureSimulateResult()
|
||||
{
|
||||
return testGestureSimulateResult_;
|
||||
}
|
||||
|
||||
void SetTestGestureSimulateResult(int GestureSimulateResult)
|
||||
{
|
||||
testGestureSimulateResult_ = GestureSimulateResult;
|
||||
}
|
||||
|
||||
int GetTestStateType()
|
||||
{
|
||||
return testStateType_;
|
||||
@@ -307,7 +297,6 @@ private:
|
||||
int testGesture_ = -1;
|
||||
int testKeyPressEvent_ = -1;
|
||||
int testDisplayId_ = -1;
|
||||
int testGestureSimulateResult_ = -1;
|
||||
int testStateType_ = -1;
|
||||
bool testKeyEvent_ = false;
|
||||
bool isServicePublished_ = false;
|
||||
|
||||
@@ -38,12 +38,8 @@ public:
|
||||
MOCK_METHOD1(OnPointerEvent, void(MMI::PointerEvent& event));
|
||||
MOCK_METHOD1(ClearEvents, void(uint32_t inputSource));
|
||||
MOCK_METHOD0(DestroyEvents, void());
|
||||
MOCK_METHOD3(InjectEvents, void(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath,
|
||||
const sptr<IAccessibleAbilityClient> &service, int32_t sequence));
|
||||
MOCK_METHOD1(InjectEvents, void(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
|
||||
MOCK_METHOD1(SendPointerEvent, void(MMI::PointerEvent& event));
|
||||
MOCK_METHOD0(InjectGesturePathInner, void());
|
||||
MOCK_METHOD0(GetCurrentGestureService, sptr<IAccessibleAbilityClient>());
|
||||
MOCK_METHOD0(GetSequence, int32_t());
|
||||
};
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -33,14 +33,12 @@ public:
|
||||
virtual void Disconnect(const int32_t channelId) override;
|
||||
virtual void OnAccessibilityEvent(const AccessibilityEventInfo& eventInfo) override;
|
||||
virtual void OnKeyPressEvent(const MMI::KeyEvent& keyEvent, const int32_t sequence) override;
|
||||
virtual void OnGestureInjectResult(const int32_t sequence, const bool completedSuccessfully) override;
|
||||
|
||||
private:
|
||||
ErrCode HandleInit(MessageParcel& data, MessageParcel& reply);
|
||||
ErrCode HandleDisconnect(MessageParcel& data, MessageParcel& reply);
|
||||
ErrCode HandleOnAccessibilityEvent(MessageParcel& data, MessageParcel& reply);
|
||||
ErrCode HandleOnKeyPressEvent(MessageParcel& data, MessageParcel& reply);
|
||||
ErrCode HandleOnGestureInjectResult(MessageParcel& data, MessageParcel& reply);
|
||||
DISALLOW_COPY_AND_MOVE(MockAccessibleAbilityClientStubImpl);
|
||||
};
|
||||
} // namespace Accessibility
|
||||
|
||||
@@ -47,9 +47,7 @@ public:
|
||||
MOCK_METHOD2(GetWindowsByDisplayId, bool(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows));
|
||||
MOCK_METHOD1(ExecuteCommonAction, bool(const int32_t action));
|
||||
MOCK_METHOD2(SetOnKeyPressEventResult, void(const bool handled, const int32_t sequence));
|
||||
MOCK_METHOD2(
|
||||
SendSimulateGesture, void(const int32_t sequenceNum,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
|
||||
MOCK_METHOD1(SendSimulateGesture, bool(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
|
||||
};
|
||||
|
||||
class MockAccessibleAbilityConnection : public AccessibleAbilityConnection {
|
||||
|
||||
@@ -28,8 +28,18 @@ TouchInjectHandler::TouchInjectHandler(
|
||||
|
||||
void TouchInjectHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event)
|
||||
{
|
||||
(void)event;
|
||||
server_.InjectGesturePathInner();
|
||||
std::shared_ptr<SendEventArgs> parameters = nullptr;
|
||||
if (!event) {
|
||||
return;
|
||||
}
|
||||
switch (event->GetInnerEventId()) {
|
||||
case TouchEventInjector::SEND_TOUCH_EVENT_MSG:
|
||||
parameters = event->GetSharedObject<SendEventArgs>();
|
||||
server_.SendPointerEvent(*parameters->event_);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TouchEventInjector::TouchEventInjector()
|
||||
|
||||
@@ -130,12 +130,11 @@ void AccessibleAbilityChannelProxy::SetOnKeyPressEventResult(const bool handled,
|
||||
(void)sequence;
|
||||
}
|
||||
|
||||
void AccessibleAbilityChannelProxy::SendSimulateGesture(const int32_t requestId,
|
||||
bool AccessibleAbilityChannelProxy::SendSimulateGesture(
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
{
|
||||
(void)requestId;
|
||||
(void)gesturePath;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::SetEventTypeFilter(const uint32_t filter)
|
||||
|
||||
@@ -69,12 +69,5 @@ void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent& keyEvent
|
||||
AccessibilityAbilityHelper::GetInstance().SetTestKeyPressEvent(sequence);
|
||||
HILOG_DEBUG("start.-----------------------------mock Proxy end ");
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientProxy::OnGestureInjectResult(const int32_t sequence, const bool completedSuccessfully)
|
||||
{
|
||||
(void)sequence;
|
||||
(void)completedSuccessfully;
|
||||
AccessibilityAbilityHelper::GetInstance().SetTestGestureSimulateResult(1);
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
@@ -66,13 +66,6 @@ ErrCode MockAccessibleAbilityClientStubImpl::HandleOnKeyPressEvent(MessageParcel
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl HandleOnKeyPressEvent";
|
||||
return 0;
|
||||
}
|
||||
ErrCode MockAccessibleAbilityClientStubImpl::HandleOnGestureInjectResult(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
(void)data;
|
||||
(void)reply;
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl HandleOnGestureInjectResult";
|
||||
return 0;
|
||||
}
|
||||
void MockAccessibleAbilityClientStubImpl::Init(const sptr<IAccessibleAbilityChannel>& channel, const int32_t channelId)
|
||||
{
|
||||
(void)channel;
|
||||
@@ -95,13 +88,5 @@ void MockAccessibleAbilityClientStubImpl::OnKeyPressEvent(const MMI::KeyEvent& k
|
||||
(void)sequence;
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl OnKeyPressEvent";
|
||||
}
|
||||
void MockAccessibleAbilityClientStubImpl::OnGestureInjectResult(
|
||||
const int32_t sequence, const bool completedSuccessfully)
|
||||
{
|
||||
(void)sequence;
|
||||
(void)completedSuccessfully;
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl OnGestureInjectResult";
|
||||
AccessibilityAbilityHelper::GetInstance().SetTestGestureSimulateResult(1);
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
@@ -134,12 +134,10 @@ void AccessibleAbilityChannel::SetOnKeyPressEventResult(const bool handled, cons
|
||||
(void)sequence;
|
||||
}
|
||||
|
||||
void AccessibleAbilityChannel::SendSimulateGesture(const int32_t requestId,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
bool AccessibleAbilityChannel::SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
{
|
||||
(void)requestId;
|
||||
(void)gesturePath;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
AccessibleAbilityConnection::AccessibleAbilityConnection(
|
||||
@@ -187,12 +185,6 @@ bool AccessibleAbilityConnection::OnKeyPressEvent(const MMI::KeyEvent& keyEvent,
|
||||
return false;
|
||||
}
|
||||
|
||||
void AccessibleAbilityConnection::OnGestureInjectResult(const int32_t sequence, const bool completedSuccessfully)
|
||||
{
|
||||
(void)sequence;
|
||||
(void)completedSuccessfully;
|
||||
}
|
||||
|
||||
bool AccessibleAbilityConnection::IsWantedEvent(int32_t eventType)
|
||||
{
|
||||
(void)eventType;
|
||||
|
||||
@@ -45,7 +45,6 @@ public:
|
||||
sptr<AccessibilityInputInterceptor> inputInterceptor_ = nullptr;
|
||||
|
||||
protected:
|
||||
sptr<IAccessibleAbilityClient> service = nullptr;
|
||||
MMI::PointerEvent CreateTouchEvent(int32_t action);
|
||||
int32_t pointId_ = -1;
|
||||
bool isClearEvents_ = false;
|
||||
@@ -70,17 +69,13 @@ void TouchEventInjectorTest::SetUp()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "TouchEventInjectorTest SetUp";
|
||||
touchEventInjector_ = new TouchEventInjector();
|
||||
|
||||
sptr<MockAccessibleAbilityClientStubImpl> stub = new MockAccessibleAbilityClientStubImpl();
|
||||
|
||||
service = new AccessibleAbilityClientProxy(stub->AsObject());
|
||||
inputInterceptor_ = AccessibilityInputInterceptor::GetInstance();
|
||||
}
|
||||
|
||||
void TouchEventInjectorTest::TearDown()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "TouchEventInjectorTest TearDown";
|
||||
service = nullptr;
|
||||
inputInterceptor_ = nullptr;
|
||||
}
|
||||
|
||||
@@ -111,7 +106,7 @@ HWTEST_F(TouchEventInjectorTest, TouchEventInjector_Unittest_TouchEventInjector_
|
||||
gesturePath->AddPosition(point);
|
||||
gesturePath->SetDurationTime(100);
|
||||
|
||||
touchEventInjector_->InjectEvents(gesturePath, service, 1);
|
||||
touchEventInjector_->InjectEvents(gesturePath);
|
||||
|
||||
sleep(SLEEP_TIME_2);
|
||||
int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
|
||||
@@ -173,7 +168,7 @@ HWTEST_F(TouchEventInjectorTest, TouchEventInjector_Unittest_TouchEventInjector_
|
||||
gesturePath->AddPosition(point);
|
||||
gesturePath->SetDurationTime(100000);
|
||||
|
||||
touchEventInjector_->InjectEvents(gesturePath, service, 1);
|
||||
touchEventInjector_->InjectEvents(gesturePath);
|
||||
sleep(SLEEP_TIME_1);
|
||||
int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
|
||||
AccessibilityAbilityHelper::GetInstance().ClearTouchEventActionVector();
|
||||
@@ -206,7 +201,7 @@ HWTEST_F(TouchEventInjectorTest, TouchEventInjector_Unittest_TouchEventInjector_
|
||||
gesturePath->AddPosition(point3);
|
||||
gesturePath->SetDurationTime(200);
|
||||
|
||||
touchEventInjector_->InjectEvents(gesturePath, service, 1);
|
||||
touchEventInjector_->InjectEvents(gesturePath);
|
||||
sleep(SLEEP_TIME_2);
|
||||
int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
|
||||
int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_DOWN;
|
||||
|
||||
@@ -224,25 +224,6 @@ HWTEST_F(
|
||||
GTEST_LOG_(INFO) << "AccessibleAbilityConnection_Unittest_OnAccessibilityEvent_002 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: AccessibleAbilityConnection_Unittest_OnGestureSimulateResult_001
|
||||
* @tc.name: OnGestureSimulateResult
|
||||
* @tc.desc: Test function OnGestureSimulateResult
|
||||
*/
|
||||
HWTEST_F(AccessibleAbilityConnectionUnitTest, AccessibleAbilityConnection_Unittest_OnGestureSimulateResult_001,
|
||||
TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AccessibleAbilityConnection_Unittest_OnGestureSimulateResult_001 start";
|
||||
if (connection_ != nullptr) {
|
||||
sleep(SLEEP_TIME_2);
|
||||
OHOS::Accessibility::Rect rect(0, 0, 0, 0);
|
||||
connection_->OnGestureInjectResult(1, false);
|
||||
sleep(SLEEP_TIME_2);
|
||||
EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestGestureSimulateResult(), 1);
|
||||
}
|
||||
GTEST_LOG_(INFO) << "AccessibleAbilityConnection_Unittest_OnGestureSimulateResult_001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: AccessibleAbilityConnection_Unittest_Connect_001
|
||||
* @tc.name: Connect
|
||||
|
||||
@@ -150,12 +150,10 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Send simulation gesture through the proxy object.
|
||||
* @param requestId The sequence of simulation gesture.
|
||||
* @param gesturePath The gesture path to send.
|
||||
* @return
|
||||
* @return Return true if gesture injection is successfully, otherwise return false.
|
||||
*/
|
||||
virtual void SendSimulateGesture(const int32_t requestId,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
|
||||
virtual bool SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
|
||||
|
||||
/**
|
||||
* @brief Set event types to filter.
|
||||
|
||||
@@ -56,14 +56,6 @@ public:
|
||||
*/
|
||||
virtual void OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int32_t sequence) override;
|
||||
|
||||
/**
|
||||
* @brief Called when need to notify the result of simulation gesture through the proxy object.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param completedSuccessfully The result of gesture completion.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnGestureInjectResult(const int32_t sequence, const bool completedSuccessfully) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Send the command data from proxy to stub in IPC mechanism.
|
||||
|
||||
@@ -35,7 +35,6 @@ private:
|
||||
ErrCode HandleDisconnect(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleOnAccessibilityEvent(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleOnKeyPressEvent(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleOnGestureInjectResult(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using AccessibleAbilityClientFunc =
|
||||
ErrCode (AccessibleAbilityClientStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
@@ -143,12 +143,10 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Send simulation gesture.
|
||||
* @param requestId The sequence of simulation gesture.
|
||||
* @param gesturePath The gesture path to send.
|
||||
* @return
|
||||
* @return Return true if gesture injection is successfully, otherwise return false.
|
||||
*/
|
||||
virtual void SendSimulateGesture(const int32_t requestId,
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) = 0;
|
||||
virtual bool SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set event types to filter.
|
||||
|
||||
@@ -58,20 +58,11 @@ public:
|
||||
*/
|
||||
virtual void OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int32_t sequence) = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when need to notify the result of simulation gesture.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param completedSuccessfully The result of gesture completion.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnGestureInjectResult(const int32_t sequence, const bool completedSuccessfully) = 0;
|
||||
|
||||
enum class Message {
|
||||
INIT = 0,
|
||||
DISCONNECT,
|
||||
ON_ACCESSIBILITY_EVENT,
|
||||
ON_KEY_PRESS_EVENT,
|
||||
ON_GESTURE_INJECT_RESULT,
|
||||
};
|
||||
};
|
||||
} // namespace Accessibility
|
||||
|
||||
@@ -442,7 +442,7 @@ void AccessibleAbilityChannelProxy::SetOnKeyPressEventResult(const bool handled,
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityChannelProxy::SendSimulateGesture(const int32_t requestId,
|
||||
bool AccessibleAbilityChannelProxy::SendSimulateGesture(
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
@@ -450,29 +450,27 @@ void AccessibleAbilityChannelProxy::SendSimulateGesture(const int32_t requestId,
|
||||
new(std::nothrow) AccessibilityGestureInjectPathParcel(*gesturePath);
|
||||
if (!path) {
|
||||
HILOG_ERROR("Failed to create path.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("requestId write error: %{public}d, ", requestId);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!data.WriteStrongParcelable(path)) {
|
||||
HILOG_ERROR("WriteStrongParcelable<AccessibilityGestureInjectPathParcel> failed");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SEND_SIMULATE_GESTURE_PATH, data, reply, option)) {
|
||||
HILOG_ERROR("fail to send simulation gesture path");
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::SetEventTypeFilter(const uint32_t filter)
|
||||
|
||||
@@ -311,8 +311,6 @@ ErrCode AccessibleAbilityChannelStub::HandleSendSimulateGesturePath(MessageParce
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
int32_t requestId = data.ReadInt32();
|
||||
|
||||
sptr<AccessibilityGestureInjectPathParcel> positions =
|
||||
data.ReadStrongParcelable<AccessibilityGestureInjectPathParcel>();
|
||||
if (!positions) {
|
||||
@@ -322,7 +320,8 @@ ErrCode AccessibleAbilityChannelStub::HandleSendSimulateGesturePath(MessageParce
|
||||
|
||||
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath =
|
||||
std::make_shared<AccessibilityGestureInjectPath>(*positions);
|
||||
SendSimulateGesture(requestId, gesturePath);
|
||||
bool result = SendSimulateGesture(gesturePath);
|
||||
reply.WriteBool(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -155,31 +155,5 @@ void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent &keyEvent
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientProxy::OnGestureInjectResult(const int32_t sequence, const bool completedSuccessfully)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_DEBUG();
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(sequence)) {
|
||||
HILOG_ERROR("fail, sequence write int32 error");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteBool(completedSuccessfully)) {
|
||||
HILOG_ERROR("fail, completedSuccessfully write bool error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityClient::Message::ON_GESTURE_INJECT_RESULT, data, reply, option)) {
|
||||
HILOG_ERROR("OnGestureInjectResult fail");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
@@ -31,8 +31,6 @@ AccessibleAbilityClientStub::AccessibleAbilityClientStub()
|
||||
&AccessibleAbilityClientStub::HandleOnAccessibilityEvent;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_KEY_PRESS_EVENT)] =
|
||||
&AccessibleAbilityClientStub::HandleOnKeyPressEvent;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_GESTURE_INJECT_RESULT)] =
|
||||
&AccessibleAbilityClientStub::HandleOnGestureInjectResult;
|
||||
}
|
||||
|
||||
AccessibleAbilityClientStub::~AccessibleAbilityClientStub()
|
||||
@@ -117,15 +115,5 @@ ErrCode AccessibleAbilityClientStub::HandleOnKeyPressEvent(MessageParcel &data,
|
||||
OnKeyPressEvent(*keyEvent, sequence);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityClientStub::HandleOnGestureInjectResult(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
int32_t sequence = data.ReadInt32();
|
||||
bool completedSuccessfully = data.ReadBool();
|
||||
|
||||
OnGestureInjectResult(sequence, completedSuccessfully);
|
||||
return NO_ERROR;
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
@@ -59,16 +59,6 @@ public:
|
||||
{
|
||||
mTgestureId_ = gestureId;
|
||||
}
|
||||
|
||||
int32_t GetTestGestureSimulate()
|
||||
{
|
||||
return testGestureSimulate_;
|
||||
}
|
||||
void SetTestGestureSimulate(int32_t testGestureSimulate)
|
||||
{
|
||||
testGestureSimulate_ = testGestureSimulate;
|
||||
}
|
||||
|
||||
OHOS::sptr<OHOS::Accessibility::IAccessibleAbilityChannel>& GetTestStub()
|
||||
{
|
||||
return testStub_;
|
||||
@@ -170,7 +160,6 @@ public:
|
||||
static const int32_t accountId_ = 100;
|
||||
|
||||
private:
|
||||
int32_t testGestureSimulate_ = -1;
|
||||
OHOS::sptr<OHOS::Accessibility::IAccessibleAbilityChannel> testStub_ = nullptr;
|
||||
std::vector<EventType> mTeventType_ = {};
|
||||
int32_t mTgestureId_ = 0;
|
||||
|
||||
@@ -76,12 +76,5 @@ void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent& keyEvent
|
||||
AccessibilityHelper::GetInstance().SetTestKeyPressEvent(sequence);
|
||||
HILOG_DEBUG("start.-----------------------------mock Proxy end ");
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientProxy::OnGestureInjectResult(const int32_t sequence, const bool completedSuccessfully)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AccessibleAbilityClientProxy OnGestureInjectResult";
|
||||
AccessibilityHelper::GetInstance().SetTestGestureSimulateResult(1);
|
||||
AccessibilityHelper::GetInstance().SetTestGestureSimulate(sequence);
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
+6
-6
@@ -149,7 +149,7 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_001,
|
||||
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
|
||||
gesturePath->AddPosition(point);
|
||||
gesturePath->SetDurationTime(100);
|
||||
aacs_->SendSimulateGesture(1, gesturePath);
|
||||
aacs_->SendSimulateGesture(gesturePath);
|
||||
sleep(3);
|
||||
|
||||
int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE;
|
||||
@@ -185,7 +185,7 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_004,
|
||||
gesturePath->AddPosition(point3);
|
||||
gesturePath->SetDurationTime(200);
|
||||
|
||||
aacs_->SendSimulateGesture(1, gesturePath);
|
||||
aacs_->SendSimulateGesture(gesturePath);
|
||||
sleep(3);
|
||||
|
||||
int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE;
|
||||
@@ -225,7 +225,7 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_005,
|
||||
gesturePath->AddPosition(point4);
|
||||
gesturePath->SetDurationTime(300);
|
||||
|
||||
aacs_->SendSimulateGesture(1, gesturePath);
|
||||
aacs_->SendSimulateGesture(gesturePath);
|
||||
sleep(3);
|
||||
int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE;
|
||||
auto mtTouchAction = MMI::MockInputManager::GetTouchActions();
|
||||
@@ -266,7 +266,7 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_006,
|
||||
gesturePath->AddPosition(point4);
|
||||
gesturePath->SetDurationTime(300);
|
||||
|
||||
aacs_->SendSimulateGesture(1, gesturePath);
|
||||
aacs_->SendSimulateGesture(gesturePath);
|
||||
sleep(3);
|
||||
|
||||
int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE;
|
||||
@@ -308,7 +308,7 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_007,
|
||||
gesturePath->AddPosition(point4);
|
||||
gesturePath->SetDurationTime(300);
|
||||
|
||||
aacs_->SendSimulateGesture(1, gesturePath);
|
||||
aacs_->SendSimulateGesture(gesturePath);
|
||||
sleep(3);
|
||||
|
||||
int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE;
|
||||
@@ -350,7 +350,7 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_008,
|
||||
gesturePath->AddPosition(point4);
|
||||
gesturePath->SetDurationTime(300);
|
||||
|
||||
aacs_->SendSimulateGesture(1, gesturePath);
|
||||
aacs_->SendSimulateGesture(gesturePath);
|
||||
sleep(3);
|
||||
|
||||
int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE;
|
||||
|
||||
+2
-6
@@ -75,7 +75,6 @@ void AamsAccessibleAbilityChannelTest::SetUp()
|
||||
void AamsAccessibleAbilityChannelTest::TearDown()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AamsAccessibleAbilityChannelTest TearDown";
|
||||
AccessibilityHelper::GetInstance().SetTestGestureSimulate(-1);
|
||||
|
||||
// Deregister ElementOperator
|
||||
Singleton<AccessibleAbilityManagerService>::GetInstance().DeregisterElementOperator(0);
|
||||
@@ -498,11 +497,9 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_S
|
||||
gesturePath->SetDurationTime(100);
|
||||
|
||||
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
|
||||
AccessibilityHelper::GetInstance().GetTestStub()->SendSimulateGesture(1, gesturePath);
|
||||
AccessibilityHelper::GetInstance().GetTestStub()->SendSimulateGesture(gesturePath);
|
||||
sleep(2);
|
||||
|
||||
int32_t result = Singleton<AccessibleAbilityManagerService>::GetInstance().GetTouchEventInjector()->GetSequence();
|
||||
EXPECT_EQ(1, result);
|
||||
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_, 0);
|
||||
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_SendSimulateGesture_001 end";
|
||||
}
|
||||
@@ -699,9 +696,8 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_S
|
||||
gesturePath->SetDurationTime(100);
|
||||
|
||||
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
|
||||
AccessibilityHelper::GetInstance().GetTestStub()->SendSimulateGesture(1, gesturePath);
|
||||
AccessibilityHelper::GetInstance().GetTestStub()->SendSimulateGesture(gesturePath);
|
||||
sleep(2);
|
||||
EXPECT_EQ(1, AccessibilityHelper::GetInstance().GetTestGestureSimulate());
|
||||
GTEST_LOG_(INFO) << "clear end";
|
||||
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_, 0);
|
||||
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_SendSimulateGesture_NoCapability_001 end";
|
||||
|
||||
Reference in New Issue
Block a user