1 /* 2 * Copyright (c) 2023 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 VIRTUALLOCATION_H 17 #define VIRTUALLOCATION_H 18 19 #include "location.h" 20 21 class VirtualLocation { 22 public: 23 static VirtualLocation& GetInstance(); 24 const int8_t* GetMockPointer() const; 25 uint32_t GetMockLen() const; 26 void SetCallBack(LocDataUpdateCallback func); 27 void SetSubscribe(bool value); 28 bool IsSubscribe() const; 29 LocDataUpdateCallback GetCallBack() const; 30 void ExecCallBack() const; 31 bool IsPostionChanged(); 32 33 // Obtains the location precision. 34 float GetAccuracy() const; 35 // Obtains the UTC time from 1970-01-01T00:00:00.000, in milliseconds. 36 uint64_t GetTime() const; 37 38 private: 39 VirtualLocation(); 40 virtual ~VirtualLocation(); 41 bool isSubsribe; 42 double longitudeChecked; 43 double latitudeChecked; 44 float accuracy; 45 int8_t* mockPointer; 46 uint32_t mockLen; 47 LocDataUpdateCallback callBack; 48 const float LOCATION_ACCURACY = 20.0; // The accuracy of location 49 const int PRECISION_BASE_NUMBER = 10; // The precision base number of longitude and latitude 50 51 void InitMockPointer(); 52 }; 53 54 #endif // VIRTUALLOCATION_H 55