• 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 GNSS_ABILITY_SKELETON_H
17 #define GNSS_ABILITY_SKELETON_H
18 #ifdef FEATURE_GNSS_SUPPORT
19 
20 #include "message_option.h"
21 #include "message_parcel.h"
22 #include "iremote_object.h"
23 #include "iremote_stub.h"
24 
25 #include "constant_definition.h"
26 #include "subability_common.h"
27 
28 namespace OHOS {
29 namespace Location {
30 class IGnssAbility : public ISubAbility {
31 public:
32     DECLARE_INTERFACE_DESCRIPTOR(u"location.IGnssAbility");
33     virtual LocationErrCode RefrashRequirements() = 0;
34     virtual LocationErrCode RegisterGnssStatusCallback(const sptr<IRemoteObject>& callback, pid_t uid) = 0;
35     virtual LocationErrCode UnregisterGnssStatusCallback(const sptr<IRemoteObject>& callback) = 0;
36     virtual LocationErrCode RegisterNmeaMessageCallback(const sptr<IRemoteObject>& callback, pid_t uid) = 0;
37     virtual LocationErrCode UnregisterNmeaMessageCallback(const sptr<IRemoteObject>& callback) = 0;
38     virtual LocationErrCode RegisterCachedCallback(const std::unique_ptr<CachedGnssLocationsRequest>& request,
39         const sptr<IRemoteObject>& callback) = 0;
40     virtual LocationErrCode UnregisterCachedCallback(const sptr<IRemoteObject>& callback) = 0;
41 
42     virtual LocationErrCode GetCachedGnssLocationsSize(int &size) = 0;
43     virtual LocationErrCode FlushCachedGnssLocations() = 0;
44     virtual LocationErrCode SendCommand(std::unique_ptr<LocationCommand>& commands) = 0;
45     virtual LocationErrCode AddFence(std::unique_ptr<GeofenceRequest>& request) = 0;
46     virtual LocationErrCode RemoveFence(std::unique_ptr<GeofenceRequest>& request) = 0;
47 };
48 
49 class GnssAbilityStub : public IRemoteStub<IGnssAbility> {
50 public:
51     int32_t OnRemoteRequest(uint32_t code,
52         MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
53     virtual void SendMessage(uint32_t code, MessageParcel &data, MessageParcel &reply) = 0;
54     virtual void UnloadGnssSystemAbility() = 0;
55 };
56 
57 class GnssStatusCallbackDeathRecipient : public IRemoteObject::DeathRecipient {
58 public:
59     void OnRemoteDied(const wptr<IRemoteObject> &remote) override;
60     GnssStatusCallbackDeathRecipient();
61     ~GnssStatusCallbackDeathRecipient() override;
62 };
63 
64 class NmeaCallbackDeathRecipient : public IRemoteObject::DeathRecipient {
65 public:
66     void OnRemoteDied(const wptr<IRemoteObject> &remote) override;
67     NmeaCallbackDeathRecipient();
68     ~NmeaCallbackDeathRecipient() override;
69 };
70 
71 class CachedLocationCallbackDeathRecipient : public IRemoteObject::DeathRecipient {
72 public:
73     void OnRemoteDied(const wptr<IRemoteObject> &remote) override;
74     CachedLocationCallbackDeathRecipient();
75     ~CachedLocationCallbackDeathRecipient() override;
76 };
77 } // namespace Location
78 } // namespace OHOS
79 #endif // FEATURE_GNSS_SUPPORT
80 #endif // GNSS_ABILITY_SKELETON_H
81