• 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 GEO_CONVERT_SERVICE_H
17 #define GEO_CONVERT_SERVICE_H
18 
19 #include <mutex>
20 #include <singleton.h>
21 #include <string>
22 #include <vector>
23 
24 #include "if_system_ability_manager.h"
25 #include "iremote_object.h"
26 #include "message_parcel.h"
27 #include "message_option.h"
28 #include "system_ability.h"
29 
30 #include "common_utils.h"
31 #include "constant_definition.h"
32 #include "geo_coding_mock_info.h"
33 #include "geo_convert_skeleton.h"
34 
35 namespace OHOS {
36 namespace Location {
37 class GeoConvertService : public SystemAbility, public GeoConvertServiceStub, DelayedSingleton<GeoConvertService> {
38 DECLEAR_SYSTEM_ABILITY(GeoConvertService);
39 
40 public:
41     DISALLOW_COPY_AND_MOVE(GeoConvertService);
42     GeoConvertService();
43     ~GeoConvertService() override;
44     void OnStart() override;
45     void OnStop() override;
QueryServiceState()46     ServiceRunningState QueryServiceState() const
47     {
48         return state_;
49     }
50     int IsGeoConvertAvailable(MessageParcel &reply) override;
51     int GetAddressByCoordinate(MessageParcel &data, MessageParcel &reply) override;
52     int GetAddressByLocationName(MessageParcel &data, MessageParcel &reply) override;
53     bool EnableReverseGeocodingMock() override;
54     bool DisableReverseGeocodingMock() override;
55     LocationErrCode SetReverseGeocodingMockInfo(std::vector<std::shared_ptr<GeocodingMockInfo>>& mockInfo) override;
56     int32_t Dump(int32_t fd, const std::vector<std::u16string>& args) override;
57 private:
58     bool Init();
59     static void SaDumpInfo(std::string& result);
60     int RemoteToService(uint32_t code, MessageParcel &data, MessageParcel &rep);
61     void ReportAddressMock(MessageParcel &data, MessageParcel &reply);
62 
63     bool mockEnabled_ = false;
64     bool registerToService_ = false;
65     ServiceRunningState state_ = ServiceRunningState::STATE_NOT_START;
66     sptr<IRemoteObject> locationService_;
67     std::vector<std::shared_ptr<GeocodingMockInfo>> mockInfo_;
68     std::mutex mockInfoMutex_;
69 };
70 } // namespace OHOS
71 } // namespace Location
72 #endif // GEO_CONVERT_SERVICE_H
73