• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 = 5000.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     LOCATION_SCENE_INDOOR_POI = 0x0407,
93 };
94 
95 enum {
96     LOCATION_PRIORITY_ACCURACY = 0x0501,
97     LOCATION_PRIORITY_LOCATING_SPEED = 0x0502,
98 };
99 
100 enum {
101     LOCATION_SCENE_HIGH_POWER_CONSUMPTION = 0x0601,
102     LOCATION_SCENE_LOW_POWER_CONSUMPTION = 0x0602,
103     LOCATION_SCENE_NO_POWER_CONSUMPTION = 0x0603,
104 };
105 
106 
107 enum {
108     COUNTRY_CODE_FROM_LOCALE = 1,
109     COUNTRY_CODE_FROM_SIM,
110     COUNTRY_CODE_FROM_LOCATION,
111     COUNTRY_CODE_FROM_NETWORK,
112 };
113 
114 enum NlpRequestType {
115     PRIORITY_TYPE_BALANCED_POWER_ACCURACY = 102,  // NLP
116     PRIORITY_TYPE_INDOOR = 300,                   // indoor
117     PRIORITY_TYPE_INDOOR_POI = 400,               // POI
118 };
119 
120 enum LocationErrCode {
121     ERRCODE_SUCCESS = 0,                      /* SUCCESS. */
122     ERRCODE_PERMISSION_DENIED = 201,          /* Permission denied. */
123     ERRCODE_SYSTEM_PERMISSION_DENIED = 202,   /* System API is not allowed called by third HAP. */
124     ERRCODE_EDM_POLICY_ABANDON = 203,         /* This feature is prohibited by enterprise management policies. */
125     ERRCODE_INVALID_PARAM = 401,              /* Parameter error. */
126     ERRCODE_NOT_SUPPORTED = 801,              /* Capability not supported. */
127     LOCATION_ERRCODE_MIN = 3300000,
128     LOCATION_ERRCODE_PERMISSION_DENIED = 3300201,        /* Permission denied. */
129     LOCATION_ERRCODE_SYSTEM_PERMISSION_DENIED = 3300202, /* System API is not allowed called by third HAP. */
130     /* This feature is prohibited by enterprise management policies. */
131     LOCATION_ERRCODE_EDM_POLICY_ABANDON = 3300203,
132     LOCATION_ERRCODE_BACKGROUND_PERMISSION_DENIED = 3300204,
133     LOCATION_ERRCODE_BACKGROUND_CONTINUE_PERMISSION_DENIED = 3300205,
134     LOCATION_ERRCODE_NOT_CURRENT_USER_ID = 3300206,
135     LOCATION_ERRCODE_REQUEST_TIMEOUT = 3300207,
136     LOCATION_ERRCODE_DEVICE_IDLE = 3300208,
137     LOCATION_ERRCODE_USING_PERMISSION = 3300209,
138     LOCATION_ERRCODE_INVALID_PARAM = 3300401,            /* Parameter error. */
139     LOCATION_ERRCODE_NOT_SUPPORTED = 3300801,            /* Capability not supported. */
140     ERRCODE_SERVICE_UNAVAILABLE = 3301000,    /* Location service is unavailable. */
141     ERRCODE_SWITCH_OFF = 3301100,             /* The location switch is off. */
142     ERRCODE_LOCATING_FAIL = 3301200,          /* Failed to obtain the geographical location. */
143     /* The network locating is failed because the network cannot be accessed. */
144     ERRCODE_LOCATING_NETWORK_FAIL = 3301201,
145     /* The positioning result does not meet the precision requirement (maxAccuracy) */
146     /* in the positioning request parameters. */
147     ERRCODE_LOCATING_ACC_FAIL = 3301203,
148     ERRCODE_LOCATING_CACHE_FAIL = 3301204,    /* The system does not have a cache locaiton. */
149     ERRCODE_LOCATING_FREEZE = 3301205,        /* This pid has been freezed by system */
150     ERRCODE_REVERSE_GEOCODING_FAIL = 3301300, /* Reverse geocoding query failed */
151     ERRCODE_GEOCODING_FAIL = 3301400,         /* Geocoding query failed */
152     ERRCODE_COUNTRYCODE_FAIL  = 3301500,      /* Failed to query the area information */
153     ERRCODE_GEOFENCE_FAIL = 3301600,          /* Failed to operate the geofence */
154     ERRCODE_NO_RESPONSE = 3301700,            /* No response to the request */
155     ERRCODE_SCAN_FAIL = 3301800,              /* Failed to start WiFi or Bluetooth scanning. */
156     /* Failed to obtain the hotpot MAC address because the Wi-Fi is not connected. */
157     ERRCODE_WIFI_IS_NOT_CONNECTED = 3301900,
158     ERRCODE_GEOFENCE_EXCEED_MAXIMUM = 3301601, /* The number of geofences exceeds the maximum. */
159     ERRCODE_GEOFENCE_INCORRECT_ID = 3301602, /* Failed to delete a geofence due to an incorrect ID. */
160     /* Failed to add a beacon fence because the location switch is off. */
161     ERRCODE_BEACONFENCE_LOCATION_SWITCH_OFF = 3501100,
162     /* Failed to add a beacon fence because the bluetooth switch is off. */
163     ERRCODE_BEACONFENCE_BLUETOOTH_SWITCH_OFF = 3501101,
164     ERRCODE_BEACONFENCE_EXCEED_MAXIMUM = 3501601, /* The number of beacon fence exceeds the maximum. */
165     /* Failed to delete the fence due to incorrect beacon fence information. */
166     ERRCODE_BEACONFENCE_INCORRECT_ID = 3501602,
167     ERRCODE_BEACONFENCE_DUPLICATE_INFORMATION = 3501603 /* Duplicate beacon fence information. */
168 };
169 
170 enum FenceExtensionErrCode {
171     EXTENSION_SUCCESS = 0,
172     EXTENSION_IS_NOT_EXIST,
173     CONNECT_ABILITY_FAILED,
174     CONNECT_ABILITY_TIMEOUT,
175     CONNECT_PROXY_IS_NULL,
176     CONNECT_EXTENSION_PROXY_IS_NULL,
177     PARAM_ERROR,
178     NOT_FOUND_ABILITY_BY_TID,
179     DISCONNECT_ABILITY_FAILED,
180     DISCONNECT_ABILITY_TIMEOUT,
181     EXTENSION_REMOTE_WRITE_FAILED,
182     EXTENSION_REMOTE_SEND_FAILED,
183     EXTENSION_REMOTE_STUB_IS_NULL,
184     EXTENSION_JS_OBJ_IS_NULL,
185     EXTENSION_JS_RUNTIME_IS_NULL,
186     EXTENSION_JS_NOT_FOUND_METHOD,
187     EXTENSION_JS_CREATE_PARAM_ERROR,
188     EXTENSION_JS_CALL_FAILED
189 };
190 
191 enum SatelliteConstellation {
192     SV_CONSTELLATION_CATEGORY_UNKNOWN = 0,
193     SV_CONSTELLATION_CATEGORY_GPS,
194     SV_CONSTELLATION_CATEGORY_SBAS,
195     SV_CONSTELLATION_CATEGORY_GLONASS,
196     SV_CONSTELLATION_CATEGORY_QZSS,
197     SV_CONSTELLATION_CATEGORY_BEIDOU,
198     SV_CONSTELLATION_CATEGORY_GALILEO,
199     SV_CONSTELLATION_CATEGORY_IRNSS,
200 };
201 
202 enum SatelliteAdditionalInfo {
203     SV_ADDITIONAL_INFO_NULL = 0,
204     SV_ADDITIONAL_INFO_EPHEMERIS_DATA_EXIST = 1,
205     SV_ADDITIONAL_INFO_ALMANAC_DATA_EXIST = 2,
206     SV_ADDITIONAL_INFO_USED_IN_FIX = 4,
207     SV_ADDITIONAL_INFO_CARRIER_FREQUENCY_EXIST = 8,
208 };
209 
210 enum LocationErr {
211     LOCATING_FAILED_DEFAULT = -1,
212     LOCATING_FAILED_LOCATION_PERMISSION_DENIED = -2,
213     LOCATING_FAILED_BACKGROUND_PERMISSION_DENIED = -3,
214     LOCATING_FAILED_LOCATION_SWITCH_OFF = -4,
215     LOCATING_FAILED_INTERNET_ACCESS_FAILURE = -5,
216 };
217 
218 enum LocatingRequiredDataType {
219     WIFI = 1,
220     BLUE_TOOTH,
221 };
222 
223 enum LocationSourceType {
224     GNSS_TYPE = 1,
225     NETWORK_TYPE = 2,
226     INDOOR_TYPE = 3,
227     RTK_TYPE = 4,
228 };
229 
230 enum SportsType {
231     RUNNING = 1,
232     WALKING,
233     CYCLING,
234 };
235 
236 typedef struct {
237     int reportingPeriodSec;
238     bool wakeUpCacheQueueFull;
239 } CachedGnssLocationsRequest;
240 
241 typedef struct {
242     int scenario;
243     std::string command;
244 } LocationCommand;
245 
246 typedef struct {
247     std::string locale;
248     double latitude;
249     double longitude;
250     int maxItems;
251 } ReverseGeocodeRequest;
252 } // namespace Location
253 } // namespace OHOS
254 #endif // CONSTANT_DEFINITION_H
255