• 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 "geo_convert_skeleton.h"
22 #include "if_system_ability_manager.h"
23 #include "system_ability.h"
24 #include "common_utils.h"
25 
26 namespace OHOS {
27 namespace Location {
28 class GeoConvertService : public SystemAbility, public GeoConvertServiceStub, DelayedSingleton<GeoConvertService> {
29 DECLEAR_SYSTEM_ABILITY(GeoConvertService);
30 
31 public:
32     DISALLOW_COPY_AND_MOVE(GeoConvertService);
33     GeoConvertService();
34     ~GeoConvertService();
35     void OnStart() override;
36     void OnStop() override;
QueryServiceState()37     ServiceRunningState QueryServiceState() const
38     {
39         return state_;
40     }
41     int IsGeoConvertAvailable(MessageParcel &data, MessageParcel &rep) override;
42     int GetAddressByCoordinate(MessageParcel &data, MessageParcel &rep) override;
43     int GetAddressByLocationName(MessageParcel &data, MessageParcel &rep) override;
44     int32_t Dump(int32_t fd, const std::vector<std::u16string>& args) override;
45 private:
46     static void SaDumpInfo(std::string& result);
47     int RemoteToService(uint32_t code, MessageParcel &data, MessageParcel &rep);
48     bool Init();
49 
50     bool registerToService_ = false;
51     ServiceRunningState state_ = ServiceRunningState::STATE_NOT_START;
52     sptr<IRemoteObject> locationService_;
53 };
54 } // namespace OHOS
55 } // namespace Location
56 #endif // GEO_CONVERT_SERVICE_H
57