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  const int MODE_STANDALONE = 1;
57  const int MODE_MS_BASED = 2;
58  const int MODE_MS_ASSISTED = 3;
59  const int DEFAULT_CALLBACK_WAIT_TIME = 10000;
60  const int COORDINATE_SYSTEM_TYPE_SIZE = 2;
61  // fence extension const start
62  constexpr const char *EXTENSION_SURVIVE_TIME = "EXTENSION_SURVIVE_TIME";
63  constexpr const char *EXTENSION_PARAM_KEY_FENCE_ID = "FENCE_ID";
64  constexpr const char *EXTENSION_PARAM_KEY_FENCE_EVENT = "FENCE_EVENT";
65  // fence extension const end
66  
67  enum {
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  
76  enum {
77      PRIORITY_UNSET = 0x0200,
78      PRIORITY_ACCURACY = 0x0201,
79      PRIORITY_LOW_POWER = 0x0202,
80      PRIORITY_FAST_FIRST_FIX = 0x0203
81  };
82  
83  enum {
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  
92  enum {
93      LOCATION_PRIORITY_ACCURACY = 0x0501,
94      LOCATION_PRIORITY_LOCATING_SPEED = 0x0502,
95  };
96  
97  enum {
98      LOCATION_SCENE_HIGH_POWER_CONSUMPTION = 0x0601,
99      LOCATION_SCENE_LOW_POWER_CONSUMPTION = 0x0602,
100      LOCATION_SCENE_NO_POWER_CONSUMPTION = 0x0603,
101  };
102  
103  
104  enum {
105      COUNTRY_CODE_FROM_LOCALE = 1,
106      COUNTRY_CODE_FROM_SIM,
107      COUNTRY_CODE_FROM_LOCATION,
108      COUNTRY_CODE_FROM_NETWORK,
109  };
110  
111  enum NlpRequestType {
112      PRIORITY_TYPE_BALANCED_POWER_ACCURACY = 102,  // NLP
113      PRIORITY_TYPE_INDOOR = 300,                   // indoor
114  };
115  
116  enum 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_WIFI_IS_NOT_CONNECTED = 3301900,
133          /* Failed to obtain the hotpot MAC address because the Wi-Fi is not connected. */
134      ERRCODE_GEOFENCE_EXCEED_MAXIMUM = 3301601, /* The number of geofences exceeds the maximum. */
135      ERRCODE_GEOFENCE_INCORRECT_ID = 3301602 /* Failed to delete a geofence due to an incorrect ID. */
136  };
137  
138  enum FenceExtensionErrCode {
139      EXTENSION_SUCCESS = 0,
140      EXTENSION_IS_NOT_EXIST,
141      CONNECT_ABILITY_FAILED,
142      CONNECT_ABILITY_TIMEOUT,
143      CONNECT_PROXY_IS_NULL,
144      CONNECT_EXTENSION_PROXY_IS_NULL,
145      PARAM_ERROR,
146      NOT_FOUND_ABILITY_BY_TID,
147      DISCONNECT_ABILITY_FAILED,
148      DISCONNECT_ABILITY_TIMEOUT,
149      EXTENSION_REMOTE_WRITE_FAILED,
150      EXTENSION_REMOTE_SEND_FAILED,
151      EXTENSION_REMOTE_STUB_IS_NULL,
152      EXTENSION_JS_OBJ_IS_NULL,
153      EXTENSION_JS_RUNTIME_IS_NULL,
154      EXTENSION_JS_NOT_FOUND_METHOD,
155      EXTENSION_JS_CREATE_PARAM_ERROR,
156      EXTENSION_JS_CALL_FAILED
157  };
158  
159  enum SatelliteConstellation {
160      SV_CONSTELLATION_CATEGORY_UNKNOWN = 0,
161      SV_CONSTELLATION_CATEGORY_GPS,
162      SV_CONSTELLATION_CATEGORY_SBAS,
163      SV_CONSTELLATION_CATEGORY_GLONASS,
164      SV_CONSTELLATION_CATEGORY_QZSS,
165      SV_CONSTELLATION_CATEGORY_BEIDOU,
166      SV_CONSTELLATION_CATEGORY_GALILEO,
167      SV_CONSTELLATION_CATEGORY_IRNSS,
168  };
169  
170  enum SatelliteAdditionalInfo {
171      SV_ADDITIONAL_INFO_NULL = 0,
172      SV_ADDITIONAL_INFO_EPHEMERIS_DATA_EXIST = 1,
173      SV_ADDITIONAL_INFO_ALMANAC_DATA_EXIST = 2,
174      SV_ADDITIONAL_INFO_USED_IN_FIX = 4,
175      SV_ADDITIONAL_INFO_CARRIER_FREQUENCY_EXIST = 8,
176  };
177  
178  enum LocationErr {
179      LOCATING_FAILED_DEFAULT = -1,
180      LOCATING_FAILED_LOCATION_PERMISSION_DENIED = -2,
181      LOCATING_FAILED_BACKGROUND_PERMISSION_DENIED = -3,
182      LOCATING_FAILED_LOCATION_SWITCH_OFF = -4,
183      LOCATING_FAILED_INTERNET_ACCESS_FAILURE = -5,
184  };
185  
186  enum LocatingRequiredDataType {
187      WIFI = 1,
188      BLUE_TOOTH,
189  };
190  
191  enum LocationSourceType {
192      GNSS_TYPE = 1,
193      NETWORK_TYPE = 2,
194      INDOOR_TYPE = 3,
195      RTK_TYPE = 4,
196  };
197  
198  typedef struct {
199      int reportingPeriodSec;
200      bool wakeUpCacheQueueFull;
201  } CachedGnssLocationsRequest;
202  
203  typedef struct {
204      int scenario;
205      std::string command;
206  } LocationCommand;
207  
208  typedef struct {
209      std::string locale;
210      double latitude;
211      double longitude;
212      int maxItems;
213  } ReverseGeocodeRequest;
214  } // namespace Location
215  } // namespace OHOS
216  #endif // CONSTANT_DEFINITION_H
217