1/* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef CONSTANT_DEFINITION_H 17#define CONSTANT_DEFINITION_H 18 19#include <string> 20 21namespace OHOS { 22namespace Location { 23// error type 24const int ERROR_PERMISSION_NOT_GRANTED = 0x0100; 25const int ERROR_SWITCH_UNOPEN = 0x0101; 26const int SESSION_START = 0x0002; 27const int SESSION_STOP = 0x0003; 28const int SUCCESS_CALLBACK = 0; 29const int FAIL_CALLBACK = 1; 30const int COMPLETE_CALLBACK = 2; 31const int32_t PARAM0 = 0; 32const int32_t PARAM1 = 1; 33const int32_t PARAM2 = 2; 34const int32_t PARAM3 = 3; 35const int32_t MAXIMUM_JS_PARAMS = 10; 36const int32_t MAX_CALLBACK_NUM = 3; 37const size_t RESULT_SIZE = 2; 38const int DEFAULT_TIMEOUT_30S = 30000; 39const int DEFAULT_TIMEOUT_5S = 5000; 40const double DEFAULT_APPROXIMATELY_ACCURACY = 5000.0; 41const int STATE_OPEN = 1; 42const int STATE_CLOSE = 0; 43const int PRIVACY_TYPE_OTHERS = 0; 44const int PRIVACY_TYPE_STARTUP = 1; 45const int PRIVACY_TYPE_CORE_LOCATION = 2; 46const int32_t UNKNOW_USER_ID = -1; 47const int32_t SUBSCRIBE_TIME = 5; 48const int32_t DEFAULT_TIME_INTERVAL = 30 * 60; // app receive location every 30 minutes in frozen state 49const int32_t REQUESTS_NUM_MAX = 1; 50constexpr const char* FEATURE_SWITCH_PROP = "ro.config.locator_background"; 51constexpr const char* TIME_INTERVAL_PROP = "ro.config.locator_background.timeInterval"; 52constexpr const char* PROC_NAME = "system"; 53constexpr const char* LOCALE_KEY = "persist.global.locale"; 54constexpr const char* LOCATION_SWITCH_MODE = "persist.location.switch_mode"; 55constexpr const char* LOCATION_LOCATIONHUB_STATE = "persist.location.locationhub_state"; 56const int MODE_STANDALONE = 1; 57const int MODE_MS_BASED = 2; 58const int MODE_MS_ASSISTED = 3; 59const int DEFAULT_CALLBACK_WAIT_TIME = 10000; 60const int COORDINATE_SYSTEM_TYPE_SIZE = 2; 61// fence extension const start 62constexpr const char *EXTENSION_SURVIVE_TIME = "EXTENSION_SURVIVE_TIME"; 63constexpr const char *EXTENSION_PARAM_KEY_FENCE_ID = "FENCE_ID"; 64constexpr const char *EXTENSION_PARAM_KEY_FENCE_EVENT = "FENCE_EVENT"; 65// fence extension const end 66 67enum { 68 SCENE_UNSET = 0x0300, 69 SCENE_NAVIGATION = 0x0301, 70 SCENE_TRAJECTORY_TRACKING = 0x0302, 71 SCENE_CAR_HAILING = 0x0303, 72 SCENE_DAILY_LIFE_SERVICE = 0x0304, 73 SCENE_NO_POWER = 0x0305 74}; 75 76enum { 77 PRIORITY_UNSET = 0x0200, 78 PRIORITY_ACCURACY = 0x0201, 79 PRIORITY_LOW_POWER = 0x0202, 80 PRIORITY_FAST_FIRST_FIX = 0x0203 81}; 82 83enum { 84 LOCATION_SCENE_NAVIGATION = 0x0401, 85 LOCATION_SCENE_SPORT = 0x0402, 86 LOCATION_SCENE_TRANSPORT = 0x0403, 87 LOCATION_SCENE_DAILY_LIFE_SERVICE = 0x0404, 88 LOCATION_SCENE_WALK = 0x0405, 89 LOCATION_SCENE_RIDE = 0x0406, 90}; 91 92enum { 93 LOCATION_PRIORITY_ACCURACY = 0x0501, 94 LOCATION_PRIORITY_LOCATING_SPEED = 0x0502, 95}; 96 97enum { 98 LOCATION_SCENE_HIGH_POWER_CONSUMPTION = 0x0601, 99 LOCATION_SCENE_LOW_POWER_CONSUMPTION = 0x0602, 100 LOCATION_SCENE_NO_POWER_CONSUMPTION = 0x0603, 101}; 102 103 104enum { 105 COUNTRY_CODE_FROM_LOCALE = 1, 106 COUNTRY_CODE_FROM_SIM, 107 COUNTRY_CODE_FROM_LOCATION, 108 COUNTRY_CODE_FROM_NETWORK, 109}; 110 111enum NlpRequestType { 112 PRIORITY_TYPE_BALANCED_POWER_ACCURACY = 102, // NLP 113 PRIORITY_TYPE_INDOOR = 300, // indoor 114}; 115 116enum LocationErrCode { 117 ERRCODE_SUCCESS = 0, /* SUCCESS. */ 118 ERRCODE_PERMISSION_DENIED = 201, /* Permission denied. */ 119 ERRCODE_SYSTEM_PERMISSION_DENIED = 202, /* System API is not allowed called by third HAP. */ 120 ERRCODE_EDM_POLICY_ABANDON = 203, /* This feature is prohibited by enterprise management policies. */ 121 ERRCODE_INVALID_PARAM = 401, /* Parameter error. */ 122 ERRCODE_NOT_SUPPORTED = 801, /* Capability not supported. */ 123 ERRCODE_SERVICE_UNAVAILABLE = 3301000, /* Location service is unavailable. */ 124 ERRCODE_SWITCH_OFF = 3301100, /* The location switch is off. */ 125 ERRCODE_LOCATING_FAIL = 3301200, /* Failed to obtain the geographical location. */ 126 ERRCODE_REVERSE_GEOCODING_FAIL = 3301300, /* Reverse geocoding query failed */ 127 ERRCODE_GEOCODING_FAIL = 3301400, /* Geocoding query failed */ 128 ERRCODE_COUNTRYCODE_FAIL = 3301500, /* Failed to query the area information */ 129 ERRCODE_GEOFENCE_FAIL = 3301600, /* Failed to operate the geofence */ 130 ERRCODE_NO_RESPONSE = 3301700, /* No response to the request */ 131 ERRCODE_SCAN_FAIL = 3301800, /* Failed to start WiFi or Bluetooth scanning. */ 132 ERRCODE_GEOFENCE_EXCEED_MAXIMUM = 3301601, /* The number of geofences exceeds the maximum. */ 133 ERRCODE_GEOFENCE_INCORRECT_ID = 3301602 /* Failed to delete a geofence due to an incorrect ID. */ 134}; 135 136enum FenceExtensionErrCode { 137 EXTENSION_SUCCESS = 0, 138 EXTENSION_IS_NOT_EXIST, 139 CONNECT_ABILITY_FAILED, 140 CONNECT_ABILITY_TIMEOUT, 141 CONNECT_PROXY_IS_NULL, 142 CONNECT_EXTENSION_PROXY_IS_NULL, 143 PARAM_ERROR, 144 NOT_FOUND_ABILITY_BY_TID, 145 DISCONNECT_ABILITY_FAILED, 146 DISCONNECT_ABILITY_TIMEOUT, 147 EXTENSION_REMOTE_WRITE_FAILED, 148 EXTENSION_REMOTE_SEND_FAILED, 149 EXTENSION_REMOTE_STUB_IS_NULL, 150 EXTENSION_JS_OBJ_IS_NULL, 151 EXTENSION_JS_RUNTIME_IS_NULL, 152 EXTENSION_JS_NOT_FOUND_METHOD, 153 EXTENSION_JS_CREATE_PARAM_ERROR, 154 EXTENSION_JS_CALL_FAILED 155}; 156 157enum SatelliteConstellation { 158 SV_CONSTELLATION_CATEGORY_UNKNOWN = 0, 159 SV_CONSTELLATION_CATEGORY_GPS, 160 SV_CONSTELLATION_CATEGORY_SBAS, 161 SV_CONSTELLATION_CATEGORY_GLONASS, 162 SV_CONSTELLATION_CATEGORY_QZSS, 163 SV_CONSTELLATION_CATEGORY_BEIDOU, 164 SV_CONSTELLATION_CATEGORY_GALILEO, 165 SV_CONSTELLATION_CATEGORY_IRNSS, 166}; 167 168enum SatelliteAdditionalInfo { 169 SV_ADDITIONAL_INFO_NULL = 0, 170 SV_ADDITIONAL_INFO_EPHEMERIS_DATA_EXIST = 1, 171 SV_ADDITIONAL_INFO_ALMANAC_DATA_EXIST = 2, 172 SV_ADDITIONAL_INFO_USED_IN_FIX = 4, 173 SV_ADDITIONAL_INFO_CARRIER_FREQUENCY_EXIST = 8, 174}; 175 176enum LocationErr { 177 LOCATING_FAILED_DEFAULT = -1, 178 LOCATING_FAILED_LOCATION_PERMISSION_DENIED = -2, 179 LOCATING_FAILED_BACKGROUND_PERMISSION_DENIED = -3, 180 LOCATING_FAILED_LOCATION_SWITCH_OFF = -4, 181 LOCATING_FAILED_INTERNET_ACCESS_FAILURE = -5, 182}; 183 184enum LocatingRequiredDataType { 185 WIFI = 1, 186 BLUE_TOOTH, 187}; 188 189enum LocationSourceType { 190 GNSS_TYPE = 1, 191 NETWORK_TYPE = 2, 192 INDOOR_TYPE = 3, 193 RTK_TYPE = 4, 194}; 195 196typedef struct { 197 int reportingPeriodSec; 198 bool wakeUpCacheQueueFull; 199} CachedGnssLocationsRequest; 200 201typedef struct { 202 int scenario; 203 std::string command; 204} LocationCommand; 205 206typedef struct { 207 std::string locale; 208 double latitude; 209 double longitude; 210 int maxItems; 211} ReverseGeocodeRequest; 212} // namespace Location 213} // namespace OHOS 214#endif // CONSTANT_DEFINITION_H 215