• 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 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 
59 enum {
60     SCENE_UNSET = 0x0300,
61     SCENE_NAVIGATION = 0x0301,
62     SCENE_TRAJECTORY_TRACKING = 0x0302,
63     SCENE_CAR_HAILING = 0x0303,
64     SCENE_DAILY_LIFE_SERVICE = 0x0304,
65     SCENE_NO_POWER = 0x0305
66 };
67 
68 enum {
69     PRIORITY_UNSET = 0x0200,
70     PRIORITY_ACCURACY = 0x0201,
71     PRIORITY_LOW_POWER = 0x0202,
72     PRIORITY_FAST_FIRST_FIX = 0x0203
73 };
74 
75 enum {
76     COUNTRY_CODE_FROM_LOCALE = 1,
77     COUNTRY_CODE_FROM_SIM,
78     COUNTRY_CODE_FROM_LOCATION,
79     COUNTRY_CODE_FROM_NETWORK,
80 };
81 
82 enum LocationRequestType {
83     PRIORITY_TYPE_HIGH_ACCURACY = 100,            // GNSS + NLP
84     PRIORITY_TYPE_BALANCED_POWER_ACCURACY = 102,  // NLP
85     PRIORITY_TYPE_LOW_POWER = 104,                // NLP
86     PRIORITY_TYPE_NO_POWER = 105,                 // passive
87     PRIORITY_TYPE_HD_ACCURACY = 200,              // HD
88     PRIORITY_TYPE_INDOOR = 300,                   // indoor
89     PRIORITY_TYPE_HIGH_ACCURACY_AND_INDOOR = 400  // indoor + GNSS
90 };
91 
92 enum LocationErrCode {
93     ERRCODE_SUCCESS = 0,                      /* SUCCESS. */
94     ERRCODE_PERMISSION_DENIED = 201,          /* Permission denied. */
95     ERRCODE_SYSTEM_PERMISSION_DENIED = 202,   /* System API is not allowed called by third HAP. */
96     ERRCODE_EDM_POLICY_ABANDON = 203,         /* This feature is prohibited by enterprise management policies. */
97     ERRCODE_INVALID_PARAM = 401,              /* Parameter error. */
98     ERRCODE_NOT_SUPPORTED = 801,              /* Capability not supported. */
99     ERRCODE_SERVICE_UNAVAILABLE = 3301000,    /* Location service is unavailable. */
100     ERRCODE_SWITCH_OFF = 3301100,             /* The location switch is off. */
101     ERRCODE_LOCATING_FAIL = 3301200,          /* Failed to obtain the geographical location. */
102     ERRCODE_REVERSE_GEOCODING_FAIL = 3301300, /* Reverse geocoding query failed */
103     ERRCODE_GEOCODING_FAIL = 3301400,         /* Geocoding query failed */
104     ERRCODE_COUNTRYCODE_FAIL  = 3301500,      /* Failed to query the area information */
105     ERRCODE_GEOFENCE_FAIL = 3301600,          /* Failed to operate the geofence */
106     ERRCODE_NO_RESPONSE = 3301700,            /* No response to the request */
107     ERRCODE_SCAN_FAIL = 3301800,              /* Failed to start WiFi or Bluetooth scanning. */
108 };
109 
110 enum LocatingRequiredDataType {
111     WIFI = 1,
112     BLUE_TOOTH,
113 };
114 
115 typedef struct {
116     int reportingPeriodSec;
117     bool wakeUpCacheQueueFull;
118 } CachedGnssLocationsRequest;
119 
120 typedef struct {
121     int scenario;
122     std::string command;
123 } LocationCommand;
124 
125 typedef struct {
126     double latitude;
127     double longitude;
128     double radius;
129     double expiration;
130 } GeoFence;
131 
132 typedef struct {
133     int scenario;
134     GeoFence geofence;
135 } GeofenceRequest;
136 
137 typedef struct {
138     std::string locale;
139     double latitude;
140     double longitude;
141     int maxItems;
142 } ReverseGeocodeRequest;
143 } // namespace Location
144 } // namespace OHOS
145 #endif // CONSTANT_DEFINITION_H
146