放大手势新增触发手势

Signed-off-by: zhaoyixin1998 <zhaoyixin5@huawei.com>
This commit is contained in:
zhaoyixin1998
2026-04-10 14:26:21 +08:00
parent b9093ede44
commit 0e609b3664
30 changed files with 2372 additions and 858 deletions
@@ -91,6 +91,8 @@ public:
void StartMagnificationInteract(uint32_t mode);
void EnableGesture(uint32_t mode);
void DisableGesture(uint32_t mode);
void SetMagnificationMode(uint32_t mode);
void SetMagnificationTriggerMethod(int32_t screenMagnificationTriggerMethod);
void InitInputManagerHandler();
void SetServiceOnKeyEventResult(int32_t connectionId, bool isHandled, uint32_t sequenceNum);
@@ -112,8 +114,7 @@ private:
void UpdateInterceptor();
void DestroyInterceptor();
void CreateMagnificationGesture(sptr<EventTransmission> &header, sptr<EventTransmission> &current);
void CreatZoomGesture();
void CreatWindowMagnificationGesture();
void CreateZoomGesture();
void ClearMagnificationGesture();
sptr<EventTransmission> pointerEventTransmitters_ = nullptr;
@@ -129,7 +130,6 @@ private:
ffrt::mutex eventHandlerMutex_;
sptr<AccessibilityZoomGesture> zoomGesture_ = nullptr;
sptr<WindowMagnificationGesture> windowMagnificationGesture_ = nullptr;
bool needInteractMagnification_ = false;
sptr<KeyEventFilter> keyEventFilter_ = nullptr;
};
@@ -23,6 +23,7 @@
#include "accessibility_caption.h"
#include "accessibility_datashare_helper.h"
#include "magnification_def.h"
namespace OHOS {
namespace Accessibility {
@@ -49,6 +50,7 @@ public:
RetError SetScreenMagnificationType(const uint32_t type);
RetError SetScreenMagnificationMode(const uint32_t mode);
RetError SetScreenMagnificationScale(const float scale);
RetError SetScreenMagnificationTriggerMethod(const int32_t triggerMethod);
RetError SetShortKeyState(const bool state);
RetError SetShortKeyOnLockScreenState(const bool state);
RetError SetShortKeyTimeout(const int32_t time);
@@ -105,6 +107,7 @@ public:
uint32_t GetScreenMagnificationType() const;
uint32_t GetScreenMagnificationMode() const;
float GetScreenMagnificationScale() const;
int32_t GetScreenMagnificationTriggerMethod() const;
bool GetFlashReminderSwitch() const;
bool GetSeniorModeState() const;
@@ -158,6 +161,7 @@ private:
std::atomic<uint32_t> screenMagnificationType_ = 0;
std::atomic<uint32_t> screenMagnificationMode_ = 0;
std::atomic<float> screenMagnificationScale_ = 2.0f;
std::atomic<int32_t> screenMagnificationTriggerMethod_ = THREE_FINGER_DOUBLE_TAP_MODE;
std::atomic<bool> isCaptionState_ = false;
AccessibilityConfig::CaptionProperty captionProperty_;
std::atomic<bool> isMouseKeyState_ = false;
@@ -21,20 +21,25 @@
#include "pointer_event.h"
#include "dm_common.h"
#include "full_screen_magnification_manager.h"
#include "window_magnification_manager.h"
#include "magnification_menu_manager.h"
#include "magnification_def.h"
#include <unordered_map>
#include <functional>
namespace OHOS {
namespace Accessibility {
enum ACCESSIBILITY_ZOOM_STATE {
READY_STATE,
ZOOMIN_STATE,
SLIDING_STATE,
MENU_SLIDING_STATE,
DRAGGING_STATE
};
#define BIND(func) [this](MMI::PointerEvent& event) { (func(event)); }
enum ACCESSIBILITY_ZOOM_GESTURE_MSG : uint32_t {
MULTI_TAP_MSG,
LONG_PRESS_MSG,
WAIT_ANOTHER_FINGER_DOWN_MSG,
HOLDING_MSG,
TWO_FINGER_SLIDING_MSG,
HOT_AREA_SLIDING_MSG,
MENU_SLIDING_MSG,
};
struct ZOOM_FOCUS_COORDINATE {
@@ -45,6 +50,7 @@ struct ZOOM_FOCUS_COORDINATE {
class AccessibilityZoomGesture : public EventTransmission {
public:
AccessibilityZoomGesture(std::shared_ptr<FullScreenMagnificationManager> fullScreenManager,
std::shared_ptr<WindowMagnificationManager> windowMagnificationManager,
std::shared_ptr<MagnificationMenuManager> menuManager);
~AccessibilityZoomGesture() = default;
@@ -54,10 +60,12 @@ public:
void ShieldZoomGesture(bool state);
void GetWindowParam(bool needRefresh = false);
void StartMagnificationInteract();
void SetGestureMode(int32_t mode);
void SetMagnificationMode(uint32_t mode);
void DisableGesture();
inline ACCESSIBILITY_ZOOM_STATE GetZoomState()
inline int32_t GetZoomState()
{
return state_;
return zoomState_;
}
private:
@@ -72,77 +80,150 @@ private:
AccessibilityZoomGesture &zoomGesture_;
};
void TransferState(ACCESSIBILITY_ZOOM_STATE state);
void TransferState(int32_t state);
void CacheEvents(MMI::PointerEvent &event);
void SendCacheEventsToNext();
void SendEventToMultimodal(MMI::PointerEvent event);
void ClearCacheEventsAndMsg();
void RecognizeInReadyState(MMI::PointerEvent &event);
void InitGestureFuncMap();
void InitSingleFingerTripleTapFuncMap();
void InitThreeFingerDoubleTapFuncMap();
void OnPointerEventExecute(MMI::PointerEvent &event);
void RecognizeInZoomStateDownEvent(MMI::PointerEvent &event);
void RecognizeInZoomStateMoveEvent(MMI::PointerEvent &event);
void RecognizeInZoomState(MMI::PointerEvent &event);
void RecognizeInSlidingState(MMI::PointerEvent &event);
void RecognizeInMenuSlidingState(MMI::PointerEvent &event);
void RecognizeInDraggingState(MMI::PointerEvent &event);
void RecognizeScroll(MMI::PointerEvent &event, ZOOM_FOCUS_COORDINATE &coordinate);
void RecognizeScale(MMI::PointerEvent &event, ZOOM_FOCUS_COORDINATE &coordinate);
void RecognizeScroll(ZOOM_FOCUS_COORDINATE &coordinate);
bool RecognizeScale(MMI::PointerEvent &event);
void CalcFocusCoordinate(MMI::PointerEvent &event, ZOOM_FOCUS_COORDINATE &coordinate);
float CalcScaleSpan(MMI::PointerEvent &event, ZOOM_FOCUS_COORDINATE coordinate);
bool IsTapOnInputMethod(MMI::PointerEvent &event);
bool IsDownValid();
bool IsUpValid();
bool IsMoveValid();
bool IsDownValid(std::shared_ptr<MMI::PointerEvent> curEvent, std::shared_ptr<MMI::PointerEvent> lastEvent);
bool IsMoveValid(std::shared_ptr<MMI::PointerEvent> curEvent, std::shared_ptr<MMI::PointerEvent> lastEvent);
bool IsLongPress();
bool IsKnuckles(MMI::PointerEvent &event);
bool IsTripleTaps();
void OnTripleTap(MMI::PointerEvent &event);
int64_t CalcIntervalTime(std::shared_ptr<MMI::PointerEvent> firstEvent,
std::shared_ptr<MMI::PointerEvent> secondEvent);
float CalcSeparationDistance(std::shared_ptr<MMI::PointerEvent> firstEvent,
std::shared_ptr<MMI::PointerEvent> secondEvent);
bool IsThreeFingerMultiTap(MMI::PointerEvent &event);
float CalcSeparationDistance(MMI::PointerEvent &event);
float CalcSeparationDistance(MMI::PointerEvent &firstEvent, MMI::PointerEvent &secondEvent);
void OnZoom(int32_t centerX, int32_t centerY, bool showMenu);
void OffZoom();
void OnScroll(float offsetX, float offsetY);
void OnScale(float scaleSpan);
void Clear();
void OnDrag();
bool startScaling_ = false;
bool isLongPress_ = false;
bool isMoveValid_ = true;
float preSpan_ = 0.0f;
float lastSpan_ = 0.0f;
float screenSpan_ = 0.0f;
float lastScrollFocusX_ = 0.0f;
float lastScrollFocusY_ = 0.0f;
void DoNothingHandler(MMI::PointerEvent &event);
void HandleSTReadyInitStateDown(MMI::PointerEvent &event);
void HandleSTReadyStateUp(MMI::PointerEvent &event);
void HandleSTReadyStateMove(MMI::PointerEvent &event);
void HandleSTReadyOneFingerTapStateDown(MMI::PointerEvent &event);
void HandleSTZoomInitStateDown(MMI::PointerEvent &event);
void HandleSTZoomOneFingerDownStateDown(MMI::PointerEvent &event);
void HandleSTZoomOneFingerDownStateUp(MMI::PointerEvent &event);
void HandleSTZoomOneFingerDownStateMove(MMI::PointerEvent &event);
void HandleSTZoomTwoFingerDownStateMove(MMI::PointerEvent &event);
void HandleSTZoomOneFingerTapStateDown(MMI::PointerEvent &event);
void HandleZoomSlidingStateDown(MMI::PointerEvent &event);
void HandleZoomSlidingStateMove(MMI::PointerEvent &event);
void HandleZoomSlidingStateUp(MMI::PointerEvent &event);
void HandleTDReadyInitStateDown(MMI::PointerEvent &event);
void HandleTDReadyOneFingerDownStateDown(MMI::PointerEvent &event);
void HandleTDReadyOneFingerDownStateMove(MMI::PointerEvent &event);
void HandleTDReadyTwoFingersDownStateDown(MMI::PointerEvent &event);
void HandleTDReadyTwoFingersDownStateMove(MMI::PointerEvent &event);
void HandleTDReadyThreeFingersDownStateUp(MMI::PointerEvent &event);
void HandleTDReadyThreeFingersDownStateMove(MMI::PointerEvent &event);
void HandleTDReadyThreeFingersTapStateDown(MMI::PointerEvent &event);
void HandleTDReadyThreeFingersTapStateMove(MMI::PointerEvent &event);
void HandleTDReadyThreeFingersContinueDownStateDown(MMI::PointerEvent &event);
void HandleTDReadyThreeFingersContinueDownStateUp(MMI::PointerEvent &event);
void HandleTDReadyThreeFingersContinueDownStateMove(MMI::PointerEvent &event);
void HandleHoldStateDown(MMI::PointerEvent &event);
void HandleHoldStateUp(MMI::PointerEvent &event);
void HandleHoldStateMove(MMI::PointerEvent &event);
void HandleMenuSlidingStateMove(MMI::PointerEvent &event);
void HandleMenuSlidingStateUp(MMI::PointerEvent &event);
void HandleHotAreaSlidingStateMove(MMI::PointerEvent &event);
void HandleHotAreaSlidingStateUp(MMI::PointerEvent &event);
void HandleTDZoomInitStateDown(MMI::PointerEvent &event);
void HandleTDZoomOneFingerDownStateDown(MMI::PointerEvent &event);
void HandleTDZoomOneFingerDownStateMove(MMI::PointerEvent &event);
void HandleTDZoomOneFingerDownStateUp(MMI::PointerEvent &event);
void HandleTDZoomTwoFingersDownStateDown(MMI::PointerEvent &event);
void HandleTDZoomTwoFingersDownStateMove(MMI::PointerEvent &event);
void HandleTDZoomThreeFingersDownStateUp(MMI::PointerEvent &event);
void HandleTDZoomThreeFingersDownStateMove(MMI::PointerEvent &event);
void HandleTDZoomThreeFingersTapStateDown(MMI::PointerEvent &event);
void HandleTDZoomThreeFingersTapStateMove(MMI::PointerEvent &event);
void HandleTDZoomThreeFingersContinueDownStateUp(MMI::PointerEvent &event);
void HandleTDZoomThreeFingersContinueDownStateMove(MMI::PointerEvent &event);
float tapDistance_ = 0.0f;
float multiTapDistance_ = 0.0f;
float scale_ = DEFAULT_SCALE;
bool isScale_ = false;
float baseDistance_ = 0.0f;
float lastDistance_ = 0.0f;
uint64_t screenId_ = -1;
uint32_t screenWidth_ = 0;
uint32_t screenHeight_ = 0;
int32_t centerX_ = 0;
int32_t centerY_ = 0;
int32_t downPid_ = -1;
ACCESSIBILITY_ZOOM_STATE state_ = READY_STATE;
uint32_t gestureType_ = 0;
int32_t zoomState_ = READY;
int32_t zoomGestureState_ = INIT;
int32_t gestureMode_ = THREE_FINGER_DOUBLE_TAP_MODE;
uint32_t magnificationMode_ = FULL_SCREEN_MAGNIFICATION;
bool isTapOnMenu_ = false;
bool isTapOnWindowHotArea_ = false;
bool isTapOnWindow_ = false;
bool hasScaled_ = false;
OHOS::Rosen::DisplayOrientation orientation_ =
OHOS::Rosen::DisplayOrientation::UNKNOWN;
std::shared_ptr<MMI::PointerEvent> preLastDownEvent_ = nullptr;
ZOOM_FOCUS_COORDINATE lastCenter = {0.0f, 0.0f};
std::shared_ptr<MMI::PointerEvent> lastDownEvent_ = nullptr;
std::shared_ptr<MMI::PointerEvent> preLastUpEvent_ = nullptr;
std::shared_ptr<MMI::PointerEvent> lastUpEvent_ = nullptr;
std::shared_ptr<MMI::PointerEvent> currentMoveEvent_ = nullptr;
std::shared_ptr<MMI::PointerEvent> longPressDownEvent_ = nullptr;
std::shared_ptr<MMI::PointerEvent> lastSlidingEvent_ = nullptr;
std::shared_ptr<MMI::PointerEvent> lastTripleTapEvents_[3] = {nullptr, nullptr, nullptr};
std::shared_ptr<ZoomGestureEventHandler> zoomGestureEventHandler_ = nullptr;
std::vector<std::shared_ptr<MMI::PointerEvent>> cacheEvents_;
std::shared_ptr<FullScreenMagnificationManager> fullScreenManager_ = nullptr;
std::shared_ptr<WindowMagnificationManager> windowMagnificationManager_ = nullptr;
std::shared_ptr<MagnificationMenuManager> menuManager_ = nullptr;
std::atomic<bool> shieldZoomGestureFlag_ = false;
bool isTapOnMenu_ = false;
uint32_t gestureType_ = 0;
bool isTripleDown_ = false;
int32_t singleFingerTapCount_ = 0;
static constexpr int32_t POINTER_ID_0 = 0;
static constexpr int32_t POINTER_ID_1 = 1;
static constexpr int32_t POINTER_ID_2 = 2;
static constexpr int32_t POINTER_COUNT_1 = 1;
static constexpr int32_t POINTER_COUNT_2 = 2;
static constexpr int32_t POINTER_COUNT_3 = 3;
static constexpr int32_t READY = 0;
static constexpr int32_t ZOOM = 1;
static constexpr int32_t PASSING_THROUGH = -2;
static constexpr int32_t INVALID = -1;
static constexpr int32_t INIT = 0;
static constexpr int32_t ONE_FINGER_DOWN = 1;
static constexpr int32_t ONE_FINGER_TAP = 2;
static constexpr int32_t ONE_FINGER_TAP_THEN_DOWN = 3;
static constexpr int32_t HOLD = 4;
static constexpr int32_t TWO_FINGER_DOWN = 5;
static constexpr int32_t THREE_FINGER_DOWN = 6;
static constexpr int32_t THREE_FINGER_TAP = 7;
static constexpr int32_t THREE_FINGER_TAP_THEN_DOWN = 8;
static constexpr int32_t SLIDING = 9;
static constexpr int32_t HOT_AREA_SLIDING = 10;
static constexpr int32_t MENU_SLIDING = 11;
static constexpr int32_t GESTURE_MODE_COUNT = 2;
static constexpr int32_t MAGNIFICATION_STATE_COUNT = 2;
static constexpr int32_t GESTURE_STATE_COUNT = 12;
static constexpr int32_t POINTER_ACTION_MAX = 5;
using GestureEventFunc = std::function<void(MMI::PointerEvent&)>;
GestureEventFunc handlerFuncMap_
[GESTURE_MODE_COUNT][MAGNIFICATION_STATE_COUNT][GESTURE_STATE_COUNT][POINTER_ACTION_MAX] = {};
};
} // namespace Accessibility
} // namespace OHOS
@@ -277,6 +277,7 @@ public:
bool GetMagnificationState();
uint32_t GetMagnificationType();
uint32_t GetMagnificationMode();
int32_t GetMagnificationTriggerMethod();
void SetMagnificationMode(int32_t mode);
float GetMagnificationScale();
void SetMagnificationScale(float scale);
@@ -368,6 +369,8 @@ private:
void RegisterScreenMagnificationState();
void OnScreenMagnificationTypeChanged();
void SetConfigScreenMagnificationScale(float scale);
void OnScreenMagnificationTriggerMethodChanged();
void SetConfigScreenMagnificationTriggerMethod(int32_t triggerMethod);
void OnScreenMagnificationScaleChanged();
void RegisterScreenMagnificationType();
void OnFlashReminderSwitchChanged();
@@ -53,6 +53,7 @@ enum class ExtMethod : int32_t {
GET_CLICK_POSITION,
FOLLOW_FOCUSE_ELEMENT,
ON_SCREEN_MAGNIFICATION_TYPE_CHANGED,
ON_SCREEN_MAGNIFICATION_TRIGGER_METHOD_CHANGE,
ON_SCREEN_MAGNIFICATION_STATE_CHANGED,
OFF_ZOOM_GESTURE,
SET_MAGNIFICATION_STATE
@@ -83,6 +84,7 @@ public:
void TransitionAnimationsCancelNotification();
int32_t TransitionAnimationsRegisterTimers(uint64_t beginTime);
void TransitionAnimationsDestroyTimers();
void OnScreenMagnificationTriggerMethodChanged(int32_t screenMagnificationTriggerMethod);
void OnScreenMagnificationTypeChanged(uint32_t screenMagnificationType);
void OnScreenMagnificationStateChanged();
void UnregisterDisplayListener();
@@ -103,6 +105,7 @@ public:
bool SetSendPointerEventForHoverCallback();
bool SetGetDelayTimeCallback();
bool SetGetMagnificationStateCallback();
bool ExtendGetMagnificationTriggerMethodCallback();
bool ExtendGetMagnificationModeCallback();
bool ExtendGetMagnificationScaleCallback();
bool ExtendUpdateInputFilterCallback();
@@ -63,6 +63,8 @@ constexpr uint32_t WINDOW_MAGNIFICATION = 2;
constexpr uint32_t SWITCH_MAGNIFICATION = 3;
constexpr uint32_t INPUT_METHOD_WINDOW_TYPE = 2105;
constexpr uint32_t ORANGE_COLOR = 0xFFFFA500;
constexpr int32_t SINGLE_FINGER_TRIPLE_TAP_MODE = 0;
constexpr int32_t THREE_FINGER_DOUBLE_TAP_MODE = 1;
constexpr uint32_t INVALID_GESTURE_TYPE = 0;
constexpr uint32_t LEFT_BACK_GESTURE = 1; // Swipe from the left side of the screen inward
@@ -91,8 +91,6 @@ namespace {
// Feature flag for window magnification.
static constexpr uint32_t FEATURE_WINDOW_MAGNIFICATION = 0x00000100;
static constexpr uint32_t WINDOW_MAGNIFICATION = 2;
} // namespace
AccessibilityAccountData::AccessibilityAccountData(int32_t accountId)
@@ -28,7 +28,6 @@ namespace OHOS {
namespace Accessibility {
namespace {
constexpr int32_t SINGLE_TREE_ID = 0;
constexpr int32_t DIVISOR_TWO = 2;
constexpr int64_t ELEMENT_ID_INVALID = -1;
constexpr int32_t WINDOW_ID_INVALID = -1;
constexpr uint32_t TIME_OUT_OPERATOR = 5000;
@@ -41,6 +41,7 @@ namespace {
const char* SCREEN_MAGNIFICATION_TYPE = "accessibility_magnification_capability";
const char* SCREEN_MAGNIFICATION_MODE = "accessibility_magnification_mode";
const char* SCREEN_MAGNIFICATION_SCALE = "accessibility_display_magnification_scale";
const char* SCREEN_MAGNIFICATION_TRIGGER_METHOD = "accessibility_display_magnification_trigger_method";
const char* MOUSEKEY = "mousekey";
const char* HIGH_CONTRAST_TEXT_KEY = "high_text_contrast_enabled";
const char* DALTONIZATION_STATE = "accessibility_display_daltonizer_enabled";
@@ -201,13 +202,11 @@ RetError AccessibilitySettingsConfig::SetScreenMagnificationState(const bool sta
{
HILOG_DEBUG("state = [%{public}s]", state ? "True" : "False");
auto ret = SetConfigState(SCREEN_MAGNIFICATION_KEY, state);
// LCOV_EXCL_BR_START
if (ret != RET_OK) {
Utils::RecordDatashareInteraction(A11yDatashareValueType::UPDATE, "SetScreenMagnificationState");
HILOG_ERROR("set SetScreenMagnificationState failed");
return ret;
}
// LCOV_EXCL_BR_STOP
SetMagnificationState(state);
return ret;
}
@@ -246,6 +245,14 @@ RetError AccessibilitySettingsConfig::SetScreenMagnificationMode(const uint32_t
return RET_OK;
}
RetError AccessibilitySettingsConfig::SetScreenMagnificationTriggerMethod(const int32_t triggerMethod)
{
HILOG_DEBUG("screenMagnificationTriggerMethod = [%{public}d]", triggerMethod);
screenMagnificationTriggerMethod_.store(triggerMethod);
return RET_OK;
}
RetError AccessibilitySettingsConfig::SetScreenMagnificationScale(const float scale)
{
HILOG_DEBUG("screenMagnificationScale = [%{public}f]", scale);
@@ -257,13 +264,11 @@ RetError AccessibilitySettingsConfig::SetShortKeyState(const bool state)
{
HILOG_DEBUG("state = [%{public}s]", state ? "True" : "False");
auto ret = SetConfigState(SHORTCUT_ENABLED, state);
// LCOV_EXCL_BR_START
if (ret != RET_OK) {
Utils::RecordDatashareInteraction(A11yDatashareValueType::UPDATE, "SetShortKeyState");
HILOG_ERROR("set isShortKeyState_ failed");
return ret;
}
// LCOV_EXCL_BR_STOP
isShortKeyState_.store(state);
return ret;
}
@@ -318,13 +323,11 @@ RetError AccessibilitySettingsConfig::SetMouseKeyState(const bool state)
{
HILOG_DEBUG("state = [%{public}s]", state ? "True" : "False");
auto ret = SetConfigState(MOUSEKEY, state);
// LCOV_EXCL_BR_START
if (ret != RET_OK) {
Utils::RecordDatashareInteraction(A11yDatashareValueType::UPDATE, "SetMouseKeyState");
HILOG_ERROR("set isMouseKeyState_ failed");
return ret;
}
// LCOV_EXCL_BR_STOP
isMouseKeyState_.store(state);
return ret;
}
@@ -356,13 +359,11 @@ RetError AccessibilitySettingsConfig::SetShortkeyTarget(const std::string &name)
}
auto ret = datashare_->PutStringValue("ShortkeyTarget", name);
// LCOV_EXCL_BR_START
if (ret != RET_OK) {
Utils::RecordDatashareInteraction(A11yDatashareValueType::UPDATE, "SetShortkeyTarget");
HILOG_ERROR("set shortkeyTarget_ failed");
return ret;
}
// LCOV_EXCL_BR_STOP
shortkeyTarget_ = name;
return ret;
}
@@ -889,6 +890,11 @@ float AccessibilitySettingsConfig::GetScreenMagnificationScale() const
return screenMagnificationScale_.load();
}
int32_t AccessibilitySettingsConfig::GetScreenMagnificationTriggerMethod() const
{
return screenMagnificationTriggerMethod_.load();
}
bool AccessibilitySettingsConfig::GetIgnoreRepeatClickState() const
{
return ignoreRepeatClickState_.load();
@@ -1148,7 +1154,6 @@ void AccessibilitySettingsConfig::InitAnimationOffConfig()
}
}
// LCOV_EXCL_START
void AccessibilitySettingsConfig::HandleIgnoreRepeatClickState()
{
int64_t recoveryDate = datashare_->GetLongValue(RECOVERY_IGNORE_REPEAT_CLICK_DATE, 0);
@@ -1233,6 +1238,8 @@ void AccessibilitySettingsConfig::InitSetting()
datashare_->GetIntValue(SCREEN_MAGNIFICATION_MODE, FULL_SCREEN_MAGNIFICATION)));
screenMagnificationScale_.store(static_cast<float>(
datashare_->GetFloatValue(SCREEN_MAGNIFICATION_SCALE, DEFAULT_MAGNIFICATION_SCALE)));
screenMagnificationTriggerMethod_.store(static_cast<int32_t>(
datashare_->GetFloatValue(SCREEN_MAGNIFICATION_TRIGGER_METHOD, THREE_FINGER_DOUBLE_TAP_MODE)));
clickResponseTime_.store(static_cast<uint32_t>(datashare_->GetIntValue(CLICK_RESPONCE_TIME, 0)));
SetClickResponseTime(clickResponseTime_.load());
ignoreRepeatClickTime_.store(static_cast<uint32_t>(datashare_->GetIntValue(IGNORE_REPEAT_CLICK_TIME, 0)));
@@ -1517,7 +1524,6 @@ void AccessibilitySettingsConfig::recoverAudioAdjustment()
SetAudioBalance(audioBalance_.load());
}
}
// LCOV_EXCL_STOP
void AccessibilitySettingsConfig::OnDataClone()
{
@@ -1543,7 +1549,6 @@ void AccessibilitySettingsConfig::OnDataClone()
} else {
SetShortKeyOnLockScreenState(false);
}
if (isShortkeyEnabled != GetShortKeyState()) {
SetShortKeyState(isShortkeyEnabled);
@@ -84,6 +84,7 @@ namespace {
const char* SCREEN_MAGNIFICATION_MODE = "accessibility_magnification_mode";
const char* ELDER_CARE_ENABLED_KEY = "accessibility_elder_care_switch_enabled";
const char* SCREEN_MAGNIFICATION_SCALE = "accessibility_display_magnification_scale";
const char* SCREEN_MAGNIFICATION_TRIGGER_METHOD = "accessibility_display_magnification_trigger_method";
const char* MAGNIFICATION_PARAM = "const.accessibility.magnification";
const char* VOICE_RECOGNITION_KEY = "accessibility_sound_recognition_switch";
const char* VOICE_RECOGNITION_TYPES = "accessibility_sound_recognition_enabled";
@@ -3019,6 +3020,43 @@ void AccessibleAbilityManagerService::OnScreenMagnificationScaleChanged()
SetConfigScreenMagnificationScale(screenMagnificationScale);
}
void AccessibleAbilityManagerService::SetConfigScreenMagnificationTriggerMethod(int32_t triggerMethod)
{
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (accountData == nullptr) {
HILOG_ERROR("accountData is nullptr");
return;
}
std::shared_ptr<AccessibilitySettingsConfig> config = accountData->GetConfig();
if (config == nullptr) {
HILOG_ERROR("config is nullptr");
return;
}
config->SetScreenMagnificationTriggerMethod(triggerMethod);
}
void AccessibleAbilityManagerService::OnScreenMagnificationTriggerMethodChanged()
{
HILOG_INFO();
shared_ptr<AccessibilityDatashareHelper> helper = GetCurrentAcountDatashareHelper();
if (helper == nullptr) {
HILOG_ERROR("datashareHelper is nullptr");
return;
}
int32_t screenMagnificationTriggerMethod = helper->GetIntValue(SCREEN_MAGNIFICATION_TRIGGER_METHOD,
THREE_FINGER_DOUBLE_TAP_MODE);
SetConfigScreenMagnificationTriggerMethod(screenMagnificationTriggerMethod);
if (Singleton<ExtendManagerServiceProxy>::GetInstance().LoadExtProxy()) {
Singleton<ExtendManagerServiceProxy>::GetInstance().
OnScreenMagnificationTriggerMethodChanged(screenMagnificationTriggerMethod);
}
}
void AccessibleAbilityManagerService::RegisterScreenMagnificationState()
{
HILOG_DEBUG();
@@ -3040,9 +3078,14 @@ void AccessibleAbilityManagerService::RegisterScreenMagnificationState()
AccessibilitySettingObserver::UpdateFunc scaleFunc = [ = ](const std::string &state) {
Singleton<AccessibleAbilityManagerService>::GetInstance().OnScreenMagnificationScaleChanged();
};
AccessibilitySettingObserver::UpdateFunc triggerMethodFunc = [ = ](const std::string &state) {
Singleton<AccessibleAbilityManagerService>::GetInstance().OnScreenMagnificationTriggerMethodChanged();
};
if (accountData->GetConfig()->GetDbHandle()) {
accountData->GetConfig()->GetDbHandle()->RegisterObserver(SCREEN_MAGNIFICATION_KEY, func);
accountData->GetConfig()->GetDbHandle()->RegisterObserver(SCREEN_MAGNIFICATION_SCALE, scaleFunc);
accountData->GetConfig()->GetDbHandle()->RegisterObserver(SCREEN_MAGNIFICATION_TRIGGER_METHOD,
triggerMethodFunc);
}
}, "REGISTER_SCREEN_ZOOM_OBSERVER");
}
@@ -3473,6 +3516,23 @@ uint32_t AccessibleAbilityManagerService::GetMagnificationMode()
return config->GetScreenMagnificationMode();
}
int32_t AccessibleAbilityManagerService::GetMagnificationTriggerMethod()
{
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (accountData == nullptr) {
HILOG_ERROR("accountData is nullptr");
return 0;
}
std::shared_ptr<AccessibilitySettingsConfig> config = accountData->GetConfig();
if (config == nullptr) {
HILOG_ERROR("config is nullptr");
return 0;
}
return config->GetScreenMagnificationTriggerMethod();
}
void AccessibleAbilityManagerService::SetMagnificationMode(int32_t mode)
{
HILOG_DEBUG();
@@ -78,6 +78,7 @@ bool ExtendManagerServiceProxy::LoadExtProxy()
SetSendPointerEventForHoverCallback();
SetGetDelayTimeCallback();
SetGetMagnificationStateCallback();
ExtendGetMagnificationTriggerMethodCallback();
ExtendGetMagnificationModeCallback();
ExtendGetMagnificationScaleCallback();
ExtendUpdateInputFilterCallback();
@@ -768,6 +769,27 @@ void ExtendManagerServiceProxy::TransitionAnimationsDestroyTimers()
return func();
}
void ExtendManagerServiceProxy::OnScreenMagnificationTriggerMethodChanged(int32_t screenMagnificationTriggerMethod)
{
using OnScreenMagnificationTriggerMethodChanged = void(*)(int32_t screenMagnificationTriggerMethod);
static OnScreenMagnificationTriggerMethodChanged func;
if (!handle_) {
HILOG_ERROR("handle is null");
return;
}
if (!func || readyFunc_.find(ExtMethod::ON_SCREEN_MAGNIFICATION_TRIGGER_METHOD_CHANGE) == readyFunc_.end()) {
func = (OnScreenMagnificationTriggerMethodChanged)GetFunc("OnScreenMagnificationTriggerMethodChanged");
if (func) {
readyFunc_.insert(ExtMethod::ON_SCREEN_MAGNIFICATION_TRIGGER_METHOD_CHANGE);
return func(screenMagnificationTriggerMethod);
} else {
HILOG_ERROR("get OnScreenMagnificationTriggerMethodChanged func failed");
return;
}
}
return func(screenMagnificationTriggerMethod);
}
void ExtendManagerServiceProxy::OnScreenMagnificationTypeChanged(uint32_t screenMagnificationType)
{
using OnScreenMagnificationTypeChanged = void(*)(uint32_t screenMagnificationType);
@@ -864,6 +886,24 @@ bool ExtendManagerServiceProxy::CheckExtProxyStatus()
return true;
}
static int32_t GetMagnificationTriggerMethodCallback()
{
return Singleton<AccessibleAbilityManagerService>::GetInstance().GetMagnificationTriggerMethod();
}
bool ExtendManagerServiceProxy::ExtendGetMagnificationTriggerMethodCallback()
{
using GetMagnificationTriggerMethod = int32_t(*)();
using SetCallback = void(*)(GetMagnificationTriggerMethod cb);
SetCallback setCallbackFun = (SetCallback)GetFunc("ExtendGetMagnificationTriggerMethodCallback");
if (!setCallbackFun) {
HILOG_ERROR("setCallbackFun is null");
return false;
}
setCallbackFun(GetMagnificationTriggerMethodCallback);
return true;
}
static uint32_t GetMagnificationModeCallback()
{
return Singleton<AccessibleAbilityManagerService>::GetInstance().GetMagnificationMode();
@@ -39,6 +39,8 @@ public:
MOCK_METHOD1(OnKeyEvent, void(MMI::KeyEvent& event));
MOCK_METHOD1(OnPointerEvent, void(MMI::PointerEvent& event));
MOCK_METHOD1(SetAvailableFunctions, void(uint32_t availableFunctions));
MOCK_METHOD1(SetMagnificationMode, void(uint32_t mode));
MOCK_METHOD1(SetMagnificationTriggerMethod, void(int32_t screenMagnificationTriggerMethod));
};
} // namespace Accessibility
} // namespace OHOS
@@ -18,12 +18,16 @@
#include <gmock/gmock.h>
#include "accessibility_zoom_gesture.h"
#include "window_magnification_manager.h"
namespace OHOS {
namespace Accessibility {
class MockAccessibilityZoomGesture : public AccessibilityZoomGesture {
public:
MockAccessibilityZoomGesture();
MockAccessibilityZoomGesture(
std::shared_ptr<FullScreenMagnificationManager> fullScreenManager = nullptr,
std::shared_ptr<WindowMagnificationManager> windowMagnificationManager = nullptr,
std::shared_ptr<MagnificationMenuManager> menuManager = nullptr);
~MockAccessibilityZoomGesture();
MOCK_METHOD1(Triple, bool(MMI::PointerEvent& event));
@@ -136,5 +136,15 @@ void AccessibilityInputInterceptor::EnableGesture(uint32_t mode)
{
(void)mode;
}
void AccessibilityInputInterceptor::SetMagnificationMode(uint32_t mode)
{
(void)mode;
}
void AccessibilityInputInterceptor::SetMagnificationTriggerMethod(int32_t screenMagnificationTriggerMethod)
{
(void)screenMagnificationTriggerMethod;
}
} // namespace Accessibility
} // namespace OHOS
@@ -108,6 +108,13 @@ RetError AccessibilitySettingsConfig::SetScreenMagnificationScale(const float sc
return RET_OK;
}
RetError AccessibilitySettingsConfig::SetScreenMagnificationTriggerMethod(const int32_t triggerMethod)
{
HILOG_DEBUG("start.");
screenMagnificationTriggerMethod_ = triggerMethod;
return RET_OK;
}
RetError AccessibilitySettingsConfig::SetShortKeyState(const bool state)
{
HILOG_DEBUG("start.");
@@ -287,6 +294,12 @@ float AccessibilitySettingsConfig::GetScreenMagnificationScale() const
return screenMagnificationScale_;
}
int32_t AccessibilitySettingsConfig::GetScreenMagnificationTriggerMethod() const
{
HILOG_DEBUG("start.");
return screenMagnificationTriggerMethod_;
}
bool AccessibilitySettingsConfig::GetShortKeyState() const
{
HILOG_DEBUG("start.");
@@ -0,0 +1,32 @@
/*
* 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 "mock_accessibility_zoom_gesture.h"
namespace OHOS {
namespace Accessibility {
MockAccessibilityZoomGesture::MockAccessibilityZoomGesture(
std::shared_ptr<FullScreenMagnificationManager> fullScreenManager,
std::shared_ptr<WindowMagnificationManager> windowMagnificationManager,
std::shared_ptr<MagnificationMenuManager> menuManager)
: AccessibilityZoomGesture(fullScreenManager, windowMagnificationManager, menuManager)
{
}
MockAccessibilityZoomGesture::~MockAccessibilityZoomGesture()
{
}
} // namespace Accessibility
} // namespace OHOS
@@ -683,6 +683,11 @@ uint32_t AccessibleAbilityManagerService::GetMagnificationMode()
return FULL_SCREEN_MAGNIFICATION;
}
int32_t AccessibleAbilityManagerService::GetMagnificationTriggerMethod()
{
return THREE_FINGER_DOUBLE_TAP_MODE;
}
void AccessibleAbilityManagerService::SetMagnificationMode(int32_t mode)
{
(void)mode;
@@ -43,6 +43,7 @@ using SendPointerEventForHoverCallback = void (*)(
using GetDelayTime = int64_t(*)();
using GetMagnificationState = bool(*)();
using GetMagnificationModeCallback = uint32_t(*)(); // get
using GetMagnificationTriggerMethodCallback = int32_t(*)();
using GetMagnificationScaleCallback = float(*)(); // get
using UpdateInputFilterCallback = void(*)();
using MagnificationModeCallback = void(*)(int32_t mode); // set
@@ -91,6 +92,7 @@ public:
RetError SetMouseAutoClick(int32_t time);
void SetServiceOnKeyEventResult(int32_t connectionId, bool isHandled, uint32_t sequenceNum);
void OnScreenMagnificationTriggerMethodChanged(int32_t screenMagnificationTriggerMethod);
void OnScreenMagnificationTypeChanged(uint32_t screenMagnificationType);
void OnScreenMagnificationStateChanged();
void UnregisterDisplayListener();
@@ -103,6 +105,7 @@ public:
bool CheckDisplayId(uint64_t displayId);
GetMagnificationModeCallback getMagnificationModeCallback = nullptr;
GetMagnificationTriggerMethodCallback getMagnificationTriggerMethodCallback = nullptr;
GetMagnificationScaleCallback getMagnificationScaleCallback = nullptr;
UpdateInputFilterCallback updateInputFilterCallback = nullptr;
MagnificationModeCallback magnificationModeCallback = nullptr;
@@ -38,7 +38,7 @@ public:
static MagnificationWindow &GetInstance();
void EnableMagnification(uint32_t magnificationType, int32_t posX, int32_t posY);
void DisableMagnification(uint32_t magnificationType, bool needClear);
void SetScale(uint32_t magnificationType, float scaleSpan);
void SetScale(uint32_t magnificationType, float ratio);
void MoveMagnification(uint32_t magnificationType, int32_t deltaX, int32_t deltaY);
PointerPos ConvertGesture(uint32_t type, PointerPos coordinates);
PointerPos ConvertCoordinates(int32_t posX, int32_t posY);
@@ -68,7 +68,7 @@ private:
// full magnification
void EnableMagnificationFull(int32_t centerX, int32_t centerY);
void DisableMagnificationFull(bool needClear = false);
void SetScaleFull(float scaleSpan);
void SetScaleFull(float ratio);
void MoveMagnificationFull(int32_t deltaX, int32_t deltaY);
void FollowFocuseElementFull(int32_t centerX, int32_t centerY);
@@ -79,7 +79,7 @@ private:
// window magnification
void EnableMagnificationPart(int32_t centerX, int32_t centerY);
void DisableMagnificationPart(bool needClear = false);
void SetScalePart(float scaleSpan);
void SetScalePart(float ratio);
void MoveMagnificationPart(int32_t deltaX, int32_t deltaY);
void FollowFocuseElementPart(int32_t centerX, int32_t centerY);
void ShowMagnificationPart();
@@ -250,34 +250,27 @@ RetError AccessibilityInputInterceptor::InjectEvents(const std::shared_ptr<Acces
return RET_OK;
}
// LCOV_EXCL_START
void AccessibilityInputInterceptor::SetMagnificationTriggerMethod(int32_t screenMagnificationTriggerMethod)
{
if (zoomGesture_ == nullptr) {
HILOG_ERROR("zoomGesture is not enable");
return;
}
zoomGesture_->SetGestureMode(screenMagnificationTriggerMethod);
}
void AccessibilityInputInterceptor::CreateMagnificationGesture(sptr<EventTransmission> &header,
sptr<EventTransmission> &current)
{
HILOG_INFO("CreatWindowMagnificationGesture start");
HILOG_INFO("CreateMagnificationGesture start");
Singleton<ExtendServiceManager>::GetInstance().InitMagnification();
uint32_t magnificationMode = Singleton<ExtendServiceManager>::GetInstance().getMagnificationModeCallback();
if (magnificationMode == FULL_SCREEN_MAGNIFICATION) {
HILOG_INFO("create zoomGesture");
CreatZoomGesture();
if (zoomGesture_ == nullptr) {
HILOG_ERROR("zoomGesture create error.");
return;
}
SetNextEventTransmitter(header, current, zoomGesture_);
} else if (magnificationMode == WINDOW_MAGNIFICATION) {
HILOG_INFO("create windowMagnificationGesture");
CreatWindowMagnificationGesture();
if (windowMagnificationGesture_ == nullptr) {
HILOG_ERROR("windowMagnificationGesture create error.");
return;
}
SetNextEventTransmitter(header, current, windowMagnificationGesture_);
} else {
HILOG_WARN("invalid magnificationMode");
ClearMagnificationGesture();
CreateZoomGesture();
if (zoomGesture_ == nullptr) {
HILOG_ERROR("zoomGesture create error.");
return;
}
SetNextEventTransmitter(header, current, zoomGesture_);
#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER
if (ExtUtils::IsWideFold() || ExtUtils::IsSmallFold()) {
AccessibilityDisplayManager &displayMgr = Singleton<AccessibilityDisplayManager>::GetInstance();
@@ -288,12 +281,18 @@ void AccessibilityInputInterceptor::CreateMagnificationGesture(sptr<EventTransmi
#endif
}
void AccessibilityInputInterceptor::CreatZoomGesture()
void AccessibilityInputInterceptor::CreateZoomGesture()
{
std::shared_ptr<WindowMagnificationManager> windowMagnificationManager =
Singleton<ExtendServiceManager>::GetInstance().GetWindowMagnificationManager();
std::shared_ptr<FullScreenMagnificationManager> fullScreenMagnificationManager =
Singleton<ExtendServiceManager>::GetInstance().GetFullScreenMagnificationManager();
std::shared_ptr<MagnificationMenuManager> menuManager =
Singleton<ExtendServiceManager>::GetInstance().GetMenuManager();
if (windowMagnificationManager == nullptr) {
HILOG_ERROR("get windowMagnification manager failed.");
return;
}
if (fullScreenMagnificationManager == nullptr) {
HILOG_ERROR("get fullScreenMagnification manager failed.");
return;
@@ -304,7 +303,8 @@ void AccessibilityInputInterceptor::CreatZoomGesture()
}
if (zoomGesture_ == nullptr) {
sptr<AccessibilityZoomGesture> zoomGesture =
new(std::nothrow) AccessibilityZoomGesture(fullScreenMagnificationManager, menuManager);
new(std::nothrow) AccessibilityZoomGesture(fullScreenMagnificationManager,
windowMagnificationManager, menuManager);
if (zoomGesture == nullptr) {
HILOG_ERROR("zoomGesture create error.");
return;
@@ -318,40 +318,10 @@ void AccessibilityInputInterceptor::CreatZoomGesture()
}
}
void AccessibilityInputInterceptor::CreatWindowMagnificationGesture()
{
std::shared_ptr<WindowMagnificationManager> windowMagnificationManager =
Singleton<ExtendServiceManager>::GetInstance().GetWindowMagnificationManager();
std::shared_ptr<MagnificationMenuManager> menuManager =
Singleton<ExtendServiceManager>::GetInstance().GetMenuManager();
if (windowMagnificationManager == nullptr) {
HILOG_ERROR("get windowMagnification manager failed.");
return;
}
if (menuManager == nullptr) {
HILOG_ERROR("get menu manager failed.");
return;
}
if (windowMagnificationGesture_ == nullptr) {
sptr<WindowMagnificationGesture> windowMagnificationGesture =
new(std::nothrow) WindowMagnificationGesture(windowMagnificationManager, menuManager);
if (windowMagnificationGesture == nullptr) {
HILOG_ERROR("windowMagnificationGesture create error.");
return;
}
windowMagnificationGesture_ = windowMagnificationGesture;
}
if (needInteractMagnification_) {
windowMagnificationGesture_->StartMagnificationInteract();
needInteractMagnification_ = false;
}
}
// LCOV_EXCL_STOP
void AccessibilityInputInterceptor::ClearMagnificationGesture()
{
zoomGesture_ = nullptr;
windowMagnificationGesture_ = nullptr;
}
void AccessibilityInputInterceptor::CreateKeyEventTransmitters()
@@ -436,7 +406,6 @@ void AccessibilityInputInterceptor::DestroyTransmitters()
Singleton<ExtendServiceManager>::GetInstance().SetTouchEventInjector(nullptr);
pointerEventTransmitters_= nullptr;
zoomGesture_ = nullptr;
windowMagnificationGesture_ = nullptr;
}
if (keyEventTransmitters_ != nullptr) {
keyEventTransmitters_->DestroyEvents();
@@ -498,16 +467,12 @@ void AccessibilityInputInterceptor::SetNextEventTransmitter(sptr<EventTransmissi
current = next;
}
// LCOV_EXCL_START
void AccessibilityInputInterceptor::ShieldZoomGesture(bool flag)
{
HILOG_INFO("flag = %{public}d", flag);
if (zoomGesture_) {
zoomGesture_->ShieldZoomGesture(flag);
}
if (windowMagnificationGesture_) {
windowMagnificationGesture_->ShieldZoomGesture(flag);
}
}
void AccessibilityInputInterceptor::RefreshDisplayInfo()
@@ -527,24 +492,24 @@ void AccessibilityInputInterceptor::StartMagnificationInteract(uint32_t mode)
void AccessibilityInputInterceptor::DisableGesture(uint32_t mode)
{
HILOG_DEBUG("mode = %{public}d", mode);
if (mode == FULL_SCREEN_MAGNIFICATION && zoomGesture_ != nullptr) {
if (zoomGesture_ != nullptr) {
zoomGesture_->DisableGesture();
} else if (mode == WINDOW_MAGNIFICATION && windowMagnificationGesture_ != nullptr) {
windowMagnificationGesture_->DisableGesture();
} else {
HILOG_WARN("invalid mode.");
}
}
void AccessibilityInputInterceptor::EnableGesture(uint32_t mode)
{
HILOG_DEBUG("mode = %{public}d", mode);
if (mode == FULL_SCREEN_MAGNIFICATION && zoomGesture_ != nullptr) {
if (zoomGesture_ != nullptr) {
zoomGesture_->StartMagnificationInteract();
} else if (mode == WINDOW_MAGNIFICATION && windowMagnificationGesture_ != nullptr) {
windowMagnificationGesture_->StartMagnificationInteract();
} else {
HILOG_WARN("invalid mode.");
}
}
void AccessibilityInputInterceptor::SetMagnificationMode(uint32_t mode)
{
HILOG_DEBUG("mode = %{public}d", mode);
if (zoomGesture_ != nullptr) {
zoomGesture_->SetMagnificationMode(mode);
}
}
@@ -555,7 +520,6 @@ void AccessibilityInputInterceptor::SetServiceOnKeyEventResult(
keyEventFilter_->SetServiceOnKeyEventResult(connectionId, isHandled, sequenceNum);
}
}
// LCOV_EXCL_STOP
AccessibilityInputEventConsumer::AccessibilityInputEventConsumer()
{
File diff suppressed because it is too large Load Diff
+11
View File
@@ -159,6 +159,11 @@ API_EXPORT OHOS::Accessibility::RetError InjectEvents(
{
return serviceManagerInstance.InjectEvents(gesturePath);
}
API_EXPORT void OnScreenMagnificationTriggerMethodChanged(int32_t screenMagnificationTriggerMethod)
{
HILOG_INFO();
return serviceManagerInstance.OnScreenMagnificationTriggerMethodChanged(screenMagnificationTriggerMethod);
}
API_EXPORT void OnScreenMagnificationTypeChanged(uint32_t screenMagnificationType)
{
HILOG_INFO();
@@ -179,6 +184,12 @@ API_EXPORT void ExtendGetMagnificationModeCallback(OHOS::Accessibility::GetMagni
HILOG_INFO();
serviceManagerInstance.getMagnificationModeCallback = cb;
}
API_EXPORT void ExtendGetMagnificationTriggerMethodCallback(
OHOS::Accessibility::GetMagnificationTriggerMethodCallback cb)
{
HILOG_INFO();
serviceManagerInstance.getMagnificationTriggerMethodCallback = cb;
}
API_EXPORT void ExtendGetMagnificationScaleCallback(OHOS::Accessibility::GetMagnificationScaleCallback cb)
{
HILOG_INFO();
@@ -187,6 +187,16 @@ uint64_t ExtendServiceManager::GetDefaultDisplayId()
#endif
}
void ExtendServiceManager::OnScreenMagnificationTriggerMethodChanged(int32_t screenMagnificationTriggerMethod)
{
auto interceptor = AccessibilityInputInterceptor::GetInstance();
if (!interceptor) {
HILOG_ERROR("interceptor is null.");
return;
}
interceptor->SetMagnificationTriggerMethod(screenMagnificationTriggerMethod);
}
void ExtendServiceManager::OnScreenMagnificationTypeChanged(uint32_t screenMagnificationType)
{
if (magnificationManager_ != nullptr) {
@@ -150,10 +150,7 @@ void MagnificationManager::OnModeChanged(uint32_t mode)
}
Singleton<ExtendServiceManager>::GetInstance().magnificationModeCallback(static_cast<int32_t>(mode));
currentMode_ = mode;
if (needShow) {
interceptor->StartMagnificationInteract(mode);
}
Singleton<ExtendServiceManager>::GetInstance().updateInputFilterCallback();
interceptor->SetMagnificationMode(mode);
}
void MagnificationManager::DisableMagnification()
@@ -315,7 +315,7 @@ void MagnificationWindow::DisableMagnificationFull(bool needClear)
isMagnificationShowFull_ = false;
}
void MagnificationWindow::SetScaleFull(float scaleSpan)
void MagnificationWindow::SetScaleFull(float ratio)
{
HILOG_DEBUG();
if (window_ == nullptr) {
@@ -326,9 +326,7 @@ void MagnificationWindow::SetScaleFull(float scaleSpan)
HILOG_ERROR("screen param invalid.");
return;
}
float ratio = scaleSpan / screenSpan_;
float tmpScale = scale_ + ratio * scale_;
float tmpScale = ratio * scale_;
if (tmpScale > MAX_SCALE) {
tmpScale = MAX_SCALE;
@@ -821,14 +819,14 @@ void MagnificationWindow::DisableMagnification(uint32_t magnificationType, bool
HILOG_DEBUG("invalid type = %{public}d", magnificationType);
}
void MagnificationWindow::SetScale(uint32_t magnificationType, float scaleSpan)
void MagnificationWindow::SetScale(uint32_t magnificationType, float ratio)
{
if (magnificationType == FULL_SCREEN_MAGNIFICATION) {
SetScaleFull(scaleSpan);
SetScaleFull(ratio);
return;
}
if (magnificationType == WINDOW_MAGNIFICATION) {
SetScalePart(scaleSpan);
SetScalePart(ratio);
return;
}
HILOG_DEBUG("invalid type = %{public}d", magnificationType);
+1 -1
View File
@@ -309,12 +309,12 @@ ohos_unittest("accessibility_zoom_gesture_test") {
"../src/touch_exploration_multi_finger_gesture.cpp",
"../src/touch_exploration_single_finger_gesture.cpp",
"../src/window_magnification_gesture.cpp",
"../src/window_magnification_manager.cpp",
"mock/src/mock_accessibility_display_manager.cpp",
"mock/src/mock_accessibility_event_transmission.cpp",
"mock/src/mock_accessibility_extend_power_manager.cpp",
"mock/src/mock_extend_service_manager.cpp",
"mock/src/mock_full_screen_magnification_manager.cpp",
"mock/src/mock_window_magnification_manager.cpp",
"mock/src/mock_magnification_menu_manager.cpp",
"mock/src/mock_system_ability.cpp",
"unittest/accessibility_zoom_gesture_test.cpp",
@@ -19,7 +19,9 @@
#include "accessibility_ut_helper.h"
#include "accessibility_zoom_gesture.h"
#include "full_screen_magnification_manager.h"
#include "window_magnification_manager.h"
#include "magnification_menu_manager.h"
#include "magnification_def.h"
using namespace testing;
using namespace testing::ext;
@@ -28,6 +30,14 @@ namespace OHOS {
namespace Accessibility {
namespace {
constexpr uint32_t TRIPLE_TAP_COUNT = 3;
constexpr uint32_t DOUBLE_TAP_COUNT = 2;
constexpr int32_t SLEEP_MS_2 = 2;
constexpr int32_t POINT_ID_0 = 0;
constexpr int32_t POINT_ID_1 = 1;
constexpr int32_t POINT_ID_2 = 2;
constexpr int32_t INVALID_POINTER_ACTION = -1;
constexpr int32_t READY_STATE = 0;
constexpr int32_t ZOOM_STATE = 1;
} // namespace
class AccessibilityZoomGestureUnitTest : public ::testing::Test {
public:
@@ -41,9 +51,16 @@ public:
void SetUp() override;
void TearDown() override;
std::shared_ptr<MMI::PointerEvent> CreatePointerEvent(int32_t sourceType, int32_t pointerAction);
std::shared_ptr<MMI::PointerEvent> CreatePointerEvent(int32_t pointerAction,
std::vector<MMI::PointerEvent::PointerItem> &points, int32_t pointerId);
void SetPointerItem(MMI::PointerEvent::PointerItem &point, int32_t id, int32_t x, int32_t y);
void TripleTaps();
void DoubleTapsWithThreeFingers();
std::shared_ptr<AccessibilityZoomGesture> zoomGesture_ = nullptr;
std::shared_ptr<FullScreenMagnificationManager> fullScreenManager_ = nullptr;
std::shared_ptr<WindowMagnificationManager> windowMagnificationManager_ = nullptr;
std::shared_ptr<MagnificationMenuManager> menuManager_ = nullptr;
};
void AccessibilityZoomGestureUnitTest::SetUpTestCase()
@@ -59,15 +76,23 @@ void AccessibilityZoomGestureUnitTest::TearDownTestCase()
void AccessibilityZoomGestureUnitTest::SetUp()
{
GTEST_LOG_(INFO) << "SetUp";
std::shared_ptr<FullScreenMagnificationManager> manager = std::make_shared<FullScreenMagnificationManager>();
std::shared_ptr<MagnificationMenuManager> menuManager = std::make_shared<MagnificationMenuManager>();
zoomGesture_ = std::make_shared<AccessibilityZoomGesture>(manager, menuManager);
fullScreenManager_ = std::make_shared<FullScreenMagnificationManager>();
windowMagnificationManager_ = std::make_shared<WindowMagnificationManager>();
menuManager_ = std::make_shared<MagnificationMenuManager>();
zoomGesture_ = std::make_shared<AccessibilityZoomGesture>(fullScreenManager_,
windowMagnificationManager_, menuManager_);
AccessibilityAbilityHelper::GetInstance().ClearZoom();
}
void AccessibilityZoomGestureUnitTest::TearDown()
{
GTEST_LOG_(INFO) << "TearDown";
AccessibilityAbilityHelper::GetInstance().ClearZoom();
AccessibilityAbilityHelper::GetInstance().ClearTouchEventActionVector();
zoomGesture_ = nullptr;
fullScreenManager_ = nullptr;
windowMagnificationManager_ = nullptr;
menuManager_ = nullptr;
}
std::shared_ptr<MMI::PointerEvent> AccessibilityZoomGestureUnitTest::CreatePointerEvent(int32_t sourceType,
@@ -82,27 +107,79 @@ std::shared_ptr<MMI::PointerEvent> AccessibilityZoomGestureUnitTest::CreatePoint
return event;
}
std::shared_ptr<MMI::PointerEvent> AccessibilityZoomGestureUnitTest::CreatePointerEvent(int32_t pointerAction,
std::vector<MMI::PointerEvent::PointerItem> &points, int32_t pointerId)
{
std::shared_ptr<MMI::PointerEvent> event = MMI::PointerEvent::Create();
if (!event) {
return nullptr;
}
for (auto &point : points) {
event->AddPointerItem(point);
}
event->SetPointerId(pointerId);
event->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
event->SetPointerAction(pointerAction);
return event;
}
void AccessibilityZoomGestureUnitTest::SetPointerItem(MMI::PointerEvent::PointerItem &point,
int32_t id, int32_t x, int32_t y)
{
point.SetPointerId(id);
point.SetDisplayX(x);
point.SetDisplayY(y);
}
void AccessibilityZoomGestureUnitTest::TripleTaps()
{
EXPECT_TRUE(zoomGesture_ != nullptr);
for (uint32_t count = 0; count < TRIPLE_TAP_COUNT; count++) {
// Pointer down
std::shared_ptr<MMI::PointerEvent> eventDown = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_DOWN);
EXPECT_TRUE(eventDown != nullptr);
MMI::PointerEvent::PointerItem item;
item.SetDisplayX(100);
item.SetDisplayY(100);
eventDown->AddPointerItem(item);
zoomGesture_->OnPointerEvent(*eventDown);
// Pointer up
std::shared_ptr<MMI::PointerEvent> eventUp = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_UP);
EXPECT_TRUE(eventUp != nullptr);
MMI::PointerEvent::PointerItem item1;
item1.SetDisplayX(100);
item1.SetDisplayY(100);
eventUp->AddPointerItem(item1);
zoomGesture_->OnPointerEvent(*eventUp);
}
}
void AccessibilityZoomGestureUnitTest::DoubleTapsWithThreeFingers()
{
EXPECT_TRUE(zoomGesture_ != nullptr);
zoomGesture_->SetGestureMode(THREE_FINGER_DOUBLE_TAP_MODE);
for (uint32_t count = 0; count < DOUBLE_TAP_COUNT; count++) {
std::vector<MMI::PointerEvent::PointerItem> points = {};
MMI::PointerEvent::PointerItem point1 = {};
SetPointerItem(point1, POINT_ID_0, 10, 10);
MMI::PointerEvent::PointerItem point2 = {};
SetPointerItem(point2, POINT_ID_1, 20, 20);
MMI::PointerEvent::PointerItem point3 = {};
SetPointerItem(point3, POINT_ID_2, 30, 30);
points.emplace_back(point1);
points.emplace_back(point2);
points.emplace_back(point3);
std::shared_ptr<MMI::PointerEvent> eventDown = CreatePointerEvent(
MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_2);
EXPECT_TRUE(eventDown != nullptr);
zoomGesture_->OnPointerEvent(*eventDown);
std::shared_ptr<MMI::PointerEvent> eventUp = CreatePointerEvent(
MMI::PointerEvent::POINTER_ACTION_UP, points, POINT_ID_2);
EXPECT_TRUE(eventUp != nullptr);
zoomGesture_->OnPointerEvent(*eventUp);
}
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_001
* @tc.name: OnPointerEvent
@@ -467,5 +544,562 @@ HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnP
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_011 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_012
* @tc.name: OnPointerEvent
* @tc.desc: Test function OnPointerEvent with invalid pointer action
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnPointerEvent_012, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_012 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
std::shared_ptr<MMI::PointerEvent> event = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
INVALID_POINTER_ACTION);
EXPECT_TRUE(event != nullptr);
AccessibilityAbilityHelper::GetInstance().ClearTouchEventActionVector();
zoomGesture_->OnPointerEvent(*event);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_012 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_013
* @tc.name: OnPointerEvent
* @tc.desc: Test function OnPointerEvent with levitate move action
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnPointerEvent_013, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_013 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
std::shared_ptr<MMI::PointerEvent> event = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_LEVITATE_MOVE);
EXPECT_TRUE(event != nullptr);
AccessibilityAbilityHelper::GetInstance().ClearTouchEventActionVector();
zoomGesture_->OnPointerEvent(*event);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_013 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_014
* @tc.name: OnPointerEvent
* @tc.desc: Test function OnPointerEvent with scrollshot pointer id
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnPointerEvent_014, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_014 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
std::shared_ptr<MMI::PointerEvent> event = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_DOWN);
EXPECT_TRUE(event != nullptr);
event->SetPointerId(SCROLL_SHOT_POINTER_ID);
AccessibilityAbilityHelper::GetInstance().ClearTouchEventActionVector();
zoomGesture_->OnPointerEvent(*event);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_014 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_DestroyEvents_001
* @tc.name: DestroyEvents
* @tc.desc: Test function DestroyEvents
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_DestroyEvents_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_DestroyEvents_001 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
TripleTaps();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
zoomGesture_->DestroyEvents();
zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_FALSE(zoomState);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_DestroyEvents_001 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_ShieldZoomGesture_001
* @tc.name: ShieldZoomGesture
* @tc.desc: Test function ShieldZoomGesture with true state
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_ShieldZoomGesture_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_ShieldZoomGesture_001 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
TripleTaps();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
zoomGesture_->ShieldZoomGesture(true);
zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_FALSE(zoomState);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_ShieldZoomGesture_001 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_ShieldZoomGesture_002
* @tc.name: ShieldZoomGesture
* @tc.desc: Test function ShieldZoomGesture with false state
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_ShieldZoomGesture_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_ShieldZoomGesture_002 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
zoomGesture_->ShieldZoomGesture(false);
TripleTaps();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_ShieldZoomGesture_002 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_ShieldZoomGesture_003
* @tc.name: ShieldZoomGesture
* @tc.desc: Test function ShieldZoomGesture called twice with same state
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_ShieldZoomGesture_003, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_ShieldZoomGesture_003 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
zoomGesture_->ShieldZoomGesture(true);
zoomGesture_->ShieldZoomGesture(true);
int32_t zoomState = zoomGesture_->GetZoomState();
EXPECT_EQ(zoomState, READY_STATE);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_ShieldZoomGesture_003 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_GetWindowParam_001
* @tc.name: GetWindowParam
* @tc.desc: Test function GetWindowParam with needRefresh true
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_GetWindowParam_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_GetWindowParam_001 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
zoomGesture_->GetWindowParam(true);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_GetWindowParam_001 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_GetWindowParam_002
* @tc.name: GetWindowParam
* @tc.desc: Test function GetWindowParam with needRefresh false
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_GetWindowParam_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_GetWindowParam_002 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
zoomGesture_->GetWindowParam(false);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_GetWindowParam_002 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_StartMagnificationInteract_001
* @tc.name: StartMagnificationInteract
* @tc.desc: Test function StartMagnificationInteract
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_StartMagnificationInteract_001,
TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_StartMagnificationInteract_001 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
zoomGesture_->StartMagnificationInteract();
int32_t zoomState = zoomGesture_->GetZoomState();
EXPECT_EQ(zoomState, ZOOM_STATE);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_StartMagnificationInteract_001 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_SetGestureMode_001
* @tc.name: SetGestureMode
* @tc.desc: Test function SetGestureMode with SINGLE_FINGER_TRIPLE_TAP_MODE
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_SetGestureMode_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_SetGestureMode_001 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
zoomGesture_->SetGestureMode(SINGLE_FINGER_TRIPLE_TAP_MODE);
TripleTaps();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_SetGestureMode_001 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_SetGestureMode_002
* @tc.name: SetGestureMode
* @tc.desc: Test function SetGestureMode with THREE_FINGER_DOUBLE_TAP_MODE
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_SetGestureMode_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_SetGestureMode_002 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
zoomGesture_->SetGestureMode(THREE_FINGER_DOUBLE_TAP_MODE);
DoubleTapsWithThreeFingers();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_SetGestureMode_002 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_SetMagnificationMode_001
* @tc.name: SetMagnificationMode
* @tc.desc: Test function SetMagnificationMode with FULL_SCREEN_MAGNIFICATION
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_SetMagnificationMode_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_SetMagnificationMode_001 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
zoomGesture_->SetMagnificationMode(FULL_SCREEN_MAGNIFICATION);
TripleTaps();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_SetMagnificationMode_001 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_SetMagnificationMode_002
* @tc.name: SetMagnificationMode
* @tc.desc: Test function SetMagnificationMode with WINDOW_MAGNIFICATION
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_SetMagnificationMode_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_SetMagnificationMode_002 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
zoomGesture_->SetMagnificationMode(WINDOW_MAGNIFICATION);
TripleTaps();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_SetMagnificationMode_002 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_DisableGesture_001
* @tc.name: DisableGesture
* @tc.desc: Test function DisableGesture
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_DisableGesture_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_DisableGesture_001 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
TripleTaps();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
zoomGesture_->DisableGesture();
zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_FALSE(zoomState);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_DisableGesture_001 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_GetZoomState_001
* @tc.name: GetZoomState
* @tc.desc: Test function GetZoomState in ready state
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_GetZoomState_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_GetZoomState_001 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
int32_t zoomState = zoomGesture_->GetZoomState();
EXPECT_EQ(zoomState, READY_STATE);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_GetZoomState_001 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_GetZoomState_002
* @tc.name: GetZoomState
* @tc.desc: Test function GetZoomState in zoom state
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_GetZoomState_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_GetZoomState_002 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
TripleTaps();
int32_t zoomState = zoomGesture_->GetZoomState();
EXPECT_EQ(zoomState, ZOOM_STATE);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_GetZoomState_002 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_015
* @tc.name: OnPointerEvent
* @tc.desc: Test function OnPointerEvent with non-touchscreen source type in ready state
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnPointerEvent_015, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_015 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
std::shared_ptr<MMI::PointerEvent> event = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_MOUSE,
MMI::PointerEvent::POINTER_ACTION_DOWN);
EXPECT_TRUE(event != nullptr);
AccessibilityAbilityHelper::GetInstance().ClearTouchEventActionVector();
zoomGesture_->OnPointerEvent(*event);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_015 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_016
* @tc.name: OnPointerEvent
* @tc.desc: Test function OnPointerEvent with three finger double tap to start zoom
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnPointerEvent_016, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_016 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
zoomGesture_->SetGestureMode(THREE_FINGER_DOUBLE_TAP_MODE);
DoubleTapsWithThreeFingers();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
DoubleTapsWithThreeFingers();
zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_FALSE(zoomState);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_016 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_017
* @tc.name: OnPointerEvent
* @tc.desc: Test function OnPointerEvent with two finger move in sliding state
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnPointerEvent_017, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_017 start";
TripleTaps();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
std::shared_ptr<MMI::PointerEvent> eventDown = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_DOWN);
EXPECT_TRUE(eventDown != nullptr);
MMI::PointerEvent::PointerItem item1;
item1.SetDisplayX(10);
item1.SetDisplayY(20);
item1.SetPointerId(POINT_ID_0);
eventDown->AddPointerItem(item1);
MMI::PointerEvent::PointerItem item2;
item2.SetDisplayX(40);
item2.SetDisplayY(20);
item2.SetPointerId(POINT_ID_1);
eventDown->AddPointerItem(item2);
zoomGesture_->OnPointerEvent(*eventDown);
std::shared_ptr<MMI::PointerEvent> eventMove = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_MOVE);
EXPECT_TRUE(eventMove != nullptr);
MMI::PointerEvent::PointerItem item3;
item3.SetDisplayX(0);
item3.SetDisplayY(50);
item3.SetPointerId(POINT_ID_0);
eventMove->AddPointerItem(item3);
MMI::PointerEvent::PointerItem item4;
item4.SetDisplayX(70);
item4.SetDisplayY(50);
item4.SetPointerId(POINT_ID_1);
eventMove->AddPointerItem(item4);
zoomGesture_->OnPointerEvent(*eventMove);
zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_017 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_018
* @tc.name: OnPointerEvent
* @tc.desc: Test function OnPointerEvent with hold state down and move
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnPointerEvent_018, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_018 start";
TripleTaps();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
std::shared_ptr<MMI::PointerEvent> eventDown = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_DOWN);
EXPECT_TRUE(eventDown != nullptr);
MMI::PointerEvent::PointerItem item;
item.SetDisplayX(100);
item.SetDisplayY(100);
eventDown->AddPointerItem(item);
zoomGesture_->OnPointerEvent(*eventDown);
std::shared_ptr<MMI::PointerEvent> eventMove = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_MOVE);
EXPECT_TRUE(eventMove != nullptr);
MMI::PointerEvent::PointerItem itemMove;
itemMove.SetDisplayX(110);
itemMove.SetDisplayY(110);
eventMove->AddPointerItem(itemMove);
zoomGesture_->OnPointerEvent(*eventMove);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_018 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_019
* @tc.name: OnPointerEvent
* @tc.desc: Test function OnPointerEvent with hold state up to exit zoom
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnPointerEvent_019, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_019 start";
TripleTaps();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
std::shared_ptr<MMI::PointerEvent> eventDown = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_DOWN);
EXPECT_TRUE(eventDown != nullptr);
MMI::PointerEvent::PointerItem item;
item.SetDisplayX(100);
item.SetDisplayY(100);
eventDown->AddPointerItem(item);
zoomGesture_->OnPointerEvent(*eventDown);
std::shared_ptr<MMI::PointerEvent> eventUp = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_UP);
EXPECT_TRUE(eventUp != nullptr);
MMI::PointerEvent::PointerItem itemUp;
itemUp.SetDisplayX(100);
itemUp.SetDisplayY(100);
eventUp->AddPointerItem(itemUp);
zoomGesture_->OnPointerEvent(*eventUp);
sleep(SLEEP_MS_2);
zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_FALSE(zoomState);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_019 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_020
* @tc.name: OnPointerEvent
* @tc.desc: Test function OnPointerEvent with passing through state
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnPointerEvent_020, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_020 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
std::shared_ptr<MMI::PointerEvent> eventDown = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_DOWN);
EXPECT_TRUE(eventDown != nullptr);
MMI::PointerEvent::PointerItem item1;
item1.SetDisplayX(10);
item1.SetDisplayY(20);
eventDown->AddPointerItem(item1);
MMI::PointerEvent::PointerItem item2;
item2.SetDisplayX(40);
item2.SetDisplayY(20);
eventDown->AddPointerItem(item2);
zoomGesture_->OnPointerEvent(*eventDown);
AccessibilityAbilityHelper::GetInstance().ClearTouchEventActionVector();
std::shared_ptr<MMI::PointerEvent> eventUp = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_UP);
EXPECT_TRUE(eventUp != nullptr);
zoomGesture_->OnPointerEvent(*eventUp);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_020 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_021
* @tc.name: OnPointerEvent
* @tc.desc: Test function OnPointerEvent with hot area sliding state
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnPointerEvent_021, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_021 start";
TripleTaps();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
AccessibilityAbilityHelper::GetInstance().SetTapOnHotArea(true);
std::shared_ptr<MMI::PointerEvent> eventDown = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_DOWN);
EXPECT_TRUE(eventDown != nullptr);
MMI::PointerEvent::PointerItem item1;
item1.SetDisplayX(10);
item1.SetDisplayY(20);
eventDown->AddPointerItem(item1);
zoomGesture_->OnPointerEvent(*eventDown);
std::shared_ptr<MMI::PointerEvent> eventMove = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_MOVE);
EXPECT_TRUE(eventMove != nullptr);
MMI::PointerEvent::PointerItem itemMove;
itemMove.SetDisplayX(200);
itemMove.SetDisplayY(200);
eventMove->AddPointerItem(itemMove);
zoomGesture_->OnPointerEvent(*eventMove);
std::shared_ptr<MMI::PointerEvent> eventUp = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_UP);
EXPECT_TRUE(eventUp != nullptr);
MMI::PointerEvent::PointerItem itemUp;
itemUp.SetDisplayX(200);
itemUp.SetDisplayY(200);
eventUp->AddPointerItem(itemUp);
zoomGesture_->OnPointerEvent(*eventUp);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_021 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_022
* @tc.name: OnPointerEvent
* @tc.desc: Test function OnPointerEvent with menu sliding state
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnPointerEvent_022, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_022 start";
TripleTaps();
bool zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState();
EXPECT_TRUE(zoomState);
AccessibilityAbilityHelper::GetInstance().SetTapOnMenu(true);
std::shared_ptr<MMI::PointerEvent> eventDown = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_DOWN);
EXPECT_TRUE(eventDown != nullptr);
MMI::PointerEvent::PointerItem item1;
item1.SetDisplayX(10);
item1.SetDisplayY(20);
eventDown->AddPointerItem(item1);
zoomGesture_->OnPointerEvent(*eventDown);
std::shared_ptr<MMI::PointerEvent> eventMove = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_MOVE);
EXPECT_TRUE(eventMove != nullptr);
MMI::PointerEvent::PointerItem itemMove;
itemMove.SetDisplayX(200);
itemMove.SetDisplayY(200);
eventMove->AddPointerItem(itemMove);
zoomGesture_->OnPointerEvent(*eventMove);
std::shared_ptr<MMI::PointerEvent> eventUp = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_UP);
EXPECT_TRUE(eventUp != nullptr);
MMI::PointerEvent::PointerItem itemUp;
itemUp.SetDisplayX(200);
itemUp.SetDisplayY(200);
eventUp->AddPointerItem(itemUp);
zoomGesture_->OnPointerEvent(*eventUp);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_022 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_023
* @tc.name: OnPointerEvent
* @tc.desc: Test function OnPointerEvent with levitate in window action
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnPointerEvent_023, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_023 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
std::shared_ptr<MMI::PointerEvent> event = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_LEVITATE_IN_WINDOW);
EXPECT_TRUE(event != nullptr);
AccessibilityAbilityHelper::GetInstance().ClearTouchEventActionVector();
zoomGesture_->OnPointerEvent(*event);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_023 end";
}
/**
* @tc.number: AccessibilityZoomGesture_Unittest_OnPointerEvent_024
* @tc.name: OnPointerEvent
* @tc.desc: Test function OnPointerEvent with levitate out window action
*/
HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnPointerEvent_024, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_024 start";
EXPECT_TRUE(zoomGesture_ != nullptr);
std::shared_ptr<MMI::PointerEvent> event = CreatePointerEvent(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN,
MMI::PointerEvent::POINTER_ACTION_LEVITATE_OUT_WINDOW);
EXPECT_TRUE(event != nullptr);
AccessibilityAbilityHelper::GetInstance().ClearTouchEventActionVector();
zoomGesture_->OnPointerEvent(*event);
GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_024 end";
}
} // namespace Accessibility
} // namespace OHOS
@@ -3828,6 +3828,23 @@ uint32_t MockAccessibleAbilityManagerService::GetMagnificationType()
return config->GetScreenMagnificationType();
}
int32_t AccessibleAbilityManagerService::GetMagnificationTriggerMethod()
{
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (accountData == nullptr) {
HILOG_ERROR("accountData is nullptr");
return 0;
}
std::shared_ptr<AccessibilitySettingsConfig> config = accountData->GetConfig();
if (config == nullptr) {
HILOG_ERROR("config is nullptr");
return 0;
}
return config->GetScreenMagnificationTriggerMethod();
}
uint32_t MockAccessibleAbilityManagerService::GetMagnificationMode()
{
HILOG_DEBUG();
@@ -49,6 +49,11 @@ bool ExtendManagerServiceProxy::SetGetMagnificationStateCallback()
return true;
}
bool ExtendManagerServiceProxy::ExtendGetMagnificationTriggerMethodCallback()
{
return true;
}
bool ExtendManagerServiceProxy::SetFindFocusedElementCallback()
{
return true;
@@ -212,6 +217,12 @@ void ExtendManagerServiceProxy::OnScreenMagnificationTypeChanged(uint32_t screen
return;
}
void ExtendManagerServiceProxy::OnScreenMagnificationTriggerMethodChanged(int32_t screenMagnificationTriggerMethod)
{
(void)screenMagnificationTriggerMethod;
return;
}
void ExtendManagerServiceProxy::OnScreenMagnificationStateChanged()
{
return;
@@ -53,6 +53,7 @@ enum class ExtMethod : int32_t {
GET_CLICK_POSITION,
FOLLOW_FOCUSE_ELEMENT,
ON_SCREEN_MAGNIFICATION_TYPE_CHANGED,
ON_SCREEN_MAGNIFICATION_TRIGGER_METHOD_CHANGE,
ON_SCREEN_MAGNIFICATION_STATE_CHANGED,
OFF_ZOOM_GESTURE,
SET_MAGNIFICATION_STATE,
@@ -86,6 +87,7 @@ public:
void TransitionAnimationsCancelNotification();
int32_t TransitionAnimationsRegisterTimers(uint64_t beginTime);
void TransitionAnimationsDestroyTimers();
void OnScreenMagnificationTriggerMethodChanged(int32_t screenMagnificationTriggerMethod);
void OnScreenMagnificationTypeChanged(uint32_t screenMagnificationType);
void OnScreenMagnificationStateChanged();
void UnregisterDisplayListener();
@@ -107,6 +109,7 @@ public:
bool SetSendPointerEventForHoverCallback();
bool SetGetDelayTimeCallback();
bool SetGetMagnificationStateCallback();
bool ExtendGetMagnificationTriggerMethodCallback();
bool ExtendGetMagnificationModeCallback();
bool ExtendGetMagnificationScaleCallback();
bool ExtendUpdateInputFilterCallback();