mirror of
https://gitee.com/openharmony/accessibility
synced 2024-11-22 22:39:56 +00:00
Accessibility init commit
Signed-off-by: yichengzhao <yichengzhao1@huawei.com>
This commit is contained in:
parent
b249c43d15
commit
2bd0b1234c
14
BUILD.gn
Normal file
14
BUILD.gn
Normal file
@ -0,0 +1,14 @@
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
177
LICENSE
Normal file
177
LICENSE
Normal file
@ -0,0 +1,177 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
70
OAT.xml
Normal file
70
OAT.xml
Normal file
@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- 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.
|
||||
|
||||
Notes:
|
||||
This is project config file for OpenHarmony OSS Audit Tool, if you have any questions or concerns, please email chenyaxun@huawei.com.
|
||||
-->
|
||||
<!-- OAT(OSS Audit Tool) configuration guide:
|
||||
basedir: Root dir, the basedir + project path is the real source file location.
|
||||
licensefile:
|
||||
1.If the project don't have "LICENSE" in root dir, please define all the license files in this project in , OAT will check license files according to this rule.
|
||||
|
||||
tasklist(only for batch mode):
|
||||
1. task: Define oat check thread, each task will start a new thread.
|
||||
2. task name: Only an name, no practical effect.
|
||||
3. task policy: Default policy for projects under this task, this field is required and the specified policy must defined in policylist.
|
||||
4. task filter: Default filefilter for projects under this task, this field is required and the specified filefilter must defined in filefilterlist.
|
||||
5. task project: Projects to be checked, the path field define the source root dir of the project.
|
||||
|
||||
|
||||
policyList:
|
||||
1. policy: All policyitems will be merged to default OAT.xml rules, the name of policy doesn't affect OAT check process.
|
||||
2. policyitem: The fields type, name, path, desc is required, and the fields rule, group, filefilter is optional,the default value is:
|
||||
<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
|
||||
3. policyitem type:
|
||||
"compatibility" is used to check license compatibility in the specified path;
|
||||
"license" is used to check source license header in the specified path;
|
||||
"copyright" is used to check source copyright header in the specified path;
|
||||
"import" is used to check source dependency in the specified path, such as import ... ,include ...
|
||||
"filetype" is used to check file type in the specified path, supported file types: archive, binary
|
||||
"filename" is used to check whether the specified file exists in the specified path(support projectroot in default OAT.xml), supported file names: LICENSE, README, README.OpenSource
|
||||
|
||||
4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license.
|
||||
5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem.
|
||||
6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed.
|
||||
7. policyitem filefilter: Used to bind filefilter which define filter rules.
|
||||
8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path.
|
||||
|
||||
Note:If the text contains special characters, please escape them according to the following rules:
|
||||
" == >
|
||||
& == >
|
||||
' == >
|
||||
< == >
|
||||
> == >
|
||||
-->
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<licensefile></licensefile>
|
||||
<policylist>
|
||||
<policy name="projectPolicy" desc="">
|
||||
</policy>
|
||||
</policylist>
|
||||
<filefilterlist>
|
||||
<filefilter name="defaultFilter" desc="Files not to check">
|
||||
<filteritem type="filename" name="*.hap|*.rpk" desc="valid and invalid bundle files for tests"/>
|
||||
</filefilter>
|
||||
</filefilterlist>
|
||||
</oatconfig>
|
||||
</configuration>
|
6
README_zh.md
Normal file
6
README_zh.md
Normal file
@ -0,0 +1,6 @@
|
||||
# XXX系统
|
||||
|
||||
## 简介
|
||||
|
||||
|
||||
|
22
accessibility.gni
Normal file
22
accessibility.gni
Normal file
@ -0,0 +1,22 @@
|
||||
# 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.
|
||||
|
||||
accessibility_path = "//base/accessibility"
|
||||
|
||||
services_path = "${accessibility_path}/services"
|
||||
|
||||
aafwk_path = "${accessibility_path}/frameworks/aafwk"
|
||||
asacfwk_path = "${accessibility_path}/frameworks/asacfwk"
|
||||
|
||||
kits_path = "${accessibility_path}/interfaces/kits"
|
||||
innerkits_path = "${accessibility_path}/interfaces/innerkits"
|
83
common/log/include/hilog_wrapper.h
Normal file
83
common/log/include/hilog_wrapper.h
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 HILOG_WRAPPER_H
|
||||
#define HILOG_WRAPPER_H
|
||||
|
||||
#define CONFIG_HILOG
|
||||
#ifdef CONFIG_HILOG
|
||||
#include "hilog/log.h"
|
||||
|
||||
#ifdef HILOG_FATAL
|
||||
#undef HILOG_FATAL
|
||||
#endif
|
||||
|
||||
#ifdef HILOG_ERROR
|
||||
#undef HILOG_ERROR
|
||||
#endif
|
||||
|
||||
#ifdef HILOG_WARN
|
||||
#undef HILOG_WARN
|
||||
#endif
|
||||
|
||||
#ifdef HILOG_INFO
|
||||
#undef HILOG_INFO
|
||||
#endif
|
||||
|
||||
#ifdef HILOG_DEBUG
|
||||
#undef HILOG_DEBUG
|
||||
#endif
|
||||
|
||||
#ifndef AAMS_LOG_DOMAIN
|
||||
#define AAMS_LOG_DOMAIN 0xD005000
|
||||
#endif
|
||||
|
||||
#ifndef AAMS_LOG_TAG
|
||||
#define AAMS_LOG_TAG "AccessibleAbilityManagerService"
|
||||
#endif
|
||||
|
||||
#ifdef LOG_LABEL
|
||||
#undef LOG_LABEL
|
||||
#endif
|
||||
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, AAMS_LOG_DOMAIN, AAMS_LOG_TAG};
|
||||
|
||||
#define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
||||
#define HILOG_FATAL(fmt, ...) \
|
||||
(void)OHOS::HiviewDFX::HiLog::Fatal( \
|
||||
LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define HILOG_ERROR(fmt, ...) \
|
||||
(void)OHOS::HiviewDFX::HiLog::Error( \
|
||||
LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define HILOG_WARN(fmt, ...) \
|
||||
(void)OHOS::HiviewDFX::HiLog::Warn( \
|
||||
LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define HILOG_INFO(fmt, ...) \
|
||||
(void)OHOS::HiviewDFX::HiLog::Info( \
|
||||
LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define HILOG_DEBUG(fmt, ...) \
|
||||
(void)OHOS::HiviewDFX::HiLog::Debug( \
|
||||
LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#else
|
||||
|
||||
#define HILOG_FATAL(...)
|
||||
#define HILOG_ERROR(...)
|
||||
#define HILOG_WARN(...)
|
||||
#define HILOG_INFO(...)
|
||||
#define HILOG_DEBUG(...)
|
||||
#endif // CONFIG_HILOG
|
||||
|
||||
#endif // HILOG_WRAPPER_H
|
162
dummyData/dummy.h
Normal file
162
dummyData/dummy.h
Normal file
@ -0,0 +1,162 @@
|
||||
/*
|
||||
* 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 DUMMY_H
|
||||
#define DUMMY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "refbase.h"
|
||||
|
||||
#define ACCESSIBLE_ABILITY_MANAGER_SERVICE_ID 4702 // to be deleted
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
class IASACStub {};
|
||||
class IClient {};
|
||||
// class TouchEventInjector:public OHOS::RefBase{};
|
||||
/*class AccessibilityInputFilter:public OHOS::RefBase{};
|
||||
class KeyEventFilter:public OHOS::RefBase{};
|
||||
|
||||
class AccessibilityZoomProxy:public OHOS::RefBase{};*/
|
||||
|
||||
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{};
|
||||
};
|
||||
|
||||
// WMS dummy start
|
||||
enum WMError {
|
||||
WM_OK = 0,
|
||||
WM_NG
|
||||
};
|
||||
|
||||
struct WMDisplayInfo:public OHOS::RefBase {
|
||||
int32_t id;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t phyWidth;
|
||||
uint32_t phyHeight;
|
||||
uint32_t vsync;
|
||||
uint32_t dpi; // 额外的像素密度,比如hi3516的mipi屏是 60mmx120mm, 480x960, dpi=203
|
||||
};
|
||||
|
||||
struct GetFocusWindowResult:public OHOS::RefBase {
|
||||
WMError wret; // 返回结果
|
||||
int32_t wid; // 窗口id
|
||||
};
|
||||
|
||||
class IWindowManagerDisplayListenerClazz {
|
||||
public:
|
||||
IWindowManagerDisplayListenerClazz() = default;
|
||||
virtual ~IWindowManagerDisplayListenerClazz() {};
|
||||
virtual void OnScreenPlugin(int32_t did) = 0;
|
||||
virtual void OnScreenPlugout(int32_t did) = 0;
|
||||
};
|
||||
|
||||
enum WindowMode {
|
||||
WINDOW_MODE_UNSET = 0,
|
||||
WINDOW_MODE_FREE = 1,
|
||||
WINDOW_MODE_TOP = 2,
|
||||
WINDOW_MODE_MAX,
|
||||
};
|
||||
|
||||
enum WMWindowType {
|
||||
WINDOW_TYPE_NORMAL = 0,
|
||||
WINDOW_TYPE_STATUS_BAR = 1,
|
||||
WINDOW_TYPE_NAVI_BAR = 2,
|
||||
WINDOW_TYPE_ALARM_SCREEN = 3,
|
||||
WINDOW_TYPE_SYSTEM_UI = 4,
|
||||
WINDOW_TYPE_LAUNCHER = 5,
|
||||
WINDOW_TYPE_VIDEO = 6,
|
||||
WINDOW_TYPE_MAX,
|
||||
};
|
||||
|
||||
struct GetWindowInfoResult:public OHOS::RefBase {
|
||||
WMError wret; // 调用返回值
|
||||
int32_t wid; // 窗口ID
|
||||
int32_t zorder; // 层级
|
||||
int32_t width; // 窗口边界
|
||||
int32_t height; // 窗口边界
|
||||
int32_t positionX; // 窗口边界
|
||||
int32_t positionY; // 窗口边界
|
||||
int32_t anchorX; // 锚点
|
||||
int32_t anchorY; // 锚点
|
||||
bool isFocused; // 是否有焦点
|
||||
WindowMode mode; // 窗口模式(画中画)
|
||||
WMWindowType type; // 窗口类型
|
||||
};
|
||||
|
||||
class IWindowChangeListenerClazz {
|
||||
public:
|
||||
IWindowChangeListenerClazz() = default;
|
||||
virtual ~IWindowChangeListenerClazz() {};
|
||||
virtual void OnWindowCreate(int32_t wid) = 0;
|
||||
virtual void OnWindowDestroy(int32_t wid) = 0;
|
||||
};
|
||||
|
||||
class IWindowManagerService : public RefBase {
|
||||
public:
|
||||
WMError GetDisplays(std::vector<struct WMDisplayInfo> &displays)
|
||||
{
|
||||
WMDisplayInfo display;
|
||||
display.dpi = 1;
|
||||
display.width = 1000;
|
||||
display.height = 1000;
|
||||
|
||||
displays.push_back(display);
|
||||
return WM_OK;
|
||||
}
|
||||
WMError AddDisplayChangeListener(IWindowManagerDisplayListenerClazz *listener) {return WM_OK;}
|
||||
sptr<struct GetFocusWindowResult> GetFocusWindowID() {return nullptr;}
|
||||
|
||||
sptr<struct GetWindowInfoResult> GetWindowInfo(int32_t wid) {
|
||||
|
||||
window = new GetWindowInfoResult();
|
||||
|
||||
window->wid = wid;
|
||||
window->type = WINDOW_TYPE_NORMAL;
|
||||
return window;
|
||||
}
|
||||
|
||||
sptr<struct GetWindowInfoResult> window;
|
||||
void OnWindowListChange(IWindowChangeListenerClazz *listener) {}
|
||||
};
|
||||
// WMS dummy end
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif // DUMMY_H
|
11
dummyData/dummy_accessibility_ability_config.json
Normal file
11
dummyData/dummy_accessibility_ability_config.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"accessibilityEventTypes": ["all"],
|
||||
"targetBundleNames": ["com.example.ohos.api1", "com.example.ohos.api2"],
|
||||
"accessibilityAbilityTypes":["spoken", "haptic", "audible"],
|
||||
"notificationTimeout": 0,
|
||||
"uiNoninteractiveTimeout": 0,
|
||||
"uiInteractiveTimeout": 10000,
|
||||
"accessibilityCapabilities":["keyEventObserver", "touchGuide", "zoom", "retrieve"],
|
||||
"description": "$string:accessibility_service_description",
|
||||
"settingsAbility": "com.example.android.accessibility.ServiceSettingsAbility"
|
||||
}
|
30
dummyData/multimoduleDummy.cpp
Normal file
30
dummyData/multimoduleDummy.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 "multimoduleDummy.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
void MultimodalInputFilter::InjectEventToMultimodal(MultimodalEvent &event) {
|
||||
}
|
||||
|
||||
void MultimodalInputManager::RegisterMultimodalInputFilter(MultimodalInputFilter &inputFilter) {
|
||||
}
|
||||
|
||||
void MultimodalInputManager::DeregisterMultimodalInputFilter() {
|
||||
}
|
||||
}
|
||||
}
|
42
dummyData/multimoduleDummy.h
Normal file
42
dummyData/multimoduleDummy.h
Normal 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.
|
||||
*/
|
||||
|
||||
#ifndef MULTIMODULE_DUMMY_H
|
||||
#define MULTIMODULE_DUMMY_H
|
||||
|
||||
#include <memory>
|
||||
#include "multimodal_event.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
class MultimodalInputFilter {
|
||||
public:
|
||||
MultimodalInputFilter() {};
|
||||
virtual ~MultimodalInputFilter() = default;
|
||||
virtual void OnInputEvent(MultimodalEvent &event) {};
|
||||
void InjectEventToMultimodal(MultimodalEvent &event);
|
||||
};
|
||||
|
||||
class MultimodalInputManager {
|
||||
public:
|
||||
// 无障碍子系统将InputFilter对象注册给多模子系统。
|
||||
void RegisterMultimodalInputFilter(MultimodalInputFilter &inputFilter);
|
||||
// 无障碍子系统将InputFilter对象反注册给多模子系统。
|
||||
void DeregisterMultimodalInputFilter();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MULTIMODULE_DUMMY_H
|
42
dummyData/ttsDummy.cpp
Normal file
42
dummyData/ttsDummy.cpp
Normal 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 "ttsDummy.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace TtsFwk {
|
||||
TtsEngine& TtsEngine::GetInstance() {
|
||||
static TtsEngine tts;
|
||||
return tts;
|
||||
}
|
||||
|
||||
void TtsEngine::Create(sptr<TtsListener> &ttsListener) {
|
||||
|
||||
}
|
||||
|
||||
void TtsEngine::Destroy() {
|
||||
|
||||
}
|
||||
|
||||
void TtsEngine::SpeakText(const char *text, int length, int utteranceId) {
|
||||
|
||||
}
|
||||
|
||||
void TtsEngine::StopSpeak() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
52
dummyData/ttsDummy.h
Normal file
52
dummyData/ttsDummy.h
Normal 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.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_FWK_TTS_ENGINE_H
|
||||
#define OHOS_FWK_TTS_ENGINE_H
|
||||
|
||||
#include "refbase.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace TtsFwk {
|
||||
class TtsListener : public virtual RefBase {
|
||||
public:
|
||||
enum TtsEvent {
|
||||
TTS_EVENT_CREATE_SUCCESS = 0,
|
||||
TTS_EVENT_CREATE_FAILED,
|
||||
TTS_EVENT_DESTROY_SUCCESS,
|
||||
TTS_EVENT_DESTROY_FAILED,
|
||||
};
|
||||
|
||||
virtual ~TtsListener() = default;
|
||||
virtual void OnEvent(int eventType) {}
|
||||
virtual void OnSpeechStart(int utteranceId) {}
|
||||
virtual void OnSpeechProgress(int utteranceId, int progress) {}
|
||||
virtual void OnSpeechFinish(int utteranceId) {}
|
||||
};
|
||||
|
||||
class TtsEngine {
|
||||
public:
|
||||
TtsEngine() = default;
|
||||
~TtsEngine() = default;
|
||||
|
||||
static TtsEngine &GetInstance();
|
||||
virtual void Create(sptr<TtsListener> &ttsListener);
|
||||
virtual void Destroy();
|
||||
virtual void SpeakText(const char *text, int length, int utteranceId);
|
||||
virtual void StopSpeak();
|
||||
};
|
||||
} // TtsFwk
|
||||
} // OHOS
|
||||
#endif // OHOS_FWK_TTS_ENGINE_H
|
73
frameworks/aafwk/BUILD.gn
Normal file
73
frameworks/aafwk/BUILD.gn
Normal file
@ -0,0 +1,73 @@
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//base/accessibility/frameworks/aafwk/aafwk.gni")
|
||||
|
||||
config("accessibleability_config") {
|
||||
visibility = [ ":*" ]
|
||||
|
||||
include_dirs = [
|
||||
"include",
|
||||
"//base/accessibility/frameworks/aafwk/include",
|
||||
"//foundation/multimodalinput/input/interfaces/native/innerkits/event/include",
|
||||
"//utils/native/base/include",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include",
|
||||
"//base/accessibility/interfaces/innerkits/asacfwk/include",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
"//base/accessibility/frameworks/asacfwk/include",
|
||||
"//foundation/appexecfwk/appexecfwk_lite/utils/bundle_lite",
|
||||
"//base/accessibility/util/include",
|
||||
"//base/accessibility/common/log/include",
|
||||
"//base/accessibility/dummyData",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"AAMS_LOG_TAG = \"accessibility_aakit\"",
|
||||
"AAMS_LOG_DOMAIN = 0xD005201",
|
||||
]
|
||||
|
||||
if (target_cpu == "arm") {
|
||||
cflags = [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
}
|
||||
|
||||
ohos_shared_library("accessibleability") {
|
||||
install_enable = true
|
||||
|
||||
sources = aafwk_files
|
||||
|
||||
configs = [
|
||||
":accessibleability_config",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//utils/native/base:utils",
|
||||
"//base/accessibility/interfaces/innerkits/asacfwk:accessibilityclient",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ipc:ipc_core",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"appexecfwk_standard:appexecfwk_base",
|
||||
"appexecfwk_standard:appexecfwk_core",
|
||||
"aafwk_standard:want",
|
||||
"aafwk_standard:ability_manager",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"multimodalinput_base:libmmi-client",
|
||||
]
|
||||
|
||||
subsystem_name = "accessibility"
|
||||
part_name = "accessibility_standard"
|
||||
}
|
24
frameworks/aafwk/aafwk.gni
Normal file
24
frameworks/aafwk/aafwk.gni
Normal file
@ -0,0 +1,24 @@
|
||||
# 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.
|
||||
|
||||
import("//base/accessibility/accessibility.gni")
|
||||
|
||||
aafwk_files = [
|
||||
"${aafwk_path}/src/accessible_ability_client_stub.cpp",
|
||||
"${aafwk_path}/src/accessible_ability_client_proxy.cpp",
|
||||
"${aafwk_path}/src/accessible_ability_client_stub_impl.cpp",
|
||||
"${aafwk_path}/src/accessible_ability_event_handler.cpp",
|
||||
"${aafwk_path}/src/accessible_ability.cpp",
|
||||
"${aafwk_path}/src/display_resize_controller.cpp",
|
||||
"${aafwk_path}/src/fingerprint_controller.cpp",
|
||||
]
|
224
frameworks/aafwk/include/accessible_ability.h
Normal file
224
frameworks/aafwk/include/accessible_ability.h
Normal file
@ -0,0 +1,224 @@
|
||||
/*
|
||||
* 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 ACCESSIBLE_ABILITY_H
|
||||
#define ACCESSIBLE_ABILITY_H
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "key_event.h"
|
||||
#include "accessible_ability_listener.h"
|
||||
#include "accessibility_element_info.h"
|
||||
#include "accessibility_window_info.h"
|
||||
#include "accessibility_event_info.h"
|
||||
#include "iremote_object.h"
|
||||
#include "accessible_ability_manager_service_interface.h"
|
||||
#include "display_resize_controller.h"
|
||||
#include "fingerprint_controller.h"
|
||||
#include "gesture_simulation.h"
|
||||
#include "accessible_ability_client_stub_impl.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
// The types of swipe gestures which are performed on the touch screen.
|
||||
enum GestureTypes : uint32_t {
|
||||
GESTURE_SWIPE_UP = 0x0001,
|
||||
GESTURE_SWIPE_DOWN = 0x0002,
|
||||
GESTURE_SWIPE_LEFT = 0x0003,
|
||||
GESTURE_SWIPE_RIGHT = 0x0004,
|
||||
GESTURE_SWIPE_LEFT_THEN_RIGHT = 0x0005,
|
||||
GESTURE_SWIPE_RIGHT_THEN_LEFT = 0x0006,
|
||||
GESTURE_SWIPE_UP_THEN_DOWN = 0x0007,
|
||||
GESTURE_SWIPE_DOWN_THEN_UP = 0x0008,
|
||||
GESTURE_SWIPE_LEFT_THEN_UP = 0x0009,
|
||||
GESTURE_SWIPE_LEFT_THEN_DOWN = 0x000A,
|
||||
GESTURE_SWIPE_RIGHT_THEN_UP = 0x000B,
|
||||
GESTURE_SWIPE_RIGHT_THEN_DOWN = 0x000C,
|
||||
GESTURE_SWIPE_UP_THEN_LEFT = 0x000D,
|
||||
GESTURE_SWIPE_UP_THEN_RIGHT = 0x000E,
|
||||
GESTURE_SWIPE_DOWN_THEN_LEFT = 0x000F,
|
||||
GESTURE_SWIPE_DOWN_THEN_RIGHT = 0x0010,
|
||||
|
||||
GESTURE_TAP = 0x0011,
|
||||
GESTURE_DOUBLETAP = 0x0012,
|
||||
GESTURE_DOUBLETAP_HOLD = 0x0013,
|
||||
GESTURE_DRAG = 0x0014,
|
||||
GESTURE_SWIPE_SLOWLY = 0x0015,
|
||||
GESTURE_TRIPLETAP = 0x0016,
|
||||
GESTURE_SCALE = 0x0017,
|
||||
GESTURE_SCROLL = 0x0018,
|
||||
GESTURE_GESTURE_ALL = 0xFFFFFFFF
|
||||
};
|
||||
|
||||
// The global action types
|
||||
enum GlobalAction : uint32_t {
|
||||
GLOBAL_ACTION_INVALID = 0x0000,
|
||||
GLOBAL_ACTION_BACK = 0x0001,
|
||||
GLOBAL_ACTION_HOME = 0x0002,
|
||||
GLOBAL_ACTION_RECENT = 0x0003,
|
||||
GLOBAL_ACTION_NOTIFICATION = 0x0004,
|
||||
GLOBAL_ACTION_POP_UP_POWER_DIALOG = 0x0006,
|
||||
GLOBAL_ACTION_DIVIDE_SCREEN = 0x0007,
|
||||
GLOBAL_ACTION_LOCK_SCREEN = 0x0008,
|
||||
GLOBAL_ACTION_CAPTURE_SCREEN = 0x0009
|
||||
};
|
||||
|
||||
class AccessibleAbility {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Gets an instance of AccessibleAbility.
|
||||
* @param
|
||||
* @return Return an instance of AccessibleAbility.
|
||||
*/
|
||||
static AccessibleAbility& GetInstance();
|
||||
|
||||
/**
|
||||
* @brief Register listener if you want to receive notification.
|
||||
* @param listener The listener used to receive notification.
|
||||
* @return
|
||||
*/
|
||||
void RegisterListener(const std::shared_ptr<AccessibleAbilityListener> &listener);
|
||||
|
||||
/**
|
||||
* @brief Connect to AAMS.
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void ConnectToAAMS();
|
||||
|
||||
/**
|
||||
* @brief Disable the accessible ability.
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void DisableAbility();
|
||||
|
||||
/**
|
||||
* @brief Obtains elementInfo of focus.
|
||||
* @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
|
||||
* @param elementInfo The elementInfo of focus.
|
||||
* @return Return true if obtains elementInfo successfully, else return false.
|
||||
*/
|
||||
bool GetFocusElementInfo(uint32_t focusType, std::optional<AccessibilityElementInfo>& elementInfo);
|
||||
|
||||
/**
|
||||
* @brief Sends simulate gestures to the screen.
|
||||
* @param gesturePathDefineList The gesture which need to send.
|
||||
* @param listener The listener of the gesture.
|
||||
* @return Return true if the gesture sends successfully, else return false.
|
||||
*/
|
||||
bool GestureSimulate(std::vector<GesturePathDefine>& gesturePathDefineList,
|
||||
std::shared_ptr<GestureResultListener>& listener);
|
||||
|
||||
/**
|
||||
* @brief Obtains the default displayResize controller.
|
||||
* @param
|
||||
* @return Return the default displayResize controller.
|
||||
*/
|
||||
std::shared_ptr<DisplayResizeController>& GetDisplayResizeController();
|
||||
|
||||
/**
|
||||
* @brief Obtains the specified displayResize controller by displayId.
|
||||
* @param displayId The id of display.
|
||||
* @return Return the specified displayResize controller.
|
||||
*/
|
||||
std::shared_ptr<DisplayResizeController>& GetDisplayResizeController(uint32_t displayId);
|
||||
|
||||
/**
|
||||
* @brief Obtains elementInfo of the accessible root node.
|
||||
* @param elementInfo The elementInfo of the accessible root node.
|
||||
* @return Return true if obtains elementInfo successfully, else return false.
|
||||
*/
|
||||
bool GetRootElementInfo(std::optional<AccessibilityElementInfo>& elementInfo);
|
||||
|
||||
/**
|
||||
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
|
||||
* @param
|
||||
* @return The infomation of windows.
|
||||
*/
|
||||
std::vector<AccessibilityWindowInfo>& GetWindows();
|
||||
|
||||
/**
|
||||
* @brief Executes a specified action.
|
||||
* @param action The action of OHOS::Accessibility::GlobalAction.
|
||||
* @return Return true if performs action successfully, else return false.
|
||||
*/
|
||||
bool PerformCommonAction(uint32_t action);
|
||||
|
||||
/**
|
||||
* @brief Obtains the controller for fingerprint operations.
|
||||
* @param
|
||||
* @return Return the fingerprint controller.
|
||||
*/
|
||||
std::shared_ptr<FingerprintController>& GetFingerprintController();
|
||||
|
||||
/**
|
||||
* @brief Dispatch the result of simulation gesture.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param result The result of gesture completion.
|
||||
* @return
|
||||
*/
|
||||
void DispatchOnSimulationGestureResult(uint32_t sequence, bool result);
|
||||
|
||||
/**
|
||||
* @brief Set channelId.
|
||||
* @param channelId The id of channel.
|
||||
* @return
|
||||
*/
|
||||
void SetChannelId(uint32_t channelId);
|
||||
|
||||
private:
|
||||
AccessibleAbility();
|
||||
~AccessibleAbility() = default;
|
||||
|
||||
/**
|
||||
* @brief Init AccessibleAbility.
|
||||
* @param
|
||||
* @return Return true if init successfully, else return false.
|
||||
*/
|
||||
bool Init();
|
||||
|
||||
/**
|
||||
* @brief Check the type of common action.
|
||||
* @param action The type of common action.
|
||||
* @return Return true if the type of common action is right, else return false.
|
||||
*/
|
||||
bool CheckCommonAction(uint32_t action);
|
||||
|
||||
std::vector<AccessibilityWindowInfo> accessibilityWindow_ {};
|
||||
std::map<uint32_t, std::shared_ptr<GestureResultListenerInfo>> gestureResultListenerInfos_{};
|
||||
std::map<uint32_t, std::shared_ptr<DisplayResizeController>> displayResizeControllers_{};
|
||||
std::shared_ptr<FingerprintController> fingerprintController_ = nullptr;
|
||||
std::shared_ptr<AccessibleAbilityEventHandler> accessibleAbilityEventHandler_ = nullptr;
|
||||
std::shared_ptr<AppExecFwk::EventRunner> runner_ = nullptr;
|
||||
|
||||
sptr<IAccessibleAbilityManagerServiceClient> proxy_ = nullptr;
|
||||
sptr<AccessibleAbilityClientStubImpl> stub_ = nullptr;
|
||||
|
||||
uint32_t channelId_ = AccessibleAbilityClientStubImpl::INVALID_CHANNEL_ID;
|
||||
uint32_t gestureStatusListenerSequence_ = 0;
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ACCESSIBLE_ABILILTY_H
|
128
frameworks/aafwk/include/accessible_ability_client_interface.h
Normal file
128
frameworks/aafwk/include/accessible_ability_client_interface.h
Normal file
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* 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 ACCESSIBLE_ABILITY_CLIENT_INTERFACE_H
|
||||
#define ACCESSIBLE_ABILITY_CLIENT_INTERFACE_H
|
||||
|
||||
#include "iremote_broker.h"
|
||||
#include "refbase.h"
|
||||
#include "key_event.h"
|
||||
#include "accessibility_element_info.h"
|
||||
#include "accessible_ability_channel_interface.h"
|
||||
#include "accessibility_event_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
class IAccessibleAbilityClient : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accessibility.IAccessibleAbilityClient");
|
||||
|
||||
/**
|
||||
* @brief Init accessible ability.
|
||||
* @param channel The object of IAccessibleAbilityChannel.
|
||||
* @param channelId The id of channel.
|
||||
* @return
|
||||
*/
|
||||
virtual void Init(const sptr<IAccessibleAbilityChannel> &channel, const int channelId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Disconnect accessible ability.
|
||||
* @param channelId The id of channel.
|
||||
* @return
|
||||
*/
|
||||
virtual void Disconnect(const int channelId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when an accessibility event occurs.
|
||||
* @param eventInfo The infomation of accessible event.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnAccessibilityEvent(const AccessibilityEventInfo &eventInfo) = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when the accessibility service is interrupted.
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void OnInterrupt() = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when a user performs a specified gesture on the device that
|
||||
* your accessibility application has requested to be in touch exploration mode.
|
||||
* @param gestureId The id of gesture.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnGesture(const int gestureId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when a key event occurs.
|
||||
* @param keyEvent Indicates the key event to send.
|
||||
* @param sequence The sequence of the key event.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int sequence) = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when the rectangle, scale, or center coordinate for performing the resizing operations is changed.
|
||||
* @param displayId The id of display.
|
||||
* @param rect Indicates the rectangle for resizing the display.
|
||||
* @param scale Indicates the scale for resizing the display.
|
||||
* @param centerX Indicates the X coordinate of the center for resizing the display.
|
||||
* @param centerY Indicates the Y coordinate of the center for resizing the display.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnDisplayResizeChanged(const int displayId, const Rect &rect, const float scale, const float centerX,
|
||||
const float centerY) = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when need to notify the result of simulation gesture.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param completedSuccessfully The result of gesture completion.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnGestureSimulateResult(const int sequence, const bool completedSuccessfully) = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when the validity status of the fingerprint sensor's gesture detection changes.
|
||||
* @param validity The validity status of the fingerprint sensor's gesture detection.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnFingerprintGestureValidityChanged(const bool validity) = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when the fingerprint sensor detects a gesture.
|
||||
* @param gesture The gesture which is detected by fingerprint sensor.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnFingerprintGesture(const int gesture) = 0;
|
||||
|
||||
enum class Message {
|
||||
INIT = 0,
|
||||
DISCONNECT,
|
||||
ON_ACCESSIBILITY_EVENT,
|
||||
ON_INTERRUPT,
|
||||
ON_GESTURE,
|
||||
ON_KEY_PRESS_EVENT,
|
||||
ON_DISPALYRESIZE_CHANGED,
|
||||
ON_GESTURE_SIMULATE_RESULT,
|
||||
ON_FINGERPRINT_GESTURE_VALIDITY_CHANGED,
|
||||
ON_FINGERPRINT_GESTURE,
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif // ACCESSIBLE_ABILITY_CLIENT_INTERFACE_H
|
124
frameworks/aafwk/include/accessible_ability_client_proxy.h
Normal file
124
frameworks/aafwk/include/accessible_ability_client_proxy.h
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* 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 ACCESSIBLE_ABILITY_CLIENT_PROXY_H
|
||||
#define ACCESSIBLE_ABILITY_CLIENT_PROXY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "accessible_ability_client_interface.h"
|
||||
#include "iremote_proxy.h"
|
||||
#include "message_parcel.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
class AccessibleAbilityClientProxy : public IRemoteProxy<IAccessibleAbilityClient>
|
||||
{
|
||||
public:
|
||||
explicit AccessibleAbilityClientProxy(const sptr<IRemoteObject> &object);
|
||||
virtual ~AccessibleAbilityClientProxy() = default;
|
||||
|
||||
/**
|
||||
* @brief Init accessible ability through the proxy object.
|
||||
* @param channel The object of IAccessibleAbilityChannel.
|
||||
* @param channelId The id of channel.
|
||||
* @return
|
||||
*/
|
||||
virtual void Init(const sptr<IAccessibleAbilityChannel> &channel, const int channelId) override;
|
||||
|
||||
/**
|
||||
* @brief Disconnect accessible ability through the proxy object.
|
||||
* @param channelId The id of channel.
|
||||
* @return
|
||||
*/
|
||||
virtual void Disconnect(const int channelId) override;
|
||||
|
||||
/**
|
||||
* @brief Called when an accessibility event occurs through the proxy object.
|
||||
* @param eventInfo The infomation of accessible event.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnAccessibilityEvent(const AccessibilityEventInfo &eventInfo) override;
|
||||
|
||||
/**
|
||||
* @brief Called when the accessibility service is interrupted through the proxy object.
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void OnInterrupt() override;
|
||||
|
||||
/**
|
||||
* @brief Called when a user performs a specified gesture on the device that
|
||||
* your accessibility application has requested to be in touch exploration mode through the proxy object.
|
||||
* @param gestureId The id of gesture.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnGesture(const int gestureId) override;
|
||||
|
||||
/**
|
||||
* @brief Called when a key event occurs through the proxy object.
|
||||
* @param keyEvent Indicates the key event to send.
|
||||
* @param sequence The sequence of the key event.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int sequence) override;
|
||||
|
||||
/**
|
||||
* @brief Called when the rectangle, scale, or center coordinate for performing the resizing operations is changed
|
||||
* through the proxy object.
|
||||
* @param displayId The id of display.
|
||||
* @param rect Indicates the rectangle for resizing the display.
|
||||
* @param scale Indicates the scale for resizing the display.
|
||||
* @param centerX Indicates the X coordinate of the center for resizing the display.
|
||||
* @param centerY Indicates the Y coordinate of the center for resizing the display.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnDisplayResizeChanged(const int displayId, const Rect &rect, const float scale, const float centerX,
|
||||
const float centerY) override;
|
||||
|
||||
/**
|
||||
* @brief Called when need to notify the result of simulation gesture through the proxy object.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param completedSuccessfully The result of gesture completion.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnGestureSimulateResult(const int sequence, const bool completedSuccessfully) override;
|
||||
|
||||
/**
|
||||
* @brief Called when the validity status of the fingerprint sensor's gesture detection changes
|
||||
* through the proxy object.
|
||||
* @param validity The validity status of the fingerprint sensor's gesture detection.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnFingerprintGestureValidityChanged(const bool validity) override;
|
||||
|
||||
/**
|
||||
* @brief Called when the fingerprint sensor detects a gesture through the proxy object.
|
||||
* @param gesture The gesture which is detected by fingerprint sensor.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnFingerprintGesture(const int gesture) override;
|
||||
|
||||
private:
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
|
||||
static inline BrokerDelegator<AccessibleAbilityClientProxy> delegator;
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ACCESSIBLE_ABILITY_CLIENT_PROXY_H
|
61
frameworks/aafwk/include/accessible_ability_client_stub.h
Normal file
61
frameworks/aafwk/include/accessible_ability_client_stub.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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 ACCESSIBLE_ABILITY_CLIENT_STUB_H
|
||||
#define ACCESSIBLE_ABILITY_CLIENT_STUB_H
|
||||
|
||||
#include <map>
|
||||
#include <stdint.h>
|
||||
#include "accessible_ability_client_interface.h"
|
||||
#include "accessibility_errorcode.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "message_parcel.h"
|
||||
#include "message_option.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
class AccessibleAbilityClientStub : public IRemoteStub<IAccessibleAbilityClient> {
|
||||
public:
|
||||
AccessibleAbilityClientStub();
|
||||
virtual ~AccessibleAbilityClientStub();
|
||||
|
||||
virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option) override;
|
||||
|
||||
private:
|
||||
ErrCode HandleInit(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleDisconnect(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleOnAccessibilityEvent(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleOnInterrupt(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleOnGesture(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleOnKeyPressEvent(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleOnDisplayResizeChanged(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleOnGestureSimulateResult(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleOnFingerprintGestureValidityChanged(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleOnFingerprintGesture(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using AccessibleAbilityClientFunc =
|
||||
ErrCode (AccessibleAbilityClientStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, AccessibleAbilityClientFunc> memberFuncMap_;
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(AccessibleAbilityClientStub);
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ACCESSIBLE_ABILITY_CLIENT_STUB_H
|
168
frameworks/aafwk/include/accessible_ability_client_stub_impl.h
Normal file
168
frameworks/aafwk/include/accessible_ability_client_stub_impl.h
Normal file
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* 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 ACCESSIBLE_ABILITY_CLIENT_STUB_IMPL_H
|
||||
#define ACCESSIBLE_ABILITY_CLIENT_STUB_IMPL_H
|
||||
|
||||
#include <memory>
|
||||
#include "refbase.h"
|
||||
#include "accessible_ability_client_stub.h"
|
||||
#include "accessible_ability_event_handler.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "accessibility_operator.h"
|
||||
#include "accessible_ability_listener.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
class AccessibleAbilityClientStubImpl : public AccessibleAbilityClientStub
|
||||
{
|
||||
public:
|
||||
AccessibleAbilityClientStubImpl(
|
||||
const std::shared_ptr<AccessibleAbilityEventHandler> &accessibleAbilityEventHandler);
|
||||
~AccessibleAbilityClientStubImpl() = default;
|
||||
|
||||
static const uint32_t INVALID_CHANNEL_ID = 0xFFFFFFFF;
|
||||
|
||||
/**
|
||||
* @brief Register listener if you want to receive notification.
|
||||
* @param listener The listener used to receive notification.
|
||||
* @return
|
||||
*/
|
||||
void RegisterListenerImpl(const std::shared_ptr<AccessibleAbilityListener> &listener);
|
||||
|
||||
/**
|
||||
* @brief Init accessible ability.
|
||||
* @param channel The object of IAccessibleAbilityChannel.
|
||||
* @param channelId The id of channel.
|
||||
* @return
|
||||
*/
|
||||
void Init(const sptr<IAccessibleAbilityChannel> &channel, const int channelId) override;
|
||||
|
||||
/**
|
||||
* @brief Disconnect accessible ability.
|
||||
* @param channelId The id of channel.
|
||||
* @return
|
||||
*/
|
||||
void Disconnect(const int channelId) override;
|
||||
|
||||
/**
|
||||
* @brief Called when an accessibility event occurs.
|
||||
* @param eventInfo The infomation of accessible event.
|
||||
* @return
|
||||
*/
|
||||
void OnAccessibilityEvent(const AccessibilityEventInfo &eventInfo) override;
|
||||
|
||||
/**
|
||||
* @brief Called when the accessibility service is interrupted.
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void OnInterrupt() override;
|
||||
|
||||
/**
|
||||
* @brief Called when a user performs a specified gesture on the device that
|
||||
* your accessibility application has requested to be in touch exploration mode.
|
||||
* @param gestureId The id of gesture.
|
||||
* @return
|
||||
*/
|
||||
void OnGesture(const int gestureId) override;
|
||||
|
||||
/**
|
||||
* @brief Called when a key event occurs.
|
||||
* @param keyEvent Indicates the key event to send.
|
||||
* @param sequence The sequence of the key event.
|
||||
* @return
|
||||
*/
|
||||
void OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int sequence) override;
|
||||
|
||||
/**
|
||||
* @brief Called when the rectangle, scale, or center coordinate for performing the resizing operations is changed.
|
||||
* @param displayId The id of display.
|
||||
* @param rect Indicates the rectangle for resizing the display.
|
||||
* @param scale Indicates the scale for resizing the display.
|
||||
* @param centerX Indicates the X coordinate of the center for resizing the display.
|
||||
* @param centerY Indicates the Y coordinate of the center for resizing the display.
|
||||
* @return
|
||||
*/
|
||||
void OnDisplayResizeChanged(const int displayId, const Rect &rect, const float scale, const float centerX,
|
||||
const float centerY) override;
|
||||
|
||||
/**
|
||||
* @brief Called when need to notify the result of simulation gesture.
|
||||
* @param sequence The sequence of gesture.
|
||||
* @param completedSuccessfully The result of gesture completion.
|
||||
* @return
|
||||
*/
|
||||
void OnGestureSimulateResult(const int sequence, const bool completedSuccessfully) override;
|
||||
|
||||
/**
|
||||
* @brief Called when the validity status of the fingerprint sensor's gesture detection changes.
|
||||
* @param validity The validity status of the fingerprint sensor's gesture detection.
|
||||
* @return
|
||||
*/
|
||||
void OnFingerprintGestureValidityChanged(const bool validity) override;
|
||||
|
||||
/**
|
||||
* @brief Called when the fingerprint sensor detects a gesture.
|
||||
* @param gesture The gesture which is detected by fingerprint sensor.
|
||||
* @return
|
||||
*/
|
||||
void OnFingerprintGesture(const int gesture) override;
|
||||
|
||||
private:
|
||||
class AccessibleAbilityDeathRecipient final : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
AccessibleAbilityDeathRecipient(uint32_t& channelId, sptr<IAccessibleAbilityChannel>& channel)
|
||||
: recipientChannelId_(channelId), recipientchannel_(channel) {};
|
||||
~AccessibleAbilityDeathRecipient() = default;
|
||||
DISALLOW_COPY_AND_MOVE(AccessibleAbilityDeathRecipient);
|
||||
|
||||
void OnRemoteDied(const wptr<IRemoteObject>& remote);
|
||||
|
||||
uint32_t& recipientChannelId_;
|
||||
sptr<IAccessibleAbilityChannel>& recipientchannel_;
|
||||
};
|
||||
|
||||
void InitInner(const sptr<IAccessibleAbilityChannel> &channel, const int channelId);
|
||||
|
||||
void OnAccessibilityEventInner(const AccessibilityEventInfo &eventInfo);
|
||||
|
||||
void OnInterruptInner();
|
||||
|
||||
void OnGestureInner(const int gestureId);
|
||||
|
||||
void OnKeyPressEventInner(const MMI::KeyEvent &keyEvent, const int sequence);
|
||||
|
||||
void OnDisplayResizeChangedInner(const int displayId, const Rect &rect, const float scale, const float centerX,
|
||||
const float centerY);
|
||||
|
||||
void OnGestureSimulateResultInner(const int sequence, const bool completedSuccessfully);
|
||||
|
||||
void OnFingerprintGestureValidityChangedInner(const bool validity);
|
||||
|
||||
void OnFingerprintGestureInner(const int gesture);
|
||||
|
||||
sptr<IRemoteObject::DeathRecipient> deathRecipient_{};
|
||||
sptr<IAccessibleAbilityChannel> channel_ = nullptr;
|
||||
std::shared_ptr<AccessibleAbilityListener> listener_ = nullptr;
|
||||
std::shared_ptr<AccessibleAbilityEventHandler> handler_ = nullptr;
|
||||
uint32_t channelId_ = INVALID_CHANNEL_ID;
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ACCESSIBLE_ABILITY_CLIENT_STUB_IMPL_H
|
42
frameworks/aafwk/include/accessible_ability_event_handler.h
Normal file
42
frameworks/aafwk/include/accessible_ability_event_handler.h
Normal 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.
|
||||
*/
|
||||
|
||||
#ifndef ACCESSIBLE_ABILILTY_EVENT_HANDLER_H
|
||||
#define ACCESSIBLE_ABILILTY_EVENT_HANDLER_H
|
||||
|
||||
#include "event_handler.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
class AccessibleAbilityEventHandler : public AppExecFwk::EventHandler {
|
||||
public:
|
||||
explicit AccessibleAbilityEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner);
|
||||
virtual ~AccessibleAbilityEventHandler() override;
|
||||
|
||||
/**
|
||||
* @brief Process the event.
|
||||
* @param event Indicates the event to be processed.
|
||||
* @return
|
||||
*/
|
||||
virtual void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ACCESSIBLE_ABILILTY_EVENT_HANDLER_H
|
72
frameworks/aafwk/include/accessible_ability_listener.h
Normal file
72
frameworks/aafwk/include/accessible_ability_listener.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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 ACCESSIBLE_ABILITY_LISTENER_H
|
||||
#define ACCESSIBLE_ABILITY_LISTENER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "key_event.h"
|
||||
#include "accessibility_event_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
class AccessibleAbilityListener {
|
||||
public:
|
||||
AccessibleAbilityListener() = default;
|
||||
virtual ~AccessibleAbilityListener() = default;
|
||||
|
||||
/**
|
||||
* @brief Called when your accessibility service is successfully connected to the OS.
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void OnAbilityConnected() {}
|
||||
|
||||
/**
|
||||
* @brief Called when an accessibility event occurs.
|
||||
* @param eventInfo The infomation of accessible event.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnAccessibilityEvent(const AccessibilityEventInfo& eventInfo) = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when a user performs a specified gesture on the device that
|
||||
* your accessibility application has requested to be in touch exploration mode.
|
||||
* @param gestureId The id of gesture.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnGesture(uint32_t gestureId) {}
|
||||
|
||||
/**
|
||||
* @brief Called when the accessibility service is interrupted.
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void OnInterrupt() = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when a key event occurs.
|
||||
* @param keyEvent Indicates the key event to send.
|
||||
* @return Returns true if the event has been consumed; returns false otherwise.
|
||||
* The event that has been consumed will not be sent to the application.
|
||||
*/
|
||||
virtual bool OnKeyPressEvent(const MMI::KeyEvent& keyEvent) {return false;}
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ACCESSIBLE_ABILITY_LISTENER_H
|
138
frameworks/aafwk/include/display_resize_controller.h
Normal file
138
frameworks/aafwk/include/display_resize_controller.h
Normal file
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* 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 DISPLAY_RESIZE_CONTROLLER_H
|
||||
#define DISPLAY_RESIZE_CONTROLLER_H
|
||||
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include "accessible_ability_client_stub_impl.h"
|
||||
#include "accessibility_element_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
class DisplayResizeListener;
|
||||
|
||||
class DisplayResizeController {
|
||||
public:
|
||||
/**
|
||||
* @brief The constructor of DisplayResizeController.
|
||||
* @param channelId The id of channel.
|
||||
* @param displayId The id of display.
|
||||
*/
|
||||
DisplayResizeController(uint32_t channelId, uint32_t displayId);
|
||||
|
||||
/**
|
||||
* @brief Adds a displayresize listener to observe display resizing operations.
|
||||
* @param listener Indicates the listener to add.
|
||||
* @return
|
||||
*/
|
||||
void AddListener(std::shared_ptr<DisplayResizeListener>& listener);
|
||||
|
||||
/**
|
||||
* @brief Removes the specified displayresize listener.
|
||||
* @param listener Indicates the listener to remove.
|
||||
* @return Return true if removing listener successfully, else return false.
|
||||
*/
|
||||
bool DeleteListener(std::shared_ptr<DisplayResizeListener>& listener);
|
||||
|
||||
/**
|
||||
* @brief Obtains the X coordinate of the center in this display resizing rectangle.
|
||||
* @param
|
||||
* @return Returns the X coordinate of the center.
|
||||
*/
|
||||
float GetCenterX();
|
||||
|
||||
/**
|
||||
* @brief Obtains the Y coordinate of the center in this display resizing rectangle.
|
||||
* @param
|
||||
* @return Returns the Y coordinate of the center.
|
||||
*/
|
||||
float GetCenterY();
|
||||
|
||||
/**
|
||||
* @brief Obtains the display resizing rectangle.
|
||||
* @param
|
||||
* @return Returns the display resizing rectangle.
|
||||
*/
|
||||
Rect GetDisplayResizeRect();
|
||||
|
||||
/**
|
||||
* @brief Obtains the resizing scale of this display resizing rectangle.
|
||||
* @param
|
||||
* @return Returns the resizing scale.
|
||||
*/
|
||||
float GetScale();
|
||||
|
||||
/**
|
||||
* @brief Resets the display to its initial size.
|
||||
* @param isShouldAnimate Specifies whether animation is required.
|
||||
* @return Returns true if the display is successfully reset; returns false otherwise.
|
||||
*/
|
||||
bool Reset(bool isShouldAnimate);
|
||||
|
||||
/**
|
||||
* @brief Sets the center coordinates for the display resizing rectangle.
|
||||
* @param centerX Indicates the X coordinate of the center for resizing the display.
|
||||
* @param centerY Indicates the Y coordinate of the center for resizing the display.
|
||||
* @param isShouldAnimate Specifies whether animation is required.
|
||||
* @return Returns true if the center coordinates are successfully set; returns false otherwise.
|
||||
*/
|
||||
bool SetCenter(float centerX, float centerY, bool isShouldAnimate);
|
||||
|
||||
/**
|
||||
* @brief Sets the display resizing scale.
|
||||
* @param scale Indicates the scale for resizing the display
|
||||
* @param isShouldAnimate Specifies whether animation is required.
|
||||
* @return Returns true if the resizing scale is successfully set; returns false otherwise.
|
||||
*/
|
||||
bool SetScale(float scale, bool isShouldAnimate);
|
||||
|
||||
/**
|
||||
* @brief Dispatch displayresize changes to listeners who has been registered.
|
||||
* @param rect The rectangle of displayresize which needs to dispatch.
|
||||
* @param scale The scale of displayresize which needs to dispatch.
|
||||
* @param centerX The centerX of displayresize which needs to dispatch.
|
||||
* @param centerY The centerY of displayresize which needs to dispatch.
|
||||
* @return
|
||||
*/
|
||||
void DispatchOnDisplayResizeChanged(const Rect& rect, const float scale, const float centerX, const float centerY);
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<DisplayResizeListener>> displayResizeListeners_ {};
|
||||
uint32_t channelId_ = AccessibleAbilityClientStubImpl::INVALID_CHANNEL_ID;
|
||||
uint32_t displayId_;
|
||||
};
|
||||
|
||||
class DisplayResizeListener {
|
||||
public:
|
||||
/**
|
||||
* @brief Called when the rectangle, scale, or center coordinate for performing the resizing operations is changed.
|
||||
* @param controller Indicates the controller for display resizing operations.
|
||||
* @param rect Indicates the rectangle for resizing the display.
|
||||
* @param scale Indicates the scale for resizing the display.
|
||||
* @param centerX Indicates the X coordinate of the center for resizing the display.
|
||||
* @param centerY Indicates the Y coordinate of the center for resizing the display.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnDisplayResizeChanged(const DisplayResizeController& controller, const Rect& rect, const float scale,
|
||||
const float centerX, const float centerY) = 0;
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // DISPLAY_RESIZE_CONTROLLER_H
|
97
frameworks/aafwk/include/fingerprint_controller.h
Normal file
97
frameworks/aafwk/include/fingerprint_controller.h
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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 FINGERPRINT_CONTROLLER_H
|
||||
#define FINGERPRINT_CONTROLLER_H
|
||||
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include "refbase.h"
|
||||
#include "accessible_ability_client_stub_impl.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
class FingerprintListener {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Callback when the validity status of the fingerprint sensor's gesture detection changes.
|
||||
* @param isActive The validity status of the fingerprint sensor's gesture detection.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnFingerprintGestureStatusChanged(bool isActive) = 0;
|
||||
|
||||
/**
|
||||
* @brief Callback when the fingerprint sensor detects a gesture.
|
||||
* @param gesture The gesture which is detected by fingerprint sensor.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnFingerprintGesture(uint32_t gesture) = 0;
|
||||
};
|
||||
|
||||
class FingerprintController {
|
||||
public:
|
||||
/**
|
||||
* @brief The constructor of FingerprintController.
|
||||
* @param channelId The id of channel.
|
||||
*/
|
||||
FingerprintController(uint32_t channelId);
|
||||
|
||||
/**
|
||||
* @brief Judge whether the gesture detection function of the fingerprint sensor is available.
|
||||
* @param
|
||||
* @return Return true if the fingerprint sensor is available, else return false.
|
||||
*/
|
||||
bool IsFingerprintGestureDetectionValid();
|
||||
|
||||
/**
|
||||
* @brief Add listener of fingerprint gesture.
|
||||
* @param listener The listener to add.
|
||||
* @return
|
||||
*/
|
||||
void AddFingerprintListener(std::shared_ptr<FingerprintListener>& listener);
|
||||
|
||||
/**
|
||||
* @brief Delete listener of fingerprint gesture.
|
||||
* @param listener The listener to delete.
|
||||
* @return
|
||||
*/
|
||||
void DeleteFingerprintListener(std::shared_ptr<FingerprintListener>& listener);
|
||||
|
||||
/**
|
||||
* @brief Dispatch the validity status change of the fingerprint sensor's gesture detection
|
||||
* to listeners who has been registered.
|
||||
* @param isActive The validity status of the fingerprint sensor's gesture detection.
|
||||
* @return
|
||||
*/
|
||||
void DispatchOnFingerprintGestureStatusChanged(bool isActive);
|
||||
|
||||
/**
|
||||
* @brief Dispatch the gesture which is detected by fingerprint sensor to listeners who has been registered.
|
||||
* @param gesture The gesture which is detected by fingerprint sensor.
|
||||
* @return
|
||||
*/
|
||||
void DispatchOnFingerprintGesture(uint32_t gesture);
|
||||
|
||||
private:
|
||||
std::shared_ptr<FingerprintListener> fingerprintListener_ = nullptr;
|
||||
uint32_t channelId_ = AccessibleAbilityClientStubImpl::INVALID_CHANNEL_ID;
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // FINGERPRINT_CONTROLLER_H
|
302
frameworks/aafwk/src/accessible_ability.cpp
Normal file
302
frameworks/aafwk/src/accessible_ability.cpp
Normal file
@ -0,0 +1,302 @@
|
||||
/*
|
||||
* 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 <algorithm>
|
||||
#include <optional>
|
||||
#include "accessible_ability.h"
|
||||
#include "accessibility_element_info.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "accessible_ability_manager_service_proxy.h"
|
||||
#include "dummy.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const string AA_NAME = "AccessibleAbility";
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
AccessibleAbility& AccessibleAbility::GetInstance()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
static AccessibleAbility accessibleAbility;
|
||||
return accessibleAbility;
|
||||
}
|
||||
|
||||
AccessibleAbility::AccessibleAbility()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (!Init()) {
|
||||
HILOG_ERROR("%{public}s Init failed!", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
bool AccessibleAbility::Init()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (!runner_) {
|
||||
runner_ = AppExecFwk::EventRunner::Create(AA_NAME);
|
||||
if (!runner_) {
|
||||
HILOG_ERROR("Create AA runner fail");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("Get runner_ successfully");
|
||||
|
||||
if (!accessibleAbilityEventHandler_) {
|
||||
accessibleAbilityEventHandler_ = std::make_shared<AccessibleAbilityEventHandler>(runner_);
|
||||
if (!accessibleAbilityEventHandler_) {
|
||||
HILOG_ERROR("Create AA event handler fail");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("Get accessibleAbilityEventHandler_ successfully");
|
||||
|
||||
stub_ = new AccessibleAbilityClientStubImpl(accessibleAbilityEventHandler_);
|
||||
if (!stub_) {
|
||||
HILOG_ERROR("stub_ is nullptr.");
|
||||
return false;
|
||||
}
|
||||
HILOG_DEBUG("Get stub_ successfully");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccessibleAbility::RegisterListener(const std::shared_ptr<AccessibleAbilityListener> &listener)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (!listener) {
|
||||
HILOG_ERROR("listener is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!stub_) {
|
||||
HILOG_ERROR("AccessibleAbility::ConnectToAAMS fail, no stub_");
|
||||
return;
|
||||
}
|
||||
stub_->RegisterListenerImpl(listener);
|
||||
}
|
||||
|
||||
void AccessibleAbility::ConnectToAAMS()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
sptr<ISystemAbilityManager> samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (!samgr) {
|
||||
HILOG_ERROR("AccessibleAbility::ConnectToAAMS Failed to get ISystemAbilityManager");
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("AccessibleAbility::ConnectToAAMS ISystemAbilityManager obtained");
|
||||
|
||||
sptr<IRemoteObject> object = samgr->GetSystemAbility(ACCESSIBLE_ABILITY_MANAGER_SERVICE_ID);
|
||||
if (!object) {
|
||||
HILOG_ERROR("[%s]Get IAccessibleAbilityManagerServiceClient object from samgr failed", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Get remote object ok");
|
||||
proxy_ = iface_cast<AccessibleAbilityManagerServiceClientProxy>(object);
|
||||
if (!proxy_) {
|
||||
HILOG_ERROR("AccessibleAbility::ConnectToAAMS IAccessibleAbilityManagerServiceClient iface_cast failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!stub_) {
|
||||
HILOG_ERROR("AccessibleAbility::stub_ is nullptr");
|
||||
return;
|
||||
}
|
||||
proxy_->RegisterAbilityConnectionClientTmp(stub_);
|
||||
}
|
||||
|
||||
void AccessibleAbility::DisableAbility()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
AccessibilityOperator::GetInstance().DisableAbility(channelId_);
|
||||
}
|
||||
|
||||
bool AccessibleAbility::GetFocusElementInfo(uint32_t focusType, std::optional<AccessibilityElementInfo>& elementInfo)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if ((focusType != FOCUS_TYPE_INPUT) && (focusType != FOCUS_TYPE_ACCESSIBILITY)) {
|
||||
HILOG_DEBUG("focusType is not allowed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
AccessibilityElementInfo info {};
|
||||
bool result = AccessibilityOperator::GetInstance().FindFocusedElementInfo(channelId_,
|
||||
ANY_WINDOW_ID, ROOT_NODE_ID, focusType, info);
|
||||
elementInfo = info;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AccessibleAbility::GestureSimulate(std::vector<GesturePathDefine>& gesturePathDefineList,
|
||||
std::shared_ptr<GestureResultListener>& listener)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (gesturePathDefineList.size() > gesturePathDefineList.front().GetMaxStrokes() ||
|
||||
gesturePathDefineList.size() <= 0) {
|
||||
HILOG_ERROR("The number of gesturePathDefine : [%{public}d] is not allowed.", gesturePathDefineList.size());
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t totalDurationTime = 0;
|
||||
for (auto gesturePath : gesturePathDefineList) {
|
||||
totalDurationTime += gesturePath.GetDurationTime();
|
||||
}
|
||||
HILOG_DEBUG("The total duration time is %{public}d.", totalDurationTime);
|
||||
|
||||
if (totalDurationTime > gesturePathDefineList.front().GetMaxStrokeDuration()) {
|
||||
HILOG_ERROR("The total duration time : [%{public}d] is not allowed.", totalDurationTime);
|
||||
return false;
|
||||
}
|
||||
|
||||
gestureStatusListenerSequence_++;
|
||||
|
||||
if (listener) {
|
||||
gestureResultListenerInfos_.insert(make_pair(gestureStatusListenerSequence_,
|
||||
make_shared<GestureResultListenerInfo>(gesturePathDefineList, listener)));
|
||||
}
|
||||
|
||||
AccessibilityOperator::GetInstance().SendSimulateGesture(
|
||||
channelId_, gestureStatusListenerSequence_, gesturePathDefineList);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<DisplayResizeController>& AccessibleAbility::GetDisplayResizeController()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
// TODO: To make sure the id of DEFAULT_DISPALY.
|
||||
uint32_t DEFAULT_DISPALY = 0;
|
||||
return GetDisplayResizeController(DEFAULT_DISPALY);
|
||||
}
|
||||
|
||||
std::shared_ptr<DisplayResizeController>& AccessibleAbility::GetDisplayResizeController(uint32_t displayId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
auto it = displayResizeControllers_.find(displayId);
|
||||
if (it != displayResizeControllers_.end()) {
|
||||
return displayResizeControllers_[displayId];
|
||||
} else {
|
||||
HILOG_DEBUG("Have no DisplayResizeController and make a new one.");
|
||||
displayResizeControllers_.insert(make_pair(displayId,
|
||||
make_shared<DisplayResizeController>(channelId_, displayId)));
|
||||
return displayResizeControllers_[displayId];
|
||||
}
|
||||
}
|
||||
|
||||
bool AccessibleAbility::GetRootElementInfo(std::optional<AccessibilityElementInfo>& elementInfo)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
AccessibilityElementInfo info {};
|
||||
bool result = AccessibilityOperator::GetInstance().GetRoot(channelId_, info);
|
||||
elementInfo = info;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<AccessibilityWindowInfo>& AccessibleAbility::GetWindows()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
accessibilityWindow_ = AccessibilityOperator::GetInstance().GetWindows(channelId_);
|
||||
return accessibilityWindow_;
|
||||
}
|
||||
|
||||
bool AccessibleAbility::PerformCommonAction(uint32_t action)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (!CheckCommonAction(action)) {
|
||||
HILOG_ERROR("action is not allowed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return AccessibilityOperator::GetInstance().PerformCommonAction(channelId_, action);
|
||||
}
|
||||
|
||||
std::shared_ptr<FingerprintController>& AccessibleAbility::GetFingerprintController()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (!fingerprintController_) {
|
||||
fingerprintController_ = make_shared<FingerprintController>(channelId_);
|
||||
}
|
||||
return fingerprintController_;
|
||||
}
|
||||
|
||||
void AccessibleAbility::DispatchOnSimulationGestureResult(uint32_t sequence, bool result)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (gestureResultListenerInfos_.empty()) {
|
||||
HILOG_ERROR("There is no informations of gestureResultListener");
|
||||
return;
|
||||
}
|
||||
|
||||
shared_ptr<GestureResultListenerInfo> gestureResultListenerInfo = nullptr;
|
||||
auto it = gestureResultListenerInfos_.find(sequence);
|
||||
if (it != gestureResultListenerInfos_.end()) {
|
||||
HILOG_DEBUG("gestureResultListenerInfo has been found.");
|
||||
gestureResultListenerInfo = gestureResultListenerInfos_[sequence];
|
||||
}
|
||||
|
||||
if (!gestureResultListenerInfo) {
|
||||
HILOG_ERROR("There is no gestureResultListenerInfo in gestureResultListenerInfos_[%{public}d", sequence);
|
||||
return;
|
||||
}
|
||||
|
||||
shared_ptr<GestureResultListener> listener = gestureResultListenerInfo->GetGestureResultListener();
|
||||
if (!listener) {
|
||||
HILOG_ERROR("listener is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
vector<GesturePathDefine> gesturePath = gestureResultListenerInfo->GetGesturePathDefine();
|
||||
if (gesturePath.empty()) {
|
||||
HILOG_ERROR("There is no gesturePath");
|
||||
return;
|
||||
}
|
||||
|
||||
if (result) {
|
||||
HILOG_DEBUG("Gesture has been sent successfully and result is %{public}d", result);
|
||||
listener->OnCompleted(gesturePath);
|
||||
} else {
|
||||
HILOG_DEBUG("Gesture has been sent failed and result is %{public}d", result);
|
||||
listener->OnCancelled(gesturePath);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbility::SetChannelId(uint32_t channelId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
channelId_ = channelId;
|
||||
}
|
||||
|
||||
bool AccessibleAbility::CheckCommonAction(uint32_t action)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if ((action != GLOBAL_ACTION_BACK) && (action != GLOBAL_ACTION_HOME) &&
|
||||
(action != GLOBAL_ACTION_RECENT) && (action != GLOBAL_ACTION_NOTIFICATION) &&
|
||||
(action != GLOBAL_ACTION_POP_UP_POWER_DIALOG) && (action != GLOBAL_ACTION_DIVIDE_SCREEN) &&
|
||||
(action != GLOBAL_ACTION_LOCK_SCREEN) && (action != GLOBAL_ACTION_CAPTURE_SCREEN)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
293
frameworks/aafwk/src/accessible_ability_client_proxy.cpp
Normal file
293
frameworks/aafwk/src/accessible_ability_client_proxy.cpp
Normal file
@ -0,0 +1,293 @@
|
||||
/*
|
||||
* 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 <stdint.h>
|
||||
#include "accessible_ability_client_proxy.h"
|
||||
#include "accessibility_errorcode.h"
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
AccessibleAbilityClientProxy::AccessibleAbilityClientProxy(const sptr<IRemoteObject> &object):
|
||||
IRemoteProxy<IAccessibleAbilityClient>(object)
|
||||
{}
|
||||
|
||||
bool AccessibleAbilityClientProxy::WriteInterfaceToken(MessageParcel &data)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (!data.WriteInterfaceToken(AccessibleAbilityClientProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("write interface token failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientProxy::Init(const sptr<IAccessibleAbilityChannel> &channel, const int channelId) {
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
if (!channel) {
|
||||
HILOG_ERROR("channel is null.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteRemoteObject(channel->AsObject())) {
|
||||
HILOG_ERROR("%{public}s fail, channel write parcelable error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(channelId)) {
|
||||
HILOG_ERROR("%{public}s fail, channelId write int32 error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::INIT), data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Init fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientProxy::Disconnect(const int channelId) {
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(channelId)) {
|
||||
HILOG_ERROR("%{public}s fail, channelId write int32 error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::DISCONNECT),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Disconnect fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientProxy::OnAccessibilityEvent(const AccessibilityEventInfo &eventInfo) {
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
if (!data.WriteParcelable(&eventInfo)) {
|
||||
HILOG_ERROR("%{public}s fail, eventInfo write parcelable error", __func__);
|
||||
return;
|
||||
}
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_ACCESSIBILITY_EVENT),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("OnAccessibilityEvent fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientProxy::OnInterrupt() {
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_INTERRUPT),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("OnInterrupt fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientProxy::OnGesture(const int gestureId) {
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(gestureId)) {
|
||||
HILOG_ERROR("%{public}s fail, gestureId write int32 error", __func__);
|
||||
return;
|
||||
}
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_GESTURE),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("OnGesture fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int sequence) {
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
#if 0 // TODO: Use AccessibilityKeyEvent to instead KeyEvent
|
||||
if (!data.WriteParcelable(&keyEvent)) {
|
||||
HILOG_ERROR("%{public}s fail, keyEvent write parcelable error", __func__);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (!data.WriteInt32(sequence)) {
|
||||
HILOG_ERROR("%{public}s fail, sequence write int32 error", __func__);
|
||||
return;
|
||||
}
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_KEY_PRESS_EVENT),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("OnKeyPressEvent fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientProxy::OnDisplayResizeChanged(const int displayId, const Rect &rect, const float scale,
|
||||
const float centerX, const float centerY) {
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(displayId)) {
|
||||
HILOG_ERROR("%{public}s fail, displayId write int32 error", __func__);
|
||||
return;
|
||||
}
|
||||
if (!data.WriteParcelable(&rect)) {
|
||||
HILOG_ERROR("%{public}s fail, rect write parcelable error", __func__);
|
||||
return;
|
||||
}
|
||||
if (!data.WriteFloat(scale)) {
|
||||
HILOG_ERROR("%{public}s fail, scale write float error", __func__);
|
||||
return;
|
||||
}
|
||||
if (!data.WriteFloat(centerX)) {
|
||||
HILOG_ERROR("%{public}s fail, centerX write float error", __func__);
|
||||
return;
|
||||
}
|
||||
if (!data.WriteFloat(centerY)) {
|
||||
HILOG_ERROR("%{public}s fail, centerY write float error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_DISPALYRESIZE_CHANGED),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("OnDisplayResizeChanged fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientProxy::OnGestureSimulateResult(const int sequence, const bool completedSuccessfully) {
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(sequence)) {
|
||||
HILOG_ERROR("%{public}s fail, sequence write int32 error", __func__);
|
||||
return;
|
||||
}
|
||||
if (!data.WriteBool(completedSuccessfully)) {
|
||||
HILOG_ERROR("%{public}s fail, completedSuccessfully write bool error", __func__);
|
||||
return;
|
||||
}
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_GESTURE_SIMULATE_RESULT),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("OnGestureSimulateResult fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientProxy::OnFingerprintGestureValidityChanged(const bool validity) {
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
if (!data.WriteBool(validity)) {
|
||||
HILOG_ERROR("%{public}s fail, validity write bool error", __func__);
|
||||
return;
|
||||
}
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::
|
||||
ON_FINGERPRINT_GESTURE_VALIDITY_CHANGED), data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("OnFingerprintGestureValidityChanged fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientProxy::OnFingerprintGesture(const int gesture) {
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(gesture)) {
|
||||
HILOG_ERROR("%{public}s fail, gesture write int32 error", __func__);
|
||||
return;
|
||||
}
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_FINGERPRINT_GESTURE),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("OnFingerprintGesture fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
196
frameworks/aafwk/src/accessible_ability_client_stub.cpp
Normal file
196
frameworks/aafwk/src/accessible_ability_client_stub.cpp
Normal file
@ -0,0 +1,196 @@
|
||||
/*
|
||||
* 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 "accessible_ability_client_stub.h"
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
AccessibleAbilityClientStub::AccessibleAbilityClientStub()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityClient::Message::INIT)] =
|
||||
&AccessibleAbilityClientStub::HandleInit;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityClient::Message::DISCONNECT)] =
|
||||
&AccessibleAbilityClientStub::HandleDisconnect;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_ACCESSIBILITY_EVENT)] =
|
||||
&AccessibleAbilityClientStub::HandleOnAccessibilityEvent;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_INTERRUPT)] =
|
||||
&AccessibleAbilityClientStub::HandleOnInterrupt;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_GESTURE)] =
|
||||
&AccessibleAbilityClientStub::HandleOnGesture;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_KEY_PRESS_EVENT)] =
|
||||
&AccessibleAbilityClientStub::HandleOnKeyPressEvent;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_DISPALYRESIZE_CHANGED)] =
|
||||
&AccessibleAbilityClientStub::HandleOnDisplayResizeChanged;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_GESTURE_SIMULATE_RESULT)] =
|
||||
&AccessibleAbilityClientStub::HandleOnGestureSimulateResult;
|
||||
memberFuncMap_[static_cast<uint32_t>(
|
||||
IAccessibleAbilityClient::Message::ON_FINGERPRINT_GESTURE_VALIDITY_CHANGED)] =
|
||||
&AccessibleAbilityClientStub::HandleOnFingerprintGestureValidityChanged;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_FINGERPRINT_GESTURE)] =
|
||||
&AccessibleAbilityClientStub::HandleOnFingerprintGesture;
|
||||
}
|
||||
|
||||
AccessibleAbilityClientStub::~AccessibleAbilityClientStub()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
memberFuncMap_.clear();
|
||||
}
|
||||
|
||||
int AccessibleAbilityClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
{
|
||||
HILOG_DEBUG("AccessibleAbilityClientStub::OnRemoteRequest, cmd = %d, flags= %d", code, option.GetFlags());
|
||||
std::u16string descriptor = AccessibleAbilityClientStub::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (descriptor != remoteDescriptor) {
|
||||
HILOG_INFO("local descriptor is not equal to remote");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
auto itFunc = memberFuncMap_.find(code);
|
||||
if (itFunc != memberFuncMap_.end()) {
|
||||
auto memberFunc = itFunc->second;
|
||||
if (memberFunc != nullptr) {
|
||||
return (this->*memberFunc)(data, reply);
|
||||
}
|
||||
}
|
||||
HILOG_WARN("AccessibleAbilityClientStub::OnRemoteRequest, default case, need check.");
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityClientStub::HandleInit(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
sptr<IRemoteObject> object = data.ReadRemoteObject();
|
||||
if (!object) {
|
||||
HILOG_ERROR("object is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
sptr<IAccessibleAbilityChannel> channel = iface_cast<IAccessibleAbilityChannel>(object);
|
||||
if (!channel) {
|
||||
HILOG_ERROR("channel is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int channelId = data.ReadInt32();
|
||||
|
||||
Init(channel, channelId);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityClientStub::HandleDisconnect(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
int channelId = data.ReadInt32();
|
||||
Disconnect(channelId);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityClientStub::HandleOnAccessibilityEvent(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
std::unique_ptr<AccessibilityEventInfo> eventInfo(data.ReadParcelable<AccessibilityEventInfo>());
|
||||
if (!eventInfo) {
|
||||
HILOG_ERROR("ReadParcelable<AccessibilityEventInfo> failed");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
OnAccessibilityEvent(*eventInfo);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityClientStub::HandleOnInterrupt(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
OnInterrupt();
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityClientStub::HandleOnGesture(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
int gestureId = data.ReadInt32();
|
||||
OnGesture(gestureId);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityClientStub::HandleOnKeyPressEvent(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
#if 0 // TODO: Use AccessibilityKeyEvent to instead KeyEvent
|
||||
std::unique_ptr<KeyEvent> keyEvent(data.ReadParcelable<KeyEvent>());
|
||||
if (!keyEvent) {
|
||||
HILOG_ERROR("ReadParcelable<KeyEvent> failed");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
int sequence = data.ReadInt32();
|
||||
|
||||
OnKeyPressEvent(*keyEvent, sequence);
|
||||
#endif
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityClientStub::HandleOnDisplayResizeChanged(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
int displayId = data.ReadInt32();
|
||||
|
||||
std::unique_ptr<Rect> rect(data.ReadParcelable<Rect>());
|
||||
if (!rect) {
|
||||
HILOG_ERROR("ReadParcelable<Rect> failed");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
float scale = data.ReadFloat();
|
||||
float centerX = data.ReadFloat();
|
||||
float centerY = data.ReadFloat();
|
||||
|
||||
OnDisplayResizeChanged(displayId, *rect, scale, centerX, centerY);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityClientStub::HandleOnGestureSimulateResult(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
int sequence = data.ReadInt32();
|
||||
bool completedSuccessfully = data.ReadBool();
|
||||
|
||||
OnGestureSimulateResult(sequence, completedSuccessfully);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityClientStub::HandleOnFingerprintGestureValidityChanged(
|
||||
MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
bool validity = data.ReadBool();
|
||||
OnFingerprintGestureValidityChanged(validity);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityClientStub::HandleOnFingerprintGesture(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
int gesture = data.ReadInt32();
|
||||
OnFingerprintGesture(gesture);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
298
frameworks/aafwk/src/accessible_ability_client_stub_impl.cpp
Normal file
298
frameworks/aafwk/src/accessible_ability_client_stub_impl.cpp
Normal file
@ -0,0 +1,298 @@
|
||||
/*
|
||||
* 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 <string>
|
||||
#include "accessible_ability_client_stub_impl.h"
|
||||
#include "accessible_ability.h"
|
||||
#include "display_resize_controller.h"
|
||||
#include "fingerprint_controller.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
const string TASK_INIT = "Init";
|
||||
const string TASK_DISCONNECT = "Disconnect";
|
||||
const string TASK_ON_ACCESSIBILITY_EVENT = "OnAccessibilityEvent";
|
||||
const string TASK_ON_INTERRUPT = "OnInterrupt";
|
||||
const string TASK_ON_GESTURE = "OnGesture";
|
||||
const string TASK_ON_KEY_PRESS_EVENT = "OnKeyPressEvent";
|
||||
const string TASK_ON_DISPLAYRESIZE_CHANGED = "OnDisplayResizeChanged";
|
||||
const string TASK_ON_GESTURE_SIMULATE_RESULT = "OnGestureSimulateResult";
|
||||
const string TASK_ON_FINGERPRINT_GESTURE_VALIDITY_CHANGED = "OnFingerprintGestureValidityChanged";
|
||||
const string TASK_ON_FINGERPRINT_GESTURE = "OnFingerprintGesture";
|
||||
|
||||
AccessibleAbilityClientStubImpl::AccessibleAbilityClientStubImpl
|
||||
(const std::shared_ptr<AccessibleAbilityEventHandler> &accessibleAbilityEventHandler)
|
||||
: handler_(accessibleAbilityEventHandler)
|
||||
{}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::RegisterListenerImpl(const std::shared_ptr<AccessibleAbilityListener> &listener)
|
||||
{
|
||||
HILOG_DEBUG("Register AccessibleAbilityClientStubImpl listener.");
|
||||
if (listener_) {
|
||||
HILOG_DEBUG("listener already exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
listener_ = listener;
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::Init(const sptr<IAccessibleAbilityChannel> &channel, const int channelId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
std::function<void()> initFunc = std::bind(&AccessibleAbilityClientStubImpl::InitInner, this, channel, channelId);
|
||||
handler_->PostTask(initFunc, TASK_INIT);
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::Disconnect(const int channelId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
std::function<void()> disconnectFunc = std::bind(&AccessibleAbilityClientStubImpl::InitInner,
|
||||
this, nullptr, channelId);
|
||||
handler_->PostTask(disconnectFunc, TASK_DISCONNECT);
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::InitInner(const sptr<IAccessibleAbilityChannel> &channel, const int channelId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (!channel) {
|
||||
HILOG_DEBUG("RemoveChannel start.");
|
||||
|
||||
// Delete death recipient
|
||||
if (channel_ && channel_->AsObject()) {
|
||||
HILOG_ERROR("Remove death recipient");
|
||||
channel_->AsObject()->RemoveDeathRecipient(deathRecipient_);
|
||||
}
|
||||
|
||||
// Remove channel
|
||||
AccessibilityOperator::RemoveChannel(channelId);
|
||||
channelId_ = INVALID_CHANNEL_ID;
|
||||
AccessibleAbility::GetInstance().SetChannelId(channelId_);
|
||||
channel_ = channel;
|
||||
} else {
|
||||
HILOG_DEBUG("AddChannel start.");
|
||||
AccessibilityOperator::AddChannel(channelId, channel);
|
||||
channelId_ = channelId;
|
||||
AccessibleAbility::GetInstance().SetChannelId(channelId_);
|
||||
channel_ = channel;
|
||||
|
||||
// Add death recipient
|
||||
if (!deathRecipient_) {
|
||||
deathRecipient_ = new AccessibleAbilityDeathRecipient(channelId_, channel_);
|
||||
}
|
||||
|
||||
auto object = channel_->AsObject();
|
||||
if (object) {
|
||||
HILOG_DEBUG("Add death recipient");
|
||||
object->AddDeathRecipient(deathRecipient_);
|
||||
}
|
||||
|
||||
// Add listener of ability
|
||||
if (!listener_) {
|
||||
HILOG_ERROR("listener is nullptr.");
|
||||
return;
|
||||
}
|
||||
listener_->OnAbilityConnected();
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnAccessibilityEvent(const AccessibilityEventInfo &eventInfo)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (channelId_ != INVALID_CHANNEL_ID) {
|
||||
std::function<void()> onAccessibilityEventFunc = std::bind(
|
||||
&AccessibleAbilityClientStubImpl::OnAccessibilityEventInner, this, eventInfo);
|
||||
handler_->PostTask(onAccessibilityEventFunc, TASK_ON_ACCESSIBILITY_EVENT);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnAccessibilityEventInner(const AccessibilityEventInfo &eventInfo)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (!listener_) {
|
||||
HILOG_ERROR("listener is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
listener_->OnAccessibilityEvent(eventInfo);
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnInterrupt()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (channelId_ != INVALID_CHANNEL_ID) {
|
||||
std::function<void()> interruptFunc = std::bind(&AccessibleAbilityClientStubImpl::OnInterruptInner, this);
|
||||
handler_->PostTask(interruptFunc, TASK_ON_INTERRUPT);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::AccessibleAbilityClientStubImpl::OnInterruptInner()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (!listener_) {
|
||||
HILOG_ERROR("listener is nullptr.");
|
||||
return;
|
||||
}
|
||||
listener_->OnInterrupt();
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnGesture(const int gestureId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (channelId_ != INVALID_CHANNEL_ID) {
|
||||
std::function<void()> onGestureFunc = std::bind(&AccessibleAbilityClientStubImpl::OnGestureInner,
|
||||
this, gestureId);
|
||||
handler_->PostTask(onGestureFunc, TASK_ON_GESTURE);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnGestureInner(const int gestureId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (!listener_) {
|
||||
HILOG_ERROR("listener is nullptr.");
|
||||
return;
|
||||
}
|
||||
listener_->OnGesture(gestureId);
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int sequence)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
// TODO: fixme
|
||||
// std::function<void()> onKeyPressEventFunc = std::bind(
|
||||
// &AccessibleAbilityClientStubImpl::OnKeyPressEventInner, this, keyEvent, sequence);
|
||||
// handler_->PostTask(onKeyPressEventFunc, TASK_ON_KEY_PRESS_EVENT);
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnKeyPressEventInner(const MMI::KeyEvent &keyEvent, const int sequence)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (!listener_) {
|
||||
HILOG_ERROR("listener is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
bool handled = listener_->OnKeyPressEvent(keyEvent);
|
||||
AccessibilityOperator::GetInstance().SetOnKeyPressEventResult(channelId_, handled, sequence);
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnDisplayResizeChanged(const int displayId, const Rect &rect, const float scale,
|
||||
const float centerX, const float centerY)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (channelId_ != INVALID_CHANNEL_ID) {
|
||||
std::function<void()> onDisplayResizeChangedFunc = std::bind(
|
||||
&AccessibleAbilityClientStubImpl::OnDisplayResizeChangedInner, this,
|
||||
displayId, rect, scale, centerX, centerY);
|
||||
handler_->PostTask(onDisplayResizeChangedFunc, TASK_ON_DISPLAYRESIZE_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnDisplayResizeChangedInner(const int displayId, const Rect &rect,
|
||||
const float scale, const float centerX, const float centerY)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
shared_ptr<DisplayResizeController> displayResizeController =
|
||||
AccessibleAbility::GetInstance().GetDisplayResizeController(displayId);
|
||||
if (!displayResizeController) {
|
||||
HILOG_ERROR("There is no displayResizeController.");
|
||||
return;
|
||||
}
|
||||
|
||||
displayResizeController->DispatchOnDisplayResizeChanged(rect, scale, centerX, centerY);
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnGestureSimulateResult(const int sequence, const bool completedSuccessfully)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (channelId_ != INVALID_CHANNEL_ID) {
|
||||
std::function<void()> onGestureSimulateResultFunc = std::bind(
|
||||
&AccessibleAbilityClientStubImpl::OnGestureSimulateResultInner, this, sequence, completedSuccessfully);
|
||||
handler_->PostTask(onGestureSimulateResultFunc, TASK_ON_GESTURE_SIMULATE_RESULT);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnGestureSimulateResultInner(const int sequence,
|
||||
const bool completedSuccessfully)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
AccessibleAbility::GetInstance().DispatchOnSimulationGestureResult(sequence, completedSuccessfully);
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnFingerprintGestureValidityChanged(const bool validity)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (channelId_ != INVALID_CHANNEL_ID) {
|
||||
std::function<void()> onFingerprintGestureValidityChangedFunc = std::bind(
|
||||
&AccessibleAbilityClientStubImpl::OnFingerprintGestureValidityChangedInner, this, validity);
|
||||
handler_->PostTask(onFingerprintGestureValidityChangedFunc, TASK_ON_FINGERPRINT_GESTURE_VALIDITY_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnFingerprintGestureValidityChangedInner(const bool validity)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
shared_ptr<FingerprintController> fingerprintController =
|
||||
AccessibleAbility::GetInstance().GetFingerprintController();
|
||||
if (!fingerprintController) {
|
||||
HILOG_ERROR("There is no fingerprintController.");
|
||||
return;
|
||||
}
|
||||
|
||||
fingerprintController->DispatchOnFingerprintGestureStatusChanged(validity);
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnFingerprintGesture(const int gesture)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (channelId_ != INVALID_CHANNEL_ID) {
|
||||
std::function<void()> onFingerprintGestureFunc = std::bind(
|
||||
&AccessibleAbilityClientStubImpl::OnFingerprintGestureInner, this, gesture);
|
||||
handler_->PostTask(onFingerprintGestureFunc, TASK_ON_FINGERPRINT_GESTURE);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::OnFingerprintGestureInner(const int gesture)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
shared_ptr<FingerprintController> fingerprintController =
|
||||
AccessibleAbility::GetInstance().GetFingerprintController();
|
||||
if (!fingerprintController) {
|
||||
HILOG_ERROR("There is no fingerprintController.");
|
||||
return;
|
||||
}
|
||||
|
||||
fingerprintController->DispatchOnFingerprintGesture(gesture);
|
||||
}
|
||||
|
||||
void AccessibleAbilityClientStubImpl::AccessibleAbilityDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
// Delete death recipient
|
||||
remote->RemoveDeathRecipient(this);
|
||||
|
||||
// Remove channel
|
||||
AccessibilityOperator::RemoveChannel(recipientChannelId_);
|
||||
recipientChannelId_ = INVALID_CHANNEL_ID;
|
||||
AccessibleAbility::GetInstance().SetChannelId(recipientChannelId_);
|
||||
recipientchannel_ = nullptr;
|
||||
}
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
43
frameworks/aafwk/src/accessible_ability_event_handler.cpp
Normal file
43
frameworks/aafwk/src/accessible_ability_event_handler.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 "accessible_ability_event_handler.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
AccessibleAbilityEventHandler::AccessibleAbilityEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner)
|
||||
: AppExecFwk::EventHandler(runner)
|
||||
{
|
||||
HILOG_DEBUG("AccessibleAbilityEventHandler is created");
|
||||
}
|
||||
|
||||
AccessibleAbilityEventHandler::~AccessibleAbilityEventHandler()
|
||||
{
|
||||
HILOG_DEBUG("AccessibleAbilityEventHandler is destroyed");
|
||||
}
|
||||
|
||||
void AccessibleAbilityEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
HILOG_DEBUG("eventId = %{public}d", event->GetInnerEventId());
|
||||
switch (event->GetInnerEventId()) {
|
||||
default:
|
||||
HILOG_ERROR("the eventId is not supported");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
118
frameworks/aafwk/src/display_resize_controller.cpp
Normal file
118
frameworks/aafwk/src/display_resize_controller.cpp
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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 "display_resize_controller.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
DisplayResizeController::DisplayResizeController(uint32_t channelId, uint32_t displayId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
channelId_ = channelId;
|
||||
displayId_ = displayId;
|
||||
}
|
||||
|
||||
void DisplayResizeController::AddListener(std::shared_ptr<DisplayResizeListener>& listener)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!listener) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto it = displayResizeListeners_.begin(); it != displayResizeListeners_.end(); ++it) {
|
||||
if (*it == listener) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
displayResizeListeners_.push_back(listener);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool DisplayResizeController::DeleteListener(std::shared_ptr<DisplayResizeListener>& listener)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
for (auto it = displayResizeListeners_.begin(); it != displayResizeListeners_.end(); ++it) {
|
||||
if (*it == listener) {
|
||||
displayResizeListeners_.erase(it);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
float DisplayResizeController::GetCenterX()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return AccessibilityOperator::GetInstance().GetDisplayResizeCenterX(channelId_, displayId_);
|
||||
}
|
||||
|
||||
float DisplayResizeController::GetCenterY()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return AccessibilityOperator::GetInstance().GetDisplayResizeCenterY(channelId_, displayId_);
|
||||
}
|
||||
|
||||
Rect DisplayResizeController::GetDisplayResizeRect()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return AccessibilityOperator::GetInstance().GetDisplayResizeRect(channelId_, displayId_);
|
||||
}
|
||||
|
||||
float DisplayResizeController::GetScale()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return AccessibilityOperator::GetInstance().GetDisplayResizeScale(channelId_, displayId_);
|
||||
}
|
||||
|
||||
bool DisplayResizeController::Reset(bool isShouldAnimate)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return AccessibilityOperator::GetInstance().ResetDisplayResize(channelId_, displayId_, isShouldAnimate);
|
||||
}
|
||||
|
||||
bool DisplayResizeController::SetCenter(float centerX, float centerY, bool isShouldAnimate)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return AccessibilityOperator::GetInstance().SetDisplayResizeScaleAndCenter(
|
||||
channelId_, displayId_, 1.0, centerX, centerY, isShouldAnimate);
|
||||
}
|
||||
|
||||
bool DisplayResizeController::SetScale(float scale, bool isShouldAnimate)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
float invalidValue = -1;
|
||||
return AccessibilityOperator::GetInstance().SetDisplayResizeScaleAndCenter(
|
||||
channelId_, displayId_, scale, invalidValue, invalidValue, isShouldAnimate);
|
||||
}
|
||||
|
||||
void DisplayResizeController::DispatchOnDisplayResizeChanged(const Rect& rect,
|
||||
const float scale, const float centerX, const float centerY)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
for (auto listener : displayResizeListeners_) {
|
||||
listener->OnDisplayResizeChanged(*this, rect, scale, centerX, centerY);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
82
frameworks/aafwk/src/fingerprint_controller.cpp
Normal file
82
frameworks/aafwk/src/fingerprint_controller.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 "fingerprint_controller.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
FingerprintController::FingerprintController(uint32_t channelId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start and channelId is %{public}d.", __func__, channelId);
|
||||
channelId_ = channelId;
|
||||
}
|
||||
|
||||
bool FingerprintController::IsFingerprintGestureDetectionValid()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return AccessibilityOperator::GetInstance().IsFingerprintGestureDetectionValid(channelId_);
|
||||
}
|
||||
|
||||
void FingerprintController::AddFingerprintListener(std::shared_ptr<FingerprintListener>& listener)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (!listener) {
|
||||
HILOG_ERROR("listener is nullptr.");
|
||||
return;
|
||||
}
|
||||
fingerprintListener_ = listener;
|
||||
}
|
||||
|
||||
void FingerprintController::DeleteFingerprintListener(std::shared_ptr<FingerprintListener>& listener)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
if (!listener) {
|
||||
HILOG_ERROR("listener is nullptr.");
|
||||
return;
|
||||
}
|
||||
if (fingerprintListener_ != listener) {
|
||||
HILOG_ERROR("There is not this listener.");
|
||||
return;
|
||||
}
|
||||
fingerprintListener_ = nullptr;
|
||||
}
|
||||
|
||||
void FingerprintController::DispatchOnFingerprintGestureStatusChanged(bool isActive)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!fingerprintListener_) {
|
||||
HILOG_ERROR("fingerprintListener_ is nullptr.");
|
||||
return;
|
||||
}
|
||||
fingerprintListener_->OnFingerprintGestureStatusChanged(isActive);
|
||||
}
|
||||
|
||||
void FingerprintController::DispatchOnFingerprintGesture(uint32_t gesture)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!fingerprintListener_) {
|
||||
HILOG_ERROR("fingerprintListener_ is nullptr.");
|
||||
return;
|
||||
}
|
||||
fingerprintListener_->OnFingerprintGesture(gesture);
|
||||
}
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
36
frameworks/asacfwk/asacfwk.gni
Normal file
36
frameworks/asacfwk/asacfwk.gni
Normal file
@ -0,0 +1,36 @@
|
||||
# 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.
|
||||
|
||||
import("//base/accessibility/accessibility.gni")
|
||||
|
||||
asacfwk_files = [
|
||||
"${asacfwk_path}/src/accessibility_event_info.cpp",
|
||||
"${asacfwk_path}/src/accessibility_element_info.cpp",
|
||||
"${asacfwk_path}/src/accessibility_window_info.cpp",
|
||||
"${asacfwk_path}/src/accessibility_state_event.cpp",
|
||||
"${asacfwk_path}/src/accessibility_system_ability_client.cpp",
|
||||
"${asacfwk_path}/src/accessible_ability_manager_service_proxy.cpp",
|
||||
"${asacfwk_path}/src/accessible_ability_manager_service_state_proxy.cpp",
|
||||
"${asacfwk_path}/src/accessible_ability_manager_service_state_stub.cpp",
|
||||
"${asacfwk_path}/src/accessible_ability_manager_service_stub.cpp",
|
||||
"${asacfwk_path}/src/accessibility_interaction_operation_callback_proxy.cpp",
|
||||
"${asacfwk_path}/src/accessibility_interaction_operation_callback_stub.cpp",
|
||||
"${asacfwk_path}/src/accessibility_interaction_operation_proxy.cpp",
|
||||
"${asacfwk_path}/src/accessibility_interaction_operation_stub.cpp",
|
||||
"${asacfwk_path}/src/accessibility_ability_info.cpp",
|
||||
"${asacfwk_path}/src/accessible_ability_channel_proxy.cpp",
|
||||
"${asacfwk_path}/src/accessible_ability_channel_stub.cpp",
|
||||
"${asacfwk_path}/src/accessibility_operator.cpp",
|
||||
"${asacfwk_path}/src/gesture_simulation.cpp",
|
||||
"//base/accessibility/util/src/json_utils.cpp",
|
||||
]
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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_INTERACTION_OPERATION_CALLBACK_INTERFACE_H
|
||||
#define ACCESSIBILITY_INTERACTION_OPERATION_CALLBACK_INTERFACE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "accessibility_element_info.h"
|
||||
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
/*
|
||||
* The class supply the callback to feedback the result from UI to AA.
|
||||
|
||||
*/
|
||||
class IAccessibilityInteractionOperationCallback : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accessibility.IAccessibilityInteractionOperationCallback");
|
||||
|
||||
/**
|
||||
* @brief Set the element information by accessibility id to AA.
|
||||
* @param infos The element info searched by accessibility id.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetSearchElementInfoByAccessibilityIdResult(const std::vector<AccessibilityElementInfo> &infos,
|
||||
const int requestId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the element informations matched with text to AA.
|
||||
* @param infos The element informations searched matched with text.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetSearchElementInfoByTextResult(const std::vector<AccessibilityElementInfo> &infos,
|
||||
const int requestId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the element informations matched with focus type to AA.
|
||||
* @param info The element informations searched matched with focus type.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetFindFocusedElementInfoResult(const AccessibilityElementInfo &info, const int requestId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the element informations by focus direction to AA.
|
||||
* @param info The element informations searched by focus direction.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetFocusMoveSearchResult(const AccessibilityElementInfo &info, const int requestId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the result of action executed to AA.
|
||||
* @param succeeded True: The action is executed successfully; otherwise is false.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetPerformActionResult(const bool succeeded, const int requestId) = 0;
|
||||
|
||||
enum class Message {
|
||||
SET_RESULT_BY_ACCESSIBILITY_ID = 0,
|
||||
SET_RESULT_BY_TEXT,
|
||||
SET_RESULT_FOCUSED_INFO,
|
||||
SET_RESULT_FOCUS_MOVE,
|
||||
SET_RESULT_PERFORM_ACTION,
|
||||
};
|
||||
};
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
||||
#endif
|
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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_INTERACTION_OPERATION_CALLBACK_PROXY_H
|
||||
#define ACCESSIBILITY_INTERACTION_OPERATION_CALLBACK_PROXY_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "accessibility_interaction_operation_callback_interface.h"
|
||||
|
||||
#include "iremote_proxy.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
/*
|
||||
* The class supply the callback to feedback the result from UI to AA.
|
||||
|
||||
*/
|
||||
class AccessibilityInteractionOperationCallbackProxy :
|
||||
public IRemoteProxy<IAccessibilityInteractionOperationCallback> {
|
||||
public:
|
||||
/**
|
||||
* @brief construct function
|
||||
* @param object The object of IPC
|
||||
* @return
|
||||
*/
|
||||
explicit AccessibilityInteractionOperationCallbackProxy(const sptr<IRemoteObject> &object);
|
||||
|
||||
/**
|
||||
* @brief destruct function
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual ~AccessibilityInteractionOperationCallbackProxy() override;
|
||||
|
||||
/**
|
||||
* @brief Set the element information by accessibility id to AA.
|
||||
* @param infos The element info searched by accessibility id.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
void SetSearchElementInfoByAccessibilityIdResult(const std::vector<AccessibilityElementInfo> &infos,
|
||||
const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Set the element informations matched with text to AA.
|
||||
* @param infos The element informations searched matched with text.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
void SetSearchElementInfoByTextResult(const std::vector<AccessibilityElementInfo> &infos,
|
||||
const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Set the element informations matched with focus type to AA.
|
||||
* @param info The element informations searched matched with focus type.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
void SetFindFocusedElementInfoResult(const AccessibilityElementInfo &info, const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Set the element informations by focus direction to AA.
|
||||
* @param info The element informations searched by focus direction.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
void SetFocusMoveSearchResult(const AccessibilityElementInfo &info, const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Set the result of action executed to AA.
|
||||
* @param succeeded True: The action is executed successfully; otherwise is false.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
void SetPerformActionResult(const bool succeeded, const int requestId) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Write the descriptor of IPC.
|
||||
* @param data It is include the descriptor of IPC.
|
||||
* @return true: Write the descriptor successfully; otherwise is not.
|
||||
*/
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
|
||||
/**
|
||||
* @brief Write the serializable data
|
||||
* @param parcelableVector The communication data of IPC
|
||||
* @param reply Serializable data
|
||||
* @return true: Write the serializable data successfully; otherwise is not.
|
||||
*/
|
||||
template<typename T>
|
||||
bool WriteParcelableVector(const std::vector<T> &parcelableVector, Parcel &reply);
|
||||
static inline BrokerDelegator<AccessibilityInteractionOperationCallbackProxy> delegator;
|
||||
};
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
||||
#endif
|
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* 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_INTERACTION_OPERATION_CALLBACK_STUB_H
|
||||
#define ACCESSIBILITY_INTERACTION_OPERATION_CALLBACK_STUB_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "accessibility_interaction_operation_callback_interface.h"
|
||||
#include "accessibility_errorcode.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "nocopyable.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
/*
|
||||
* The class define the interface for UI to implement.
|
||||
* It triggered by ABMS when AA to request the accessibility information.
|
||||
*/
|
||||
class AccessibilityInteractionOperationCallbackStub : public IRemoteStub<IAccessibilityInteractionOperationCallback> {
|
||||
public:
|
||||
/**
|
||||
* @brief construct function
|
||||
* @param object The object of IPC
|
||||
* @return
|
||||
*/
|
||||
AccessibilityInteractionOperationCallbackStub();
|
||||
|
||||
/**
|
||||
* @brief destruct function
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual ~AccessibilityInteractionOperationCallbackStub();
|
||||
|
||||
/**
|
||||
* @brief Receive the event from proxy by IPC mechanism.
|
||||
* @param code The code is matched with the process function.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @param option The option paramter of IPC,such as: async,sync
|
||||
* @return
|
||||
*/
|
||||
virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option) override;
|
||||
private:
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:SetSearchElementInfoByAccessibilityIdResult.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleSetSearchElementInfoByAccessibilityIdResult(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:SetSearchElementInfoByTextResult.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleSetSearchElementInfoByTextResult(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:SetFindFocusedElementInfoResult.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleSetFindFocusedElementInfoResult(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:SetFocusMoveSearchResult.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleSetFocusMoveSearchResult(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:SetPerformActionResult.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleSetPerformActionResult(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using AccessibilityInteractionOperationCallbackFunc = ErrCode (AccessibilityInteractionOperationCallbackStub::*)
|
||||
(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, AccessibilityInteractionOperationCallbackFunc> memberFuncMap_;
|
||||
};
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
||||
#endif
|
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* 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_INTERACTION_OPERATION_INTERFACE_H
|
||||
#define ACCESSIBILITY_INTERACTION_OPERATION_INTERFACE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "accessibility_interaction_operation_callback_interface.h"
|
||||
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_object.h"
|
||||
#include "refbase.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
/*
|
||||
* The class define the interface for UI to implement.
|
||||
* It triggered by ABMS when AA to request the accessibility information.
|
||||
*/
|
||||
class IAccessibilityInteractionOperation : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accessibility.IAccessibilityInteractionOperation");
|
||||
|
||||
/**
|
||||
* @brief Make the node information by accessibility ID and set the result by callback.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also.
|
||||
* PREFETCH_SIBLINGS: Need to make the sister/brothers node info also.
|
||||
* PREFETCH_CHILDREN: Need to make the child node info also.
|
||||
* otherwise: Make the node information by elementId only.
|
||||
* @return -
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
virtual void SearchElementInfoByAccessibilityId(const long elementId,
|
||||
const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback, const int mode) = 0;
|
||||
|
||||
/**
|
||||
* @brief Make the child node information by accessibility ID and filtered by text and set the result by callback.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param text Filter for the child components to matched with the text
|
||||
* @return
|
||||
*/
|
||||
virtual void SearchElementInfosByText(const long elementId, const std::string &text,
|
||||
const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief Make the node information of the component focused by the focus type specified.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus
|
||||
* FOCUS_TYPE_INPUT: text input focus
|
||||
* @return
|
||||
*/
|
||||
virtual void FindFocusedElementInfo(const long elementId, const int focusType, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief Make the node info by current focus move direction.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
|
||||
* @return -
|
||||
*/
|
||||
virtual void FocusMoveSearch(const long elementId, const int direction, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief To return the result of perform action.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param action Refer to [AccessibilityElementInfo.ActionType]
|
||||
* @param actionArguments The parameter for action type. such as:
|
||||
* action: ACCESSIBILITY_ACTION_NEXT_HTML_ITEM,
|
||||
* actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
|
||||
* action: ACCESSIBILITY_ACTION_PREVIOUS_HTML_ITEM,
|
||||
* actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
|
||||
* action: ACCESSIBILITY_ACTION_NEXT_TEXT,
|
||||
* actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
|
||||
* action: ACCESSIBILITY_ACTION_PREVIOUS_TEXT,
|
||||
* actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
|
||||
* action: ACCESSIBILITY_ACTION_SET_SELECTION,
|
||||
* actionArguments({ACTION_ARGU_SELECT_TEXT_START,"1"(start location)},
|
||||
* {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
|
||||
* action: ACCESSIBILITY_ACTION_SET_TEXT,
|
||||
* actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
|
||||
* @return
|
||||
*/
|
||||
virtual void PerformAction(const long elementId, const int action,
|
||||
const std::map<std::string, std::string> actionArguments,
|
||||
const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief The function is called while accessibility System check the id of window is not equal
|
||||
* to the id of active window when sendAccessibility.
|
||||
* @param -
|
||||
* @return
|
||||
*/
|
||||
virtual void ClearFocus() = 0;
|
||||
|
||||
/**
|
||||
* @brief the low layser is notified by the function called while accessibility system execute
|
||||
* the function of performAction from AS to check the all low windows cared the outside event.
|
||||
* Example: PopupWindow receive the OUTSIDE_EVENT to close itself.
|
||||
* @param -
|
||||
* @return
|
||||
*/
|
||||
virtual void OutsideTouch() = 0;
|
||||
|
||||
enum class Message {
|
||||
SEARCH_BY_ACCESSIBILITY_ID = 0,
|
||||
SEARCH_BY_TEXT,
|
||||
FIND_FOCUSED_INFO,
|
||||
FOCUS_FIND,
|
||||
PERFORM_ACTION,
|
||||
CLEAR_FOCUS,
|
||||
OUTSIDE_TOUCH,
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif
|
@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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_INTERACTION_OPERATION_PROXY_H
|
||||
#define ACCESSIBILITY_INTERACTION_OPERATION_PROXY_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "accessibility_interaction_operation_callback_interface.h"
|
||||
#include "accessibility_interaction_operation_interface.h"
|
||||
|
||||
#include "iremote_proxy.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
/*
|
||||
* The class define the interface for UI to implement.
|
||||
* It triggered by ABMS when AA to request the accessibility information.
|
||||
*/
|
||||
class AccessibilityInteractionOperationProxy : public IRemoteProxy<IAccessibilityInteractionOperation>{
|
||||
public:
|
||||
/**
|
||||
* @brief construct function
|
||||
* @param object The object of IPC
|
||||
* @return
|
||||
*/
|
||||
explicit AccessibilityInteractionOperationProxy(const sptr<IRemoteObject> &object);
|
||||
|
||||
/**
|
||||
* @brief destruct function
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual ~AccessibilityInteractionOperationProxy() override;
|
||||
|
||||
/**
|
||||
* @brief Make the node information by accessibility ID and set the result by callback.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also.
|
||||
* PREFETCH_SIBLINGS: Need to make the sister/brothers node info also.
|
||||
* PREFETCH_CHILDREN: Need to make the child node info also.
|
||||
* otherwise: Make the node information by elementId only.
|
||||
* @return -
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
virtual void SearchElementInfoByAccessibilityId(const long elementId, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback, const int mode) override;
|
||||
|
||||
/**
|
||||
* @brief Make the child node information by accessibility ID and filtered by text and set the result by callback.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param text Filter for the child components to matched with the text
|
||||
* @return
|
||||
*/
|
||||
virtual void SearchElementInfosByText(const long elementId, const std::string &text,
|
||||
const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback) override;
|
||||
|
||||
/**
|
||||
* @brief Make the node information of the component focused by the focus type specified.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus
|
||||
* FOCUS_TYPE_INPUT: text input focus
|
||||
* @return
|
||||
*/
|
||||
virtual void FindFocusedElementInfo(const long elementId, const int focusType, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) override;
|
||||
|
||||
/**
|
||||
* @brief Make the node info by current focus move direction.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
|
||||
* @return -
|
||||
*/
|
||||
virtual void FocusMoveSearch(const long elementId, const int direction, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) override;
|
||||
|
||||
/**
|
||||
* @brief To return the result of perform action.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param action Refer to [AccessibilityElementInfo.ActionType]
|
||||
* @param actionArguments The parameter for action type. such as:
|
||||
* action: ACCESSIBILITY_ACTION_NEXT_HTML_ITEM,
|
||||
* actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
|
||||
* action: ACCESSIBILITY_ACTION_PREVIOUS_HTML_ITEM,
|
||||
* actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
|
||||
* action: ACCESSIBILITY_ACTION_NEXT_TEXT,
|
||||
* actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
|
||||
* action: ACCESSIBILITY_ACTION_PREVIOUS_TEXT,
|
||||
* actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
|
||||
* action: ACCESSIBILITY_ACTION_SET_SELECTION,
|
||||
* actionArguments({ACTION_ARGU_SELECT_TEXT_START,"1"(start location)},
|
||||
* {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
|
||||
* action: ACCESSIBILITY_ACTION_SET_TEXT,
|
||||
* actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
|
||||
* @return
|
||||
*/
|
||||
virtual void PerformAction(const long elementId, const int action,
|
||||
const std::map<std::string, std::string> actionArguments,
|
||||
int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback) override;
|
||||
|
||||
/**
|
||||
* @brief The function is called while accessibility System check the id of window is not equal
|
||||
* to the id of active window when sendAccessibility.
|
||||
* @param -
|
||||
* @return
|
||||
*/
|
||||
virtual void ClearFocus() override;
|
||||
|
||||
/**
|
||||
* @brief the low layser is notified by the function called while accessibility system execute
|
||||
* the function of performAction from AS to check the all low windows cared the outside event.
|
||||
* Example: PopupWindow receive the OUTSIDE_EVENT to close itself.
|
||||
* @param -
|
||||
* @return
|
||||
*/
|
||||
virtual void OutsideTouch() override;
|
||||
private:
|
||||
/**
|
||||
* @brief Write the descriptor of IPC.
|
||||
* @param data It is include the descriptor of IPC.
|
||||
* @return true: Write the descriptor successfully; otherwise is not.
|
||||
*/
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
static inline BrokerDelegator<AccessibilityInteractionOperationProxy> delegator;
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif
|
@ -0,0 +1,325 @@
|
||||
/*
|
||||
* 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_INTERACTION_OPERATION_STUB_H
|
||||
#define ACCESSIBILITY_INTERACTION_OPERATION_STUB_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "accessibility_interaction_operation_interface.h"
|
||||
#include "accessibility_interaction_operation_callback.h"
|
||||
#include "accessibility_errorcode.h"
|
||||
#include "iremote_object.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "nocopyable.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
/*
|
||||
* The class define the interface for UI to implement.
|
||||
* It is triggered by ABMS when AA to request the accessibility information.
|
||||
*/
|
||||
class AccessibilityInteractionOperationStub : public IRemoteStub<IAccessibilityInteractionOperation>{
|
||||
public:
|
||||
/**
|
||||
* @brief construct function
|
||||
* @param object The object of IPC
|
||||
* @return
|
||||
*/
|
||||
AccessibilityInteractionOperationStub();
|
||||
|
||||
/**
|
||||
* @brief destruct function
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual ~AccessibilityInteractionOperationStub();
|
||||
|
||||
/**
|
||||
* @brief Receive the event from proxy by IPC mechanism.
|
||||
* @param code The code is matched with the process function.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @param option The option paramter of IPC,such as: async,sync
|
||||
* @return
|
||||
*/
|
||||
virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option) override;
|
||||
|
||||
/**
|
||||
* @brief Make the node information by accessibility ID and set the result by callback.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also.
|
||||
* PREFETCH_SIBLINGS: Need to make the sister/brothers node info also.
|
||||
* PREFETCH_CHILDREN: Need to make the child node info also.
|
||||
* otherwise: Make the node information by elementId only.
|
||||
* @return -
|
||||
*/
|
||||
virtual void SearchElementInfoByAccessibilityId(const long elementId, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback, const int mode) override;
|
||||
|
||||
/**
|
||||
* @brief Make the child node information by accessibility ID and filtered by text and set the result by callback.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param text Filter for the child components to matched with the text
|
||||
* @return
|
||||
*/
|
||||
virtual void SearchElementInfosByText(const long elementId, const std::string &text,
|
||||
const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback) override;
|
||||
|
||||
/**
|
||||
* @brief Make the node information of the component focused by the focus type specified.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus
|
||||
* FOCUS_TYPE_INPUT: text input focus
|
||||
* @return
|
||||
*/
|
||||
virtual void FindFocusedElementInfo(const long elementId, const int focusType, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) override;
|
||||
|
||||
/**
|
||||
* @brief Make the node info by current focus move direction.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
|
||||
* @return -
|
||||
*/
|
||||
virtual void FocusMoveSearch(const long elementId, const int direction, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) override;
|
||||
|
||||
/**
|
||||
* @brief To return the result of perform action.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param action Refer to [AccessibilityElementInfo.ActionType]
|
||||
* @param actionArguments The parameter for action type. such as:
|
||||
* action: ACCESSIBILITY_ACTION_NEXT_HTML_ITEM,
|
||||
* actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
|
||||
* action: ACCESSIBILITY_ACTION_PREVIOUS_HTML_ITEM,
|
||||
* actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
|
||||
* action: ACCESSIBILITY_ACTION_NEXT_TEXT,
|
||||
* actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
|
||||
* action: ACCESSIBILITY_ACTION_PREVIOUS_TEXT,
|
||||
* actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
|
||||
* action: ACCESSIBILITY_ACTION_SET_SELECTION,
|
||||
* actionArguments({ACTION_ARGU_SELECT_TEXT_START,"1"(start location)},
|
||||
* {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
|
||||
* action: ACCESSIBILITY_ACTION_SET_TEXT,
|
||||
* actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
|
||||
* @return
|
||||
*/
|
||||
virtual void PerformAction(const long elementId, const int action,
|
||||
const std::map<std::string, std::string> actionArguments,
|
||||
int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback) override;
|
||||
|
||||
/**
|
||||
* @brief The function is called while accessibility System check the id of window is not equal
|
||||
* to the id of active window when sendAccessibility.
|
||||
* @param -
|
||||
* @return
|
||||
*/
|
||||
|
||||
virtual void ClearFocus() override;
|
||||
|
||||
/**
|
||||
* @brief the low layser is notified by the function called while accessibility system execute
|
||||
* the function of performAction from AS to check the all low windows cared the outside event.
|
||||
* Example: PopupWindow receive the OUTSIDE_EVENT to close itself.
|
||||
* @param -
|
||||
* @return
|
||||
*/
|
||||
virtual void OutsideTouch() override;
|
||||
|
||||
/**
|
||||
* @brief Save the window id related with operator object
|
||||
* @param windowId: The unique id of the window related with operator object.
|
||||
* @return -
|
||||
*/
|
||||
void SetWindowId(int windowId);
|
||||
|
||||
/**
|
||||
* @brief Get the window id related with operator object
|
||||
* @param windowId: The unique id of the window related with operator object.
|
||||
* @return -
|
||||
*/
|
||||
int GetWindowId();
|
||||
|
||||
/**
|
||||
* Implement the function to set the result to AA when ACE complete the request.
|
||||
*/
|
||||
class CallbackImpl : public AccessibilityInteractionOperationCallback {
|
||||
public:
|
||||
enum CALL_API_NUM : uint32_t {
|
||||
CALLBACK_BY_ACCESSIBILITY_ID = 0x00000001,
|
||||
CALLBACK_BY_TEXT = 0x00000002,
|
||||
CALLBACK_FIND_FOCUS = 0x00000004,
|
||||
CALLBACK_BY_FOCUS_MOVE = 0x00000008,
|
||||
CALLBACK_PERFORM_ACTION = 0x00000010,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief construct function
|
||||
* @param object The object of IPC
|
||||
* @return
|
||||
*/
|
||||
CallbackImpl();
|
||||
|
||||
/**
|
||||
* @brief construct function
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @param callNum The id is matched handle function of IPC.
|
||||
* @return
|
||||
*/
|
||||
CallbackImpl(const int requestId, CALL_API_NUM callNum);
|
||||
|
||||
/**
|
||||
* @brief Set the element information by accessibility id to AA.
|
||||
* @param infos The element info searched by accessibility id.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetSearchElementInfoByAccessibilityIdResult(const std::list<AccessibilityElementInfo> &infos,
|
||||
const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Set the element informations matched with text to AA.
|
||||
* @param infos The element informations searched matched with text.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetSearchElementInfoByTextResult(const std::list<AccessibilityElementInfo> &infos,
|
||||
const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Set the element informations matched with focus type to AA.
|
||||
* @param info The element informations searched matched with focus type.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetFindFocusedElementInfoResult(const AccessibilityElementInfo &info,
|
||||
const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Set the element informations by focus direction to AA.
|
||||
* @param info The element informations searched by focus direction.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetFocusMoveSearchResult(const AccessibilityElementInfo &info, const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Set the result of action executed to AA.
|
||||
* @param succeeded True: The action is executed successfully; otherwise is false.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetPerformActionResult(const bool succeeded, const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Get the callback object of AA.
|
||||
* @param
|
||||
* @return The callback object of AA and the request id matched.
|
||||
*/
|
||||
std::map<const int, const sptr<IAccessibilityInteractionOperationCallback>> GetAACallbackList();
|
||||
|
||||
/**
|
||||
* @brief Remove the callback object of AA after send the result to AA.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
void RemoveAACallbackList(int requestId);
|
||||
private:
|
||||
int requestId_ = 0;
|
||||
CALL_API_NUM callNum_ = CALLBACK_BY_ACCESSIBILITY_ID;
|
||||
};
|
||||
private:
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:SetSearchElementInfoByAccessibilityIdResult.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleSearchElementInfoByAccessibilityId(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:SetSearchElementInfoByTextResult.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleSearchElementInfosByText(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:SetFindFocusedElementInfoResult.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleFindFocusedElementInfo(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:SetFocusMoveSearchResult.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleFocusFind(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:SetPerformActionResult.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandlePerformAction(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:ClearFocus.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleClearFocus(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:OutsideTouch.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleOutsideTouch(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using AccessibilityInteractionOperationFunc = ErrCode (AccessibilityInteractionOperationStub::*)
|
||||
(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, AccessibilityInteractionOperationFunc> memberFuncMap_ {};
|
||||
static std::map<const int, const sptr<IAccessibilityInteractionOperationCallback>> aaCallbacks_;
|
||||
int windowId_ = 0;
|
||||
DISALLOW_COPY_AND_MOVE(AccessibilityInteractionOperationStub);
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif
|
372
frameworks/asacfwk/include/accessibility_operator.h
Normal file
372
frameworks/asacfwk/include/accessibility_operator.h
Normal file
@ -0,0 +1,372 @@
|
||||
/*
|
||||
* 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_INTERACTION_CLIENT_H
|
||||
#define ACCESSIBILITY_INTERACTION_CLIENT_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "accessible_ability_channel_interface.h"
|
||||
#include "accessible_ability_channel_proxy.h"
|
||||
#include "accessibility_element_info.h"
|
||||
#include "accessibility_window_info.h"
|
||||
#include "accessibility_interaction_operation_callback_interface.h"
|
||||
#include "accessibility_interaction_operation_callback_stub.h"
|
||||
#include "gesture_simulation.h"
|
||||
#include "refbase.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
/*
|
||||
* The class supply the api called by AA to get the accessibility info of UI.
|
||||
* It call the API of AAMS and the request will be proccessed by
|
||||
* UI and then set the result by callback(AA-->this class(with Callback)--> AAMS
|
||||
* --> UI process and set Callback).
|
||||
* It supply one instance for each thread to use this class.
|
||||
*/
|
||||
class AccessibilityOperator : public AccessibilityInteractionOperationCallbackStub{
|
||||
public:
|
||||
static const int NONE_ID = -1;
|
||||
static const int MAX_INSTANCE = 10;
|
||||
/**
|
||||
* @brief construct function
|
||||
* @param object The object of IPC
|
||||
* @return
|
||||
*/
|
||||
AccessibilityOperator();
|
||||
|
||||
/**
|
||||
* @brief Get the instance of AccessibilityOperator
|
||||
* @param
|
||||
* @return The instance of AccessibilityOperator
|
||||
*/
|
||||
static AccessibilityOperator &GetInstance();
|
||||
|
||||
/**
|
||||
* @brief Inner function: Get the instance of AccessibilityOperator for each thread.
|
||||
* The max instance is MAX_INSTANCE.
|
||||
* @param threadId The thread id that request to get instance.
|
||||
* @return The instance of AccessibilityOperator
|
||||
*/
|
||||
static AccessibilityOperator &GetInstanceForThread(std::thread::id threadId);
|
||||
|
||||
/**
|
||||
* @brief Inner function: Get the object connected from AA to AAMS by channel id.
|
||||
* @param channelId The id matched the object connected from AA to AAMS
|
||||
* @return The object connected from AA to AAMS.
|
||||
*/
|
||||
static sptr<IAccessibleAbilityChannel> GetChannel(int channelId);
|
||||
|
||||
/**
|
||||
* @brief Set the object connected from AA to AAMS and channel id matched.
|
||||
* @param channelId The id matched the object connected from AA to AAMS
|
||||
* @param channel The object connected from AA to AAMS.
|
||||
* @return
|
||||
*/
|
||||
static void AddChannel(const int channelId, const sptr<IAccessibleAbilityChannel> &channel);
|
||||
|
||||
/**
|
||||
* @brief Remove the object connected from AA to AAMS by channel id.
|
||||
* @param channelId The id matched the object connected from AA to AAMS
|
||||
* @return
|
||||
*/
|
||||
static void RemoveChannel(int channelId);
|
||||
|
||||
/**
|
||||
* @brief Get the root component information
|
||||
* @param channelId The id matched the object connected from AA to AAMS
|
||||
* @param elementInfo[out] The root component information
|
||||
* @return
|
||||
*/
|
||||
bool GetRoot(int channelId, AccessibilityElementInfo &elementInfo);
|
||||
|
||||
/**
|
||||
* @brief Get all windows of accessibility.
|
||||
* @param channelId The id matched the object connected from AA to AAMS
|
||||
* @return All windows information of accessibility.
|
||||
*/
|
||||
std::vector<AccessibilityWindowInfo> GetWindows(int channelId);
|
||||
|
||||
/**
|
||||
* @brief Find the node information by accessibility ID.
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param accessibilityWindowId The window id that the component belongs to.
|
||||
* @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also.
|
||||
* PREFETCH_SIBLINGS: Need to make the sister/brothers node info also.
|
||||
* PREFETCH_CHILDREN: Need to make the child node info also.
|
||||
* otherwise: Make the node information by elementId only.
|
||||
* @param elementInfos[out] The components information matched conditions searched.
|
||||
* @return -
|
||||
*/
|
||||
bool SearchElementInfosByAccessibilityId(int channelId,
|
||||
int accessibilityWindowId, int elementId,
|
||||
int mode, std::vector<AccessibilityElementInfo> &elementInfos);
|
||||
|
||||
/**
|
||||
* @brief Find the node information filtered by text.
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param accessibilityWindowId The window id that the component belongs to.
|
||||
* @param text The filter text.
|
||||
* @param elementInfos[out] The components information matched conditions searched.
|
||||
* @return -
|
||||
*/
|
||||
bool SearchElementInfosByText(int channelId, int accessibilityWindowId, int elementId,
|
||||
const std::string &text, std::vector<AccessibilityElementInfo>& elementInfos);
|
||||
|
||||
/**
|
||||
* @brief Find the focus node information.
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param accessibilityWindowId The window id that the component belongs to.
|
||||
* @param focusType The type of focus.
|
||||
* FOCUS_TYPE_ACCESSIBILITY: accessibility focus
|
||||
* FOCUS_TYPE_INPUT: text input focus
|
||||
* @param elementInfos[out] The components information matched conditions searched.
|
||||
* @return -
|
||||
*/
|
||||
bool FindFocusedElementInfo(int channelId, int accessibilityWindowId,
|
||||
int elementId, int focusType, AccessibilityElementInfo &elementInfo);
|
||||
|
||||
/**
|
||||
* @brief Find the node information by focus move direction.
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param accessibilityWindowId The window id that the component belongs to.
|
||||
* @param direction The direction of focus move direction.
|
||||
* Refer to FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD).
|
||||
* @param elementInfos[out] The components information matched conditions searched.
|
||||
* @return -
|
||||
*/
|
||||
bool FocusMoveSearch(int channelId, int accessibilityWindowId,
|
||||
int elementId, int direction, AccessibilityElementInfo &elementInfo);
|
||||
|
||||
/**
|
||||
* @brief Perform the action on the component.
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param accessibilityWindowId The window id that the component belongs to.
|
||||
* @param action The action triggered on component.
|
||||
* Refer to [AccessibilityElementInfo.ActionType]
|
||||
* @param actionArguments The parameter for action type. such as:
|
||||
* action: ACCESSIBILITY_ACTION_NEXT_HTML_ITEM,
|
||||
* actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
|
||||
* action: ACCESSIBILITY_ACTION_PREVIOUS_HTML_ITEM,
|
||||
* actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
|
||||
* action: ACCESSIBILITY_ACTION_NEXT_TEXT,
|
||||
* actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
|
||||
* action: ACCESSIBILITY_ACTION_PREVIOUS_TEXT,
|
||||
* actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
|
||||
* action: ACCESSIBILITY_ACTION_SET_SELECTION,
|
||||
* actionArguments({ACTION_ARGU_SELECT_TEXT_START,"1"(start location)},
|
||||
* {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
|
||||
* action: ACCESSIBILITY_ACTION_SET_TEXT,
|
||||
* actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
|
||||
* @return true: Perform action successfully; otherwise is not.
|
||||
*/
|
||||
bool PerformAction(int channelId, int accessibilityWindowId,
|
||||
int elementId, int action, std::map<std::string, std::string> &actionArguments);
|
||||
|
||||
/**
|
||||
* @brief Save the elements information searched in ACE side
|
||||
* @param infos The elements info searched by accessibility id.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
void SetSearchElementInfoByAccessibilityIdResult(const std::vector<AccessibilityElementInfo> &infos,
|
||||
const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Save the elements information searched in ACE side
|
||||
* @param infos The elements info searched by accessibility id.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
void SetSearchElementInfoByTextResult(const std::vector<AccessibilityElementInfo> &infos,
|
||||
const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Save the element information searched in ACE side
|
||||
* @param infos The element info searched by accessibility id.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
void SetFindFocusedElementInfoResult(const AccessibilityElementInfo &info, const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Save the element information searched in ACE side
|
||||
* @param infos The element info searched by accessibility id.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
void SetFocusMoveSearchResult(const AccessibilityElementInfo &info, const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Save the result of action executed in ACE.
|
||||
* @param succeeded True: The action is executed successfully; otherwise is false.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
void SetPerformActionResult(const bool succeeded, const int requestId) override;
|
||||
|
||||
/**
|
||||
* @brief Wrap the function of function expect for ACE related
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param action: The common action
|
||||
* @return true: Perform successfully; otherwise is not.
|
||||
*/
|
||||
bool PerformCommonAction(const int channelId, const int action);
|
||||
|
||||
/**
|
||||
* @brief Wrap the function of function expect for ACE related
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @return -
|
||||
*/
|
||||
void DisableAbility(const int channelId);
|
||||
|
||||
/**
|
||||
* @brief Wrap the function of function expect for ACE related
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param handled True: That is handled; otherwise is not.
|
||||
* @param sequence The number of sequence.
|
||||
* @return -
|
||||
*/
|
||||
void SetOnKeyPressEventResult(const int channelId, const bool handled, const int sequence);
|
||||
|
||||
/**
|
||||
* @brief Wrap the function of function expect for ACE related
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param displayId The display id
|
||||
* @return -
|
||||
*/
|
||||
float GetDisplayResizeScale(const int channelId, const int displayId);
|
||||
|
||||
/**
|
||||
* @brief Wrap the function of function expect for ACE related
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param displayId The display id
|
||||
* @return -
|
||||
*/
|
||||
float GetDisplayResizeCenterX(const int channelId, const int displayId);
|
||||
|
||||
/**
|
||||
* @brief Wrap the function of function expect for ACE related
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param displayId The display id
|
||||
* @return -
|
||||
*/
|
||||
float GetDisplayResizeCenterY(const int channelId, const int displayId);
|
||||
|
||||
/**
|
||||
* @brief Wrap the function of function expect for ACE related
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param displayId The display id
|
||||
* @return The range displayed.
|
||||
*/
|
||||
Rect GetDisplayResizeRect(const int channelId, const int displayId);
|
||||
|
||||
/**
|
||||
* @brief Wrap the function of function expect for ACE related
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param displayId The display id
|
||||
* @param animate true: It is animation; otherwise is not.
|
||||
* @return true: Reset successfully; otherwise is not.
|
||||
*/
|
||||
bool ResetDisplayResize(const int channelId, const int displayId, const bool animate);
|
||||
|
||||
/**
|
||||
* @brief Wrap the function of function expect for ACE related
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param displayId The display id
|
||||
* @param scale The value of scaled.
|
||||
* @param animate true: It is animation; otherwise is not.
|
||||
* @param centerX coordinate X.
|
||||
* @param centerY coordinate Y.
|
||||
* @return true: Resize successfully; otherwise is not.
|
||||
*/
|
||||
bool SetDisplayResizeScaleAndCenter(const int channelId, const int displayId, const float scale,
|
||||
const float centerX, const float centerY, const bool animate);
|
||||
|
||||
/**
|
||||
* @brief Wrap the function of function expect for ACE related
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @param sequence The number of sequence.
|
||||
* @param gestureSteps The value of gesture.
|
||||
* @return -
|
||||
*/
|
||||
void SendSimulateGesture(const int channelId, const int sequence,
|
||||
const std::vector<GesturePathDefine> &gestureSteps);
|
||||
|
||||
/**
|
||||
* @brief Wrap the function of function expect for ACE related
|
||||
* @param channelId The id matched the object connected from AA to AAMS.
|
||||
* @return true: It is valid fingerprint; otherwise is not.
|
||||
*/
|
||||
bool IsFingerprintGestureDetectionValid(const int channelId);
|
||||
|
||||
/**
|
||||
* @brief Inner function: The status requested from AA to ACE.
|
||||
* @param
|
||||
* @return true: The requestion is completed; otherwise is not.
|
||||
*/
|
||||
bool GetOperationStatus();
|
||||
|
||||
/**
|
||||
* @brief Inner function: Set the status requested from AA to ACE.
|
||||
* @param status true: The requestion is completed; otherwise is not.
|
||||
* @return -
|
||||
*/
|
||||
void SetOperationStatus(bool status);
|
||||
private:
|
||||
/**
|
||||
* @brief Inner function: Set the timer related with the requestion from AA to ACE.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return -
|
||||
*/
|
||||
bool WaitForResultTimedLocked(int requestId);
|
||||
|
||||
/**
|
||||
* @brief Inner function: Count the unique id requested
|
||||
* @param
|
||||
* @return The request id from AA, it is used to match with request and response.
|
||||
*/
|
||||
int CreateRequestId();
|
||||
static const long TIMEOUT_OPERATOR_MILLIS = 500000;
|
||||
static const long SLEEP_MILLIS = 5000;
|
||||
static const uint32_t SECOND_TO_MILLIS = 1000000;
|
||||
static const uint32_t MAX_REQUEST = 0x7FFFFFFF;
|
||||
static std::vector<sptr<AccessibilityOperator>> instances_;
|
||||
static std::map<int, sptr<IAccessibleAbilityChannel>> channels_;
|
||||
int responseId_ = 0;
|
||||
|
||||
static int requestId_; //matched request with callback result
|
||||
AccessibilityElementInfo accessibilityInfoResult_{};
|
||||
std::vector<AccessibilityElementInfo> accessibilityInfosResult_{};
|
||||
std::vector<AccessibilityWindowInfo> windows_{};
|
||||
bool performActionResult_ = false;
|
||||
static std::recursive_mutex mutex_;
|
||||
bool completed_ = false;
|
||||
|
||||
};
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
||||
#endif
|
@ -0,0 +1,224 @@
|
||||
/*
|
||||
* 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 ACCESSIBLE_ABILITY_CHANNEL_INTERFACE_H
|
||||
#define ACCESSIBLE_ABILITY_CHANNEL_INTERFACE_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "accessibility_interaction_operation_callback_interface.h"
|
||||
#include "accessibility_element_info.h"
|
||||
#include "accessibility_window_info.h"
|
||||
#include "gesture_simulation.h"
|
||||
#include "iremote_broker.h"
|
||||
#include "refbase.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
class IAccessibleAbilityChannel : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accessibility.IAccessibleAbilityChannel");
|
||||
|
||||
/**
|
||||
* @brief Searchs elementInfo by accessibility id and set the result by callback.
|
||||
* @param accessibilityWindowId The id of accessibility window.
|
||||
* @param elementId The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the element info to ASAC.
|
||||
* @param mode PREFETCH_PREDECESSORS: Need to make the parent element info also.
|
||||
* PREFETCH_SIBLINGS: Need to make the sister/brothers element info also.
|
||||
* PREFETCH_CHILDREN: Need to make the child element info also.
|
||||
* otherwise: Make the element information by elementId only.
|
||||
* @return Return true if search elementInfo successfully, else return false.
|
||||
*/
|
||||
virtual bool SearchElementInfoByAccessibilityId(const int accessibilityWindowId,
|
||||
const long elementId, const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback,
|
||||
const int mode) = 0;
|
||||
|
||||
/**
|
||||
* @brief Make the child element information by accessibility ID and filtered by text and
|
||||
* set the result by callback.
|
||||
* @param accessibilityWindowId The id of accessibility window.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param text Filter for the child components to matched with the text
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the element info to ASAC and it defined by ASAC.
|
||||
* @return Return true if search elementInfo successfully, else return false.
|
||||
*/
|
||||
virtual bool SearchElementInfosByText(const int accessibilityWindowId, const long elementId,
|
||||
const std::string &text, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief Make the element information of the component focused by the focus type specified.
|
||||
* @param accessibilityWindowId The id of accessibility window.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus
|
||||
* FOCUS_TYPE_INPUT: text input focus
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the element info to ASAC and it defined by ASAC.
|
||||
* @return Return true if find elementInfo successfully, else return false.
|
||||
*/
|
||||
virtual bool FindFocusedElementInfo(const int accessibilityWindowId, const long elementId,
|
||||
const int focusType, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief Make the element info by current focus move direction.
|
||||
* @param accessibilityWindowId The id of accessibility window.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the element info to ASAC and it defined by ASAC.
|
||||
* @return Return true if search elementInfo successfully, else return false.
|
||||
*/
|
||||
virtual bool FocusMoveSearch(const int accessibilityWindowId, const long elementId,
|
||||
const int direction, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief To perform action.
|
||||
* @param accessibilityWindowId The id of accessibility window.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param action Refer to [AccessibilityElementInfo.ActionType]
|
||||
* @param actionArguments The parameter for action type.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @return Return true if perform action successfully, else return false.
|
||||
*/
|
||||
virtual bool PerformAction(const int accessibilityWindowId, const long elementId, const int action,
|
||||
std::map<std::string, std::string> &actionArguments, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
|
||||
* @param
|
||||
* @return The infomation of windows.
|
||||
*/
|
||||
virtual std::vector<AccessibilityWindowInfo> GetWindows() = 0;
|
||||
|
||||
/**
|
||||
* @brief Executes a specified action.
|
||||
* @param action The action of OHOS::Accessibility::GlobalAction.
|
||||
* @return Return true if performs action successfully, else return false.
|
||||
*/
|
||||
virtual bool PerformCommonAction(const int action) = 0;
|
||||
|
||||
/**
|
||||
* @brief Disable the accessible ability.
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void DisableAbility() = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the result of key press event.
|
||||
* @param handled The result of key press event, true if the event has been consumed, otherwise false.
|
||||
* @param sequence The sequence of key press event result.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetOnKeyPressEventResult(const bool handled, const int sequence) = 0;
|
||||
|
||||
/**
|
||||
* @brief Obtains the resizing scale of this display resizing rectangle.
|
||||
* @param displayId The id of display.
|
||||
* @return Returns the resizing scale.
|
||||
*/
|
||||
virtual float GetDisplayResizeScale(const int displayId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Obtains the X coordinate of the center in this display resizing rectangle.
|
||||
* @param displayId The id of display.
|
||||
* @return Returns the X coordinate of the center.
|
||||
*/
|
||||
virtual float GetDisplayResizeCenterX(const int displayId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Obtains the Y coordinate of the center in this display resizing rectangle.
|
||||
* @param displayId The id of display.
|
||||
* @return Returns the Y coordinate of the center.
|
||||
*/
|
||||
virtual float GetDisplayResizeCenterY(const int displayId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Obtains the display resizing rectangle.
|
||||
* @param displayId The id of display.
|
||||
* @return Returns the display resizing rectangle.
|
||||
*/
|
||||
virtual Rect GetDisplayResizeRect(const int displayId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Resets the display to its initial size.
|
||||
* @param displayId The id of display.
|
||||
* @param animate Specifies whether animation is required.
|
||||
* @return Returns true if the display is successfully reset; returns false otherwise.
|
||||
*/
|
||||
virtual bool ResetDisplayResize(const int displayId, const bool animate) = 0;
|
||||
|
||||
/**
|
||||
* @brief Sets the center coordinates and scale for the display resizing rectangle.
|
||||
* @param displayId The id of display.
|
||||
* @param scale Indicates the scale for resizing the display
|
||||
* @param centerX Indicates the X coordinate of the center for resizing the display.
|
||||
* @param centerY Indicates the Y coordinate of the center for resizing the display.
|
||||
* @param animate Specifies whether animation is required.
|
||||
* @return Returns true if the center coordinates and scale are successfully set; returns false otherwise.
|
||||
*/
|
||||
virtual bool SetDisplayResizeScaleAndCenter(const int displayId, const float scale, const float centerX,
|
||||
const float centerY, const bool animate) = 0;
|
||||
|
||||
/**
|
||||
* @brief Send simulation gesture.
|
||||
* @param sequence The sequence of simulation gesture.
|
||||
* @param gestureSteps The gesture to send.
|
||||
* @return
|
||||
*/
|
||||
virtual void SendSimulateGesture(const int sequence, const std::vector<GesturePathDefine> &gestureSteps) = 0;
|
||||
|
||||
/**
|
||||
* @brief Judge whether the gesture detection function of the fingerprint sensor is available.
|
||||
* @param
|
||||
* @return Return true if the fingerprint sensor is available, else return false.
|
||||
*/
|
||||
virtual bool IsFingerprintGestureDetectionValid() = 0;
|
||||
|
||||
enum class Message {
|
||||
SEARCH_ELEMENTINFO_BY_ACCESSIBILITYID = 0,
|
||||
SEARCH_ELEMENTINFOS_BY_TEXT,
|
||||
FIND_FOCUSED_ELEMENTINFO,
|
||||
FOCUS_MOVE_SEARCH,
|
||||
PERFORM_ACTION,
|
||||
GET_WINDOWS,
|
||||
PERFORM_COMMON_ACTION,
|
||||
DISABLE_ABILITY,
|
||||
SET_ON_KEY_PRESS_EVENT_RESULT,
|
||||
GET_DISPALYRESIZE_SCALE,
|
||||
GET_DISPALYRESIZE_CETER_X,
|
||||
GET_DISPLAYRESIZE_CETER_Y,
|
||||
GET_DISPLAYRESIZE_RECT,
|
||||
RESET_DISPALYRESIZE,
|
||||
SET_DISPLAYRESIZE_SCALE_AND_CENTER,
|
||||
SEND_SIMULATE_GESTURE,
|
||||
IS_FINGERPRINT_GESTURE_DETECTION_VALID,
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif // ACCESSIBLE_ABILITY_CHANNEL_INTERFACE_H
|
235
frameworks/asacfwk/include/accessible_ability_channel_proxy.h
Normal file
235
frameworks/asacfwk/include/accessible_ability_channel_proxy.h
Normal file
@ -0,0 +1,235 @@
|
||||
/*
|
||||
* 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 ACCESSIBLE_ABILITY_CHANNEL_PROXY_H
|
||||
#define ACCESSIBLE_ABILITY_CHANNEL_PROXY_H
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include "accessible_ability_channel_interface.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "iremote_proxy.h"
|
||||
#include "message_parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
class AccessibleAbilityChannelProxy : public IRemoteProxy<IAccessibleAbilityChannel> {
|
||||
public:
|
||||
/**
|
||||
* @brief construct function
|
||||
* @param object The object of IPC
|
||||
* @return
|
||||
*/
|
||||
explicit AccessibleAbilityChannelProxy(const sptr<IRemoteObject> &object);
|
||||
|
||||
/**
|
||||
* @brief destruct function
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual ~AccessibleAbilityChannelProxy() = default;
|
||||
|
||||
/**
|
||||
* @brief Searchs elementInfo by accessibility id and set the result by callback through the proxy object.
|
||||
* @param accessibilityWindowId The id of accessibility window.
|
||||
* @param elementId The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the element info to ASAC.
|
||||
* @param mode PREFETCH_PREDECESSORS: Need to make the parent element info also.
|
||||
* PREFETCH_SIBLINGS: Need to make the sister/brothers element info also.
|
||||
* PREFETCH_CHILDREN: Need to make the child element info also.
|
||||
* otherwise: Make the element information by elementId only.
|
||||
* @return Return true if search elementInfo successfully, else return false.
|
||||
*/
|
||||
virtual bool SearchElementInfoByAccessibilityId(const int accessibilityWindowId,
|
||||
const long elementId, const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback,
|
||||
const int mode) override;
|
||||
|
||||
/**
|
||||
* @brief Make the child element information by accessibility ID and filtered by text and
|
||||
* set the result by callback through the proxy object.
|
||||
* @param accessibilityWindowId The id of accessibility window.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param text Filter for the child components to matched with the text
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the element info to ASAC and it defined by ASAC.
|
||||
* @return Return true if search elementInfo successfully, else return false.
|
||||
*/
|
||||
virtual bool SearchElementInfosByText(const int accessibilityWindowId, const long elementId,
|
||||
const std::string &text, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) override;
|
||||
|
||||
/**
|
||||
* @brief Make the element information of the component focused
|
||||
* by the focus type specified through the proxy object.
|
||||
* @param accessibilityWindowId The id of accessibility window.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus
|
||||
* FOCUS_TYPE_INPUT: text input focus
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the element info to ASAC and it defined by ASAC.
|
||||
* @return Return true if find elementInfo successfully, else return false.
|
||||
*/
|
||||
virtual bool FindFocusedElementInfo(const int accessibilityWindowId, const long elementId,
|
||||
const int focusType, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) override;
|
||||
|
||||
/**
|
||||
* @brief Make the element info by current focus move direction through the proxy object.
|
||||
* @param accessibilityWindowId The id of accessibility window.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the element info to ASAC and it defined by ASAC.
|
||||
* @return Return true if search elementInfo successfully, else return false.
|
||||
*/
|
||||
virtual bool FocusMoveSearch(const int accessibilityWindowId, const long elementId,
|
||||
const int direction, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) override;
|
||||
|
||||
/**
|
||||
* @brief To perform action through the proxy object.
|
||||
* @param accessibilityWindowId The id of accessibility window.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param action Refer to [AccessibilityElementInfo.ActionType]
|
||||
* @param actionArguments The parameter for action type.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @return Return true if perform action successfully, else return false.
|
||||
*/
|
||||
virtual bool PerformAction(const int accessibilityWindowId, const long elementId, const int action,
|
||||
std::map<std::string, std::string> &actionArguments, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the list of interactive windows on the device,
|
||||
* in the layers they are visible to users through the proxy object.
|
||||
* @param
|
||||
* @return The infomation of windows.
|
||||
*/
|
||||
virtual std::vector<AccessibilityWindowInfo> GetWindows() override;
|
||||
|
||||
/**
|
||||
* @brief Executes a specified action through the proxy object.
|
||||
* @param action The action of OHOS::Accessibility::GlobalAction.
|
||||
* @return Return true if performs action successfully, else return false.
|
||||
*/
|
||||
virtual bool PerformCommonAction(const int action) override;
|
||||
|
||||
/**
|
||||
* @brief Disable the accessible ability through the proxy object.
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void DisableAbility() override;
|
||||
|
||||
/**
|
||||
* @brief Set the result of key press event through the proxy object.
|
||||
* @param handled The result of key press event, true if the event has been consumed, otherwise false.
|
||||
* @param sequence The sequence of key press event result.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetOnKeyPressEventResult(const bool handled, const int sequence) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the resizing scale of this display resizing rectangle through the proxy object.
|
||||
* @param displayId The id of display.
|
||||
* @return Returns the resizing scale.
|
||||
*/
|
||||
virtual float GetDisplayResizeScale(const int displayId) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the X coordinate of the center in this display resizing rectangle through the proxy object.
|
||||
* @param displayId The id of display.
|
||||
* @return Returns the X coordinate of the center.
|
||||
*/
|
||||
virtual float GetDisplayResizeCenterX(const int displayId) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the Y coordinate of the center in this display resizing rectangle through the proxy object.
|
||||
* @param displayId The id of display.
|
||||
* @return Returns the Y coordinate of the center.
|
||||
*/
|
||||
virtual float GetDisplayResizeCenterY(const int displayId) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the display resizing rectangle through the proxy object.
|
||||
* @param displayId The id of display.
|
||||
* @return Returns the display resizing rectangle.
|
||||
*/
|
||||
virtual Rect GetDisplayResizeRect(const int displayId) override;
|
||||
|
||||
/**
|
||||
* @brief Resets the display to its initial size through the proxy object.
|
||||
* @param displayId The id of display.
|
||||
* @param animate Specifies whether animation is required.
|
||||
* @return Returns true if the display is successfully reset; returns false otherwise.
|
||||
*/
|
||||
virtual bool ResetDisplayResize(const int displayId, const bool animate) override;
|
||||
|
||||
/**
|
||||
* @brief Sets the center coordinates and scale for the display resizing rectangle through the proxy object.
|
||||
* @param displayId The id of display.
|
||||
* @param scale Indicates the scale for resizing the display
|
||||
* @param centerX Indicates the X coordinate of the center for resizing the display.
|
||||
* @param centerY Indicates the Y coordinate of the center for resizing the display.
|
||||
* @param animate Specifies whether animation is required.
|
||||
* @return Returns true if the center coordinates and scale are successfully set; returns false otherwise.
|
||||
*/
|
||||
virtual bool SetDisplayResizeScaleAndCenter(const int displayId, const float scale, const float centerX,
|
||||
const float centerY, const bool animate) override;
|
||||
|
||||
/**
|
||||
* @brief Send simulation gesture through the proxy object.
|
||||
* @param sequence The sequence of simulation gesture.
|
||||
* @param gestureSteps The gesture to send.
|
||||
* @return
|
||||
*/
|
||||
virtual void SendSimulateGesture(const int sequence, const std::vector<GesturePathDefine> &gestureSteps) override;
|
||||
|
||||
/**
|
||||
* @brief Judge whether the gesture detection function of the fingerprint sensor is available
|
||||
* through the proxy object.
|
||||
* @param
|
||||
* @return Return true if the fingerprint sensor is available, else return false.
|
||||
*/
|
||||
virtual bool IsFingerprintGestureDetectionValid() override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Write the descriptor of IPC.
|
||||
* @param data It is include the descriptor of IPC.
|
||||
* @return true: Write the descriptor successfully; otherwise is not.
|
||||
*/
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
/**
|
||||
* @brief Send the command data from proxy to stub in IPC mechanism.
|
||||
* @param code The code matched the function called.
|
||||
* @param data Serializable data
|
||||
* @param reply The response of IPC
|
||||
* @param option The option paramter of IPC,such as: async,sync
|
||||
* @return true: Write the descriptor successfully; otherwise is not.
|
||||
*/
|
||||
bool SendTransactCmd(IAccessibleAbilityChannel::Message code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option);
|
||||
static inline BrokerDelegator<AccessibleAbilityChannelProxy> delegator;
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ACCESSIBLE_ABILITY_CHANNEL_PROXY_H
|
205
frameworks/asacfwk/include/accessible_ability_channel_stub.h
Normal file
205
frameworks/asacfwk/include/accessible_ability_channel_stub.h
Normal file
@ -0,0 +1,205 @@
|
||||
/*
|
||||
* 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 ACCESSIBLE_ABILITY_CHANNEL_STUB_H
|
||||
#define ACCESSIBLE_ABILITY_CHANNEL_STUB_H
|
||||
|
||||
#include <map>
|
||||
#include <stdint.h>
|
||||
#include "accessible_ability_channel_interface.h"
|
||||
#include "accessibility_errorcode.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "nocopyable.h"
|
||||
#include "message_parcel.h"
|
||||
#include "message_option.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
class AccessibleAbilityChannelStub : public IRemoteStub<IAccessibleAbilityChannel> {
|
||||
public:
|
||||
/**
|
||||
* @brief construct function
|
||||
* @param object The object of IPC
|
||||
* @return
|
||||
*/
|
||||
AccessibleAbilityChannelStub();
|
||||
|
||||
/**
|
||||
* @brief destruct function
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual ~AccessibleAbilityChannelStub();
|
||||
|
||||
/**
|
||||
* @brief Receive the event from proxy by IPC mechanism.
|
||||
* @param code The code is matched with the process function.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @param option The option paramter of IPC,such as: async,sync
|
||||
* @return
|
||||
*/
|
||||
virtual int OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option) override;
|
||||
private:
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleSearchElementInfoByAccessibilityId.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleSearchElementInfoByAccessibilityId(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleSearchElementInfosByText.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleSearchElementInfosByText(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleFindFocusedElementInfo.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleFindFocusedElementInfo(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleFocusMoveSearch.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleFocusMoveSearch(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandlePerformAction.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandlePerformAction(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleGetWindows.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleGetWindows(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandlePerformCommonAction.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandlePerformCommonAction(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleDisableAbility.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleDisableAbility(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleSetOnKeyPressEventResult.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleSetOnKeyPressEventResult(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleGetDisplayResizeScale.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleGetDisplayResizeScale(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleGetDisplayResizeCenterX.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleGetDisplayResizeCenterX(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleGetDisplayResizeCenterY.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleGetDisplayResizeCenterY(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleGetDisplayResizeRect.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleGetDisplayResizeRect(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleResetDisplayResize.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleResetDisplayResize(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleSetDisplayResizeScaleAndCenter.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleSetDisplayResizeScaleAndCenter(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleSendSimulateGesture.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleSendSimulateGesture(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleIsFingerprintGestureDetectionValid.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleIsFingerprintGestureDetectionValid(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
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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_ABILITY_MANAGER_SERVICE_CLIENT_INTERFACE_H
|
||||
#define ACCESSIBILITY_ABILITY_MANAGER_SERVICE_CLIENT_INTERFACE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include "accessibility_ability_info.h"
|
||||
#include "accessible_ability_manager_service_state_interface.h"
|
||||
#include "accessibility_event_info.h"
|
||||
#include "accessibility_interaction_operation_interface.h"
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
/*
|
||||
* The class define the interface to call ABMS API.
|
||||
*/
|
||||
class IAccessibleAbilityManagerServiceClient : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accessibility.IAccessibleAbilityManagerServiceClient");
|
||||
|
||||
/**
|
||||
* @brief Sends information about an accessibility event.
|
||||
* @param uiEvent Indicates the accessibility event information specified by AccessibilityEventInfo.
|
||||
* @param accountId The user id.
|
||||
* @return true: send ok; otherwise is refused.
|
||||
*/
|
||||
virtual void SendEvent(const AccessibilityEventInfo &uiEvent, const int accountId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Register the state observer of AAMS.
|
||||
* @param callback state observer
|
||||
* @param accountId The user id.
|
||||
* @return 0: Register ok; otherwise is refused.
|
||||
*/
|
||||
virtual uint32_t RegisterStateCallback(const sptr<IAccessibleAbilityManagerServiceState> &callback,
|
||||
const int accountId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Queries the list of accessibility abilities.
|
||||
* @param accessibilityAbilityTypes Indicates the accessibility type specified by
|
||||
* AccessibilityAbilityInfo#ACCESSIBILITY_ABILITY_TYPE_SPOKEN.
|
||||
* @param stateType Indicates the accessibility ability status. 1 indicates that the ability is enabled;
|
||||
* 2 indicates that the ability is disabled; 4 indicates that the ability has been installed.
|
||||
* @return
|
||||
*/
|
||||
virtual std::vector<AccessibilityAbilityInfo> GetAbilityList(const int abilityTypes, const int stateType) = 0;
|
||||
|
||||
/**
|
||||
* @brief Register the interaction operation, so the AA can get node info from ACE.
|
||||
* @param windowId Window ID
|
||||
* @param operation The callback object.
|
||||
* @param accountId User ID
|
||||
* @return 0: Succeed ; otherwise is failed.
|
||||
*/
|
||||
virtual void RegisterInteractionOperation(const int windowId,
|
||||
const sptr<IAccessibilityInteractionOperation> &operation,
|
||||
const int accountId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Deregister the interaction operation.
|
||||
* @param windowId Window ID
|
||||
* @return
|
||||
*/
|
||||
virtual void DeregisterInteractionOperation(const int windowId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Requests feedback interruption from all accessibility services.
|
||||
* Remained.
|
||||
* @param -
|
||||
* @return
|
||||
*/
|
||||
virtual void Interrupt(const int accountId) = 0; //Remained
|
||||
|
||||
/**
|
||||
* @brief Register AA connection to AAMS.
|
||||
* Temp Solution.
|
||||
* @param obj IPC object
|
||||
* @return
|
||||
*/
|
||||
virtual void RegisterAbilityConnectionClientTmp(const sptr<IRemoteObject>& obj) = 0;
|
||||
|
||||
/**
|
||||
* @brief Obtains the suggested interval for switching the UI.
|
||||
* @param
|
||||
* @return Returns the interval.
|
||||
*/
|
||||
virtual uint64_t GetSuggestedInterval() = 0;
|
||||
|
||||
enum class Message {
|
||||
SEND_EVENT = 0,
|
||||
REGISTER_STATE_CALLBACK,
|
||||
GET_ABILITYLIST,
|
||||
REGISTER_INTERACTION_CONNECTION,
|
||||
DEREGISTER_INTERACTION_CONNECTION,
|
||||
INTERRUPT,
|
||||
GET_SUGGESTED_INTERVAL,
|
||||
REGISTER_ABILITY_CONNECTION_CLIENT // Temp Solution
|
||||
};
|
||||
};
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
||||
#endif
|
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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_ABILITY_MANAGER_SERVICE_CLIENT_PROXY_H
|
||||
#define ACCESSIBILITY_ABILITY_MANAGER_SERVICE_CLIENT_PROXY_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include "accessible_ability_manager_service_interface.h"
|
||||
#include "accessible_ability_manager_service_state_interface.h"
|
||||
#include "accessibility_event_info.h"
|
||||
#include "iremote_proxy.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
/*
|
||||
* The class define the interface to call ABMS API.
|
||||
*/
|
||||
class AccessibleAbilityManagerServiceClientProxy : public IRemoteProxy<IAccessibleAbilityManagerServiceClient> {
|
||||
public:
|
||||
/**
|
||||
* @brief construct function
|
||||
* @param object The object of IPC
|
||||
* @return
|
||||
*/
|
||||
explicit AccessibleAbilityManagerServiceClientProxy(const sptr<IRemoteObject> &object);
|
||||
|
||||
/**
|
||||
* @brief destruct function
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual ~AccessibleAbilityManagerServiceClientProxy() override;
|
||||
|
||||
/**
|
||||
* @brief Sends information about an accessibility event.
|
||||
* @param uiEvent Indicates the accessibility event information specified by AccessibilityEventInfo.
|
||||
* @param accountId The user id.
|
||||
* @return true: send ok; otherwise is refused.
|
||||
*/
|
||||
virtual void SendEvent(const AccessibilityEventInfo &uiEvent, const int accountId) override;
|
||||
|
||||
/**
|
||||
* @brief Register the state observer of AAMS.
|
||||
* @param callback state observer
|
||||
* @param accountId The user id.
|
||||
* @return 0: Register ok; otherwise is refused.
|
||||
*/
|
||||
virtual uint32_t RegisterStateCallback(const sptr<IAccessibleAbilityManagerServiceState> &callback,
|
||||
const int accountId) override;
|
||||
|
||||
/**
|
||||
* @brief Queries the list of accessibility abilities.
|
||||
* @param accessibilityAbilityTypes Indicates the accessibility type specified by
|
||||
* AccessibilityAbilityInfo#ACCESSIBILITY_ABILITY_TYPE_SPOKEN.
|
||||
* @param stateType Indicates the accessibility ability status. 1 indicates that the ability is enabled;
|
||||
* 2 indicates that the ability is disabled; 4 indicates that the ability has been installed.
|
||||
* @return
|
||||
*/
|
||||
virtual std::vector<AccessibilityAbilityInfo> GetAbilityList(const int abilityTypes, const int stateType) override;
|
||||
|
||||
/**
|
||||
* @brief Register the interaction operation, so the AA can get node info from ACE.
|
||||
* @param windowId Window ID
|
||||
* @param operation The callback object.
|
||||
* @param accountId User ID
|
||||
* @return 0: Succeed ; otherwise is failed.
|
||||
*/
|
||||
virtual void RegisterInteractionOperation(const int windowId,
|
||||
const sptr<IAccessibilityInteractionOperation> &operation,
|
||||
const int accountId) override;
|
||||
|
||||
/**
|
||||
* @brief Deregister the interaction operation.
|
||||
* @param windowId Window ID
|
||||
* @return
|
||||
*/
|
||||
virtual void DeregisterInteractionOperation(const int windowId) override;
|
||||
|
||||
/**
|
||||
* @brief Requests feedback interruption from all accessibility services.
|
||||
* Remained.
|
||||
* @param -
|
||||
* @return
|
||||
*/
|
||||
virtual void Interrupt(const int accountId) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the suggested interval for switching the UI.
|
||||
* @param
|
||||
* @return Returns the interval.
|
||||
*/
|
||||
virtual uint64_t GetSuggestedInterval() override;
|
||||
|
||||
/**
|
||||
* @brief Register AA connection to AAMS.
|
||||
* Temp Solution.
|
||||
* @param obj IPC object
|
||||
* @return
|
||||
*/
|
||||
virtual void RegisterAbilityConnectionClientTmp(const sptr<IRemoteObject>& obj) override;
|
||||
|
||||
/**
|
||||
* @brief Get IPC object.
|
||||
* @param
|
||||
* @return IPC object
|
||||
*/
|
||||
sptr<IRemoteObject> GetObject();
|
||||
private:
|
||||
/**
|
||||
* @brief Write the descriptor of IPC.
|
||||
* @param data It is include the descriptor of IPC.
|
||||
* @return true: Write the descriptor successfully; otherwise is not.
|
||||
*/
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
static inline BrokerDelegator<AccessibleAbilityManagerServiceClientProxy> delegator;
|
||||
};
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
||||
#endif
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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_SYSTEM_CLIENT_H
|
||||
#define ACCESSIBILITY_SYSTEM_CLIENT_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
class IAccessibleAbilityManagerServiceState: public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accessibility.IAccessibleAbilityManagerServiceState");
|
||||
|
||||
/**
|
||||
* @brief Receive the state notify from AAMS and send it to the observer registed..
|
||||
* @param stateType The state type and value.
|
||||
* state type: Refer to AccessibilityStateEventType.
|
||||
* value: STATE_ACCESSIBILITY_ENABLED/STATE_EXPLORATION_ENABLED/
|
||||
* STATE_ACCESSIBILITY_DISABLED/STATE_EXPLORATION_DISABLED
|
||||
* @return
|
||||
*/
|
||||
virtual void OnStateChanged(const uint32_t stateType) = 0;
|
||||
|
||||
enum class Message {
|
||||
ON_STATE_CHANGED,
|
||||
};
|
||||
};
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
||||
#endif
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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_SYSTEM_CLIENT_PROXY_H
|
||||
#define ACCESSIBILITY_SYSTEM_CLIENT_PROXY_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "accessible_ability_manager_service_state_interface.h"
|
||||
#include "iremote_proxy.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
class AccessibleAbilityManagerServiceStateProxy : public IRemoteProxy<IAccessibleAbilityManagerServiceState> {
|
||||
public:
|
||||
/**
|
||||
* @brief construct function
|
||||
* @param object The object of IPC
|
||||
* @return
|
||||
*/
|
||||
explicit AccessibleAbilityManagerServiceStateProxy(const sptr<IRemoteObject> &object);
|
||||
|
||||
/**
|
||||
* @brief destruct function
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual ~AccessibleAbilityManagerServiceStateProxy() override;
|
||||
|
||||
/**
|
||||
* @brief Receive the state notify from AAMS and send it to the observer registed..
|
||||
* @param stateType The state type and value.
|
||||
* state type: Refer to AccessibilityStateEventType.
|
||||
* value: STATE_ACCESSIBILITY_ENABLED/STATE_EXPLORATION_ENABLED/
|
||||
* STATE_ACCESSIBILITY_DISABLED/STATE_EXPLORATION_DISABLED
|
||||
* @return
|
||||
*/
|
||||
virtual void OnStateChanged(const uint32_t stateType) override;
|
||||
private:
|
||||
/**
|
||||
* @brief Write the descriptor of IPC.
|
||||
* @param data It is include the descriptor of IPC.
|
||||
* @return true: Write the descriptor successfully; otherwise is not.
|
||||
*/
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
static inline BrokerDelegator<AccessibleAbilityManagerServiceStateProxy> delegator;
|
||||
};
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
||||
#endif
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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_ABILITY_MANAGER_SERVICE_STATE_STUB_H
|
||||
#define ACCESSIBILITY_ABILITY_MANAGER_SERVICE_STATE_STUB_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
|
||||
#include "accessible_ability_manager_service_state_interface.h"
|
||||
#include "accessibility_errorcode.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "nocopyable.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
class AccessibleAbilityManagerServiceStateStub : public IRemoteStub<IAccessibleAbilityManagerServiceState> {
|
||||
public:
|
||||
/**
|
||||
* @brief construct function
|
||||
* @param object The object of IPC
|
||||
* @return
|
||||
*/
|
||||
AccessibleAbilityManagerServiceStateStub();
|
||||
|
||||
/**
|
||||
* @brief destruct function
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual ~AccessibleAbilityManagerServiceStateStub() = default;
|
||||
|
||||
/**
|
||||
* @brief Receive the event from proxy by IPC mechanism.
|
||||
* @param code The code is matched with the process function.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @param option The option paramter of IPC,such as: async,sync
|
||||
* @return
|
||||
*/
|
||||
int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option) override;
|
||||
|
||||
/**
|
||||
* @brief Receive the state notify from AAMS and send it to the observer registed..
|
||||
* @param stateType The state type and value.
|
||||
* state type: Refer to AccessibilityStateEventType.
|
||||
* value: STATE_ACCESSIBILITY_ENABLED/STATE_EXPLORATION_ENABLED/
|
||||
* STATE_ACCESSIBILITY_DISABLED/STATE_EXPLORATION_DISABLED
|
||||
* @return
|
||||
*/
|
||||
void OnStateChanged(const uint32_t stateType) override;
|
||||
private:
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleOnStateChanged.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleOnStateChanged(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(AccessibleAbilityManagerServiceStateStub);
|
||||
};
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
||||
#endif
|
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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_ABILITY_MANAGER_SERVICE_CLIENT_STUB_H
|
||||
#define ACCESSIBILITY_ABILITY_MANAGER_SERVICE_CLIENT_STUB_H
|
||||
|
||||
#include <cstdint>
|
||||
#include "accessibility_ability_info.h"
|
||||
#include "accessible_ability_manager_service_state_interface.h"
|
||||
#include "accessible_ability_manager_service_interface.h"
|
||||
#include "accessibility_event_info.h"
|
||||
#include "accessibility_errorcode.h"
|
||||
#include "iremote_object.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "nocopyable.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
/*
|
||||
* The class define the interface to call ABMS API.
|
||||
*/
|
||||
class AccessibleAbilityManagerServiceClientStub : public IRemoteStub<IAccessibleAbilityManagerServiceClient> {
|
||||
public:
|
||||
/**
|
||||
* @brief construct function
|
||||
* @param object The object of IPC
|
||||
* @return
|
||||
*/
|
||||
AccessibleAbilityManagerServiceClientStub();
|
||||
|
||||
/**
|
||||
* @brief destruct function
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual ~AccessibleAbilityManagerServiceClientStub();
|
||||
|
||||
/**
|
||||
* @brief Receive the event from proxy by IPC mechanism.
|
||||
* @param code The code is matched with the process function.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @param option The option paramter of IPC,such as: async,sync
|
||||
* @return
|
||||
*/
|
||||
virtual int OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option) override;
|
||||
private:
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleSendEvent.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleSendEvent(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleRegisterStateCallback.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleRegisterStateCallback(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleGetAbilityList.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleGetAbilityList(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleRegisterAccessibilityInteractionOperation.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleRegisterAccessibilityInteractionOperation(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleDeregisterAccessibilityInteractionOperation.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleDeregisterAccessibilityInteractionOperation(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleInterrupt.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleInterrupt(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleGetSuggestedInterval.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleGetSuggestedInterval(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
/**
|
||||
* @brief Handle the IPC request for the function:HandleRegisterAbilityConnectionClientTmp.
|
||||
* @param data The data of prcess communication
|
||||
* @param reply The response of IPC request
|
||||
* @return NO_ERROR: successful; otherwise is failed.
|
||||
*/
|
||||
ErrCode HandleRegisterAbilityConnectionClientTmp(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using AccessibilityAbilityManagerServiceFunc = ErrCode (AccessibleAbilityManagerServiceClientStub::*)
|
||||
(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, AccessibilityAbilityManagerServiceFunc> memberFuncMap_;
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(AccessibleAbilityManagerServiceClientStub);
|
||||
};
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
||||
#endif
|
230
frameworks/asacfwk/include/gesture_simulation.h
Normal file
230
frameworks/asacfwk/include/gesture_simulation.h
Normal file
@ -0,0 +1,230 @@
|
||||
/*
|
||||
* 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 GESTURE_SIMULATION_H
|
||||
#define GESTURE_SIMULATION_H
|
||||
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include "parcel_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
class GesturePathPositionDefine : public Parcelable
|
||||
{
|
||||
public:
|
||||
GesturePathPositionDefine() {}
|
||||
~GesturePathPositionDefine() {}
|
||||
|
||||
GesturePathPositionDefine(float positionX, float positionY);
|
||||
|
||||
/**
|
||||
* @brief Obtains the X coordinate of the position.
|
||||
* @param
|
||||
* @return Return the X coordinate of the position.
|
||||
*/
|
||||
float GetPositionX();
|
||||
|
||||
/**
|
||||
* @brief Obtains the Y coordinate of the position.
|
||||
* @param
|
||||
* @return Return the Y coordinate of the position.
|
||||
*/
|
||||
float GetPositionY();
|
||||
|
||||
/**
|
||||
* @brief Sets the X coordinate of the position.
|
||||
* @param positionX The X coordinate of the position.
|
||||
* @return
|
||||
*/
|
||||
void SetPositionX(float positionX);
|
||||
|
||||
/**
|
||||
* @brief Sets the Y coordinate of the position.
|
||||
* @param positionX The Y coordinate of the position.
|
||||
* @return
|
||||
*/
|
||||
void SetPositionY(float positionY);
|
||||
|
||||
/**
|
||||
* @brief read this sequenceable object from a Parcel.
|
||||
* @param parcel Indicates the Parcel object into which the sequenceable object has been marshaled.
|
||||
* @return Return true if read successfully, else return false.
|
||||
*/
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
|
||||
/**
|
||||
* @brief Marshals this sequenceable object into a Parcel.
|
||||
* @param parcel Indicates the Parcel object to which the sequenceable object will be marshaled.
|
||||
* @return Return true if Marshal successfully, else return false.
|
||||
*/
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
||||
/**
|
||||
* @brief Unmarshals this sequenceable object from a Parcel.
|
||||
* @param parcel Indicates the Parcel object into which the sequenceable object has been marshaled.
|
||||
* @return Return a sequenceable object of GesturePathPositionDefine.
|
||||
*/
|
||||
static GesturePathPositionDefine *Unmarshalling(Parcel &parcel);
|
||||
|
||||
private:
|
||||
float positionX_ = 0;
|
||||
float positionY_ = 0;
|
||||
};
|
||||
|
||||
class GesturePathDefine : public Parcelable
|
||||
{
|
||||
public:
|
||||
GesturePathDefine() {}
|
||||
~GesturePathDefine() {}
|
||||
|
||||
GesturePathDefine(GesturePathPositionDefine &startPosition,
|
||||
GesturePathPositionDefine &endPosition, uint32_t durationTime);
|
||||
|
||||
/**
|
||||
* @brief Obtains the duration for completing the maximum number of gesture strokes.
|
||||
* @param
|
||||
* @return Return the duration for completing the maximum number of gesture strokes.
|
||||
*/
|
||||
static uint32_t GetMaxStrokeDuration();
|
||||
|
||||
/**
|
||||
* @brief Obtains the maximum number of strokes in this gesture path.
|
||||
* @param
|
||||
* @return Return the maximum number of strokes in this gesture path.
|
||||
*/
|
||||
static uint32_t GetMaxStrokes();
|
||||
|
||||
/**
|
||||
* @brief Obtains the duration in which this gesture path continues.
|
||||
* @param
|
||||
* @return Return the duration in which this gesture path continues.
|
||||
*/
|
||||
uint32_t GetDurationTime();
|
||||
|
||||
/**
|
||||
* @brief Obtains the end position of this gesture path.
|
||||
* @param
|
||||
* @return Return the end position of this gesture path.
|
||||
*/
|
||||
GesturePathPositionDefine &GetEndPosition();
|
||||
|
||||
/**
|
||||
* @brief Obtains the start position of this gesture path.
|
||||
* @param
|
||||
* @return Return the start position of this gesture path.
|
||||
*/
|
||||
GesturePathPositionDefine &GetStartPosition();
|
||||
|
||||
/**
|
||||
* @brief Sets the duration for this gesture path to continue.
|
||||
* @param durationTime The duration for this gesture path to continue.
|
||||
* @return
|
||||
*/
|
||||
void SetDurationTime(uint32_t durationTime);
|
||||
|
||||
/**
|
||||
* @brief Sets the end position of this gesture path.
|
||||
* @param endPosition The end position of this gesture path.
|
||||
* @return
|
||||
*/
|
||||
void SetEndPosition(GesturePathPositionDefine &endPosition);
|
||||
|
||||
/**
|
||||
* @brief Sets the start position of this gesture path.
|
||||
* @param startPosition The start position of this gesture path.
|
||||
* @return
|
||||
*/
|
||||
void SetStartPosition(GesturePathPositionDefine &startPosition);
|
||||
|
||||
/**
|
||||
* @brief read this sequenceable object from a Parcel.
|
||||
* @param parcel Indicates the Parcel object into which the sequenceable object has been marshaled.
|
||||
* @return Return true if read successfully, else return false.
|
||||
*/
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
|
||||
/**
|
||||
* @brief Marshals this sequenceable object into a Parcel.
|
||||
* @param parcel Indicates the Parcel object to which the sequenceable object will be marshaled.
|
||||
* @return Return true if Marshal successfully, else return false.
|
||||
*/
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
||||
/**
|
||||
* @brief Unmarshals this sequenceable object from a Parcel.
|
||||
* @param parcel Indicates the Parcel object into which the sequenceable object has been marshaled.
|
||||
* @return Return a sequenceable object of GesturePathDefine.
|
||||
*/
|
||||
static GesturePathDefine *Unmarshalling(Parcel &parcel);
|
||||
|
||||
private:
|
||||
const static uint32_t MAX_STROKE_DURATION = 60 * 1000;
|
||||
const static uint32_t MAX_STROKES = 10;
|
||||
|
||||
GesturePathPositionDefine startPosition_;
|
||||
GesturePathPositionDefine endPosition_;
|
||||
uint32_t durationTime_ = 0;
|
||||
};
|
||||
|
||||
class GestureResultListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Called when the gesture is cancelled.
|
||||
* @param gesturePathDefine The gesture which will be notified to listener.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnCancelled(std::vector<GesturePathDefine> &gesturePathDefine) = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when the gesture is completed.
|
||||
* @param gesturePathDefine The gesture which will be notified to listener.
|
||||
* @return
|
||||
*/
|
||||
virtual void OnCompleted(std::vector<GesturePathDefine> &gesturePathDefine) = 0;
|
||||
};
|
||||
|
||||
class GestureResultListenerInfo
|
||||
{
|
||||
public:
|
||||
GestureResultListenerInfo(std::vector<GesturePathDefine> gesturePathDefine,
|
||||
std::shared_ptr<GestureResultListener>& gestureResultListener);
|
||||
|
||||
/**
|
||||
* @brief Obtains the listener observing gestures sent to the screen.
|
||||
* @param
|
||||
* @return Return the listener observing gestures sent to the screen.
|
||||
*/
|
||||
std::shared_ptr<GestureResultListener>& GetGestureResultListener();
|
||||
|
||||
/**
|
||||
* @brief Obtains GesturePath of this listenerInfo.
|
||||
* @param
|
||||
* @return Return GesturePath of this listenerInfo.
|
||||
*/
|
||||
std::vector<GesturePathDefine> GetGesturePathDefine();
|
||||
|
||||
private:
|
||||
std::vector<GesturePathDefine> gesturePathDefine_ {};
|
||||
std::shared_ptr<GestureResultListener> gestureResultListener_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // GESTURE_SIMULATION_H
|
265
frameworks/asacfwk/src/accessibility_ability_info.cpp
Normal file
265
frameworks/asacfwk/src/accessibility_ability_info.cpp
Normal file
@ -0,0 +1,265 @@
|
||||
/*
|
||||
* 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 "accessibility_ability_info.h"
|
||||
#include "dummy.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel_util.h"
|
||||
#include "json_utils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
AccessibilityAbilityInfo::AccessibilityAbilityInfo(AbilityInfo abilityInfo)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
abilityInfo_ = abilityInfo;
|
||||
|
||||
#if 0
|
||||
// dummy data for test. It's temporary.
|
||||
AccessibilityAbilityInfoDummy accessibilityAbilityInfoDummydata;
|
||||
capabilities_ = accessibilityAbilityInfoDummydata.capabilities;
|
||||
abilityTypes_ = accessibilityAbilityInfoDummydata.accessibilityAbilityTypes;
|
||||
eventTypes_ = accessibilityAbilityInfoDummydata.accessibilityEventTypes;
|
||||
notificationTimeout_ = accessibilityAbilityInfoDummydata.notificationTimeout;
|
||||
uiInteractiveTimeout_ = accessibilityAbilityInfoDummydata.uiInteractiveTime;
|
||||
uiNoninteractiveTimeout_ = accessibilityAbilityInfoDummydata.uiNoninteractiveTime;
|
||||
targetBundleNames_ = accessibilityAbilityInfoDummydata.filterBundleNames;
|
||||
description_ = accessibilityAbilityInfoDummydata.description;
|
||||
settingsAbility_ = accessibilityAbilityInfoDummydata.settingsAbility;
|
||||
|
||||
#else
|
||||
|
||||
if (!ParseAAConfig()) {
|
||||
HILOG_ERROR("Parse AccessibilityAbility config file failed.");
|
||||
}
|
||||
|
||||
#endif // 0
|
||||
}
|
||||
|
||||
bool AccessibilityAbilityInfo::ParseAAConfig()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
nlohmann::json sourceJson;
|
||||
if (!JsonUtils::GetJsonObjFromJson(sourceJson, AccessibleAbility_JSON_FILE_PATH)) {
|
||||
HILOG_ERROR("Get JsonObj from json failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
vector<string> eventTypes;
|
||||
if (!JsonUtils::GetStringVecFromJson(sourceJson, AccessibleAbility_JSON_KEY_ACCESSIBILITY_EVENT_TYPES,
|
||||
eventTypes)) {
|
||||
HILOG_ERROR("Get stringVec from json failed.");
|
||||
return false;
|
||||
}
|
||||
PraseVecUtils::ParseEventTypesFromVec(eventTypes, eventTypes_);
|
||||
|
||||
if (!JsonUtils::GetStringVecFromJson(sourceJson, AccessibleAbility_JSON_KEY_TARGET_BUNDLE_NAMES,
|
||||
targetBundleNames_)) {
|
||||
HILOG_ERROR("Get stringVec from json failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
vector<string> abilityType;
|
||||
if (!JsonUtils::GetStringVecFromJson(sourceJson, AccessibleAbility_JSON_KEY_ACCESSIBILITY_ABILITY_TYPES,
|
||||
abilityType)) {
|
||||
HILOG_ERROR("Get stringVec from json failed.");
|
||||
return false;
|
||||
}
|
||||
PraseVecUtils::ParseAbilityTypesFromVec(abilityType, abilityTypes_);
|
||||
|
||||
int notificationTimeout = -1;
|
||||
if (!JsonUtils::GetIntFromJson(sourceJson, AccessibleAbility_JSON_KEY_NOTIFICATION_TIMEOUT,
|
||||
notificationTimeout)) {
|
||||
HILOG_ERROR("Get int from json failed.");
|
||||
return false;
|
||||
}
|
||||
notificationTimeout_ = static_cast<uint32_t>(notificationTimeout);
|
||||
|
||||
int uiNoninteractiveTimeout = -1;
|
||||
if (!JsonUtils::GetIntFromJson(sourceJson, AccessibleAbility_JSON_KEY_UI_NONINTERACTIVE_TIMEOUT,
|
||||
uiNoninteractiveTimeout)) {
|
||||
HILOG_ERROR("Get int from json failed.");
|
||||
return false;
|
||||
}
|
||||
uiNoninteractiveTimeout_ = static_cast<uint32_t>(uiNoninteractiveTimeout);
|
||||
|
||||
int uiInteractiveTimeout = -1;
|
||||
if (!JsonUtils::GetIntFromJson(sourceJson, AccessibleAbility_JSON_KEY_UI_INTERACTIVE_TIMEOUT,
|
||||
uiInteractiveTimeout)) {
|
||||
HILOG_ERROR("Get int from json failed.");
|
||||
return false;
|
||||
}
|
||||
uiInteractiveTimeout_ = static_cast<uint32_t>(uiInteractiveTimeout);
|
||||
|
||||
vector<string> capabilities;
|
||||
if (!JsonUtils::GetStringVecFromJson(sourceJson,
|
||||
AccessibleAbility_JSON_KEY_ACCESSIBILITY_CAPABILITIES, capabilities)) {
|
||||
HILOG_ERROR("Get stringVec from json failed.");
|
||||
return false;
|
||||
}
|
||||
PraseVecUtils::ParseCapabilitiesFromVec(capabilities, capabilities_);
|
||||
|
||||
if (!JsonUtils::GetStringFromJson(sourceJson, AccessibleAbility_JSON_KEY_DESCRIPTION, description_)) {
|
||||
HILOG_ERROR("Get string from json failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!JsonUtils::GetStringFromJson(sourceJson, AccessibleAbility_JSON_KEY_SETTINGS_ABILITY, settingsAbility_)) {
|
||||
HILOG_ERROR("Get string from json failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const AbilityInfo &AccessibilityAbilityInfo::GetAbilityInfo()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return abilityInfo_;
|
||||
}
|
||||
|
||||
uint32_t AccessibilityAbilityInfo::GetAccessibilityAbilityType()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return abilityTypes_;
|
||||
}
|
||||
|
||||
uint32_t AccessibilityAbilityInfo::GetCapabilityValues()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return capabilities_;
|
||||
}
|
||||
|
||||
string AccessibilityAbilityInfo::GetDescription()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return description_;
|
||||
}
|
||||
|
||||
uint32_t AccessibilityAbilityInfo::GetEventTypes()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return eventTypes_;
|
||||
}
|
||||
|
||||
string AccessibilityAbilityInfo::GetId()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return abilityInfo_.bundleName + "/" + abilityInfo_.name;
|
||||
}
|
||||
|
||||
string AccessibilityAbilityInfo::GetName()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return abilityInfo_.name;
|
||||
}
|
||||
|
||||
string AccessibilityAbilityInfo::GetPackageName()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return abilityInfo_.bundleName;
|
||||
}
|
||||
|
||||
vector<string> AccessibilityAbilityInfo::GetFilterBundleNames()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return targetBundleNames_;
|
||||
}
|
||||
|
||||
std::string AccessibilityAbilityInfo::GetSettingsAbility()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return settingsAbility_;
|
||||
}
|
||||
|
||||
uint32_t AccessibilityAbilityInfo::GetNotificationTimeout()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return notificationTimeout_;
|
||||
}
|
||||
|
||||
uint32_t AccessibilityAbilityInfo::GetUiInteractiveTime()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return uiInteractiveTimeout_;
|
||||
}
|
||||
|
||||
uint32_t AccessibilityAbilityInfo::GetUiNoninteractiveTime()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return uiNoninteractiveTimeout_;
|
||||
}
|
||||
|
||||
bool AccessibilityAbilityInfo::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, abilityTypes_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, capabilities_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, description_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, eventTypes_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, settingsAbility_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, notificationTimeout_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, uiInteractiveTimeout_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, uiNoninteractiveTimeout_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(StringVector, parcel, &targetBundleNames_);
|
||||
|
||||
std::unique_ptr<AbilityInfo> abilityInfo(parcel.ReadParcelable<AbilityInfo>());
|
||||
if (!abilityInfo) {
|
||||
HILOG_ERROR("ReadParcelable AbilityInfo failed.");
|
||||
return false;
|
||||
}
|
||||
abilityInfo_ = *abilityInfo;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityAbilityInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, abilityTypes_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, capabilities_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, description_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, eventTypes_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, settingsAbility_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, notificationTimeout_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, uiInteractiveTimeout_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, uiNoninteractiveTimeout_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(StringVector, parcel, targetBundleNames_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &abilityInfo_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
AccessibilityAbilityInfo *AccessibilityAbilityInfo::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
AccessibilityAbilityInfo *accessibilityAbilityInfo = new AccessibilityAbilityInfo();
|
||||
|
||||
if (accessibilityAbilityInfo && !accessibilityAbilityInfo->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("ReadFromParcel AccessibilityAbilityInfo failed.");
|
||||
delete accessibilityAbilityInfo;
|
||||
accessibilityAbilityInfo = nullptr;
|
||||
}
|
||||
|
||||
return accessibilityAbilityInfo;
|
||||
}
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
1369
frameworks/asacfwk/src/accessibility_element_info.cpp
Normal file
1369
frameworks/asacfwk/src/accessibility_element_info.cpp
Normal file
File diff suppressed because it is too large
Load Diff
537
frameworks/asacfwk/src/accessibility_event_info.cpp
Normal file
537
frameworks/asacfwk/src/accessibility_event_info.cpp
Normal file
@ -0,0 +1,537 @@
|
||||
/*
|
||||
* 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 "accessibility_event_info.h"
|
||||
#include "accessibility_operator.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
bool AccessibilityMemo::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, channelId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, componentId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, currentIndex_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, beginIndex_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, endIndex_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(StringVector, parcel, &contents_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, componentType_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, description_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, beforeText_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, latestConent_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, elementId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, itemCounts_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityMemo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, channelId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, componentId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, currentIndex_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, beginIndex_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, endIndex_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(StringVector, parcel, contents_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, componentType_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, description_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, beforeText_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, latestConent_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, elementId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, itemCounts_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
AccessibilityMemo* AccessibilityMemo::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
AccessibilityMemo* accessibilityRecord = new AccessibilityMemo();
|
||||
if (!accessibilityRecord->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("read from parcel failed");
|
||||
delete accessibilityRecord;
|
||||
accessibilityRecord = nullptr;
|
||||
}
|
||||
return accessibilityRecord;
|
||||
}
|
||||
|
||||
void AccessibilityMemo::SetChannelId(const int channelId)
|
||||
{
|
||||
channelId_ = channelId;
|
||||
HILOG_DEBUG("[%{public}s] channelId_[%{public}d]", __func__, channelId_);
|
||||
}
|
||||
|
||||
int AccessibilityMemo::GetChannelId() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] channelId_[%{public}d]", __func__, channelId_);
|
||||
return channelId_;
|
||||
}
|
||||
|
||||
void AccessibilityMemo::SetSource(const int componentId)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] componentId[%{public}d]", __func__, componentId);
|
||||
componentId_ = componentId;
|
||||
elementId_ = componentId;
|
||||
}
|
||||
|
||||
bool AccessibilityMemo::GetSource(AccessibilityElementInfo &elementInfo) const
|
||||
{
|
||||
HILOG_INFO("[%{public}s] called] channelId_[%{public}d], windowId_[%{public}d], elementId_[%{public}d]",
|
||||
__func__, channelId_, windowId_, elementId_);
|
||||
AccessibilityOperator * instance = &AccessibilityOperator::GetInstance();
|
||||
AccessibilityElementInfo element {};
|
||||
std::vector<AccessibilityElementInfo> elementInfos {};
|
||||
bool result = false;
|
||||
if (instance != nullptr) {
|
||||
result = instance->SearchElementInfosByAccessibilityId(channelId_, windowId_, elementId_, 0,elementInfos);
|
||||
for (auto& info : elementInfos) {
|
||||
HILOG_INFO("[%{public}s] called] GetSource OK", __func__);
|
||||
result = true;
|
||||
elementInfo = info;
|
||||
break;
|
||||
}
|
||||
HILOG_INFO("[%{public}s] called] GetSource is null", __func__);
|
||||
} else {
|
||||
HILOG_INFO("[%{public}s] called] Can't get AccessibilityOperator instance", __func__);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int AccessibilityMemo::GetViewId() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] componentId_[%{public}d]", __func__, componentId_);
|
||||
return componentId_;
|
||||
}
|
||||
|
||||
int AccessibilityMemo::GetAccessibilityId() const
|
||||
{
|
||||
HILOG_INFO("[%{public}s] called] elementId_[%{public}d]",__func__, elementId_);
|
||||
return elementId_;
|
||||
}
|
||||
|
||||
void AccessibilityMemo::SetWindowId(const int windowId)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] windowId[%{public}d]", __func__, windowId);
|
||||
windowId_ = windowId;
|
||||
}
|
||||
|
||||
int AccessibilityMemo::GetWindowId() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] windowId_[%{public}d]", __func__, windowId_);
|
||||
return windowId_;
|
||||
}
|
||||
|
||||
int AccessibilityMemo::GetCurrentIndex() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] currentIndex_[%{public}d]", __func__, currentIndex_);
|
||||
return currentIndex_;
|
||||
}
|
||||
|
||||
void AccessibilityMemo::SetCurrentIndex(const int index)
|
||||
{
|
||||
currentIndex_ = index;
|
||||
HILOG_DEBUG("[%{public}s] currentIndex_[%{public}d]", __func__, currentIndex_);
|
||||
}
|
||||
|
||||
int AccessibilityMemo::GetBeginIndex() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] beginIndex_[%{public}d]", __func__, beginIndex_);
|
||||
return beginIndex_;
|
||||
}
|
||||
|
||||
void AccessibilityMemo::SetBeginIndex(const int index)
|
||||
{
|
||||
beginIndex_ = index;
|
||||
HILOG_DEBUG("[%{public}s] beginIndex_[%{public}d]", __func__, beginIndex_);
|
||||
}
|
||||
|
||||
int AccessibilityMemo::GetEndIndex() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] endIndex_[%{public}d]", __func__, endIndex_);
|
||||
return endIndex_;
|
||||
}
|
||||
|
||||
void AccessibilityMemo::SetEndIndex(const int index)
|
||||
{
|
||||
endIndex_ = index;
|
||||
HILOG_DEBUG("[%{public}s] endIndex_[%{public}d]", __func__, endIndex_);
|
||||
}
|
||||
|
||||
std::string AccessibilityMemo::GetComponentType() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] componentType_[%{public}s]", __func__, componentType_.c_str());
|
||||
return componentType_;
|
||||
}
|
||||
|
||||
void AccessibilityMemo::SetComponentType(const std::string &className)
|
||||
{
|
||||
componentType_ = className;
|
||||
HILOG_DEBUG("[%{public}s] componentType_[%{public}s]", __func__, componentType_.c_str());
|
||||
}
|
||||
|
||||
std::string AccessibilityMemo::GetBeforeText() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] beforeText_[%{public}s]", __func__, beforeText_.c_str());
|
||||
return beforeText_;
|
||||
}
|
||||
|
||||
void AccessibilityMemo::SetBeforeText(const std::string &beforeText)
|
||||
{
|
||||
beforeText_ = beforeText;
|
||||
HILOG_DEBUG("[%{public}s] beforeText_[%{public}s]", __func__, beforeText_.c_str());
|
||||
}
|
||||
|
||||
void AccessibilityMemo::AddContent(const std::string &content)
|
||||
{
|
||||
contents_.push_back(content);
|
||||
HILOG_DEBUG("[%{public}s] content[%{public}s]", __func__, content.c_str());
|
||||
}
|
||||
|
||||
std::vector<std::string> AccessibilityMemo::GetContentList() const
|
||||
{
|
||||
return contents_;
|
||||
}
|
||||
|
||||
std::string AccessibilityMemo::GetLatestContent() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] latestConent_[%{public}s]", __func__, latestConent_.c_str());
|
||||
return latestConent_;
|
||||
}
|
||||
|
||||
void AccessibilityMemo::SetLatestContent(const std::string &content)
|
||||
{
|
||||
latestConent_ = content;
|
||||
HILOG_DEBUG("[%{public}s] latestConent_[%{public}s]", __func__, latestConent_.c_str());
|
||||
}
|
||||
|
||||
std::string AccessibilityMemo::GetDescription() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] description_[%{public}s]", __func__, description_.c_str());
|
||||
return description_;
|
||||
}
|
||||
|
||||
void AccessibilityMemo::SetDescription(const std::string &contentDescription)
|
||||
{
|
||||
description_ = contentDescription;
|
||||
HILOG_DEBUG("[%{public}s] description_[%{public}s]", __func__, description_.c_str());
|
||||
}
|
||||
|
||||
void AccessibilityMemo::SetItemCounts(const int itemCounts)
|
||||
{
|
||||
itemCounts_ = itemCounts;
|
||||
HILOG_DEBUG("[%{public}s] itemCounts_[%{public}d]", __func__, itemCounts_);
|
||||
}
|
||||
|
||||
int AccessibilityMemo::GetItemCounts() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] itemCounts_[%{public}d]", __func__, itemCounts_);
|
||||
return itemCounts_;
|
||||
}
|
||||
|
||||
bool AccessibilityEventInfo::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
int eventType = TYPE_VIEW_INVALID;
|
||||
int triggerAction = ACCESSIBILITY_ACTION_INVALID;
|
||||
int textMoveStep = STEP_CHARACTER;
|
||||
int windowContentChangeTypes = CONTENT_CHANGE_TYPE_INVALID;
|
||||
int windowChangeTypes = WINDOW_UPDATE_INVALID;
|
||||
int category = CATEGORY_INVALID;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, eventType);
|
||||
eventType_ = static_cast<EventType>(eventType);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, triggerAction);
|
||||
triggerAction_ = static_cast<ActionType>(triggerAction);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, timeStamp_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, textMoveStep);
|
||||
textMoveStep_ = static_cast<TextMoveUnit>(textMoveStep);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowContentChangeTypes);
|
||||
windowContentChangeTypes_ = static_cast<WindowsContentChangeTypes>(windowContentChangeTypes);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowChangeTypes);
|
||||
windowChangeTypes_ = static_cast<WindowUpdateType>(windowChangeTypes);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, recordsCount_);
|
||||
int32_t recordSize = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, recordSize);
|
||||
for (auto i = 0; i < recordSize; i++) {
|
||||
std::shared_ptr<AccessibilityEventInfo> accessibilityRecord(parcel.ReadParcelable<AccessibilityEventInfo>());
|
||||
if (!accessibilityRecord) {
|
||||
HILOG_ERROR("ReadParcelable<accessibilityInfo> failed");
|
||||
}
|
||||
records_.emplace_back(*accessibilityRecord);
|
||||
}
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, category);
|
||||
category_ = static_cast<NotificationCategory>(category);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, pageId_);
|
||||
|
||||
int32_t channelId = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, channelId);
|
||||
SetChannelId(channelId);
|
||||
int32_t componentId = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, componentId);
|
||||
SetSource(componentId);
|
||||
int32_t windowId = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowId);
|
||||
SetWindowId(windowId);
|
||||
int32_t currentIndex = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, currentIndex);
|
||||
SetCurrentIndex(currentIndex);
|
||||
int32_t beginIndex = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, beginIndex);
|
||||
SetBeginIndex(beginIndex);
|
||||
int32_t endIndex = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, endIndex);
|
||||
SetEndIndex(endIndex);
|
||||
int32_t contentSize = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, contentSize);
|
||||
std::string content;
|
||||
for (auto i = 0 ; i < contentSize; i++) {
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, content);
|
||||
AddContent(content);
|
||||
}
|
||||
std::string componentType;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, componentType);
|
||||
SetComponentType(componentType);
|
||||
std::string description;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, description);
|
||||
SetDescription(description);
|
||||
std::string beforeText;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, beforeText);
|
||||
SetBeforeText(beforeText);
|
||||
std::string latestConent;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, latestConent);
|
||||
SetLatestContent(latestConent);
|
||||
int32_t elementId = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, elementId);
|
||||
//SetSource(elementId);
|
||||
int32_t itemCounts = 0;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, itemCounts);
|
||||
SetItemCounts(itemCounts);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityEventInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int>(eventType_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int>(triggerAction_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, timeStamp_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int>(textMoveStep_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int>(windowContentChangeTypes_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int>(windowChangeTypes_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, recordsCount_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, records_.size());
|
||||
for (auto &record : records_) {
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &record);
|
||||
}
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int>(category_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, pageId_);
|
||||
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetChannelId());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetViewId());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetWindowId());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetCurrentIndex());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetBeginIndex());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetEndIndex());
|
||||
auto contentList = GetContentList();
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, contentList.size());
|
||||
for (auto &content : contentList) {
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, content);
|
||||
}
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, GetComponentType());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, GetDescription());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, GetBeforeText());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, GetLatestContent());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetAccessibilityId());
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, GetItemCounts());
|
||||
return true;
|
||||
}
|
||||
|
||||
AccessibilityEventInfo *AccessibilityEventInfo::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
AccessibilityEventInfo *accessibilityEventInfo = new AccessibilityEventInfo();
|
||||
if (!accessibilityEventInfo->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("read from parcel failed");
|
||||
delete accessibilityEventInfo;
|
||||
accessibilityEventInfo = nullptr;
|
||||
}
|
||||
return accessibilityEventInfo;
|
||||
}
|
||||
|
||||
int AccessibilityEventInfo::GetRecordCount() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] recordsCount_[%{public}d]", __func__, recordsCount_);
|
||||
return recordsCount_;
|
||||
}
|
||||
|
||||
void AccessibilityEventInfo::SetRecordCount(const int recordCount)
|
||||
{
|
||||
recordsCount_ = recordCount;
|
||||
HILOG_DEBUG("[%{public}s] recordsCount_[%{public}d]", __func__, recordsCount_);
|
||||
}
|
||||
|
||||
void AccessibilityEventInfo::AddRecord(const AccessibilityEventInfo &record)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
records_.push_back(record);
|
||||
}
|
||||
|
||||
AccessibilityEventInfo AccessibilityEventInfo::GetRecord(const int index)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
if (index >= recordsCount_ || index < 0) {
|
||||
AccessibilityEventInfo record {};
|
||||
HILOG_ERROR("[%{public}s] called] index[%{public}d] is invalid", __func__, index);
|
||||
return record;
|
||||
}
|
||||
return records_[index];
|
||||
}
|
||||
|
||||
std::vector<AccessibilityEventInfo> AccessibilityEventInfo::GetRecords()
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
return records_;
|
||||
}
|
||||
|
||||
EventType AccessibilityEventInfo::GetEventType() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] eventType_[%{public}d]", __func__, eventType_);
|
||||
return eventType_;
|
||||
}
|
||||
|
||||
WindowsContentChangeTypes AccessibilityEventInfo::GetWindowContentChangeTypes() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] windowType_[%{public}d]", __func__, windowContentChangeTypes_);
|
||||
return windowContentChangeTypes_;
|
||||
}
|
||||
|
||||
void AccessibilityEventInfo::SetWindowContentChangeTypes(const WindowsContentChangeTypes changeTypes)
|
||||
{
|
||||
windowContentChangeTypes_ = changeTypes;
|
||||
HILOG_DEBUG("[%{public}s] windowType_[%{public}d]", __func__, windowContentChangeTypes_);
|
||||
}
|
||||
|
||||
WindowUpdateType AccessibilityEventInfo::GetWindowChangeTypes() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] windowType_[%{public}d]", __func__, windowChangeTypes_);
|
||||
return windowChangeTypes_;
|
||||
}
|
||||
|
||||
void AccessibilityEventInfo::SetWindowChangeTypes(const WindowUpdateType changeTypes)
|
||||
{
|
||||
windowChangeTypes_ = changeTypes;
|
||||
HILOG_DEBUG("[%{public}s] windowType_[%{public}d]", __func__, windowChangeTypes_);
|
||||
}
|
||||
|
||||
void AccessibilityEventInfo::SetEventType(const EventType eventType)
|
||||
{
|
||||
eventType_ = EventType(eventType);
|
||||
HILOG_DEBUG("[%{public}s] eventType_[%{public}d]", __func__, eventType_);
|
||||
}
|
||||
|
||||
long long AccessibilityEventInfo::GetTimeStamp() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
return timeStamp_;
|
||||
}
|
||||
|
||||
void AccessibilityEventInfo::SetTimeStamp(const long long eventTime)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
timeStamp_ = eventTime;
|
||||
}
|
||||
|
||||
std::string AccessibilityEventInfo::GetBundleName() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] bundleName_[%{public}s]", __func__, bundleName_.c_str());
|
||||
return bundleName_;
|
||||
}
|
||||
|
||||
void AccessibilityEventInfo::SetBundleName(const std::string &bundleName)
|
||||
{
|
||||
bundleName_ = bundleName;
|
||||
HILOG_DEBUG("[%{public}s] bundleName_[%{public}s]", __func__, bundleName_.c_str());
|
||||
}
|
||||
|
||||
void AccessibilityEventInfo::SetTextMovementStep(const TextMoveUnit granularity)
|
||||
{
|
||||
textMoveStep_ = granularity;
|
||||
HILOG_DEBUG("[%{public}s] textMoveStep_[%{public}d]", __func__, textMoveStep_);
|
||||
}
|
||||
|
||||
TextMoveUnit AccessibilityEventInfo::GetTextMovementStep() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] textMoveStep_[%{public}d]", __func__, textMoveStep_);
|
||||
return textMoveStep_;
|
||||
}
|
||||
|
||||
void AccessibilityEventInfo::SetTriggerAction(const ActionType action)
|
||||
{
|
||||
triggerAction_ = action;
|
||||
HILOG_DEBUG("[%{public}s] triggerAction_[%{public}d]", __func__, triggerAction_);
|
||||
}
|
||||
|
||||
ActionType AccessibilityEventInfo::GetTriggerAction() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] triggerAction_[%{public}d]", __func__, triggerAction_);
|
||||
return triggerAction_;
|
||||
}
|
||||
|
||||
AccessibilityEventInfo::AccessibilityEventInfo(
|
||||
int windowId, WindowUpdateType windowChangeTypes)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
eventType_ = TYPE_WINDOW_UPDATE;
|
||||
windowChangeTypes_ = windowChangeTypes;
|
||||
SetWindowId(windowId);
|
||||
}
|
||||
|
||||
AccessibilityEventInfo::AccessibilityEventInfo(EventType eventType)
|
||||
{
|
||||
eventType_ = eventType;
|
||||
HILOG_DEBUG("[%{public}s] eventType_[%{public}d]", __func__, eventType_);
|
||||
}
|
||||
|
||||
void AccessibilityEventInfo::SetNotificationInfo(const NotificationCategory category)
|
||||
{
|
||||
category_ = category;
|
||||
HILOG_DEBUG("[%{public}s] category_[%{public}d]", __func__, category_);
|
||||
}
|
||||
|
||||
NotificationCategory AccessibilityEventInfo::GetNotificationInfo() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] category_[%{public}d]", __func__, category_);
|
||||
return category_;
|
||||
}
|
||||
|
||||
void AccessibilityEventInfo::SetPageId(const int pageId)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] pageId[%{public}d]", __func__, pageId);
|
||||
pageId_ = pageId;
|
||||
}
|
||||
|
||||
int AccessibilityEventInfo::GetPageId() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] pageId_[%{public}d]", __func__, pageId_);
|
||||
return pageId_;
|
||||
}
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
@ -0,0 +1,221 @@
|
||||
/*
|
||||
* 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 "accessibility_interaction_operation_callback_proxy.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_types.h"
|
||||
#include "iremote_object.h"
|
||||
#include "parcel_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
AccessibilityInteractionOperationCallbackProxy::AccessibilityInteractionOperationCallbackProxy(
|
||||
const sptr<IRemoteObject> &impl) : IRemoteProxy<IAccessibilityInteractionOperationCallback>(impl)
|
||||
{}
|
||||
|
||||
AccessibilityInteractionOperationCallbackProxy::~AccessibilityInteractionOperationCallbackProxy()
|
||||
{}
|
||||
bool AccessibilityInteractionOperationCallbackProxy::WriteInterfaceToken(MessageParcel &data)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
if (!data.WriteInterfaceToken(AccessibilityInteractionOperationCallbackProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("write interface token failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationCallbackProxy::SetSearchElementInfoByAccessibilityIdResult(
|
||||
const std::vector<AccessibilityElementInfo> &infos, const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!WriteParcelableVector(infos, data)) {
|
||||
HILOG_ERROR("write failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write requestId", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IAccessibilityInteractionOperationCallback::Message::SET_RESULT_BY_ACCESSIBILITY_ID),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("SearchAccessibilityInfoByAccessibility fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationCallbackProxy::SetSearchElementInfoByTextResult(
|
||||
const std::vector<AccessibilityElementInfo> &infos, const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!WriteParcelableVector(infos, data)) {
|
||||
HILOG_ERROR("write failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write requestId", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IAccessibilityInteractionOperationCallback::Message::SET_RESULT_BY_TEXT),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("SearchAccessibilityInfoByAccessibility fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationCallbackProxy::SetFindFocusedElementInfoResult(
|
||||
const AccessibilityElementInfo &info, const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&info)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write info", __func__);
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write requestId", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IAccessibilityInteractionOperationCallback::Message::SET_RESULT_FOCUSED_INFO),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("SetFindFocusedElementInfo fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationCallbackProxy::SetFocusMoveSearchResult(const AccessibilityElementInfo &info,
|
||||
const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&info)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write info", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write requestId", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IAccessibilityInteractionOperationCallback::Message::SET_RESULT_FOCUS_MOVE),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("SetFocusMoveSearchResult fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationCallbackProxy::SetPerformActionResult(const bool succeeded, const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteBool(succeeded)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write succeeded", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write requestId", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IAccessibilityInteractionOperationCallback::Message::SET_RESULT_PERFORM_ACTION),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("SetPerformActionResult fail, error: %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool AccessibilityInteractionOperationCallbackProxy::WriteParcelableVector(const std::vector<T> &parcelableVector,
|
||||
Parcel &reply)
|
||||
{
|
||||
if (!reply.WriteInt32(parcelableVector.size())) {
|
||||
HILOG_ERROR("write ParcelableVector failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto &parcelable : parcelableVector) {
|
||||
if (!reply.WriteParcelable(&parcelable)) {
|
||||
HILOG_ERROR("write ParcelableVector failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* 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 <vector>
|
||||
#include "accessibility_interaction_operation_callback_stub.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "ipc_types.h"
|
||||
#include "iremote_object.h"
|
||||
#include "accessibility_errorcode.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
AccessibilityInteractionOperationCallbackStub::AccessibilityInteractionOperationCallbackStub()
|
||||
{
|
||||
memberFuncMap_[static_cast<uint32_t>(
|
||||
IAccessibilityInteractionOperationCallback::Message::SET_RESULT_BY_ACCESSIBILITY_ID)] =
|
||||
&AccessibilityInteractionOperationCallbackStub::HandleSetSearchElementInfoByAccessibilityIdResult;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibilityInteractionOperationCallback::Message::SET_RESULT_BY_TEXT)] =
|
||||
&AccessibilityInteractionOperationCallbackStub::HandleSetSearchElementInfoByTextResult;
|
||||
memberFuncMap_[static_cast<uint32_t>(
|
||||
IAccessibilityInteractionOperationCallback::Message::SET_RESULT_FOCUSED_INFO)] =
|
||||
&AccessibilityInteractionOperationCallbackStub::HandleSetFindFocusedElementInfoResult;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibilityInteractionOperationCallback::Message::SET_RESULT_FOCUS_MOVE)] =
|
||||
&AccessibilityInteractionOperationCallbackStub::HandleSetFocusMoveSearchResult;
|
||||
memberFuncMap_[static_cast<uint32_t>(
|
||||
IAccessibilityInteractionOperationCallback::Message::SET_RESULT_PERFORM_ACTION)] =
|
||||
&AccessibilityInteractionOperationCallbackStub::HandleSetPerformActionResult;
|
||||
}
|
||||
|
||||
AccessibilityInteractionOperationCallbackStub::~AccessibilityInteractionOperationCallbackStub()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
memberFuncMap_.clear();
|
||||
}
|
||||
|
||||
int AccessibilityInteractionOperationCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
HILOG_DEBUG("AccessibilityInteractionOperationCallbackStub::OnRemoteRequest, cmd = %d, flags= %d",
|
||||
code, option.GetFlags());
|
||||
std::u16string descriptor = AccessibilityInteractionOperationCallbackStub::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
|
||||
if (descriptor != remoteDescriptor) {
|
||||
HILOG_INFO("local descriptor is not equal to remote");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
auto memFunc = memberFuncMap_.find(code);
|
||||
if (memFunc != memberFuncMap_.end()) {
|
||||
auto func = memFunc->second;
|
||||
if (func != nullptr) {
|
||||
return (this->*func)(data,reply);
|
||||
}
|
||||
}
|
||||
HILOG_WARN("AccessibilityInteractionOperationCallbackStub::OnRemoteRequest, default case, need check.");
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
ErrCode AccessibilityInteractionOperationCallbackStub::HandleSetSearchElementInfoByAccessibilityIdResult(
|
||||
MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
std::vector<AccessibilityElementInfo> infos{};
|
||||
int32_t accessibilityInfosize = data.ReadInt32();
|
||||
for (int i = 0; i< accessibilityInfosize; i++) {
|
||||
std::shared_ptr<AccessibilityElementInfo> accessibilityInfo(data.ReadParcelable<AccessibilityElementInfo>());
|
||||
if (!accessibilityInfo) {
|
||||
HILOG_ERROR("ReadParcelable<accessibilityInfo> failed");
|
||||
}
|
||||
infos.emplace_back(*accessibilityInfo);
|
||||
}
|
||||
int requestId = data.ReadInt32();
|
||||
|
||||
SetSearchElementInfoByAccessibilityIdResult(infos, requestId);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityInteractionOperationCallbackStub::HandleSetSearchElementInfoByTextResult(
|
||||
MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
std::vector<AccessibilityElementInfo> infos{};
|
||||
int32_t accessibilityInfosize = data.ReadInt32();
|
||||
for (int i = 0; i< accessibilityInfosize; i++) {
|
||||
std::shared_ptr<AccessibilityElementInfo> accessibilityInfo(data.ReadParcelable<AccessibilityElementInfo>());
|
||||
if (!accessibilityInfo) {
|
||||
HILOG_ERROR("ReadParcelable<accessibilityInfo> failed");
|
||||
}
|
||||
infos.emplace_back(*accessibilityInfo);
|
||||
}
|
||||
int requestId = data.ReadInt32();
|
||||
|
||||
SetSearchElementInfoByTextResult(infos, requestId);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityInteractionOperationCallbackStub::HandleSetFindFocusedElementInfoResult(MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
std::shared_ptr<AccessibilityElementInfo> info(data.ReadParcelable<AccessibilityElementInfo>());
|
||||
if (!info) {
|
||||
HILOG_ERROR("ReadParcelable<AccessibilityElementInfo> failed");
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
int requestId = data.ReadInt32();
|
||||
|
||||
SetFindFocusedElementInfoResult(*info, requestId);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityInteractionOperationCallbackStub::HandleSetFocusMoveSearchResult(MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
std::shared_ptr<AccessibilityElementInfo> info(data.ReadParcelable<AccessibilityElementInfo>());
|
||||
if (!info) {
|
||||
HILOG_ERROR("ReadParcelable<AccessibilityElementInfo> failed");
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
int requestId = data.ReadInt32();
|
||||
|
||||
SetFocusMoveSearchResult(*info, requestId);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityInteractionOperationCallbackStub::HandleSetPerformActionResult(MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
bool succeeded = data.ReadBool();
|
||||
int requestId = data.ReadInt32();
|
||||
|
||||
SetPerformActionResult(succeeded, requestId);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
@ -0,0 +1,325 @@
|
||||
/*
|
||||
* 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 "accessibility_interaction_operation_proxy.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_types.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
AccessibilityInteractionOperationProxy::AccessibilityInteractionOperationProxy(
|
||||
const sptr<IRemoteObject> &impl) : IRemoteProxy<IAccessibilityInteractionOperation>(impl)
|
||||
{}
|
||||
|
||||
AccessibilityInteractionOperationProxy::~AccessibilityInteractionOperationProxy()
|
||||
{}
|
||||
|
||||
bool AccessibilityInteractionOperationProxy::WriteInterfaceToken(MessageParcel &data)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
if (!data.WriteInterfaceToken(AccessibilityInteractionOperationProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("write interface token failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationProxy::SearchElementInfoByAccessibilityId(const long elementId,
|
||||
const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback, const int mode)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(elementId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write parcelable elementId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write parcelable requestId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("%{public}s fail, connection write parcelable callback error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(mode)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write parcelable mode error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(AccessibilityInteractionOperationProxy::Message::SEARCH_BY_ACCESSIBILITY_ID),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("SearchAccessibilityInfo fail, error: %d", error);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationProxy::SearchElementInfosByText(const long elementId,
|
||||
const std::string &text,
|
||||
const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(elementId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write parcelable elementId error", __func__);
|
||||
return;
|
||||
}
|
||||
if (!data.WriteString(text)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write text error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write requestId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("%{public}s fail, connection write callback error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(AccessibilityInteractionOperationProxy::Message::SEARCH_BY_TEXT),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("SearchElementInfosByText fail, error: %d", error);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
void AccessibilityInteractionOperationProxy::FindFocusedElementInfo(const long elementId,
|
||||
const int focusType, const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(elementId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write elementId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(focusType)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write focusType error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write requestId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("%{public}s fail, connection write callback error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(AccessibilityInteractionOperationProxy::Message::FIND_FOCUSED_INFO),data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("FindFocusedElementInfo fail, error: %d", error);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationProxy::FocusMoveSearch(const long elementId,
|
||||
const int direction, const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(elementId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write elementId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(direction)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write focusType error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write requestId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("%{public}s fail, connection write callback error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(AccessibilityInteractionOperationProxy::Message::FOCUS_FIND),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("FindFocusedElementInfo fail, error: %d", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationProxy::PerformAction(const long elementId, const int action,
|
||||
const std::map<std::string, std::string> arguments, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(elementId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write elementId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(action)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write focusType error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
auto iter = arguments.begin();
|
||||
std::vector<std::string> argumentKey;
|
||||
std::vector<std::string> argumentValue;
|
||||
while(iter != arguments.end()) {
|
||||
argumentKey.push_back(iter->first);
|
||||
argumentValue.push_back(iter->second);
|
||||
iter++;
|
||||
}
|
||||
|
||||
if (!data.WriteStringVector(argumentKey)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write argumentKey error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteStringVector(argumentValue)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write argumentValue error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write requestId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("%{public}s fail, connection write callback error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(
|
||||
AccessibilityInteractionOperationProxy::Message::PERFORM_ACTION),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("PerformAction fail, error: %d", error);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationProxy::ClearFocus()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(AccessibilityInteractionOperationProxy::Message::CLEAR_FOCUS),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("PerformAction fail, error: %d", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationProxy::OutsideTouch()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(AccessibilityInteractionOperationProxy::Message::OUTSIDE_TOUCH),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("PerformAction fail, error: %d", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
@ -0,0 +1,413 @@
|
||||
/*
|
||||
* 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 "accessibility_interaction_operation_callback_proxy.h"
|
||||
#include "accessibility_interaction_operation_callback_stub.h"
|
||||
#include "accessibility_interaction_operation_stub.h"
|
||||
#include "accessibility_system_ability_client.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "ipc_types.h"
|
||||
#include "iremote_object.h"
|
||||
#include "parcel_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
std::map<const int, const sptr<IAccessibilityInteractionOperationCallback>>
|
||||
AccessibilityInteractionOperationStub::aaCallbacks_ = {};
|
||||
AccessibilityInteractionOperationStub::AccessibilityInteractionOperationStub()
|
||||
{
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibilityInteractionOperation::Message::SEARCH_BY_ACCESSIBILITY_ID)] =
|
||||
&AccessibilityInteractionOperationStub::HandleSearchElementInfoByAccessibilityId;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibilityInteractionOperation::Message::SEARCH_BY_TEXT)] =
|
||||
&AccessibilityInteractionOperationStub::HandleSearchElementInfosByText;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibilityInteractionOperation::Message::FIND_FOCUSED_INFO)] =
|
||||
&AccessibilityInteractionOperationStub::HandleFindFocusedElementInfo;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibilityInteractionOperation::Message::FOCUS_FIND)] =
|
||||
&AccessibilityInteractionOperationStub::HandleFocusFind;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibilityInteractionOperation::Message::PERFORM_ACTION)] =
|
||||
&AccessibilityInteractionOperationStub::HandlePerformAction;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibilityInteractionOperation::Message::CLEAR_FOCUS)] =
|
||||
&AccessibilityInteractionOperationStub::HandleClearFocus;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibilityInteractionOperation::Message::OUTSIDE_TOUCH)] =
|
||||
&AccessibilityInteractionOperationStub::HandleOutsideTouch;
|
||||
}
|
||||
|
||||
AccessibilityInteractionOperationStub::~AccessibilityInteractionOperationStub()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
memberFuncMap_.clear();
|
||||
}
|
||||
|
||||
int AccessibilityInteractionOperationStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
HILOG_DEBUG("AccessibilityInteractionOperationStub::OnRemoteRequest,cmd = %d,flags= %d", code, option.GetFlags());
|
||||
std::u16string descriptor = AccessibilityInteractionOperationStub::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
|
||||
if (descriptor != remoteDescriptor) {
|
||||
HILOG_INFO("local descriptor is not equal to remote");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
auto memFunc = memberFuncMap_.find(code);
|
||||
if (memFunc != memberFuncMap_.end()) {
|
||||
auto func = memFunc->second;
|
||||
if (func != nullptr) {
|
||||
return (this->*func)(data,reply);
|
||||
}
|
||||
}
|
||||
HILOG_WARN("AccessibilityInteractionOperationStub::OnRemoteRequest, default case, need check.");
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
ErrCode AccessibilityInteractionOperationStub::HandleSearchElementInfoByAccessibilityId(MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
long elementId = data.ReadInt32();
|
||||
int requestId = data.ReadInt32();
|
||||
sptr<IRemoteObject> obj = data.ReadRemoteObject();
|
||||
|
||||
sptr<IAccessibilityInteractionOperationCallback> callback =
|
||||
new AccessibilityInteractionOperationCallbackProxy(obj);
|
||||
int mode = data.ReadInt32();
|
||||
SearchElementInfoByAccessibilityId(elementId, requestId, callback, mode);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityInteractionOperationStub::HandleSearchElementInfosByText(MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
long elementId = data.ReadInt32();
|
||||
std::string text = data.ReadString();
|
||||
int requestId = data.ReadInt32();
|
||||
sptr<IRemoteObject> obj = data.ReadRemoteObject();
|
||||
|
||||
sptr<IAccessibilityInteractionOperationCallback> callback =
|
||||
new AccessibilityInteractionOperationCallbackProxy(obj);
|
||||
SearchElementInfosByText(elementId, text, requestId, callback);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityInteractionOperationStub::HandleFindFocusedElementInfo(MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
long elementId = data.ReadInt32();
|
||||
int focusType = data.ReadInt32();
|
||||
int requestId = data.ReadInt32();
|
||||
sptr<IRemoteObject> obj = data.ReadRemoteObject();
|
||||
|
||||
sptr<IAccessibilityInteractionOperationCallback> callback =
|
||||
new AccessibilityInteractionOperationCallbackProxy(obj);
|
||||
FindFocusedElementInfo(elementId, focusType, requestId, callback);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityInteractionOperationStub::HandleFocusFind(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
long elementId = data.ReadInt32();
|
||||
int direction = data.ReadInt32();
|
||||
int requestId = data.ReadInt32();
|
||||
sptr<IRemoteObject> obj = data.ReadRemoteObject();
|
||||
|
||||
sptr<IAccessibilityInteractionOperationCallback> callback =
|
||||
new AccessibilityInteractionOperationCallbackProxy(obj);
|
||||
FocusMoveSearch(elementId, direction, requestId, callback);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityInteractionOperationStub::HandlePerformAction(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
std::vector<std::string> argumentKey{};
|
||||
std::vector<std::string> argumentValue{};
|
||||
long elementId = data.ReadInt32();
|
||||
int action = data.ReadInt32();
|
||||
if (!data.ReadStringVector(&argumentKey)) {
|
||||
return ERROR;
|
||||
}
|
||||
if (!data.ReadStringVector(&argumentValue)) {
|
||||
return ERROR;
|
||||
}
|
||||
if (argumentKey.size() != argumentValue.size()) {
|
||||
return ERROR;
|
||||
}
|
||||
std::map<std::string, std::string> arguments{};
|
||||
for (unsigned int i = 0;i < argumentKey.size(); i++) {
|
||||
arguments.insert(std::pair<std::string, std::string>(argumentKey[i],argumentValue[i]));
|
||||
}
|
||||
int requestId = data.ReadInt32();
|
||||
sptr<IRemoteObject> obj = data.ReadRemoteObject();
|
||||
|
||||
sptr<IAccessibilityInteractionOperationCallback> callback =
|
||||
new AccessibilityInteractionOperationCallbackProxy(obj);
|
||||
PerformAction(elementId, action, arguments, requestId, callback);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityInteractionOperationStub::HandleClearFocus(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
ClearFocus();
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibilityInteractionOperationStub::HandleOutsideTouch(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
OutsideTouch();
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::SearchElementInfoByAccessibilityId(const long elementId,
|
||||
const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback, const int mode)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
|
||||
AccessibilityInteractionOperationCallback *tempCallback = new CallbackImpl(requestId,
|
||||
CallbackImpl::CALLBACK_BY_ACCESSIBILITY_ID);
|
||||
aaCallbacks_.insert(
|
||||
std::pair<const int, const sptr<IAccessibilityInteractionOperationCallback>>(requestId, callback));
|
||||
std::shared_ptr<AccessibilityInteractionOperation> obj =
|
||||
AccessibilitySystemAbilityClient::GetInstance()->GetInteractionObject(GetWindowId());
|
||||
if (obj != nullptr) {
|
||||
obj->SearchElementInfoByAccessibilityId(elementId, requestId, *tempCallback, mode);
|
||||
} else {
|
||||
HILOG_DEBUG("%{public}s Can not find interaction object", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::SearchElementInfosByText(const long elementId,
|
||||
const std::string &text,
|
||||
const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
|
||||
AccessibilityInteractionOperationCallback *tempCallback = new CallbackImpl(requestId,
|
||||
CallbackImpl::CALLBACK_BY_TEXT);
|
||||
aaCallbacks_.insert(
|
||||
std::pair<const int, const sptr<IAccessibilityInteractionOperationCallback>>(requestId, callback));
|
||||
std::shared_ptr<AccessibilityInteractionOperation> obj =
|
||||
AccessibilitySystemAbilityClient::GetInstance()->GetInteractionObject(GetWindowId());
|
||||
if (obj != nullptr) {
|
||||
obj->SearchElementInfosByText(elementId, text, requestId, *tempCallback);
|
||||
} else {
|
||||
HILOG_DEBUG("%{public}s Can not find interaction object", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::FindFocusedElementInfo(const long elementId,
|
||||
const int focusType, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
|
||||
AccessibilityInteractionOperationCallback *tempCallback = new CallbackImpl(requestId,
|
||||
CallbackImpl::CALLBACK_FIND_FOCUS);
|
||||
aaCallbacks_.insert(
|
||||
std::pair<const int, const sptr<IAccessibilityInteractionOperationCallback>>(requestId, callback));
|
||||
std::shared_ptr<AccessibilityInteractionOperation> obj =
|
||||
AccessibilitySystemAbilityClient::GetInstance()->GetInteractionObject(GetWindowId());
|
||||
if (obj != nullptr) {
|
||||
obj->FindFocusedElementInfo(elementId, focusType, requestId, *tempCallback);
|
||||
} else {
|
||||
HILOG_DEBUG("%{public}s Can not find interaction object", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::FocusMoveSearch(const long elementId,
|
||||
const int direction, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
|
||||
AccessibilityInteractionOperationCallback *tempCallback = new CallbackImpl(requestId,
|
||||
CallbackImpl::CALLBACK_BY_FOCUS_MOVE);
|
||||
aaCallbacks_.insert(
|
||||
std::pair<const int, const sptr<IAccessibilityInteractionOperationCallback>>(requestId, callback));
|
||||
std::shared_ptr<AccessibilityInteractionOperation> obj =
|
||||
AccessibilitySystemAbilityClient::GetInstance()->GetInteractionObject(GetWindowId());
|
||||
if (obj != nullptr) {
|
||||
obj->FocusMoveSearch(elementId, direction, requestId, *tempCallback);
|
||||
} else {
|
||||
HILOG_DEBUG("%{public}s Can not find interaction object", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::PerformAction(const long elementId,
|
||||
const int action, const std::map<std::string, std::string> actionArguments,
|
||||
int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
|
||||
AccessibilityInteractionOperationCallback *tempCallback = new CallbackImpl(requestId,
|
||||
CallbackImpl::CALLBACK_PERFORM_ACTION);
|
||||
aaCallbacks_.insert(
|
||||
std::pair<const int, const sptr<IAccessibilityInteractionOperationCallback>>(requestId, callback));
|
||||
std::shared_ptr<AccessibilityInteractionOperation> obj =
|
||||
AccessibilitySystemAbilityClient::GetInstance()->GetInteractionObject(GetWindowId());
|
||||
if (obj != nullptr) {
|
||||
obj->PerformAction(elementId, action, actionArguments, requestId, *tempCallback);
|
||||
} else {
|
||||
HILOG_DEBUG("%{public}s Can not find interaction object", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::ClearFocus()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
std::shared_ptr<AccessibilityInteractionOperation> obj =
|
||||
AccessibilitySystemAbilityClient::GetInstance()->GetInteractionObject(GetWindowId());
|
||||
if (obj != nullptr) {
|
||||
obj->ClearFocus();
|
||||
} else {
|
||||
HILOG_DEBUG("%{public}s Can not find interaction object", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::OutsideTouch()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
std::shared_ptr<AccessibilityInteractionOperation> obj =
|
||||
AccessibilitySystemAbilityClient::GetInstance()->GetInteractionObject(GetWindowId());
|
||||
if (obj != nullptr) {
|
||||
obj->OutsideTouch();
|
||||
} else {
|
||||
HILOG_DEBUG("%{public}s Can not find interaction object", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
AccessibilityInteractionOperationStub::CallbackImpl::CallbackImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AccessibilityInteractionOperationStub::CallbackImpl::CallbackImpl(const int requestId,
|
||||
CALL_API_NUM callNum)
|
||||
{
|
||||
requestId_ = requestId;
|
||||
callNum_ = callNum;
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::CallbackImpl::SetSearchElementInfoByAccessibilityIdResult(
|
||||
const std::list<AccessibilityElementInfo> &infos, const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
std::vector<AccessibilityElementInfo> myInfos = TranslateListToVector(infos);
|
||||
auto callback = GetAACallbackList().find(requestId);
|
||||
if (callback != GetAACallbackList().end() && callback->second != nullptr) {
|
||||
callback->second->SetSearchElementInfoByAccessibilityIdResult(myInfos, requestId);
|
||||
} else {
|
||||
HILOG_DEBUG("%s Can't find the callback [requestId:%d]", __func__, requestId);
|
||||
}
|
||||
RemoveAACallbackList(requestId);
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::CallbackImpl::SetSearchElementInfoByTextResult(
|
||||
const std::list<AccessibilityElementInfo> &infos, const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
std::vector<AccessibilityElementInfo> myInfos = TranslateListToVector(infos);
|
||||
auto callback = GetAACallbackList().find(requestId);
|
||||
if (callback != GetAACallbackList().end() && callback->second != nullptr) {
|
||||
callback->second->SetSearchElementInfoByTextResult(myInfos, requestId);
|
||||
} else {
|
||||
HILOG_DEBUG("%s Can't find the callback [requestId:%d]", __func__, requestId);
|
||||
}
|
||||
RemoveAACallbackList(requestId);
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::CallbackImpl::SetFindFocusedElementInfoResult(
|
||||
const AccessibilityElementInfo &info, const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
auto callback = GetAACallbackList().find(requestId);
|
||||
if (callback != GetAACallbackList().end() && callback->second != nullptr) {
|
||||
callback->second->SetFindFocusedElementInfoResult(info, requestId);
|
||||
} else {
|
||||
HILOG_DEBUG("%s Can't find the callback [requestId:%d]", __func__, requestId);
|
||||
}
|
||||
RemoveAACallbackList(requestId);
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::CallbackImpl::SetFocusMoveSearchResult(
|
||||
const AccessibilityElementInfo &info, const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
auto callback = GetAACallbackList().find(requestId);
|
||||
if (callback != GetAACallbackList().end() && callback->second != nullptr) {
|
||||
callback->second->SetFocusMoveSearchResult(info, requestId);
|
||||
} else {
|
||||
HILOG_DEBUG("%s Can't find the callback [requestId:%d]", __func__, requestId);
|
||||
}
|
||||
RemoveAACallbackList(requestId);
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::CallbackImpl::SetPerformActionResult(
|
||||
const bool succeeded, const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
auto callback = GetAACallbackList().find(requestId);
|
||||
if (callback != GetAACallbackList().end() && callback->second != nullptr) {
|
||||
callback->second->SetPerformActionResult(succeeded, requestId);
|
||||
} else {
|
||||
HILOG_DEBUG("%s Can't find the callback [requestId:%d]", __func__, requestId);
|
||||
}
|
||||
RemoveAACallbackList(requestId);
|
||||
}
|
||||
|
||||
std::map<const int, const sptr<IAccessibilityInteractionOperationCallback>>
|
||||
AccessibilityInteractionOperationStub::CallbackImpl::GetAACallbackList()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
return aaCallbacks_;
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::CallbackImpl::RemoveAACallbackList(int requestId)
|
||||
{
|
||||
for (auto iter = aaCallbacks_.begin(); iter != aaCallbacks_.end();) {
|
||||
if (iter->first == requestId) {
|
||||
aaCallbacks_.erase(iter++);
|
||||
return;
|
||||
} else {
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("%{public}s Not find requestID[%{public}d]", __func__, requestId);
|
||||
}
|
||||
|
||||
void AccessibilityInteractionOperationStub::SetWindowId(int windowId)
|
||||
{
|
||||
windowId_ = windowId;
|
||||
}
|
||||
|
||||
int AccessibilityInteractionOperationStub::GetWindowId()
|
||||
{
|
||||
return windowId_;
|
||||
}
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
514
frameworks/asacfwk/src/accessibility_operator.cpp
Normal file
514
frameworks/asacfwk/src/accessibility_operator.cpp
Normal file
@ -0,0 +1,514 @@
|
||||
/*
|
||||
* 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 "accessibility_operator.h"
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
std::map<int, sptr<IAccessibleAbilityChannel>> AccessibilityOperator::channels_ = {};
|
||||
std::vector<sptr<AccessibilityOperator>> AccessibilityOperator::instances_ = {};
|
||||
std::recursive_mutex AccessibilityOperator::mutex_ = {};
|
||||
int AccessibilityOperator::requestId_ = 0;
|
||||
|
||||
AccessibilityOperator::AccessibilityOperator()
|
||||
{
|
||||
performActionResult_ = false;
|
||||
}
|
||||
|
||||
AccessibilityOperator &AccessibilityOperator::GetInstance()
|
||||
{
|
||||
std::thread::id tid = std::this_thread::get_id();
|
||||
return GetInstanceForThread(tid);
|
||||
}
|
||||
|
||||
AccessibilityOperator &AccessibilityOperator::GetInstanceForThread(std::thread::id threadId)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] threadId[%{public}u]", __func__, (*(uint32_t*)&threadId));
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (instances_.size() >= MAX_INSTANCE) {
|
||||
for (auto iter = instances_.begin(); iter != instances_.end();iter++) {
|
||||
if (iter->GetRefPtr() != nullptr &&
|
||||
iter->GetRefPtr()->GetOperationStatus()) {
|
||||
HILOG_DEBUG("[%{public}s] complete instance is removed", __func__);
|
||||
instances_.erase(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HILOG_DEBUG("[%{public}s] new instance instanceSize[%{public}u]", __func__, instances_.size());
|
||||
sptr<AccessibilityOperator> inst(new AccessibilityOperator());
|
||||
instances_.push_back(inst);
|
||||
|
||||
HILOG_DEBUG("[%{public}s] End instanceSize[%{public}u]", __func__, instances_.size());
|
||||
return *(inst.GetRefPtr());
|
||||
}
|
||||
|
||||
sptr<IAccessibleAbilityChannel> AccessibilityOperator::GetChannel(int channelId)
|
||||
{
|
||||
auto channel = channels_.find(channelId);
|
||||
if (channel != channels_.end()) {
|
||||
HILOG_DEBUG("[%{public}s] Find aams [channelId:%{public}d]", __func__, channelId);
|
||||
return channel->second;
|
||||
} else {
|
||||
HILOG_ERROR("[%{public}s] Failed to find aams [channelId:%{public}d]", __func__, channelId);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool AccessibilityOperator::GetOperationStatus()
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] [completed_:%{public}d]", __func__, completed_);
|
||||
return completed_;
|
||||
}
|
||||
|
||||
void AccessibilityOperator::SetOperationStatus(bool status)
|
||||
{
|
||||
completed_ = status;
|
||||
}
|
||||
|
||||
void AccessibilityOperator::AddChannel(const int channelId, const sptr<IAccessibleAbilityChannel> &channel)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] Add connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
int tempId = *(const_cast<int *>(&channelId));
|
||||
for (auto iter = channels_.begin(); iter != channels_.end(); iter++) {
|
||||
if (iter->first == tempId) {
|
||||
HILOG_ERROR("[%{public}s] Connection to aams [channelId:%{public}d] is exited", __func__, channelId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
sptr<IAccessibleAbilityChannel> tempChanel = const_cast<sptr<IAccessibleAbilityChannel> &>(channel);
|
||||
channels_.insert(std::pair<int, sptr<IAccessibleAbilityChannel>>(tempId, tempChanel));
|
||||
}
|
||||
|
||||
void AccessibilityOperator::RemoveChannel(int channelId)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] Remove connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
auto iter = channels_.find(channelId);
|
||||
if (iter != channels_.end()) {
|
||||
channels_.erase(iter);
|
||||
} else {
|
||||
HILOG_DEBUG("[%{public}s] Failed to remove connection with aams [channelId:%{public}d]", __func__, channelId);
|
||||
}
|
||||
}
|
||||
|
||||
bool AccessibilityOperator::GetRoot(int channelId, AccessibilityElementInfo &elementInfo)
|
||||
{
|
||||
AccessibilityElementInfo element {};
|
||||
std::vector<AccessibilityElementInfo> elementInfos {};
|
||||
bool result = SearchElementInfosByAccessibilityId(channelId, ACTIVE_WINDOW_ID, NONE_ID, 0, elementInfos);
|
||||
for (auto& info : elementInfos) {
|
||||
HILOG_DEBUG("[%{public}s] element [elementSize:%{public}d]", __func__, accessibilityInfosResult_.size());
|
||||
elementInfo = info;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<AccessibilityWindowInfo> AccessibilityOperator::GetWindows(int channelId)
|
||||
{
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
auto windows = connectService->GetWindows();
|
||||
for (auto &window : windows) {
|
||||
window.SetChannelId(channelId);
|
||||
}
|
||||
return windows;
|
||||
} else {
|
||||
HILOG_ERROR("[%{public}s] Failed to connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
return windows_;
|
||||
}
|
||||
}
|
||||
|
||||
bool AccessibilityOperator::SearchElementInfosByAccessibilityId(int channelId,
|
||||
int accessibilityWindowId, int elementId, int mode, std::vector<AccessibilityElementInfo>& elementInfos)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
bool result = false;
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
int requestId = CreateRequestId();
|
||||
HILOG_DEBUG("[%{public}s] search element info [channelId:%{public}d] [requestId:%{public}d]", __func__,
|
||||
channelId, requestId);
|
||||
result = connectService->SearchElementInfoByAccessibilityId(accessibilityWindowId, elementId, requestId,
|
||||
this, mode);
|
||||
if (!result) {
|
||||
return result;
|
||||
}
|
||||
HILOG_DEBUG("[%{public}s] search element info End[channelId:%{public}d] [requestId:%{public}d]", __func__,
|
||||
channelId, requestId);
|
||||
if (!WaitForResultTimedLocked(requestId)) {
|
||||
HILOG_ERROR("[%{public}s] Failed to wait result", __func__);
|
||||
result = false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("[%{public}s] search element info OK [channelId:%{public}d]", __func__, channelId);
|
||||
for (auto& info : accessibilityInfosResult_) {
|
||||
info.SetChannelId(channelId);
|
||||
}
|
||||
completed_ = true;
|
||||
HILOG_DEBUG("[%{public}s] search element info End[size:%{public}d]", __func__, accessibilityInfosResult_.size());
|
||||
elementInfos = accessibilityInfosResult_;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AccessibilityOperator::SearchElementInfosByText(int channelId, int accessibilityWindowId,
|
||||
int elementId, const std::string &text,std::vector<AccessibilityElementInfo>& elementInfos)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
bool result = false;
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
int requestId = CreateRequestId();
|
||||
result = connectService->SearchElementInfosByText(accessibilityWindowId, elementId, text, requestId,
|
||||
this);
|
||||
if (!result) {
|
||||
return result;
|
||||
}
|
||||
if (!WaitForResultTimedLocked(requestId)) {
|
||||
HILOG_ERROR("[%{public}s] Failed to wait result", __func__);
|
||||
result = false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& info : accessibilityInfosResult_) {
|
||||
info.SetChannelId(channelId);
|
||||
}
|
||||
completed_ = true;
|
||||
HILOG_DEBUG("[%{public}s] [size:%{public}d] end", __func__, accessibilityInfosResult_.size());
|
||||
elementInfos = accessibilityInfosResult_;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AccessibilityOperator::FindFocusedElementInfo(int channelId, int accessibilityWindowId,
|
||||
int elementId, int focusType, AccessibilityElementInfo& elementInfo)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
bool result = false;
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
int requestId = CreateRequestId();
|
||||
result = connectService->FindFocusedElementInfo(accessibilityWindowId, elementId, focusType, requestId,
|
||||
this);
|
||||
if (!result) {
|
||||
return result;
|
||||
}
|
||||
HILOG_DEBUG(
|
||||
"FindFocusedElementInfo channelId[%{public}d] elementId[%{public}d],\
|
||||
focusType[%{public}d] requestId[%{public}d]",
|
||||
channelId, accessibilityWindowId, elementId, focusType);
|
||||
if (!WaitForResultTimedLocked(requestId)) {
|
||||
HILOG_ERROR("[%{public}s] Failed to wait result", __func__);
|
||||
result = false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
accessibilityInfoResult_.SetChannelId(channelId);
|
||||
completed_ = true;
|
||||
HILOG_DEBUG("[%{public}s] [channelId:%{public}d] end", __func__, channelId);
|
||||
elementInfo = accessibilityInfoResult_;
|
||||
if (accessibilityInfoResult_.GetWindowId() == 0 &&
|
||||
accessibilityInfoResult_.GetAccessibilityId() == 0) {
|
||||
HILOG_DEBUG("[%{public}s] Can't find the component info", __func__);
|
||||
result = false;
|
||||
} else {
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AccessibilityOperator::FocusMoveSearch(int channelId, int accessibilityWindowId,
|
||||
int elementId, int direction, AccessibilityElementInfo& elementInfo)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
bool result = false;
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
int requestId = CreateRequestId();
|
||||
result = connectService->FocusMoveSearch(accessibilityWindowId, elementId, direction, requestId, this);
|
||||
if (!result) {
|
||||
return result;
|
||||
}
|
||||
if (!WaitForResultTimedLocked(requestId)) {
|
||||
HILOG_ERROR("[%{public}s] Failed to wait result", __func__);
|
||||
result = false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
accessibilityInfoResult_.SetChannelId(channelId);
|
||||
completed_ = true;
|
||||
HILOG_DEBUG("[%{public}s] [channelId:%{public}d] end", __func__, channelId);
|
||||
elementInfo = accessibilityInfoResult_;
|
||||
if (accessibilityInfoResult_.GetWindowId() == 0 &&
|
||||
accessibilityInfoResult_.GetAccessibilityId() == 0) {
|
||||
HILOG_DEBUG("[%{public}s] Can't find the component info", __func__);
|
||||
result = false;
|
||||
} else {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AccessibilityOperator::PerformAction(int channelId, int accessibilityWindowId,
|
||||
int elementId, int action, std::map<std::string, std::string> &actionArguments)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
int requestId = CreateRequestId();
|
||||
bool result = connectService->PerformAction(accessibilityWindowId, elementId, action, actionArguments,
|
||||
requestId,
|
||||
this);
|
||||
if (!result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!WaitForResultTimedLocked(requestId)) {
|
||||
HILOG_ERROR("[%{public}s] Failed to wait result", __func__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
completed_ = true;
|
||||
HILOG_DEBUG("[%{public}s] [channelId:%{public}d] end", __func__, channelId);
|
||||
return performActionResult_;
|
||||
}
|
||||
|
||||
void AccessibilityOperator::SetSearchElementInfoByAccessibilityIdResult(
|
||||
const std::vector<AccessibilityElementInfo> &infos, const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] Response [requestId:%{public}d]", __func__, requestId);
|
||||
responseId_ = requestId;
|
||||
for (auto iter = infos.begin(); iter != infos.end(); iter++) {
|
||||
HILOG_DEBUG("[%{public}s] Response", __func__);
|
||||
accessibilityInfosResult_.push_back(*iter);
|
||||
}
|
||||
HILOG_DEBUG("[%{public}s] Response [requestId:%{public}d] end", __func__, requestId);
|
||||
}
|
||||
|
||||
void AccessibilityOperator::SetSearchElementInfoByTextResult(const std::vector<AccessibilityElementInfo> &infos,
|
||||
const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] Response [requestId:%{public}d]", __func__, requestId);
|
||||
responseId_ = requestId;
|
||||
for (auto iter = infos.begin(); iter != infos.end(); iter++) {
|
||||
accessibilityInfosResult_.push_back(*iter);
|
||||
}
|
||||
HILOG_DEBUG("[%{public}s] Response [requestId:%{public}d] end", __func__, requestId);
|
||||
}
|
||||
|
||||
void AccessibilityOperator::SetFindFocusedElementInfoResult(const AccessibilityElementInfo &info, const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] Response [requestId:%{public}d]", __func__, requestId);
|
||||
responseId_ = requestId;
|
||||
accessibilityInfoResult_ = info;
|
||||
HILOG_DEBUG("[%{public}s] Response [requestId:%{public}d] end", __func__, requestId);
|
||||
}
|
||||
|
||||
void AccessibilityOperator::SetFocusMoveSearchResult(const AccessibilityElementInfo &info, const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] Response [requestId:%{public}d]", __func__, requestId);
|
||||
responseId_ = requestId;
|
||||
accessibilityInfoResult_ = info;
|
||||
HILOG_DEBUG("[%{public}s] Response [requestId:%{public}d] end", __func__, requestId);
|
||||
}
|
||||
|
||||
void AccessibilityOperator::SetPerformActionResult(const bool succeeded, const int requestId)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] Response [requestId:%{public}d] result[%{public}d]", __func__, requestId, succeeded);
|
||||
performActionResult_ = succeeded;
|
||||
responseId_ = requestId;
|
||||
HILOG_DEBUG("[%{public}s] Response [requestId:%{public}d] end", __func__, requestId);
|
||||
}
|
||||
|
||||
bool AccessibilityOperator::WaitForResultTimedLocked(const int requestId)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
struct timeval getTime {};
|
||||
gettimeofday(&getTime, NULL);
|
||||
uint64_t startTime = getTime.tv_sec * SECOND_TO_MILLIS + getTime.tv_usec;
|
||||
HILOG_DEBUG("[%{public}s] element requestId[%{public}d]", __func__, requestId);
|
||||
|
||||
do {
|
||||
if (responseId_ == requestId) {
|
||||
return true;
|
||||
}
|
||||
gettimeofday(&getTime, NULL);
|
||||
uint64_t endTime = getTime.tv_sec * SECOND_TO_MILLIS + getTime.tv_usec;
|
||||
uint64_t waitTime = endTime - startTime;
|
||||
if (TIMEOUT_OPERATOR_MILLIS < waitTime) {
|
||||
completed_ = true;
|
||||
HILOG_ERROR("[%{public}s] Failed to wait requestId[%{public}d], responseId_[%{public}d]", __func__,
|
||||
requestId, responseId_);
|
||||
return false;
|
||||
}
|
||||
usleep(SLEEP_MILLIS);
|
||||
} while (true);
|
||||
HILOG_DEBUG("[%{public}s] Response [requestId:%{public}d] end", __func__, requestId);
|
||||
return true;
|
||||
}
|
||||
|
||||
int AccessibilityOperator::CreateRequestId()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
HILOG_INFO("[%{public}s] [requestId_:%{public}d]", __func__, requestId_);
|
||||
requestId_++;
|
||||
requestId_ = requestId_ % MAX_REQUEST;
|
||||
HILOG_INFO("[%{public}s] [requestId_:%{public}d] end", __func__, requestId_);
|
||||
return requestId_;
|
||||
}
|
||||
|
||||
bool AccessibilityOperator::PerformCommonAction(const int channelId, const int action)
|
||||
{
|
||||
HILOG_INFO("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
return connectService->PerformCommonAction(action);
|
||||
} else {
|
||||
HILOG_ERROR("[%{public}s] Failed to Get connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityOperator::DisableAbility(const int channelId)
|
||||
{
|
||||
HILOG_INFO("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
connectService->DisableAbility();
|
||||
} else {
|
||||
HILOG_ERROR("[%{public}s] Failed to Get connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityOperator::SetOnKeyPressEventResult(const int channelId, const bool handled, const int sequence)
|
||||
{
|
||||
HILOG_INFO("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
connectService->SetOnKeyPressEventResult(handled, sequence);
|
||||
} else {
|
||||
HILOG_ERROR("[%{public}s] Failed to Get connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
}
|
||||
}
|
||||
|
||||
float AccessibilityOperator::GetDisplayResizeScale(const int channelId, const int displayId)
|
||||
{
|
||||
HILOG_INFO("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
return connectService->GetDisplayResizeScale(displayId);
|
||||
} else {
|
||||
HILOG_ERROR("[%{public}s] Failed to Get connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
float AccessibilityOperator::GetDisplayResizeCenterX(const int channelId, const int displayId)
|
||||
{
|
||||
HILOG_INFO("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
return connectService->GetDisplayResizeCenterX(displayId);
|
||||
} else {
|
||||
HILOG_ERROR("[%{public}s] Failed to Get connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
float AccessibilityOperator::GetDisplayResizeCenterY(const int channelId, const int displayId)
|
||||
{
|
||||
HILOG_INFO("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
return connectService->GetDisplayResizeCenterY(displayId);
|
||||
} else {
|
||||
HILOG_ERROR("[%{public}s] Failed to Get connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Rect AccessibilityOperator::GetDisplayResizeRect(const int channelId, const int displayId)
|
||||
{
|
||||
HILOG_INFO("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
return connectService->GetDisplayResizeRect(displayId);
|
||||
} else {
|
||||
HILOG_ERROR("[%{public}s] Failed to Get connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
Rect rect {};
|
||||
return rect;
|
||||
}
|
||||
}
|
||||
|
||||
bool AccessibilityOperator::ResetDisplayResize(const int channelId, const int displayId, const bool animate)
|
||||
{
|
||||
HILOG_INFO("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
return connectService->ResetDisplayResize(displayId, animate);
|
||||
} else {
|
||||
HILOG_ERROR("[%{public}s] Failed to Get connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool AccessibilityOperator::SetDisplayResizeScaleAndCenter(const int channelId,
|
||||
const int displayId, const float scale, const float centerX,
|
||||
const float centerY, const bool animate)
|
||||
{
|
||||
HILOG_INFO("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
return connectService->SetDisplayResizeScaleAndCenter(displayId, scale, centerX,
|
||||
centerY, animate);
|
||||
} else {
|
||||
HILOG_ERROR("[%{public}s] Failed to Get connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityOperator::SendSimulateGesture(const int channelId,
|
||||
const int sequence, const std::vector<GesturePathDefine> &gestureSteps)
|
||||
{
|
||||
HILOG_INFO("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
connectService->SendSimulateGesture(sequence, gestureSteps);
|
||||
} else {
|
||||
HILOG_ERROR("[%{public}s] Failed to Get connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
}
|
||||
}
|
||||
|
||||
bool AccessibilityOperator::IsFingerprintGestureDetectionValid(const int channelId)
|
||||
{
|
||||
HILOG_INFO("[%{public}s] [channelId:%{public}d]", __func__, channelId);
|
||||
auto connectService = GetChannel(channelId);
|
||||
if (connectService != nullptr) {
|
||||
return connectService->IsFingerprintGestureDetectionValid();
|
||||
} else {
|
||||
HILOG_ERROR("[%{public}s] Failed to Get connection to aams [channelId:%{public}d]", __func__, channelId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
57
frameworks/asacfwk/src/accessibility_state_event.cpp
Normal file
57
frameworks/asacfwk/src/accessibility_state_event.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 "accessibility_state_event.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
AccessibilityStateEvent::AccessibilityStateEvent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AccessibilityStateEventType AccessibilityStateEvent::GetEventType() const
|
||||
{
|
||||
return eventType_;
|
||||
}
|
||||
|
||||
int AccessibilityStateEvent::GetEventResult() const
|
||||
{
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
std::string AccessibilityStateEvent::GetEventMsg() const
|
||||
{
|
||||
return describeEvent_;
|
||||
}
|
||||
|
||||
void AccessibilityStateEvent::SetEventType(const AccessibilityStateEventType eventType)
|
||||
{
|
||||
eventType_ = *(const_cast<AccessibilityStateEventType*>(&eventType));
|
||||
}
|
||||
|
||||
void AccessibilityStateEvent::SetEventResult(const int enabled)
|
||||
{
|
||||
enabled_ = enabled;
|
||||
}
|
||||
|
||||
void AccessibilityStateEvent::SetEventMsg(std::string &description)
|
||||
{
|
||||
describeEvent_ = description;
|
||||
}
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
576
frameworks/asacfwk/src/accessibility_system_ability_client.cpp
Normal file
576
frameworks/asacfwk/src/accessibility_system_ability_client.cpp
Normal file
@ -0,0 +1,576 @@
|
||||
/*
|
||||
* 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 "accessibility_system_ability_client.h"
|
||||
#include "ability_context.h"
|
||||
#include "accessible_ability_manager_service_proxy.h"
|
||||
#include "accessibility_interaction_operation.h"
|
||||
#include "accessible_ability_manager_service_state_stub.h"
|
||||
#include "accessibility_interaction_operation_stub.h"
|
||||
#include "dummy.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
using namespace OHOS::AppExecFwk;
|
||||
using namespace std;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
shared_ptr<AccessibilitySystemAbilityClient> AccessibilitySystemAbilityClient::instance_ = nullptr;
|
||||
|
||||
struct AccessibilitySystemAbilityClient::Impl {
|
||||
class DeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
DeathRecipient() = default;
|
||||
~DeathRecipient() = default;
|
||||
DISALLOW_COPY_AND_MOVE(DeathRecipient);
|
||||
|
||||
void OnRemoteDied(const wptr<IRemoteObject>& remote) {
|
||||
AccessibilitySystemAbilityClient::GetInstance()->ResetService(remote);
|
||||
}
|
||||
};
|
||||
sptr<IRemoteObject::DeathRecipient> deathRecipient_{};
|
||||
sptr<AccessibleAbilityManagerServiceStateStub> stateCallback_{};
|
||||
sptr<AccessibleAbilityManagerServiceClientProxy> serviceProxy_{};
|
||||
sptr<IAccessibleAbilityManagerServiceClient> GetService() {
|
||||
if (serviceProxy_ != nullptr) {
|
||||
return serviceProxy_;
|
||||
}
|
||||
|
||||
sptr<ISystemAbilityManager> samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (samgr == nullptr) {
|
||||
HILOG_ERROR("[%s] Failed to get ISystemAbilityManager", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> object = samgr->GetSystemAbility(ACCESSIBLE_ABILITY_MANAGER_SERVICE_ID);
|
||||
if (object == nullptr) {
|
||||
HILOG_ERROR("[%s]Get IAccessibleAbilityManagerServiceClient object from samgr failed", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (deathRecipient_ == nullptr) {
|
||||
deathRecipient_ = new DeathRecipient();
|
||||
}
|
||||
|
||||
if ((object->IsProxyObject()) && (!object->AddDeathRecipient(deathRecipient_))) {
|
||||
HILOG_ERROR("Failed to add death recipient");
|
||||
}
|
||||
|
||||
HILOG_DEBUG("get remote object ok");
|
||||
serviceProxy_ = iface_cast<AccessibleAbilityManagerServiceClientProxy>(object);
|
||||
if (serviceProxy_ == nullptr) {
|
||||
HILOG_ERROR("IAccessibleAbilityManagerServiceClient iface_cast failed");
|
||||
}
|
||||
return serviceProxy_;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
AccessibilitySystemAbilityClient::AccessibilitySystemAbilityClient(const Context &context,
|
||||
int accountId) : pimpl(std::make_unique<Impl>())
|
||||
{
|
||||
interactionOperator_ = nullptr;
|
||||
accountId_ = accountId;
|
||||
pimpl->stateCallback_ = new AccessibleAbilityManagerServiceStateStub();
|
||||
auto proxyService = pimpl->GetService();
|
||||
if (proxyService == nullptr) {
|
||||
HILOG_ERROR("[%{public}s] Failed to get aams service", __func__);
|
||||
return;
|
||||
}
|
||||
uint32_t stateType = proxyService->RegisterStateCallback(pimpl->stateCallback_, accountId_);
|
||||
|
||||
if (stateType & AccessibilitySystemAbilityClient::STATE_ACCESSIBILITY_ENABLED) {
|
||||
isEnabled_ = true;
|
||||
} else {
|
||||
isEnabled_ = false;
|
||||
}
|
||||
|
||||
if (stateType & AccessibilitySystemAbilityClient::STATE_EXPLORATION_ENABLED) {
|
||||
isTouchExplorationEnabled_ = true;
|
||||
} else {
|
||||
isTouchExplorationEnabled_ = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AccessibilitySystemAbilityClient::Interrupt() //Remained: target app called
|
||||
{
|
||||
HILOG_DEBUG("AccessibilitySystemAbilityClient Interrupt");
|
||||
|
||||
auto proxyService = pimpl->GetService();
|
||||
if (proxyService == nullptr) {
|
||||
HILOG_ERROR("[%{public}s] Failed to get aams service", __func__);
|
||||
return;
|
||||
}
|
||||
proxyService->Interrupt(accountId_);
|
||||
|
||||
HILOG_DEBUG("AccessibilitySystemAbilityClient Interrupt OK");
|
||||
}
|
||||
|
||||
void AccessibilitySystemAbilityClient::ResetService(const wptr<IRemoteObject>& remote)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
std::lock_guard<std::recursive_mutex> lock(asacProxyLock_);
|
||||
if (pimpl->serviceProxy_ != nullptr) {
|
||||
sptr<IRemoteObject> object = pimpl->serviceProxy_->GetObject();
|
||||
if ((object != nullptr) && (remote == object)) {
|
||||
object->RemoveDeathRecipient(pimpl->deathRecipient_);
|
||||
pimpl->serviceProxy_ = nullptr;
|
||||
HILOG_DEBUG("[%{public}s] Reset OK", __func__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int AccessibilitySystemAbilityClient::RegisterInteractionOperation(const int windowId,
|
||||
const shared_ptr<AccessibilityInteractionOperation> &operation, int user)
|
||||
{
|
||||
HILOG_INFO("[%{public}s]", __func__);
|
||||
if (!operation) {
|
||||
HILOG_ERROR("[%{public}s] Input operation is null", __func__);
|
||||
return -1;
|
||||
}
|
||||
int result = 0;
|
||||
connectionWindowId_ = windowId;
|
||||
for (auto iter = interactionOperators_.begin(); iter != interactionOperators_.end(); iter++) {
|
||||
if (iter->first == windowId) {
|
||||
HILOG_ERROR("[%{public}s] windowID[%{public}d] is exited", __func__, windowId);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
interactionOperators_.insert(pair<int, shared_ptr<AccessibilityInteractionOperation>>(windowId, operation));
|
||||
if (operation != nullptr) {
|
||||
interactionOperator_ = operation;
|
||||
sptr<AccessibilityInteractionOperationStub> aamsInteractionOperator =
|
||||
new AccessibilityInteractionOperationStub();
|
||||
aamsInteractionOperator->SetWindowId(windowId);
|
||||
auto proxyService = pimpl->GetService();
|
||||
if (proxyService == nullptr) {
|
||||
HILOG_ERROR("[%{public}s] Failed to get aams service", __func__);
|
||||
return -1;
|
||||
}
|
||||
proxyService->RegisterInteractionOperation(windowId, aamsInteractionOperator, user);
|
||||
} else {
|
||||
HILOG_DEBUG("AccessibilitySystemAbilityClient had register AccessibilityInteractionOperation.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void AccessibilitySystemAbilityClient::DeregisterInteractionOperation(const int windowId)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
auto proxyService = pimpl->GetService();
|
||||
if (proxyService == nullptr) {
|
||||
HILOG_ERROR("[%{public}s] Failed to get aams service", __func__);
|
||||
return;
|
||||
}
|
||||
proxyService->DeregisterInteractionOperation(windowId);
|
||||
for (auto iter = interactionOperators_.begin(); iter != interactionOperators_.end(); iter++) {
|
||||
if (iter->first == windowId) {
|
||||
HILOG_DEBUG("[%{public}s] windowID[%{public}d] is erase", __func__, windowId);
|
||||
interactionOperator_ = nullptr;
|
||||
connectionWindowId_ = -1;
|
||||
interactionOperators_.erase(iter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("[%{public}s] Not find windowID[%{public}d]", __func__, windowId);
|
||||
}
|
||||
|
||||
shared_ptr<AccessibilityInteractionOperation> AccessibilitySystemAbilityClient::GetInteractionObject(int windowId)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] windowId[%{public}d]", __func__, windowId);
|
||||
for (auto it = interactionOperators_.begin(); it != interactionOperators_.end(); it++) {
|
||||
if (it->second != nullptr && it->first == windowId) {
|
||||
HILOG_DEBUG("[%{public}s] find interaction object windowId[%{public}d]", __func__, windowId);
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("[%{public}s] Failed to get interaction", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool AccessibilitySystemAbilityClient::IsEnabled()
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] isEnabled_[%{public}d]", __func__, isEnabled_);
|
||||
return isEnabled_;
|
||||
}
|
||||
|
||||
bool AccessibilitySystemAbilityClient::IsTouchExplorationEnabled()
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] isEnabled_[%{public}d]", __func__, isTouchExplorationEnabled_);
|
||||
return isTouchExplorationEnabled_;
|
||||
}
|
||||
|
||||
std::vector<AccessibilityAbilityInfo> AccessibilitySystemAbilityClient::GetAbilityList(
|
||||
const int accessibilityAbilityTypes, const AbilityStateType stateType)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
bool check = false;
|
||||
if ((accessibilityAbilityTypes & AccessibilityAbilityTypes::ACCESSIBILITY_ABILITY_TYPE_SPOKEN) ||
|
||||
(accessibilityAbilityTypes & AccessibilityAbilityTypes::ACCESSIBILITY_ABILITY_TYPE_HAPTIC) ||
|
||||
(accessibilityAbilityTypes & AccessibilityAbilityTypes::ACCESSIBILITY_ABILITY_TYPE_AUDIBLE) ||
|
||||
(accessibilityAbilityTypes & AccessibilityAbilityTypes::ACCESSIBILITY_ABILITY_TYPE_VISUAL) ||
|
||||
(accessibilityAbilityTypes & AccessibilityAbilityTypes::ACCESSIBILITY_ABILITY_TYPE_GENERIC)) {
|
||||
check = true;
|
||||
}
|
||||
if (stateType == ABILITY_STATE_INVALID) {
|
||||
check = false;
|
||||
}
|
||||
auto proxyService = pimpl->GetService();
|
||||
if (proxyService == nullptr || !check) {
|
||||
HILOG_ERROR("[%{public}s] Failed to get aams service", __func__);
|
||||
std::vector<AccessibilityAbilityInfo> infos;
|
||||
return infos;
|
||||
}
|
||||
return (proxyService->GetAbilityList(accessibilityAbilityTypes, stateType));
|
||||
}
|
||||
|
||||
shared_ptr<AccessibilitySystemAbilityClient> AccessibilitySystemAbilityClient::GetInstance(
|
||||
const Context &abilityContext)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
if (instance_ == nullptr) {
|
||||
int accountId = 0;
|
||||
instance_ = std::make_shared<AccessibilitySystemAbilityClient>(abilityContext, accountId);
|
||||
} else {
|
||||
HILOG_DEBUG("IAccessibleAbilityManagerServiceClient had construct instance");
|
||||
}
|
||||
|
||||
return instance_;
|
||||
}
|
||||
|
||||
shared_ptr<AccessibilitySystemAbilityClient> AccessibilitySystemAbilityClient::GetInstance()
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
AbilityContext abilityContext {};
|
||||
if (instance_ == nullptr) {
|
||||
int accountId = 0;
|
||||
instance_ = std::make_shared<AccessibilitySystemAbilityClient>(abilityContext, accountId);
|
||||
} else {
|
||||
HILOG_DEBUG("IAccessibleAbilityManagerServiceClient had construct instance");
|
||||
}
|
||||
|
||||
return instance_;
|
||||
}
|
||||
|
||||
int AccessibilitySystemAbilityClient::GetSuggestedInterval(const int timeout, const int contentType)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
int interval = 0;
|
||||
int64_t timeSuggested = 0;
|
||||
auto proxyService = pimpl->GetService();
|
||||
if (proxyService == nullptr) {
|
||||
HILOG_ERROR("[%{public}s] Failed to get aams service", __func__);
|
||||
return -1;
|
||||
}
|
||||
timeSuggested = proxyService->GetSuggestedInterval();
|
||||
if (contentType == CONTENT_CONTROLS) {
|
||||
interval = timeSuggested;
|
||||
} else {
|
||||
interval = timeSuggested >> NUM_INT32;
|
||||
}
|
||||
|
||||
if (interval < timeout) {
|
||||
interval = timeout;
|
||||
}
|
||||
return interval;
|
||||
}
|
||||
|
||||
CaptionProperties AccessibilitySystemAbilityClient::GetAccessibilityCaptionProperties() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
return captionProperties_;
|
||||
}
|
||||
|
||||
bool AccessibilitySystemAbilityClient::IsAccessibilityCaptionEnabled() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilitySystemAbilityClient::CheckEventType(EventType eventType)
|
||||
{
|
||||
if ((eventType & EventType::TYPE_VIEW_CLICKED_EVENT) != EventType::TYPE_VIEW_CLICKED_EVENT &&
|
||||
(eventType & EventType::TYPE_VIEW_LONG_CLICKED_EVENT) != EventType::TYPE_VIEW_LONG_CLICKED_EVENT &&
|
||||
(eventType & EventType::TYPE_VIEW_SELECTED_EVENT) != EventType::TYPE_VIEW_SELECTED_EVENT &&
|
||||
(eventType & EventType::TYPE_VIEW_FOCUSED_EVENT) != EventType::TYPE_VIEW_FOCUSED_EVENT &&
|
||||
(eventType & EventType::TYPE_VIEW_TEXT_UPDATE_EVENT) != EventType::TYPE_VIEW_TEXT_UPDATE_EVENT &&
|
||||
(eventType & EventType::TYPE_PAGE_STATE_UPDATE) != EventType::TYPE_PAGE_STATE_UPDATE &&
|
||||
(eventType & EventType::TYPE_NOTIFICATION_UPDATE_EVENT) != EventType::TYPE_NOTIFICATION_UPDATE_EVENT &&
|
||||
(eventType & EventType::TYPE_VIEW_HOVER_ENTER_EVENT) != EventType::TYPE_VIEW_HOVER_ENTER_EVENT &&
|
||||
(eventType & EventType::TYPE_VIEW_HOVER_EXIT_EVENT) != EventType::TYPE_VIEW_HOVER_EXIT_EVENT &&
|
||||
(eventType & EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN) != EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN &&
|
||||
(eventType & EventType::TYPE_TOUCH_GUIDE_GESTURE_END) != EventType::TYPE_TOUCH_GUIDE_GESTURE_END &&
|
||||
(eventType & EventType::TYPE_PAGE_CONTENT_UPDATE) != EventType::TYPE_PAGE_CONTENT_UPDATE &&
|
||||
(eventType & EventType::TYPE_VIEW_SCROLLED_EVENT) != EventType::TYPE_VIEW_SCROLLED_EVENT &&
|
||||
(eventType & EventType::TYPE_VIEW_TEXT_SELECTION_UPDATE_EVENT) !=
|
||||
EventType::TYPE_VIEW_TEXT_SELECTION_UPDATE_EVENT &&
|
||||
(eventType & EventType::TYPE_PUBLIC_NOTICE_EVENT) != EventType::TYPE_PUBLIC_NOTICE_EVENT &&
|
||||
(eventType & EventType::TYPE_VIEW_ACCESSIBILITY_FOCUSED_EVENT) !=
|
||||
EventType::TYPE_VIEW_ACCESSIBILITY_FOCUSED_EVENT &&
|
||||
(eventType & EventType::TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED_EVENT) !=
|
||||
EventType::TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED_EVENT &&
|
||||
(eventType & EventType::TYPE_VIEW_TEXT_MOVE_UNIT_EVENT) != EventType::TYPE_VIEW_TEXT_MOVE_UNIT_EVENT &&
|
||||
(eventType & EventType::TYPE_TOUCH_GUIDE_BEGIN) != EventType::TYPE_TOUCH_GUIDE_BEGIN &&
|
||||
(eventType & EventType::TYPE_TOUCH_GUIDE_END) != EventType::TYPE_TOUCH_GUIDE_END &&
|
||||
(eventType & EventType::TYPE_TOUCH_BEGIN) != EventType::TYPE_TOUCH_BEGIN &&
|
||||
(eventType & EventType::TYPE_TOUCH_END) != EventType::TYPE_TOUCH_END &&
|
||||
(eventType & EventType::TYPE_WINDOW_UPDATE) != EventType::TYPE_WINDOW_UPDATE &&
|
||||
(eventType & EventType::TYPES_ALL_MASK) != EventType::TYPES_ALL_MASK) {
|
||||
HILOG_ERROR("[%{public}s] event type is invalid", __func__);
|
||||
return false;
|
||||
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool AccessibilitySystemAbilityClient::SendEvent(const EventType eventType, const int componentId)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] componentId[%{public}d], eventType[%{public}d]", __func__, componentId, eventType);
|
||||
if (!CheckEventType(eventType)) {
|
||||
return false;
|
||||
}
|
||||
AccessibilityEventInfo event;
|
||||
event.SetEventType(eventType);
|
||||
event.SetSource(componentId);
|
||||
auto proxyService = pimpl->GetService();
|
||||
if (proxyService == nullptr) {
|
||||
HILOG_ERROR("[%{public}s] Failed to get aams service", __func__);
|
||||
return false;
|
||||
}
|
||||
proxyService->SendEvent(event, accountId_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilitySystemAbilityClient::SendEvent(const AccessibilityEventInfo &event)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] EventType[%{public}d]", __func__, event.GetEventType());
|
||||
if (!CheckEventType(event.GetEventType())) {
|
||||
return false;
|
||||
}
|
||||
auto proxyService = pimpl->GetService();
|
||||
if (proxyService == nullptr) {
|
||||
HILOG_ERROR("[%{public}s] Failed to get aams service", __func__);
|
||||
return false;
|
||||
}
|
||||
proxyService->SendEvent(event, accountId_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilitySystemAbilityClient::SubscribeStateObserver(const shared_ptr<AccessibilityStateObserver> &observer,
|
||||
const int eventType)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
if (eventType != AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED &&
|
||||
eventType != AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED) {
|
||||
HILOG_ERROR("[%{public}s] Input eventType is out of scope", __func__);
|
||||
return false;
|
||||
}
|
||||
if (!observer) {
|
||||
HILOG_ERROR("[%{public}s] Input observer is null", __func__);
|
||||
return false;
|
||||
}
|
||||
AccessibilityStateEventType et = AccessibilityStateEventType(
|
||||
*(const_cast<int*>(&eventType)));
|
||||
shared_ptr<AccessibilityStateObserver> ob = const_cast<shared_ptr<AccessibilityStateObserver> &>(observer);
|
||||
if (et == AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED) {
|
||||
observersAceessibilityState_.push_back(ob);
|
||||
} else {
|
||||
observersTouchState_.push_back(ob);
|
||||
}
|
||||
HILOG_DEBUG("[%{public}s] end", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilitySystemAbilityClient::UnsubscribeStateObserver(const shared_ptr<AccessibilityStateObserver> &observer,
|
||||
const int eventType)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
if (eventType != AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED &&
|
||||
eventType != AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED) {
|
||||
HILOG_ERROR("[%{public}s] Input eventType is out of scope", __func__);
|
||||
return false;
|
||||
}
|
||||
if (!observer) {
|
||||
HILOG_ERROR("[%{public}s] Input observer is null", __func__);
|
||||
return false;
|
||||
}
|
||||
AccessibilityStateEventType et = AccessibilityStateEventType(*(const_cast<int*>(&eventType)));
|
||||
if (et == AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED) {
|
||||
for (auto it = observersAceessibilityState_.begin(); it != observersAceessibilityState_.end(); it++) {
|
||||
if (*it == observer) {
|
||||
observersAceessibilityState_.erase(it);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (auto it = observersTouchState_.begin(); it != observersTouchState_.end(); it++) {
|
||||
if (*it == observer) {
|
||||
observersTouchState_.erase(it);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("%{public}s Not find eventType[%{public}d]" , __func__, eventType);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AccessibilitySystemAbilityClient::UnsubscribeStateObserver(const shared_ptr<AccessibilityStateObserver> &observer)
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
if (!observer) {
|
||||
HILOG_ERROR("[%{public}s] Input observer is null", __func__);
|
||||
return false;
|
||||
}
|
||||
bool result = false;
|
||||
for (auto it = observersAceessibilityState_.begin(); it != observersAceessibilityState_.end(); it++) {
|
||||
if (*it == observer) {
|
||||
observersAceessibilityState_.erase(it);
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = observersTouchState_.begin(); it != observersTouchState_.end(); it++) {
|
||||
if (*it == observer) {
|
||||
observersTouchState_.erase(it);
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void AccessibilitySystemAbilityClient::SetEnabled(const bool enabled)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
isEnabled_ = enabled;
|
||||
NotifyAccessibilityStateChanged();
|
||||
HILOG_DEBUG("[%{public}s] end", __func__);
|
||||
}
|
||||
|
||||
void AccessibilitySystemAbilityClient::SetTouchExplorationEnabled(const bool enabled)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
isTouchExplorationEnabled_ = enabled;
|
||||
NotifyTouchExplorationStateChanged();
|
||||
HILOG_DEBUG("[%{public}s] end", __func__);
|
||||
}
|
||||
|
||||
void AccessibilitySystemAbilityClient::NotifyAccessibilityStateChanged()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
std::lock_guard<std::recursive_mutex> lock(asacProxyLock_);
|
||||
if (observersAceessibilityState_.size() == 0) {
|
||||
HILOG_DEBUG("%{public}s observersAceessibilityState_ is null" , __func__);
|
||||
return;
|
||||
}
|
||||
for (auto it = observersAceessibilityState_.begin(); it != observersAceessibilityState_.end(); it++) {
|
||||
AccessibilityStateEvent stateEvent;
|
||||
stateEvent.SetEventType(EVENT_ACCESSIBILITY_STATE_CHANGED);
|
||||
stateEvent.SetEventResult(isEnabled_);
|
||||
if (*it != nullptr && it->get() != nullptr) {
|
||||
it->get()->OnStateChanged(stateEvent);
|
||||
} else {
|
||||
HILOG_ERROR("%{public}s end observersAceessibilityState_ is null" , __func__);
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("[%{public}s] end", __func__);
|
||||
}
|
||||
|
||||
void AccessibilitySystemAbilityClient::NotifyTouchExplorationStateChanged()
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s]", __func__);
|
||||
std::lock_guard<std::recursive_mutex> lock(asacProxyLock_);
|
||||
if (observersTouchState_.size() == 0) {
|
||||
HILOG_DEBUG("%{public}s observersTouchState_ is null" , __func__);
|
||||
return;
|
||||
}
|
||||
for (auto it = observersTouchState_.begin(); it != observersTouchState_.end(); it++) {
|
||||
AccessibilityStateEvent stateEvent;
|
||||
stateEvent.SetEventType(EVENT_TOUCH_GUIDE_STATE_CHANGED);
|
||||
stateEvent.SetEventResult(isTouchExplorationEnabled_);
|
||||
if (*it != nullptr && it->get() != nullptr) {
|
||||
it->get()->OnStateChanged(stateEvent);
|
||||
} else {
|
||||
HILOG_ERROR("%{public}s end observersTouchState_ is null" , __func__);
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("[%{public}s] end", __func__);
|
||||
}
|
||||
|
||||
bool CaptionProperties::CheckProperty(const std::string &property)
|
||||
{
|
||||
bool result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
int CaptionProperties::GetBackgroundColor() const
|
||||
{
|
||||
return backgroundColor_;
|
||||
}
|
||||
|
||||
int CaptionProperties::GetForegroundColor() const
|
||||
{
|
||||
return foregroundColor_;
|
||||
}
|
||||
|
||||
int CaptionProperties::GetEdgeType() const
|
||||
{
|
||||
return edgeType_;
|
||||
}
|
||||
|
||||
int CaptionProperties::GetEdgeColor() const
|
||||
{
|
||||
return edgeColor_;
|
||||
}
|
||||
|
||||
int CaptionProperties::GetWindowColor() const
|
||||
{
|
||||
return windowColor_;
|
||||
}
|
||||
|
||||
bool CaptionProperties::HasBackgroundColor()
|
||||
{
|
||||
return hasBackgroundColor_;
|
||||
}
|
||||
|
||||
bool CaptionProperties::HasForegroundColor()
|
||||
{
|
||||
return hasForegroundColor_;
|
||||
}
|
||||
|
||||
bool CaptionProperties::HasEdgeType()
|
||||
{
|
||||
return hasEdgeType_;
|
||||
}
|
||||
|
||||
bool CaptionProperties::HasEdgeColor()
|
||||
{
|
||||
return hasEdgeColor_;
|
||||
}
|
||||
|
||||
bool CaptionProperties::HasWindowColor()
|
||||
{
|
||||
return hasWindowColor_;
|
||||
}
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
319
frameworks/asacfwk/src/accessibility_window_info.cpp
Normal file
319
frameworks/asacfwk/src/accessibility_window_info.cpp
Normal file
@ -0,0 +1,319 @@
|
||||
/*
|
||||
* 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 "accessibility_window_info.h"
|
||||
#include "accessibility_operator.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
/* AccessibleAction Parcel struct */
|
||||
bool AccessibilityWindowInfo::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
int windowType = TYPE_WINDOW_INVALID;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowType);
|
||||
windowType_ = static_cast<WindowType>(windowType);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowLayer_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, parentId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, windowTitle_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32Vector, parcel, &childIds_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, anchorId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, childNum_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, channelId_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, active_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, focused_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityFocused_);
|
||||
std::shared_ptr<Rect> boundsInScreen(parcel.ReadParcelable<Rect>());
|
||||
if (!boundsInScreen) {
|
||||
HILOG_ERROR("ReadParcelable boundsInScreen failed.");
|
||||
return false;
|
||||
}
|
||||
boundsInScreen_ = *boundsInScreen;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityWindowInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int>(windowType_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowLayer_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, windowId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, parentId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, windowTitle_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32Vector, parcel, childIds_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, anchorId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, childNum_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, channelId_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, active_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, focused_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityFocused_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &boundsInScreen_);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
AccessibilityWindowInfo* AccessibilityWindowInfo::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
AccessibilityWindowInfo *accessibilityWindow = new AccessibilityWindowInfo();
|
||||
if (!accessibilityWindow->ReadFromParcel(parcel)) {
|
||||
delete accessibilityWindow;
|
||||
accessibilityWindow = nullptr;
|
||||
}
|
||||
return accessibilityWindow;
|
||||
}
|
||||
|
||||
std::string AccessibilityWindowInfo::GetWindowTitle() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] windowTitle_[%{public}s]", __func__, windowTitle_.c_str());
|
||||
return windowTitle_;
|
||||
}
|
||||
|
||||
void AccessibilityWindowInfo::SetWindowTitle(std::string &title)
|
||||
{
|
||||
windowTitle_ = title;
|
||||
HILOG_DEBUG("[%{public}s] windowTitle_[%{public}s]", __func__, windowTitle_.c_str());
|
||||
}
|
||||
|
||||
WindowType AccessibilityWindowInfo::GetWindowType() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] windowType_[%{public}d]", __func__, windowType_);
|
||||
return windowType_;
|
||||
}
|
||||
|
||||
void AccessibilityWindowInfo::SetWindowType(const WindowType type)
|
||||
{
|
||||
windowType_ = type;
|
||||
HILOG_DEBUG("[%{public}s] windowType_[%{public}d]", __func__, windowType_);
|
||||
}
|
||||
|
||||
int AccessibilityWindowInfo::GetWindowLayer() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] windowLayer_[%{public}d]", __func__, windowLayer_);
|
||||
return windowLayer_;
|
||||
}
|
||||
|
||||
void AccessibilityWindowInfo::SetWindowLayer(const int layer)
|
||||
{
|
||||
windowLayer_ = layer;
|
||||
HILOG_DEBUG("[%{public}s] windowLayer_[%{public}d]", __func__, windowLayer_);
|
||||
}
|
||||
|
||||
bool AccessibilityWindowInfo::GetRootAccessibilityInfo(AccessibilityElementInfo &elementInfo)
|
||||
{
|
||||
HILOG_INFO("[%{public}s] called] channelId_[%{public}d], windowId_[%{public}d]",
|
||||
__func__, channelId_, windowId_);
|
||||
AccessibilityOperator * instance = &AccessibilityOperator::GetInstance();
|
||||
|
||||
std::vector<AccessibilityElementInfo> elementInfos {};
|
||||
bool result = false;
|
||||
if (instance != nullptr) {
|
||||
result = instance->SearchElementInfosByAccessibilityId(channelId_, windowId_, -1, 0, elementInfos);
|
||||
if (elementInfos.empty()) {
|
||||
result = false;
|
||||
} else {
|
||||
elementInfo = elementInfos.front();
|
||||
}
|
||||
} else {
|
||||
HILOG_INFO("[%{public}s] called] Can't get AccessibilityOperator instance", __func__);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void AccessibilityWindowInfo::SetAnchorId(const int anchorId)
|
||||
{
|
||||
anchorId_ = anchorId;
|
||||
HILOG_DEBUG("[%{public}s] anchorId_[%{public}d]", __func__, anchorId_);
|
||||
}
|
||||
|
||||
bool AccessibilityWindowInfo::GetAnchor(AccessibilityElementInfo &elementInfo)
|
||||
{
|
||||
HILOG_DEBUG("GetAnchor of windowInfo is not support!");
|
||||
HILOG_INFO("[%{public}s] called] channelId_[%{public}d], windowId_[%{public}d], anchorId_[%{public}d]",
|
||||
__func__, channelId_, windowId_, anchorId_);
|
||||
AccessibilityOperator * instance = &AccessibilityOperator::GetInstance();
|
||||
|
||||
std::vector<AccessibilityElementInfo> elementInfos {};
|
||||
bool result = false;
|
||||
if (instance != nullptr) {
|
||||
result = instance->SearchElementInfosByAccessibilityId(channelId_, windowId_, anchorId_, 0, elementInfos);
|
||||
if (elementInfos.empty()) {
|
||||
result = false;
|
||||
} else {
|
||||
elementInfo = elementInfos.front();
|
||||
}
|
||||
} else {
|
||||
HILOG_INFO("[%{public}s] called] Can't get AccessibilityOperator instance", __func__);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
AccessibilityWindowInfo AccessibilityWindowInfo::GetParent()
|
||||
{
|
||||
HILOG_DEBUG("GetParent of windowInfo is not support!");
|
||||
AccessibilityWindowInfo win {};
|
||||
HILOG_INFO("[%{public}s] called] channelId_[%{public}d], parentId_[%{public}d]",
|
||||
__func__, channelId_, parentId_);
|
||||
AccessibilityOperator * instance = &AccessibilityOperator::GetInstance();
|
||||
if (instance != nullptr) {
|
||||
for (auto window : instance->GetWindows(channelId_)) {
|
||||
if (window.GetWindowId() == parentId_) {
|
||||
return window;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
HILOG_INFO("[%{public}s] called] Can't get AccessibilityOperator instance", __func__);
|
||||
}
|
||||
return win;
|
||||
}
|
||||
|
||||
void AccessibilityWindowInfo::SetParentId(const int parentId)
|
||||
{
|
||||
parentId_ = parentId;
|
||||
HILOG_DEBUG("[%{public}s] parentId_[%{public}d]", __func__, parentId_);
|
||||
}
|
||||
|
||||
int AccessibilityWindowInfo::GetParentId()
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] parentId_[%{public}d]", __func__, parentId_);
|
||||
return parentId_;
|
||||
}
|
||||
|
||||
std::vector<int> AccessibilityWindowInfo::GetChildIds()
|
||||
{
|
||||
return childIds_;
|
||||
}
|
||||
|
||||
int AccessibilityWindowInfo::GetAnchorId()
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] anchorId_[%{public}d]", __func__, anchorId_);
|
||||
return anchorId_;
|
||||
}
|
||||
int AccessibilityWindowInfo::GetWindowId() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] windowId_[%{public}d]", __func__, windowId_);
|
||||
return windowId_;
|
||||
}
|
||||
|
||||
void AccessibilityWindowInfo::SetWindowId(const int id)
|
||||
{
|
||||
windowId_ = id;
|
||||
HILOG_DEBUG("[%{public}s] windowId_[%{public}d]", __func__, windowId_);
|
||||
}
|
||||
|
||||
void AccessibilityWindowInfo::SetChannelId(const int channelId)
|
||||
{
|
||||
channelId_ = channelId;
|
||||
HILOG_DEBUG("[%{public}s] channelId_[%{public}d]", __func__, channelId_);
|
||||
}
|
||||
|
||||
int AccessibilityWindowInfo::GetChannelId() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] channelId_[%{public}d]", __func__, channelId_);
|
||||
return channelId_;
|
||||
}
|
||||
|
||||
Rect AccessibilityWindowInfo::GetRectInScreen() const
|
||||
{
|
||||
return boundsInScreen_;
|
||||
}
|
||||
|
||||
void AccessibilityWindowInfo::SetRectInScreen(const Rect &bounds)
|
||||
{
|
||||
boundsInScreen_.SetLeftTopScreenPostion(const_cast<Rect &>(bounds).GetLeftTopXScreenPostion(),
|
||||
const_cast<Rect &>(bounds).GetLeftTopYScreenPostion());
|
||||
boundsInScreen_.SetRightBottomScreenPostion(const_cast<Rect &>(bounds).GetRightBottomXScreenPostion(),
|
||||
const_cast<Rect &>(bounds).GetRightBottomYScreenPostion());
|
||||
}
|
||||
|
||||
bool AccessibilityWindowInfo::IsActive() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] active_[%{public}d]", __func__, active_);
|
||||
return active_;
|
||||
}
|
||||
|
||||
void AccessibilityWindowInfo::SetActive(bool active)
|
||||
{
|
||||
active_ = active;
|
||||
HILOG_DEBUG("[%{public}s] active_[%{public}d]", __func__, active_);
|
||||
}
|
||||
|
||||
bool AccessibilityWindowInfo::IsFocused() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] focused_[%{public}d]", __func__, focused_);
|
||||
return focused_;
|
||||
}
|
||||
|
||||
void AccessibilityWindowInfo::SetFocused(bool focused)
|
||||
{
|
||||
focused_ = focused;
|
||||
HILOG_DEBUG("[%{public}s] focused_[%{public}d]", __func__, focused_);
|
||||
}
|
||||
|
||||
bool AccessibilityWindowInfo::IsAccessibilityFocused() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] accessibilityFocused_[%{public}d]", __func__, accessibilityFocused_);
|
||||
return accessibilityFocused_;
|
||||
}
|
||||
|
||||
void AccessibilityWindowInfo::SetAccessibilityFocused(const bool accessibilityfocused)
|
||||
{
|
||||
accessibilityFocused_ = accessibilityfocused;
|
||||
HILOG_DEBUG("[%{public}s] accessibilityFocused_[%{public}d]", __func__, accessibilityFocused_);
|
||||
}
|
||||
|
||||
int AccessibilityWindowInfo::GetChildNum() const
|
||||
{
|
||||
HILOG_DEBUG("[%{public}s] childNum_[%{public}d]", __func__, childNum_);
|
||||
return childNum_;
|
||||
}
|
||||
|
||||
AccessibilityWindowInfo AccessibilityWindowInfo::GetChild(const int index)
|
||||
{
|
||||
HILOG_DEBUG("GetChild of windowInfo is not support!");
|
||||
AccessibilityWindowInfo win {};
|
||||
HILOG_INFO("[%{public}s] called] channelId_[%{public}d], childNum_[%{public}d], index[%{public}d]",
|
||||
__func__, channelId_, childNum_, index);
|
||||
if (index >= childNum_ || index < 0) {
|
||||
HILOG_ERROR("[%{public}s] called] index[%{public}d] is invalid", __func__, index);
|
||||
return win;
|
||||
}
|
||||
AccessibilityOperator * instance = &AccessibilityOperator::GetInstance();
|
||||
if (instance != nullptr) {
|
||||
for (auto window : instance->GetWindows(channelId_)) {
|
||||
if (window.GetWindowId() == childIds_[index]) {
|
||||
return window;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
HILOG_INFO("[%{public}s] called] Can't get AccessibilityOperator instance", __func__);
|
||||
}
|
||||
return win;
|
||||
}
|
||||
|
||||
void AccessibilityWindowInfo::AddChild(const int childId)
|
||||
{
|
||||
childIds_.push_back(childId);
|
||||
childNum_++;
|
||||
}
|
||||
|
||||
AccessibilityWindowInfo::AccessibilityWindowInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
596
frameworks/asacfwk/src/accessible_ability_channel_proxy.cpp
Normal file
596
frameworks/asacfwk/src/accessible_ability_channel_proxy.cpp
Normal file
@ -0,0 +1,596 @@
|
||||
/*
|
||||
* 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 "accessible_ability_channel_proxy.h"
|
||||
#include "parcel.h"
|
||||
#include "accessibility_errorcode.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
AccessibleAbilityChannelProxy::AccessibleAbilityChannelProxy(
|
||||
const sptr<IRemoteObject> &object): IRemoteProxy<IAccessibleAbilityChannel>(object)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::WriteInterfaceToken(MessageParcel &data)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (!data.WriteInterfaceToken(AccessibleAbilityChannelProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("write interface token failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::SendTransactCmd(IAccessibleAbilityChannel::Message code,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (!remote) {
|
||||
HILOG_ERROR("fail to send transact cmd %{public}d due to remote object", code);
|
||||
return false;
|
||||
}
|
||||
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
|
||||
if (result != NO_ERROR) {
|
||||
HILOG_ERROR("receive error transact code %{public}d in transact cmd %{public}d", result, code);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::SearchElementInfoByAccessibilityId(const int accessibilityWindowId,
|
||||
const long elementId, const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback,
|
||||
const int mode)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(accessibilityWindowId)) {
|
||||
HILOG_ERROR("accessibilityWindowId write error: %{public}d, ", accessibilityWindowId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt64(elementId)) {
|
||||
HILOG_ERROR("elementId write error: %{public}ld, ", elementId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("requestId write error: %{public}d, ", requestId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("callback write error");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(mode)) {
|
||||
HILOG_ERROR("mode write error: %{public}d, ", mode);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SEARCH_ELEMENTINFO_BY_ACCESSIBILITYID,
|
||||
data, reply, option)) {
|
||||
HILOG_ERROR("fail to find elementInfo by elementId");
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::SearchElementInfosByText(const int accessibilityWindowId,
|
||||
const long elementId, const std::string &text, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(accessibilityWindowId)) {
|
||||
HILOG_ERROR("accessibilityWindowId write error: %{public}d, ", accessibilityWindowId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(elementId)) {
|
||||
HILOG_ERROR("elementId write error: %{public}ld, ", elementId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteString(text)) {
|
||||
HILOG_ERROR("text write error: %{public}s, ", text.c_str());
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("requestId write error: %{public}d, ", requestId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("callback write error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SEARCH_ELEMENTINFOS_BY_TEXT,
|
||||
data, reply, option)) {
|
||||
HILOG_ERROR("fail to find elementInfo by text");
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::FindFocusedElementInfo(const int accessibilityWindowId,
|
||||
const long elementId, const int focusType, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(accessibilityWindowId)) {
|
||||
HILOG_ERROR("accessibilityWindowId write error: %{public}d, ", accessibilityWindowId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(elementId)) {
|
||||
HILOG_ERROR("elementId write error: %{public}ld, ", elementId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(focusType)) {
|
||||
HILOG_ERROR("focusType write error: %{public}d, ", focusType);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("requestId write error: %{public}d, ", requestId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("callback write error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::FIND_FOCUSED_ELEMENTINFO, data, reply, option)) {
|
||||
HILOG_ERROR("fail to gain focus");
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::FocusMoveSearch(const int accessibilityWindowId, const long elementId,
|
||||
const int direction, const int requestId, const sptr<IAccessibilityInteractionOperationCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(accessibilityWindowId)) {
|
||||
HILOG_ERROR("accessibilityWindowId write error: %{public}d, ", accessibilityWindowId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(elementId)) {
|
||||
HILOG_ERROR("elementId write error: %{public}ld, ", elementId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(direction)) {
|
||||
HILOG_ERROR("direction write error: %{public}d, ", direction);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("requestId write error: %{public}d, ", requestId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("callback write error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::FOCUS_MOVE_SEARCH, data, reply, option)) {
|
||||
HILOG_ERROR("fail to search focus");
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::PerformAction(const int accessibilityWindowId, const long elementId,
|
||||
const int action, std::map<std::string, std::string> &actionArguments, const int requestId,
|
||||
const sptr<IAccessibilityInteractionOperationCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(accessibilityWindowId)) {
|
||||
HILOG_ERROR("accessibilityWindowId write error: %{public}d, ", accessibilityWindowId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(elementId)) {
|
||||
HILOG_ERROR("elementId write error: %{public}ld, ", elementId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(action)) {
|
||||
HILOG_ERROR("action write error: %{public}d, ", action);
|
||||
return false;
|
||||
}
|
||||
|
||||
vector<string> actionArgumentsKey{};
|
||||
vector<string> actionArgumentsValue{};
|
||||
for (auto iter = actionArguments.begin(); iter != actionArguments.end(); iter++) {
|
||||
actionArgumentsKey.push_back(iter->first);
|
||||
actionArgumentsValue.push_back(iter->second);
|
||||
}
|
||||
if (!data.WriteStringVector(actionArgumentsKey)) {
|
||||
HILOG_ERROR("actionArgumentsKey write error");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteStringVector(actionArgumentsValue)) {
|
||||
HILOG_ERROR("actionArgumentsValue write error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(requestId)) {
|
||||
HILOG_ERROR("requestId write error: %{public}d, ", requestId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("callback write error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::PERFORM_ACTION,
|
||||
data, reply, option)) {
|
||||
HILOG_ERROR("fail to perform accessibility action");
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
vector<AccessibilityWindowInfo> AccessibleAbilityChannelProxy::GetWindows()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
vector<AccessibilityWindowInfo> windowsError;
|
||||
vector<AccessibilityWindowInfo> windows;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return windowsError;
|
||||
}
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::GET_WINDOWS, data, reply, option)) {
|
||||
HILOG_ERROR("fail to get windows");
|
||||
return windowsError;
|
||||
}
|
||||
|
||||
int32_t windowsSize = reply.ReadInt32();
|
||||
for (int32_t i = 0; i < windowsSize; i++) {
|
||||
unique_ptr<AccessibilityWindowInfo> window(reply.ReadParcelable<AccessibilityWindowInfo>());
|
||||
if (!window) {
|
||||
HILOG_ERROR("ReadParcelable<AccessibilityWindowInfo> failed");
|
||||
return windowsError;
|
||||
}
|
||||
windows.emplace_back(*window);
|
||||
}
|
||||
|
||||
return windows;
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::PerformCommonAction(const int action)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(action)) {
|
||||
HILOG_ERROR("action write error: %{public}d, ", action);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::PERFORM_COMMON_ACTION, data, reply, option)) {
|
||||
HILOG_ERROR("fail to perform common action");
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
void AccessibleAbilityChannelProxy::DisableAbility()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::DISABLE_ABILITY, data, reply, option)) {
|
||||
HILOG_ERROR("fail to disable ability");
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityChannelProxy::SetOnKeyPressEventResult(const bool handled, const int sequence)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
if (!data.WriteBool(handled)) {
|
||||
HILOG_ERROR("handled write error: %{public}d, ", handled);
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(sequence)) {
|
||||
HILOG_ERROR("sequence write error: %{public}d, ", sequence);
|
||||
return;
|
||||
}
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SET_ON_KEY_PRESS_EVENT_RESULT,
|
||||
data, reply, option)) {
|
||||
HILOG_ERROR("fail to set onKeyPressEvent result");
|
||||
}
|
||||
}
|
||||
|
||||
float AccessibleAbilityChannelProxy::GetDisplayResizeScale(const int displayId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return 0;
|
||||
}
|
||||
if (!data.WriteInt32(displayId)) {
|
||||
HILOG_ERROR("displayId write error: %{public}d, ", displayId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::GET_DISPALYRESIZE_SCALE, data, reply, option)) {
|
||||
HILOG_ERROR("fail to get displayResize scale");
|
||||
return 0;
|
||||
}
|
||||
return reply.ReadFloat();
|
||||
}
|
||||
|
||||
float AccessibleAbilityChannelProxy::GetDisplayResizeCenterX(const int displayId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return 0;
|
||||
}
|
||||
if (!data.WriteInt32(displayId)) {
|
||||
HILOG_ERROR("displayId write error: %{public}d, ", displayId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::GET_DISPALYRESIZE_CETER_X, data, reply, option)) {
|
||||
HILOG_ERROR("fail to get displayResize centerX");
|
||||
return 0;
|
||||
}
|
||||
return reply.ReadFloat();
|
||||
}
|
||||
|
||||
float AccessibleAbilityChannelProxy::GetDisplayResizeCenterY(const int displayId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return 0;
|
||||
}
|
||||
if (!data.WriteInt32(displayId)) {
|
||||
HILOG_ERROR("displayId write error: %{public}d, ", displayId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::GET_DISPLAYRESIZE_CETER_Y, data, reply, option)) {
|
||||
HILOG_ERROR("fail to get displayResize centerY");
|
||||
return 0;
|
||||
}
|
||||
return reply.ReadFloat();
|
||||
}
|
||||
|
||||
Rect AccessibleAbilityChannelProxy::GetDisplayResizeRect(const int displayId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
Rect rect(0, 0, 0, 0);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return rect;
|
||||
}
|
||||
if (!data.WriteInt32(displayId)) {
|
||||
HILOG_ERROR("displayId write error: %{public}d, ", displayId);
|
||||
return rect;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::GET_DISPLAYRESIZE_RECT, data, reply, option)) {
|
||||
HILOG_ERROR("fail to get displayResize rect");
|
||||
return rect;
|
||||
}
|
||||
|
||||
std::shared_ptr<Rect> result(reply.ReadParcelable<Rect>());
|
||||
if (!result) {
|
||||
HILOG_ERROR("ReadParcelable<Rect> failed");
|
||||
return rect;
|
||||
}
|
||||
return *result;
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::ResetDisplayResize(const int displayId, const bool animate)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(displayId)) {
|
||||
HILOG_ERROR("displayId write error: %{public}d, ", displayId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteBool(animate)) {
|
||||
HILOG_ERROR("animate write error: %{public}d, ", animate);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::RESET_DISPALYRESIZE, data, reply, option)) {
|
||||
HILOG_ERROR("fail to reset displayResize");
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::SetDisplayResizeScaleAndCenter(const int displayId, const float scale,
|
||||
const float centerX, const float centerY, const bool animate)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(displayId)) {
|
||||
HILOG_ERROR("displayId write error: %{public}d, ", displayId);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteFloat(scale)) {
|
||||
HILOG_ERROR("scale write error: %{public}f, ", scale);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteFloat(centerX)) {
|
||||
HILOG_ERROR("centerX write error: %{public}f, ", centerX);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteFloat(centerY)) {
|
||||
HILOG_ERROR("centerY write error: %{public}f, ", centerY);
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteBool(animate)) {
|
||||
HILOG_ERROR("animate write error: %{public}d, ", animate);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SET_DISPLAYRESIZE_SCALE_AND_CENTER,
|
||||
data, reply, option)) {
|
||||
HILOG_ERROR("fail to set displayResize scale and center");
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
void AccessibleAbilityChannelProxy::SendSimulateGesture(const int sequence,
|
||||
const std::vector<GesturePathDefine> &gestureSteps)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(sequence)) {
|
||||
HILOG_ERROR("sequence write error: %{public}d, ", sequence);
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(gestureSteps.size())) {
|
||||
HILOG_ERROR("gestureSteps.size() write error: %{public}d, ", gestureSteps.size());
|
||||
return;
|
||||
}
|
||||
for (auto &step : gestureSteps) {
|
||||
if (!data.WriteParcelable(&step)) {
|
||||
HILOG_ERROR("gestureSteps write error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SEND_SIMULATE_GESTURE, data, reply, option)) {
|
||||
HILOG_ERROR("fail to send simulation gesture");
|
||||
}
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::IsFingerprintGestureDetectionValid()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return false;
|
||||
}
|
||||
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::IS_FINGERPRINT_GESTURE_DETECTION_VALID,
|
||||
data, reply, option)) {
|
||||
HILOG_ERROR("fail to get fingerprint gesture detection's validity");
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
364
frameworks/asacfwk/src/accessible_ability_channel_stub.cpp
Normal file
364
frameworks/asacfwk/src/accessible_ability_channel_stub.cpp
Normal file
@ -0,0 +1,364 @@
|
||||
/*
|
||||
* 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 "accessible_ability_channel_stub.h"
|
||||
#include "parcel.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
AccessibleAbilityChannelStub::AccessibleAbilityChannelStub() {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::SEARCH_ELEMENTINFO_BY_ACCESSIBILITYID)] =
|
||||
&AccessibleAbilityChannelStub::HandleSearchElementInfoByAccessibilityId;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::SEARCH_ELEMENTINFOS_BY_TEXT)] =
|
||||
&AccessibleAbilityChannelStub::HandleSearchElementInfosByText;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::FIND_FOCUSED_ELEMENTINFO)] =
|
||||
&AccessibleAbilityChannelStub::HandleFindFocusedElementInfo;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::FOCUS_MOVE_SEARCH)] =
|
||||
&AccessibleAbilityChannelStub::HandleFocusMoveSearch;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::PERFORM_ACTION)] =
|
||||
&AccessibleAbilityChannelStub::HandlePerformAction;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::GET_WINDOWS)] =
|
||||
&AccessibleAbilityChannelStub::HandleGetWindows;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::PERFORM_COMMON_ACTION)] =
|
||||
&AccessibleAbilityChannelStub::HandlePerformCommonAction;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::DISABLE_ABILITY)] =
|
||||
&AccessibleAbilityChannelStub::HandleDisableAbility;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::SET_ON_KEY_PRESS_EVENT_RESULT)] =
|
||||
&AccessibleAbilityChannelStub::HandleSetOnKeyPressEventResult;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::GET_DISPALYRESIZE_SCALE)] =
|
||||
&AccessibleAbilityChannelStub::HandleGetDisplayResizeScale;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::GET_DISPALYRESIZE_CETER_X)] =
|
||||
&AccessibleAbilityChannelStub::HandleGetDisplayResizeCenterX;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::GET_DISPLAYRESIZE_CETER_Y)] =
|
||||
&AccessibleAbilityChannelStub::HandleGetDisplayResizeCenterY;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::GET_DISPLAYRESIZE_RECT)] =
|
||||
&AccessibleAbilityChannelStub::HandleGetDisplayResizeRect;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::RESET_DISPALYRESIZE)] =
|
||||
&AccessibleAbilityChannelStub::HandleResetDisplayResize;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::SET_DISPLAYRESIZE_SCALE_AND_CENTER)] =
|
||||
&AccessibleAbilityChannelStub::HandleSetDisplayResizeScaleAndCenter;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::SEND_SIMULATE_GESTURE)] =
|
||||
&AccessibleAbilityChannelStub::HandleSendSimulateGesture;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityChannel::Message::IS_FINGERPRINT_GESTURE_DETECTION_VALID)] =
|
||||
&AccessibleAbilityChannelStub::HandleIsFingerprintGestureDetectionValid;
|
||||
}
|
||||
|
||||
AccessibleAbilityChannelStub::~AccessibleAbilityChannelStub() {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
memberFuncMap_.clear();
|
||||
}
|
||||
|
||||
int32_t AccessibleAbilityChannelStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option) {
|
||||
HILOG_DEBUG("AccessibleAbilityChannelStub::OnRemoteRequest, cmd = %{public}d, flags= %{public}d",
|
||||
code, option.GetFlags());
|
||||
std::u16string descriptor = AccessibleAbilityChannelStub::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (descriptor != remoteDescriptor) {
|
||||
HILOG_INFO("local descriptor is not equal to remote");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
auto itFunc = memberFuncMap_.find(code);
|
||||
if (itFunc != memberFuncMap_.end()) {
|
||||
auto requestFunc = itFunc->second;
|
||||
if (requestFunc != nullptr) {
|
||||
return (this->*requestFunc)(data, reply);
|
||||
}
|
||||
}
|
||||
HILOG_WARN("AbilityManagerStub::OnRemoteRequest, default case, need check.");
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleSearchElementInfoByAccessibilityId(MessageParcel &data,
|
||||
MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
int accessibilityWindowId = data.ReadInt32();
|
||||
int elementId = data.ReadInt64();
|
||||
int requestId = data.ReadInt32();
|
||||
|
||||
sptr<IRemoteObject> object = data.ReadRemoteObject();
|
||||
if (!object) {
|
||||
HILOG_ERROR("object is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
sptr<IAccessibilityInteractionOperationCallback> callback =
|
||||
iface_cast<IAccessibilityInteractionOperationCallback>(object);
|
||||
if (!callback) {
|
||||
HILOG_ERROR("callback is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
int mode = data.ReadInt32();
|
||||
bool result = SearchElementInfoByAccessibilityId(accessibilityWindowId, elementId, requestId, callback, mode);
|
||||
HILOG_DEBUG("SearchElementInfoByAccessibilityId ret = %{public}d", result);
|
||||
reply.WriteBool(result);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleSearchElementInfosByText(MessageParcel &data,
|
||||
MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
int accessibilityWindowId = data.ReadInt32();
|
||||
long elementId = data.ReadInt32();
|
||||
string text = data.ReadString();
|
||||
int requestId = data.ReadInt32();
|
||||
|
||||
sptr<IRemoteObject> object = data.ReadRemoteObject();
|
||||
sptr<IAccessibilityInteractionOperationCallback> callback =
|
||||
iface_cast<IAccessibilityInteractionOperationCallback>(object);
|
||||
|
||||
bool result = SearchElementInfosByText(accessibilityWindowId, elementId, text, requestId, callback);
|
||||
HILOG_DEBUG("SearchElementInfosByText ret = %{public}d", result);
|
||||
reply.WriteBool(result);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleFindFocusedElementInfo(MessageParcel &data, MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
int accessibilityWindowId = data.ReadInt32();
|
||||
long elementId = data.ReadInt32();
|
||||
int focusType = data.ReadInt32();
|
||||
int requestId = data.ReadInt32();
|
||||
|
||||
sptr<IRemoteObject> object = data.ReadRemoteObject();
|
||||
sptr<IAccessibilityInteractionOperationCallback> callback =
|
||||
iface_cast<IAccessibilityInteractionOperationCallback>(object);
|
||||
|
||||
bool result = FindFocusedElementInfo(accessibilityWindowId, elementId, focusType, requestId, callback);
|
||||
HILOG_DEBUG("FindFocusedElementInfo ret = %{public}d", result);
|
||||
reply.WriteBool(result);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleFocusMoveSearch(MessageParcel &data, MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
int accessibilityWindowId = data.ReadInt32();
|
||||
long elementId = data.ReadInt32();
|
||||
int direction = data.ReadInt32();
|
||||
int requestId = data.ReadInt32();
|
||||
|
||||
sptr<IRemoteObject> object = data.ReadRemoteObject();
|
||||
sptr<IAccessibilityInteractionOperationCallback> callback =
|
||||
iface_cast<IAccessibilityInteractionOperationCallback>(object);
|
||||
|
||||
bool result = FocusMoveSearch(accessibilityWindowId, elementId, direction, requestId, callback);
|
||||
HILOG_DEBUG("FocusMoveSearch ret = %{public}d", result);
|
||||
reply.WriteBool(result);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandlePerformAction(MessageParcel &data, MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
int accessibilityWindowId = data.ReadInt32();
|
||||
long elementId = data.ReadInt32();
|
||||
int action = data.ReadInt32();
|
||||
|
||||
vector<string> actionArgumentsKey{};
|
||||
vector<string> actionArgumentsValue{};
|
||||
map<string, string> actionArguments{};
|
||||
|
||||
if (!data.ReadStringVector(&actionArgumentsKey)) {
|
||||
HILOG_ERROR("ReadStringVector actionArgumentsKey failed");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (!data.ReadStringVector(&actionArgumentsValue)) {
|
||||
HILOG_ERROR("ReadStringVector actionArgumentsValue failed");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (actionArgumentsKey.size() != actionArgumentsValue.size()) {
|
||||
HILOG_ERROR("Read actionArguments failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
for (unsigned int i = 0; i < actionArgumentsKey.size(); i++) {
|
||||
actionArguments.insert(make_pair(actionArgumentsKey[i], actionArgumentsValue[i]));
|
||||
}
|
||||
|
||||
int requestId = data.ReadInt32();
|
||||
|
||||
auto callback = iface_cast<IAccessibilityInteractionOperationCallback>(data.ReadRemoteObject());
|
||||
if (!callback) {
|
||||
HILOG_ERROR("callback is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
bool result = PerformAction(accessibilityWindowId, elementId, action, actionArguments, requestId, callback);
|
||||
HILOG_DEBUG("PerformAction ret = %{public}d", result);
|
||||
reply.WriteBool(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleGetWindows(MessageParcel &data, MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
vector<AccessibilityWindowInfo> windows = GetWindows();
|
||||
if (!reply.WriteInt32((int32_t)windows.size())) {
|
||||
HILOG_ERROR("windows.size() write error: %{public}d, ", windows.size());
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
for (auto &window : windows) {
|
||||
if (!reply.WriteParcelable(&window)) {
|
||||
HILOG_ERROR("write windows failed");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandlePerformCommonAction(MessageParcel &data, MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
int action = data.ReadInt32();
|
||||
bool result = PerformCommonAction(action);
|
||||
|
||||
HILOG_DEBUG("PerformCommonAction ret = %{public}d", result);
|
||||
reply.WriteBool(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleDisableAbility(MessageParcel &data, MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
DisableAbility();
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleSetOnKeyPressEventResult(MessageParcel &data, MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
bool handled = data.ReadBool();
|
||||
int sequence = data.ReadInt32();
|
||||
SetOnKeyPressEventResult(handled, sequence);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleGetDisplayResizeScale(MessageParcel &data, MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
int displayId = data.ReadInt32();
|
||||
float result = GetDisplayResizeScale(displayId);
|
||||
|
||||
HILOG_DEBUG("GetDisplayResizeScale ret = %{public}f", result);
|
||||
reply.WriteFloat(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleGetDisplayResizeCenterX(MessageParcel &data, MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
int displayId = data.ReadInt32();
|
||||
float result = GetDisplayResizeCenterX(displayId);
|
||||
|
||||
HILOG_DEBUG("GetDisplayResizeCenterX ret = %{public}f", result);
|
||||
reply.WriteFloat(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleGetDisplayResizeCenterY(MessageParcel &data, MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
int displayId = data.ReadInt32();
|
||||
float result = GetDisplayResizeCenterY(displayId);
|
||||
|
||||
HILOG_DEBUG("GetDisplayResizeCenterY ret = %{public}f", result);
|
||||
reply.WriteFloat(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleGetDisplayResizeRect(MessageParcel &data, MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
int displayId = data.ReadInt32();
|
||||
Rect rect = GetDisplayResizeRect(displayId);
|
||||
|
||||
HILOG_DEBUG("GetDisplayResizeRect");
|
||||
reply.WriteParcelable(&rect);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleResetDisplayResize(MessageParcel &data, MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
int displayId = data.ReadInt32();
|
||||
bool animate = data.ReadBool();
|
||||
bool result = ResetDisplayResize(displayId, animate);
|
||||
|
||||
HILOG_DEBUG("ResetDisplayResize ret = %{public}d", result);
|
||||
reply.WriteBool(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleSetDisplayResizeScaleAndCenter(MessageParcel &data,
|
||||
MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
int displayId = data.ReadInt32();
|
||||
float scale = data.ReadFloat();
|
||||
float centerX = data.ReadFloat();
|
||||
float centerY = data.ReadFloat();
|
||||
bool animate = data.ReadBool();
|
||||
bool result = SetDisplayResizeScaleAndCenter(displayId, scale, centerX, centerY, animate);
|
||||
|
||||
HILOG_DEBUG("SetDisplayResizeScaleAndCenter ret = %{public}d", result);
|
||||
reply.WriteBool(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleSendSimulateGesture(MessageParcel &data, MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
int32_t sequence = data.ReadInt32();
|
||||
|
||||
vector<GesturePathDefine> gestureSteps;
|
||||
int32_t stepSize = data.ReadInt32();
|
||||
for (int32_t i = 0; i < stepSize; i++) {
|
||||
std::shared_ptr<GesturePathDefine> gestureStep(data.ReadParcelable<GesturePathDefine>());
|
||||
if (!gestureStep) {
|
||||
HILOG_ERROR("ReadParcelable<GesturePathDefine> failed");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
gestureSteps.emplace_back(*gestureStep);
|
||||
}
|
||||
SendSimulateGesture(sequence, gestureSteps);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityChannelStub::HandleIsFingerprintGestureDetectionValid(MessageParcel &data,
|
||||
MessageParcel &reply) {
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
bool result = IsFingerprintGestureDetectionValid();
|
||||
|
||||
HILOG_DEBUG("IsFingerprintGestureDetectionValid ret = %{public}d", result);
|
||||
reply.WriteBool(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,322 @@
|
||||
/*
|
||||
* 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 "accessible_ability_manager_service_proxy.h"
|
||||
#include "accessibility_errorcode.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_types.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
AccessibleAbilityManagerServiceClientProxy::AccessibleAbilityManagerServiceClientProxy(
|
||||
const sptr<IRemoteObject> &impl) : IRemoteProxy<IAccessibleAbilityManagerServiceClient>(impl)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AccessibleAbilityManagerServiceClientProxy::~AccessibleAbilityManagerServiceClientProxy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool AccessibleAbilityManagerServiceClientProxy::WriteInterfaceToken(MessageParcel &data)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
if (!data.WriteInterfaceToken(IAccessibleAbilityManagerServiceClient::GetDescriptor())) {
|
||||
HILOG_ERROR("write interface token failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccessibleAbilityManagerServiceClientProxy::SendEvent(const AccessibilityEventInfo &uiEvent, const int userId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uiEvent)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write parcelable AccessibilityEventInfo error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(userId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write userId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::SEND_EVENT),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("SendEvent fail, error: %{public}d", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t AccessibleAbilityManagerServiceClientProxy::RegisterStateCallback(
|
||||
const sptr<IAccessibleAbilityManagerServiceState> &client, const int userId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
if (client == nullptr) {
|
||||
HILOG_ERROR("%{public}s fail, Input client is null", __func__);
|
||||
return ErrCode::ERROR;
|
||||
}
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token error", __func__);
|
||||
return ErrCode::ERROR;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(client->AsObject())) {
|
||||
HILOG_ERROR("%{public}s fail, connection write client error", __func__);
|
||||
return ErrCode::ERROR;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(userId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write userId error", __func__);
|
||||
return ErrCode::ERROR;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::REGISTER_STATE_CALLBACK),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("SendEvent fail, error: %{public}d", error);
|
||||
return ErrCode::ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadUint32();
|
||||
}
|
||||
|
||||
std::vector<AccessibilityAbilityInfo> AccessibleAbilityManagerServiceClientProxy::GetAbilityList(const int abilityTypes,
|
||||
const int stateType)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
std::vector<AccessibilityAbilityInfo> errorList{};
|
||||
std::vector<AccessibilityAbilityInfo> abilityInfos{};
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token error", __func__);
|
||||
return errorList;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(abilityTypes)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write abilityTypes error", __func__);
|
||||
return errorList;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(stateType)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write stateType error", __func__);
|
||||
return errorList;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::GET_ABILITYLIST),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("SendEvent fail, error: %d", error);
|
||||
return errorList;
|
||||
}
|
||||
// read result
|
||||
int32_t abilityInfoSize = reply.ReadInt32();
|
||||
for (int i = 0; i < abilityInfoSize; i++) {
|
||||
std::shared_ptr<AccessibilityAbilityInfo> accessibilityAbilityInfo(
|
||||
reply.ReadParcelable<AccessibilityAbilityInfo>());
|
||||
if (!accessibilityAbilityInfo) {
|
||||
HILOG_ERROR("ReadParcelable<accessibilityAbilityInfo> failed");
|
||||
return errorList;
|
||||
}
|
||||
abilityInfos.emplace_back(*accessibilityAbilityInfo);
|
||||
}
|
||||
return abilityInfos;
|
||||
}
|
||||
|
||||
void AccessibleAbilityManagerServiceClientProxy::RegisterInteractionOperation(int windowId,
|
||||
const sptr <IAccessibilityInteractionOperation> &operation, const int userId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (operation == nullptr) {
|
||||
HILOG_ERROR("%{public}s fail, Input operation is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(windowId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write windowId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(operation->AsObject())) {
|
||||
HILOG_ERROR("%{public}s fail, connection write parcelable operation error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(userId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write userId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::REGISTER_INTERACTION_CONNECTION),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Register fail, error: %{public}d", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityManagerServiceClientProxy::DeregisterInteractionOperation(const int windowId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(windowId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write userId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::DEREGISTER_INTERACTION_CONNECTION),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Deregister fail, error: %{public}d", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleAbilityManagerServiceClientProxy::Interrupt(const int userId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(userId)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write userId error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::INTERRUPT),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Interrupt fail, error: %{public}d", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t AccessibleAbilityManagerServiceClientProxy::GetSuggestedInterval()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return ErrCode::ERROR;
|
||||
}
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::GET_SUGGESTED_INTERVAL),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Interrupt fail, error: %{public}d", error);
|
||||
return ErrCode::ERROR;
|
||||
}
|
||||
return reply.ReadInt64();
|
||||
}
|
||||
|
||||
void AccessibleAbilityManagerServiceClientProxy::RegisterAbilityConnectionClientTmp(const sptr<IRemoteObject>& obj)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(obj)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write obj", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::REGISTER_ABILITY_CONNECTION_CLIENT),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Interrupt fail, error: %{public}d", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> AccessibleAbilityManagerServiceClientProxy::GetObject()
|
||||
{
|
||||
return this->AsObject();
|
||||
}
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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 "accessible_ability_manager_service_state_proxy.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_types.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
AccessibleAbilityManagerServiceStateProxy::AccessibleAbilityManagerServiceStateProxy(
|
||||
const sptr<IRemoteObject> &impl) : IRemoteProxy<IAccessibleAbilityManagerServiceState>(impl)
|
||||
{}
|
||||
|
||||
AccessibleAbilityManagerServiceStateProxy::~AccessibleAbilityManagerServiceStateProxy()
|
||||
{}
|
||||
|
||||
bool AccessibleAbilityManagerServiceStateProxy::WriteInterfaceToken(MessageParcel &data)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
if (!data.WriteInterfaceToken(AccessibleAbilityManagerServiceStateProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("write interface token failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccessibleAbilityManagerServiceStateProxy::OnStateChanged(const uint32_t stateType)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int error = NO_ERROR;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write Token", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteUint32(stateType)) {
|
||||
HILOG_ERROR("%{public}s fail, connection write stateType error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IAccessibleAbilityManagerServiceState::Message::ON_STATE_CHANGED),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("OnStateChanged fail, error: %{public}d", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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 "accessible_ability_manager_service_state_stub.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "ipc_types.h"
|
||||
#include "iremote_object.h"
|
||||
#include "accessibility_system_ability_client.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
AccessibleAbilityManagerServiceStateStub::AccessibleAbilityManagerServiceStateStub()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
}
|
||||
|
||||
int AccessibleAbilityManagerServiceStateStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
HILOG_DEBUG("AccessibleAbilityManagerServiceStateStub::OnRemoteRequest, cmd = %{public}d, flags= %{public}d",
|
||||
code, option.GetFlags());
|
||||
std::u16string descriptor = AccessibleAbilityManagerServiceStateStub::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
|
||||
if (descriptor != remoteDescriptor) {
|
||||
HILOG_INFO("local descriptor is not equal to remote");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (code == static_cast<uint32_t>(IAccessibleAbilityManagerServiceState::Message::ON_STATE_CHANGED)) {
|
||||
HandleOnStateChanged(data, reply);
|
||||
}
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityManagerServiceStateStub::HandleOnStateChanged(MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
int stateType = data.ReadUint32();
|
||||
OnStateChanged(stateType);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
void AccessibleAbilityManagerServiceStateStub::OnStateChanged(const uint32_t stateType)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s stateType[%{public}d} " , __func__, stateType);
|
||||
std::shared_ptr<AccessibilitySystemAbilityClient> instance = AccessibilitySystemAbilityClient::GetInstance();
|
||||
if (instance == nullptr) {
|
||||
HILOG_DEBUG("%{public}s Can't get asac instance" , __func__);
|
||||
return;
|
||||
}
|
||||
if (stateType & AccessibilitySystemAbilityClient::STATE_ACCESSIBILITY_ENABLED) {
|
||||
instance->SetEnabled(true);
|
||||
} else {
|
||||
instance->SetEnabled(false);
|
||||
}
|
||||
|
||||
if (stateType & AccessibilitySystemAbilityClient::STATE_EXPLORATION_ENABLED) {
|
||||
instance->SetTouchExplorationEnabled(true);
|
||||
} else {
|
||||
instance->SetTouchExplorationEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
@ -0,0 +1,192 @@
|
||||
/*
|
||||
* 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 <memory>
|
||||
#include "accessible_ability_manager_service_stub.h"
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "ipc_types.h"
|
||||
#include "iremote_object.h"
|
||||
#include "refbase.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
AccessibleAbilityManagerServiceClientStub::AccessibleAbilityManagerServiceClientStub()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::SEND_EVENT)] =
|
||||
&AccessibleAbilityManagerServiceClientStub::HandleSendEvent;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::REGISTER_STATE_CALLBACK)] =
|
||||
&AccessibleAbilityManagerServiceClientStub::HandleRegisterStateCallback;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::GET_ABILITYLIST)] =
|
||||
&AccessibleAbilityManagerServiceClientStub::HandleGetAbilityList;
|
||||
memberFuncMap_[static_cast<uint32_t>
|
||||
(IAccessibleAbilityManagerServiceClient::Message::REGISTER_INTERACTION_CONNECTION)] =
|
||||
&AccessibleAbilityManagerServiceClientStub::HandleRegisterAccessibilityInteractionOperation;
|
||||
memberFuncMap_[static_cast<uint32_t>
|
||||
(IAccessibleAbilityManagerServiceClient::Message::DEREGISTER_INTERACTION_CONNECTION)] =
|
||||
&AccessibleAbilityManagerServiceClientStub::HandleDeregisterAccessibilityInteractionOperation;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::INTERRUPT)] =
|
||||
&AccessibleAbilityManagerServiceClientStub::HandleInterrupt;
|
||||
memberFuncMap_[static_cast<uint32_t>
|
||||
(IAccessibleAbilityManagerServiceClient::Message::GET_SUGGESTED_INTERVAL)] =
|
||||
&AccessibleAbilityManagerServiceClientStub::HandleGetSuggestedInterval;
|
||||
memberFuncMap_[static_cast<uint32_t>
|
||||
(IAccessibleAbilityManagerServiceClient::Message::REGISTER_ABILITY_CONNECTION_CLIENT)] =
|
||||
&AccessibleAbilityManagerServiceClientStub::HandleRegisterAbilityConnectionClientTmp;
|
||||
}
|
||||
|
||||
AccessibleAbilityManagerServiceClientStub::~AccessibleAbilityManagerServiceClientStub()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
memberFuncMap_.clear();
|
||||
}
|
||||
|
||||
int AccessibleAbilityManagerServiceClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
HILOG_DEBUG("AccessibleAbilityManagerServiceClientStub::OnRemoteRequest, cmd = %{public}d, flags= %{public}d",
|
||||
code, option.GetFlags());
|
||||
std::u16string descriptor = AccessibleAbilityManagerServiceClientStub::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
|
||||
if (descriptor != remoteDescriptor) {
|
||||
HILOG_INFO("local descriptor is not equal to remote");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
auto memFunc = memberFuncMap_.find(code);
|
||||
if (memFunc != memberFuncMap_.end()) {
|
||||
auto func = memFunc->second;
|
||||
if (func != nullptr) {
|
||||
return (this->*func)(data,reply);
|
||||
}
|
||||
}
|
||||
HILOG_WARN("AccessibleAbilityManagerServiceClientStub::OnRemoteRequest, default case, need check.");
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityManagerServiceClientStub::HandleSendEvent(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
std::shared_ptr<AccessibilityEventInfo> uiEvent(data.ReadParcelable<AccessibilityEventInfo>());
|
||||
if (!uiEvent) {
|
||||
HILOG_DEBUG("ReadParcelable<AbilityInfo> failed");
|
||||
return ERROR;
|
||||
}
|
||||
int userId = data.ReadInt32();
|
||||
SendEvent(*uiEvent, userId);
|
||||
|
||||
return ErrCode::NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityManagerServiceClientStub::HandleRegisterStateCallback(MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
sptr <IRemoteObject> obj = data.ReadRemoteObject();
|
||||
sptr <IAccessibleAbilityManagerServiceState> client = iface_cast<IAccessibleAbilityManagerServiceState>(obj);
|
||||
int userId = data.ReadInt32();
|
||||
uint64_t result = RegisterStateCallback(client, userId);
|
||||
reply.WriteUint64(result);
|
||||
|
||||
return ErrCode::NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityManagerServiceClientStub::HandleGetAbilityList(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int abilityTypes = data.ReadInt32();
|
||||
int stateType = data.ReadInt32();
|
||||
std::vector<AccessibilityAbilityInfo> abilityInfos{};
|
||||
abilityInfos = GetAbilityList(abilityTypes, stateType);
|
||||
|
||||
int32_t abilityInfoSize = abilityInfos.size();
|
||||
reply.WriteInt32(abilityInfoSize);
|
||||
for (auto &abilityInfo : abilityInfos) {
|
||||
if (!reply.WriteParcelable(&abilityInfo)) {
|
||||
HILOG_ERROR("ReadParcelable<accessibilityAbilityInfo> failed");
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
return ErrCode::NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityManagerServiceClientStub::HandleRegisterAccessibilityInteractionOperation(
|
||||
MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int windowId = data.ReadInt32();
|
||||
sptr <IRemoteObject> obj = data.ReadRemoteObject();
|
||||
sptr <IAccessibilityInteractionOperation> operation = iface_cast<IAccessibilityInteractionOperation>(obj);
|
||||
int userId = data.ReadInt32();
|
||||
RegisterInteractionOperation(windowId, operation, userId);
|
||||
|
||||
return ErrCode::NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityManagerServiceClientStub::HandleDeregisterAccessibilityInteractionOperation(
|
||||
MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int windowId = data.ReadInt32();
|
||||
DeregisterInteractionOperation(windowId);
|
||||
|
||||
return ErrCode::NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityManagerServiceClientStub::HandleInterrupt(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
int userId = data.ReadInt32();
|
||||
Interrupt(userId);
|
||||
|
||||
return ErrCode::NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityManagerServiceClientStub::HandleGetSuggestedInterval(MessageParcel &data,
|
||||
MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
uint64_t result = GetSuggestedInterval();
|
||||
|
||||
reply.WriteUint64(result);
|
||||
|
||||
return ErrCode::NO_ERROR;
|
||||
}
|
||||
|
||||
ErrCode AccessibleAbilityManagerServiceClientStub::HandleRegisterAbilityConnectionClientTmp(
|
||||
MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s" , __func__);
|
||||
|
||||
sptr <IRemoteObject> obj = data.ReadRemoteObject();
|
||||
|
||||
RegisterAbilityConnectionClientTmp(obj);
|
||||
|
||||
return ErrCode::NO_ERROR;
|
||||
}
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
230
frameworks/asacfwk/src/gesture_simulation.cpp
Normal file
230
frameworks/asacfwk/src/gesture_simulation.cpp
Normal file
@ -0,0 +1,230 @@
|
||||
/*
|
||||
* 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 <memory>
|
||||
#include "gesture_simulation.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
GesturePathPositionDefine::GesturePathPositionDefine(float positionX, float positionY)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
positionX_ = positionX;
|
||||
positionY_ = positionY;
|
||||
}
|
||||
|
||||
float GesturePathPositionDefine::GetPositionX()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start and positionX_ is %{public}f", __func__, positionX_);
|
||||
return positionX_;
|
||||
}
|
||||
|
||||
float GesturePathPositionDefine::GetPositionY()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start and positionY_ is %{public}f", __func__, positionY_);
|
||||
return positionY_;
|
||||
}
|
||||
|
||||
void GesturePathPositionDefine::SetPositionX(float positionX)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
positionX_ = positionX;
|
||||
}
|
||||
|
||||
void GesturePathPositionDefine::SetPositionY(float positionY)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
positionY_ = positionY;
|
||||
}
|
||||
|
||||
bool GesturePathPositionDefine::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Float, parcel, positionX_);
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Float, parcel, positionY_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GesturePathPositionDefine::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Float, parcel, positionX_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Float, parcel, positionY_);
|
||||
return true;
|
||||
}
|
||||
|
||||
GesturePathPositionDefine *GesturePathPositionDefine::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
GesturePathPositionDefine *gesturePathPositionDefine = new GesturePathPositionDefine();
|
||||
|
||||
if (gesturePathPositionDefine && !gesturePathPositionDefine->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("ReadFromParcel GesturePathPositionDefine failed.");
|
||||
delete gesturePathPositionDefine;
|
||||
gesturePathPositionDefine = nullptr;
|
||||
}
|
||||
|
||||
return gesturePathPositionDefine;
|
||||
}
|
||||
|
||||
GesturePathDefine::GesturePathDefine(GesturePathPositionDefine &startPosition,
|
||||
GesturePathPositionDefine &endPosition, uint32_t durationTime)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (startPosition.GetPositionX() < 0 || startPosition.GetPositionY() < 0) {
|
||||
HILOG_ERROR("startPosition: (%{public}f , %{public}f) is not allowed.",
|
||||
startPosition.GetPositionX(), startPosition.GetPositionY());
|
||||
return;
|
||||
}
|
||||
startPosition_ = startPosition;
|
||||
|
||||
if (endPosition.GetPositionX() < 0 || endPosition.GetPositionY() < 0) {
|
||||
HILOG_ERROR("endPosition : (%{public}f , %{public}f) is not allowed.",
|
||||
endPosition.GetPositionX(), endPosition.GetPositionY());
|
||||
return;
|
||||
}
|
||||
endPosition_ = endPosition;
|
||||
|
||||
durationTime_ = durationTime;
|
||||
}
|
||||
|
||||
uint32_t GesturePathDefine::GetDurationTime()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start and max stroke duration is %{public}d", __func__, durationTime_);
|
||||
return durationTime_;
|
||||
}
|
||||
|
||||
GesturePathPositionDefine &GesturePathDefine::GetEndPosition()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return endPosition_;
|
||||
}
|
||||
|
||||
uint32_t GesturePathDefine::GetMaxStrokeDuration()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start and max stroke duration is %{public}d", __func__, MAX_STROKE_DURATION);
|
||||
return MAX_STROKE_DURATION;
|
||||
}
|
||||
|
||||
uint32_t GesturePathDefine::GetMaxStrokes()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start and max strokes is %{public}d", __func__, MAX_STROKES);
|
||||
return MAX_STROKES;
|
||||
}
|
||||
|
||||
GesturePathPositionDefine &GesturePathDefine::GetStartPosition()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return startPosition_;
|
||||
}
|
||||
|
||||
void GesturePathDefine::SetDurationTime(uint32_t durationTime)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
durationTime_ = durationTime;
|
||||
}
|
||||
|
||||
void GesturePathDefine::SetEndPosition(GesturePathPositionDefine &endPosition)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
endPosition_ = endPosition;
|
||||
}
|
||||
|
||||
void GesturePathDefine::SetStartPosition(GesturePathPositionDefine &startPosition)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
startPosition_ = startPosition;
|
||||
}
|
||||
|
||||
bool GesturePathDefine::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
std::unique_ptr<GesturePathPositionDefine> startPosition(parcel.ReadParcelable<GesturePathPositionDefine>());
|
||||
if (!startPosition) {
|
||||
HILOG_ERROR("ReadParcelable startPosition failed.");
|
||||
return false;
|
||||
}
|
||||
startPosition_ = *startPosition;
|
||||
|
||||
std::unique_ptr<GesturePathPositionDefine> endPosition(parcel.ReadParcelable<GesturePathPositionDefine>());
|
||||
if (!endPosition) {
|
||||
HILOG_ERROR("ReadParcelable endPosition failed.");
|
||||
return false;
|
||||
}
|
||||
endPosition_ = *endPosition;
|
||||
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, durationTime_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GesturePathDefine::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &startPosition_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &endPosition_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, durationTime_);
|
||||
return true;
|
||||
}
|
||||
|
||||
GesturePathDefine *GesturePathDefine::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
GesturePathDefine *gesturePathDefine = new GesturePathDefine();
|
||||
|
||||
if (gesturePathDefine && !gesturePathDefine->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("ReadFromParcel GesturePathDefine failed.");
|
||||
delete gesturePathDefine;
|
||||
gesturePathDefine = nullptr;
|
||||
}
|
||||
|
||||
return gesturePathDefine;
|
||||
}
|
||||
|
||||
GestureResultListenerInfo::GestureResultListenerInfo(std::vector<GesturePathDefine> gesturePathDefine,
|
||||
std::shared_ptr<GestureResultListener>& gestureResultListener)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
|
||||
if (gesturePathDefine.empty()) {
|
||||
HILOG_ERROR("There is no gesture path.");
|
||||
gestureResultListener = nullptr;
|
||||
} else {
|
||||
for (auto gesturePath : gesturePathDefine) {
|
||||
gesturePathDefine_.push_back(gesturePath);
|
||||
}
|
||||
gestureResultListener_ = gestureResultListener;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<GestureResultListener>& GestureResultListenerInfo::GetGestureResultListener()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return gestureResultListener_;
|
||||
}
|
||||
|
||||
std::vector<GesturePathDefine> GestureResultListenerInfo::GetGesturePathDefine()
|
||||
{
|
||||
HILOG_DEBUG("%{public}s start.", __func__);
|
||||
return gesturePathDefine_;
|
||||
}
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
70
interfaces/innerkits/asacfwk/BUILD.gn
Normal file
70
interfaces/innerkits/asacfwk/BUILD.gn
Normal file
@ -0,0 +1,70 @@
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//base/accessibility/frameworks/asacfwk/asacfwk.gni")
|
||||
|
||||
config("accessibilityclient_config") {
|
||||
visibility = [ ":*" ]
|
||||
|
||||
include_dirs = [
|
||||
"include",
|
||||
"//base/accessibility/frameworks/asacfwk/include",
|
||||
"//base/accessibility/util/include",
|
||||
"//base/accessibility/common/log/include",
|
||||
"//base/accessibility/dummyData",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/base/include",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include",
|
||||
#"//foundation/appexecfwk/standard/common/log/include",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"AAMS_LOG_TAG = \"accessibility_aakit\"",
|
||||
"AAMS_LOG_DOMAIN = 0xD005202",
|
||||
]
|
||||
|
||||
if (target_cpu == "arm") {
|
||||
cflags = [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
}
|
||||
|
||||
ohos_shared_library("accessibilityclient") {
|
||||
install_enable = true
|
||||
|
||||
sources = asacfwk_files
|
||||
|
||||
configs = [
|
||||
":accessibilityclient_config",
|
||||
# "//foundation/aafwk/standard/interfaces/innerkits/base:base_public_config",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//utils/native/base:utils",
|
||||
"//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native",
|
||||
"//base/miscservices/time/services:time_service",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ipc:ipc_core",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"appexecfwk_standard:appexecfwk_base",
|
||||
"appexecfwk_standard:appexecfwk_core",
|
||||
"aafwk_standard:want",
|
||||
"aafwk_standard:ability_manager",
|
||||
"samgr_standard:samgr_proxy",
|
||||
|
||||
]
|
||||
|
||||
subsystem_name = "accessibility"
|
||||
part_name = "accessibility_standard"
|
||||
}
|
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* 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_ABILILTY_INFO_H
|
||||
#define ACCESSIBILITY_ABILILTY_INFO_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include "ability_info.h"
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
|
||||
// The capability types of the accessible ability.
|
||||
enum Capability : uint32_t {
|
||||
CAPABILITY_RETRIEVE = 0x0001,
|
||||
CAPABILITY_TOUCH_GUIDE = 0x0002,
|
||||
CAPABILITY_KEY_EVENT_OBSERVER = 0x0008,
|
||||
CAPABILITY_ZOOM = 0x0010,
|
||||
CAPABILITY_GESTURE = 0x0020,
|
||||
};
|
||||
|
||||
// The accessibility ability types for feedbacks.
|
||||
enum AccessibilityAbilityTypes : uint32_t {
|
||||
ACCESSIBILITY_ABILITY_TYPE_INVALID = 0x00000000,
|
||||
ACCESSIBILITY_ABILITY_TYPE_SPOKEN = 0x00000001,
|
||||
ACCESSIBILITY_ABILITY_TYPE_HAPTIC = 0x00000002,
|
||||
ACCESSIBILITY_ABILITY_TYPE_AUDIBLE = 0x00000004,
|
||||
ACCESSIBILITY_ABILITY_TYPE_VISUAL = 0x00000008,
|
||||
ACCESSIBILITY_ABILITY_TYPE_GENERIC = 0x00000010,
|
||||
ACCESSIBILITY_ABILITY_TYPE_ALL = 0xFFFFFFFF,
|
||||
};
|
||||
|
||||
// The swipe types of fingerprint gesture.
|
||||
// enum FingerprintGestureTypes : uint32_t {
|
||||
// FINGERPRINT_GESTURE_UP = 0x1,
|
||||
// FINGERPRINT_GESTURE_DOWN = 0x2,
|
||||
// FINGERPRINT_GESTURE_LEFT = 0x4,
|
||||
// FINGERPRINT_GESTURE_RIGHT = 0x8,
|
||||
// FINGERPRINT_GESTURE_ALL = 0xFFFFFFFF,
|
||||
// };
|
||||
|
||||
// The interception types of key event.
|
||||
// enum KeyEventInterceptionTypes : uint32_t{
|
||||
// INTERCEPT_KEY_POWER = 0x001,
|
||||
// INTERCEPT_KEY_VOLUME_UP = 0x002,
|
||||
// INTERCEPT_KEY_VOLUME_DOWN = 0x004,
|
||||
// INETRCEPT_KEY_ALL = 0xFFFFFFFF,
|
||||
// };
|
||||
|
||||
class AccessibilityAbilityInfo : public Parcelable {
|
||||
public:
|
||||
|
||||
AccessibilityAbilityInfo() = default;
|
||||
~AccessibilityAbilityInfo() = default;
|
||||
|
||||
AccessibilityAbilityInfo(AppExecFwk::AbilityInfo abilityInfo);
|
||||
|
||||
/**
|
||||
* @brief Obtains information about the application with the accessible ability.
|
||||
* @param
|
||||
* @return Return information about the application with the accessible ability.
|
||||
*/
|
||||
const AppExecFwk::AbilityInfo &GetAbilityInfo();
|
||||
|
||||
/**
|
||||
* @brief Obtains the types of the accessible ability.
|
||||
* @param
|
||||
* @return Return the type of the accessible ability.
|
||||
*/
|
||||
uint32_t GetAccessibilityAbilityType();
|
||||
|
||||
/**
|
||||
* @brief Obtains the types of the capabilities.
|
||||
* @param
|
||||
* @return Return the types of the capabilities.
|
||||
*/
|
||||
uint32_t GetCapabilityValues();
|
||||
|
||||
/**
|
||||
* @brief Obtains the description of the accessible ability.
|
||||
* @param
|
||||
* @return Return the description of the accessible ability.
|
||||
*/
|
||||
std::string GetDescription();
|
||||
|
||||
/**
|
||||
* @brief Obtains the type of the accessible events.
|
||||
* @param
|
||||
* @return Return the type of the accessible events.
|
||||
*/
|
||||
uint32_t GetEventTypes();
|
||||
|
||||
/**
|
||||
* @brief Obtains the id of the accessible ability.
|
||||
* @param
|
||||
* @return Return the id of the accessible ability.
|
||||
*/
|
||||
std::string GetId();
|
||||
|
||||
/**
|
||||
* @brief Obtains the name of the accessible ability.
|
||||
* @param
|
||||
* @return Return the name of the accessible ability.
|
||||
*/
|
||||
std::string GetName();
|
||||
|
||||
/**
|
||||
* @brief Obtains the package name of the accessible ability.
|
||||
* @param
|
||||
* @return Return the package name of the accessible ability.
|
||||
*/
|
||||
std::string GetPackageName();
|
||||
|
||||
/**
|
||||
* @brief Obtains the target bundles's name that you are listening on.
|
||||
* @param
|
||||
* @return Return the target bundles's name that you are listening on.
|
||||
*/
|
||||
std::vector<std::string> GetFilterBundleNames();
|
||||
|
||||
/**
|
||||
* @brief Obtains the setting ability of the accessible ability.
|
||||
* @param
|
||||
* @return Return the setting ability of the accessible ability.
|
||||
*/
|
||||
std::string GetSettingsAbility();
|
||||
|
||||
/**
|
||||
* @brief Get notification timeout in ms.
|
||||
* @param
|
||||
* @return Return notification timeout in ms.
|
||||
*/
|
||||
uint32_t GetNotificationTimeout();
|
||||
|
||||
/**
|
||||
* @brief Get UI interactive timeout in ms
|
||||
* @param
|
||||
* @return Return UI interactive timeout in ms
|
||||
*/
|
||||
uint32_t GetUiInteractiveTime();
|
||||
|
||||
/* get UI noninteractive timeout in ms. */
|
||||
/**
|
||||
* @brief Get UI noninteractive timeout in ms.
|
||||
* @param
|
||||
* @return Return UI noninteractive timeout in ms.
|
||||
*/
|
||||
uint32_t GetUiNoninteractiveTime();
|
||||
|
||||
/**
|
||||
* @brief read this sequenceable object from a Parcel.
|
||||
* @param parcel Indicates the Parcel object into which the sequenceable object has been marshaled.
|
||||
* @return Return true if read successfully, else return false.
|
||||
*/
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
|
||||
/**
|
||||
* @brief Marshals this sequenceable object into a Parcel.
|
||||
* @param parcel Indicates the Parcel object to which the sequenceable object will be marshaled.
|
||||
* @return Return true if Marshal successfully, else return false.
|
||||
*/
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
||||
/**
|
||||
* @brief Unmarshals this sequenceable object from a Parcel.
|
||||
* @param parcel Indicates the Parcel object into which the sequenceable object has been marshaled.
|
||||
* @return Return a sequenceable object of AccessibilityAbilityInfo.
|
||||
*/
|
||||
static AccessibilityAbilityInfo *Unmarshalling(Parcel &parcel);
|
||||
|
||||
/**
|
||||
* @brief Set the types of the capabilities.
|
||||
* @param capabilities the capabilities to set.
|
||||
* @return
|
||||
*/
|
||||
inline void SetCapabilityValues(uint32_t capabilities) {capabilities_ = capabilities;};
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief Parse config files of the accessible ability.
|
||||
* @param
|
||||
* @return Return true if parses config files successfully, else return false.
|
||||
*/
|
||||
bool ParseAAConfig();
|
||||
|
||||
AppExecFwk::AbilityInfo abilityInfo_;
|
||||
uint32_t abilityTypes_ = 0;
|
||||
uint32_t capabilities_ = 0;
|
||||
uint32_t eventTypes_ = 0;
|
||||
uint32_t notificationTimeout_ = 0;
|
||||
uint32_t uiInteractiveTimeout_ = 10000;
|
||||
uint32_t uiNoninteractiveTimeout_ = 2000;
|
||||
std::string description_;
|
||||
std::string settingsAbility_;
|
||||
std::vector<std::string> targetBundleNames_;
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ACCESSIBILITY_ABILITY_INFO_H
|
1827
interfaces/innerkits/asacfwk/include/accessibility_element_info.h
Normal file
1827
interfaces/innerkits/asacfwk/include/accessibility_element_info.h
Normal file
File diff suppressed because it is too large
Load Diff
685
interfaces/innerkits/asacfwk/include/accessibility_event_info.h
Normal file
685
interfaces/innerkits/asacfwk/include/accessibility_event_info.h
Normal file
@ -0,0 +1,685 @@
|
||||
/*
|
||||
* 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_EVENT_INFO_H
|
||||
#define ACCESSIBILITY_EVENT_INFO_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "accessibility_element_info.h"
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
enum WindowUpdateType : int {
|
||||
WINDOW_UPDATE_INVALID = 0,
|
||||
WINDOW_UPDATE_ACCESSIBILITY_FOCUSED = 0x00000001,
|
||||
WINDOW_UPDATE_FOCUSED = 0x00000002,
|
||||
WINDOW_UPDATE_ACTIVE = 0x00000004,
|
||||
WINDOW_UPDATE_ADDED = 0x00000008,
|
||||
WINDOW_UPDATE_REMOVED = 0x00000010,
|
||||
WINDOW_UPDATE_BOUNDS = 0x00000020,
|
||||
WINDOW_UPDATE_TITLE = 0x00000040,
|
||||
WINDOW_UPDATE_LAYER = 0x00000080,
|
||||
WINDOW_UPDATE_PARENT = 0x00000100,
|
||||
WINDOW_UPDATE_CHILDREN = 0x00000200,
|
||||
WINDOW_UPDATE_PIP = 0x00000400,
|
||||
};
|
||||
|
||||
enum WindowsContentChangeTypes : int {
|
||||
CONTENT_CHANGE_TYPE_INVALID = 0,
|
||||
CONTENT_CHANGE_TYPE_SUBTREE = 0x00000001,
|
||||
CONTENT_CHANGE_TYPE_TEXT = 0x00000002,
|
||||
CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION = 0x00000004,
|
||||
};
|
||||
|
||||
enum EventType : int {
|
||||
TYPE_VIEW_INVALID = 0,
|
||||
TYPE_VIEW_CLICKED_EVENT = 0x00000001,
|
||||
TYPE_VIEW_LONG_CLICKED_EVENT = 0x00000002,
|
||||
TYPE_VIEW_SELECTED_EVENT = 0x00000004,
|
||||
TYPE_VIEW_FOCUSED_EVENT = 0x00000008,
|
||||
TYPE_VIEW_TEXT_UPDATE_EVENT = 0x00000010,
|
||||
TYPE_PAGE_STATE_UPDATE = 0x00000020,
|
||||
TYPE_NOTIFICATION_UPDATE_EVENT = 0x00000040,
|
||||
TYPE_VIEW_HOVER_ENTER_EVENT = 0x00000080,
|
||||
TYPE_VIEW_HOVER_EXIT_EVENT = 0x00000100,
|
||||
TYPE_TOUCH_GUIDE_GESTURE_BEGIN = 0x00000200,
|
||||
TYPE_TOUCH_GUIDE_GESTURE_END = 0x00000400,
|
||||
TYPE_PAGE_CONTENT_UPDATE = 0x00000800,
|
||||
TYPE_VIEW_SCROLLED_EVENT = 0x000001000,
|
||||
TYPE_VIEW_TEXT_SELECTION_UPDATE_EVENT = 0x000002000,
|
||||
TYPE_PUBLIC_NOTICE_EVENT = 0x00004000,
|
||||
TYPE_VIEW_ACCESSIBILITY_FOCUSED_EVENT = 0x00008000,
|
||||
TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED_EVENT = 0x00010000,
|
||||
TYPE_VIEW_TEXT_MOVE_UNIT_EVENT = 0x00020000,
|
||||
TYPE_TOUCH_GUIDE_BEGIN = 0x00040000,
|
||||
TYPE_TOUCH_GUIDE_END = 0x00080000,
|
||||
TYPE_TOUCH_BEGIN = 0x00100000,
|
||||
TYPE_TOUCH_END = 0x00200000,
|
||||
TYPE_WINDOW_UPDATE = 0x00400000,
|
||||
TYPES_ALL_MASK = 0xFFFFFFFF,
|
||||
};
|
||||
|
||||
enum NotificationCategory : int {
|
||||
CATEGORY_INVALID = 0,
|
||||
CATEGORY_CALL = 0x00000001,
|
||||
CATEGORY_MSG = 0x00000002,
|
||||
CATEGORY_EMAIL = 0x00000004,
|
||||
CATEGORY_EVENT = 0x00000008,
|
||||
CATEGORY_PROMO = 0x00000010,
|
||||
CATEGORY_ALARM = 0x00000020,
|
||||
CATEGORY_PROGRESS = 0x00000040,
|
||||
CATEGORY_SOCIAL = 0x00000080,
|
||||
CATEGORY_ERR = 0x00000100,
|
||||
CATEGORY_TRANSPORT = 0x00000200,
|
||||
CATEGORY_SYS = 0x00000400,
|
||||
CATEGORY_SERVICE = 0x00000800,
|
||||
CATEGORY_OTHERS = 0x00001000,
|
||||
};
|
||||
/*
|
||||
* The class supply the content information about the event.
|
||||
* The SetXxx() API is almost supplied to ACE to set the information.
|
||||
* Parts of SetXxx() API is called by AAMS, such as: SetConnectId().
|
||||
* The GetXxx() API is almost supplied to AA to get the information.
|
||||
*/
|
||||
class AccessibilityMemo : public Parcelable {
|
||||
public:
|
||||
/**
|
||||
* @brief Construct
|
||||
* @param
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
AccessibilityMemo() {}
|
||||
|
||||
/**
|
||||
* @brief AAMS called to set the id of the IAccessibleAbilityChannel
|
||||
* @param channelId The id of the IAccessibleAbilityChannel
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetChannelId(const int channelId);
|
||||
|
||||
/**
|
||||
* @brief Get the id of the IAccessibleAbilityChannel
|
||||
* @param -
|
||||
* @return The id of the IAccessibleAbilityChannel
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetChannelId() const;
|
||||
|
||||
/**
|
||||
* @brief Set the component of the event related.
|
||||
* @param componentId The id of component.
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetSource(const int componentId);
|
||||
|
||||
/**
|
||||
* @brief Get the node information related with the event
|
||||
* @param -
|
||||
* @return The node information related with the event
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
bool GetSource(AccessibilityElementInfo &elementInfo) const;
|
||||
|
||||
/**
|
||||
* @brief Gets the view(component) ID associated with the accessibility event.
|
||||
* @param -
|
||||
* @return The view(component) ID associated with the accessibility event.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetViewId() const;
|
||||
|
||||
/**
|
||||
* @brief Gets the accessibility ID of the component.
|
||||
* @param -
|
||||
* @return The accessibility ID of the component.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetAccessibilityId() const;
|
||||
|
||||
/**
|
||||
* @brief Set the window ID associated with the accessibility event.
|
||||
* @param windowId The window ID associated with the accessibility event.
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetWindowId(const int windowId);
|
||||
|
||||
/**
|
||||
* @brief Gets the window ID associated with the accessibility event.
|
||||
* @param -
|
||||
* @return The window ID associated with the accessibility event.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
|
||||
int GetWindowId() const;
|
||||
|
||||
/**
|
||||
* @brief Gets the current index of listed items or text postion associated with the current event.
|
||||
* @param -
|
||||
* @return The current index of listed items or text postion associated with the current event.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetCurrentIndex() const;
|
||||
|
||||
/**
|
||||
* @brief Sets the current index of listed items or text postion associated with the current event.
|
||||
* @param index The current index of listed items or text postion associated with the current event.
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetCurrentIndex(const int index);
|
||||
|
||||
/**
|
||||
* @brief Gets the start index of listed items on the screen.
|
||||
* @param -
|
||||
* @return The start index of listed items. It is unique value for the listed items.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetBeginIndex() const;
|
||||
|
||||
/**
|
||||
* @brief Sets the start index of listed items on the screen.
|
||||
* @param index The start index of listed items. It is unique value for the listed items.
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetBeginIndex(const int index);
|
||||
|
||||
/**
|
||||
* @brief Gets the number items on the screen.
|
||||
* @param -
|
||||
* @return The number of items.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetItemCounts() const;
|
||||
|
||||
/**
|
||||
* @brief Sets the number items on the screen.
|
||||
* @param ItemCounts The number of items.
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetItemCounts(const int itemCounts);
|
||||
|
||||
/**
|
||||
* @brief Gets the end index of listed items on the screen.
|
||||
* @param -
|
||||
* @return The end index of listed items on the screen.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetEndIndex() const;
|
||||
|
||||
/**
|
||||
* @brief Sets the end index of listed items on the screen.
|
||||
* @param index The end index of listed items on the screen.
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetEndIndex(const int index);
|
||||
|
||||
/**
|
||||
* @brief Gets the class(component type) name.
|
||||
* @param -
|
||||
* @return The class(component type) name.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
std::string GetComponentType() const;
|
||||
|
||||
/**
|
||||
* @brief Sets the class(component type) name.
|
||||
* @param className The class(component type) name.
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetComponentType(const std::string &className);
|
||||
|
||||
/**
|
||||
* @brief Gets the before text changed of the component.
|
||||
* @param -
|
||||
* @return The before text changed of the component.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
std::string GetBeforeText() const;
|
||||
|
||||
/**
|
||||
* @brief Set the before text changed of the component.
|
||||
* @param beforeText The before text changed of the component.
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetBeforeText(const std::string &beforeText);
|
||||
|
||||
/**
|
||||
* @brief Adds an text to the content list.
|
||||
* @param content Indicates the text to add.
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void AddContent(const std::string &content);
|
||||
|
||||
/**
|
||||
* @brief Gets the content list in the event.
|
||||
* @param -
|
||||
* @return Returns the content list in the event.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
std::vector<std::string> GetContentList() const;
|
||||
|
||||
/**
|
||||
* @brief Gets the last content of the component(The text of changed after).
|
||||
* @param -
|
||||
* @return The last content of the component(The text of changed after).
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
std::string GetLatestContent() const;
|
||||
|
||||
/**
|
||||
* @brief Sets the last content of the component.
|
||||
* @param content Indicates the last content to set for the component.
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetLatestContent(const std::string &content);
|
||||
|
||||
/**
|
||||
* @brief Gets the accessibility event description.
|
||||
* @param -
|
||||
* @return The accessibility event description
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
std::string GetDescription() const;
|
||||
|
||||
/**
|
||||
* @brief Sets the accessibility event description.
|
||||
* @param contentDescription The accessibility event description
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetDescription(const std::string &contentDescription);
|
||||
|
||||
/*Parcel*//**
|
||||
* @brief Used for IPC communication
|
||||
* @param parcel
|
||||
* @return rue: Read parcel data successfully; ohterwise is not.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
|
||||
/**
|
||||
* @brief Used for IPC communication
|
||||
* @param parcel
|
||||
* @return true: Write parcel data successfully; ohterwise is not.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @param parcel Used for IPC communication
|
||||
* @return Read AccessibilityMemo from parcel data
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
static AccessibilityMemo *Unmarshalling(Parcel &parcel);
|
||||
|
||||
private:
|
||||
int channelId_ = 0;
|
||||
int componentId_ = 0;
|
||||
int windowId_ = 0;
|
||||
int currentIndex_ = 0;
|
||||
int beginIndex_ = 0;
|
||||
int endIndex_ = 0;
|
||||
std::vector<std::string> contents_{};
|
||||
std::string componentType_ = "";
|
||||
std::string description_ = "";
|
||||
std::string beforeText_ = "";
|
||||
std::string latestConent_ = "";
|
||||
int elementId_ = 0;
|
||||
int itemCounts_ = 0;
|
||||
};
|
||||
|
||||
/*
|
||||
* The class define the event types and supply the api to
|
||||
* get/set the property of event. and it triggerred by UI
|
||||
* changed and sent to AA. According to the event property,
|
||||
* AA can get event properties, such as: action triggerred
|
||||
* the event and the source.
|
||||
*/
|
||||
class AccessibilityEventInfo : public AccessibilityMemo{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct
|
||||
* @param
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
AccessibilityEventInfo() {}
|
||||
|
||||
/**
|
||||
* @brief Construct
|
||||
* @param eventType the type of event info
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
AccessibilityEventInfo(EventType eventType);
|
||||
|
||||
/**
|
||||
* @brief Construct
|
||||
* @param windowId The id of window
|
||||
* @param windowChangeTypes the window change type
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
AccessibilityEventInfo(int windowId, WindowUpdateType windowChangeTypes);
|
||||
|
||||
/**
|
||||
* @brief Gets the number of accessibility records.
|
||||
* @note It is same to getCount()
|
||||
* @param -
|
||||
* @return The number of the records that describe the information of current event
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetRecordCount() const;
|
||||
|
||||
/**
|
||||
* @brief Set the number of accessibility records.
|
||||
* @note It is same to setCount(int count)
|
||||
* @param recordCount The number of the records that describe the information of current event
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetRecordCount(const int recordCount);
|
||||
|
||||
/**
|
||||
* @brief Adds an accessibility record to describe the information of the current event.
|
||||
* @note It is same to addRecord(AccessibilityEventInfo eventInfo)
|
||||
* @param record The records that describe the information of current event
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void AddRecord(const AccessibilityEventInfo &record);
|
||||
|
||||
/**
|
||||
* @brief Get the record by index.
|
||||
* @note Remained
|
||||
* @param
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
AccessibilityEventInfo GetRecord(const int index); //remained
|
||||
|
||||
/**
|
||||
* @brief Gets the accessibility record list.
|
||||
* @param
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
std::vector<AccessibilityEventInfo> GetRecords();
|
||||
|
||||
/**
|
||||
* @brief Gets the type of an accessibility event.
|
||||
* @note It is same to the getAccessibilityEventType()
|
||||
* @param -
|
||||
* @return The type of an accessibility event.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
EventType GetEventType() const;
|
||||
|
||||
/**
|
||||
* @brief Get the window content changed types
|
||||
* @param -
|
||||
* @return The window content changed types. Refer to "WindowsContentChangeTypes"
|
||||
* @since 3
|
||||
* * @sysCap Accessibility
|
||||
*/
|
||||
WindowsContentChangeTypes GetWindowContentChangeTypes() const;
|
||||
|
||||
/**
|
||||
* @brief Set the window content changed types
|
||||
* @param changeTypes The window content changed types. Refer to "WindowsContentChangeTypes"
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetWindowContentChangeTypes(const WindowsContentChangeTypes changeTypes);
|
||||
|
||||
/**
|
||||
* @brief Get the window changed types
|
||||
* @param -
|
||||
* @return The window changed types.refer to WindowUpdateType
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
WindowUpdateType GetWindowChangeTypes() const;
|
||||
|
||||
/**
|
||||
* @brief Set the window changed types
|
||||
* @param changeTypes The window changed types.refer to WindowUpdateType
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetWindowChangeTypes(const WindowUpdateType changeTypes);
|
||||
|
||||
/**
|
||||
* @brief Sets the type of an accessibility event.
|
||||
* @note It is same to setAccessibilityEventType(int accessibilityEventType)
|
||||
* @param eventType The type of an accessibility event. Refer to "EventType"
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetEventType(const EventType eventType);
|
||||
|
||||
/**
|
||||
* @brief AA get the time of accessibility event is sent from ASAC.
|
||||
* @param -
|
||||
* @return The time of accessibility event is sent from ASAC
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
long long GetTimeStamp() const;
|
||||
|
||||
/**
|
||||
* @brief ASAC set the time of accessibility is sent to AA
|
||||
* @param eventTime The time of accessibility event is sent from ASAC
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetTimeStamp(const long long eventTime); //remained:for send event timestamp
|
||||
|
||||
/**
|
||||
* @brief Gets the bundle name of the event source, that is, the bundle name of the target application.
|
||||
* @param -
|
||||
* @return Returns the bundle name of the event source.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
std::string GetBundleName() const;
|
||||
|
||||
/**
|
||||
* @brief Set the bundle name of the event source, that is, the bundle name of the target application.
|
||||
* @param bundleName The bundle name of the event source.
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetBundleName(const std::string &bundleName);
|
||||
|
||||
/**
|
||||
* @brief Set the move granularity of the text
|
||||
* @param granularity The move granularity of the text. Refer to "AccessibilityElementInfo.TextMoveUnit"
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetTextMovementStep(const TextMoveUnit granularity);
|
||||
|
||||
/**
|
||||
* @brief Get the move granularity of the text
|
||||
* @param -
|
||||
* @return he move granularity of the text. Refer to "AccessibilityElementInfo.TextMoveUnit"
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
TextMoveUnit GetTextMovementStep() const;
|
||||
|
||||
/**
|
||||
* @brief Sets the action that triggers the accessibility event.
|
||||
* @param action The operation of the event. Refer to "AccessibilityElementInfo.ActionType"
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetTriggerAction(const ActionType action);
|
||||
|
||||
/**
|
||||
* @brief Gets the action that triggers the accessibility event.
|
||||
* @param -
|
||||
* @return The operation of the event. Refer to "AccessibilityElementInfo.ActionType"
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
ActionType GetTriggerAction() const;
|
||||
|
||||
/**
|
||||
* @brief Set the information of accessibility event of [TYPE_NOTIFICATION_UPDATE_EVENT]
|
||||
* @param category Refer to [NotificationCategory], It maybe changed from APP
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetNotificationInfo(const NotificationCategory category);
|
||||
|
||||
/**
|
||||
* @brief Get the information of accessibility event of [TYPE_NOTIFICATION_UPDATE_EVENT]
|
||||
* @param -
|
||||
* @return Refer to [NotificationCategory], It maybe changed from APP
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
NotificationCategory GetNotificationInfo() const;
|
||||
|
||||
/*Parcel*/
|
||||
/**
|
||||
* @brief Used for IPC comminication
|
||||
* @param parcel
|
||||
* @return true: Read parcel data successfully; ohterwise is not.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
|
||||
/**
|
||||
* @brief Used for IPC comminication
|
||||
* @param parcel
|
||||
* @return true: Write parcel data successfully; ohterwise is not.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
||||
/**
|
||||
* @brief Used for IPC comminication
|
||||
* @param parcel
|
||||
* @return Read AccessibilityEventInfo from parcel data
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
static AccessibilityEventInfo *Unmarshalling(Parcel &parcel);
|
||||
|
||||
/**
|
||||
* @brief Set the page ID associated with the accessibility event.
|
||||
* @param pageId The page ID associated with the accessibility event.
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetPageId(const int pageId);
|
||||
|
||||
/**
|
||||
* @brief Gets the page ID associated with the accessibility event.
|
||||
* @param -
|
||||
* @return The page ID associated with the accessibility event.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
|
||||
int GetPageId() const;
|
||||
|
||||
private:
|
||||
EventType eventType_ = TYPE_VIEW_INVALID;
|
||||
std::string bundleName_ = "";
|
||||
ActionType triggerAction_ = ACCESSIBILITY_ACTION_INVALID;
|
||||
long long timeStamp_ = 0;
|
||||
TextMoveUnit textMoveStep_ = STEP_CHARACTER;
|
||||
WindowsContentChangeTypes windowContentChangeTypes_ = CONTENT_CHANGE_TYPE_INVALID;
|
||||
WindowUpdateType windowChangeTypes_ = WINDOW_UPDATE_INVALID;
|
||||
int recordsCount_ = 0;
|
||||
std::vector<AccessibilityEventInfo> records_{};
|
||||
NotificationCategory category_ = CATEGORY_INVALID;
|
||||
int pageId_ = 0;
|
||||
};
|
||||
|
||||
} //namesapce Accessibility
|
||||
} //namespace OHOS
|
||||
#endif
|
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* 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_INTERACTION_OPERATION_H
|
||||
#define ACCESSIBILITY_INTERACTION_OPERATION_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "accessibility_interaction_operation_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
/*
|
||||
* The class define the interface for UI to implement.
|
||||
* It triggered by AAMS when AA to request the accessibility information.
|
||||
*/
|
||||
class AccessibilityInteractionOperation {
|
||||
public:
|
||||
/**
|
||||
* @brief Make the node information by accessibility ID and set the result by callback.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also.
|
||||
* PREFETCH_SIBLINGS: Need to make the sister/brothers node info also.
|
||||
* PREFETCH_CHILDREN: Need to make the child node info also.
|
||||
* otherwise: Make the node information by elementId only.
|
||||
* @return -
|
||||
*/
|
||||
virtual void SearchElementInfoByAccessibilityId(const long elementId,
|
||||
const int requestId, AccessibilityInteractionOperationCallback &callback, const int mode) = 0;
|
||||
|
||||
/**
|
||||
* @brief Make the child node information by accessibility ID and filtered by text and set the result by callback.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param text Filter for the child components to matched with the text
|
||||
* @return
|
||||
*/
|
||||
virtual void SearchElementInfosByText(const long elementId, const std::string &text,
|
||||
const int requestId, AccessibilityInteractionOperationCallback &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief Make the node information of the component focused by the focus type specified.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus
|
||||
* FOCUS_TYPE_INPUT: text input focus
|
||||
* @return
|
||||
*/
|
||||
virtual void FindFocusedElementInfo(const long elementId, const int focusType, const int requestId,
|
||||
AccessibilityInteractionOperationCallback &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief Make the node info by current focus move direction.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
|
||||
* @return -
|
||||
*/
|
||||
virtual void FocusMoveSearch(const long elementId, const int direction, const int requestId,
|
||||
AccessibilityInteractionOperationCallback &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief To return the result of perform action.
|
||||
* @param elementId: The unique id of the component ID.
|
||||
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
|
||||
* @param callback To transfer the node info to ASAC and it defined by ASAC.
|
||||
* @param action Refer to [AccessibilityElementInfo.ActionType]
|
||||
* @param actionArguments The parameter for action type. such as:
|
||||
* action: ACCESSIBILITY_ACTION_NEXT_HTML_ITEM,
|
||||
* actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
|
||||
* action: ACCESSIBILITY_ACTION_PREVIOUS_HTML_ITEM,
|
||||
* actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
|
||||
* action: ACCESSIBILITY_ACTION_NEXT_TEXT,
|
||||
* actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
|
||||
* action: ACCESSIBILITY_ACTION_PREVIOUS_TEXT,
|
||||
* actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
|
||||
* action: ACCESSIBILITY_ACTION_SET_SELECTION,
|
||||
* actionArguments({ACTION_ARGU_SELECT_TEXT_START,"1"(start location)},
|
||||
* {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
|
||||
* action: ACCESSIBILITY_ACTION_SET_TEXT,
|
||||
* actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
|
||||
* @return
|
||||
*/
|
||||
virtual void PerformAction(const long elementId, const int action, const std::map<std::string, std::string> actionArguments,
|
||||
const int requestId, AccessibilityInteractionOperationCallback &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief The function is called while accessibility System check the id of window is not equal
|
||||
* to the id of active window when sendAccessibility.
|
||||
* @param -
|
||||
* @return
|
||||
*/
|
||||
virtual void ClearFocus() = 0;
|
||||
|
||||
/**
|
||||
* @brief The low layser is notified by the function called while accessibility system execute
|
||||
* the function of performAction from AS to check the all low windows cared the outside event.
|
||||
* Example: PopupWindow receive the OUTSIDE_EVENT to close itself.
|
||||
* @param -
|
||||
* @return
|
||||
*/
|
||||
virtual void OutsideTouch() = 0;
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
#endif
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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_INTERACTION_OPERATION_CALLBACK_H
|
||||
#define ACCESSIBILITY_INTERACTION_OPERATION_CALLBACK_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "accessibility_element_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
/*
|
||||
* The class supply the callback to feedback the result from UI to AA.
|
||||
|
||||
*/
|
||||
class AccessibilityInteractionOperationCallback {
|
||||
public:
|
||||
/**
|
||||
* @brief Set the element information by accessibility id to AA.
|
||||
* @param infos The element info searched by accessibility id.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetSearchElementInfoByAccessibilityIdResult(const std::list<AccessibilityElementInfo> &infos,
|
||||
const int requestId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the element informations matched with text to AA.
|
||||
* @param infos The element informations searched matched with text.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetSearchElementInfoByTextResult(const std::list<AccessibilityElementInfo> &infos,
|
||||
const int requestId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the element informations matched with focus type to AA.
|
||||
* @param info The element informations searched matched with focus type.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetFindFocusedElementInfoResult(const AccessibilityElementInfo &info, const int requestId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the element informations by focus direction to AA.
|
||||
* @param info The element informations searched by focus direction.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetFocusMoveSearchResult(const AccessibilityElementInfo &info, const int requestId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the result of action executed to AA.
|
||||
* @param succeeded True: The action is executed successfully; otherwise is false.
|
||||
* @param requestId The request id from AA, it is used to match with request and response.
|
||||
* @return
|
||||
*/
|
||||
virtual void SetPerformActionResult(const bool succeeded, const int requestId) = 0;
|
||||
};
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namesapce OHOS
|
||||
#endif
|
121
interfaces/innerkits/asacfwk/include/accessibility_state_event.h
Normal file
121
interfaces/innerkits/asacfwk/include/accessibility_state_event.h
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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_STATE_EVENT_H
|
||||
#define ACCESSIBILITY_STATE_EVENT_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
enum AccessibilityStateEventType : int {
|
||||
EVENT_ACCESSIBILITY_STATE_CHANGED = 0x00000001,
|
||||
EVENT_TOUCH_GUIDE_STATE_CHANGED = 0x00000002,
|
||||
};
|
||||
/*
|
||||
* This class is used for ASAC as the listener of AAMS.
|
||||
|
||||
*/
|
||||
class AccessibilityStateEvent {
|
||||
public:
|
||||
AccessibilityStateEvent();
|
||||
|
||||
/**
|
||||
* @brief Get the type of the state event.
|
||||
* @return EVENT_ACCESSIBILITY_STATE_CHANGED/EVENT_TOUCH_GUIDE_STATE_CHANGED
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
AccessibilityStateEventType GetEventType() const;
|
||||
|
||||
/**
|
||||
* @brief Get the state of the ability.
|
||||
* @return 0:enabled; otherwise is disabled;
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetEventResult() const;
|
||||
|
||||
/**
|
||||
* @brief Get the description of the ability.
|
||||
* @return The description of the ability
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
std::string GetEventMsg() const;
|
||||
|
||||
/**
|
||||
* @brief Set the type of the state event.
|
||||
* @param eventType EVENT_ACCESSIBILITY_STATE_CHANGED/EVENT_TOUCH_GUIDE_STATE_CHANGED
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetEventType(const AccessibilityStateEventType eventType);
|
||||
|
||||
/**
|
||||
* @brief Get the state of the ability.
|
||||
* @param enabled 0:enabled; otherwise is disabled;
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetEventResult(const int enabled);
|
||||
|
||||
/**
|
||||
* @brief Set the description of the ability.
|
||||
* @param description The description of the ability
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetEventMsg(std::string &description);
|
||||
private:
|
||||
AccessibilityStateEventType eventType_ = EVENT_ACCESSIBILITY_STATE_CHANGED;
|
||||
int enabled_ = 0;
|
||||
std::string describeEvent_ = "";
|
||||
};
|
||||
|
||||
class AccessibilityStateObserver {
|
||||
public:
|
||||
/**
|
||||
* @brief Receives notifications on accessibility status changes.
|
||||
* @param stateEvent Indicates the status change event.
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
virtual void OnStateChanged(const AccessibilityStateEvent& stateEvent) = 0;
|
||||
|
||||
/**
|
||||
* @brief Construct
|
||||
* @param
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
AccessibilityStateObserver() {}
|
||||
|
||||
/**
|
||||
* @brief Destruct
|
||||
* @param
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
virtual ~AccessibilityStateObserver() = default;
|
||||
};
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
||||
#endif
|
@ -0,0 +1,322 @@
|
||||
/*
|
||||
* 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_SYSTEM_ABILITY_CLIENT_H
|
||||
#define ACCESSIBILITY_SYSTEM_ABILITY_CLIENT_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "accessibility_event_info.h"
|
||||
#include "accessibility_state_event.h"
|
||||
#include "accessibility_interaction_operation.h"
|
||||
#include "accessibility_ability_info.h"
|
||||
#include "context.h"
|
||||
#include "refbase.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
#define ACCESSIBILITY_DECLARE_IMPL() \
|
||||
struct Impl; \
|
||||
std::unique_ptr<Impl> pimpl
|
||||
|
||||
enum AccessibilityControlType : int {
|
||||
CONTENT_CONTROLS = 0x00000001,
|
||||
CONTENT_ICONS = 0x00000002,
|
||||
CONTENT_TEXT = 0x00000004,
|
||||
};
|
||||
|
||||
enum AbilityStateType: int {
|
||||
ABILITY_STATE_INVALID = 0,
|
||||
ABILITY_STATE_ENABLE,
|
||||
ABILITY_STATE_DISABLE,
|
||||
ABILITY_STATE_INSTALLED,
|
||||
};
|
||||
|
||||
/*
|
||||
* The class register the accessibility service observer to AAMS,and
|
||||
* dispatch the accessibility service status changed. such as Service Enable,
|
||||
* Accessibility Enable. It calls AAMS API to send the event to AA.
|
||||
* It supply sington instance for each process.
|
||||
*/
|
||||
class CaptionProperties {
|
||||
public:
|
||||
CaptionProperties() {}
|
||||
bool CheckProperty(const std::string &property);
|
||||
int GetBackgroundColor() const; //remained
|
||||
int GetForegroundColor() const; //remained
|
||||
int GetEdgeType() const; //remained
|
||||
int GetEdgeColor() const; //remained
|
||||
int GetWindowColor() const; //remained
|
||||
|
||||
private:
|
||||
bool HasBackgroundColor();
|
||||
bool HasForegroundColor();
|
||||
bool HasEdgeType();
|
||||
bool HasEdgeColor();
|
||||
bool HasWindowColor();
|
||||
|
||||
bool hasBackgroundColor_ = false;
|
||||
bool hasEdgeType_ = false;
|
||||
bool hasEdgeColor_ = false;
|
||||
bool hasWindowColor_ = false;
|
||||
bool hasForegroundColor_ = false;
|
||||
int backgroundColor_ = 0; //remained
|
||||
int edgeType_ = 0; //remained
|
||||
int edgeColor_ = 0; //remained
|
||||
int windowColor_ = 0; //remained
|
||||
int foregroundColor_ =0; //remained
|
||||
};
|
||||
|
||||
class AccessibilitySystemAbilityClient {
|
||||
public:
|
||||
static const int NUM_INT32 = 32;
|
||||
static const uint32_t STATE_ACCESSIBILITY_ENABLED = 0x00000001;
|
||||
static const uint32_t STATE_EXPLORATION_ENABLED = 0x00000002;
|
||||
static const uint32_t STATE_ACCESSIBILITY_DISABLED = 0x00000004;
|
||||
static const uint32_t STATE_EXPLORATION_DISABLED = 0x00000008;
|
||||
|
||||
/**
|
||||
* @brief Construct.
|
||||
* @param context Indicates the context of the associated ability.
|
||||
* @param accountId User Id
|
||||
*/
|
||||
AccessibilitySystemAbilityClient(const AppExecFwk::Context &context, int accountId);
|
||||
|
||||
/**
|
||||
* @brief Register the interaction operation, so the AA can get node info from ACE.
|
||||
* @param windowId Window ID
|
||||
* @param operation The callback object.
|
||||
* @param accountId User ID
|
||||
* @return 0: Succeed ; otherwise is failed.
|
||||
*/
|
||||
int RegisterInteractionOperation(const int windowId,
|
||||
const std::shared_ptr<AccessibilityInteractionOperation> &operation, int accountId);
|
||||
|
||||
/**
|
||||
* @brief Deregister the interaction operation.
|
||||
* @param windowId Window ID
|
||||
* @return
|
||||
*/
|
||||
void DeregisterInteractionOperation(const int windowId);
|
||||
|
||||
/**
|
||||
* @brief Checks whether accessibility ability is enabled.
|
||||
* @param -
|
||||
* @return true: enabled; false: disabled
|
||||
*/
|
||||
bool IsEnabled();
|
||||
|
||||
/**
|
||||
* @brief Checks whether touch exploration ability is enabled.
|
||||
* @param -
|
||||
* @return true: enabled; false: disabled
|
||||
*/
|
||||
bool IsTouchExplorationEnabled();
|
||||
|
||||
/**
|
||||
* @brief Queries the list of accessibility abilities.
|
||||
* @param accessibilityAbilityTypes Indicates the accessibility type specified by
|
||||
* AccessibilityAbilityInfo#ACCESSIBILITY_ABILITY_TYPE_SPOKEN.
|
||||
* @param stateType Indicates the accessibility ability status.
|
||||
* 1 indicates that the ability is enabled;
|
||||
* 2 indicates that the ability is disabled;
|
||||
* 4 indicates that the ability has been installed.
|
||||
* @return
|
||||
*/
|
||||
std::vector<AccessibilityAbilityInfo> GetAbilityList(const int accessibilityAbilityTypes,
|
||||
const AbilityStateType stateType);
|
||||
|
||||
/**
|
||||
* @brief Obtains the AccessibilitySystemAbilityClient instance.
|
||||
* @param abilityContext Indicates the context of the associated ability.
|
||||
* @return AccessibilitySystemAbilityClient instance
|
||||
*/
|
||||
static std::shared_ptr<AccessibilitySystemAbilityClient> GetInstance(const AppExecFwk::Context &abilityContext);
|
||||
|
||||
/**
|
||||
* @brief Obtains the AccessibilitySystemAbilityClient instance.
|
||||
* @param -
|
||||
* @return AccessibilitySystemAbilityClient instance
|
||||
*/
|
||||
static std::shared_ptr<AccessibilitySystemAbilityClient> GetInstance();
|
||||
|
||||
/**
|
||||
* @brief Obtains the suggested interval for switching the UI.
|
||||
* Remained.
|
||||
* @param timeout Indicates the interval at which the UI is changed.
|
||||
* @param contentType Indicates the type of the UI control.
|
||||
* @return Returns the interval.
|
||||
*/
|
||||
int GetSuggestedInterval(const int timeout, const int contentType);
|
||||
|
||||
/**
|
||||
* @brief Obtains the properties of the accessibility caption function.
|
||||
* Remained for caption.
|
||||
* @param -
|
||||
* @return Returns the properties of the accessibility caption function.
|
||||
*/
|
||||
CaptionProperties GetAccessibilityCaptionProperties() const;
|
||||
|
||||
/**
|
||||
* @brief Checks whether the accessibility caption function is enabled.
|
||||
* Remained for caption.
|
||||
* @param -
|
||||
* @return True if the caption function is enabled; returns False otherwise.
|
||||
*/
|
||||
bool IsAccessibilityCaptionEnabled() const;
|
||||
|
||||
/**
|
||||
* @brief Sends an accessibility event.
|
||||
* @param eventType Identifies the accessibility event specified by AccessibilityEventInfo.
|
||||
* @param componentId Indicates the ID of the component to be associated with the event.
|
||||
* @return true: send ok; otherwise is refused.
|
||||
*/
|
||||
bool SendEvent(const EventType eventType, const int componentId);
|
||||
|
||||
/**
|
||||
* @brief Sends information about an accessibility event.
|
||||
* @param event Indicates the accessibility event information specified by AccessibilityEventInfo.
|
||||
* @return true: send ok; otherwise is refused.
|
||||
*/
|
||||
bool SendEvent(const AccessibilityEventInfo &event);
|
||||
|
||||
/**
|
||||
* @brief Subscribes to the specified type of accessibility status change events.
|
||||
* @param observer Indicates the observer for listening to status events, which is specified
|
||||
* by AccessibilityStateObserver.
|
||||
* @param eventType Indicates the status type, which is specified by AccessibilityStateEvent
|
||||
* #EVENT_ACCESSIBILITY_STATE_CHANGED and AccessibilityStateEvent#EVENT_TOUCH_BROWSE_STATE_CHANGED
|
||||
* @return true: send ok; otherwise is refused.
|
||||
*/
|
||||
bool SubscribeStateObserver(const std::shared_ptr<AccessibilityStateObserver> &observer, const int eventType);
|
||||
|
||||
/**
|
||||
* @brief Unsubscribe the specified type of accessibility status change events.
|
||||
* @param observer Indicates the registered accessibility status event observer.
|
||||
* @param eventType Indicates the status type, which is specified by AccessibilityStateEvent
|
||||
* #EVENT_ACCESSIBILITY_STATE_CHANGED and AccessibilityStateEvent#EVENT_TOUCH_BROWSE_STATE_CHANGED
|
||||
* @return true: send ok; otherwise is refused.
|
||||
*/
|
||||
bool UnsubscribeStateObserver(const std::shared_ptr<AccessibilityStateObserver> &observer, const int eventType);
|
||||
|
||||
/**
|
||||
* @brief Unsubscribe the accessibility status change events from the observer.
|
||||
* @param observer Indicates the registered accessibility status event observer.
|
||||
* @return true is succeed otherwise is failed.
|
||||
*/
|
||||
bool UnsubscribeStateObserver(const std::shared_ptr<AccessibilityStateObserver> &observer);
|
||||
|
||||
/**
|
||||
* @brief Inner function for aams status update;
|
||||
* Set whether accessibility ability is enabled.
|
||||
* @param enabled true is enabled otherwise is disabled.
|
||||
* @return -
|
||||
*/
|
||||
void SetEnabled(const bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Inner function for aams status update;
|
||||
* Set whether touch exploration is enabled.
|
||||
* @param enabled true is enabled otherwise is disabled.
|
||||
* @return -
|
||||
*/
|
||||
void SetTouchExplorationEnabled(const bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Check otherwise Accessibility Ability(AA) is conflicted with other AA.
|
||||
* Remained for setting subsystem.
|
||||
* @param abilityName The AA specified (include deviceId/bundleName/abilityName)
|
||||
* @return LAUNCH_CONFLICT_NONE: no conflict;
|
||||
* LAUNCH_CONFLICT_TOUCH_BROWSER: conflict with touch browser;
|
||||
* LAUNCH_CONFLICT_DISPLAY_RESIZE: conflict with display resize;
|
||||
* LAUNCH_CONFLICT_KEY_EVENT: conflict with key event;
|
||||
* LAUNCH_CONFLICT_FINGERPRINT_GESTURE: conflict with fingerprint gesture.
|
||||
*/
|
||||
int CheckConflictWithEnabledAbility(const AppExecFwk::ElementName &abilityName) { return 0;}
|
||||
|
||||
/**
|
||||
* @brief Get the AA specified capability.
|
||||
* Remained for setting subsystem.
|
||||
* @param abilityName The AA specified (include deviceId/bundleName/abilityName)
|
||||
* @return refer to AccessibilityAbilityInfo.Capability
|
||||
*/
|
||||
int GetAccessibleAbilityCapability(const AppExecFwk::ElementName &abilityName) { return 0;}
|
||||
|
||||
/**
|
||||
* @brief Requests feedback interruption from all accessibility services.
|
||||
* Remained.
|
||||
* @param -
|
||||
* @return
|
||||
*/
|
||||
void Interrupt();
|
||||
|
||||
/**
|
||||
* @brief Inner function.
|
||||
* Get the callback object registed by ACE.
|
||||
* @param windowId The window id related the operation object registed.
|
||||
* @return The callback object of ACE.
|
||||
*/
|
||||
std::shared_ptr<AccessibilityInteractionOperation> GetInteractionObject(int windowId);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Clean the AAMS object data.
|
||||
* @param remote The object access to AAMS.
|
||||
* @return
|
||||
*/
|
||||
void ResetService(const wptr<IRemoteObject>& remote);
|
||||
|
||||
/**
|
||||
* @brief Notify the state of accessibility is changed.
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void NotifyAccessibilityStateChanged();
|
||||
|
||||
/**
|
||||
* @brief Notify the state of touch exploration is changed.
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void NotifyTouchExplorationStateChanged();
|
||||
|
||||
/**
|
||||
* @brief Check the event type is valid or not.
|
||||
* @param eventType The data of event type.
|
||||
* @return True: The data of event type is valid; otherwise is not.
|
||||
*/
|
||||
bool CheckEventType(EventType eventType);
|
||||
std::vector<std::shared_ptr<AccessibilityStateObserver>> observersAceessibilityState_{};
|
||||
std::vector<std::shared_ptr<AccessibilityStateObserver>> observersTouchState_{};
|
||||
CaptionProperties captionProperties_ {};
|
||||
int accountId_ = 0;
|
||||
bool isEnabled_ = 0;
|
||||
bool isTouchExplorationEnabled_ = 0;
|
||||
std::recursive_mutex asacProxyLock_;
|
||||
static std::shared_ptr<AccessibilitySystemAbilityClient> instance_ ;
|
||||
std::shared_ptr<AccessibilityInteractionOperation> interactionOperator_;
|
||||
std::map<int, std::shared_ptr<AccessibilityInteractionOperation>> interactionOperators_{};
|
||||
int connectionWindowId_ = 0;
|
||||
ACCESSIBILITY_DECLARE_IMPL();
|
||||
};
|
||||
|
||||
} //namespace Accessibility
|
||||
} //namespace OHOS
|
||||
#endif
|
357
interfaces/innerkits/asacfwk/include/accessibility_window_info.h
Normal file
357
interfaces/innerkits/asacfwk/include/accessibility_window_info.h
Normal file
@ -0,0 +1,357 @@
|
||||
/*
|
||||
* 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_WINDOW_H
|
||||
#define ACCESSIBILITY_WINDOW_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include "accessibility_element_info.h"
|
||||
#include "accessibility_event_info.h"
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
enum WindowType : int {
|
||||
TYPE_WINDOW_INVALID = 0,
|
||||
TYPE_ACCESSIBILITY_OVERLAY = 0x00000001,
|
||||
TYPE_APPLICATION = 0x00000002,
|
||||
TYPE_INPUT_METHOD = 0x00000004,
|
||||
TYPE_SPLIT_SCREEN_DIVIDER = 0x00000008,
|
||||
TYPE_SYSTEM = 0x00000010,
|
||||
};
|
||||
static const int INVALID_WINDOW_ID = -1;
|
||||
static const int ANY_WINDOW_ID = -2;
|
||||
static const int ACTIVE_WINDOW_ID = 0x7FFFFFFF;
|
||||
|
||||
class AccessibilityWindowInfo : public Parcelable {
|
||||
public:
|
||||
/**
|
||||
* @brief Construct
|
||||
* @param
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
AccessibilityWindowInfo();
|
||||
|
||||
/**
|
||||
* @brief Get the title of window
|
||||
* @param -
|
||||
* @return The title of window
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
std::string GetWindowTitle() const;
|
||||
|
||||
/**
|
||||
* @brief Set the title of window
|
||||
* @param title The title of window
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetWindowTitle(std::string &title);
|
||||
|
||||
/**
|
||||
* @brief Get the window type.
|
||||
* @param -
|
||||
* @return The window type. Refer to [WindowType].
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
WindowType GetWindowType() const;
|
||||
|
||||
/**
|
||||
* @brief Set the window type.
|
||||
* @param type The window type. Refer to [WindowType].
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetWindowType(const WindowType type);
|
||||
|
||||
/**
|
||||
* @brief Get The window layer
|
||||
* @param -
|
||||
* @return The layer of window
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetWindowLayer() const;
|
||||
|
||||
/**
|
||||
* @brief Set The window layer
|
||||
* @param layer The window layer
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetWindowLayer(const int layer);
|
||||
|
||||
/**
|
||||
* @brief Get the root node information of the window.
|
||||
* @param -
|
||||
* @return The root node information.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
bool GetRootAccessibilityInfo(AccessibilityElementInfo &elementInfo);
|
||||
|
||||
/**
|
||||
* @brief Set an anchor accessibility node that anchors this window to another window.
|
||||
* @param anchorId The accessibility id of component.
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetAnchorId(const int anchorId);
|
||||
|
||||
/**
|
||||
* @brief Obtains an anchor accessibility node that anchors this window to another window.
|
||||
* @param -
|
||||
* @return The node information of the anchored component.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
bool GetAnchor(AccessibilityElementInfo &elementInfo);
|
||||
|
||||
/**
|
||||
* @brief Get the parent window
|
||||
* @param -
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
AccessibilityWindowInfo GetParent();
|
||||
|
||||
/**
|
||||
* @brief Set the parent window
|
||||
* @param parentId The window id of the parent.
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetParentId(const int parentId);
|
||||
|
||||
/**
|
||||
* @brief Get the parent window
|
||||
* @param -
|
||||
* @return The window id of the parent.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetParentId();
|
||||
|
||||
/**
|
||||
* @brief Get the anchor window
|
||||
* @param -
|
||||
* @return The anchor id of the window.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetAnchorId();
|
||||
|
||||
/**
|
||||
* @brief Get the parent window
|
||||
* @param -
|
||||
* @return The window id of the parent.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
std::vector<int> GetChildIds();
|
||||
|
||||
/**
|
||||
* @brief Get the widnow id of current window.
|
||||
* @param -
|
||||
* @return The widnow id of current window.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetWindowId() const;
|
||||
|
||||
/**
|
||||
* @brief Set the widnow id of current window.
|
||||
* @param id The widnow id of current window.
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetWindowId(const int id);
|
||||
|
||||
/**
|
||||
* @brief AAMS called to set the id of the IAccessibleAbilityChannel.
|
||||
* @param channelId The id of the IAccessibleAbilityChannel.
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetChannelId(const int channelId);
|
||||
|
||||
/**
|
||||
* @brief Get the id of the IAccessibleAbilityChannel.
|
||||
* @param
|
||||
* @return The id of the IAccessibleAbilityChannel.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetChannelId() const;
|
||||
|
||||
/**
|
||||
* @brief Get the screen pixel coordinates
|
||||
* @param -
|
||||
* @return The screen pixel coordinates
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
Rect GetRectInScreen() const;
|
||||
|
||||
/**
|
||||
* @brief Set the screen pixel coordinates
|
||||
* @param bounds The screen pixel coordinates
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetRectInScreen(const Rect &bounds);
|
||||
|
||||
/**
|
||||
* @brief Check whether the window is active or not.
|
||||
* @param -
|
||||
* @return true: the window is active, otherwise is not.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
bool IsActive() const;
|
||||
|
||||
/**
|
||||
* @brief Set whether the window is active or not.
|
||||
* @param active true: the window is active, otherwise is not.
|
||||
* @return
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetActive(bool active);
|
||||
|
||||
/**
|
||||
* @brief Checks whether this window has gained focus.
|
||||
* @param
|
||||
* @return true: the window has gained focus, otherwise is not.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
bool IsFocused() const;
|
||||
|
||||
/**
|
||||
* @brief Set whether this window has gained focus.
|
||||
* @param focused true: the window has gained focus, otherwise is not.
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetFocused(bool focused);
|
||||
|
||||
/**
|
||||
* @brief Checks whether this window has gained accessibility focus.
|
||||
* @param -
|
||||
* @return true: this window has gained accessibility focus, otherwise is not.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
bool IsAccessibilityFocused() const;
|
||||
|
||||
/**
|
||||
* @brief Set whether this window has gained accessibility focus.
|
||||
* @param accessibilityfocused true: this window has gained accessibility focus, otherwise is not.
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void SetAccessibilityFocused(const bool accessibilityfocused);
|
||||
|
||||
/**
|
||||
* @brief Obtains the quantity of child windows.
|
||||
* @param -
|
||||
* @return The quantity of child windows.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
int GetChildNum() const;
|
||||
|
||||
/**
|
||||
* @brief Obtains information about the accessibility child window at a specified index.
|
||||
* @param index The index of the child
|
||||
* @return The child window specified by index.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
AccessibilityWindowInfo GetChild(const int index);
|
||||
|
||||
/**
|
||||
* @brief Add the child window
|
||||
* @param childId the window id of the child
|
||||
* @return -
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
void AddChild(const int childId);
|
||||
|
||||
/*Parcel*/
|
||||
/**
|
||||
* @brief Used for IPC communication.
|
||||
* @param parcel Serializable data.
|
||||
* @return true: Read parcel data successfully; otherwise is not.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
|
||||
/**
|
||||
* @brief Used for IPC communication.
|
||||
* @param parcel
|
||||
* @return true: Write parcel data successfully; otherwise is not.
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
||||
/**
|
||||
* @brief Used for IPC communication.
|
||||
* @param parcel
|
||||
* @return The data of AccessibilityWindowInfo
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
static AccessibilityWindowInfo *Unmarshalling(Parcel &parcel);
|
||||
|
||||
private:
|
||||
WindowType windowType_ = TYPE_WINDOW_INVALID;
|
||||
int windowLayer_ = INVALID_WINDOW_ID;
|
||||
int windowId_ = INVALID_WINDOW_ID;
|
||||
int parentId_ = INVALID_WINDOW_ID;
|
||||
std::string windowTitle_ = "";
|
||||
std::vector<int> childIds_{};
|
||||
int anchorId_ = -1;
|
||||
int childNum_ = 0;
|
||||
int channelId_ = INVALID_WINDOW_ID;
|
||||
bool active_ = false;
|
||||
bool focused_ = false;
|
||||
bool accessibilityFocused_ = false;
|
||||
Rect boundsInScreen_ {};
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif
|
50
interfaces/kits/js/@component/displayResizeInfo.d.ts
vendored
Normal file
50
interfaces/kits/js/@component/displayResizeInfo.d.ts
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { Rect } from './rect'
|
||||
//@note hide
|
||||
export interface DisplayResizeInfo {
|
||||
/**
|
||||
* The rect of the display resized.
|
||||
* @default -
|
||||
* @since 3
|
||||
* @sysCap AccessibilityAbility
|
||||
*/
|
||||
rect: Rect;
|
||||
|
||||
/**
|
||||
* The scale of the display resized.
|
||||
* @default -
|
||||
* @since 3
|
||||
* @sysCap AccessibilityAbility
|
||||
*/
|
||||
scale: number;
|
||||
|
||||
/**
|
||||
* the x coordinate of the resize center.
|
||||
* @default -
|
||||
* @since 3
|
||||
* @sysCap AccessibilityAbility
|
||||
*/
|
||||
centerX: number;
|
||||
|
||||
/**
|
||||
* the y coordinate of the resize center.
|
||||
* @default -
|
||||
* @since 3
|
||||
* @sysCap AccessibilityAbility
|
||||
*/
|
||||
centerY: number;
|
||||
}
|
70
interfaces/kits/js/@component/gesturePath.d.ts
vendored
Normal file
70
interfaces/kits/js/@component/gesturePath.d.ts
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
//@note hide
|
||||
export class GesturePath {
|
||||
/**
|
||||
* The path list of the gesture.
|
||||
* @default -
|
||||
* @since 3
|
||||
* @sysCap AccessibilityAbility
|
||||
* @note The max number of the path is 10;
|
||||
*/
|
||||
pos: Array<GesturePos>;
|
||||
|
||||
/**
|
||||
* The start position of the gesture.
|
||||
* @default -
|
||||
* @since 3
|
||||
* @sysCap AccessibilityAbility
|
||||
*/
|
||||
startPos: GesturePos;
|
||||
|
||||
/**
|
||||
* The end position of the gesture.
|
||||
* @default -
|
||||
* @since 3
|
||||
* @sysCap AccessibilityAbility
|
||||
*/
|
||||
endPos: GesturePos;
|
||||
|
||||
/**
|
||||
* The duration time of the gesture.
|
||||
* @default -
|
||||
* @since 3
|
||||
* @sysCap AccessibilityAbility
|
||||
* @note The max of the durationtime is 60 * 1000 ms;
|
||||
*/
|
||||
durationTime: number;
|
||||
}
|
||||
//@note hide
|
||||
export class GesturePos {
|
||||
constructor(x: number, y: number);
|
||||
/**
|
||||
* The x coordinate of position.
|
||||
* @default -
|
||||
* @since 3
|
||||
* @sysCap AccessibilityAbility
|
||||
*/
|
||||
posX: number;
|
||||
|
||||
/**
|
||||
* The y coordinate of position.
|
||||
* @default -
|
||||
* @since 3
|
||||
* @sysCap AccessibilityAbility
|
||||
*/
|
||||
posY: number;
|
||||
}
|
91
interfaces/kits/js/@component/gridInfo.d.ts
vendored
Normal file
91
interfaces/kits/js/@component/gridInfo.d.ts
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export interface GridInfo {
|
||||
/**
|
||||
* Row count of the collection.
|
||||
* @default 0
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
rowCount: number;
|
||||
|
||||
/**
|
||||
* Column count of the collection.
|
||||
* @default 0
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
columnCount: number;
|
||||
|
||||
/**
|
||||
* Selection mode of collection.
|
||||
* @default 0
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
selectionMode: number;
|
||||
}
|
||||
|
||||
export interface GridItemInfo {
|
||||
/**
|
||||
* Whether is head.
|
||||
* @default false
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
heading: boolean;
|
||||
|
||||
/**
|
||||
* The index of the column.
|
||||
* @default 0
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
columnIndex: number;
|
||||
|
||||
/**
|
||||
* The index of the row.
|
||||
* @default 0
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
rowIndex: number;
|
||||
|
||||
/**
|
||||
* column span.
|
||||
* @default 0
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
columnSpan: number;
|
||||
|
||||
/**
|
||||
* row span.
|
||||
* @default 0
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
rowSpan: number;
|
||||
|
||||
/**
|
||||
* Whether is selected.
|
||||
* @default false
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
selected: boolean;
|
||||
|
||||
}
|
41
interfaces/kits/js/@component/progress.d.ts
vendored
Normal file
41
interfaces/kits/js/@component/progress.d.ts
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
//define for progressbar
|
||||
export interface RangeInfo {
|
||||
/**
|
||||
* The min of the ProgressBar.
|
||||
* @default 0
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
min: number;
|
||||
|
||||
/**
|
||||
* The max of the ProgressBar.
|
||||
* @default 100
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
max: number;
|
||||
|
||||
/**
|
||||
* The current value of the ProgressBar.
|
||||
* @default 0
|
||||
* @since 3
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
current: number;
|
||||
}
|
22
interfaces/kits/js/@component/rect.d.ts
vendored
Normal file
22
interfaces/kits/js/@component/rect.d.ts
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Rect
|
||||
export interface Rect{
|
||||
leftTopX:number;
|
||||
leftTopY: number;
|
||||
rightBottomX: number;
|
||||
rightBottomY: number;
|
||||
}
|
1180
interfaces/kits/js/@ohos.accessibility.d.ts
vendored
Normal file
1180
interfaces/kits/js/@ohos.accessibility.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1435
interfaces/kits/js/@ohos.accessibility.full.d.ts
vendored
Normal file
1435
interfaces/kits/js/@ohos.accessibility.full.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
42
interfaces/kits/js/@ohos.tts.d.ts
vendored
Normal file
42
interfaces/kits/js/@ohos.tts.d.ts
vendored
Normal 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.
|
||||
*/
|
||||
|
||||
declare namespace tts {
|
||||
|
||||
function getInstance(): TtsClient;
|
||||
|
||||
interface TtsClient {
|
||||
|
||||
create(context, ttsListener): void;
|
||||
|
||||
release(): void; //不用实现,有接口就可以
|
||||
|
||||
init(ttsParams): boolean; //不用实现,有接口就可以,返回true
|
||||
|
||||
setParams(ttsParams):boolean; //不用实现,有接口就可以,返回true
|
||||
|
||||
setAudioType(audioType): boolean; //不用实现,有接口就可以,返回true
|
||||
|
||||
speakText(text, utteranceId): void;
|
||||
|
||||
isSpeaking(): boolean;
|
||||
|
||||
stopSpeak(): void;
|
||||
|
||||
destroy(): void;
|
||||
}
|
||||
}
|
||||
|
||||
export default media;
|
123
interfaces/kits/napi/BUILD.gn
Normal file
123
interfaces/kits/napi/BUILD.gn
Normal file
@ -0,0 +1,123 @@
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
|
||||
ohos_shared_library("accessibility") {
|
||||
#visiblity = [ ":*" ]
|
||||
|
||||
include_dirs = [
|
||||
"//foundation/ace/napi/interfaces/kits",
|
||||
"//third_party/node/src",
|
||||
"//utils/system/safwk/native/include",
|
||||
"//base/accessibility/common/log/include",
|
||||
"//base/accessibility/frameworks/aafwk/include",
|
||||
"//base/accessibility/interfaces/innerkits/asacfwk/include",
|
||||
"//base/accessibility/frameworks/aafwk/include",
|
||||
"//base/accessibility/frameworks/asacfwk/include",
|
||||
"//base/accessibility/util/include",
|
||||
"./include",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"AAMS_LOG_TAG = \"accessibility_napi\"",
|
||||
"AAMS_LOG_DOMAIN = 0xD005210",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"./src/native_module.cpp",
|
||||
"./src/napi_accessible_ability.cpp",
|
||||
"./src/napi_accessibility_system_ability_client.cpp",
|
||||
"./src/napi_accessibility_utils.cpp",
|
||||
"./src/napi_accessible_ability_observer.cpp",
|
||||
"./src/napi_accessibility_event_info.cpp",
|
||||
"./src/napi_accessibility_window_info.cpp",
|
||||
"./src/napi_accessibility_info.cpp",
|
||||
]
|
||||
|
||||
configs = [
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/base:base_public_config",
|
||||
]
|
||||
|
||||
deps = [
|
||||
#"//foundation/aafwk/standard/interfaces/innerkits/base:base",
|
||||
#"//foundation/aafwk/standard/interfaces/innerkits/want:want",
|
||||
#"//foundation/appexecfwk/standard/common:libappexecfwk_common",
|
||||
#"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base",
|
||||
#"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core:appexecfwk_core",
|
||||
#"//foundation/appexecfwk/standard/libs/libeventhandler:libeventhandler_target",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
#"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
#"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//foundation/ace/napi:ace_napi",
|
||||
"//base/accessibility/frameworks/aafwk:accessibleability",
|
||||
"//base/accessibility/interfaces/innerkits/asacfwk:accessibilityclient",
|
||||
"//utils/native/base:utils",
|
||||
"//foundation/appexecfwk/standard/kits:appkit_native",
|
||||
"//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"multimodalinput_base:libmmi-client",
|
||||
"appexecfwk_standard:appexecfwk_base",
|
||||
"appexecfwk_standard:appexecfwk_core",
|
||||
"aafwk_standard:want",
|
||||
"aafwk_standard:ability_manager",
|
||||
]
|
||||
|
||||
relative_install_dir = "module"
|
||||
subsystem_name = "accessibility"
|
||||
part_name = "accessibility_standard"
|
||||
}
|
||||
|
||||
ohos_shared_library("tts") {
|
||||
include_dirs = [
|
||||
"//base/accessibility/common/log/include",
|
||||
"//foundation/ace/napi/interfaces/kits",
|
||||
"//third_party/node/src",
|
||||
"./include",
|
||||
"//base/accessibility/dummyData",
|
||||
"//utils/native/base/include",
|
||||
#"//foundation/tts/interfaces/innerkits/native_cpp/framework/include",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"AAMS_LOG_TAG = \"tts_napi\"",
|
||||
"AAMS_LOG_DOMAIN = 0xD005299",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"./src/napi_tts.cpp",
|
||||
"//base/accessibility/dummyData/ttsDummy.cpp",
|
||||
]
|
||||
|
||||
#configs = [
|
||||
# "//foundation/aafwk/standard/interfaces/innerkits/base:base_public_config",
|
||||
#]
|
||||
|
||||
deps = [
|
||||
"//foundation/ace/napi:ace_napi",
|
||||
"//utils/native/base:utils",
|
||||
#"//foundation/tts/interfaces/innerkits/native_cpp/framework:tts_engine",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
|
||||
relative_install_dir = "module"
|
||||
subsystem_name = "accessibility"
|
||||
part_name = "accessibility_standard"
|
||||
}
|
27
interfaces/kits/napi/include/napi_accessibility_def.h
Normal file
27
interfaces/kits/napi/include/napi_accessibility_def.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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_DEF_H
|
||||
#define NAPI_ACCESSIBILITY_DEF_H
|
||||
|
||||
enum AccessibleAbilityObserverFlag: uint32_t {
|
||||
A11Y_OBSERVER_FLAG_ABILITY_CONNECTED = 0x01,
|
||||
A11Y_OBSERVER_FLAG_ACCESSIBILITY_EVENT = 0x02,
|
||||
A11Y_OBSERVER_FLAG_INTERRUPT = 0x04,
|
||||
A11Y_OBSERVER_FLAG_GESTURE = 0x08,
|
||||
A11Y_OBSERVER_FLAG_KEY_PRESS = 0x0A,
|
||||
};
|
||||
|
||||
#endif // NAPI_ACCESSIBILITY_DEF_H
|
51
interfaces/kits/napi/include/napi_accessibility_event_info.h
Normal file
51
interfaces/kits/napi/include/napi_accessibility_event_info.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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_EVENT_INFO_H
|
||||
#define NAPI_ACCESSIBILITY_EVENT_INFO_H
|
||||
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "accessibility_event_info.h"
|
||||
#include "accessibility_element_info.h"
|
||||
|
||||
|
||||
struct NAccessibilityEventInfoData {
|
||||
napi_async_work work_ {};
|
||||
napi_deferred deferred_ {};
|
||||
napi_ref thisRefer_ {};
|
||||
napi_ref callback_ {};
|
||||
napi_env env_ {};
|
||||
bool result_ = false;
|
||||
OHOS::Accessibility::AccessibilityEventInfo eventInfo_ {};
|
||||
OHOS::Accessibility::AccessibilityElementInfo nodeInfo_ {};
|
||||
std::string content_ = "";
|
||||
int childIndex_ = 0;
|
||||
};
|
||||
|
||||
class NAccessibilityEventInfo {
|
||||
public:
|
||||
static void DefineJSAccessibilityEventInfo(napi_env env);
|
||||
static napi_value JSConstructor(napi_env env, napi_callback_info info);
|
||||
|
||||
static napi_value GetSource(napi_env env, napi_callback_info info);
|
||||
|
||||
static napi_value cons_;
|
||||
private:
|
||||
NAccessibilityEventInfo() = default;
|
||||
~NAccessibilityEventInfo() = default;
|
||||
};
|
||||
|
||||
#endif // NAPI_ACCESSIBILITY_EVENT_INFO_H
|
56
interfaces/kits/napi/include/napi_accessibility_info.h
Normal file
56
interfaces/kits/napi/include/napi_accessibility_info.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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_INFO_H
|
||||
#define NAPI_ACCESSIBILITY_INFO_H
|
||||
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "accessibility_element_info.h"
|
||||
|
||||
struct NAccessibilityInfoData {
|
||||
napi_async_work work_ {};
|
||||
napi_deferred deferred_ {};
|
||||
napi_ref thisRefer_ {};
|
||||
napi_ref callback_ {};
|
||||
napi_env env_ {};
|
||||
bool result_ = false;
|
||||
OHOS::Accessibility::AccessibilityElementInfo nativeNodeInfo_ = {};
|
||||
std::vector<OHOS::Accessibility::AccessibilityElementInfo> nodeInfos_ {};
|
||||
OHOS::Accessibility::AccessibilityElementInfo nodeInfo_ {};
|
||||
std::string content_ = "";
|
||||
int childIndex_ = 0;
|
||||
std::map<std::string, std::string> actionArguments_;
|
||||
bool ret_ = false;
|
||||
};
|
||||
|
||||
class NElementInfo {
|
||||
public:
|
||||
static void DefineJSElementInfo(napi_env env);
|
||||
static napi_value JSConstructor(napi_env env, napi_callback_info info);
|
||||
|
||||
static napi_value ExecuteAction(napi_env env, napi_callback_info info);
|
||||
static napi_value GetByContent(napi_env env, napi_callback_info info);
|
||||
static napi_value GetFocus(napi_env env, napi_callback_info info);
|
||||
static napi_value GetNext(napi_env env, napi_callback_info info);
|
||||
static napi_value GetChild(napi_env env, napi_callback_info info);
|
||||
static napi_value GetParent(napi_env env, napi_callback_info info);
|
||||
|
||||
static napi_value cons_;
|
||||
private:
|
||||
NElementInfo() = default;
|
||||
~NElementInfo() = default;
|
||||
};
|
||||
#endif // NAPI_ACCESSIBILITY_INFO_H
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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_SYSTEM_ABILITY_CLIENT_H
|
||||
#define NAPI_ACCESSIBILITY_SYSTEM_ABILITY_CLIENT_H
|
||||
|
||||
#include <vector>
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "accessibility_system_ability_client.h"
|
||||
#include "accessibility_state_event.h"
|
||||
#include "accessibility_ability_info.h"
|
||||
|
||||
class StateListener : public OHOS::Accessibility::AccessibilityStateObserver {
|
||||
public:
|
||||
StateListener();
|
||||
static void NotifyJS(napi_env env, bool enabled, std::string stateType, std::string desc, napi_ref handlerRef);
|
||||
std::string GetEventType() {return eventType_;}
|
||||
napi_value StartWork(napi_env env, size_t functionIndex, napi_value *args);
|
||||
void OnStateChanged(const OHOS::Accessibility::AccessibilityStateEvent& stateEvent) override;
|
||||
OHOS::Accessibility::AccessibilityStateEventType GetStateType();
|
||||
napi_env GetEnv() {return env_;};
|
||||
napi_ref GetHandler() {return handlerRef_;}
|
||||
private:
|
||||
napi_ref handlerRef_ = nullptr;
|
||||
napi_env env_ = nullptr;
|
||||
std::string eventType_ = "";
|
||||
std::string description_ = "";
|
||||
};
|
||||
|
||||
struct NAccessibilitySystemAbilityClient {
|
||||
napi_async_work work_ {};
|
||||
napi_deferred deferred_ {};
|
||||
napi_ref thisRefer_ {};
|
||||
napi_ref callback_ {};
|
||||
napi_env env_ {};
|
||||
bool enabled_ = false;
|
||||
bool touchEnabled_ = false;
|
||||
OHOS::Accessibility::AbilityStateType stateTypes_;
|
||||
int32_t abilityTypes_ = 0;
|
||||
std::vector<OHOS::Accessibility::AccessibilityAbilityInfo> abilityList_ {};
|
||||
OHOS::Accessibility::AccessibilityEventInfo eventInfo_ {};
|
||||
bool result_ = false;
|
||||
std::vector<std::shared_ptr<StateListener>> stateListener_ {};
|
||||
std::string eventType_ = "";
|
||||
};
|
||||
|
||||
napi_value IsOpenAccessibility(napi_env env, napi_callback_info info);
|
||||
napi_value IsOpenTouchExploration(napi_env env, napi_callback_info info);
|
||||
napi_value GetAbilityList(napi_env env, napi_callback_info info);
|
||||
napi_value SubscribeState(napi_env env, napi_callback_info info);
|
||||
napi_value UnsubscribeState(napi_env env, napi_callback_info info);
|
||||
napi_value SendEvent(napi_env env, napi_callback_info info);
|
||||
#endif // NAPI_ACCESSIBILITY_SYSTEM_ABILITY_CLIENT_H
|
81
interfaces/kits/napi/include/napi_accessibility_utils.h
Normal file
81
interfaces/kits/napi/include/napi_accessibility_utils.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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_UTILS_H
|
||||
#define NAPI_ACCESSIBILITY_UTILS_H
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include "accessibility_ability_info.h"
|
||||
#include "accessibility_event_info.h"
|
||||
#include "accessibility_element_info.h"
|
||||
#include "accessible_ability.h"
|
||||
#include "napi_accessibility_system_ability_client.h"
|
||||
#include "accessibility_window_info.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
|
||||
constexpr size_t CALLBACK_SIZE = 1;
|
||||
constexpr size_t ARGS_SIZE_ONE = 1;
|
||||
constexpr size_t ARGS_SIZE_TWO = 2;
|
||||
constexpr size_t ARGS_SIZE_THREE = 3;
|
||||
constexpr size_t ARGS_SIZE_FOUR = 4;
|
||||
constexpr int32_t DEFAULT_INT32 = 0;
|
||||
constexpr int32_t PARAM0 = 0;
|
||||
constexpr int32_t PARAM1 = 1;
|
||||
constexpr int32_t CODE_SUCCESS = 0;
|
||||
constexpr int32_t CODE_FAILED = -1;
|
||||
|
||||
std::string GetStringFromNAPI(napi_env env, napi_value value);
|
||||
bool ParseString(napi_env env, std::string ¶m, napi_value args);
|
||||
bool ParseUint32(napi_env env, uint32_t ¶m, napi_value args);
|
||||
napi_value GetErrorValue(napi_env env, int errCode);
|
||||
|
||||
|
||||
void ConvertRectToJS(napi_env env, napi_value result, OHOS::Accessibility::Rect& rect);
|
||||
void ConvertAccessibilityWindowInfoToJS(napi_env env, napi_value result,
|
||||
OHOS::Accessibility::AccessibilityWindowInfo& accessibilityWindowInfo);
|
||||
void ConvertAccessibilityWindowInfosToJS(napi_env env, napi_value result,
|
||||
std::vector<OHOS::Accessibility::AccessibilityWindowInfo>& accessibilityWindowInfos);
|
||||
void ConvertAccessibilityEventInfoToJS(napi_env env, napi_value objEventInfo,
|
||||
const OHOS::Accessibility::AccessibilityEventInfo &eventInfo);
|
||||
void ConvertAccessibleAbilityInfoToJS(napi_env env, napi_value result,
|
||||
OHOS::Accessibility::AccessibilityAbilityInfo& info);
|
||||
void ConvertAccessibleAbilityInfosToJS(napi_env env, napi_value result,
|
||||
std::vector<OHOS::Accessibility::AccessibilityAbilityInfo>& accessibleAbilityInfos);
|
||||
|
||||
void ConvertAbilityInfoToJS(napi_env env, napi_value result, OHOS::AppExecFwk::AbilityInfo& info);
|
||||
|
||||
void ConvertAbilityApplicationInfoToJS(napi_env env, napi_value result, OHOS::AppExecFwk::ApplicationInfo& info);
|
||||
|
||||
void ConvertElementInfoToJS(napi_env env, napi_value result,
|
||||
OHOS::Accessibility::AccessibilityElementInfo& elementInfo);
|
||||
void ConvertOperationToJS(napi_env env, napi_value result, OHOS::Accessibility::AccessibleAction& operation);
|
||||
void ConvertRangeInfoToJS(napi_env env, napi_value nRangeInfo, OHOS::Accessibility::RangeInfo& rangeInfo);
|
||||
void ConvertGridInfoToJS(napi_env env, napi_value nGrid, OHOS::Accessibility::GridInfo& grid);
|
||||
void ConvertGridItemToJS(napi_env env, napi_value nGridItem,
|
||||
OHOS::Accessibility::GridItemInfo& gridItem);
|
||||
void ConvertEventInfoJSToNAPI(napi_env env, napi_value object, OHOS::Accessibility::AccessibilityEventInfo &eventInfo);
|
||||
void ConvertElementInfosToJS(napi_env env, napi_value result,
|
||||
std::vector<OHOS::Accessibility::AccessibilityElementInfo>& elementInfos);
|
||||
OHOS::Accessibility::ActionType ConvertStringToAccessibleOperationType(std::string type);
|
||||
OHOS::Accessibility::AccessibilityAbilityTypes ConvertStringToAccessibilityAbilityTypes(std::string type);
|
||||
OHOS::Accessibility::AbilityStateType ConvertStringToAbilityStateTypes(std::string type);
|
||||
OHOS::Accessibility::GlobalAction ConvertStringToGlobalAction(std::string type);
|
||||
void ConvertActionArgsJSToNAPI(napi_env env, napi_value object, std::map<std::string, std::string> &args, OHOS::Accessibility::ActionType action);
|
||||
std::vector<std::string> ParseAbilityTypesToVec(uint32_t abilityTypesValue);
|
||||
std::vector<std::string> ParseCapabilitiesToVec(uint32_t capabilitiesValue);
|
||||
std::vector<std::string> ParseEventTypesToVec(uint32_t eventTypesValue);
|
||||
#endif // NAPI_ACCESSIBILITY_UTILS_H
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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_WINDOW_H
|
||||
#define NAPI_ACCESSIBILITY_WINDOW_H
|
||||
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "accessibility_window_info.h"
|
||||
#include "accessibility_element_info.h"
|
||||
|
||||
struct NAccessibilityWindowInfoData {
|
||||
napi_async_work work_ {};
|
||||
napi_deferred deferred_ {};
|
||||
napi_ref thisRefer_ {};
|
||||
napi_ref callback_ {};
|
||||
napi_env env_ {};
|
||||
bool result_ = false;
|
||||
OHOS::Accessibility::AccessibilityWindowInfo nativeWindowInfo_;
|
||||
OHOS::Accessibility::AccessibilityElementInfo nodeInfo_ {};
|
||||
OHOS::Accessibility::AccessibilityWindowInfo window_ {};
|
||||
std::string content_ = "";
|
||||
int childIndex_ = 0;
|
||||
};
|
||||
|
||||
class NAccessibilityWindowInfo {
|
||||
public:
|
||||
static void DefineJSAccessibilityWindowInfo(napi_env env);
|
||||
static napi_value JSConstructor(napi_env env, napi_callback_info info);
|
||||
|
||||
static napi_value GetAnchorElementInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value GetRootElementInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value GetParent(napi_env env, napi_callback_info info);
|
||||
static napi_value GetChild(napi_env env, napi_callback_info info);
|
||||
|
||||
static napi_value cons_;
|
||||
private:
|
||||
NAccessibilityWindowInfo() = default;
|
||||
~NAccessibilityWindowInfo() = default;
|
||||
};
|
||||
#endif // NAPI_ACCESSIBILITY_WINDOW_H
|
104
interfaces/kits/napi/include/napi_accessible_ability.h
Normal file
104
interfaces/kits/napi/include/napi_accessible_ability.h
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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_ACCESSIBLE_ABILITY_H
|
||||
#define NAPI_ACCESSIBLE_ABILITY_H
|
||||
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "accessibility_window_info.h"
|
||||
#include "accessible_ability_listener.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
|
||||
const std::string STR_A11Y_OBSERVER_ABILITY_CONNECTED = "AbilityConnected";
|
||||
const std::string STR_A11Y_OBSERVER_INTERRUPT = "interrupt";
|
||||
const std::string STR_A11Y_OBSERVER_ACCESSIBILITY_EVENT = "accessibilityEvent";
|
||||
const std::string STR_A11Y_OBSERVER_GESTURE = "gesture";
|
||||
const std::string STR_A11Y_OBSERVER_KEY_PRESS = "keyPress";
|
||||
|
||||
struct AsyncGetAccessibleAbilityCallbackInfo {
|
||||
napi_env env_;
|
||||
napi_async_work asyncWork_;
|
||||
napi_deferred deferred_;
|
||||
napi_ref callback_ = 0;
|
||||
};
|
||||
|
||||
struct AsyncDisableAbilityCallbackInfo {
|
||||
napi_env env_;
|
||||
napi_async_work asyncWork_;
|
||||
napi_deferred deferred_;
|
||||
napi_ref callback_ = 0;
|
||||
};
|
||||
|
||||
struct AsyncGetWindowsCallbackInfo {
|
||||
napi_env env_;
|
||||
napi_async_work asyncWork_;
|
||||
napi_deferred deferred_;
|
||||
napi_ref callback_ = 0;
|
||||
std::vector<OHOS::Accessibility::AccessibilityWindowInfo> accessibilityWindows_;
|
||||
};
|
||||
|
||||
struct AsyncGetRootElementInfoCallbackInfo {
|
||||
public:
|
||||
napi_env env_;
|
||||
napi_async_work asyncWork_;
|
||||
napi_deferred deferred_;
|
||||
napi_ref callback_ = 0;
|
||||
std::optional<OHOS::Accessibility::AccessibilityElementInfo> elementInfo_;
|
||||
bool result_ = false;
|
||||
};
|
||||
|
||||
struct AccessibleAbilityCallbackInfo {
|
||||
napi_env env_;
|
||||
// napi_async_work asyncWork_;
|
||||
// napi_deferred deferred_;
|
||||
napi_ref callback_ = 0;
|
||||
};
|
||||
|
||||
struct AsyncGetFocusElementInfoCallbackInfo {
|
||||
napi_env env_;
|
||||
napi_async_work asyncWork_;
|
||||
napi_deferred deferred_;
|
||||
napi_ref callback_ = 0;
|
||||
std::string focusType_ = "";
|
||||
std::optional<OHOS::Accessibility::AccessibilityElementInfo> elementInfo_;
|
||||
bool result_ = false;
|
||||
};
|
||||
|
||||
struct AsyncPerformCommonActionCallbackInfo {
|
||||
napi_env env_;
|
||||
napi_async_work asyncWork_;
|
||||
napi_deferred deferred_;
|
||||
napi_ref callback_ = 0;
|
||||
uint32_t action_ = 0xFFFFFFFF;
|
||||
bool performActionResult_ = false;
|
||||
};
|
||||
|
||||
void CreateGlobalAccessibleAbilityJSObject(napi_env env);
|
||||
napi_value AccessibleAbilityConstructor(napi_env env, napi_callback_info info);
|
||||
napi_value GetAccessibleAbility(napi_env env, napi_callback_info info);
|
||||
|
||||
napi_value RegisterCallback(napi_env env, napi_callback_info info);
|
||||
napi_value DisableAbility(napi_env env, napi_callback_info info);
|
||||
napi_value GetWindows(napi_env env, napi_callback_info info);
|
||||
napi_value GetRootElementInfo(napi_env env, napi_callback_info info);
|
||||
napi_value GetFocusElementInfo(napi_env env, napi_callback_info info);
|
||||
napi_value PerformCommonAction(napi_env env, napi_callback_info info);
|
||||
|
||||
// Dummy
|
||||
napi_value ConnectToAAMS(napi_env env, napi_callback_info info);
|
||||
#endif // NAPI_ACCESSIBLE_ABILITY_H
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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_ACCESSIBLE_ABILITY_OBSERVER_H
|
||||
#define NAPI_ACCESSIBLE_ABILITY_OBSERVER_H
|
||||
|
||||
#include "accessible_ability_listener.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
|
||||
class AccessibleAbilityObserver: public OHOS::Accessibility::AccessibleAbilityListener {
|
||||
public:
|
||||
AccessibleAbilityObserver() = default;
|
||||
~AccessibleAbilityObserver() = default;
|
||||
|
||||
void OnAccessibilityEvent(const OHOS::Accessibility::AccessibilityEventInfo& eventInfo) override;
|
||||
void OnInterrupt() override;
|
||||
void OnAbilityConnected() override;
|
||||
void OnGesture(uint32_t gestureId) override;
|
||||
bool OnKeyPressEvent(const OHOS::MMI::KeyEvent& keyEvent) override;
|
||||
};
|
||||
#endif // NAPI_ACCESSIBLE_ABILITY_OBSERVER_H
|
56
interfaces/kits/napi/include/napi_tts.h
Normal file
56
interfaces/kits/napi/include/napi_tts.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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_TTS_H
|
||||
#define NAPI_TTS_H
|
||||
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "ttsDummy.h"
|
||||
// #include "tts_engine.h"
|
||||
|
||||
namespace OHOS {
|
||||
class TtsObserver : public TtsFwk::TtsListener {
|
||||
public:
|
||||
TtsObserver() = default;
|
||||
~TtsObserver() = default;
|
||||
|
||||
void OnEvent(int eventType) override;
|
||||
void OnSpeechStart(int utteranceId) override;
|
||||
void OnSpeechProgress(int utteranceId, int progress) override;
|
||||
void OnSpeechFinish(int utteranceId) override;
|
||||
};
|
||||
|
||||
class NTTSClient {
|
||||
public:
|
||||
static napi_value Create(napi_env env, napi_callback_info info);
|
||||
static napi_value Release(napi_env env, napi_callback_info info);
|
||||
static napi_value InitTTS(napi_env env, napi_callback_info info);
|
||||
static napi_value SetParams(napi_env env, napi_callback_info info);
|
||||
static napi_value SetAudioType(napi_env env, napi_callback_info info);
|
||||
static napi_value SpeakText(napi_env env, napi_callback_info info);
|
||||
static napi_value StopSpeak(napi_env env, napi_callback_info info);
|
||||
static napi_value Destroy(napi_env env, napi_callback_info info);
|
||||
|
||||
static napi_value ttsClientCons_;
|
||||
static napi_env env_;
|
||||
static napi_ref onEventRef_;
|
||||
static napi_ref onSpeechFinishedRef_;
|
||||
static sptr<TtsFwk::TtsListener> listener_;
|
||||
};
|
||||
}// namespace OHOS
|
||||
|
||||
|
||||
#endif // NAPI_TTS_H
|
134
interfaces/kits/napi/src/napi_accessibility_event_info.cpp
Normal file
134
interfaces/kits/napi/src/napi_accessibility_event_info.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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 <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "accessibility_event_info.h"
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
#include "napi_accessibility_def.h"
|
||||
#include "napi_accessibility_utils.h"
|
||||
#include "napi_accessibility_window_info.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "napi_accessibility_event_info.h"
|
||||
#include "napi_accessibility_info.h"
|
||||
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::Accessibility;
|
||||
|
||||
napi_value NAccessibilityEventInfo::cons_ = nullptr;
|
||||
|
||||
void NAccessibilityEventInfo::DefineJSAccessibilityEventInfo(napi_env env) {
|
||||
napi_property_descriptor descForAccessibilityEventInfo[] = {
|
||||
DECLARE_NAPI_FUNCTION("getSource", NAccessibilityEventInfo::GetSource),
|
||||
};
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env,
|
||||
napi_define_class(env,
|
||||
"EventInfo",
|
||||
NAPI_AUTO_LENGTH,
|
||||
NAccessibilityEventInfo::JSConstructor,
|
||||
nullptr,
|
||||
sizeof(descForAccessibilityEventInfo) / sizeof(descForAccessibilityEventInfo[0]),
|
||||
descForAccessibilityEventInfo,
|
||||
&NAccessibilityEventInfo::cons_));
|
||||
}
|
||||
|
||||
napi_value NAccessibilityEventInfo::JSConstructor(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;
|
||||
}
|
||||
|
||||
napi_value NAccessibilityEventInfo::GetSource(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("%{public}s start", __func__);
|
||||
size_t argc = ARGS_SIZE_ONE;
|
||||
napi_value argv[ARGS_SIZE_ONE] = {0};
|
||||
napi_status status;
|
||||
napi_value thisVar;
|
||||
void* data = nullptr;
|
||||
AccessibilityEventInfo* eventInfo = nullptr;
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
|
||||
HILOG_DEBUG("argc = %{public}d", (int)argc);
|
||||
|
||||
status = napi_unwrap(env, thisVar, (void**)&eventInfo);
|
||||
HILOG_DEBUG("napi_unwrap status: %{public}d", (int)status);
|
||||
if (!eventInfo) {
|
||||
HILOG_DEBUG("eventInfo is null!!");
|
||||
}
|
||||
|
||||
NAccessibilityEventInfoData *callbackInfo = new NAccessibilityEventInfoData();
|
||||
callbackInfo->eventInfo_ = *eventInfo;
|
||||
|
||||
napi_value promise = nullptr;
|
||||
if (argc > 0) {
|
||||
HILOG_DEBUG("GetSource callback mode");
|
||||
napi_create_reference(env, argv[PARAM0], 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_DEBUG("GetSource promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetSource", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) { // execute async to call c++ function
|
||||
NAccessibilityEventInfoData *callbackInfo = (NAccessibilityEventInfoData*)data;
|
||||
AccessibilityEventInfo eventInfo = callbackInfo->eventInfo_;
|
||||
callbackInfo->result_ = eventInfo.GetSource(callbackInfo->nodeInfo_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) { //execute the complete function
|
||||
HILOG_DEBUG("GetSource execute back");
|
||||
NAccessibilityEventInfoData* callbackInfo = (NAccessibilityEventInfoData*)data;
|
||||
napi_value jsReturnValue = 0;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
napi_new_instance(env, NElementInfo::cons_, 0, nullptr, &argv[PARAM1]);
|
||||
ConvertElementInfoToJS(env, argv[PARAM1], callbackInfo->nodeInfo_);
|
||||
|
||||
argv[PARAM0] = GetErrorValue(env, callbackInfo->result_ ? CODE_SUCCESS : CODE_FAILED);
|
||||
if (callbackInfo->callback_) {
|
||||
// Callback mode
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, argv, &jsReturnValue);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
if (callbackInfo->result_) {
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, argv[PARAM1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, argv[PARAM0]);
|
||||
}
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
|
||||
return promise;
|
||||
}
|
551
interfaces/kits/napi/src/napi_accessibility_info.cpp
Normal file
551
interfaces/kits/napi/src/napi_accessibility_info.cpp
Normal file
@ -0,0 +1,551 @@
|
||||
/*
|
||||
* 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_info.h"
|
||||
#include "napi_accessibility_utils.h"
|
||||
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::Accessibility;
|
||||
|
||||
napi_value NElementInfo::cons_ = nullptr;
|
||||
|
||||
void NElementInfo::DefineJSElementInfo(napi_env env) {
|
||||
napi_property_descriptor descForElementInfo[] = {
|
||||
DECLARE_NAPI_FUNCTION("executeAction", NElementInfo::ExecuteAction),
|
||||
DECLARE_NAPI_FUNCTION("getByContent", NElementInfo::GetByContent),
|
||||
DECLARE_NAPI_FUNCTION("get", NElementInfo::GetFocus),
|
||||
DECLARE_NAPI_FUNCTION("next", NElementInfo::GetNext),
|
||||
DECLARE_NAPI_FUNCTION("getChild", NElementInfo::GetChild),
|
||||
DECLARE_NAPI_FUNCTION("getParent", NElementInfo::GetParent),
|
||||
};
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env,
|
||||
napi_define_class(env,
|
||||
"AccessibilityElementInfo",
|
||||
NAPI_AUTO_LENGTH,
|
||||
NElementInfo::JSConstructor,
|
||||
nullptr,
|
||||
sizeof(descForElementInfo) / sizeof(descForElementInfo[0]),
|
||||
descForElementInfo,
|
||||
&NElementInfo::cons_));
|
||||
}
|
||||
|
||||
napi_value NElementInfo::JSConstructor(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;
|
||||
}
|
||||
|
||||
napi_value NElementInfo::ExecuteAction(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("%{public}s start", __func__);
|
||||
size_t argc = ARGS_SIZE_THREE;
|
||||
napi_value argv[ARGS_SIZE_THREE] = {0};
|
||||
napi_status status;
|
||||
napi_value thisVar;
|
||||
void* data = nullptr;
|
||||
AccessibilityElementInfo* nodeInfo = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
|
||||
std::string action;
|
||||
ParseString(env, action, argv[PARAM0]);
|
||||
HILOG_DEBUG("argc = %{public}d", (int)argc);
|
||||
HILOG_INFO("action = %{public}s", action.c_str());
|
||||
status = napi_unwrap(env, thisVar, (void**)&nodeInfo);
|
||||
if (!nodeInfo) {
|
||||
HILOG_ERROR("nodeInfo is null!!");
|
||||
}
|
||||
NAccessibilityInfoData *callbackInfo = new NAccessibilityInfoData();
|
||||
ConvertActionArgsJSToNAPI(env, argv[ARGS_SIZE_TWO], callbackInfo->actionArguments_,
|
||||
ConvertStringToAccessibleOperationType(action));
|
||||
callbackInfo->nativeNodeInfo_ = *nodeInfo;
|
||||
callbackInfo->content_ = action;
|
||||
napi_value promise = nullptr;
|
||||
|
||||
//Parse function
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
if (argc >= ARGS_SIZE_TWO) {
|
||||
NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valueType));
|
||||
}
|
||||
if (valueType == napi_function) {
|
||||
HILOG_ERROR("ExecuteAction callback mode");
|
||||
napi_create_reference(env, argv[PARAM1], 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_ERROR("ExecuteAction promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "ExecuteAction", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) {
|
||||
NAccessibilityInfoData *callbackInfo = (NAccessibilityInfoData*)data;
|
||||
ActionType action = ConvertStringToAccessibleOperationType(callbackInfo->content_);
|
||||
AccessibilityElementInfo nodeInfo = callbackInfo->nativeNodeInfo_;
|
||||
callbackInfo->result_ = nodeInfo.ExecuteAction(action, callbackInfo->actionArguments_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) {
|
||||
HILOG_DEBUG("ExecuteAction execute back");
|
||||
NAccessibilityInfoData* callbackInfo = (NAccessibilityInfoData*)data;
|
||||
napi_value jsReturnValue = 0;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
napi_get_boolean(env, callbackInfo->result_, &argv[PARAM1]);
|
||||
HILOG_DEBUG("callbackInfo->result_[%{public}d]", callbackInfo->result_);
|
||||
|
||||
if (callbackInfo->callback_) {
|
||||
// Callback mode
|
||||
argv[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, argv, &jsReturnValue);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, argv[PARAM1]);
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value NElementInfo::GetByContent(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("%{public}s start", __func__);
|
||||
size_t argc = ARGS_SIZE_TWO;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_status status;
|
||||
napi_value thisVar;
|
||||
void* data = nullptr;
|
||||
AccessibilityElementInfo* nodeInfo = nullptr;
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
|
||||
std::string content;
|
||||
ParseString(env, content, argv[PARAM0]);
|
||||
HILOG_DEBUG("argc = %{public}d", (int)argc);
|
||||
HILOG_INFO("content[%{public}s]", content.c_str());
|
||||
|
||||
status = napi_unwrap(env, thisVar, (void**)&nodeInfo);
|
||||
if (!nodeInfo) {
|
||||
HILOG_ERROR("nodeInfo is null!!");
|
||||
}
|
||||
|
||||
NAccessibilityInfoData *callbackInfo = new NAccessibilityInfoData();
|
||||
callbackInfo->nativeNodeInfo_ = *nodeInfo;
|
||||
callbackInfo->content_ = content;
|
||||
napi_value promise = nullptr;
|
||||
if (argc > ARGS_SIZE_ONE) {
|
||||
HILOG_ERROR("callback mode");
|
||||
napi_create_reference(env, argv[PARAM1], 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_ERROR("promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetByContent", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) { // execute async to call c++ function
|
||||
NAccessibilityInfoData *callbackInfo = (NAccessibilityInfoData*)data;
|
||||
AccessibilityElementInfo nodeInfo = callbackInfo->nativeNodeInfo_;
|
||||
callbackInfo->ret_ = nodeInfo.GetByContent(callbackInfo->content_, callbackInfo->nodeInfos_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) { //execute the complete function
|
||||
HILOG_DEBUG("execute back");
|
||||
NAccessibilityInfoData* callbackInfo = (NAccessibilityInfoData*)data;
|
||||
napi_value jsReturnValue = 0;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
napi_create_array(env, &argv[PARAM1]);
|
||||
ConvertElementInfosToJS(env, argv[PARAM1], callbackInfo->nodeInfos_);
|
||||
|
||||
|
||||
argv[PARAM0] = GetErrorValue(env, callbackInfo->ret_ ? CODE_SUCCESS : CODE_FAILED);
|
||||
if (callbackInfo->callback_) {
|
||||
// Callback mode
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, argv, &jsReturnValue);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
if (callbackInfo->ret_) {
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, argv[PARAM1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, argv[PARAM0]);
|
||||
}
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value NElementInfo::GetFocus(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("%{public}s start", __func__);
|
||||
size_t argc = ARGS_SIZE_TWO;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_status status;
|
||||
napi_value thisVar;
|
||||
void* data = nullptr;
|
||||
AccessibilityElementInfo* nodeInfo = nullptr;
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
|
||||
std::string focusType;
|
||||
ParseString(env, focusType, argv[PARAM0]);
|
||||
HILOG_DEBUG("argc = %{public}d", (int)argc);
|
||||
HILOG_INFO("focusType[%{public}s]", focusType.c_str());
|
||||
|
||||
status = napi_unwrap(env, thisVar, (void**)&nodeInfo);
|
||||
if (!nodeInfo) {
|
||||
HILOG_ERROR("nodeInfo is null!!");
|
||||
}
|
||||
|
||||
NAccessibilityInfoData *callbackInfo = new NAccessibilityInfoData();
|
||||
callbackInfo->nativeNodeInfo_ = *nodeInfo;
|
||||
callbackInfo->content_ = focusType;
|
||||
napi_value promise = nullptr;
|
||||
if (argc > ARGS_SIZE_ONE) {
|
||||
HILOG_DEBUG("callback mode");
|
||||
napi_create_reference(env, argv[PARAM1], 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_DEBUG("promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetFocus", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) {
|
||||
NAccessibilityInfoData *callbackInfo = (NAccessibilityInfoData*)data;
|
||||
int focus = 0;
|
||||
if (std::strcmp(callbackInfo->content_.c_str(), "accessibility") == 0) {
|
||||
focus = FOCUS_TYPE_ACCESSIBILITY;
|
||||
} else if (std::strcmp(callbackInfo->content_.c_str(), "normal") == 0) {
|
||||
focus = FOCUS_TYPE_INPUT;
|
||||
} else {
|
||||
focus = FOCUS_TYPE_INVALID;
|
||||
}
|
||||
AccessibilityElementInfo nodeInfo = callbackInfo->nativeNodeInfo_;
|
||||
callbackInfo->ret_ = nodeInfo.GetFocus(focus, callbackInfo->nodeInfo_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) {
|
||||
HILOG_DEBUG("execute back");
|
||||
NAccessibilityInfoData* callbackInfo = (NAccessibilityInfoData*)data;
|
||||
napi_value jsReturnValue = 0;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
napi_new_instance(env, NElementInfo::cons_, 0, nullptr, &argv[PARAM1]);
|
||||
ConvertElementInfoToJS(env, argv[PARAM1], callbackInfo->nodeInfo_);
|
||||
|
||||
argv[PARAM0] = GetErrorValue(env, callbackInfo->ret_ ? CODE_SUCCESS : CODE_FAILED);
|
||||
if (callbackInfo->callback_) {
|
||||
// Callback mode
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, argv, &jsReturnValue);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
if (callbackInfo->ret_) {
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, argv[PARAM1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, argv[PARAM0]);
|
||||
}
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
static FocusMoveDirection CovertStringToDirection(std::string str) {
|
||||
static const std::map<std::string, FocusMoveDirection> focusMoveDirectionTable = {
|
||||
{"up", FocusMoveDirection::UP},
|
||||
{"down", FocusMoveDirection::DOWN},
|
||||
{"left", FocusMoveDirection::LEFT},
|
||||
{"right", FocusMoveDirection::RIGHT},
|
||||
{"forward", FocusMoveDirection::FORWARD},
|
||||
{"backward", FocusMoveDirection::BACKWARD}
|
||||
};
|
||||
|
||||
if (focusMoveDirectionTable.find(str) == focusMoveDirectionTable.end()) {
|
||||
return FocusMoveDirection::DIRECTION_INVALID;
|
||||
}
|
||||
|
||||
return focusMoveDirectionTable.at(str);
|
||||
}
|
||||
|
||||
napi_value NElementInfo::GetNext(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("%{public}s start", __func__);
|
||||
size_t argc = ARGS_SIZE_TWO;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_status status;
|
||||
napi_value thisVar;
|
||||
void* data = nullptr;
|
||||
AccessibilityElementInfo* nodeInfo = nullptr;
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
|
||||
std::string direction;
|
||||
ParseString(env, direction, argv[PARAM0]);
|
||||
HILOG_DEBUG("argc = %{public}d", (int)argc);
|
||||
HILOG_INFO("direction[%{public}s]", direction.c_str());
|
||||
|
||||
status = napi_unwrap(env, thisVar, (void**)&nodeInfo);
|
||||
if (!nodeInfo) {
|
||||
HILOG_ERROR("nodeInfo is null!!");
|
||||
}
|
||||
|
||||
NAccessibilityInfoData *callbackInfo = new NAccessibilityInfoData();
|
||||
callbackInfo->nativeNodeInfo_ = *nodeInfo;
|
||||
callbackInfo->content_ = direction;
|
||||
napi_value promise = nullptr;
|
||||
if (argc > ARGS_SIZE_ONE) {
|
||||
HILOG_DEBUG("GetNext callback mode");
|
||||
napi_create_reference(env, argv[PARAM1], 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_DEBUG("GetNext promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetNext", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) { // execute async to call c++ function
|
||||
NAccessibilityInfoData *callbackInfo = (NAccessibilityInfoData*)data;
|
||||
AccessibilityElementInfo nodeInfo = callbackInfo->nativeNodeInfo_;
|
||||
callbackInfo->ret_ = nodeInfo.GetNext(CovertStringToDirection(callbackInfo->content_),
|
||||
callbackInfo->nodeInfo_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) { //execute the complete function
|
||||
HILOG_DEBUG("GetNext execute back");
|
||||
NAccessibilityInfoData* callbackInfo = (NAccessibilityInfoData*)data;
|
||||
napi_value jsReturnValue = 0;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
napi_new_instance(env, NElementInfo::cons_, 0, nullptr, &argv[PARAM1]);
|
||||
ConvertElementInfoToJS(env, argv[PARAM1], callbackInfo->nodeInfo_);
|
||||
|
||||
argv[PARAM0] = GetErrorValue(env, callbackInfo->ret_ ? CODE_SUCCESS : CODE_FAILED);
|
||||
if (callbackInfo->callback_) {
|
||||
// Callback mode
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, argv, &jsReturnValue);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
if (callbackInfo->ret_) {
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, argv[PARAM1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, argv[PARAM0]);
|
||||
}
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value NElementInfo::GetChild(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("%{public}s start", __func__);
|
||||
size_t argc = ARGS_SIZE_TWO;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_status status;
|
||||
napi_value thisVar;
|
||||
void* data = nullptr;
|
||||
AccessibilityElementInfo* nodeInfo = nullptr;
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
|
||||
HILOG_DEBUG("argc = %{public}d", (int)argc);
|
||||
int childIndex;
|
||||
napi_get_value_int32(env, argv[PARAM0], &childIndex);
|
||||
HILOG_INFO("childIndex[%{public}d]", childIndex);
|
||||
|
||||
status = napi_unwrap(env, thisVar, (void**)&nodeInfo);
|
||||
if (!nodeInfo) {
|
||||
HILOG_ERROR("nodeInfo is null!!");
|
||||
}
|
||||
|
||||
NAccessibilityInfoData *callbackInfo = new NAccessibilityInfoData();
|
||||
callbackInfo->nativeNodeInfo_ = *nodeInfo;
|
||||
callbackInfo->childIndex_ = childIndex;
|
||||
napi_value promise = nullptr;
|
||||
if (argc > ARGS_SIZE_ONE) {
|
||||
HILOG_DEBUG("GetChild callback mode");
|
||||
napi_create_reference(env, argv[PARAM1], 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_DEBUG("GetChild promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetChild", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) { // execute async to call c++ function
|
||||
NAccessibilityInfoData *callbackInfo = (NAccessibilityInfoData*)data;
|
||||
AccessibilityElementInfo nodeInfo = callbackInfo->nativeNodeInfo_;
|
||||
callbackInfo->ret_ = nodeInfo.GetChild(callbackInfo->childIndex_, callbackInfo->nodeInfo_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) { //execute the complete function
|
||||
HILOG_DEBUG("GetChild execute back");
|
||||
NAccessibilityInfoData* callbackInfo = (NAccessibilityInfoData*)data;
|
||||
napi_value jsReturnValue = 0;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
napi_new_instance(env, NElementInfo::cons_, 0, nullptr, &argv[PARAM1]);
|
||||
ConvertElementInfoToJS(env, argv[PARAM1], callbackInfo->nodeInfo_);
|
||||
|
||||
argv[PARAM0] = GetErrorValue(env, callbackInfo->ret_ ? CODE_SUCCESS : CODE_FAILED);
|
||||
if (callbackInfo->callback_) {
|
||||
// Callback mode
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, argv, &jsReturnValue);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
if (callbackInfo->ret_) {
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, argv[PARAM1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, argv[PARAM0]);
|
||||
}
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value NElementInfo::GetParent(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("%{public}s start", __func__);
|
||||
size_t argc = ARGS_SIZE_ONE;
|
||||
napi_value argv[ARGS_SIZE_ONE] = {0};
|
||||
napi_status status;
|
||||
napi_value thisVar;
|
||||
void* data = nullptr;
|
||||
AccessibilityElementInfo* nodeInfo = nullptr;
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
|
||||
HILOG_DEBUG("argc = %{public}d", (int)argc);
|
||||
|
||||
status = napi_unwrap(env, thisVar, (void**)&nodeInfo);
|
||||
if (!nodeInfo) {
|
||||
HILOG_ERROR("nodeInfo is null!!");
|
||||
}
|
||||
|
||||
NAccessibilityInfoData *callbackInfo = new NAccessibilityInfoData();
|
||||
callbackInfo->nativeNodeInfo_ = *nodeInfo;
|
||||
|
||||
napi_value promise = nullptr;
|
||||
if (argc > 0) {
|
||||
HILOG_DEBUG("GetParent callback mode");
|
||||
napi_create_reference(env, argv[PARAM0], 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_DEBUG("GetParent promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetParent", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) { // execute async to call c++ function
|
||||
NAccessibilityInfoData *callbackInfo = (NAccessibilityInfoData*)data;
|
||||
AccessibilityElementInfo nodeInfo = callbackInfo->nativeNodeInfo_;
|
||||
callbackInfo->ret_ = nodeInfo.GetParent(callbackInfo->nodeInfo_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) { //execute the complete function
|
||||
HILOG_DEBUG("GetParent execute back");
|
||||
NAccessibilityInfoData* callbackInfo = (NAccessibilityInfoData*)data;
|
||||
napi_value jsReturnValue = 0;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
napi_new_instance(env, NElementInfo::cons_, 0, nullptr, &argv[PARAM1]);
|
||||
ConvertElementInfoToJS(env, argv[PARAM1], callbackInfo->nodeInfo_);
|
||||
|
||||
argv[PARAM0] = GetErrorValue(env, callbackInfo->ret_ ? CODE_SUCCESS : CODE_FAILED);
|
||||
if (callbackInfo->callback_) {
|
||||
// Callback mode
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, argv, &jsReturnValue);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
if (callbackInfo->ret_) {
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, argv[PARAM1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, argv[PARAM0]);
|
||||
}
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
|
||||
return promise;
|
||||
}
|
@ -0,0 +1,435 @@
|
||||
/*
|
||||
* 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_system_ability_client.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "napi_accessibility_utils.h"
|
||||
#include "accessibility_state_event.h"
|
||||
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::Accessibility;
|
||||
|
||||
std::vector<std::shared_ptr<StateListener>> g_states;
|
||||
napi_value IsOpenAccessibility(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("%{public}s start", __func__);
|
||||
size_t argc = ARGS_SIZE_ONE;
|
||||
napi_value argv;
|
||||
napi_get_cb_info(env, info, &argc, &argv, nullptr, nullptr);
|
||||
|
||||
napi_value promise = nullptr;
|
||||
NAccessibilitySystemAbilityClient *callbackInfo = new NAccessibilitySystemAbilityClient();
|
||||
if (argc > 0) {
|
||||
HILOG_DEBUG("IsOpenAccessibility callback mode");
|
||||
napi_create_reference(env, argv, 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_DEBUG("IsOpenAccessibility promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "IsOpenAccessibility", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) { // execute async to call c++ function
|
||||
NAccessibilitySystemAbilityClient *callbackInfo = (NAccessibilitySystemAbilityClient*)data;
|
||||
callbackInfo->enabled_ = AccessibilitySystemAbilityClient::GetInstance()->IsEnabled();
|
||||
HILOG_INFO("IsOpenAccessibility Executing enabled[%{public}d]", callbackInfo->enabled_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) { //execute the complete function
|
||||
NAccessibilitySystemAbilityClient *callbackInfo = (NAccessibilitySystemAbilityClient*)data;
|
||||
napi_value result[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, callbackInfo->enabled_, &result[PARAM1]));
|
||||
HILOG_INFO("IsOpenAccessibility completed enabled[%{public}d]", callbackInfo->enabled_);
|
||||
|
||||
if (callbackInfo->callback_) {
|
||||
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_value return_val;
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &return_val);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
|
||||
}
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value IsOpenTouchExploration(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("%{public}s start", __func__);
|
||||
size_t argc = ARGS_SIZE_ONE;
|
||||
napi_value argv;
|
||||
napi_get_cb_info(env, info, &argc, &argv, nullptr, nullptr);
|
||||
|
||||
napi_value promise = nullptr;
|
||||
NAccessibilitySystemAbilityClient *callbackInfo = new NAccessibilitySystemAbilityClient();
|
||||
if (argc > 0) {
|
||||
HILOG_DEBUG("IsOpenTouchExploration callback mode");
|
||||
napi_create_reference(env, argv, 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_DEBUG("IsOpenTouchExploration promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "IsOpenTouchExploration", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) { // execute async to call c++ function
|
||||
NAccessibilitySystemAbilityClient *callbackInfo = (NAccessibilitySystemAbilityClient*)data;
|
||||
callbackInfo->enabled_ = AccessibilitySystemAbilityClient::GetInstance()->IsEnabled();
|
||||
HILOG_INFO("IsOpenTouchExploration Executing touchEnabled[%{public}d]", callbackInfo->touchEnabled_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) { //execute the complete function
|
||||
NAccessibilitySystemAbilityClient *callbackInfo = (NAccessibilitySystemAbilityClient*)data;
|
||||
napi_value result[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, callbackInfo->enabled_, &result[PARAM1]));
|
||||
HILOG_INFO("IsOpenTouchExploration completed touchEnabled_[%{public}d]", callbackInfo->touchEnabled_);
|
||||
|
||||
if (callbackInfo->callback_) {
|
||||
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_value return_val;
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &return_val);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
|
||||
}
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value GetAbilityList(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("%{public}s start", __func__);
|
||||
size_t argc = 3;
|
||||
napi_value parameters[3] = {0};
|
||||
napi_get_cb_info(env, info, &argc, parameters, nullptr, nullptr);
|
||||
|
||||
std::string abilityTypes = GetStringFromNAPI(env, parameters[0]);
|
||||
std::string stateTypes = GetStringFromNAPI(env, parameters[1]);;
|
||||
|
||||
HILOG_INFO("abilityTypes[%{public}s]", abilityTypes.c_str());
|
||||
HILOG_INFO("stateTypes[%{public}s]", stateTypes.c_str());
|
||||
|
||||
NAccessibilitySystemAbilityClient *callbackInfo = new NAccessibilitySystemAbilityClient();
|
||||
callbackInfo->abilityTypes_ = ConvertStringToAccessibilityAbilityTypes(abilityTypes);
|
||||
callbackInfo->stateTypes_ = ConvertStringToAbilityStateTypes(stateTypes);
|
||||
|
||||
napi_value promise = nullptr;
|
||||
|
||||
if (argc > ARGS_SIZE_TWO) {
|
||||
HILOG_DEBUG("GetAbilityList callback mode");
|
||||
napi_create_reference(env, parameters[2], 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_DEBUG("GetAbilityList promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetAbilityList", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) { // execute async to call c++ function
|
||||
NAccessibilitySystemAbilityClient *callbackInfo = (NAccessibilitySystemAbilityClient*)data;
|
||||
callbackInfo->abilityList_ = AccessibilitySystemAbilityClient::GetInstance()->GetAbilityList(
|
||||
int(callbackInfo->abilityTypes_),
|
||||
callbackInfo->stateTypes_);
|
||||
HILOG_INFO("GetAbilityList Executing GetAbilityList[%{public}d]", callbackInfo->abilityList_.size());
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) { //execute the complete function
|
||||
NAccessibilitySystemAbilityClient *callbackInfo = (NAccessibilitySystemAbilityClient*)data;
|
||||
napi_value result[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
napi_create_array(env, &result[PARAM1]);
|
||||
HILOG_INFO("GetAbilityList ENTER ConvertAccessibleAbilityInfosToJS");
|
||||
ConvertAccessibleAbilityInfosToJS(env, result[PARAM1], callbackInfo->abilityList_);
|
||||
if (callbackInfo->callback_) {
|
||||
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_value return_val;
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &return_val);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
|
||||
}
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value SendEvent(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("%{public}s start", __func__);
|
||||
size_t argc = ARGS_SIZE_TWO;
|
||||
napi_value parameters[ARGS_SIZE_TWO] = {0};
|
||||
napi_get_cb_info(env, info, &argc, parameters, nullptr, nullptr);
|
||||
|
||||
NAccessibilitySystemAbilityClient *callbackInfo = new NAccessibilitySystemAbilityClient();
|
||||
ConvertEventInfoJSToNAPI(env, parameters[0], callbackInfo->eventInfo_);
|
||||
napi_value promise = nullptr;
|
||||
|
||||
if (argc > ARGS_SIZE_ONE) {
|
||||
HILOG_DEBUG("SendEvent callback mode");
|
||||
napi_create_reference(env, parameters[1], 1, &callbackInfo->callback_);
|
||||
} else {
|
||||
HILOG_DEBUG("SendEvent promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "SendEvent", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) {
|
||||
NAccessibilitySystemAbilityClient *callbackInfo = (NAccessibilitySystemAbilityClient*)data;
|
||||
callbackInfo->result_ = AccessibilitySystemAbilityClient::GetInstance()->SendEvent(
|
||||
callbackInfo->eventInfo_);
|
||||
HILOG_INFO("SendEvent result[%{public}d]", callbackInfo->result_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) {
|
||||
NAccessibilitySystemAbilityClient *callbackInfo = (NAccessibilitySystemAbilityClient*)data;
|
||||
napi_value result[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, callbackInfo->result_, &result[PARAM1]));
|
||||
if (callbackInfo->callback_) {
|
||||
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_value return_val;
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &return_val);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
|
||||
}
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value SubscribeState(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("%{public}s start", __func__);
|
||||
size_t argc = ARGS_SIZE_TWO;
|
||||
napi_value args[ARGS_SIZE_TWO] = {0};
|
||||
napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
|
||||
NAPI_ASSERT(env, status == napi_ok, "Failed to get event type");
|
||||
|
||||
std::shared_ptr<StateListener> stateListener = std::make_shared<StateListener>();
|
||||
stateListener->StartWork(env, 1, args);
|
||||
g_states.push_back(stateListener);
|
||||
std::string eventType = GetStringFromNAPI(env, args[0]);
|
||||
AccessibilityStateEventType type = AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED;
|
||||
if (std::strcmp(eventType.c_str(), "accessibility") == 0) {
|
||||
type = AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED;
|
||||
} else if (std::strcmp(eventType.c_str(), "touchExplorer") == 0) {
|
||||
type = AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED;
|
||||
} else {
|
||||
HILOG_ERROR("SubscribeState eventType[%{public}s] is error", eventType.c_str());
|
||||
}
|
||||
bool result = AccessibilitySystemAbilityClient::GetInstance()->SubscribeStateObserver(stateListener, type);
|
||||
napi_value ret = {0};
|
||||
napi_get_boolean(env, result, &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
napi_value UnsubscribeState(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("%{public}s start observer size%{public}d", __func__, g_states.size());
|
||||
bool result = false;
|
||||
size_t argc = ARGS_SIZE_TWO;
|
||||
napi_value args[ARGS_SIZE_TWO] = {0};
|
||||
//napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
|
||||
napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
|
||||
//NAPI_ASSERT(env, status == napi_ok, "Failed to get event type");
|
||||
std::string eventType = GetStringFromNAPI(env, args[0]);
|
||||
|
||||
if (argc > ARGS_SIZE_ONE) {
|
||||
HILOG_DEBUG("UnsubscribeState callback mode %{public}d", g_states.size());
|
||||
NAccessibilitySystemAbilityClient *callbackInfo = new NAccessibilitySystemAbilityClient();
|
||||
napi_create_reference(env, args[1], 1, &callbackInfo->callback_);
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "off", NAPI_AUTO_LENGTH, &resource);
|
||||
callbackInfo->eventType_ = eventType;
|
||||
callbackInfo->stateListener_ = g_states;
|
||||
//async to sync start
|
||||
AccessibilityStateEventType type = AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED;
|
||||
std::string eventType = callbackInfo->eventType_ ;
|
||||
if (std::strcmp(eventType.c_str(), "accessibility") == 0) {
|
||||
type = AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED;
|
||||
} else if (std::strcmp(eventType.c_str(), "touchExplorer") == 0) {
|
||||
type = AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED;
|
||||
} else {
|
||||
HILOG_ERROR("SubscribeState eventType[%{public}s] is error", eventType.c_str());
|
||||
}
|
||||
int i = 0;
|
||||
HILOG_INFO("%{public}s *******observer size%{public}d*******", __func__, g_states.size());
|
||||
for (auto observer : g_states) {
|
||||
if (observer->GetEnv() == env && strcmp(observer->GetEventType().c_str(), eventType.c_str()) == 0) {
|
||||
callbackInfo->result_ = AccessibilitySystemAbilityClient::GetInstance()->UnsubscribeStateObserver(observer, type);
|
||||
HILOG_INFO("%{public}s ***********i%{public}d*********", __func__, i);
|
||||
g_states.erase(g_states.begin() + i);
|
||||
HILOG_INFO("%{public}s unregister result%{public}d", __func__, callbackInfo->result_);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
napi_value result[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
napi_get_boolean(env, callbackInfo->result_, &result[PARAM1]);
|
||||
// NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, callbackInfo->result_, &result[PARAM1]));
|
||||
if (callbackInfo->callback_) {
|
||||
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_value return_val;
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &return_val);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
HILOG_ERROR("SubscribeState end eventType[%{public}s] is error", callbackInfo->eventType_.c_str());
|
||||
}
|
||||
//async to sync end
|
||||
} else {
|
||||
AccessibilityStateEventType type = AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED;
|
||||
if (std::strcmp(eventType.c_str(), "accessibility") == 0) {
|
||||
type = AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED;
|
||||
} else if (std::strcmp(eventType.c_str(), "touchExplorer") == 0) {
|
||||
type = AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED;
|
||||
} else {
|
||||
HILOG_ERROR("SubscribeState eventType[%{public}s] is error", eventType.c_str());
|
||||
}
|
||||
int i = 0;
|
||||
for (auto observer : g_states) {
|
||||
if (observer->GetEnv() == env && strcmp(observer->GetEventType().c_str(), eventType.c_str()) == 0) {
|
||||
result = AccessibilitySystemAbilityClient::GetInstance()->UnsubscribeStateObserver(observer, type);
|
||||
g_states.erase(g_states.begin() + i);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
napi_value ret = 0;
|
||||
napi_get_boolean(env, result, &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
StateListener::StateListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AccessibilityStateEventType StateListener::GetStateType()
|
||||
{
|
||||
HILOG_INFO("%{public}s" , __func__);
|
||||
AccessibilityStateEventType type = EVENT_ACCESSIBILITY_STATE_CHANGED;
|
||||
if (std::strcmp(eventType_.c_str(), "accessibility") == 0) {
|
||||
type = EVENT_ACCESSIBILITY_STATE_CHANGED;
|
||||
} else if (std::strcmp(eventType_.c_str(), "touchExplorer") == 0) {
|
||||
type = EVENT_TOUCH_GUIDE_STATE_CHANGED;
|
||||
} else {
|
||||
HILOG_ERROR("SubscribeState eventType[%s] is error", eventType_.c_str());
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
napi_value StateListener::StartWork(napi_env env, size_t functionIndex, napi_value *args)
|
||||
{
|
||||
HILOG_INFO("%{public}s" , __func__);
|
||||
eventType_ = GetStringFromNAPI(env, args[0]);
|
||||
napi_create_reference(env, args[functionIndex], 1, &handlerRef_);
|
||||
env_ = env;
|
||||
napi_value result = {0};
|
||||
return result;
|
||||
}
|
||||
|
||||
void StateListener::NotifyJS(napi_env env, bool enabled, std::string stateType, std::string desc, napi_ref handlerRef)
|
||||
{
|
||||
HILOG_INFO("%{public}s" , __func__);
|
||||
napi_value jsEvent;
|
||||
napi_create_object(env, &jsEvent);
|
||||
|
||||
napi_value eventType;
|
||||
napi_create_string_utf8(env, stateType.c_str(), NAPI_AUTO_LENGTH, &eventType);
|
||||
napi_set_named_property(env, jsEvent, "eventType", eventType);
|
||||
|
||||
napi_value state;
|
||||
napi_get_boolean(env, enabled, &state);
|
||||
napi_set_named_property(env, jsEvent, "state", state);
|
||||
|
||||
napi_value description;
|
||||
napi_create_string_utf8(env, desc.c_str(), NAPI_AUTO_LENGTH, &description);
|
||||
napi_set_named_property(env, jsEvent, "description", description);
|
||||
|
||||
napi_value handler = nullptr;
|
||||
napi_value callResult;
|
||||
napi_get_reference_value(env, handlerRef, &handler);
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
napi_call_function(env, undefined, handler, 1, &jsEvent, &callResult);
|
||||
int32_t result;
|
||||
napi_get_value_int32(env, callResult, &result);
|
||||
HILOG_INFO("NotifyJS napi_call_function result[%{public}d]", result);
|
||||
}
|
||||
|
||||
void StateListener::OnStateChanged(const OHOS::Accessibility::AccessibilityStateEvent& stateEvent)
|
||||
{
|
||||
HILOG_INFO("%{public}s" , __func__);
|
||||
for (auto observer : g_states) {
|
||||
if (observer->GetStateType() == stateEvent.GetEventType()) {
|
||||
if (stateEvent.GetEventResult()) {
|
||||
observer->NotifyJS(observer->GetEnv(), true, observer->GetEventType(),
|
||||
stateEvent.GetEventMsg(), observer->GetHandler());
|
||||
} else {
|
||||
observer->NotifyJS(observer->GetEnv(), false, observer->GetEventType(),
|
||||
stateEvent.GetEventMsg(), observer->GetHandler());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1722
interfaces/kits/napi/src/napi_accessibility_utils.cpp
Normal file
1722
interfaces/kits/napi/src/napi_accessibility_utils.cpp
Normal file
File diff suppressed because it is too large
Load Diff
355
interfaces/kits/napi/src/napi_accessibility_window_info.cpp
Normal file
355
interfaces/kits/napi/src/napi_accessibility_window_info.cpp
Normal file
@ -0,0 +1,355 @@
|
||||
/*
|
||||
* 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_window_info.h"
|
||||
#include "napi_accessibility_utils.h"
|
||||
#include "napi_accessibility_info.h"
|
||||
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::Accessibility;
|
||||
|
||||
napi_value NAccessibilityWindowInfo::cons_ = nullptr;
|
||||
|
||||
void NAccessibilityWindowInfo::DefineJSAccessibilityWindowInfo(napi_env env) {
|
||||
napi_property_descriptor descForAccessibilityWindowInfo[] = {
|
||||
DECLARE_NAPI_FUNCTION("getAnchorElementInfo", NAccessibilityWindowInfo::GetAnchorElementInfo),
|
||||
DECLARE_NAPI_FUNCTION("getRootElementInfo", NAccessibilityWindowInfo::GetRootElementInfo),
|
||||
DECLARE_NAPI_FUNCTION("getParent", NAccessibilityWindowInfo::GetParent),
|
||||
DECLARE_NAPI_FUNCTION("getChild", NAccessibilityWindowInfo::GetChild),
|
||||
};
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env,
|
||||
napi_define_class(env,
|
||||
"AccessibilityWindowInfo",
|
||||
NAPI_AUTO_LENGTH,
|
||||
NAccessibilityWindowInfo::JSConstructor,
|
||||
nullptr,
|
||||
sizeof(descForAccessibilityWindowInfo) / sizeof(descForAccessibilityWindowInfo[0]),
|
||||
descForAccessibilityWindowInfo,
|
||||
&NAccessibilityWindowInfo::cons_));
|
||||
}
|
||||
|
||||
napi_value NAccessibilityWindowInfo::JSConstructor(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;
|
||||
}
|
||||
|
||||
napi_value NAccessibilityWindowInfo::GetAnchorElementInfo(napi_env env, napi_callback_info info) {
|
||||
HILOG_DEBUG("GetAnchorElementInfo called");
|
||||
size_t argc = ARGS_SIZE_ONE;
|
||||
napi_value argv[ARGS_SIZE_ONE] = {0};
|
||||
napi_status status;
|
||||
napi_value thisVar;
|
||||
void* data = nullptr;
|
||||
AccessibilityWindowInfo* windowInfo = nullptr;
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
|
||||
HILOG_DEBUG("argc = %{public}d", (int)argc);
|
||||
|
||||
status = napi_unwrap(env, thisVar, (void**)&windowInfo);
|
||||
HILOG_DEBUG("napi_unwrap status: %{public}d", (int)status);
|
||||
if (!windowInfo) {
|
||||
HILOG_DEBUG("windowInfo is null!!");
|
||||
}
|
||||
|
||||
NAccessibilityWindowInfoData *callbackInfo = new NAccessibilityWindowInfoData();
|
||||
callbackInfo->nativeWindowInfo_ = *windowInfo;
|
||||
|
||||
napi_value promise = nullptr;
|
||||
if (argc > 0) {
|
||||
HILOG_ERROR("GetAnchorElementInfo callback mode");
|
||||
napi_create_reference(env, argv[PARAM0], 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_ERROR("GetAnchorElementInfo promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetAnchorElementInfo", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) { // execute async to call c++ function
|
||||
NAccessibilityWindowInfoData *callbackInfo = (NAccessibilityWindowInfoData*)data;
|
||||
AccessibilityWindowInfo windowInfo = callbackInfo->nativeWindowInfo_;
|
||||
callbackInfo->result_ = windowInfo.GetAnchor(callbackInfo->nodeInfo_ );
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) { //execute the complete function
|
||||
HILOG_DEBUG("GetAnchorElementInfo execute back");
|
||||
NAccessibilityWindowInfoData* callbackInfo = (NAccessibilityWindowInfoData*)data;
|
||||
napi_value jsReturnValue = 0;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
// napi_create_object(env, &argv);
|
||||
napi_new_instance(env, NElementInfo::cons_, 0, nullptr, &argv[PARAM1]);
|
||||
ConvertElementInfoToJS(env, argv[PARAM1], callbackInfo->nodeInfo_);
|
||||
|
||||
argv[PARAM0] = GetErrorValue(env, callbackInfo->result_ ? CODE_SUCCESS : CODE_FAILED);
|
||||
if (callbackInfo->callback_) {
|
||||
// Callback mode
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, argv, &jsReturnValue);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
if (callbackInfo->result_) {
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, argv[PARAM1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, argv[PARAM0]);
|
||||
}
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value NAccessibilityWindowInfo::GetRootElementInfo(napi_env env, napi_callback_info info) {
|
||||
HILOG_DEBUG("GetRootElementInfo called");
|
||||
size_t argc = ARGS_SIZE_ONE;
|
||||
napi_value argv[ARGS_SIZE_ONE] = {0};
|
||||
napi_status status;
|
||||
napi_value thisVar;
|
||||
void* data = nullptr;
|
||||
AccessibilityWindowInfo* windowInfo = nullptr;
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
|
||||
HILOG_DEBUG("argc = %{public}d", (int)argc);
|
||||
|
||||
status = napi_unwrap(env, thisVar, (void**)&windowInfo);
|
||||
HILOG_DEBUG("napi_unwrap status: %{public}d", (int)status);
|
||||
if (!windowInfo) {
|
||||
HILOG_DEBUG("windowInfo is null!!");
|
||||
}
|
||||
|
||||
NAccessibilityWindowInfoData *callbackInfo = new NAccessibilityWindowInfoData();
|
||||
callbackInfo->nativeWindowInfo_ = *windowInfo;
|
||||
|
||||
napi_value promise = nullptr;
|
||||
if (argc > 0) {
|
||||
HILOG_ERROR("GetRootElementInfo callback mode");
|
||||
napi_create_reference(env, argv[PARAM0], 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_ERROR("GetRootElementInfo promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetRootElementInfo", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) { // execute async to call c++ function
|
||||
NAccessibilityWindowInfoData *callbackInfo = (NAccessibilityWindowInfoData*)data;
|
||||
AccessibilityWindowInfo windowInfo = callbackInfo->nativeWindowInfo_;
|
||||
callbackInfo->result_ = windowInfo.GetRootAccessibilityInfo(callbackInfo->nodeInfo_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) { //execute the complete function
|
||||
HILOG_DEBUG("GetRootElementInfo execute back");
|
||||
NAccessibilityWindowInfoData* callbackInfo = (NAccessibilityWindowInfoData*)data;
|
||||
napi_value jsReturnValue = 0;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
// napi_create_object(env, &argv);
|
||||
napi_new_instance(env, NElementInfo::cons_, 0, nullptr, &argv[PARAM1]);
|
||||
ConvertElementInfoToJS(env, argv[PARAM1], callbackInfo->nodeInfo_);
|
||||
|
||||
argv[PARAM0] = GetErrorValue(env, callbackInfo->result_ ? CODE_SUCCESS : CODE_FAILED);
|
||||
if (callbackInfo->callback_) {
|
||||
// Callback mode
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, argv, &jsReturnValue);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
if (callbackInfo->result_) {
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, argv[PARAM1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, argv[PARAM0]);
|
||||
}
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value NAccessibilityWindowInfo::GetParent(napi_env env, napi_callback_info info) {
|
||||
HILOG_DEBUG("GetParent called");
|
||||
size_t argc = ARGS_SIZE_ONE;
|
||||
napi_value argv[ARGS_SIZE_ONE] = {0};
|
||||
napi_status status;
|
||||
napi_value thisVar;
|
||||
void* data = nullptr;
|
||||
AccessibilityWindowInfo* windowInfo = nullptr;
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
|
||||
HILOG_DEBUG("argc = %{public}d", (int)argc);
|
||||
|
||||
status = napi_unwrap(env, thisVar, (void**)&windowInfo);
|
||||
HILOG_DEBUG("napi_unwrap status: %{public}d", (int)status);
|
||||
if (!windowInfo) {
|
||||
HILOG_DEBUG("windowInfo is null!!");
|
||||
}
|
||||
|
||||
NAccessibilityWindowInfoData *callbackInfo = new NAccessibilityWindowInfoData();
|
||||
callbackInfo->nativeWindowInfo_ = *windowInfo;
|
||||
|
||||
napi_value promise = nullptr;
|
||||
if (argc > 0) {
|
||||
HILOG_ERROR("GetParent callback mode");
|
||||
napi_create_reference(env, argv[PARAM0], 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_ERROR("GetParent promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetParent", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) { // execute async to call c++ function
|
||||
NAccessibilityWindowInfoData *callbackInfo = (NAccessibilityWindowInfoData*)data;
|
||||
AccessibilityWindowInfo windowInfo = callbackInfo->nativeWindowInfo_;
|
||||
callbackInfo->window_ = windowInfo.GetParent();
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) { //execute the complete function
|
||||
HILOG_DEBUG("GetParent execute back");
|
||||
NAccessibilityWindowInfoData* callbackInfo = (NAccessibilityWindowInfoData*)data;
|
||||
napi_value jsReturnValue = 0;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
napi_new_instance(env, NAccessibilityWindowInfo::cons_, 0, nullptr, &argv[PARAM1]);
|
||||
ConvertAccessibilityWindowInfoToJS(env, argv[PARAM1], callbackInfo->window_);
|
||||
|
||||
if (callbackInfo->callback_) {
|
||||
// Callback mode
|
||||
argv[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, argv, &jsReturnValue);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, argv[PARAM1]);
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value NAccessibilityWindowInfo::GetChild(napi_env env, napi_callback_info info) {
|
||||
HILOG_DEBUG("GetChild called");
|
||||
size_t argc = ARGS_SIZE_TWO;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_status status;
|
||||
napi_value thisVar;
|
||||
void* data = nullptr;
|
||||
AccessibilityWindowInfo* windowInfo = nullptr;
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
|
||||
HILOG_DEBUG("argc = %{public}d", (int)argc);
|
||||
|
||||
status = napi_unwrap(env, thisVar, (void**)&windowInfo);
|
||||
HILOG_DEBUG("napi_unwrap status: %{public}d", (int)status);
|
||||
if (!windowInfo) {
|
||||
HILOG_DEBUG("windowInfo is null!!");
|
||||
}
|
||||
int childIndex;
|
||||
napi_get_value_int32(env, argv[PARAM0], &childIndex);
|
||||
HILOG_INFO("GetChild childIndex = %{public}d", childIndex);
|
||||
|
||||
NAccessibilityWindowInfoData *callbackInfo = new NAccessibilityWindowInfoData();
|
||||
callbackInfo->nativeWindowInfo_ = *windowInfo;
|
||||
callbackInfo->childIndex_ = childIndex;
|
||||
|
||||
napi_value promise = nullptr;
|
||||
if (argc >= ARGS_SIZE_TWO) {
|
||||
HILOG_ERROR("GetChild callback mode");
|
||||
napi_create_reference(env, argv[PARAM1], 1, &callbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
HILOG_ERROR("GetChild promise mode");
|
||||
napi_create_promise(env, &callbackInfo->deferred_, &promise);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetChild", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) { // execute async to call c++ function
|
||||
NAccessibilityWindowInfoData *callbackInfo = (NAccessibilityWindowInfoData*)data;
|
||||
AccessibilityWindowInfo windowInfo = callbackInfo->nativeWindowInfo_;
|
||||
callbackInfo->window_ = windowInfo.GetChild(callbackInfo->childIndex_ );
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) { //execute the complete function
|
||||
HILOG_DEBUG("GetChild execute back");
|
||||
NAccessibilityWindowInfoData* callbackInfo = (NAccessibilityWindowInfoData*)data;
|
||||
napi_value jsReturnValue = 0;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
napi_new_instance(env, NAccessibilityWindowInfo::cons_, 0, nullptr, &argv[PARAM1]);
|
||||
ConvertAccessibilityWindowInfoToJS(env, argv[PARAM1], callbackInfo->window_);
|
||||
|
||||
if (callbackInfo->callback_) {
|
||||
// Callback mode
|
||||
argv[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
|
||||
napi_get_reference_value(env, callbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, argv, &jsReturnValue);
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
napi_resolve_deferred(env, callbackInfo->deferred_, argv[PARAM1]);
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, callbackInfo->work_);
|
||||
delete callbackInfo;
|
||||
},
|
||||
(void*)callbackInfo,
|
||||
&callbackInfo->work_);
|
||||
napi_queue_async_work(env, callbackInfo->work_);
|
||||
|
||||
return promise;
|
||||
}
|
551
interfaces/kits/napi/src/napi_accessible_ability.cpp
Normal file
551
interfaces/kits/napi/src/napi_accessible_ability.cpp
Normal file
@ -0,0 +1,551 @@
|
||||
/*
|
||||
* 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 <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "accessible_ability.h"
|
||||
#include "accessibility_element_info.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "napi_accessibility_info.h"
|
||||
#include "napi_accessible_ability.h"
|
||||
#include "napi_accessible_ability_observer.h"
|
||||
#include "napi_accessibility_def.h"
|
||||
#include "napi_accessibility_utils.h"
|
||||
#include "napi_accessibility_window_info.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::Accessibility;
|
||||
|
||||
napi_value g_accessibleAbility;
|
||||
std::map<std::string, std::shared_ptr<AccessibleAbilityCallbackInfo>> g_JsAACallbacks = {};
|
||||
std::shared_ptr<AccessibleAbilityListener> g_AAObserver = std::make_shared<AccessibleAbilityObserver>();
|
||||
|
||||
void CreateGlobalAccessibleAbilityJSObject(napi_env env) {
|
||||
napi_property_descriptor accessibleAbilityDesc[] = {
|
||||
DECLARE_NAPI_FUNCTION("on", RegisterCallback),
|
||||
DECLARE_NAPI_FUNCTION("connect", ConnectToAAMS),
|
||||
DECLARE_NAPI_FUNCTION("disableAbility", DisableAbility),
|
||||
DECLARE_NAPI_FUNCTION("getWindows", GetWindows),
|
||||
DECLARE_NAPI_FUNCTION("getRootElementInfo", GetRootElementInfo),
|
||||
DECLARE_NAPI_FUNCTION("getFocusElementInfo", GetFocusElementInfo),
|
||||
DECLARE_NAPI_FUNCTION("performCommonAction", PerformCommonAction),
|
||||
};
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env,
|
||||
napi_define_class(env,
|
||||
"AccessibleAbility",
|
||||
NAPI_AUTO_LENGTH,
|
||||
AccessibleAbilityConstructor,
|
||||
nullptr,
|
||||
sizeof(accessibleAbilityDesc) / sizeof(accessibleAbilityDesc[0]),
|
||||
accessibleAbilityDesc,
|
||||
&g_accessibleAbility));
|
||||
}
|
||||
|
||||
napi_value AccessibleAbilityConstructor(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;
|
||||
}
|
||||
|
||||
napi_value GetAccessibleAbility(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("GetAccessibleAbility called");
|
||||
size_t expectedArgsCount = ARGS_SIZE_ONE;
|
||||
size_t argc = expectedArgsCount;
|
||||
napi_value argv = 0;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &argv, nullptr, nullptr));
|
||||
NAPI_ASSERT(env, argc <= expectedArgsCount, "Requires up to 1 argument.");
|
||||
|
||||
AsyncGetAccessibleAbilityCallbackInfo* pCallbackInfo = new AsyncGetAccessibleAbilityCallbackInfo();
|
||||
pCallbackInfo->env_ = env;
|
||||
|
||||
napi_value promise = nullptr;
|
||||
|
||||
if (argc > (expectedArgsCount - CALLBACK_SIZE)) {
|
||||
// Callback mode
|
||||
HILOG_INFO("GetAccessibleAbility callback mode");
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
NAPI_CALL(env, napi_typeof(env, argv, &valueType));
|
||||
NAPI_ASSERT(env, valueType == napi_function, "Wrong argument type. Function expected.");
|
||||
napi_create_reference(env, argv, 1, &pCallbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
// Promise mode
|
||||
HILOG_INFO("GetAccessibleAbility promise mode");
|
||||
napi_create_promise(env, &pCallbackInfo->deferred_, &promise);
|
||||
}
|
||||
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetAccessibleAbility", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) {},
|
||||
[](napi_env env, napi_status status, void* data) {
|
||||
AsyncGetAccessibleAbilityCallbackInfo* pCallbackInfo = (AsyncGetAccessibleAbilityCallbackInfo*)data;
|
||||
napi_value result[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_value callResult = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
napi_new_instance(env, g_accessibleAbility, 0, nullptr, &result[PARAM1]);
|
||||
|
||||
if (pCallbackInfo->callback_) {
|
||||
// Callback mode
|
||||
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
|
||||
napi_get_reference_value(env, pCallbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &callResult);
|
||||
napi_delete_reference(env, pCallbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
napi_resolve_deferred(env, pCallbackInfo->deferred_, result[PARAM1]);
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, pCallbackInfo->asyncWork_);
|
||||
delete pCallbackInfo;
|
||||
},
|
||||
(void*)pCallbackInfo,
|
||||
&pCallbackInfo->asyncWork_);
|
||||
napi_queue_async_work(env, pCallbackInfo->asyncWork_);
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value RegisterCallback(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("RegisterCallback called");
|
||||
size_t expectedArgsCount = ARGS_SIZE_TWO;
|
||||
size_t argc = expectedArgsCount;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
|
||||
NAPI_ASSERT(env, argc == expectedArgsCount, "Requires 2 arguments.");
|
||||
std::string type;
|
||||
ParseString(env, type, argv[PARAM0]);
|
||||
std::shared_ptr<AccessibleAbilityCallbackInfo> pCallbackInfo = std::make_shared<AccessibleAbilityCallbackInfo>();
|
||||
pCallbackInfo->env_ = env;
|
||||
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
napi_typeof(env, argv[PARAM1], &valueType);
|
||||
NAPI_ASSERT(env, valueType == napi_function, "Wrong argument type. Function expected.");
|
||||
NAPI_CALL(env, napi_create_reference(env, argv[PARAM1], 1, &pCallbackInfo->callback_));
|
||||
g_JsAACallbacks[type] = pCallbackInfo;
|
||||
|
||||
napi_value ret = nullptr;
|
||||
napi_get_undefined(env, &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
napi_value DisableAbility(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("DisableAbility called");
|
||||
size_t argc = ARGS_SIZE_ONE;
|
||||
napi_value argv;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &argv, nullptr, nullptr));
|
||||
NAPI_ASSERT(env, argc <= ARGS_SIZE_ONE, "Requires up to 1 argument.");
|
||||
|
||||
AsyncDisableAbilityCallbackInfo* pCallbackInfo = new AsyncDisableAbilityCallbackInfo();
|
||||
pCallbackInfo->env_ = env;
|
||||
|
||||
napi_value promise = nullptr;
|
||||
|
||||
if (argc == ARGS_SIZE_ONE) {
|
||||
// Callback mode
|
||||
HILOG_INFO("DisableAbility callback mode");
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
NAPI_CALL(env, napi_typeof(env, argv, &valueType));
|
||||
NAPI_ASSERT(env, valueType == napi_function, "Wrong argument type. Function expected.");
|
||||
napi_create_reference(env, argv, 1, &pCallbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
// Promise mode
|
||||
HILOG_INFO("DisableAbility promise mode");
|
||||
napi_create_promise(env, &pCallbackInfo->deferred_, &promise);
|
||||
}
|
||||
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "DisableAbility", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) {
|
||||
HILOG_DEBUG("DisableAbility execute");
|
||||
AccessibleAbility::GetInstance().DisableAbility();
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) {
|
||||
HILOG_DEBUG("DisableAbility execute back");
|
||||
AsyncDisableAbilityCallbackInfo* pCallbackInfo = (AsyncDisableAbilityCallbackInfo*)data;
|
||||
napi_value jsReturnValue = 0;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
napi_get_undefined(env, &argv[PARAM1]);
|
||||
|
||||
if (pCallbackInfo->callback_) {
|
||||
// Callback mode
|
||||
argv[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
|
||||
napi_get_reference_value(env, pCallbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, argv, &jsReturnValue);
|
||||
napi_delete_reference(env, pCallbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
napi_resolve_deferred(env, pCallbackInfo->deferred_, argv[PARAM1]);
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, pCallbackInfo->asyncWork_);
|
||||
delete pCallbackInfo;
|
||||
},
|
||||
(void*)pCallbackInfo,
|
||||
&pCallbackInfo->asyncWork_);
|
||||
|
||||
napi_queue_async_work(env, pCallbackInfo->asyncWork_);
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value GetWindows(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("GetWindows called");
|
||||
size_t argc = ARGS_SIZE_ONE;
|
||||
napi_value argv;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &argv, nullptr, nullptr));
|
||||
NAPI_ASSERT(env, argc <= ARGS_SIZE_ONE, "Requires up to 1 argument.");
|
||||
|
||||
AsyncGetWindowsCallbackInfo* pCallbackInfo = new AsyncGetWindowsCallbackInfo();
|
||||
pCallbackInfo->env_ = env;
|
||||
|
||||
napi_value promise = nullptr;
|
||||
|
||||
if (argc == ARGS_SIZE_ONE) {
|
||||
// Callback mode
|
||||
HILOG_INFO("GetWindows callback mode");
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
NAPI_CALL(env, napi_typeof(env, argv, &valueType));
|
||||
NAPI_ASSERT(env, valueType == napi_function, "Wrong argument type. Function expected.");
|
||||
napi_create_reference(env, argv, 1, &pCallbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
// Promise mode
|
||||
HILOG_INFO("GetWindows promise mode");
|
||||
napi_create_promise(env, &pCallbackInfo->deferred_, &promise);
|
||||
}
|
||||
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetWindows", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) {
|
||||
HILOG_DEBUG("GetWindows execute");
|
||||
AsyncGetWindowsCallbackInfo* pCallbackInfo = (AsyncGetWindowsCallbackInfo*)data;
|
||||
pCallbackInfo->accessibilityWindows_ = Accessibility::AccessibleAbility::GetInstance().GetWindows();
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) {
|
||||
HILOG_DEBUG("GetWindows execute back");
|
||||
AsyncGetWindowsCallbackInfo* pCallbackInfo = (AsyncGetWindowsCallbackInfo*)data;
|
||||
napi_value result[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_value callResult = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
if (!pCallbackInfo->accessibilityWindows_.empty()) {
|
||||
HILOG_DEBUG("GetWindows accessibilityWindows is not null");
|
||||
napi_create_array(env, &result[PARAM1]);
|
||||
ConvertAccessibilityWindowInfosToJS(env, result[PARAM1], pCallbackInfo->accessibilityWindows_);
|
||||
} else {
|
||||
HILOG_DEBUG("GetWindows accessibilityWindows is null");
|
||||
napi_get_undefined(env, &result[PARAM1]);
|
||||
}
|
||||
|
||||
if (pCallbackInfo->callback_) {
|
||||
// Callback mode
|
||||
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
|
||||
napi_get_reference_value(env, pCallbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &callResult);
|
||||
napi_delete_reference(env, pCallbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
napi_resolve_deferred(env, pCallbackInfo->deferred_, result[PARAM1]);
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, pCallbackInfo->asyncWork_);
|
||||
delete pCallbackInfo;
|
||||
},
|
||||
(void*)pCallbackInfo,
|
||||
&pCallbackInfo->asyncWork_);
|
||||
|
||||
napi_queue_async_work(env, pCallbackInfo->asyncWork_);
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value GetRootElementInfo(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("GetRootElementInfo called");
|
||||
size_t argc = ARGS_SIZE_ONE;
|
||||
napi_value argv;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &argv, nullptr, nullptr));
|
||||
NAPI_ASSERT(env, argc <= ARGS_SIZE_ONE, "Requires up to 1 argument.");
|
||||
|
||||
AsyncGetRootElementInfoCallbackInfo* pCallbackInfo = new AsyncGetRootElementInfoCallbackInfo();
|
||||
pCallbackInfo->env_ = env;
|
||||
|
||||
napi_value promise = nullptr;
|
||||
|
||||
if (argc == ARGS_SIZE_ONE) {
|
||||
// Callback mode
|
||||
HILOG_INFO("GetRootElementInfo callback mode");
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
NAPI_CALL(env, napi_typeof(env, argv, &valueType));
|
||||
NAPI_ASSERT(env, valueType == napi_function, "Wrong argument type. Function expected.");
|
||||
napi_create_reference(env, argv, 1, &pCallbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
// Promise mode
|
||||
HILOG_INFO("GetRootElementInfo promise mode");
|
||||
napi_create_promise(env, &pCallbackInfo->deferred_, &promise);
|
||||
}
|
||||
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetRootElementInfo", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) {
|
||||
HILOG_DEBUG("GetRootElementInfo execute");
|
||||
AsyncGetRootElementInfoCallbackInfo* pCallbackInfo = (AsyncGetRootElementInfoCallbackInfo*)data;
|
||||
pCallbackInfo->result_ = AccessibleAbility::GetInstance().GetRootElementInfo(pCallbackInfo->elementInfo_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) {
|
||||
HILOG_DEBUG("GetRootElementInfo execute back");
|
||||
AsyncGetRootElementInfoCallbackInfo* pCallbackInfo = (AsyncGetRootElementInfoCallbackInfo*)data;
|
||||
napi_value jsReturnValue = 0;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
if (pCallbackInfo->elementInfo_.has_value()) {
|
||||
HILOG_DEBUG("GetRootElementInfo elementInfo is not null");
|
||||
napi_new_instance(env, NElementInfo::cons_, 0, nullptr, &argv[PARAM1]);
|
||||
ConvertElementInfoToJS(env, argv[PARAM1], *(pCallbackInfo->elementInfo_));
|
||||
} else {
|
||||
HILOG_DEBUG("GetRootElementInfo elementInfo is null");
|
||||
napi_get_undefined(env, &argv[PARAM1]);
|
||||
}
|
||||
|
||||
argv[PARAM0] = GetErrorValue(env, pCallbackInfo->result_ ? CODE_SUCCESS : CODE_FAILED);
|
||||
if (pCallbackInfo->callback_) {
|
||||
// Callback mode
|
||||
napi_get_reference_value(env, pCallbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, argv, &jsReturnValue);
|
||||
napi_delete_reference(env, pCallbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
if (pCallbackInfo->result_) {
|
||||
napi_resolve_deferred(env, pCallbackInfo->deferred_, argv[PARAM1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, pCallbackInfo->deferred_, argv[PARAM0]);
|
||||
}
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, pCallbackInfo->asyncWork_);
|
||||
delete pCallbackInfo;
|
||||
},
|
||||
(void*)pCallbackInfo,
|
||||
&pCallbackInfo->asyncWork_);
|
||||
|
||||
napi_queue_async_work(env, pCallbackInfo->asyncWork_);
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value ConnectToAAMS(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("ConnectToAAMS called");
|
||||
|
||||
AccessibleAbility& aa = AccessibleAbility::GetInstance();
|
||||
aa.RegisterListener(g_AAObserver);
|
||||
aa.ConnectToAAMS();
|
||||
|
||||
napi_value ret = nullptr;
|
||||
napi_get_undefined(env, &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
napi_value GetFocusElementInfo(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("GetFocusElementInfo called");
|
||||
size_t expectedArgsCount = ARGS_SIZE_TWO;
|
||||
size_t argc = expectedArgsCount;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
|
||||
NAPI_ASSERT(env, argc <= expectedArgsCount, "Requires at most 2 arguments.");
|
||||
std::string focusType;
|
||||
ParseString(env, focusType, argv[PARAM0]);
|
||||
HILOG_INFO("GetFocusElementInfo focusType = %{public}s", focusType.c_str());
|
||||
|
||||
AsyncGetFocusElementInfoCallbackInfo* pCallbackInfo = new AsyncGetFocusElementInfoCallbackInfo();
|
||||
pCallbackInfo->env_ = env;
|
||||
pCallbackInfo->focusType_ = focusType;
|
||||
|
||||
napi_value promise = nullptr;
|
||||
|
||||
if (argc > (expectedArgsCount - CALLBACK_SIZE)) {
|
||||
// Callback mode
|
||||
HILOG_INFO("GetFocusElementInfo callback mode");
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valueType));
|
||||
NAPI_ASSERT(env, valueType == napi_function, "Wrong argument type. Function expected.");
|
||||
napi_create_reference(env, argv[PARAM1], 1, &pCallbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
// Promise mode
|
||||
HILOG_INFO("GetFocusElementInfo promise mode");
|
||||
napi_create_promise(env, &pCallbackInfo->deferred_, &promise);
|
||||
}
|
||||
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "GetFocusElementInfo", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) {
|
||||
HILOG_DEBUG("GetFocusElementInfo execute");
|
||||
AsyncGetFocusElementInfoCallbackInfo* pCallbackInfo = (AsyncGetFocusElementInfoCallbackInfo*)data;
|
||||
uint32_t focus = 0;
|
||||
if (std::strcmp(pCallbackInfo->focusType_.c_str(), "accessibility") == 0) {
|
||||
focus = FOCUS_TYPE_ACCESSIBILITY;
|
||||
} else if (std::strcmp(pCallbackInfo->focusType_.c_str(), "normal") == 0) {
|
||||
focus = FOCUS_TYPE_INPUT;
|
||||
} else {
|
||||
focus = FOCUS_TYPE_INVALID;
|
||||
}
|
||||
pCallbackInfo->result_ = AccessibleAbility::GetInstance().GetFocusElementInfo(
|
||||
focus, pCallbackInfo->elementInfo_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) {
|
||||
HILOG_DEBUG("GetFocusElementInfo execute back");
|
||||
AsyncGetFocusElementInfoCallbackInfo* pCallbackInfo = (AsyncGetFocusElementInfoCallbackInfo*)data;
|
||||
napi_value result[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_value callResult = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
|
||||
if (pCallbackInfo->elementInfo_.has_value()) {
|
||||
HILOG_DEBUG("GetFocusElementInfo elementInfo is not null");
|
||||
napi_new_instance(env, NElementInfo::cons_, 0, nullptr, &result[PARAM1]);
|
||||
ConvertElementInfoToJS(env, result[PARAM1], *(pCallbackInfo->elementInfo_));
|
||||
} else {
|
||||
HILOG_DEBUG("GetFocusElementInfo elementInfo is null");
|
||||
napi_get_undefined(env, &result[PARAM1]);
|
||||
}
|
||||
|
||||
result[PARAM0] = GetErrorValue(env, pCallbackInfo->result_ ? CODE_SUCCESS : CODE_FAILED);
|
||||
if (pCallbackInfo->callback_) {
|
||||
// Callback mode
|
||||
napi_get_reference_value(env, pCallbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &callResult);
|
||||
napi_delete_reference(env, pCallbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
if (pCallbackInfo->result_) {
|
||||
napi_resolve_deferred(env, pCallbackInfo->deferred_, result[PARAM1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, pCallbackInfo->deferred_, result[PARAM0]);
|
||||
}
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, pCallbackInfo->asyncWork_);
|
||||
delete pCallbackInfo;
|
||||
},
|
||||
(void*)pCallbackInfo,
|
||||
&pCallbackInfo->asyncWork_);
|
||||
|
||||
napi_queue_async_work(env, pCallbackInfo->asyncWork_);
|
||||
return promise;
|
||||
}
|
||||
|
||||
napi_value PerformCommonAction(napi_env env, napi_callback_info info) {
|
||||
HILOG_INFO("PerformCommonAction called");
|
||||
size_t expectedArgsCount = ARGS_SIZE_TWO;
|
||||
size_t argc = expectedArgsCount;
|
||||
napi_value argv[ARGS_SIZE_TWO] = {0};
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
|
||||
NAPI_ASSERT(env, argc <= expectedArgsCount, "Requires at most 2 arguments.");
|
||||
std::string action;
|
||||
ParseString(env, action, argv[PARAM0]);
|
||||
HILOG_INFO("PerformCommonAction action = %{public}s", action.c_str());
|
||||
|
||||
AsyncPerformCommonActionCallbackInfo* pCallbackInfo = new AsyncPerformCommonActionCallbackInfo();
|
||||
pCallbackInfo->env_ = env;
|
||||
pCallbackInfo->action_ = ConvertStringToGlobalAction(action);
|
||||
|
||||
napi_value promise = nullptr;
|
||||
|
||||
if (argc > (expectedArgsCount - CALLBACK_SIZE)) {
|
||||
// Callback mode
|
||||
HILOG_INFO("PerformCommonAction callback mode");
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valueType));
|
||||
NAPI_ASSERT(env, valueType == napi_function, "Wrong argument type. Function expected.");
|
||||
napi_create_reference(env, argv[PARAM1], 1, &pCallbackInfo->callback_);
|
||||
napi_get_undefined(env, &promise);
|
||||
} else {
|
||||
// Promise mode
|
||||
HILOG_INFO("PerformCommonAction promise mode");
|
||||
napi_create_promise(env, &pCallbackInfo->deferred_, &promise);
|
||||
}
|
||||
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "PerformCommonAction", NAPI_AUTO_LENGTH, &resource);
|
||||
|
||||
napi_create_async_work(
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) {
|
||||
HILOG_DEBUG("PerformCommonAction execute");
|
||||
AsyncPerformCommonActionCallbackInfo* pCallbackInfo = (AsyncPerformCommonActionCallbackInfo*)data;
|
||||
pCallbackInfo->performActionResult_ = AccessibleAbility::GetInstance().PerformCommonAction(pCallbackInfo->action_);
|
||||
HILOG_DEBUG("PerformCommonAction result is %{public}d!", pCallbackInfo->performActionResult_);
|
||||
},
|
||||
[](napi_env env, napi_status status, void* data) {
|
||||
HILOG_DEBUG("PerformCommonAction execute back");
|
||||
AsyncPerformCommonActionCallbackInfo* pCallbackInfo = (AsyncPerformCommonActionCallbackInfo*)data;
|
||||
napi_value result[ARGS_SIZE_TWO] = {0};
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_value callResult = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
napi_get_boolean(env, pCallbackInfo->performActionResult_, &result[PARAM1]);
|
||||
HILOG_DEBUG("PerformCommonAction result is %{public}d!", pCallbackInfo->performActionResult_);
|
||||
|
||||
if (pCallbackInfo->callback_) {
|
||||
// Callback mode
|
||||
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
|
||||
napi_get_reference_value(env, pCallbackInfo->callback_, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &callResult);
|
||||
napi_delete_reference(env, pCallbackInfo->callback_);
|
||||
} else {
|
||||
// Promise mode
|
||||
napi_resolve_deferred(env, pCallbackInfo->deferred_, result[PARAM1]);
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, pCallbackInfo->asyncWork_);
|
||||
delete pCallbackInfo;
|
||||
},
|
||||
(void*)pCallbackInfo,
|
||||
&pCallbackInfo->asyncWork_);
|
||||
|
||||
napi_queue_async_work(env, pCallbackInfo->asyncWork_);
|
||||
return promise;
|
||||
}
|
110
interfaces/kits/napi/src/napi_accessible_ability_observer.cpp
Normal file
110
interfaces/kits/napi/src/napi_accessible_ability_observer.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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 <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
#include "napi_accessible_ability_observer.h"
|
||||
#include "napi_accessible_ability.h"
|
||||
#include "napi_accessibility_event_info.h"
|
||||
#include "napi_accessibility_utils.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::Accessibility;
|
||||
|
||||
extern std::map<std::string, std::shared_ptr<AccessibleAbilityCallbackInfo>> g_JsAACallbacks;
|
||||
|
||||
void AccessibleAbilityObserver::OnAccessibilityEvent(const AccessibilityEventInfo& eventInfo) {
|
||||
HILOG_INFO("NAPI OnAccessibilityEvent called");
|
||||
if (!g_JsAACallbacks[STR_A11Y_OBSERVER_ACCESSIBILITY_EVENT]) {
|
||||
HILOG_WARN("This callback is not registered by ability.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<AccessibleAbilityCallbackInfo> callbackInfo =
|
||||
g_JsAACallbacks[STR_A11Y_OBSERVER_ACCESSIBILITY_EVENT];
|
||||
napi_value result = 0;
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_value argv = 0;
|
||||
napi_get_undefined(callbackInfo->env_, &undefined);
|
||||
napi_new_instance(callbackInfo->env_, NAccessibilityEventInfo::cons_, 0, nullptr, &argv);
|
||||
ConvertAccessibilityEventInfoToJS(callbackInfo->env_, argv, eventInfo);
|
||||
napi_get_reference_value(callbackInfo->env_, callbackInfo->callback_, &callback);
|
||||
napi_call_function(callbackInfo->env_, undefined, callback, ARGS_SIZE_ONE, &argv, &result);
|
||||
}
|
||||
|
||||
void AccessibleAbilityObserver::OnInterrupt() {
|
||||
HILOG_INFO("NAPI OnInterrupt called");
|
||||
if (!g_JsAACallbacks[STR_A11Y_OBSERVER_INTERRUPT]) {
|
||||
HILOG_WARN("This callback is not registered by ability.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<AccessibleAbilityCallbackInfo> callbackInfo = g_JsAACallbacks[STR_A11Y_OBSERVER_INTERRUPT];
|
||||
napi_value result = 0;
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(callbackInfo->env_, &undefined);
|
||||
napi_get_reference_value(callbackInfo->env_, callbackInfo->callback_, &callback);
|
||||
napi_call_function(callbackInfo->env_, undefined, callback, 0, nullptr, &result);
|
||||
}
|
||||
|
||||
void AccessibleAbilityObserver::OnAbilityConnected() {
|
||||
HILOG_INFO("NAPI OnAbilityConnected called");
|
||||
if (!g_JsAACallbacks[STR_A11Y_OBSERVER_ABILITY_CONNECTED]) {
|
||||
HILOG_WARN("This callback is not registered by ability.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<AccessibleAbilityCallbackInfo> callbackInfo = g_JsAACallbacks[STR_A11Y_OBSERVER_ABILITY_CONNECTED];
|
||||
napi_value result = 0;
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(callbackInfo->env_, &undefined);
|
||||
napi_get_reference_value(callbackInfo->env_, callbackInfo->callback_, &callback);
|
||||
napi_call_function(callbackInfo->env_, undefined, callback, 0, nullptr, &result);
|
||||
}
|
||||
|
||||
void AccessibleAbilityObserver::OnGesture(uint32_t gestureId) {
|
||||
HILOG_INFO("NAPI OnGesture called");
|
||||
if (!g_JsAACallbacks[STR_A11Y_OBSERVER_GESTURE]) {
|
||||
HILOG_WARN("This callback is not registered by ability.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<AccessibleAbilityCallbackInfo> callbackInfo = g_JsAACallbacks[STR_A11Y_OBSERVER_GESTURE];
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_value result = 0;
|
||||
napi_value callResult = 0;
|
||||
napi_get_undefined(callbackInfo->env_, &undefined);
|
||||
napi_create_uint32(callbackInfo->env_, gestureId, &result);
|
||||
napi_get_reference_value(callbackInfo->env_, callbackInfo->callback_, &callback);
|
||||
napi_call_function(callbackInfo->env_, undefined, callback, ARGS_SIZE_ONE, &result, &callResult);
|
||||
}
|
||||
|
||||
bool AccessibleAbilityObserver::OnKeyPressEvent(const OHOS::MMI::KeyEvent& keyEvent) {
|
||||
HILOG_INFO("NAPI OnKeyPressEvent called");
|
||||
if (!g_JsAACallbacks[STR_A11Y_OBSERVER_KEY_PRESS]) {
|
||||
HILOG_WARN("This callback is not registered by ability.");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user