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 21 namespace OHOS { 22 namespace Location { 23 // error type 24 const int ERROR_PERMISSION_NOT_GRANTED = 0x0100; 25 const int ERROR_SWITCH_UNOPEN = 0x0101; 26 const int SESSION_START = 0x0002; 27 const int SESSION_STOP = 0x0003; 28 const int SUCCESS_CALLBACK = 0; 29 const int FAIL_CALLBACK = 1; 30 const int COMPLETE_CALLBACK = 2; 31 const int32_t PARAM0 = 0; 32 const int32_t PARAM1 = 1; 33 const int32_t PARAM2 = 2; 34 const int32_t PARAM3 = 3; 35 const int32_t MAXIMUM_JS_PARAMS = 10; 36 const int32_t MAX_CALLBACK_NUM = 3; 37 const size_t RESULT_SIZE = 2; 38 const int DEFAULT_TIMEOUT_30S = 30000; 39 const int DEFAULT_TIMEOUT_5S = 5000; 40 const double DEFAULT_APPROXIMATELY_ACCURACY = 50.0; 41 const int STATE_OPEN = 1; 42 const int STATE_CLOSE = 0; 43 const int PRIVACY_TYPE_OTHERS = 0; 44 const int PRIVACY_TYPE_STARTUP = 1; 45 const int PRIVACY_TYPE_CORE_LOCATION = 2; 46 const int32_t UNKNOW_USER_ID = -1; 47 const int32_t SUBSCRIBE_TIME = 5; 48 const int32_t DEFAULT_TIME_INTERVAL = 30 * 60; // app receive location every 30 minutes in frozen state 49 const int32_t REQUESTS_NUM_MAX = 1; 50 constexpr const char* FEATURE_SWITCH_PROP = "ro.config.locator_background"; 51 constexpr const char* TIME_INTERVAL_PROP = "ro.config.locator_background.timeInterval"; 52 constexpr const char* PROC_NAME = "system"; 53 constexpr const char* LOCALE_KEY = "persist.global.locale"; 54 constexpr const char* LOCATION_SWITCH_MODE = "persist.location.switch_mode"; 55 constexpr const char* LOCATION_LOCATIONHUB_STATE = "persist.location.locationhub_state"; 56 constexpr const char* LOCATION_LAST_SIM_OPKEY = "persist.location.last_sim_opkey"; 57 constexpr const char* LOCATION_SIM_CONFIGURE_SWITCH = "const.location.gnss_adapt_card"; 58 const int MODE_STANDALONE = 1; 59 const int MODE_MS_BASED = 2; 60 const int MODE_MS_ASSISTED = 3; 61 const int DEFAULT_CALLBACK_WAIT_TIME = 10000; 62 const int COORDINATE_SYSTEM_TYPE_SIZE = 2; 63 // fence extension const start 64 constexpr const char *EXTENSION_SURVIVE_TIME = "EXTENSION_SURVIVE_TIME"; 65 constexpr const char *EXTENSION_PARAM_KEY_FENCE_ID = "FENCE_ID"; 66 constexpr const char *EXTENSION_PARAM_KEY_FENCE_EVENT = "FENCE_EVENT"; 67 // fence extension const end 68 69 enum { 70 SCENE_UNSET = 0x0300, 71 SCENE_NAVIGATION = 0x0301, 72 SCENE_TRAJECTORY_TRACKING = 0x0302, 73 SCENE_CAR_HAILING = 0x0303, 74 SCENE_DAILY_LIFE_SERVICE = 0x0304, 75 SCENE_NO_POWER = 0x0305 76 }; 77 78 enum { 79 PRIORITY_UNSET = 0x0200, 80 PRIORITY_ACCURACY = 0x0201, 81 PRIORITY_LOW_POWER = 0x0202, 82 PRIORITY_FAST_FIRST_FIX = 0x0203 83 }; 84 85 enum { 86 LOCATION_SCENE_NAVIGATION = 0x0401, 87 LOCATION_SCENE_SPORT = 0x0402, 88 LOCATION_SCENE_TRANSPORT = 0x0403, 89 LOCATION_SCENE_DAILY_LIFE_SERVICE = 0x0404, 90 LOCATION_SCENE_WALK = 0x0405, 91 LOCATION_SCENE_RIDE = 0x0406, 92 }; 93 94 enum { 95 LOCATION_PRIORITY_ACCURACY = 0x0501, 96 LOCATION_PRIORITY_LOCATING_SPEED = 0x0502, 97 }; 98 99 enum { 100 LOCATION_SCENE_HIGH_POWER_CONSUMPTION = 0x0601, 101 LOCATION_SCENE_LOW_POWER_CONSUMPTION = 0x0602, 102 LOCATION_SCENE_NO_POWER_CONSUMPTION = 0x0603, 103 }; 104 105 106 enum { 107 COUNTRY_CODE_FROM_LOCALE = 1, 108 COUNTRY_CODE_FROM_SIM, 109 COUNTRY_CODE_FROM_LOCATION, 110 COUNTRY_CODE_FROM_NETWORK, 111 }; 112 113 enum NlpRequestType { 114 PRIORITY_TYPE_BALANCED_POWER_ACCURACY = 102, // NLP 115 PRIORITY_TYPE_INDOOR = 300, // indoor 116 }; 117 118 enum LocationErrCode { 119 ERRCODE_SUCCESS = 0, /* SUCCESS. */ 120 ERRCODE_PERMISSION_DENIED = 201, /* Permission denied. */ 121 ERRCODE_SYSTEM_PERMISSION_DENIED = 202, /* System API is not allowed called by third HAP. */ 122 ERRCODE_EDM_POLICY_ABANDON = 203, /* This feature is prohibited by enterprise management policies. */ 123 ERRCODE_INVALID_PARAM = 401, /* Parameter error. */ 124 ERRCODE_NOT_SUPPORTED = 801, /* Capability not supported. */ 125 ERRCODE_SERVICE_UNAVAILABLE = 3301000, /* Location service is unavailable. */ 126 ERRCODE_SWITCH_OFF = 3301100, /* The location switch is off. */ 127 ERRCODE_LOCATING_FAIL = 3301200, /* Failed to obtain the geographical location. */ 128 ERRCODE_LOCATING_NETWORK_FAIL = 3301201, 129 /* The network locating is failed because the network cannot be accessed. */ 130 ERRCODE_LOCATING_ACC_FAIL = 3301203, 131 /* The positioning result does not meet the precision requirement (maxAccuracy) */ 132 /* in the positioning request parameters. */ 133 ERRCODE_LOCATING_CACHE_FAIL = 3301204, /* The system does not have a cache locaiton. */ 134 ERRCODE_REVERSE_GEOCODING_FAIL = 3301300, /* Reverse geocoding query failed */ 135 ERRCODE_GEOCODING_FAIL = 3301400, /* Geocoding query failed */ 136 ERRCODE_COUNTRYCODE_FAIL = 3301500, /* Failed to query the area information */ 137 ERRCODE_GEOFENCE_FAIL = 3301600, /* Failed to operate the geofence */ 138 ERRCODE_NO_RESPONSE = 3301700, /* No response to the request */ 139 ERRCODE_SCAN_FAIL = 3301800, /* Failed to start WiFi or Bluetooth scanning. */ 140 ERRCODE_WIFI_IS_NOT_CONNECTED = 3301900, 141 /* Failed to obtain the hotpot MAC address because the Wi-Fi is not connected. */ 142 ERRCODE_GEOFENCE_EXCEED_MAXIMUM = 3301601, /* The number of geofences exceeds the maximum. */ 143 ERRCODE_GEOFENCE_INCORRECT_ID = 3301602 /* Failed to delete a geofence due to an incorrect ID. */ 144 }; 145 146 enum FenceExtensionErrCode { 147 EXTENSION_SUCCESS = 0, 148 EXTENSION_IS_NOT_EXIST, 149 CONNECT_ABILITY_FAILED, 150 CONNECT_ABILITY_TIMEOUT, 151 CONNECT_PROXY_IS_NULL, 152 CONNECT_EXTENSION_PROXY_IS_NULL, 153 PARAM_ERROR, 154 NOT_FOUND_ABILITY_BY_TID, 155 DISCONNECT_ABILITY_FAILED, 156 DISCONNECT_ABILITY_TIMEOUT, 157 EXTENSION_REMOTE_WRITE_FAILED, 158 EXTENSION_REMOTE_SEND_FAILED, 159 EXTENSION_REMOTE_STUB_IS_NULL, 160 EXTENSION_JS_OBJ_IS_NULL, 161 EXTENSION_JS_RUNTIME_IS_NULL, 162 EXTENSION_JS_NOT_FOUND_METHOD, 163 EXTENSION_JS_CREATE_PARAM_ERROR, 164 EXTENSION_JS_CALL_FAILED 165 }; 166 167 enum SatelliteConstellation { 168 SV_CONSTELLATION_CATEGORY_UNKNOWN = 0, 169 SV_CONSTELLATION_CATEGORY_GPS, 170 SV_CONSTELLATION_CATEGORY_SBAS, 171 SV_CONSTELLATION_CATEGORY_GLONASS, 172 SV_CONSTELLATION_CATEGORY_QZSS, 173 SV_CONSTELLATION_CATEGORY_BEIDOU, 174 SV_CONSTELLATION_CATEGORY_GALILEO, 175 SV_CONSTELLATION_CATEGORY_IRNSS, 176 }; 177 178 enum SatelliteAdditionalInfo { 179 SV_ADDITIONAL_INFO_NULL = 0, 180 SV_ADDITIONAL_INFO_EPHEMERIS_DATA_EXIST = 1, 181 SV_ADDITIONAL_INFO_ALMANAC_DATA_EXIST = 2, 182 SV_ADDITIONAL_INFO_USED_IN_FIX = 4, 183 SV_ADDITIONAL_INFO_CARRIER_FREQUENCY_EXIST = 8, 184 }; 185 186 enum LocationErr { 187 LOCATING_FAILED_DEFAULT = -1, 188 LOCATING_FAILED_LOCATION_PERMISSION_DENIED = -2, 189 LOCATING_FAILED_BACKGROUND_PERMISSION_DENIED = -3, 190 LOCATING_FAILED_LOCATION_SWITCH_OFF = -4, 191 LOCATING_FAILED_INTERNET_ACCESS_FAILURE = -5, 192 }; 193 194 enum LocatingRequiredDataType { 195 WIFI = 1, 196 BLUE_TOOTH, 197 }; 198 199 enum LocationSourceType { 200 GNSS_TYPE = 1, 201 NETWORK_TYPE = 2, 202 INDOOR_TYPE = 3, 203 RTK_TYPE = 4, 204 }; 205 206 enum SportsType { 207 RUNNING = 1, 208 WALKING, 209 CYCLING, 210 }; 211 212 typedef struct { 213 int reportingPeriodSec; 214 bool wakeUpCacheQueueFull; 215 } CachedGnssLocationsRequest; 216 217 typedef struct { 218 int scenario; 219 std::string command; 220 } LocationCommand; 221 222 typedef struct { 223 std::string locale; 224 double latitude; 225 double longitude; 226 int maxItems; 227 } ReverseGeocodeRequest; 228 } // namespace Location 229 } // namespace OHOS 230 #endif // CONSTANT_DEFINITION_H 231