已合并
事件取消订阅增加hilog #2708
wwwyyyhhhh创建于 15 天前
事件取消订阅增加hilog #2708
已合并
共 8 个文件变更+73-4
| @@ -31,6 +31,13 @@ | |||
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | namespace OHOS { | 33 | namespace OHOS { |
| 34 | +namespace Accessibility { | ||
| 35 | +enum AccessibilityStateEventType : uint32_t; | ||
| 36 | +} // namespace Accessibility | ||
| 37 | +namespace AccessibilityConfig { | ||
| 38 | +enum CONFIG_ID : int32_t; | ||
| 39 | +} // namespace AccessibilityConfig | ||
| 40 | + | ||
| 34 | namespace AccessibilityNapi { | 41 | namespace AccessibilityNapi { |
| 35 | // key action | 42 | // key action |
| 36 | enum KeyAction : int32_t { | 43 | enum KeyAction : int32_t { |
| @@ -147,6 +154,8 @@ bool ConvertGesturePathJSToNAPIPart2(napi_env env, napi_value object, | |||
| 147 | AccessibilityEventType CovertStringToAccessibilityEventType(const std::string &eventType); | 154 | AccessibilityEventType CovertStringToAccessibilityEventType(const std::string &eventType); |
| 148 | AccessibilityEventType CovertStringToAccessibilityEventType( | 155 | AccessibilityEventType CovertStringToAccessibilityEventType( |
| 149 | const OHOS::Accessibility::AccessibilityEventInfo &eventInfo, const std::string &eventTypeString); | 156 | const OHOS::Accessibility::AccessibilityEventInfo &eventInfo, const std::string &eventTypeString); |
| 157 | +std::string ConvertStateEventTypeToString(OHOS::Accessibility::AccessibilityStateEventType type); | ||
| 158 | +std::string ConvertConfigIdToString(OHOS::AccessibilityConfig::CONFIG_ID configId); | ||
| 150 | 159 | ||
| 151 | struct AccessibilityCallbackInfo { | 160 | struct AccessibilityCallbackInfo { |
| 152 | napi_env env_; | 161 | napi_env env_; |
| @@ -29,6 +29,7 @@ ohos_shared_library("accessibility_napi") { | |||
| 29 | "../../../common/log/include", | 29 | "../../../common/log/include", |
| 30 | "./include", | 30 | "./include", |
| 31 | "../../../common/interface/include", | 31 | "../../../common/interface/include", |
| 32 | + "../../innerkits/asacfwk/include", | ||
| 32 | ] | 33 | ] |
| 33 | 34 | ||
| 34 | defines = [ | 35 | defines = [ |
| @@ -30,6 +30,7 @@ ohos_shared_library("config_napi") { | |||
| 30 | "../include", | 30 | "../include", |
| 31 | "./include", | 31 | "./include", |
| 32 | "../../../../common/interface/include", | 32 | "../../../../common/interface/include", |
| 33 | + "../../../innerkits/asacfwk/include", | ||
| 33 | ] | 34 | ] |
| 34 | 35 | ||
| 35 | defines = [ | 36 | defines = [ |
| @@ -1512,7 +1512,7 @@ void EnableAbilityListsObserverImpl::UnsubscribeObserver(napi_env env, napi_valu | |||
| 1512 | 1512 | ||
| 1513 | void EnableAbilityListsObserverImpl::UnsubscribeObservers() | 1513 | void EnableAbilityListsObserverImpl::UnsubscribeObservers() |
| 1514 | { | 1514 | { |
| 1515 | - HILOG_DEBUG(); | 1515 | + HILOG_INFO("SubEvent op=off_all kit=AccessibilityKit event=enabledAccessibilityExtensionListChange"); |
| 1516 | std::lock_guard<ffrt::mutex> lock(mutex_); | 1516 | std::lock_guard<ffrt::mutex> lock(mutex_); |
| 1517 | enableAbilityListsObservers_.clear(); | 1517 | enableAbilityListsObservers_.clear(); |
| 1518 | } | 1518 | } |
| @@ -1531,7 +1531,7 @@ void EnableAbilityListsObserverImpl::UnsubscribeInstallObserver(napi_env env, na | |||
| 1531 | 1531 | ||
| 1532 | void EnableAbilityListsObserverImpl::UnsubscribeInstallObservers() | 1532 | void EnableAbilityListsObserverImpl::UnsubscribeInstallObservers() |
| 1533 | { | 1533 | { |
| 1534 | - HILOG_DEBUG(); | 1534 | + HILOG_INFO("SubEvent op=off_all kit=AccessibilityKit event=installedAccessibilityListChange"); |
| 1535 | std::lock_guard<ffrt::mutex> lock(mutex_); | 1535 | std::lock_guard<ffrt::mutex> lock(mutex_); |
| 1536 | installAbilityListsObservers_.clear(); | 1536 | installAbilityListsObservers_.clear(); |
| 1537 | } | 1537 | } |
| @@ -482,7 +482,8 @@ void NAccessibilityConfigObserverImpl::UnsubscribeObserver(napi_env env, | |||
| 482 | 482 | ||
| 483 | void NAccessibilityConfigObserverImpl::UnsubscribeObservers(OHOS::AccessibilityConfig::CONFIG_ID id) | 483 | void NAccessibilityConfigObserverImpl::UnsubscribeObservers(OHOS::AccessibilityConfig::CONFIG_ID id) |
| 484 | { | 484 | { |
| 485 | - HILOG_INFO(); | 485 | + HILOG_INFO("SubEvent op=off_all kit=AccessibilityKit event=%{public}s", |
| 486 | + ConvertConfigIdToString(id).c_str()); | ||
| 486 | std::lock_guard<ffrt::mutex> lock(mutex_); | 487 | std::lock_guard<ffrt::mutex> lock(mutex_); |
| 487 | for (auto iter = observers_.begin(); iter != observers_.end();) { | 488 | for (auto iter = observers_.begin(); iter != observers_.end();) { |
| 488 | if ((*iter)->configId_ == id) { | 489 | if ((*iter)->configId_ == id) { |
| @@ -24,6 +24,7 @@ config("accessibility_extension_module_config") { | |||
| 24 | "../../../innerkits/acfwk/include", | 24 | "../../../innerkits/acfwk/include", |
| 25 | "include", | 25 | "include", |
| 26 | "../include", | 26 | "../include", |
| 27 | + "../../../innerkits/asacfwk/include", | ||
| 27 | ] | 28 | ] |
| 28 | 29 | ||
| 29 | defines = [ | 30 | defines = [ |
| @@ -2045,7 +2045,8 @@ void StateListenerImpl::UnsubscribeObserver(napi_env env, napi_value observer) | |||
| 2045 | 2045 | ||
| 2046 | void StateListenerImpl::UnsubscribeObservers() | 2046 | void StateListenerImpl::UnsubscribeObservers() |
| 2047 | { | 2047 | { |
| 2048 | - HILOG_INFO(); | 2048 | + HILOG_INFO("SubEvent op=off_all kit=AccessibilityKit event=%{public}s", |
| 2049 | + ConvertStateEventTypeToString(type_).c_str()); | ||
| 2049 | std::lock_guard<ffrt::mutex> lock(mutex_); | 2050 | std::lock_guard<ffrt::mutex> lock(mutex_); |
| 2050 | for (auto iter = observers_.begin(); iter != observers_.end();) { | 2051 | for (auto iter = observers_.begin(); iter != observers_.end();) { |
| 2051 | DeleteObserverReference((*iter)->env_, *iter); | 2052 | DeleteObserverReference((*iter)->env_, *iter); |
| @@ -15,6 +15,8 @@ | |||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | + | ||
| 19 | + | ||
| 18 | 20 | ||
| 19 | 21 | ||
| 20 | 22 | ||
| @@ -2179,5 +2181,58 @@ bool ConvertStringToInt64(std::string &str, int64_t &value) | |||
| 2179 | auto [ptr, errCode] = std::from_chars(str.data(), str.data() + str.size(), value); | 2181 | auto [ptr, errCode] = std::from_chars(str.data(), str.data() + str.size(), value); |
| 2180 | return errCode == std::errc{} && ptr == str.data() + str.size(); | 2182 | return errCode == std::errc{} && ptr == str.data() + str.size(); |
| 2181 | } | 2183 | } |
| 2184 | + | ||
| 2185 | +std::string ConvertStateEventTypeToString(OHOS::Accessibility::AccessibilityStateEventType type) | ||
| 2186 | +{ | ||
| 2187 | + static const std::map<AccessibilityStateEventType, const std::string> stateEventTable = { | ||
| 2188 | + {AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED, "accessibilityStateChange"}, | ||
| 2189 | + {AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED, "touchGuideStateChange"}, | ||
| 2190 | + {AccessibilityStateEventType::EVENT_SCREEN_READER_STATE_CHANGED, "screenReaderStateChange"}, | ||
| 2191 | + {AccessibilityStateEventType::EVENT_TOUCH_MODE_CHANGED, "touchModeChange"}, | ||
| 2192 | + {AccessibilityStateEventType::EVENT_AUDIO_MONO, "audioMonoStateChange"}, | ||
| 2193 | + {AccessibilityStateEventType::EVENT_ANIMATION_OFF, "animationReduceStateChange"}, | ||
| 2194 | + {AccessibilityStateEventType::EVENT_FLASH_REMINDER_SWITCH, "flashReminderStateChange"}, | ||
| 2195 | + {AccessibilityStateEventType::EVENT_ELDER_CARE_ENABLED, "seniorModeStateChange"}, | ||
| 2196 | + {AccessibilityStateEventType::EVENT_SELF_SENIOR_MODE_STATE_CHANGE, "seniorModeStateChangeForSelf"}, | ||
| 2197 | + }; | ||
| 2198 | + | ||
| 2199 | + if (stateEventTable.find(type) == stateEventTable.end()) { | ||
| 2200 | + return ""; | ||
| 2201 | + } | ||
| 2202 | + | ||
| 2203 | + return stateEventTable.at(type); | ||
| 2204 | +} | ||
| 2205 | + | ||
| 2206 | +std::string ConvertConfigIdToString(CONFIG_ID configId) | ||
| 2207 | +{ | ||
| 2208 | + static const std::map<CONFIG_ID, const std::string> configIdTable = { | ||
| 2209 | + {CONFIG_HIGH_CONTRAST_TEXT, "highContrastText"}, | ||
| 2210 | + {CONFIG_INVERT_COLOR, "invertColor"}, | ||
| 2211 | + {CONFIG_DALTONIZATION_COLOR_FILTER, "daltonizationColorFilter"}, | ||
| 2212 | + {CONFIG_CONTENT_TIMEOUT, "contentTimeout"}, | ||
| 2213 | + {CONFIG_ANIMATION_OFF, "animationOff"}, | ||
| 2214 | + {CONFIG_BRIGHTNESS_DISCOUNT, "brightnessDiscount"}, | ||
| 2215 | + {CONFIG_AUDIO_MONO, "audioMono"}, | ||
| 2216 | + {CONFIG_AUDIO_BALANCE, "audioBalance"}, | ||
| 2217 | + {CONFIG_MOUSE_KEY, "mouseKey"}, | ||
| 2218 | + {CONFIG_SHORT_KEY, "shortkey"}, | ||
| 2219 | + {CONFIG_CAPTION_STATE, "captions"}, | ||
| 2220 | + {CONFIG_CAPTION_STYLE, "captionsStyle"}, | ||
| 2221 | + {CONFIG_SCREEN_MAGNIFICATION, "screenMagnification"}, | ||
| 2222 | + {CONFIG_SHORT_KEY_TARGET, "shortkeyTarget"}, | ||
| 2223 | + {CONFIG_MOUSE_AUTOCLICK, "mouseAutoClick"}, | ||
| 2224 | + {CONFIG_DALTONIZATION_STATE, "daltonizationState"}, | ||
| 2225 | + {CONFIG_CLICK_RESPONSE_TIME, "clickResponseTime"}, | ||
| 2226 | + {CONFIG_IGNORE_REPEAT_CLICK_STATE, "ignoreRepeatClick"}, | ||
| 2227 | + {CONFIG_IGNORE_REPEAT_CLICK_TIME, "repeatClickInterval"}, | ||
| 2228 | + {CONFIG_SHORT_KEY_MULTI_TARGET, "shortkeyMultiTargets"} | ||
| 2229 | + }; | ||
| 2230 | + | ||
| 2231 | + if (configIdTable.find(configId) == configIdTable.end()) { | ||
| 2232 | + return ""; | ||
| 2233 | + } | ||
| 2234 | + | ||
| 2235 | + return configIdTable.at(configId); | ||
| 2236 | +} | ||
| 2182 | } // namespace AccessibilityNapi | 2237 | } // namespace AccessibilityNapi |
| 2183 | } // namespace OHOS | 2238 | } // namespace OHOS |