• 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 size_t RESULT_SIZE = 2;
36 const int DEFAULT_TIMEOUT_30S = 30000;
37 const int DEFAULT_APPROXIMATELY_ACCURACY = 5000;
38 const int STATE_OPEN = 1;
39 const int STATE_CLOSE = 0;
40 const int PRIVACY_TYPE_OTHERS = 0;
41 const int PRIVACY_TYPE_STARTUP = 1;
42 const int PRIVACY_TYPE_CORE_LOCATION = 2;
43 const int32_t UNKNOW_USER_ID = -1;
44 const int32_t SUBSCRIBE_TIME = 5;
45 const int32_t DEFAULT_TIME_INTERVAL = 30 * 60; // app receive location every 30 minutes in frozen state
46 const int32_t REQUESTS_NUM_MAX = 1;
47 const std::string FEATURE_SWITCH_PROP = "ro.config.locator_background";
48 const std::string TIME_INTERVAL_PROP = "ro.config.locator_background.timeInterval";
49 const std::string PROC_NAME = "system";
50 const std::string SEARCH_NET_WORK_STATE_CHANGE_ACTION = "com.hos.action.SEARCH_NET_WORK_STATE_CHANGE";
51 const std::string SIM_STATE_CHANGE_ACTION = "com.hos.action.SIM_STATE_CHANGE";
52 const std::string LOCALE_KEY = "persist.global.locale";
53 
54 enum {
55     SCENE_UNSET = 0x0300,
56     SCENE_NAVIGATION = 0x0301,
57     SCENE_TRAJECTORY_TRACKING = 0x0302,
58     SCENE_CAR_HAILING = 0x0303,
59     SCENE_DAILY_LIFE_SERVICE = 0x0304,
60     SCENE_NO_POWER = 0x0305
61 };
62 
63 enum {
64     PRIORITY_UNSET = 0x0200,
65     PRIORITY_ACCURACY = 0x0201,
66     PRIORITY_LOW_POWER = 0x0202,
67     PRIORITY_FAST_FIRST_FIX = 0x0203
68 };
69 
70 enum {
71     COUNTRY_CODE_FROM_LOCALE = 1,
72     COUNTRY_CODE_FROM_SIM,
73     COUNTRY_CODE_FROM_LOCATION,
74     COUNTRY_CODE_FROM_NETWORK,
75 };
76 
77 enum LocationRequestType {
78     PRIORITY_TYPE_HIGH_ACCURACY = 100,            // GNSS + NLP
79     PRIORITY_TYPE_BALANCED_POWER_ACCURACY = 102,  // NLP
80     PRIORITY_TYPE_LOW_POWER = 104,                // NLP
81     PRIORITY_TYPE_NO_POWER = 105,                 // passive
82     PRIORITY_TYPE_HD_ACCURACY = 200,              // HD
83     PRIORITY_TYPE_INDOOR = 300,                   // indoor
84     PRIORITY_TYPE_HIGH_ACCURACY_AND_INDOOR = 400  // indoor + GNSS
85 };
86 
87 enum LocationErrCode {
88     ERRCODE_SUCCESS = 0,                      /* SUCCESS. */
89     ERRCODE_PERMISSION_DENIED = 201,          /* Permission denied. */
90     ERRCODE_SYSTEM_PERMISSION_DENIED = 202,   /* System API is not allowed called by third HAP. */
91     ERRCODE_INVALID_PARAM = 401,              /* Parameter error. */
92     ERRCODE_NOT_SUPPORTED = 801,              /* Capability not supported. */
93     ERRCODE_SERVICE_UNAVAILABLE = 3301000,    /* Location service is unavailable. */
94     ERRCODE_SWITCH_OFF = 3301100,             /* The location switch is off. */
95     ERRCODE_LOCATING_FAIL = 3301200,          /* Failed to obtain the geographical location. */
96     ERRCODE_REVERSE_GEOCODING_FAIL = 3301300, /* Reverse geocoding query failed */
97     ERRCODE_GEOCODING_FAIL = 3301400,         /* Geocoding query failed */
98     ERRCODE_COUNTRYCODE_FAIL  = 3301500,      /* Failed to query the area information */
99     ERRCODE_GEOFENCE_FAIL = 3301600,          /* Failed to operate the geofence */
100     ERRCODE_NO_RESPONSE = 3301700,            /* No response to the request */
101 };
102 
103 typedef struct {
104     int reportingPeriodSec;
105     bool wakeUpCacheQueueFull;
106 } CachedGnssLocationsRequest;
107 
108 typedef struct {
109     int scenario;
110     std::string command;
111 } LocationCommand;
112 
113 typedef struct {
114     double latitude;
115     double longitude;
116     double radius;
117     double expiration;
118 } GeoFence;
119 
120 typedef struct {
121     int scenario;
122     GeoFence geofence;
123 } GeofenceRequest;
124 
125 typedef struct {
126     std::string locale;
127     double latitude;
128     double longitude;
129     int maxItems;
130 } ReverseGeocodeRequest;
131 } // namespace Location
132 } // namespace OHOS
133 #endif // CONSTANT_DEFINITION_H
134