1885b47fbSopenharmony_ci/* 2885b47fbSopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd. 3885b47fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4885b47fbSopenharmony_ci * you may not use this file except in compliance with the License. 5885b47fbSopenharmony_ci * You may obtain a copy of the License at 6885b47fbSopenharmony_ci * 7885b47fbSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8885b47fbSopenharmony_ci * 9885b47fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10885b47fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11885b47fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12885b47fbSopenharmony_ci * See the License for the specific language governing permissions and 13885b47fbSopenharmony_ci * limitations under the License. 14885b47fbSopenharmony_ci */ 15885b47fbSopenharmony_ci 16885b47fbSopenharmony_ci#ifndef ACCESSIBILITY_UTILS_H 17885b47fbSopenharmony_ci#define ACCESSIBILITY_UTILS_H 18885b47fbSopenharmony_ci 19885b47fbSopenharmony_ci#include "accessibility_ability_info.h" 20885b47fbSopenharmony_ci#include "element_name.h" 21885b47fbSopenharmony_ci#include "extension_ability_info.h" 22885b47fbSopenharmony_ci 23885b47fbSopenharmony_cinamespace OHOS { 24885b47fbSopenharmony_cinamespace Accessibility { 25885b47fbSopenharmony_cienum class TraceTaskId : int32_t { 26885b47fbSopenharmony_ci ACCESSIBLE_ABILITY_CONNECT = 0, 27885b47fbSopenharmony_ci}; 28885b47fbSopenharmony_ci 29885b47fbSopenharmony_cienum class A11yUnavailableEvent : uint32_t { 30885b47fbSopenharmony_ci READ_EVENT, 31885b47fbSopenharmony_ci CONNECT_EVENT, 32885b47fbSopenharmony_ci QUERY_EVENT, 33885b47fbSopenharmony_ci}; 34885b47fbSopenharmony_ci 35885b47fbSopenharmony_cienum class A11yError : uint32_t { 36885b47fbSopenharmony_ci ERROR_NEED_REPORT_BASE = 1000, // error code > 1000 means need report 37885b47fbSopenharmony_ci ERROR_READ_FAILED, 38885b47fbSopenharmony_ci ERROR_CONNECT_A11Y_APPLICATION_FAILED, 39885b47fbSopenharmony_ci ERROR_A11Y_APPLICATION_DISCONNECT_ABNORMALLY, 40885b47fbSopenharmony_ci ERROR_CONNECT_TARGET_APPLICATION_FAILED, 41885b47fbSopenharmony_ci ERROR_TARGET_APPLICATION_DISCONNECT_ABNORMALLY, 42885b47fbSopenharmony_ci ERROR_QUERY_WINDOW_INFO_FAILED, 43885b47fbSopenharmony_ci ERROR_QUERY_PACKAGE_INFO_FAILED, 44885b47fbSopenharmony_ci ERROR_NEED_REPORT_END, 45885b47fbSopenharmony_ci}; 46885b47fbSopenharmony_ci 47885b47fbSopenharmony_ciclass Utils { 48885b47fbSopenharmony_cipublic: 49885b47fbSopenharmony_ci static void Parse(const AppExecFwk::ExtensionAbilityInfo &abilityInfo, AccessibilityAbilityInitParams &initParams); 50885b47fbSopenharmony_ci static int64_t GetSystemTime(); 51885b47fbSopenharmony_ci static std::string GetUri(const OHOS::AppExecFwk::ElementName &elementName); 52885b47fbSopenharmony_ci static std::string GetUri(const std::string &bundleName, const std::string &abilityName); 53885b47fbSopenharmony_ci static std::string GetAbilityAutoStartStateKey(const std::string &bundleName, const std::string &abilityName, 54885b47fbSopenharmony_ci int32_t accountId); 55885b47fbSopenharmony_ci static void SelectUsefulFromVecWithSameBundle(std::vector<std::string> &selectVec, std::vector<std::string> &cmpVec, 56885b47fbSopenharmony_ci bool &hasDif, const std::string &bundleName); 57885b47fbSopenharmony_ci static void RecordUnavailableEvent(A11yUnavailableEvent event, A11yError errCode, 58885b47fbSopenharmony_ci const std::string &bundleName = "", const std::string &abilityName = ""); 59885b47fbSopenharmony_ci static void RecordStartingA11yEvent(uint32_t flag); 60885b47fbSopenharmony_ci static void RecordStartingA11yEvent(const std::string &name); 61885b47fbSopenharmony_ci static void VectorToString(const std::vector<std::string> &vectorVal, std::string &stringOut); 62885b47fbSopenharmony_ci static void StringToVector(const std::string &stringIn, std::vector<std::string> &vectorResult); 63885b47fbSopenharmony_ci static int32_t GetUserIdByCallingUid(); 64885b47fbSopenharmony_ci 65885b47fbSopenharmony_ciprivate: 66885b47fbSopenharmony_ci static std::string TransferUnavailableEventToString(A11yUnavailableEvent type); 67885b47fbSopenharmony_ci}; 68885b47fbSopenharmony_ci} // namespace Accessibility 69885b47fbSopenharmony_ci} // namespace OHOS 70885b47fbSopenharmony_ci#endif // ACCESSIBILITY_UTILS_H