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 double DEFAULT_APPROXIMATELY_ACCURACY = 5000.0; 40 const int STATE_OPEN = 1; 41 const int STATE_CLOSE = 0; 42 const int PRIVACY_TYPE_OTHERS = 0; 43 const int PRIVACY_TYPE_STARTUP = 1; 44 const int PRIVACY_TYPE_CORE_LOCATION = 2; 45 const int32_t UNKNOW_USER_ID = -1; 46 const int32_t SUBSCRIBE_TIME = 5; 47 const int32_t DEFAULT_TIME_INTERVAL = 30 * 60; // app receive location every 30 minutes in frozen state 48 const int32_t REQUESTS_NUM_MAX = 1; 49 const std::string FEATURE_SWITCH_PROP = "ro.config.locator_background"; 50 const std::string TIME_INTERVAL_PROP = "ro.config.locator_background.timeInterval"; 51 const std::string PROC_NAME = "system"; 52 const std::string SEARCH_NET_WORK_STATE_CHANGE_ACTION = "com.hos.action.SEARCH_NET_WORK_STATE_CHANGE"; 53 const std::string SIM_STATE_CHANGE_ACTION = "com.hos.action.SIM_STATE_CHANGE"; 54 const std::string LOCALE_KEY = "persist.global.locale"; 55 const int MODE_STANDALONE = 1; 56 const int MODE_MS_BASED = 2; 57 const int MODE_MS_ASSISTED = 3; 58 const int DEFAULT_CALLBACK_WAIT_TIME = 10000; 59 const int COORDINATE_SYSTEM_TYPE_SIZE = 2; 60 61 enum { 62 SCENE_UNSET = 0x0300, 63 SCENE_NAVIGATION = 0x0301, 64 SCENE_TRAJECTORY_TRACKING = 0x0302, 65 SCENE_CAR_HAILING = 0x0303, 66 SCENE_DAILY_LIFE_SERVICE = 0x0304, 67 SCENE_NO_POWER = 0x0305 68 }; 69 70 enum { 71 PRIORITY_UNSET = 0x0200, 72 PRIORITY_ACCURACY = 0x0201, 73 PRIORITY_LOW_POWER = 0x0202, 74 PRIORITY_FAST_FIRST_FIX = 0x0203 75 }; 76 77 enum { 78 LOCATION_SCENE_NAVIGATION = 0x0401, 79 LOCATION_SCENE_SPORT = 0x0402, 80 LOCATION_SCENE_TRANSPORT = 0x0403, 81 LOCATION_SCENE_DAILY_LIFE_SERVICE = 0x0404, 82 }; 83 84 enum { 85 LOCATION_PRIORITY_ACCURACY = 0x0501, 86 LOCATION_PRIORITY_LOCATING_SPEED = 0x0502, 87 }; 88 89 enum { 90 LOCATION_SCENE_HIGH_POWER_CONSUMPTION = 0x0601, 91 LOCATION_SCENE_LOW_POWER_CONSUMPTION = 0x0602, 92 LOCATION_SCENE_NO_POWER_CONSUMPTION = 0x0603, 93 }; 94 95 96 enum { 97 COUNTRY_CODE_FROM_LOCALE = 1, 98 COUNTRY_CODE_FROM_SIM, 99 COUNTRY_CODE_FROM_LOCATION, 100 COUNTRY_CODE_FROM_NETWORK, 101 }; 102 103 enum NlpRequestType { 104 PRIORITY_TYPE_BALANCED_POWER_ACCURACY = 102, // NLP 105 PRIORITY_TYPE_INDOOR = 300, // indoor 106 }; 107 108 enum LocationErrCode { 109 ERRCODE_SUCCESS = 0, /* SUCCESS. */ 110 ERRCODE_PERMISSION_DENIED = 201, /* Permission denied. */ 111 ERRCODE_SYSTEM_PERMISSION_DENIED = 202, /* System API is not allowed called by third HAP. */ 112 ERRCODE_EDM_POLICY_ABANDON = 203, /* This feature is prohibited by enterprise management policies. */ 113 ERRCODE_INVALID_PARAM = 401, /* Parameter error. */ 114 ERRCODE_NOT_SUPPORTED = 801, /* Capability not supported. */ 115 ERRCODE_SERVICE_UNAVAILABLE = 3301000, /* Location service is unavailable. */ 116 ERRCODE_SWITCH_OFF = 3301100, /* The location switch is off. */ 117 ERRCODE_LOCATING_FAIL = 3301200, /* Failed to obtain the geographical location. */ 118 ERRCODE_REVERSE_GEOCODING_FAIL = 3301300, /* Reverse geocoding query failed */ 119 ERRCODE_GEOCODING_FAIL = 3301400, /* Geocoding query failed */ 120 ERRCODE_COUNTRYCODE_FAIL = 3301500, /* Failed to query the area information */ 121 ERRCODE_GEOFENCE_FAIL = 3301600, /* Failed to operate the geofence */ 122 ERRCODE_NO_RESPONSE = 3301700, /* No response to the request */ 123 ERRCODE_SCAN_FAIL = 3301800, /* Failed to start WiFi or Bluetooth scanning. */ 124 ERRCODE_GEOFENCE_EXCEED_MAXIMUM = 3301601, /* The number of geofences exceeds the maximum. */ 125 ERRCODE_GEOFENCE_INCORRECT_ID = 3301602 /* Failed to delete a geofence due to an incorrect ID. */ 126 }; 127 128 enum SatelliteConstellation { 129 SV_CONSTELLATION_CATEGORY_UNKNOWN = 0, 130 SV_CONSTELLATION_CATEGORY_GPS, 131 SV_CONSTELLATION_CATEGORY_SBAS, 132 SV_CONSTELLATION_CATEGORY_GLONASS, 133 SV_CONSTELLATION_CATEGORY_QZSS, 134 SV_CONSTELLATION_CATEGORY_BEIDOU, 135 SV_CONSTELLATION_CATEGORY_GALILEO, 136 SV_CONSTELLATION_CATEGORY_IRNSS, 137 }; 138 139 enum SatelliteAdditionalInfo { 140 SV_ADDITIONAL_INFO_NULL = 0, 141 SV_ADDITIONAL_INFO_EPHEMERIS_DATA_EXIST = 1, 142 SV_ADDITIONAL_INFO_ALMANAC_DATA_EXIST = 2, 143 SV_ADDITIONAL_INFO_USED_IN_FIX = 4, 144 SV_ADDITIONAL_INFO_CARRIER_FREQUENCY_EXIST = 8, 145 }; 146 147 enum LocationErr { 148 LOCATING_FAILED_DEFAULT = -1, 149 LOCATING_FAILED_LOCATION_PERMISSION_DENIED = -2, 150 LOCATING_FAILED_BACKGROUND_PERMISSION_DENIED = -3, 151 LOCATING_FAILED_LOCATION_SWITCH_OFF = -4, 152 LOCATING_FAILED_INTERNET_ACCESS_FAILURE = -5, 153 }; 154 155 enum LocatingRequiredDataType { 156 WIFI = 1, 157 BLUE_TOOTH, 158 }; 159 160 enum LocationSourceType { 161 GNSS_TYPE = 1, 162 NETWORK_TYPE = 2, 163 INDOOR_TYPE = 3, 164 RTK_TYPE = 4, 165 }; 166 167 typedef struct { 168 int reportingPeriodSec; 169 bool wakeUpCacheQueueFull; 170 } CachedGnssLocationsRequest; 171 172 typedef struct { 173 int scenario; 174 std::string command; 175 } LocationCommand; 176 177 typedef struct { 178 std::string locale; 179 double latitude; 180 double longitude; 181 int maxItems; 182 } ReverseGeocodeRequest; 183 } // namespace Location 184 } // namespace OHOS 185 #endif // CONSTANT_DEFINITION_H 186