release 20220225

Signed-off-by: yichengzhao <yichengzhao1@huawei.com>
Change-Id: Ib7006e82e7c15244734fabbbe00a2fa59c23ccd5
This commit is contained in:
yichengzhao 2022-02-25 18:15:47 +08:00
parent ebb432d38d
commit 1a5cf66edf
98 changed files with 711 additions and 918 deletions

View File

@ -42,15 +42,11 @@
"name": "//base/accessibility/frameworks/aafwk:accessibleability",
"header": {
"header_files": [
"accessible_ability_client_interface.h",
"accessible_ability_client_proxy.h",
"accessible_ability_client_stub.h",
"accessible_ability_client_stub_impl.h",
"accessibility_extension_context.h",
"accessibility_extension.h",
"display_resize_controller.h"
"accessibility_ui_test_ability_listener.h",
"accessibility_ui_test_ability.h"
],
"header_base": "//base/accessibility/frameworks/aafwk/include"
"header_base": "//base/accessibility/interfaces/innerkits/aafwk/include"
}
},
{

View File

@ -25,29 +25,6 @@ namespace OHOS {
namespace Accessibility {
class IASACStub {};
class IClient {};
struct AccessibilityAbilityInfoDummy {
uint32_t accessibilityEventTypes = 0xFFFFFFFF; // TYPES_ALL_MASK
// ACCESSIBILITY_ABILITY_TYPE_SPOKEN | ACCESSIBILITY_ABILITY_TYPE_HAPTIC | ACCESSIBILITY_ABILITY_TYPE_AUDIBLE
uint32_t accessibilityAbilityTypes = 0x00000001 | 0x00000002 | 0x00000004;
// CAPABILITY_KEY_EVENT_OBSERVER | CAPABILITY_TOUCH_GUIDE | CAPABILITY_ZOOM | CAPABILITY_RETRIEVE
uint32_t capabilities = 0x0008 | 0x0002 | 0x0010 | 0x0001;
std::string description =
"When TalkBack is on, it provides spoken feedback so that you can use your device without looking at the screen.";
uint32_t uiInteractiveTime = 10000;
uint32_t notificationTimeout = 0;
std::string settingsAbility = "com.ohos.talkback.TalkBackPreferencesActivity";
// The following two properties talkback is not configured.
uint32_t uiNoninteractiveTime = 0;
std::vector<std::string> filterBundleNames{};
};
} // namespace Accessibility
} // namespace OHOS
#endif // DUMMY_H

View File

@ -22,5 +22,5 @@ aafwk_files = [
"${aafwk_path}/src/display_resize_controller.cpp",
"${aafwk_path}/src/js_accessibility_extension.cpp",
"${aafwk_path}/src/js_accessibility_extension_context.cpp",
"${aafwk_path}/src/accessibility_ui_test_ability.cpp",
"${aafwk_path}/src/accessibility_ui_test_ability_impl.cpp",
]

View File

@ -91,5 +91,4 @@ public:
};
} // namespace Accessibility
} // namespace OHOS
#endif // ACCESSIBILITY_EXTENSION_H

View File

@ -0,0 +1,67 @@
/*
* Copyright (C) 2021 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_UI_TEST_ABILITY_IMPL_H
#define ACCESSIBILITY_UI_TEST_ABILITY_IMPL_H
#include "accessibility_ui_test_ability.h"
#include "accessible_ability_client_stub_impl.h"
#include "accessible_ability_manager_service_proxy.h"
namespace OHOS {
namespace Accessibility {
class AccessibilityUITestAbilityImpl final : public AccessibilityUITestAbility {
public:
/**
* @brief Construct
* @param
* @return
*/
AccessibilityUITestAbilityImpl();
/**
* @brief Destruct
* @param
* @return
*/
~AccessibilityUITestAbilityImpl() = default;
/**
* @brief RegisterListener
* @param
* @return
*/
virtual bool RegisterListener(const std::shared_ptr<IAccessibleUITestAbilityListener> &listener) override;
/**
* @brief Connect to AAMS.
* @param
* @return
*/
virtual bool Connect() override;
/**
* @brief disconnect to AAMS.
* @param
* @return
*/
virtual bool Disconnect() override;
private:
sptr<AccessibleAbilityClientStubImpl> stub_ = nullptr;
sptr<AccessibleAbilityManagerServiceClientProxy> serviceProxy_ = nullptr;
};
} // namespace Accessibility
} // namespace OHOS
#endif // ACCESSIBILITY_UI_TEST_ABILITY_IMPL_H

View File

@ -24,9 +24,7 @@
namespace OHOS {
namespace Accessibility {
class AccessibleAbilityClientProxy : public IRemoteProxy<IAccessibleAbilityClient>
{
class AccessibleAbilityClientProxy : public IRemoteProxy<IAccessibleAbilityClient> {
public:
explicit AccessibleAbilityClientProxy(const sptr<IRemoteObject> &object);
virtual ~AccessibleAbilityClientProxy() = default;
@ -87,8 +85,6 @@ private:
static inline BrokerDelegator<AccessibleAbilityClientProxy> delegator;
};
} // namespace Accessibility
} // namespace OHOS
#endif // ACCESSIBLE_ABILITY_CLIENT_PROXY_H

View File

@ -26,9 +26,7 @@
namespace OHOS {
namespace Accessibility {
class AccessibleAbilityClientStubImpl : public AccessibleAbilityClientStub
{
class AccessibleAbilityClientStubImpl : public AccessibleAbilityClientStub {
public:
AccessibleAbilityClientStubImpl() = default;
~AccessibleAbilityClientStubImpl() = default;
@ -122,15 +120,13 @@ private:
void OnGestureSimulateResultInner(const int sequence, const bool completedSuccessfully);
sptr<IRemoteObject::DeathRecipient> deathRecipient_{};
sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr;
sptr<IAccessibleAbilityChannel> channel_ = nullptr;
std::shared_ptr<AccessibilityExtension> listener_ = nullptr;
std::shared_ptr<IAccessibleUITestAbilityListener> uiTestListener_ = nullptr;
uint32_t channelId_ = INVALID_CHANNEL_ID;
bool uiTestEnabled_ = false;
};
} // namespace Accessibility
} // namespace OHOS
#endif // ACCESSIBLE_ABILITY_CLIENT_STUB_IMPL_H

View File

@ -86,7 +86,7 @@ public:
bool OnKeyPressEvent(const MMI::KeyEvent& keyEvent) override;
private:
NativeValue* CallObjectMethod(const char* name, NativeValue* const * argv = nullptr, size_t argc = 0);
NativeValue* CallObjectMethod(const char* name, NativeValue * const * argv = nullptr, size_t argc = 0);
void GetSrcPath(std::string &srcPath);

View File

@ -77,7 +77,7 @@ std::shared_ptr<DisplayResizeController>& AccessibilityExtensionContext::GetDisp
{
HILOG_DEBUG("%{public}s start.", __func__);
// TODO: To make sure the id of DEFAULT_DISPALY.
// this is a temp deal: To make sure the id of DEFAULT_DISPALY.
uint32_t DEFAULT_DISPALY = 0;
return GetDisplayResizeController(DEFAULT_DISPALY);
}

View File

@ -13,7 +13,9 @@
* limitations under the License.
*/
#include "accessibility_ui_test_ability.h"
#include "accessibility_ui_test_ability_impl.h"
#include <mutex>
#include "hilog_wrapper.h"
#include "if_system_ability_manager.h"
#include "iservice_registry.h"
@ -21,73 +23,21 @@
namespace OHOS {
namespace Accessibility {
std::shared_ptr<AccessibilityUITestAbility> AccessibilityUITestAbility::instance_ = nullptr;
AccessibilityUITestAbility& AccessibilityUITestAbility::GetInstance()
static std::mutex g_Mutex;
static std::shared_ptr<AccessibilityUITestAbilityImpl> g_Instance = nullptr;
std::shared_ptr<AccessibilityUITestAbility> AccessibilityUITestAbility::GetInstance()
{
HILOG_DEBUG("%{public}s start.", __func__);
if (instance_ == nullptr) {
std::shared_ptr<AccessibilityUITestAbility> temp(new AccessibilityUITestAbility);
instance_ = temp;
std::lock_guard<std::mutex> lock(g_Mutex);
if (g_Instance == nullptr) {
g_Instance = std::make_shared<AccessibilityUITestAbilityImpl>();
}
return *instance_;
return g_Instance;
}
AccessibilityUITestAbility::AccessibilityUITestAbility()
AccessibilityUITestAbilityImpl::AccessibilityUITestAbilityImpl()
{
HILOG_DEBUG("%{public}s start.", __func__);
stub_ = new AccessibleAbilityClientStubImpl();
stub_->SetUITestEnabled();
GetService();
}
bool AccessibilityUITestAbility::RegisterListener(const std::shared_ptr<IAccessibleUITestAbilityListener> &listener)
{
HILOG_DEBUG("%{public}s start.", __func__);
if (!listener) {
HILOG_ERROR("listener is nullptr.");
return false;
}
if (!stub_) {
HILOG_ERROR("AccessibleAbility::stub_ is nullptr");
return false;
}
return stub_->RegisterUITestAbilityListener(listener);
}
bool AccessibilityUITestAbility::Connect()
{
HILOG_DEBUG("%{public}s start.", __func__);
if (serviceProxy_ == nullptr) {
HILOG_ERROR("Failed to get aams service");
return false;
}
if (!stub_) {
HILOG_ERROR("stub_ is nullptr");
return false;
}
return serviceProxy_->RegisterUITestAbilityConnectionClient(stub_);
}
bool AccessibilityUITestAbility::Disconnect()
{
HILOG_DEBUG("%{public}s start.", __func__);
if (serviceProxy_ == nullptr) {
HILOG_ERROR("Failed to get aams service");
return false;
}
return serviceProxy_->DeregisterUITestAbilityConnectionClient();
}
void AccessibilityUITestAbility::GetService()
{
HILOG_DEBUG("%{public}s start.", __func__);
if (serviceProxy_ != nullptr) {
return;
}
sptr<ISystemAbilityManager> samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (!samgr) {
@ -106,7 +56,57 @@ void AccessibilityUITestAbility::GetService()
serviceProxy_ = iface_cast<AccessibleAbilityManagerServiceClientProxy>(object);
if (!serviceProxy_) {
HILOG_ERROR("Get aams proxy failed");
return;
}
stub_ = new AccessibleAbilityClientStubImpl();
stub_->SetUITestEnabled();
}
bool AccessibilityUITestAbilityImpl::RegisterListener(const std::shared_ptr<IAccessibleUITestAbilityListener> &listener)
{
HILOG_DEBUG("%{public}s start.", __func__);
std::lock_guard<std::mutex> lock(g_Mutex);
if (!listener) {
HILOG_ERROR("listener is nullptr.");
return false;
}
if (!stub_) {
HILOG_ERROR("AccessibleAbility::stub_ is nullptr");
return false;
}
return stub_->RegisterUITestAbilityListener(listener);
}
bool AccessibilityUITestAbilityImpl::Connect()
{
HILOG_DEBUG("%{public}s start.", __func__);
std::lock_guard<std::mutex> lock(g_Mutex);
if (serviceProxy_ == nullptr) {
HILOG_ERROR("Failed to get aams service");
return false;
}
if (!stub_) {
HILOG_ERROR("stub_ is nullptr");
return false;
}
return serviceProxy_->RegisterUITestAbilityConnectionClient(stub_);
}
bool AccessibilityUITestAbilityImpl::Disconnect()
{
HILOG_DEBUG("%{public}s start.", __func__);
std::lock_guard<std::mutex> lock(g_Mutex);
if (serviceProxy_ == nullptr) {
HILOG_ERROR("Failed to get aams service");
return false;
}
return serviceProxy_->DeregisterUITestAbilityConnectionClient();
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -131,6 +131,12 @@ void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent &keyEvent
HILOG_ERROR("%{public}s fail, sequence write int32 error", __func__);
return;
}
if (!keyEvent.WriteToParcel(data)) {
HILOG_ERROR("%{public}s fail, keyEvent WriteToParcel error", __func__);
return;
}
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_KEY_PRESS_EVENT),
data, reply, option);
if (error != NO_ERROR) {

View File

@ -107,6 +107,14 @@ ErrCode AccessibleAbilityClientStub::HandleOnAccessibilityEvent(MessageParcel &d
ErrCode AccessibleAbilityClientStub::HandleOnKeyPressEvent(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG("%{public}s start.", __func__);
int sequence = data.ReadInt32();
std::shared_ptr<MMI::KeyEvent> keyEvent = MMI::KeyEvent::Create();
if (!keyEvent->ReadFromParcel(data)) {
HILOG_ERROR("keyEvent ReadFromParcel failed");
return ERR_INVALID_VALUE;
}
OnKeyPressEvent(*keyEvent, sequence);
return NO_ERROR;
}

View File

@ -94,7 +94,7 @@ void AccessibleAbilityClientStubImpl::Init(const sptr<IAccessibleAbilityChannel>
return;
}
AccessibilityUITestAbility::GetInstance().SetChannelId(channelId);
AccessibilityUITestAbility::GetInstance()->SetChannelId(channelId);
AccessibilityOperator::AddChannel(channelId, channel);
channelId_ = channelId;
channel_ = channel;
@ -135,7 +135,7 @@ void AccessibleAbilityClientStubImpl::Disconnect(const int channelId)
listener_ = nullptr;
}
} else {
AccessibilityUITestAbility::GetInstance().SetChannelId(channelId_);
AccessibilityUITestAbility::GetInstance()->SetChannelId(channelId_);
uiTestListener_ = nullptr;
}
}
@ -198,7 +198,7 @@ void AccessibleAbilityClientStubImpl::OnGestureSimulateResult(const int sequence
if (uiTestEnabled_) {
HILOG_DEBUG("Dispatch the result of simulation gesture.");
AccessibilityUITestAbility::GetInstance().DispatchOnSimulationGestureResult(
AccessibilityUITestAbility::GetInstance()->DispatchOnSimulationGestureResult(
sequence, completedSuccessfully);
}
}

View File

@ -204,6 +204,7 @@ private:
// wrap accessibilityWindows
NAccessibilityWindowInfo::DefineJSAccessibilityWindowInfo(reinterpret_cast<napi_env>(&engine));
napi_value napiWindowInfos = nullptr;
napi_create_array(reinterpret_cast<napi_env>(&engine), &napiWindowInfos);
ConvertAccessibilityWindowInfosToJS(
reinterpret_cast<napi_env>(&engine), napiWindowInfos, accessibilityWindows);
NativeValue* nativeWindowInfos = reinterpret_cast<NativeValue*>(napiWindowInfos);
@ -277,9 +278,9 @@ private:
}
// unwrap gesturePaths
napi_value nGesturePaths = reinterpret_cast<napi_value>(info.argv[PARAM0]);
std::vector<GesturePathDefine> gesturePaths;
ConvertGesturePathsJSToNAPI(reinterpret_cast<napi_env>(&engine),
reinterpret_cast<napi_value>(info.argv[PARAM0]), gesturePaths);
ConvertGesturePathsJSToNAPI(reinterpret_cast<napi_env>(&engine), nGesturePaths, gesturePaths);
// unwrap callback
if (info.argv[PARAM1]->TypeOf() != NATIVE_FUNCTION) {

View File

@ -56,7 +56,7 @@ ohos_unittest("accessible_ability_test") {
"../../asacfwk/src/accessibility_caption.cpp",
"../src/accessibility_extension.cpp",
"../src/accessibility_extension_context.cpp",
"../src/accessibility_ui_test_ability.cpp",
"../src/accessibility_ui_test_ability_impl.cpp",
"../src/accessible_ability_client_proxy.cpp",
"../src/accessible_ability_client_stub.cpp",
"../src/accessible_ability_client_stub_impl.cpp",

View File

@ -23,6 +23,7 @@
namespace OHOS {
namespace Accessibility {
using AccessibilityElementOperatorCallbacks = std::map<const int, const sptr<IAccessibilityElementOperatorCallback>>;
std::map<const int, const sptr<IAccessibilityElementOperatorCallback>>
AccessibilityElementOperatorStub::aaCallbacks_ = {};
AccessibilityElementOperatorStub::AccessibilityElementOperatorStub()
@ -135,8 +136,7 @@ void AccessibilityElementOperatorStub::CallbackImpl::SetExecuteActionResult(
const bool succeeded, const int requestId)
{}
std::map<const int, const sptr<IAccessibilityElementOperatorCallback>>
AccessibilityElementOperatorStub::CallbackImpl::GetAACallbackList()
AccessibilityElementOperatorCallbacks AccessibilityElementOperatorStub::CallbackImpl::GetAACallbackList()
{
return aaCallbacks_;
}

View File

@ -21,8 +21,7 @@
namespace OHOS {
namespace Accessibility {
class AccessibilityElementAsyncOperatorMng
{
class AccessibilityElementAsyncOperatorMng {
public:
/**
* @brief construct function
@ -75,7 +74,6 @@ private:
static std::recursive_mutex mutex_;
static int sequence_; //matched request with callback result
};
} // namespace Accessibility
} // namespace OHOS
#endif

View File

@ -21,7 +21,6 @@
#include <string>
#include "accessibility_element_info.h"
#include "iremote_broker.h"
namespace OHOS {

View File

@ -21,7 +21,6 @@
#include <string>
#include "accessibility_element_operator_callback_interface.h"
#include "iremote_proxy.h"
namespace OHOS {
@ -30,9 +29,7 @@ namespace Accessibility {
* The class supply the callback to feedback the result from UI to AA.
*/
class AccessibilityElementOperatorCallbackProxy :
public IRemoteProxy<IAccessibilityElementOperatorCallback>
{
class AccessibilityElementOperatorCallbackProxy : public IRemoteProxy<IAccessibilityElementOperatorCallback> {
public:
/**
* @brief construct function
@ -108,7 +105,6 @@ private:
bool WriteParcelableVector(const std::vector<T> &parcelableVector, Parcel &reply);
static inline BrokerDelegator<AccessibilityElementOperatorCallbackProxy> delegator;
};
} // namespace Accessibility
} // namespace OHOS
#endif

View File

@ -31,8 +31,7 @@ namespace Accessibility {
* The class define the interface for UI to implement.
* It triggered by ABMS when AA to request the accessibility information.
*/
class AccessibilityElementOperatorCallbackStub : public IRemoteStub<IAccessibilityElementOperatorCallback>
{
class AccessibilityElementOperatorCallbackStub : public IRemoteStub<IAccessibilityElementOperatorCallback> {
public:
/**
* @brief construct function
@ -99,11 +98,10 @@ private:
*/
ErrCode HandleSetExecuteActionResult(MessageParcel &data, MessageParcel &reply);
using AccessibilityElementOperatorCallbackFunc = ErrCode (AccessibilityElementOperatorCallbackStub::*)
(MessageParcel &data, MessageParcel &reply);
using AccessibilityElementOperatorCallbackFunc =
ErrCode (AccessibilityElementOperatorCallbackStub::*)(MessageParcel &data, MessageParcel &reply);
std::map<uint32_t, AccessibilityElementOperatorCallbackFunc> memberFuncMap_;
};
} // namespace Accessibility
} // namespace OHOS
#endif

View File

@ -18,11 +18,10 @@
#include <cstdint>
#include <list>
#include <string>
#include <map>
#include <string>
#include "accessibility_element_operator_callback_interface.h"
#include "iremote_broker.h"
#include "iremote_object.h"
#include "refbase.h"
@ -33,8 +32,7 @@ namespace Accessibility {
* The class define the interface for UI to implement.
* It triggered by ABMS when AA to request the accessibility information.
*/
class IAccessibilityElementOperator : public IRemoteBroker
{
class IAccessibilityElementOperator : public IRemoteBroker {
public:
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accessibility.IAccessibilityElementOperator");
@ -140,7 +138,6 @@ public:
OUTSIDE_TOUCH,
};
};
} // namespace Accessibility
} // namespace OHOS
#endif

View File

@ -18,8 +18,8 @@
#include <cstdint>
#include <list>
#include <vector>
#include <string>
#include <vector>
#include "accessibility_element_operator_interface.h"
#include "accessibility_element_operator_callback.h"
@ -34,8 +34,7 @@ namespace Accessibility {
* The class define the interface for UI to implement.
* It is triggered by ABMS when AA to request the accessibility information.
*/
class AccessibilityElementOperatorStub : public IRemoteStub<IAccessibilityElementOperator>
{
class AccessibilityElementOperatorStub : public IRemoteStub<IAccessibilityElementOperator> {
public:
/**
* @brief construct function
@ -313,14 +312,13 @@ private:
*/
ErrCode HandleOutsideTouch(MessageParcel &data, MessageParcel &reply);
using AccessibilityElementOperatorFunc = ErrCode (AccessibilityElementOperatorStub::*)
(MessageParcel &data, MessageParcel &reply);
std::map<uint32_t, AccessibilityElementOperatorFunc> memberFuncMap_ {};
using AccessibilityElementOperatorFunc =
ErrCode (AccessibilityElementOperatorStub::*)(MessageParcel &data, MessageParcel &reply);
std::map<uint32_t, AccessibilityElementOperatorFunc> memberFuncMap_;
static std::map<const int, const sptr<IAccessibilityElementOperatorCallback>> aaCallbacks_;
int windowId_ = 0;
DISALLOW_COPY_AND_MOVE(AccessibilityElementOperatorStub);
};
} // namespace Accessibility
} // namespace OHOS
#endif

View File

@ -42,8 +42,7 @@ namespace Accessibility {
* --> UI process and set Callback).
* It supply one instance for each thread to use this class.
*/
class AccessibilityOperator : public AccessibilityElementOperatorCallbackStub
{
class AccessibilityOperator : public AccessibilityElementOperatorCallbackStub {
public:
static const int NONE_ID = -1;
static const int MAX_INSTANCE = 10;
@ -118,8 +117,8 @@ public:
* @return -
*/
bool SearchElementInfosByAccessibilityId(int channelId,
int accessibilityWindowId, int elementId,
int mode, std::vector<AccessibilityElementInfo> &elementInfos);
int accessibilityWindowId, int elementId,
int mode, std::vector<AccessibilityElementInfo> &elementInfos);
/**
* @brief Find the node information filtered by text.
@ -145,7 +144,7 @@ public:
* @return -
*/
bool FindFocusedElementInfo(int channelId, int accessibilityWindowId,
int elementId, int focusType, AccessibilityElementInfo &elementInfo);
int elementId, int focusType, AccessibilityElementInfo &elementInfo);
/**
* @brief Find the node information by focus move direction.
@ -158,7 +157,7 @@ public:
* @return -
*/
bool FocusMoveSearch(int channelId, int accessibilityWindowId,
int elementId, int direction, AccessibilityElementInfo &elementInfo);
int elementId, int direction, AccessibilityElementInfo &elementInfo);
/**
* @brief Perform the action on the component.
@ -184,7 +183,7 @@ public:
* @return true: Perform action successfully; otherwise is not.
*/
bool ExecuteAction(int channelId, int accessibilityWindowId,
int elementId, int action, std::map<std::string, std::string> &actionArguments);
int elementId, int action, std::map<std::string, std::string> &actionArguments);
/**
* @brief Save the elements information searched in ACE side
@ -314,12 +313,11 @@ private:
static std::map<int, sptr<IAccessibleAbilityChannel>> channels_;
AccessibilityElementAsyncOperatorMng asyncElementOperatorMng_ = {};
AccessibilityElementInfo accessibilityInfoResult_ = {};
std::vector<AccessibilityElementInfo> elementInfosResult_ = {};
std::vector<AccessibilityWindowInfo> windows_ = {};
std::vector<AccessibilityElementInfo> elementInfosResult_;
std::vector<AccessibilityWindowInfo> windows_;
bool executeActionResult_ = false;
static std::recursive_mutex mutex_;
};
} // namespace Accessibility
} // namespace OHOS
#endif

View File

@ -30,8 +30,7 @@
namespace OHOS {
namespace Accessibility {
class IAccessibleAbilityChannel : public IRemoteBroker
{
class IAccessibleAbilityChannel : public IRemoteBroker {
public:
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accessibility.IAccessibleAbilityChannel");
@ -202,9 +201,7 @@ public:
SET_DISPLAYRESIZE_SCALE_AND_CENTER,
SEND_SIMULATE_GESTURE,
};
};
} // namespace Accessibility
} // namespace OHOS
#endif // ACCESSIBLE_ABILITY_CHANNEL_INTERFACE_H

View File

@ -26,9 +26,7 @@
namespace OHOS {
namespace Accessibility {
class AccessibleAbilityChannelProxy : public IRemoteProxy<IAccessibleAbilityChannel>
{
class AccessibleAbilityChannelProxy : public IRemoteProxy<IAccessibleAbilityChannel> {
public:
/**
* @brief construct function
@ -211,10 +209,9 @@ private:
* @return true: Write the descriptor successfully; otherwise is not.
*/
bool SendTransactCmd(IAccessibleAbilityChannel::Message code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
MessageParcel &reply, MessageOption &option);
static inline BrokerDelegator<AccessibleAbilityChannelProxy> delegator;
};
} // namespace Accessibility
} // namespace OHOS
#endif // ACCESSIBLE_ABILITY_CHANNEL_PROXY_H

View File

@ -28,9 +28,7 @@
namespace OHOS {
namespace Accessibility {
class AccessibleAbilityChannelStub : public IRemoteStub<IAccessibleAbilityChannel>
{
class AccessibleAbilityChannelStub : public IRemoteStub<IAccessibleAbilityChannel> {
public:
/**
* @brief construct function
@ -55,7 +53,7 @@ public:
* @return
*/
virtual int OnRemoteRequest(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option) override;
MessageParcel &reply, MessageOption &option) override;
private:
/**
* @brief Handle the IPC request for the function:HandleSearchElementInfoByAccessibilityId.
@ -177,14 +175,12 @@ private:
*/
ErrCode HandleSendSimulateGesture(MessageParcel &data, MessageParcel &reply);
using AccessibleAbilityConnectionFunc = ErrCode (AccessibleAbilityChannelStub::*)(MessageParcel &data,
MessageParcel &reply);
using AccessibleAbilityConnectionFunc =
ErrCode (AccessibleAbilityChannelStub::*)(MessageParcel &data, MessageParcel &reply);
std::map<uint32_t, AccessibleAbilityConnectionFunc> memberFuncMap_;
DISALLOW_COPY_AND_MOVE(AccessibleAbilityChannelStub);
};
} // namespace Accessibility
} // namespace OHOS
#endif // ACCESSIBLE_ABILITY_CHANNEL_STUB_H

View File

@ -23,8 +23,7 @@
namespace OHOS {
namespace Accessibility {
class IAccessibleAbilityManagerServiceState : public IRemoteBroker
{
class IAccessibleAbilityManagerServiceState : public IRemoteBroker {
public:
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accessibility.IAccessibleAbilityManagerServiceState");
@ -42,7 +41,6 @@ public:
ON_STATE_CHANGED,
};
};
} // namespace Accessibility
} // namespace OHOS
#endif

View File

@ -23,8 +23,7 @@
namespace OHOS {
namespace Accessibility {
class AccessibleAbilityManagerServiceStateProxy : public IRemoteProxy<IAccessibleAbilityManagerServiceState>
{
class AccessibleAbilityManagerServiceStateProxy : public IRemoteProxy<IAccessibleAbilityManagerServiceState> {
public:
/**
* @brief construct function
@ -58,7 +57,6 @@ private:
bool WriteInterfaceToken(MessageParcel &data);
static inline BrokerDelegator<AccessibleAbilityManagerServiceStateProxy> delegator;
};
} // namespace Accessibility
} // namespace OHOS
#endif

View File

@ -26,8 +26,7 @@
namespace OHOS {
namespace Accessibility {
class AccessibleAbilityManagerServiceStateStub : public IRemoteStub<IAccessibleAbilityManagerServiceState>
{
class AccessibleAbilityManagerServiceStateStub : public IRemoteStub<IAccessibleAbilityManagerServiceState> {
public:
/**
* @brief construct function
@ -74,7 +73,6 @@ private:
DISALLOW_COPY_AND_MOVE(AccessibleAbilityManagerServiceStateStub);
};
} // namespace Accessibility
} // namespace OHOS
#endif

View File

@ -22,8 +22,7 @@
namespace OHOS {
namespace Accessibility {
class GesturePathPositionDefine : public Parcelable
{
class GesturePathPositionDefine : public Parcelable {
public:
GesturePathPositionDefine() {}
~GesturePathPositionDefine() {}
@ -80,18 +79,17 @@ public:
static GesturePathPositionDefine *Unmarshalling(Parcel &parcel);
private:
float positionX_ = 0;
float positionY_ = 0;
float positionX_ = .0f;
float positionY_ = .0f;
};
class GesturePathDefine : public Parcelable
{
class GesturePathDefine : public Parcelable {
public:
GesturePathDefine() {}
~GesturePathDefine() {}
GesturePathDefine(GesturePathPositionDefine &startPosition,
GesturePathPositionDefine &endPosition, uint32_t durationTime);
GesturePathPositionDefine &endPosition, uint32_t durationTime);
/**
* @brief Obtains the duration for completing the maximum number of gesture strokes.
@ -179,10 +177,8 @@ private:
uint32_t durationTime_ = 0;
};
class GestureResultListener
{
class GestureResultListener {
public:
/**
* @brief Called when the gesture is finished.
* @param sequence
@ -191,8 +187,6 @@ public:
*/
virtual void OnGestureInjectResult(uint32_t sequence, bool result) = 0;
};
} // namespace Accessibility
} // namespace OHOS
#endif // GESTURE_SIMULATION_H

View File

@ -55,8 +55,8 @@ bool AccessibilityAbilityInfo::ParseAAConfig(nlohmann::json sourceJson)
//accessibilityCapabilities
vector<string> capabilities;
if (!JsonUtils::GetStringVecFromJson(
sourceJson, AccessibleAbility_JSON_KEY_ACCESSIBILITY_CAPABILITIES,
capabilities)) {
sourceJson, AccessibleAbility_JSON_KEY_ACCESSIBILITY_CAPABILITIES,
capabilities)) {
HILOG_ERROR("Get stringVec from json failed.");
return false;
}
@ -64,19 +64,19 @@ bool AccessibilityAbilityInfo::ParseAAConfig(nlohmann::json sourceJson)
//accessibilityCapabilityRationale
if (!JsonUtils::GetStringFromJson(
sourceJson,
AccessibleAbility_JSON_KEY_ACCESSIBILITY_CAPABILITIES_RATIONALE,
rationale_)) {
HILOG_ERROR("Get stringVec from json failed.");
return false;
sourceJson,
AccessibleAbility_JSON_KEY_ACCESSIBILITY_CAPABILITIES_RATIONALE,
rationale_)) {
HILOG_ERROR("Get stringVec from json failed.");
return false;
}
// settingsAbility
if (!JsonUtils::GetStringFromJson(
sourceJson, AccessibleAbility_JSON_KEY_SETTINGS_ABILITY,
settingsAbility_)) {
HILOG_ERROR("Get stringVec from json failed.");
return false;
sourceJson, AccessibleAbility_JSON_KEY_SETTINGS_ABILITY,
settingsAbility_)) {
HILOG_ERROR("Get stringVec from json failed.");
return false;
}
return true;
}

View File

@ -344,9 +344,8 @@ bool AccessibilityElementInfo::ExecuteAction(const ActionType &action,
__func__, channelId_, windowId_, elementId_);
AccessibilityOperator *instance = &AccessibilityOperator::GetInstance();
if (instance != nullptr) {
return instance->ExecuteAction(channelId_,
windowId_, elementId_, action,
const_cast<std::map<std::string, std::string> &>(actionArguments));
return instance->ExecuteAction(channelId_, windowId_, elementId_, action,
const_cast<std::map<std::string, std::string> &>(actionArguments));
} else {
HILOG_INFO("[%{public}s] called] Can't get AccessibilityOperator instance", __func__);
return false;
@ -377,7 +376,7 @@ bool AccessibilityElementInfo::GetElementInfosById(const int elementId, int mode
bool result = false;
if (instance != nullptr) {
result = instance->SearchElementInfosByAccessibilityId(channelId_,
windowId_, elementId, mode, elementInfos);
windowId_, elementId, mode, elementInfos);
} else {
HILOG_INFO("[%{public}s] called] Can't get AccessibilityOperator instance", __func__);
}
@ -900,7 +899,7 @@ bool AccessibilityElementInfo::GetLabeled(AccessibilityElementInfo &elementInfo)
bool result = false;
if (instance != nullptr) {
result = instance->SearchElementInfosByAccessibilityId(channelId_,
windowId_, labeled_, 0, elementInfos);
windowId_, labeled_, 0, elementInfos);
if (elementInfos.empty()) {
result = false;
} else {

View File

@ -52,7 +52,7 @@ int AccessibilityElementOperatorCallbackStub::OnRemoteRequest(uint32_t code, Mes
MessageParcel &reply, MessageOption &option)
{
HILOG_DEBUG("AccessibilityElementOperatorCallbackStub::OnRemoteRequest, cmd = %d, flags= %d",
code, option.GetFlags());
code, option.GetFlags());
std::u16string descriptor = AccessibilityElementOperatorCallbackStub::GetDescriptor();
std::u16string remoteDescriptor = data.ReadInterfaceToken();

View File

@ -25,6 +25,7 @@
namespace OHOS {
namespace Accessibility {
using AccessibilityElementOperatorCallbacks = std::map<const int, const sptr<IAccessibilityElementOperatorCallback>>;
std::map<const int, const sptr<IAccessibilityElementOperatorCallback>>
AccessibilityElementOperatorStub::aaCallbacks_ = {};
AccessibilityElementOperatorStub::AccessibilityElementOperatorStub()
@ -381,8 +382,7 @@ void AccessibilityElementOperatorStub::CallbackImpl::SetExecuteActionResult(
RemoveAACallbackList(requestId);
}
std::map<const int, const sptr<IAccessibilityElementOperatorCallback>>
AccessibilityElementOperatorStub::CallbackImpl::GetAACallbackList()
AccessibilityElementOperatorCallbacks AccessibilityElementOperatorStub::CallbackImpl::GetAACallbackList()
{
HILOG_DEBUG("%{public}s", __func__);
return aaCallbacks_;

View File

@ -17,6 +17,7 @@
#include "ability_context.h"
#include "accessibility_element_operator.h"
#include "accessibility_element_operator_stub.h"
#include "accessibility_window_info.h"
#include "accessible_ability_manager_service_proxy.h"
#include "accessible_ability_manager_service_state_stub.h"
#include "accessible_ability_manager_service_caption_property_stub.h"
@ -24,7 +25,6 @@
#include "if_system_ability_manager.h"
#include "iservice_registry.h"
#include "system_ability_definition.h"
#include "accessibility_window_info.h"
using namespace OHOS::AppExecFwk;
using namespace std;
@ -388,8 +388,8 @@ bool AccessibilitySystemAbilityClient::CheckEventType(EventType eventType)
bool AccessibilitySystemAbilityClient::CheckActionType(ActionType actionType)
{
if ((actionType < ActionType::ACCESSIBILITY_ACTION_FOCUS) ||
((actionType > ActionType::ACCESSIBILITY_ACTION_DELETED)
&& (actionType != ActionType::ACCESSIBILITY_ACTION_TYPE_MASK))) {
((actionType > ActionType::ACCESSIBILITY_ACTION_DELETED) &&
(actionType != ActionType::ACCESSIBILITY_ACTION_TYPE_MASK))) {
HILOG_ERROR("[%{public}s] action type is invalid", __func__);
return false;
} else {
@ -823,10 +823,11 @@ bool AccessibilitySystemAbilityClient::SetEnabledObj(std::map<std::string, AppEx
std::map<std::string, AppExecFwk::ElementName> AccessibilitySystemAbilityClient::GetEnabledAbilities()
{
HILOG_DEBUG("[%{public}s]", __func__);
std::map<std::string, AppExecFwk::ElementName> it{};
auto proxyService = pimpl->GetService();
if (proxyService == nullptr) {
HILOG_ERROR("[%{public}s] Failed to get aams service", __func__);
std::map<std::string, AppExecFwk::ElementName> it;
return it;
}
return proxyService->GetEnabledAbilities();
@ -910,6 +911,5 @@ int AccessibilitySystemAbilityClient::GetActiveWindow()
return proxyService->GetActiveWindow();
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -25,7 +25,6 @@ namespace Accessibility {
AccessibleAbilityChannelProxy::AccessibleAbilityChannelProxy(
const sptr<IRemoteObject> &object): IRemoteProxy<IAccessibleAbilityChannel>(object)
{
}
bool AccessibleAbilityChannelProxy::WriteInterfaceToken(MessageParcel &data)
@ -92,7 +91,7 @@ bool AccessibleAbilityChannelProxy::SearchElementInfoByAccessibilityId(const int
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SEARCH_ELEMENTINFO_BY_ACCESSIBILITYID,
data, reply, option)) {
data, reply, option)) {
HILOG_ERROR("fail to find elementInfo by elementId");
return false;
}
@ -134,7 +133,7 @@ bool AccessibleAbilityChannelProxy::SearchElementInfosByText(const int accessibi
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SEARCH_ELEMENTINFOS_BY_TEXT,
data, reply, option)) {
data, reply, option)) {
HILOG_ERROR("fail to find elementInfo by text");
return false;
}
@ -273,7 +272,7 @@ bool AccessibleAbilityChannelProxy::ExecuteAction(const int accessibilityWindowI
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::PERFORM_ACTION,
data, reply, option)) {
data, reply, option)) {
HILOG_ERROR("fail to perform accessibility action");
return false;
}
@ -354,7 +353,7 @@ void AccessibleAbilityChannelProxy::SetOnKeyPressEventResult(const bool handled,
return;
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SET_ON_KEY_PRESS_EVENT_RESULT,
data, reply, option)) {
data, reply, option)) {
HILOG_ERROR("fail to set onKeyPressEvent result");
}
}
@ -519,7 +518,7 @@ bool AccessibleAbilityChannelProxy::SetDisplayResizeScaleAndCenter(const int dis
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SET_DISPLAYRESIZE_SCALE_AND_CENTER,
data, reply, option)) {
data, reply, option)) {
HILOG_ERROR("fail to set displayResize scale and center");
return false;
}

View File

@ -66,7 +66,7 @@ int32_t AccessibleAbilityChannelStub::OnRemoteRequest(uint32_t code, MessageParc
MessageOption &option)
{
HILOG_DEBUG("AccessibleAbilityChannelStub::OnRemoteRequest, cmd = %{public}d, flags= %{public}d",
code, option.GetFlags());
code, option.GetFlags());
std::u16string descriptor = AccessibleAbilityChannelStub::GetDescriptor();
std::u16string remoteDescriptor = data.ReadInterfaceToken();
if (descriptor != remoteDescriptor) {
@ -175,7 +175,8 @@ ErrCode AccessibleAbilityChannelStub::HandleFocusMoveSearch(MessageParcel &data,
return NO_ERROR;
}
ErrCode AccessibleAbilityChannelStub::HandleExecuteAction(MessageParcel &data, MessageParcel &reply) {
ErrCode AccessibleAbilityChannelStub::HandleExecuteAction(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG("%{public}s start.", __func__);
int accessibilityWindowId = data.ReadInt32();
@ -319,7 +320,7 @@ ErrCode AccessibleAbilityChannelStub::HandleResetDisplayResize(MessageParcel &da
}
ErrCode AccessibleAbilityChannelStub::HandleSetDisplayResizeScaleAndCenter(MessageParcel &data,
MessageParcel &reply)
MessageParcel &reply)
{
HILOG_DEBUG("%{public}s start.", __func__);
@ -354,6 +355,5 @@ ErrCode AccessibleAbilityChannelStub::HandleSendSimulateGesture(MessageParcel &d
SendSimulateGesture(requestId, gestureSteps);
return NO_ERROR;
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -27,44 +27,36 @@ namespace Accessibility {
#define RECT_FOUR 4
bool MockAccessibleAbilityChannel::SearchElementInfoByAccessibilityId(const int accessibilityWindowId,
const long elementId, const int requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback,
const int mode)
const sptr<IAccessibilityElementOperatorCallback> &callback, const int mode)
{
GTEST_LOG_(INFO) << "MockAccessibleAbilityChannel::SearchElementInfoByAccessibilityId start";
return true;
}
bool MockAccessibleAbilityChannel::SearchElementInfosByText(const int accessibilityWindowId, const long elementId,
const std::string &text, const int requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback)
const std::string &text, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
{
GTEST_LOG_(INFO) << "MockAccessibleAbilityChannel::SearchElementInfosByText start";
return true;
}
bool MockAccessibleAbilityChannel::FindFocusedElementInfo(const int accessibilityWindowId, const long elementId,
const int focusType,
const int requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback)
const int focusType, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
{
GTEST_LOG_(INFO) << "MockAccessibleAbilityChannel::FindFocusedElementInfo start";
return true;
}
bool MockAccessibleAbilityChannel::FocusMoveSearch(const int accessibilityWindowId, const long elementId,
const int direction,
const int requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback)
const int direction, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
{
GTEST_LOG_(INFO) << "MockAccessibleAbilityChannel::FocusMoveSearch start";
return true;
}
bool MockAccessibleAbilityChannel::ExecuteAction(const int accessibilityWindowId, const long elementId,
const int action,
std::map<std::string, std::string> &actionArguments,
const int requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback)
const int action, std::map<std::string, std::string> &actionArguments,
const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
{
GTEST_LOG_(INFO) << "MockAccessibleAbilityChannel::ExecuteAction start";
return true;
@ -91,18 +83,18 @@ void MockAccessibleAbilityChannel::SetOnKeyPressEventResult(const bool handled,
float MockAccessibleAbilityChannel::GetDisplayResizeScale(const int displayId)
{
GTEST_LOG_(INFO) << "MockAccessibleAbilityChannel::GetDisplayResizeScale start";
return 1;
return 1.0f;
}
float MockAccessibleAbilityChannel::GetDisplayResizeCenterX(const int displayId)
{
GTEST_LOG_(INFO) << "MockAccessibleAbilityChannel::GetDisplayResizeCenterX start";
return 1;
return 1.0f;
}
float MockAccessibleAbilityChannel::GetDisplayResizeCenterY(const int displayId) {
GTEST_LOG_(INFO) << "MockAccessibleAbilityChannel::GetDisplayResizeCenterY start";
return 1;
return 1.0f;
}
Rect MockAccessibleAbilityChannel::GetDisplayResizeRect(const int displayId)
@ -119,8 +111,7 @@ bool MockAccessibleAbilityChannel::ResetDisplayResize(const int displayId, const
}
bool MockAccessibleAbilityChannel::SetDisplayResizeScaleAndCenter(const int displayId,
const float scale, const float centerX,
const float centerY, const bool animate)
const float scale, const float centerX, const float centerY, const bool animate)
{
GTEST_LOG_(INFO) << "MockAccessibleAbilityChannel::SetDisplayResizeScaleAndCenter start";
return true;

View File

@ -34,25 +34,30 @@ public:
{
return 1;
}
std::vector<AccessibilityAbilityInfo> GetAbilityList(const int abilityTypes, const int stateType)
{
std::vector<AccessibilityAbilityInfo> infos;
return infos;
}
void RegisterElementOperator(const int windowId,
const sptr<IAccessibilityElementOperator> &operation, const int accountId) {}
void DeregisterElementOperator(const int windowId) {}
uint32_t RegisterCaptionPropertyCallback(
const sptr<IAccessibleAbilityManagerServiceCaptionProperty>& callback, const int accountId)
uint32_t RegisterCaptionPropertyCallback(const sptr<IAccessibleAbilityManagerServiceCaptionProperty>& callback,
const int accountId)
{
return 0;
}
CaptionProperty GetCaptionProperty()
{
CaptionProperty cap;
return cap;
}
bool GetEnabledState()
{
return true;

View File

@ -50,20 +50,19 @@ public:
void AccessibilityAbilityInfoUnitTest::WritefileAll(const char* fname, const char* data)
{
FILE *fp;
if ((fp = fopen(fname, "w")) == NULL)
{
if ((fp = fopen(fname, "w")) == NULL) {
printf("open file %s fail \n", fname);
}
fprintf(fp, "%s", data);
(void)fprintf(fp, "%s", data);
fclose(fp);
}
void AccessibilityAbilityInfoUnitTest::CreateAccessibilityConfig()
{
std::ostringstream os;
Json::Value object1, targetBundleNames, accessibilityAbilityTypes, accessibilityEventTypes,
accessibilityCapabilities;
Json::Value object1, targetBundleNames;
Json::Value accessibilityAbilityTypes, accessibilityEventTypes, accessibilityCapabilities;
string jsonStr;
if (remove("/system/app/dummy_accessibility_ability_config.json") == 0) {

View File

@ -32,16 +32,20 @@ public:
AccessibilityOperatorUnitTest() {}
~AccessibilityOperatorUnitTest() {}
static void SetUpTestCase() {
static void SetUpTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityOperatorUnitTest Start";
}
static void TearDownTestCase() {
static void TearDownTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityOperatorUnitTest End";
}
void SetUp() {
void SetUp()
{
GTEST_LOG_(INFO) << "AccessibilityOperatorUnitTest SetUp()";
};
void TearDown() {
void TearDown()
{
GTEST_LOG_(INFO) << "AccessibilityOperatorUnitTest TearDown()";
}
};

View File

@ -30,21 +30,26 @@ public:
ASACStubUnitTest() {}
~ASACStubUnitTest() {}
static void SetUpTestCase() {
static void SetUpTestCase()
{
GTEST_LOG_(INFO) << "ASACStubUnitTest Start";
}
static void TearDownTestCase() {
static void TearDownTestCase()
{
GTEST_LOG_(INFO) << "ASACStubUnitTest End";
}
void SetUp() {
void SetUp()
{
GTEST_LOG_(INFO) << "ASACStubUnitTest SetUp()";
mockStub_ = new MockAccessibleAbilityManagerServiceStub();
};
void TearDown() {
void TearDown()
{
GTEST_LOG_(INFO) << "ASACStubUnitTest TearDown()";
mockStub_ = nullptr;
}
void WriteInterfaceToken(MessageParcel &data) {
void WriteInterfaceToken(MessageParcel &data)
{
GTEST_LOG_(INFO) << "ASACStateStubUnitTest WriteInterfaceToken";
data.WriteInterfaceToken(MockAccessibleAbilityManagerServiceStub::GetDescriptor());
}

View File

@ -16,21 +16,17 @@
#ifndef ACCESSIBILITY_EXTENSION_CONTEXT_H
#define ACCESSIBILITY_EXTENSION_CONTEXT_H
#include <map>
#include <memory>
#include <optional>
#include <stdint.h>
#include <vector>
#include <map>
#include "key_event.h"
#include "accessibility_element_info.h"
#include "accessibility_window_info.h"
#include "accessibility_event_info.h"
#include "extension_context.h"
#include "accessible_ability_manager_service_interface.h"
#include "display_resize_controller.h"
#include "extension_context.h"
#include "gesture_simulation.h"
#include "hilog_wrapper.h"
#include "key_event.h"
namespace OHOS {
namespace Accessibility {
@ -126,10 +122,10 @@ private:
*/
bool CheckCommonAction(uint32_t action);
std::vector<AccessibilityWindowInfo> accessibilityWindow_ {};
std::map<uint32_t, std::shared_ptr<GestureResultListener>> gestureResultListenerInfos_ {};
std::map<uint32_t, std::shared_ptr<DisplayResizeController>> displayResizeControllers_ {};
uint32_t channelId_ = 0xFFFFFFFF;
std::vector<AccessibilityWindowInfo> accessibilityWindow_ {};
std::map<uint32_t, std::shared_ptr<GestureResultListener>> gestureResultListenerInfos_;
std::map<uint32_t, std::shared_ptr<DisplayResizeController>> displayResizeControllers_;
};
} // namespace Accessibility
} // namespace OHOS

View File

@ -17,53 +17,47 @@
#define ACCESSIBILITY_UI_TEST_ABILITY_H
#include <memory>
#include "accessible_ability_client_stub_impl.h"
#include "accessible_ability_manager_service_proxy.h"
#include "accessibility_extension_context.h"
#include "accessibility_ui_test_ability_listener.h"
namespace OHOS {
namespace Accessibility {
class AccessibilityUITestAbility final : public AccessibilityExtensionContext {
class AccessibilityUITestAbility : public AccessibilityExtensionContext {
public:
~AccessibilityUITestAbility() = default;
/**
* @brief Destruct
* @param
* @return
*/
virtual ~AccessibilityUITestAbility() = default;
/**
* @brief Gets an instance of AccessibleAbility.
* @param
* @return Return an instance of AccessibleAbility.
*/
static AccessibilityUITestAbility& GetInstance();
static std::shared_ptr<AccessibilityUITestAbility> GetInstance();
/**
* @brief RegisterListener
* @param
* @return
*/
bool RegisterListener(const std::shared_ptr<IAccessibleUITestAbilityListener> &listener);
virtual bool RegisterListener(const std::shared_ptr<IAccessibleUITestAbilityListener> &listener) = 0;
/**
* @brief Connect to AAMS.
* @param
* @return
*/
bool Connect();
virtual bool Connect() = 0;
/**
* @brief disconnect to AAMS.
* @param
* @return
*/
bool Disconnect();
private:
AccessibilityUITestAbility();
void GetService();
sptr<AccessibleAbilityClientStubImpl> stub_ = nullptr;
sptr<AccessibleAbilityManagerServiceClientProxy> serviceProxy_ = nullptr;
static std::shared_ptr<AccessibilityUITestAbility> instance_;
* @brief disconnect to AAMS.
* @param
* @return
*/
virtual bool Disconnect() = 0;
};
} // namespace Accessibility
} // namespace OHOS

View File

@ -49,5 +49,4 @@ public:
};
} // namespace Accessibility
} // namespace OHOS
#endif // ACCESSIBILITY_UI_TEST_ABILITY_LISTENER_H

View File

@ -1443,7 +1443,7 @@ public:
/**
* @brief Set whether this node has live region
* @param liveRegion live region: 0: not live region; 1: interrupt current talkback; 2: talk back by order
* @param liveRegion live region: 0: not live region; 1: interrupt current talk back; 2: talk back by order
* @return
* @since 3
* @sysCap Accessibility
@ -1808,7 +1808,7 @@ private:
int beginIndex_ = 0;
int endIndex_ = 0;
RangeInfo rangeInfo_ {};
GridInfo grid_{};
GridInfo grid_ {};
GridItemInfo gridItem_ {};
int liveRegion_ = 0;
bool contentInvalid_ = true;

View File

@ -100,7 +100,8 @@ public:
* actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
* @return
*/
virtual void ExecuteAction(const long elementId, const int action, const std::map<std::string, std::string> actionArguments,
virtual void ExecuteAction(const long elementId, const int action,
const std::map<std::string, std::string> actionArguments,
const int requestId, AccessibilityElementOperatorCallback &callback) = 0;
/**

View File

@ -34,6 +34,8 @@ ohos_shared_library("accessibility") {
sources = [
"./src/napi_accessibility_event_info.cpp",
"./src/napi_accessibility_gesture_pos.cpp",
"./src/napi_accessibility_gesture_path.cpp",
"./src/napi_accessibility_info.cpp",
"./src/napi_accessibility_system_ability_client.cpp",
"./src/napi_accessibility_utils.cpp",

View File

@ -20,8 +20,7 @@ extern const char _binary_accessibility_extension_context_js_end[];
extern const char _binary_accessibility_extension_context_abc_start[];
extern const char _binary_accessibility_extension_context_abc_end[];
extern "C" __attribute__((constructor))
void NAPI_application_AccessibilityExtensionContext_AutoRegister()
extern "C" __attribute__((constructor)) void NAPI_application_AccessibilityExtensionContext_AutoRegister()
{
auto moduleManager = NativeModuleManager::GetInstance();
NativeModule newModuleInfo = {
@ -32,8 +31,8 @@ void NAPI_application_AccessibilityExtensionContext_AutoRegister()
moduleManager->Register(&newModuleInfo);
}
extern "C" __attribute__((visibility("default")))
void NAPI_application_AccessibilityExtensionContext_GetJSCode(const char **buf, int *bufLen)
extern "C" __attribute__((visibility("default"))) void NAPI_application_AccessibilityExtensionContext_GetJSCode(
const char **buf, int *bufLen)
{
if (buf != nullptr) {
*buf = _binary_accessibility_extension_context_js_start;
@ -45,8 +44,8 @@ void NAPI_application_AccessibilityExtensionContext_GetJSCode(const char **buf,
}
// accessibility extension context JS register
extern "C" __attribute__((visibility("default")))
void NAPI_application_AccessibilityExtensionContext_GetABCCode(const char **buf, int *buflen)
extern "C" __attribute__((visibility("default"))) void NAPI_application_AccessibilityExtensionContext_GetABCCode(
const char **buf, int *buflen)
{
if (buf != nullptr) {
*buf = _binary_accessibility_extension_context_abc_start;

View File

@ -0,0 +1,29 @@
/*
* Copyright (C) 2021 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 NAPI_ACCESSIBILITY_GESTURE_PATH_H
#define NAPI_ACCESSIBILITY_GESTURE_PATH_H
#include "napi/native_api.h"
#include "napi/native_node_api.h"
class NGesturePath {
public:
static napi_value pathCons_;
static void DefineJSGesturePath(napi_env env);
static napi_value JSPathConstructor(napi_env env, napi_callback_info info);
};
#endif // NAPI_ACCESSIBILITY_GESTURE_PATH_H

View File

@ -0,0 +1,29 @@
/*
* Copyright (C) 2021 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 NAPI_ACCESSIBILITY_GESTURE_POS_H
#define NAPI_ACCESSIBILITY_GESTURE_POS_H
#include "napi/native_api.h"
#include "napi/native_node_api.h"
class NGesturePos {
public:
static napi_value posCons_;
static void DefineJSGesturePos(napi_env env);
static napi_value JSPosConstructor(napi_env env, napi_callback_info info);
};
#endif // NAPI_ACCESSIBILITY_GESTURE_POS_H

View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2021 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 "napi_accessibility_gesture_path.h"
#include "napi_accessibility_utils.h"
using namespace OHOS;
using namespace OHOS::Accessibility;
napi_value NGesturePath::pathCons_ = nullptr;
void NGesturePath::DefineJSGesturePath(napi_env env)
{
NAPI_CALL_RETURN_VOID(env,
napi_define_class(env,
"GesturePath",
NAPI_AUTO_LENGTH,
NGesturePath::JSPathConstructor,
nullptr,
0,
nullptr,
&NGesturePath::pathCons_));
}
napi_value NGesturePath::JSPathConstructor(napi_env env, napi_callback_info info)
{
napi_value jsthis = nullptr;
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &jsthis, nullptr));
return jsthis;
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2021 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 "hilog_wrapper.h"
#include "napi_accessibility_gesture_pos.h"
#include "napi_accessibility_utils.h"
using namespace OHOS;
using namespace OHOS::Accessibility;
napi_value NGesturePos::posCons_ = nullptr;
void NGesturePos::DefineJSGesturePos(napi_env env)
{
NAPI_CALL_RETURN_VOID(env,
napi_define_class(env,
"GesturePos",
NAPI_AUTO_LENGTH,
NGesturePos::JSPosConstructor,
nullptr,
0,
nullptr,
&NGesturePos::posCons_));
}
napi_value NGesturePos::JSPosConstructor(napi_env env, napi_callback_info info)
{
size_t argc = ARGS_SIZE_TWO;
napi_value argv[ARGS_SIZE_TWO] = {0};
napi_value jsthis = nullptr;
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &jsthis, nullptr));
uint32_t x=0, y=0;
ParseUint32(env, x, argv[PARAM0]);
ParseUint32(env, y, argv[PARAM1]);
HILOG_INFO("JSPosConstructor, x:%{public}d, y:%{public}d", x, y);
napi_set_named_property(env, jsthis, "posX", argv[PARAM0]);
napi_set_named_property(env, jsthis, "posY", argv[PARAM1]);
return jsthis;
}

View File

@ -71,7 +71,7 @@ napi_value NElementInfo::ExecuteAction(napi_env env, napi_callback_info info)
}
NAccessibilityInfoData *callbackInfo = new NAccessibilityInfoData();
ConvertActionArgsJSToNAPI(env, argv[argc - 1], callbackInfo->actionArguments_,
ConvertStringToAccessibleOperationType(action));
ConvertStringToAccessibleOperationType(action));
callbackInfo->nativeNodeInfo_ = *nodeInfo;
callbackInfo->content_ = action;
napi_value promise = nullptr;
@ -361,7 +361,7 @@ napi_value NElementInfo::GetNext(napi_env env, napi_callback_info info)
NAccessibilityInfoData *callbackInfo = (NAccessibilityInfoData*)data;
AccessibilityElementInfo nodeInfo = callbackInfo->nativeNodeInfo_;
callbackInfo->ret_ = nodeInfo.GetNext(CovertStringToDirection(callbackInfo->content_),
callbackInfo->nodeInfo_);
callbackInfo->nodeInfo_);
},
[](napi_env env, napi_status status, void* data) { //execute the complete function
HILOG_DEBUG("GetNext execute back");

View File

@ -535,8 +535,8 @@ napi_value NAccessibilityClient::SetCaptionProperty(napi_env env, napi_callback_
// execute async to call c++ function
[](napi_env env, void* data) {
NAccessibilitySystemAbilityClient* callbackInfo = (NAccessibilitySystemAbilityClient*)data;
callbackInfo->setCaptionPropertyReturn_ =
AccessibilitySystemAbilityClient::GetInstance()->SetCaptionPropertyTojson(callbackInfo->captionProperty_);
callbackInfo->setCaptionPropertyReturn_ = AccessibilitySystemAbilityClient::GetInstance()
->SetCaptionPropertyTojson(callbackInfo->captionProperty_);
},
// execute the complete function
[](napi_env env, napi_status status, void* data) {
@ -672,7 +672,8 @@ napi_value NAccessibilityClient::SetCaptionState(napi_env env, napi_callback_inf
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_value returnVal;
napi_status retStatus = napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &returnVal);
napi_status retStatus =
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &returnVal);
napi_delete_reference(env, callbackInfo->callback_);
HILOG_DEBUG("napi_call_function return: %{public}d", retStatus);
} else {
@ -1530,7 +1531,7 @@ napi_value NAccessibilityClient::GetCaptionStyle(napi_env env, napi_callback_inf
{
HILOG_INFO("%{public}s start", __func__);
OHOS::Accessibility::CaptionProperty captionProperty{};
OHOS::Accessibility::CaptionProperty captionProperty {};
napi_value captionStyle = nullptr;
captionProperty = AccessibilitySystemAbilityClient::GetInstance()->GetCaptionProperty();
@ -1825,7 +1826,8 @@ napi_value NAccessibilityClient::SetCaptionsFontFamily(napi_env env, napi_callba
captionProperty.SetFontFamily(std::string(outBuffer));
returnVal = AccessibilitySystemAbilityClient::GetInstance()->SetCaptionPropertyTojson(captionProperty);
HILOG_INFO("%{public}s SetCaptionPropertyTojson() return = %{public}s", __func__, returnVal?"True":"False");
HILOG_INFO("%{public}s SetCaptionPropertyTojson() return = %{public}s",
__func__, returnVal ? "True" : "False");
} else {
HILOG_INFO("%{public}s argc size Error", __func__);
}
@ -1873,7 +1875,8 @@ napi_value NAccessibilityClient::SetCaptionsFontScale(napi_env env, napi_callbac
captionProperty.SetFontScale(num);
returnVal = AccessibilitySystemAbilityClient::GetInstance()->SetCaptionPropertyTojson(captionProperty);
HILOG_INFO("%{public}s SetCaptionPropertyTojson() return = %{public}s", __func__, returnVal?"True":"False");
HILOG_INFO("%{public}s SetCaptionPropertyTojson() return = %{public}s",
__func__, returnVal ? "True" : "False");
} else {
HILOG_INFO("%{public}s argc size Error", __func__);
}
@ -1922,7 +1925,8 @@ napi_value NAccessibilityClient::SetCaptionFrontColor(napi_env env, napi_callbac
captionProperty.SetFontColor(std::string(outBuffer));
returnVal = AccessibilitySystemAbilityClient::GetInstance()->SetCaptionPropertyTojson(captionProperty);
HILOG_INFO("%{public}s SetCaptionPropertyTojson() return = %{public}s", __func__, returnVal?"True":"False");
HILOG_INFO("%{public}s SetCaptionPropertyTojson() return = %{public}s",
__func__, returnVal ? "True" : "False");
} else {
HILOG_INFO("%{public}s argc size Error", __func__);
}
@ -1971,7 +1975,8 @@ napi_value NAccessibilityClient::SetCaptionFontEdgeType(napi_env env, napi_callb
captionProperty.SetFontEdgeType(std::string(outBuffer));
returnVal = AccessibilitySystemAbilityClient::GetInstance()->SetCaptionPropertyTojson(captionProperty);
HILOG_INFO("%{public}s SetCaptionPropertyTojson() return = %{public}s", __func__, returnVal?"True":"False");
HILOG_INFO("%{public}s SetCaptionPropertyTojson() return = %{public}s",
__func__, returnVal ? "True" : "False");
} else {
HILOG_INFO("%{public}s argc size Error", __func__);
}
@ -2020,7 +2025,8 @@ napi_value NAccessibilityClient::SetCaptionBackgroundColor(napi_env env, napi_ca
captionProperty.SetBackgroundColor(std::string(outBuffer));
returnVal = AccessibilitySystemAbilityClient::GetInstance()->SetCaptionPropertyTojson(captionProperty);
HILOG_INFO("%{public}s SetCaptionPropertyTojson() return = %{public}s", __func__, returnVal?"True":"False");
HILOG_INFO("%{public}s SetCaptionPropertyTojson() return = %{public}s",
__func__, returnVal ? "True" : "False");
} else {
HILOG_INFO("%{public}s argc size Error", __func__);
}
@ -2069,7 +2075,8 @@ napi_value NAccessibilityClient::SetCaptionWindowColor(napi_env env, napi_callba
captionProperty.SetWindowColor(std::string(outBuffer));
returnVal = AccessibilitySystemAbilityClient::GetInstance()->SetCaptionPropertyTojson(captionProperty);
HILOG_INFO("%{public}s SetCaptionPropertyTojson() return = %{public}s", __func__, returnVal?"True":"False");
HILOG_INFO("%{public}s SetCaptionPropertyTojson() return = %{public}s",
__func__, returnVal ? "True" : "False");
} else {
HILOG_INFO("%{public}s argc size Error", __func__);
}

View File

@ -1554,7 +1554,7 @@ void ConvertGesturePathsJSToNAPI(napi_env env, napi_value object, std::vector<Ge
return;
}
ConvertGesturePathJSToNAPI(env, object, path);
ConvertGesturePathJSToNAPI(env, jsValue, path);
gesturePaths.push_back(path);
}
}

View File

@ -22,6 +22,8 @@
#include "napi/native_node_api.h"
#include "napi_accessibility_system_ability_client.h"
#include "napi_accessibility_event_info.h"
#include "napi_accessibility_gesture_path.h"
#include "napi_accessibility_gesture_pos.h"
#include "napi_accessibility_window_info.h"
#include "napi_accessibility_info.h"
@ -63,6 +65,10 @@ static napi_value Init(napi_env env, napi_value exports)
NAccessibilityWindowInfo::DefineJSAccessibilityWindowInfo(env);
NAccessibilityEventInfo::DefineJSAccessibilityEventInfo(env);
NAPI_CALL(env, napi_set_named_property(env, exports, "EventInfo", NAccessibilityEventInfo::cons_));
NGesturePos::DefineJSGesturePos(env);
NAPI_CALL(env, napi_set_named_property(env, exports, "GesturePos", NGesturePos::posCons_));
NGesturePath::DefineJSGesturePath(env);
NAPI_CALL(env, napi_set_named_property(env, exports, "GesturePath", NGesturePath::pathCons_));
HILOG_INFO("-----Init end------");
return exports;

View File

@ -43,6 +43,7 @@ namespace Accessibility {
#define MIN_PIXELS(xyDpi) ((xyDpi) * 0.1f)
#define POINTER_COUNT_1 1
#define POINTER_COUNT_2 2
#define US_TO_MS 1000
struct Pointer {
float px_;

View File

@ -19,14 +19,16 @@
#include <string>
#include "accessible_ability_manager_service.h"
#include "accessibility_element_info.h"
#include "accessibility_operator.h"
#include "accessibility_element_operator_interface.h"
#include "accessibility_operator.h"
#include "mmi_point.h"
namespace OHOS {
namespace Accessibility{
class AccessibilityInteractionBridge {
public:
~AccessibilityInteractionBridge() = default;
/**
* @brief Get the instance of Interaction Bridge.
* @return Returns Static reference the instance of Interaction Bridge.
@ -46,7 +48,7 @@ public:
*/
bool ExecuteActionOnAccessibilityFocused(const ActionType &action);
bool GetPointerItermOfAccessibilityFocusClick(MMI::PointerEvent::PointerItem &point);
~AccessibilityInteractionBridge() = default;
private:
AccessibilityInteractionBridge();
AccessibilityElementInfo FindFocusedElementInfo(const int &windowId);

View File

@ -96,7 +96,7 @@ public:
* @return
*/
void InjectEvents(const std::vector<GesturePathDefine> &gesturePath,
const sptr<IAccessibleAbilityClient> &service, int sequence );
const sptr<IAccessibleAbilityClient> &service, int sequence);
/**
* @brief Send pointer event to next stream node.
@ -117,7 +117,8 @@ public:
* @param
* @return the corresponding AccessiblityAbility
*/
sptr<IAccessibleAbilityClient> GetCurrentGestureService() {
sptr<IAccessibleAbilityClient> GetCurrentGestureService()
{
return currentGestureService_;
}
@ -126,7 +127,8 @@ public:
* @param
* @return the sequence of gesture
*/
int GetSequence() {
int GetSequence()
{
return sequence_;
}
@ -175,7 +177,8 @@ private:
* @param point the endpoint of event
* @return the created touchevent
*/
std::shared_ptr<MMI::PointerEvent> obtainTouchEvent(int action, MMI::PointerEvent::PointerItem point);
std::shared_ptr<MMI::PointerEvent> obtainTouchEvent(int action,
MMI::PointerEvent::PointerItem point, long actionTime);
/**
* @brief Get the number of milliseconds elapsed since the system was booted.

View File

@ -75,7 +75,7 @@ public:
*/
static AccessibilityZoomProxy &GetInstance()
{
static AccessibilityZoomProxy instance_ {};
static AccessibilityZoomProxy instance_;
return instance_;
}
@ -114,9 +114,18 @@ public:
void DeleteListener(AccessibilityDisplayResizeListener &listener) {}
void Register(int displayId) {}
void Unregister(int displayId) {}
bool IsRegistered(int displayId) { return false; }
bool IsRunning(int displayId) { return false; }
bool IsRegistered(int displayId)
{
return false;
}
bool IsRunning(int displayId)
{
return false;
}
/**
* @brief Gets the scale.
@ -126,7 +135,10 @@ public:
* @since 1.0
* @version 1.0
*/
float GetScale(int displayId) { return 0.0; }
float GetScale(int displayId)
{
return 0.0;
}
/**
* @brief Gets the screen-relative X coordinate that is centered.
@ -136,7 +148,10 @@ public:
* @since 1.0
* @version 1.0
*/
float GetCenterX(int displayId) { return 0.0; }
float GetCenterX(int displayId)
{
return 0.0;
}
/**
* @brief Gets the screen-relative Y coordinate that is centered.
@ -146,7 +161,10 @@ public:
* @since 1.0
* @version 1.0
*/
float GetCenterY(int displayId) { return 0.0; }
float GetCenterY(int displayId)
{
return 0.0;
}
/**
* @brief Gets the current magnification area.
@ -170,7 +188,10 @@ public:
* @since 1.0
* @version 1.0
*/
bool Reset(int displayId) { return false; }
bool Reset(int displayId)
{
return false;
}
/**
* @brief Set the magnification center and scale.
@ -182,10 +203,13 @@ public:
* @since 1.0
* @version 1.0
*/
bool SetScaleAndCenter(int displayId, float scale, float centerX, float centerY) { return false; }
bool SetScaleAndCenter(int displayId, float scale, float centerX, float centerY)
{
return false;
}
private:
std::vector<AccessibilityDisplayResizeListener> mListeners_ {};
std::vector<AccessibilityDisplayResizeListener> mListeners_;
/**
* @brief Set the magnification scale.
@ -196,8 +220,7 @@ private:
* @since 1.0
* @version 1.0
*/
bool SetScale(int displayId, float scale, float pivotX, float pivotY,
bool animate, int id)
bool SetScale(int displayId, float scale, float pivotX, float pivotY, bool animate, int id)
{
return false;
}
@ -211,7 +234,10 @@ private:
* @since 1.0
* @version 1.0
*/
bool SetCenter(int displayId, float centerX, float centerY, bool animate, int id) { return false; }
bool SetCenter(int displayId, float centerX, float centerY, bool animate, int id)
{
return false;
}
/**
* @brief Set the magnifying offset.

View File

@ -640,7 +640,7 @@ bool AccessibilityAccountData::GetInstalledAbilitiesFromBMS()
auto aams = DelayedSingleton<AccessibleAbilityManagerService>::GetInstance();
sptr<AppExecFwk::IBundleMgr> bms = nullptr;
bms = aams->GetBundleMgrProxy();
if(bms == nullptr) {
if (bms == nullptr) {
HILOG_ERROR("GetBundleMgrProxy failed.");
return false;
}

View File

@ -22,16 +22,15 @@ using namespace std;
using namespace OHOS::EventFwk;
using namespace OHOS::AAFwk;
namespace OHOS{
namespace Accessibility{
namespace OHOS {
namespace Accessibility {
AccessibilityCommonEventRegistry::AccessibilityCommonEventRegistry()
{
HILOG_DEBUG("AccessibilityCommonEventRegistry AccessibilityCommonEventRegistry");
handleEventFunc_[CommonEventSupport::COMMON_EVENT_USER_REMOVED] =
&AccessibilityCommonEventRegistry::HandleRemovedUser;
handleEventFunc_[CommonEventSupport::COMMON_EVENT_USER_REMOVED] =
&AccessibilityCommonEventRegistry::HandleRemovedUser;
handleEventFunc_[CommonEventSupport::COMMON_EVENT_USER_PRESENT] =
&AccessibilityCommonEventRegistry::HandlePresentUser;
handleEventFunc_[CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED] =
&AccessibilityCommonEventRegistry::HandlePackageAdd;
handleEventFunc_[CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED] =

View File

@ -15,11 +15,10 @@
#include "accessibility_gesture_recognizer.h"
namespace OHOS{
namespace Accessibility{
GestureHandler::GestureHandler(
const std::shared_ptr<AppExecFwk::EventRunner> &runner, AccessibilityGestureRecognizer &server)
: AppExecFwk::EventHandler(runner),server_(server)
namespace OHOS {
namespace Accessibility {
GestureHandler::GestureHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner,
AccessibilityGestureRecognizer &server) : AppExecFwk::EventHandler(runner), server_(server)
{
}
@ -148,7 +147,7 @@ void AccessibilityGestureRecognizer::HandleTouchDownEvent(MMI::PointerEvent &eve
pointerRoute_.push_back(mp);
prePointer_ = pointerIterm;
startPointer_ = pointerIterm;
startTime_ = event.GetActionTime();
startTime_ = event.GetActionTime() / US_TO_MS;
}
bool AccessibilityGestureRecognizer::HandleTouchMoveEvent(MMI::PointerEvent &event)
@ -160,7 +159,7 @@ bool AccessibilityGestureRecognizer::HandleTouchMoveEvent(MMI::PointerEvent &eve
if (!event.GetPointerItem(event.GetPointerId(), pointerIterm)) {
HILOG_ERROR("get GetPointerItem(%d) failed", event.GetPointerId());
}
unsigned int eventTime = event.GetActionTime();
unsigned int eventTime = event.GetActionTime() / US_TO_MS;
float offsetX = startPointer_.GetGlobalX() - pointerIterm.GetGlobalX();
float offsetY = startPointer_.GetGlobalY() - pointerIterm.GetGlobalY();
double duration = hypot(offsetX, offsetY);
@ -398,7 +397,7 @@ std::vector<Pointer> AccessibilityGestureRecognizer::GetPointerPath(std::vector<
bool AccessibilityGestureRecognizer::isDoubleTap(MMI::PointerEvent &event)
{
HILOG_DEBUG();
int durationTime = event.GetActionTime() - pPreUp_->GetActionTime();
int durationTime = (event.GetActionTime() - pPreUp_->GetActionTime()) / US_TO_MS;
if (!(durationTime <= DOUBLE_TAP_TIMEOUT && durationTime >= MIN_DOUBLE_TAP_TIME)) {
return false;
}

View File

@ -192,12 +192,12 @@ void AccessibilityInputInterceptor::DestroyTransmitters()
{
HILOG_DEBUG();
if (nullptr != pointerEventTransmitters_) {
if (pointerEventTransmitters_ != nullptr) {
pointerEventTransmitters_->DestroyEvents();
ams_->SetTouchEventInjector(nullptr);
pointerEventTransmitters_= nullptr;
}
if (nullptr != keyEventTransmitters_) {
if (keyEventTransmitters_ != nullptr) {
keyEventTransmitters_->DestroyEvents();
ams_->SetKeyEventFilter(nullptr);
keyEventTransmitters_ = nullptr;
@ -208,10 +208,10 @@ void AccessibilityInputInterceptor::NotifyAccessibilityEvent(AccessibilityEventI
{
HILOG_DEBUG();
if (nullptr != pointerEventTransmitters_) {
if (pointerEventTransmitters_ != nullptr) {
pointerEventTransmitters_->OnAccessibilityEvent(event);
}
if (nullptr != keyEventTransmitters_) {
if (keyEventTransmitters_ != nullptr) {
keyEventTransmitters_->OnAccessibilityEvent(event);
}
}
@ -220,7 +220,7 @@ void AccessibilityInputInterceptor::ProcessPointerEvent(std::shared_ptr<MMI::Poi
{
HILOG_DEBUG();
if (nullptr == pointerEventTransmitters_) {
if (pointerEventTransmitters_ == nullptr) {
HILOG_DEBUG("pointerEventTransmitters_ is empty.");
return;
}
@ -232,7 +232,7 @@ void AccessibilityInputInterceptor::ProcessKeyEvent(std::shared_ptr<MMI::KeyEven
{
HILOG_DEBUG();
if (nullptr == keyEventTransmitters_) {
if (keyEventTransmitters_ == nullptr) {
HILOG_DEBUG("keyEventTransmitters_ is empty.");
return;
}
@ -280,7 +280,7 @@ void AccessibilityInputEventConsumer::OnInputEvent(std::shared_ptr<MMI::KeyEvent
return;
}
if (nullptr == eventHandler_) {
if (eventHandler_ == nullptr) {
HILOG_DEBUG("eventHandler_ is empty.");
return;
}
@ -303,7 +303,7 @@ void AccessibilityInputEventConsumer::OnInputEvent(std::shared_ptr<MMI::PointerE
return;
}
if (nullptr == eventHandler_) {
if (eventHandler_ == nullptr) {
HILOG_DEBUG("eventHandler_ is empty.");
return;
}

View File

@ -13,8 +13,9 @@
* limitations under the License.
*/
#include <algorithm>
#include "accessibility_interaction_bridge.h"
#include <algorithm>
#include "accessibility_ability_info.h"
#include "accessibility_account_data.h"
#include "accessibility_display_manager.h"

View File

@ -20,12 +20,14 @@ namespace OHOS {
namespace Accessibility {
const int value_1000 = 1000;
const int value_1000000 = 1000000;
TouchInjectHandler::TouchInjectHandler(
const std::shared_ptr<AppExecFwk::EventRunner> &runner, TouchEventInjector &server)
: AppExecFwk::EventHandler(runner), server_(server) {
const int MS_TO_US = 1000;
TouchInjectHandler::TouchInjectHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner,
TouchEventInjector &server) : AppExecFwk::EventHandler(runner), server_(server)
{
}
void TouchInjectHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) {
void TouchInjectHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
{
std::shared_ptr<SendEventArgs> parameters = nullptr;
switch (event->GetInnerEventId()) {
case TouchEventInjector::SEND_TOUCH_EVENT_MSG:
@ -108,8 +110,8 @@ void TouchEventInjector::GetTapsEvents(long startTime)
float py = gesturePath_[i].GetStartPosition().GetPositionY();
pointer.SetGlobalX(px);
pointer.SetGlobalY(py);
pointer.SetDownTime(downTime);
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pointer);
pointer.SetDownTime(downTime * MS_TO_US);
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pointer, downTime);
HILOG_INFO("append down event");
injectedEvents_.push_back(event);
@ -119,11 +121,12 @@ void TouchEventInjector::GetTapsEvents(long startTime)
py = gesturePath_[i].GetEndPosition().GetPositionY();
pointer.SetGlobalX(px);
pointer.SetGlobalY(py);
pointer.SetDownTime(nowTime);
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pointer);
pointer.SetDownTime(downTime * MS_TO_US);
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pointer, nowTime);
HILOG_INFO("append up event");
injectedEvents_.push_back(event);
nowTime += DOUBLE_TAP_MIN_TIME;
downTime += DOUBLE_TAP_MIN_TIME;
}
}
@ -140,8 +143,8 @@ void TouchEventInjector::GetMovesEvents(long startTime)
pointer.SetPointerId(1);
pointer.SetGlobalX(px);
pointer.SetGlobalY(py);
pointer.SetDownTime(downTime);
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pointer);
pointer.SetDownTime(downTime * MS_TO_US);
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pointer, downTime);
HILOG_INFO("append down event");
injectedEvents_.push_back(event);
for (unsigned int i = 0; i < gesturePath_.size(); i++) {
@ -149,19 +152,19 @@ void TouchEventInjector::GetMovesEvents(long startTime)
py = gesturePath_[i].GetEndPosition().GetPositionY();
pointer.SetGlobalX(px);
pointer.SetGlobalY(py);
pointer.SetDownTime(nowTime);
pointer.SetDownTime(downTime * MS_TO_US);
HILOG_INFO("append move event");
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, pointer);
injectedEvents_.push_back(event);
nowTime += gesturePath_[i].GetDurationTime();
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, pointer, nowTime);
injectedEvents_.push_back(event);
}
/* append up event */
px = gesturePath_[gesturePath_.size() - 1].GetEndPosition().GetPositionX();
py = gesturePath_[gesturePath_.size() - 1].GetEndPosition().GetPositionY();
pointer.SetGlobalX(px);
pointer.SetGlobalY(py);
pointer.SetDownTime(nowTime);
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pointer);
pointer.SetDownTime(downTime * MS_TO_US);
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pointer, nowTime);
HILOG_INFO("append up event");
injectedEvents_.push_back(event);
}
@ -197,7 +200,7 @@ void TouchEventInjector::InjectEventsInner()
std::shared_ptr<SendEventArgs> parameters = std::make_shared<SendEventArgs>();
parameters->isLastEvent_ = (i == injectedEvents_.size() - 1) ? true : false;
parameters->event_ = injectedEvents_[i];
int64_t timeout = injectedEvents_[i]->GetActionTime() - curTime;
int64_t timeout = injectedEvents_[i]->GetActionTime() / MS_TO_US - curTime;
handler_->SendEvent(SEND_TOUCH_EVENT_MSG, parameters, timeout);
}
@ -225,10 +228,10 @@ void TouchEventInjector::CancelGesture()
MMI::PointerEvent::PointerItem pointer = {};
pointer.SetPointerId(1);
long time = getSystemTime();
pointer.SetDownTime((int32_t)time);
pointer.SetDownTime((int32_t)time * MS_TO_US);
pointer.SetPointerId(1);
if (GetNext() != nullptr && isGestureUnderway_) {
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_CANCEL, pointer);
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_CANCEL, pointer, time);
SendPointerEvent(*event);
isGestureUnderway_ = false;
}
@ -255,12 +258,15 @@ void TouchEventInjector::GetTouchEventsFromGesturePath(long startTime)
}
}
std::shared_ptr<MMI::PointerEvent> TouchEventInjector::obtainTouchEvent(int action, MMI::PointerEvent::PointerItem point)
std::shared_ptr<MMI::PointerEvent> TouchEventInjector::obtainTouchEvent(int action,
MMI::PointerEvent::PointerItem point, long actionTime)
{
HILOG_INFO("TouchEventInjector::obtainTouchEvent: start");
std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
pointerEvent->SetPointerId(point.GetPointerId());
pointerEvent->SetPointerAction(action);
pointerEvent->SetActionTime(actionTime * MS_TO_US);
pointerEvent->SetActionStartTime(point.GetDownTime());
pointerEvent->AddPointerItem(point);
pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
return pointerEvent;

View File

@ -18,8 +18,8 @@
#include "accessibility_interaction_bridge.h"
#include "securec.h"
namespace OHOS{
namespace Accessibility{
namespace OHOS {
namespace Accessibility {
TGEventHandler::TGEventHandler(
const std::shared_ptr<AppExecFwk::EventRunner> &runner, TouchGuider &tgServer)
: AppExecFwk::EventHandler(runner), tgServer_(tgServer)
@ -41,7 +41,7 @@ void TouchGuider::StartUp()
runner_ = pAams_->GetMainRunner();
if (!runner_) {
HILOG_ERROR("get runner failed");
return;
return;
}
handler_ = std::make_shared<TGEventHandler>(runner_, *this);
@ -167,7 +167,7 @@ void TouchGuider::SendEventToMultimodal(MMI::PointerEvent &event, int action)
HILOG_DEBUG("action is %{public}d.", action);
HILOG_DEBUG("SourceType is %{public}d.", event.GetSourceType());
switch(action){
switch (action) {
case HOVER_MOVE:
if (event.GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) {
event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_MOVE);
@ -223,7 +223,7 @@ void TouchGuider::TouchGuideListener::OnDoubleTapLongPress(MMI::PointerEvent &ev
}
if (server_.getLastReceivedEvent() &&
server_.getLastReceivedEvent()->GetPointersIdList().size() == 0) {
return;
return;
}
int ret = GetClickPosition(clickPoint);
if (ret == CLICK_NONE) {
@ -254,8 +254,8 @@ bool TouchGuider::TouchGuideListener::OnDoubleTap(MMI::PointerEvent &event)
server_.ForceSendAndRemoveEvent(server_.SEND_TOUCH_GUIDE_END_MSG, event);
server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END);
if (AccessibilityInteractionBridge::GetInstance()
.ExecuteActionOnAccessibilityFocused(ActionType::ACCESSIBILITY_ACTION_CLICK)) {
if (AccessibilityInteractionBridge::GetInstance().ExecuteActionOnAccessibilityFocused(
ActionType::ACCESSIBILITY_ACTION_CLICK)) {
return true;
}
int ret = GetClickPosition(clickPoint);
@ -685,7 +685,7 @@ void TouchGuider::RecordInjectedEvent(MMI::PointerEvent &event)
case MMI::PointerEvent::POINTER_ACTION_DOWN:
injectedRecorder_.downPointerNum++;
injectedRecorder_.downPointers |= (1 << pointerId);
injectedRecorder_.lastDownTime = event.GetActionTime();
injectedRecorder_.lastDownTime = event.GetActionTime() / US_TO_MS;
break;
case MMI::PointerEvent::POINTER_ACTION_UP:
injectedRecorder_.downPointers &= ~(1 << pointerId);

View File

@ -17,19 +17,18 @@
using namespace std;
namespace OHOS{
namespace Accessibility{
namespace OHOS {
namespace Accessibility {
AccessibilityWindowConnection::AccessibilityWindowConnection(const int windowId,
const sptr<IAccessibilityElementOperator> &connection, const int accountId) {
const sptr<IAccessibilityElementOperator> &connection, const int accountId)
{
windowId_ = windowId;
proxy_ = connection;
accountId_ = accountId;
}
AccessibilityWindowConnection::~AccessibilityWindowConnection() {
AccessibilityWindowConnection::~AccessibilityWindowConnection()
{
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -18,7 +18,8 @@
namespace OHOS {
namespace Accessibility {
void AccessibilityWindowListener::OnWindowUpdate(const sptr<Rosen::WindowInfo>& windowInfo, Rosen::WindowUpdateType type)
void AccessibilityWindowListener::OnWindowUpdate(const sptr<Rosen::WindowInfo>& windowInfo,
Rosen::WindowUpdateType type)
{
HILOG_DEBUG("%{public}s: windowId[%{public}d] type[%{public}d]", __func__, windowInfo->wid_, type);
auto aams = DelayedSingleton<AccessibleAbilityManagerService>::GetInstance();

View File

@ -996,7 +996,7 @@ void AccessibleAbilityManagerService::OnAddSystemAbility(int32_t systemAbilityId
break;
case BUNDLE_MGR_SERVICE_SYS_ABILITY_ID:
// Get installed accessibility extension ability from BMS
if(accountData->GetInstalledAbilitiesFromBMS()) {
if (accountData->GetInstalledAbilitiesFromBMS()) {
UpdateAbilities();
UpdateAccessibilityManagerService();
} else {

View File

@ -18,7 +18,8 @@
namespace OHOS {
namespace Accessibility {
AAMSEventHandler::AAMSEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner) : AppExecFwk::EventHandler(runner)
AAMSEventHandler::AAMSEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner)
: AppExecFwk::EventHandler(runner)
{
}

View File

@ -53,12 +53,10 @@ void AccessibilityAbilityInfo::SetPackageName(string bundleName)
AccessibilityAbilityInfo::AccessibilityAbilityInfo(ExtensionAbilityInfo abilityInfo)
{
AccessibilityAbilityInfoDummy accessibilityAbilityInfoDummydata;
// CAPABILITY_KEY_EVENT_OBSERVER | CAPABILITY_TOUCH_GUIDE | CAPABILITY_ZOOM | CAPABILITY_RETRIEVE | CAPABILITY_GESTURE
uint32_t capabilities = 0x0008 | 0x0002 | 0x0010 | 0x0001 | 0x0020;
capabilities_ = capabilities;
targetBundleNames_ = accessibilityAbilityInfoDummydata.filterBundleNames;
eventTypes_ = accessibilityAbilityInfoDummydata.accessibilityEventTypes;
eventTypes_ = 0xFFFFFFFF; // TYPES_ALL_MASK
name_ = abilityInfo.name;
bundleName_ = abilityInfo.bundleName;
}

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <vector>
#include "accessibility_element_operator_callback_stub.h"
#include "hilog_wrapper.h"
#include "ipc_skeleton.h"

View File

@ -444,7 +444,8 @@ void AccessibilityElementInfo::SetHint(const std::string &hintText)
}
std::string AccessibilityElementInfo::GetDescriptionInfo() const
{ return contentDescription_;
{
return contentDescription_;
}
void AccessibilityElementInfo::SetDescriptionInfo(const std::string contentDescription)

View File

@ -163,9 +163,9 @@ Rect AccessibilityWindowInfo::GetRectInScreen() const
void AccessibilityWindowInfo::SetRectInScreen(const Rect &bounds)
{
boundsInScreen_.SetLeftTopScreenPostion(const_cast<Rect &>(bounds).GetLeftTopXScreenPostion(),
const_cast<Rect &>(bounds).GetLeftTopYScreenPostion());
const_cast<Rect &>(bounds).GetLeftTopYScreenPostion());
boundsInScreen_.SetRightBottomScreenPostion(const_cast<Rect &>(bounds).GetRightBottomXScreenPostion(),
const_cast<Rect &>(bounds).GetRightBottomYScreenPostion());
const_cast<Rect &>(bounds).GetRightBottomYScreenPostion());
}
bool AccessibilityWindowInfo::IsActive() const

View File

@ -13,8 +13,8 @@
* limitations under the License.
*/
#include <cstdint>
#include <gtest/gtest.h>
#include <stdint.h>
#include "accessibility_account_data.h"
#include "accessibility_errorcode.h"
#include "accessibility_event_info.h"
@ -30,12 +30,11 @@ int g_testGesture = -1;
int g_testKeyPressEvent = -1;
int g_testDisplayId = -1;
int g_testGestureSimulateResult = -1;
OHOS::sptr<OHOS::Accessibility::IAccessibleAbilityChannel> testStub = nullptr;
namespace OHOS {
namespace Accessibility {
std::vector<EventType> g_mTeventType;
int g_mTgestureId = -1;
sptr<OHOS::Accessibility::IAccessibleAbilityChannel> g_testStub = nullptr;
AccessibleAbilityClientProxy::AccessibleAbilityClientProxy(const sptr<IRemoteObject> &object)
: IRemoteProxy<IAccessibleAbilityClient>(object)
@ -49,7 +48,7 @@ bool AccessibleAbilityClientProxy::WriteInterfaceToken(MessageParcel &data)
void AccessibleAbilityClientProxy::Init(const sptr<IAccessibleAbilityChannel> &channel, const int channelId)
{
testStub = channel;
g_testStub = channel;
g_testChannalId = channelId;
}

View File

@ -14,6 +14,7 @@
*/
#include "accessible_ability_manager_service.h"
#include <ctime>
#include <functional>
#include <unistd.h>
@ -22,8 +23,8 @@
#include "accessibility_event_info.h"
#include "accessibility_interaction_bridge.h"
#include "accessibility_window_manager.h"
#include "hilog_wrapper.h"
#include "iservice_registry.h"
#include "hilog_wrapper.h"
#include "system_ability_definition.h"
using namespace std;
@ -524,8 +525,7 @@ std::map<std::string, AppExecFwk::ElementName> AccessibleAbilityManagerService::
{
HILOG_DEBUG(" %{public}s", __func__);
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
std::map<std::string, AppExecFwk::ElementName> it{};
it = accountData->GetEnabledAbilities();
std::map<std::string, AppExecFwk::ElementName> it = accountData->GetEnabledAbilities();
return it;
}

View File

@ -1,435 +0,0 @@
// /*
// * Copyright (c) 2021 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 "event_runner.h"
// #include <condition_variable>
// #include <mutex>
// #include <sstream>
// #include <thread>
// #include <unordered_map>
// #include <vector>
// #include <sys/prctl.h>
// #include "event_handler.h"
// #include "event_handler_utils.h"
// #include "event_inner_runner.h"
// #include "thread_local_data.h"
// #include "singleton.h"
// DEFINE_HILOG_LABEL("EventRunner");
// namespace OHOS {
//namespace AppExecFwk {
// namespace {
// // Invoke system call to set name of current thread.
// inline void SystemCallSetThreadName(const std::string &name)
// {
// }
// // Help to calculate hash code of object.
// template<typename T>
// inline size_t CalculateHashCode(const T &obj)
// {
// return 0
// }
// // Thread collector is used to reclaim thread that needs to finish running.
// class ThreadCollector : public DelayedRefSingleton<ThreadCollector> {
// DECLARE_DELAYED_REF_SINGLETON(ThreadCollector);
// public:
// DISALLOW_COPY_AND_MOVE(ThreadCollector);
// using ExitFunction = std::function<void()>;
// void ReclaimCurrentThread()
// {
// // Get id of current thread.
// auto threadId = std::this_thread::get_id();
// HILOGD("Reclaim: Thread id: %{public}zu", CalculateHashCode(threadId));
// {
// // Add thread id to list and notify to reclaim.
// std::lock_guard<std::mutex> lock(collectorLock_);
// if (destroying_) {
// HILOGI("Reclaim: Thread collector is destroying");
// return;
// }
// reclaims_.emplace_back(threadId);
// if (isWaiting_) {
// condition_.notify_one();
// }
// }
// if (threadLock_.try_lock()) {
// if ((!thread_) && (needCreateThread_)) {
// // Start daemon thread to collect finished threads, if not exist.
// thread_ = std::make_unique<std::thread>(&ThreadCollector::Run, this);
// }
// threadLock_.unlock();
// }
// }
// bool Deposit(std::unique_ptr<std::thread> &thread, const ExitFunction &threadExit)
// {
// if ((!thread) || (!thread->joinable()) || (!threadExit)) {
// auto threadState = thread ? (thread->joinable() ? "active" : "finished") : "null";
// HILOGE("Deposit(%{public}s, %{public}s): Invalid parameter", threadState, threadExit ? "valid" : "null");
// return false;
// }
// auto threadId = thread->get_id();
// HILOGD("Deposit: New thread id: %{public}zu", CalculateHashCode(threadId));
// // Save these information into map.
// std::lock_guard<std::mutex> lock(collectorLock_);
// if (destroying_) {
// HILOGW("Deposit: Collector thread is destroying");
// return false;
// }
// // Save thread object and its exit callback.
// depositMap_.emplace(threadId,
// ThreadExitInfo {
// .thread = std::move(thread),
// .threadExit = threadExit,
// });
// return true;
// }
// private:
// DEFINE_HILOG_LABEL("ThreadCollector");
// struct ThreadExitInfo {
// std::unique_ptr<std::thread> thread;
// ExitFunction threadExit;
// };
// inline void ReclaimAll()
// {
// std::unique_lock<std::mutex> lock(collectorLock_);
// // All thread deposited need to stop one by one.
// while (!depositMap_.empty()) {
// DoReclaimLocked(lock, depositMap_.begin());
// }
// }
// void Stop()
// {
// {
// // Stop the collect thread, while destruction of collector.
// std::lock_guard<std::mutex> lock(collectorLock_);
// destroying_ = true;
// if (isWaiting_) {
// condition_.notify_all();
// }
// }
// {
// std::lock_guard<std::mutex> lock(threadLock_);
// if ((thread_) && (thread_->joinable())) {
// // Wait utils collect thread finished, if exists.
// thread_->join();
// }
// needCreateThread_ = false;
// }
// ReclaimAll();
// }
// void DoReclaimLocked(std::unique_lock<std::mutex> &lock,
// std::unordered_map<std::thread::id, ThreadExitInfo>::iterator it, bool needCallExit = true)
// {
// if (it == depositMap_.end()) {
// return;
// }
// // Remove thread information from map.
// auto threadId = it->first;
// auto exitInfo = std::move(it->second);
// (void)depositMap_.erase(it);
// // Unlock, because stopping thread maybe spend lot of time, it should be out of the lock.
// lock.unlock();
// size_t hashThreadId = CalculateHashCode(threadId);
// HILOGD("DoReclaim: Thread id: %{public}zu", hashThreadId);
// if (needCallExit) {
// // Call exit callback to stop loop in thread.
// exitInfo.threadExit();
// }
// // Wait until thread finished.
// exitInfo.thread->join();
// HILOGD("DoReclaim: Done, thread id: %{public}zu", hashThreadId);
// // Lock again.
// lock.lock();
// }
// void Run()
// {
// HILOGD("Run: Collector thread is started");
// std::unique_lock<std::mutex> lock(collectorLock_);
// while (!destroying_) {
// // Reclaim threads in list one by one.
// while (!reclaims_.empty()) {
// auto threadId = reclaims_.back();
// reclaims_.pop_back();
// DoReclaimLocked(lock, depositMap_.find(threadId), false);
// }
// // Maybe stop running while doing reclaim, so check before waiting.
// if (destroying_) {
// break;
// }
// isWaiting_ = true;
// condition_.wait(lock);
// isWaiting_ = false;
// }
// HILOGD("Run: Collector thread is stopped");
// }
// std::mutex collectorLock_;
// std::condition_variable condition_;
// bool isWaiting_ {false};
// bool destroying_ {false};
// std::vector<std::thread::id> reclaims_;
// std::unordered_map<std::thread::id, ThreadExitInfo> depositMap_;
// std::mutex threadLock_;
// // Thread for collector
// std::unique_ptr<std::thread> thread_;
// bool needCreateThread_ {true};
// // Avatar of thread collector, used to stop collector at the specified opportunity.
// class Avatar {
// public:
// DISALLOW_COPY_AND_MOVE(Avatar);
// Avatar() = default;
// ~Avatar()
// {
// if (avatarEnabled_) {
// GetInstance().avatarDestructed_ = true;
// GetInstance().Stop();
// }
// }
// inline void Disable() const
// {
// avatarEnabled_ = false;
// }
// };
// // Mark whether avatar is destructed.
// volatile bool avatarDestructed_ {false};
// // Mark whether avatar is enabled.
// static volatile bool avatarEnabled_;
// static Avatar avatar_;
// };
// ThreadCollector::ThreadCollector() :
// collectorLock_(), condition_(), reclaims_(), depositMap_(), threadLock_(), thread_(nullptr)
// {
// // Thread collector is created, so enable avatar.
// avatarEnabled_ = true;
// }
// ThreadCollector::~ThreadCollector()
// {
// // If avatar is not destructed, stop collector by itself.
// if (!avatarDestructed_) {
// avatar_.Disable();
// Stop();
// }
// }
// class EventRunnerImpl final : public EventInnerRunner {
// public:
// explicit EventRunnerImpl(const std::shared_ptr<EventRunner> &runner) : EventInnerRunner(runner)
// {
// queue_ = std::make_shared<EventQueue>();
// }
// ~EventRunnerImpl() final = default;
// DISALLOW_COPY_AND_MOVE(EventRunnerImpl);
// static void ThreadMain(const std::weak_ptr<EventRunnerImpl> &wp)
// {
// }
// void Run() final
// {
// }
// void Stop() final
// {
// queue_->Finish();
// }
// inline bool Attach(std::unique_ptr<std::thread> &thread)
// {
// return true;
// }
// inline void SetThreadName(const std::string &threadName)
// {
// }
// private:
// DEFINE_HILOG_LABEL("EventRunnerImpl");
// };
// } // unnamed namespace
// EventInnerRunner::EventInnerRunner(const std::shared_ptr<EventRunner> &runner) :
// queue_(nullptr), owner_(runner), logger_(nullptr), threadName_(""), threadId_()
// {}
// std::shared_ptr<EventRunner> EventInnerRunner::GetCurrentEventRunner()
// {
// return nullptr;
// }
// ThreadLocalData<std::weak_ptr<EventRunner>> EventInnerRunner::currentEventRunner;
// namespace {
// volatile bool ThreadCollector::avatarEnabled_ = false;
// /*
// * All event runners are relied on 'currentEventRunner', so make sure destruction of 'currentEventRunner'
// * should after all event runners finished. All event runners finished in destruction of 'ThreadCollector::Avatar',
// * so instance of 'ThreadCollector::Avatar' MUST defined after 'currentEventRunner'.
// */
// ThreadCollector::Avatar ThreadCollector::avatar_;
// } // unnamed namespace
// std::shared_ptr<EventRunner> EventRunner::mainRunner_;
// std::shared_ptr<EventRunner> EventRunner::Create(bool inNewThread)
// {
// if (inNewThread) {
// return Create(std::string());
// }
// // Constructor of 'EventRunner' is private, could not use 'std::make_shared' to construct it.
// std::shared_ptr<EventRunner> sp(new EventRunner(false));
// auto innerRunner = std::make_shared<EventRunnerImpl>(sp);
// sp->innerRunner_ = innerRunner;
// sp->queue_ = innerRunner->GetEventQueue();
// return sp;
// }
// std::shared_ptr<EventRunner> EventRunner::Create(const std::string &threadName)
// {
// // Constructor of 'EventRunner' is private, could not use 'std::make_shared' to construct it.
// std::shared_ptr<EventRunner> sp(new EventRunner(true));
// auto innerRunner = std::make_shared<EventRunnerImpl>(sp);
// sp->innerRunner_ = innerRunner;
// sp->queue_ = innerRunner->GetEventQueue();
// // Start new thread
// innerRunner->SetThreadName(threadName);
// auto thread =
// std::make_unique<std::thread>(EventRunnerImpl::ThreadMain, std::weak_ptr<EventRunnerImpl>(innerRunner));
// if (!innerRunner->Attach(thread)) {
// HILOGW("Create: Failed to attach thread, maybe process is exiting");
// innerRunner->Stop();
// thread->join();
// }
// return sp;
// }
// std::shared_ptr<EventRunner> EventRunner::Current()
// {
// auto runner = EventInnerRunner::GetCurrentEventRunner();
// if (runner) {
// return runner;
// }
// return nullptr;
// }
// EventRunner::EventRunner(bool deposit) : deposit_(deposit)
// {}
// EventRunner::~EventRunner()
// {
// if (deposit_) {
// innerRunner_->Stop();
// }
// }
// ErrCode EventRunner::Run()
// {
// if (deposit_) {
// HILOGE("Run: Do not call, if event runner is deposited");
// return EVENT_HANDLER_ERR_RUNNER_NO_PERMIT;
// }
// // Avoid more than one thread to start this runner.
// if (running_.exchange(true)) {
// HILOGW("Run: Already running");
// return EVENT_HANDLER_ERR_RUNNER_ALREADY;
// }
// // Entry event loop.
// innerRunner_->Run();
// running_.store(false);
// return ERR_OK;
// }
// ErrCode EventRunner::Stop()
// {
// return ERR_OK;
// }
// void EventRunner::Dump(Dumper &dumper)
// {
// }
// void EventRunner::SetLogger(const std::shared_ptr<Logger> &logger)
// {
// }
// std::shared_ptr<EventQueue> EventRunner::GetCurrentEventQueue()
// {
// }
// uint64_t EventRunner::GetThreadId()
// {
// return 0;
// }
// bool EventRunner::IsCurrentRunnerThread()
// {
// return 0;
// }
// std::shared_ptr<EventRunner> EventRunner::GetMainEventRunner()
// {
// return mainRunner_;
// }
// } //namespace AppExecFwk
// } // namespace OHOS

View File

@ -204,4 +204,4 @@ int32_t SystemAbilityManager::AddSystemProcess(const std::u16string& procName, c
{
return 0;
}
} // namespace OHOS
} // namespace OHOS

View File

@ -262,7 +262,8 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_Ability
* @tc.name: RemoveConnectingA11yAbility
* @tc.desc: Check the remove connecting A11y ability.GetAccessibilityWindows
*/
HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_RemoveConnectingA11yAbility001, TestSize.Level1)
HWTEST_F(AccessibilityAccountDataTest,
AccessibilityAccountData_Unittest_RemoveConnectingA11yAbility001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_RemoveConnectingA11yAbility001 start";
const int accountId = 1;
@ -297,7 +298,8 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_AddEnab
/* add */
accountData->AddEnabledAbility(elementName);
EXPECT_EQ(1, (int)accountData->GetEnabledAbilities().size());
bool test = accountData->GetEnabledAbilities().find(elementName.GetURI()) != accountData->GetEnabledAbilities().end();
bool test =
accountData->GetEnabledAbilities().find(elementName.GetURI()) != accountData->GetEnabledAbilities().end();
EXPECT_TRUE(test);
GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_AddEnabledAbility001 end";
@ -318,7 +320,8 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_RemoveE
/* add */
accountData->AddEnabledAbility(elementName);
EXPECT_EQ(1, (int)accountData->GetEnabledAbilities().size());
bool test = accountData->GetEnabledAbilities().find(elementName.GetURI()) != accountData->GetEnabledAbilities().end();
bool test =
accountData->GetEnabledAbilities().find(elementName.GetURI()) != accountData->GetEnabledAbilities().end();
EXPECT_TRUE(test);
/* remove */
accountData->RemoveEnabledAbility(elementName);
@ -397,7 +400,8 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_ClearIn
* @tc.name: GetAccessibleAbilityConnection
* @tc.desc: Check the get accessibility connection.
*/
HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_GetAccessibleAbilityConnection001, TestSize.Level1)
HWTEST_F(AccessibilityAccountDataTest,
AccessibilityAccountData_Unittest_GetAccessibleAbilityConnection001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_GetAccessibleAbilityConnection001 start";
const int accountId = 1;
@ -420,7 +424,8 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_GetAcce
* @tc.name: GetAccessibleAbilityConnection
* @tc.desc: Check the get accessibility connection.
*/
HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_GetAccessibleAbilityConnection002, TestSize.Level1)
HWTEST_F(AccessibilityAccountDataTest,
AccessibilityAccountData_Unittest_GetAccessibleAbilityConnection002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_GetAccessibleAbilityConnection002 start";
const int accountId = 1;
@ -595,8 +600,8 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_GetAbil
* @tc.name: AddAccessibilityWindowConnection
* @tc.desc: Check the add accessibility interaction connection.
*/
HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_AddAccessibilityWindowConnection001,
TestSize.Level1)
HWTEST_F(AccessibilityAccountDataTest,
AccessibilityAccountData_Unittest_AddAccessibilityWindowConnection001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_AddAccessibilityWindowConnection001 star";
const int accountId = 1;
@ -621,8 +626,8 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_AddAcce
* @tc.name: GetAccessibilityWindowConnection
* @tc.desc: Check the get accessibility interaction connection.
*/
HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_GetAccessibilityWindowConnection001,
TestSize.Level1)
HWTEST_F(AccessibilityAccountDataTest,
AccessibilityAccountData_Unittest_GetAccessibilityWindowConnection001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_GetAccessibilityWindowConnection001 star";
const int accountId = 1;
@ -648,8 +653,8 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_GetAcce
* @tc.name: RemoveAccessibilityWindowConnection
* @tc.desc: Check the remove accessibility interaction connection.
*/
HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_RemoveAccessibilityWindowConnection001,
TestSize.Level1)
HWTEST_F(AccessibilityAccountDataTest,
AccessibilityAccountData_Unittest_RemoveAccessibilityWindowConnection001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_RemoveAccessibilityWindowConnection001 star";
const int accountId = 1;

View File

@ -18,9 +18,9 @@
#include "accessible_ability_connection.h"
#include "accessible_ability_client_stub_impl.h"
#include "accessible_ability_manager_service.h"
#include "accessibility_display_manager.h"
#include "accessibility_element_operator_stub.h"
#include "accessibility_element_operator_proxy.h"
#include "accessibility_display_manager.h"
#include "iservice_registry.h"
#include "mock_bundle_manager.h"
#include "system_ability_definition.h"
@ -178,7 +178,8 @@ HWTEST_F(AccessibleAbilityConnectionUnitTest, AccessibleAbilityConnection_Unitte
* @tc.name: OnAccessibilityEvent
* @tc.desc: Test function OnAccessibilityEvent
*/
HWTEST_F(AccessibleAbilityConnectionUnitTest, AccessibleAbilityConnection_Unittest_OnAccessibilityEvent_001, TestSize.Level1)
HWTEST_F(AccessibleAbilityConnectionUnitTest,
AccessibleAbilityConnection_Unittest_OnAccessibilityEvent_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibleAbilityConnection_Unittest_OnAccessibilityEvent_001 start";
AccessibilityEventInfo eventInfo;
@ -195,7 +196,8 @@ HWTEST_F(AccessibleAbilityConnectionUnitTest, AccessibleAbilityConnection_Unitte
* @tc.name: OnAccessibilityEvent
* @tc.desc: Test function OnAccessibilityEvent
*/
HWTEST_F(AccessibleAbilityConnectionUnitTest, AccessibleAbilityConnection_Unittest_OnAccessibilityEvent_002, TestSize.Level1)
HWTEST_F(AccessibleAbilityConnectionUnitTest,
AccessibleAbilityConnection_Unittest_OnAccessibilityEvent_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibleAbilityConnection_Unittest_OnAccessibilityEvent_002 start";
AccessibilityEventInfo eventInfo;
@ -214,7 +216,8 @@ HWTEST_F(AccessibleAbilityConnectionUnitTest, AccessibleAbilityConnection_Unitte
* @tc.name: OnGestureSimulateResult
* @tc.desc: Test function OnGestureSimulateResult
*/
HWTEST_F(AccessibleAbilityConnectionUnitTest, AccessibleAbilityConnection_Unittest_OnGestureSimulateResult_001, TestSize.Level1)
HWTEST_F(AccessibleAbilityConnectionUnitTest,
AccessibleAbilityConnection_Unittest_OnGestureSimulateResult_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibleAbilityConnection_Unittest_OnGestureSimulateResult_001 start";

View File

@ -24,6 +24,7 @@
namespace OHOS {
namespace Accessibility {
using AccessibilityElementOperatorCallbacks = std::map<const int, const sptr<IAccessibilityElementOperatorCallback>>;
std::map<const int,
const sptr<IAccessibilityElementOperatorCallback>> AccessibilityElementOperatorStub::aaCallbacks_ = {};
AccessibilityElementOperatorStub::AccessibilityElementOperatorStub()
@ -162,8 +163,7 @@ void AccessibilityElementOperatorStub::CallbackImpl::SetExecuteActionResult(
return;
}
std::map<const int, const sptr<IAccessibilityElementOperatorCallback>>
AccessibilityElementOperatorStub::CallbackImpl::GetAACallbackList()
AccessibilityElementOperatorCallbacks AccessibilityElementOperatorStub::CallbackImpl::GetAACallbackList()
{
return aaCallbacks_;
}

View File

@ -13,8 +13,8 @@
* limitations under the License.
*/
#include "accessibility_operator.h"
#include <unistd.h>
#include "accessibility_operator.h"
namespace OHOS {
namespace Accessibility {

View File

@ -42,7 +42,8 @@ int g_mTgestureId = -1;
AccessibleAbilityClientProxy::AccessibleAbilityClientProxy(const sptr<IRemoteObject> &object)
: IRemoteProxy<IAccessibleAbilityClient>(object)
{}
{
}
bool AccessibleAbilityClientProxy::WriteInterfaceToken(MessageParcel &data)
{
@ -56,7 +57,8 @@ void AccessibleAbilityClientProxy::Init(const sptr<IAccessibleAbilityChannel> &c
}
void AccessibleAbilityClientProxy::Disconnect(const int channelId)
{}
{
}
void AccessibleAbilityClientProxy::OnAccessibilityEvent(const AccessibilityEventInfo &eventInfo)
{
@ -66,8 +68,7 @@ void AccessibleAbilityClientProxy::OnAccessibilityEvent(const AccessibilityEvent
g_testEventType = int(eventInfo.GetEventType());
g_mTgestureId = int(eventInfo.GetGestureType());
switch (eventInfo.GetEventType())
{
switch (eventInfo.GetEventType()) {
case TYPE_TOUCH_GUIDE_GESTURE_BEGIN:
case TYPE_TOUCH_GUIDE_GESTURE_END:
case TYPE_TOUCH_GUIDE_BEGIN:
@ -86,11 +87,11 @@ void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent &keyEvent
MessageParcel data;
MessageParcel reply;
HILOG_DEBUG();
HILOG_DEBUG("%{public}s start.-----------------------------zjx mock Proxy Start ", __func__);
HILOG_DEBUG("%{public}s start.----------sequence--%{public}d ----------zjx mock Proxy Start ", __func__, sequence);
HILOG_DEBUG("%{public}s start.-----------------------------mock Proxy Start ", __func__);
HILOG_DEBUG("%{public}s start.----------sequence--%{public}d ----------mock Proxy Start ", __func__, sequence);
g_testKeyPressEvent = sequence;
HILOG_DEBUG("%{public}s mock AccessibleAbilityClientProxy -------mock -----mock------------- end.", __func__);
HILOG_DEBUG("%{public}s start.-----------------------------zjx mock Proxy end ", __func__);
HILOG_DEBUG("%{public}s mock AccessibleAbilityClientProxy-----mock------------- end.", __func__);
HILOG_DEBUG("%{public}s start.-----------------------------mock Proxy end ", __func__);
}
void AccessibleAbilityClientProxy::OnDisplayResized(const int displayId, const Rect &rect, const float scale,
@ -104,6 +105,5 @@ void AccessibleAbilityClientProxy::OnGestureSimulateResult(const int sequence, c
g_testGestureSimulateResult = 1;
g_testGestureSimulate = sequence;
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -107,7 +107,6 @@ bool BundleMgrService::CheckWantEntity(const AAFwk::Want &want, AbilityInfo &abi
}
auto find = false;
// filter ams onstart
HILOG_DEBUG(" mock BundleMgrService QueryAbilityInfo CheckWantEntity ------------ start---------2");
for (const auto &entity : entityVector) {
if (entity == Want::FLAG_HOME_INTENT_FROM_SYSTEM && element.GetAbilityName().empty() &&

5
services/test/mock/multimodalinput/include/key_event.h Normal file → Executable file
View File

@ -19,6 +19,7 @@
#include <vector>
#include "input_event.h"
#include "parcel.h"
namespace OHOS {
namespace MMI {
@ -66,6 +67,10 @@ public:
void AddKeyItem(const KeyItem& keyItem);
public:
bool WriteToParcel(Parcel &out) const;
bool ReadFromParcel(Parcel &in);
protected:
explicit KeyEvent(int32_t eventType);

View File

@ -93,5 +93,15 @@ void KeyEvent::SetKeyCode(int32_t keyCode)
{
keyCode_ = keyCode;
}
bool KeyEvent::WriteToParcel(Parcel &out) const
{
return true;
}
bool KeyEvent::ReadFromParcel(Parcel &in)
{
return true;
}
}
}

View File

@ -134,7 +134,8 @@ void PointerEvent::PointerItem::SetDeviceId(int32_t deviceId)
PointerEvent::PointerEvent(int32_t eventType) : InputEvent(eventType) {}
PointerEvent::~PointerEvent() {
PointerEvent::~PointerEvent()
{
pointers_.clear();
pressedButtons_.clear();
pressedKeys_.clear();
@ -213,6 +214,5 @@ std::vector<int32_t> PointerEvent::GetPointersIdList() const
return pointerIdList;
}
}
}

View File

@ -24,11 +24,11 @@
using namespace testing;
using namespace testing::ext;
using namespace OHOS;
using namespace OHOS::EventFwk;
using namespace OHOS::Accessibility;
using namespace std;
namespace OHOS {
namespace Accessibility {
class AccessibilityCommonEventRegistryTest : public ::testing::Test {
public:
AccessibilityCommonEventRegistryTest() {}
@ -112,8 +112,8 @@ void AccessibilityCommonEventRegistryTest::AddAccessibleAbilityConnection()
* @tc.desc: There is a connected ability. The package is added to the connecting ability during the update.
* After the package update. Remove connecting ability.
*/
HWTEST_F(AccessibilityCommonEventRegistryTest, AccessibilityCommonEventRegistry_ModuleTest_PackageUpdateFinished_001,
TestSize.Level1)
HWTEST_F(AccessibilityCommonEventRegistryTest,
AccessibilityCommonEventRegistry_ModuleTest_PackageUpdateFinished_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityCommonEventRegistry_ModuleTest_PackageUpdateFinished_001 start";
AddAccessibleAbilityConnection();
@ -135,8 +135,8 @@ HWTEST_F(AccessibilityCommonEventRegistryTest, AccessibilityCommonEventRegistry_
* @tc.name: PackageChanged
* @tc.desc: There is a connected ability. The package has changed. Empty all install ability.
*/
HWTEST_F(AccessibilityCommonEventRegistryTest, AccessibilityCommonEventRegistry_ModuleTest_PackageChanged_001,
TestSize.Level1)
HWTEST_F(AccessibilityCommonEventRegistryTest,
AccessibilityCommonEventRegistry_ModuleTest_PackageChanged_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityCommonEventRegistry_ModuleTest_PackageChanged_001 start";
AddAccessibleAbilityConnection();
@ -156,8 +156,8 @@ HWTEST_F(AccessibilityCommonEventRegistryTest, AccessibilityCommonEventRegistry_
* @tc.name: PresentUser
* @tc.desc: After presenting user, the ability which is connected before is still connected.
*/
HWTEST_F(AccessibilityCommonEventRegistryTest, AccessibilityCommonEventRegistry_ModuleTest_PresentUser_001,
TestSize.Level1)
HWTEST_F(AccessibilityCommonEventRegistryTest,
AccessibilityCommonEventRegistry_ModuleTest_PresentUser_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityCommonEventRegistry_ModuleTest_PresentUser_001 start";
ASSERT_TRUE(aams_);
@ -176,3 +176,5 @@ HWTEST_F(AccessibilityCommonEventRegistryTest, AccessibilityCommonEventRegistry_
GTEST_LOG_(INFO) << "AccessibilityCommonEventRegistry_ModuleTest_PresentUser_001 end";
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -116,7 +116,7 @@ void AAMSServerTest::WritefileAll(const char* fname, const char* data)
}
(void)fprintf(fp, "%s", data);
fclose(fp);
(void)fclose(fp);
}
void AAMSServerTest::CreateAccessibilityConfigForTouchGuide()

View File

@ -15,6 +15,7 @@
#ifndef AAMS_ST_ABILITY_B1
#define AAMS_ST_ABILITY_B1
#include <string>
#include "ability_loader.h"
#include "accessibility_element_operator.h"

View File

@ -29,7 +29,7 @@ namespace AppExecFwk {
void AccessibleAbilityListenerTest::OnAbilityConnected()
{
HILOG_INFO("######################AamsStAbilityB1: Accessible application is connected.");
HILOG_INFO("##############AamsStAbilityB1: Accessible application is connected.");
AbilityContext context;
auto eventType = Accessibility::EventType::TYPE_VIEW_ACCESSIBILITY_FOCUSED_EVENT;
int componentId = 1;
@ -38,7 +38,8 @@ void AccessibleAbilityListenerTest::OnAbilityConnected()
void AccessibleAbilityListenerTest::OnAccessibilityEvent(const AccessibilityEventInfo& eventInfo)
{
HILOG_INFO("######################AamsStAbilityB1: An Accessibility event is received and eventType is %{public}d", eventInfo.GetEventType());
HILOG_INFO("##############AamsStAbilityB1: An Accessibility event is received and eventType is %{public}d",
eventInfo.GetEventType());
std::optional<AccessibilityElementInfo> elementInfo;
Accessibility::AccessibleAbility::GetInstance().GetRootElementInfo(elementInfo);
@ -52,17 +53,17 @@ void AccessibleAbilityListenerTest::OnAccessibilityEvent(const AccessibilityEven
void AccessibleAbilityListenerTest::OnGesture(uint32_t gestureId)
{
HILOG_INFO("######################AamsStAbilityB1: A gesture is received and gestureId is %{public}d.", gestureId);
HILOG_INFO("##############AamsStAbilityB1: A gesture is received and gestureId is %{public}d.", gestureId);
}
void AccessibleAbilityListenerTest::OnInterrupt()
{
HILOG_INFO("######################AamsStAbilityB1: Accessible application is on interrupt.");
HILOG_INFO("##############AamsStAbilityB1: Accessible application is on interrupt.");
}
bool AccessibleAbilityListenerTest::OnKeyPressEvent(const MMI::KeyEvent& keyEvent)
{
HILOG_INFO("######################AamsStAbilityB1: A key press event is received");
HILOG_INFO("##############AamsStAbilityB1: A key press event is received");
return true;
}
@ -70,7 +71,7 @@ void AamsStAbilityB1::OnStart(const Want &want)
{
GetWantInfo(want);
HILOG_INFO("######################AamsStAbilityB1::onStart");
HILOG_INFO("##############AamsStAbilityB1::onStart");
RegisterInteractionOperation();
AbilityContext context;
auto eventType = Accessibility::EventType::TYPE_VIEW_ACCESSIBILITY_FOCUSED_EVENT;
@ -150,7 +151,7 @@ void AamsStAbilityB1::RegisterInteractionOperation()
AbilityContext context;
int windowId = 0;
int userId = TESTUSERID;
std::shared_ptr<AccessibilityInteractionOperationTest> interactionOperation =
std::shared_ptr<AccessibilityInteractionOperationTest> interactionOperation =
std::make_shared<AccessibilityInteractionOperationTest>();
Accessibility::AccessibilitySystemAbilityClient::GetInstance(context)->RegisterInteractionOperation(
windowId, interactionOperation, userId);
@ -184,7 +185,7 @@ void AamsStAbilityB1::GetSuggestedInterval()
void AamsStAbilityB1::SendEventWithType()
{
HILOG_INFO("###################AamsStAbilityB1::SendEventWithType");
HILOG_INFO("##############AamsStAbilityB1::SendEventWithType");
AbilityContext context;
auto eventType = Accessibility::EventType::TYPE_VIEW_ACCESSIBILITY_FOCUSED_EVENT;
int componentId = 1;
@ -232,10 +233,10 @@ void AamsStAbilityB1::UnsubscribeStateObserverEventType()
void AamsStAbilityB1::RegisterListenerToAA()
{
HILOG_INFO("###############################AamsStAbilityB1::%{public}s start", __func__);
HILOG_INFO("##############AamsStAbilityB1::%{public}s start", __func__);
listener_ = std::make_shared<AccessibleAbilityListenerTest>();
if (!listener_) {
HILOG_ERROR("###############################listener_ is nullptr.");
HILOG_ERROR("##############listener_ is nullptr.");
return;
}
Accessibility::AccessibleAbility::GetInstance().RegisterListener(listener_);
@ -243,13 +244,13 @@ void AamsStAbilityB1::RegisterListenerToAA()
void AamsStAbilityB1::ConnectToAAMS()
{
HILOG_INFO("###############################AamsStAbilityB1::%{public}s start", __func__);
HILOG_INFO("##############AamsStAbilityB1::%{public}s start", __func__);
Accessibility::AccessibleAbility::GetInstance().ConnectToAAMS();
}
void AamsStAbilityB1::GetRootElementInfo()
{
HILOG_INFO("####################AamsStAbilityB1::%{public}s start", __func__);
HILOG_INFO("##############AamsStAbilityB1::%{public}s start", __func__);
std::optional<AccessibilityElementInfo> elementInfo;
Accessibility::AccessibleAbility::GetInstance().GetRootElementInfo(elementInfo);
@ -263,7 +264,7 @@ void AamsStAbilityB1::GetRootElementInfo()
void AccessibilityInteractionOperationTest::SearchElementInfoByAccessibilityId(const long elementId,
const int requestId, Accessibility::AccessibilityInteractionOperationCallback &callback, const int mode)
{
HILOG_INFO("###############################AamsStAbilityB1::%{public}s start", __func__);
HILOG_INFO("##############AamsStAbilityB1::%{public}s start", __func__);
AccessibilityElementInfo info;
info.SetBundleName("testapp_B1");
info.SetWindowId(0);
@ -279,7 +280,7 @@ void AccessibilityInteractionOperationTest::SearchElementInfoByAccessibilityId(c
void AccessibilityInteractionOperationTest::SearchElementInfosByText(const long elementId, const std::string &text,
const int requestId, Accessibility::AccessibilityInteractionOperationCallback &callback)
{
HILOG_INFO("###############################AamsStAbilityB1::%{public}s start", __func__);
HILOG_INFO("##############AamsStAbilityB1::%{public}s start", __func__);
AccessibilityElementInfo info;
info.SetBundleName("fang-ch");
info.SetWindowId(0);
@ -289,26 +290,26 @@ void AccessibilityInteractionOperationTest::SearchElementInfosByText(const long
std::list<AccessibilityElementInfo> infos{};
infos.push_back(info);
callback.SetSearchElementInfoByTextResult(infos, requestId);
HILOG_INFO("###############################AamsStAbilityB1::=================SearchElementInfosByText===========success=========");
HILOG_INFO("##############AamsStAbilityB1::=======SearchElementInfosByText::=======success=======");
}
void AccessibilityInteractionOperationTest::FindFocusedElementInfo(const long elementId, const int focusType, const int requestId,
Accessibility::AccessibilityInteractionOperationCallback &callback)
void AccessibilityInteractionOperationTest::FindFocusedElementInfo(const long elementId, const int focusType,
const int requestId, Accessibility::AccessibilityInteractionOperationCallback &callback)
{
HILOG_INFO("###############################AamsStAbilityB1::%{public}s start", __func__);
HILOG_INFO("##############AamsStAbilityB1::%{public}s start", __func__);
AccessibilityElementInfo info;
info.SetWindowId(0);
info.SetBundleName("testapp_B1_findFocus");
info.SetCheckable(true);
info.SetHint("testapp_B1_findFocus");
callback.SetFindFocusedElementInfoResult(info, requestId);
HILOG_INFO("###############################AamsStAbilityB1::=================FindFocusedElementInfo===========success=========");
HILOG_INFO("##############AamsStAbilityB1::=======FindFocusedElementInfo=======success=======");
}
void AccessibilityInteractionOperationTest::FocusMoveSearch(const long elementId, const int direction, const int requestId,
Accessibility::AccessibilityInteractionOperationCallback &callback)
void AccessibilityInteractionOperationTest::FocusMoveSearch(const long elementId, const int direction,
const int requestId, Accessibility::AccessibilityInteractionOperationCallback &callback)
{
HILOG_INFO("###############################AamsStAbilityB1::%{public}s start", __func__);
HILOG_INFO("##############AamsStAbilityB1::%{public}s start", __func__);
AccessibilityElementInfo info;
info.SetWindowId(0);
info.SetBundleName("testapp_B1_FocusMoveSearch");
@ -318,35 +319,36 @@ void AccessibilityInteractionOperationTest::FocusMoveSearch(const long elementId
info.SetParent(parentId);
callback.SetFocusMoveSearchResult(info, requestId);
HILOG_INFO("###############################AamsStAbilityB1::=================FocusMoveSearch===========success=========");
HILOG_INFO("##############AamsStAbilityB1::=======FocusMoveSearch=======success=======");
}
void AccessibilityInteractionOperationTest::PerformAction(const long elementId, const int action, const std::map<std::string, std::string> actionArguments,
void AccessibilityInteractionOperationTest::PerformAction(const long elementId, const int action,
const std::map<std::string, std::string> actionArguments,
int requestId, Accessibility::AccessibilityInteractionOperationCallback &callback)
{
HILOG_INFO("###############################AamsStAbilityB1::%{public}s start", __func__);
HILOG_INFO("##############AamsStAbilityB1::%{public}s start", __func__);
AccessibilityElementInfo info;
info.SetWindowId(0);
info.SetBundleName("testapp_B1_findFocus");
info.SetCheckable(true);
info.SetHint("testapp_B1_findFocus");
callback.SetPerformActionResult(true, requestId);
HILOG_INFO("###############################AamsStAbilityB1::=================PerformAction===========success=========");
HILOG_INFO("##############AamsStAbilityB1::=======PerformAction=======success=======");
}
void AccessibilityInteractionOperationTest::ClearFocus()
{
HILOG_INFO("###############################AamsStAbilityB1::%{public}s start", __func__);
HILOG_INFO("##############AamsStAbilityB1::%{public}s start", __func__);
}
void AccessibilityInteractionOperationTest::OutsideTouch()
{
HILOG_INFO("###############################AamsStAbilityB1::%{public}s start", __func__);
HILOG_INFO("##############AamsStAbilityB1::%{public}s start", __func__);
}
void AccessibilityStateObserverTest::OnStateChanged(const Accessibility::AccessibilityStateEvent& stateEvent)
{
HILOG_INFO("###############################AamsStAbilityB1::%{public}s start", __func__);
HILOG_INFO("##############AamsStAbilityB1::%{public}s start", __func__);
}
REGISTER_AA(AamsStAbilityB1);

View File

@ -14,8 +14,6 @@
*/
#pragma once
#include <condition_variable>
#include <string>
#include <vector>
namespace STtools {

View File

@ -14,8 +14,6 @@
*/
#pragma once
#include <string>
#include <memory>
#include <vector>
namespace STtools {

View File

@ -14,7 +14,6 @@
*/
#include "event.h"
#include <cstdio>
#include <iostream>
namespace STtools {

View File

@ -74,8 +74,13 @@ void DeserializationStOperatorFromVector(StOperator &ParentOperator, std::vector
int StOperator::countChild = 0;
StOperator::StOperator()
: g_parentOperator(nullptr), g_abilityType("0"), g_bundleName(""), g_abilityName(""), g_operatorName(""), g_message("")
StOperator::StOperator() :
g_parentOperator(nullptr),
g_abilityType("0"),
g_bundleName(""),
g_abilityName(""),
g_operatorName(""),
g_message("")
{
g_childOperator.clear();
StOperator::countChild++;

View File

@ -166,8 +166,7 @@ bool JsonUtils::SetVecValue(nlohmann::json& json, const std::string& key, std::s
return false;
}
if (json.find(key) != json.end() && json.at(key).is_array())
{
if (json.find(key) != json.end() && json.at(key).is_array()) {
HILOG_DEBUG("Find key[%{public}s] successful.", key.c_str());
std::string str1 = "{\"BundleName\":\"";
std::string str2 = "\"}";
@ -176,7 +175,7 @@ bool JsonUtils::SetVecValue(nlohmann::json& json, const std::string& key, std::s
HILOG_DEBUG("jsonStr = %{public}s .", jsonStr.c_str());
nlohmann::json jsonobj = json.parse(jsonStr);
json[key].push_back(jsonobj);
}
}
return true;
}