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