15c735df2Sopenharmony_ci/* 25c735df2Sopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd. 35c735df2Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 45c735df2Sopenharmony_ci * you may not use this file except in compliance with the License. 55c735df2Sopenharmony_ci * You may obtain a copy of the License at 65c735df2Sopenharmony_ci * 75c735df2Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 85c735df2Sopenharmony_ci * 95c735df2Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 105c735df2Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 115c735df2Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 125c735df2Sopenharmony_ci * See the License for the specific language governing permissions and 135c735df2Sopenharmony_ci * limitations under the License. 145c735df2Sopenharmony_ci */ 155c735df2Sopenharmony_ci 165c735df2Sopenharmony_ci#ifndef GNSS_ABILITY_SKELETON_H 175c735df2Sopenharmony_ci#define GNSS_ABILITY_SKELETON_H 185c735df2Sopenharmony_ci#ifdef FEATURE_GNSS_SUPPORT 195c735df2Sopenharmony_ci#include <map> 205c735df2Sopenharmony_ci#include "message_option.h" 215c735df2Sopenharmony_ci#include "message_parcel.h" 225c735df2Sopenharmony_ci#include "iremote_object.h" 235c735df2Sopenharmony_ci#include "iremote_stub.h" 245c735df2Sopenharmony_ci 255c735df2Sopenharmony_ci#include "constant_definition.h" 265c735df2Sopenharmony_ci#include "subability_common.h" 275c735df2Sopenharmony_ci 285c735df2Sopenharmony_ci#include "app_identity.h" 295c735df2Sopenharmony_ci#include "geofence_request.h" 305c735df2Sopenharmony_ci 315c735df2Sopenharmony_cinamespace OHOS { 325c735df2Sopenharmony_cinamespace Location { 335c735df2Sopenharmony_ciclass IGnssAbility : public ISubAbility { 345c735df2Sopenharmony_cipublic: 355c735df2Sopenharmony_ci DECLARE_INTERFACE_DESCRIPTOR(u"location.IGnssAbility"); 365c735df2Sopenharmony_ci virtual LocationErrCode RefrashRequirements() = 0; 375c735df2Sopenharmony_ci virtual LocationErrCode RegisterGnssStatusCallback(const sptr<IRemoteObject>& callback, AppIdentity &identity) = 0; 385c735df2Sopenharmony_ci virtual LocationErrCode UnregisterGnssStatusCallback(const sptr<IRemoteObject>& callback) = 0; 395c735df2Sopenharmony_ci virtual LocationErrCode RegisterNmeaMessageCallback(const sptr<IRemoteObject>& callback, AppIdentity &identity) = 0; 405c735df2Sopenharmony_ci virtual LocationErrCode UnregisterNmeaMessageCallback(const sptr<IRemoteObject>& callback) = 0; 415c735df2Sopenharmony_ci virtual LocationErrCode RegisterCachedCallback(const std::unique_ptr<CachedGnssLocationsRequest>& request, 425c735df2Sopenharmony_ci const sptr<IRemoteObject>& callback) = 0; 435c735df2Sopenharmony_ci virtual LocationErrCode UnregisterCachedCallback(const sptr<IRemoteObject>& callback) = 0; 445c735df2Sopenharmony_ci 455c735df2Sopenharmony_ci virtual LocationErrCode GetCachedGnssLocationsSize(int &size) = 0; 465c735df2Sopenharmony_ci virtual LocationErrCode FlushCachedGnssLocations() = 0; 475c735df2Sopenharmony_ci virtual LocationErrCode SendCommand(std::unique_ptr<LocationCommand>& commands) = 0; 485c735df2Sopenharmony_ci virtual LocationErrCode AddFence(std::shared_ptr<GeofenceRequest>& request) = 0; 495c735df2Sopenharmony_ci virtual LocationErrCode RemoveFence(std::shared_ptr<GeofenceRequest>& request) = 0; 505c735df2Sopenharmony_ci virtual LocationErrCode AddGnssGeofence(std::shared_ptr<GeofenceRequest>& request) = 0; 515c735df2Sopenharmony_ci virtual LocationErrCode RemoveGnssGeofence(std::shared_ptr<GeofenceRequest>& request) = 0; 525c735df2Sopenharmony_ci virtual LocationErrCode QuerySupportCoordinateSystemType( 535c735df2Sopenharmony_ci std::vector<CoordinateSystemType>& coordinateSystemTypes) = 0; 545c735df2Sopenharmony_ci virtual LocationErrCode SendNetworkLocation(const std::unique_ptr<Location>& location) = 0; 555c735df2Sopenharmony_ci}; 565c735df2Sopenharmony_ci 575c735df2Sopenharmony_ciclass GnssAbilityStub : public IRemoteStub<IGnssAbility> { 585c735df2Sopenharmony_cipublic: 595c735df2Sopenharmony_ci using GnssMsgHandle = std::function<int(MessageParcel &, MessageParcel &, AppIdentity &)>; 605c735df2Sopenharmony_ci using GnssMsgHandleMap = std::map<int, GnssMsgHandle>; 615c735df2Sopenharmony_ci GnssAbilityStub(); 625c735df2Sopenharmony_ci virtual ~GnssAbilityStub() = default; 635c735df2Sopenharmony_ci void InitGnssMsgHandleMap(); 645c735df2Sopenharmony_ci void InitGnssEnhanceMsgHandleMap(); 655c735df2Sopenharmony_ci int32_t OnRemoteRequest(uint32_t code, 665c735df2Sopenharmony_ci MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 675c735df2Sopenharmony_ci virtual void SendMessage(uint32_t code, MessageParcel &data, MessageParcel &reply) = 0; 685c735df2Sopenharmony_ci virtual bool CancelIdleState() = 0; 695c735df2Sopenharmony_ci virtual void UnloadGnssSystemAbility() = 0; 705c735df2Sopenharmony_ciprivate: 715c735df2Sopenharmony_ci int SendLocationRequestInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 725c735df2Sopenharmony_ci int SetMockLocationsInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 735c735df2Sopenharmony_ci int SetEnableInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 745c735df2Sopenharmony_ci int RefreshRequirementsInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 755c735df2Sopenharmony_ci int RegisterGnssStatusCallbackInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 765c735df2Sopenharmony_ci int UnregisterGnssStatusCallbackInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 775c735df2Sopenharmony_ci int RegisterNmeaMessageCallbackInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 785c735df2Sopenharmony_ci int UnregisterNmeaMessageCallbackInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 795c735df2Sopenharmony_ci int RegisterCachedCallbackInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 805c735df2Sopenharmony_ci int UnregisterCachedCallbackInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 815c735df2Sopenharmony_ci int GetCachedGnssLocationsSizeInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 825c735df2Sopenharmony_ci int FlushCachedGnssLocationsInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 835c735df2Sopenharmony_ci int SendCommandInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 845c735df2Sopenharmony_ci int EnableMockInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 855c735df2Sopenharmony_ci int DisableMockInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 865c735df2Sopenharmony_ci int AddFenceInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 875c735df2Sopenharmony_ci int RemoveFenceInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 885c735df2Sopenharmony_ci int AddGnssGeofenceInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 895c735df2Sopenharmony_ci int RemoveGnssGeofenceInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 905c735df2Sopenharmony_ci int QuerySupportCoordinateSystemTypeInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 915c735df2Sopenharmony_ci int SendNetworkLocationInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity); 925c735df2Sopenharmony_ciprivate: 935c735df2Sopenharmony_ci bool isMessageRequest_ = false; 945c735df2Sopenharmony_ci GnssMsgHandleMap GnssMsgHandleMap_; 955c735df2Sopenharmony_ci}; 965c735df2Sopenharmony_ci 975c735df2Sopenharmony_ciclass GnssStatusCallbackDeathRecipient : public IRemoteObject::DeathRecipient { 985c735df2Sopenharmony_cipublic: 995c735df2Sopenharmony_ci void OnRemoteDied(const wptr<IRemoteObject> &remote) override; 1005c735df2Sopenharmony_ci GnssStatusCallbackDeathRecipient(); 1015c735df2Sopenharmony_ci ~GnssStatusCallbackDeathRecipient() override; 1025c735df2Sopenharmony_ci}; 1035c735df2Sopenharmony_ci 1045c735df2Sopenharmony_ciclass NmeaCallbackDeathRecipient : public IRemoteObject::DeathRecipient { 1055c735df2Sopenharmony_cipublic: 1065c735df2Sopenharmony_ci void OnRemoteDied(const wptr<IRemoteObject> &remote) override; 1075c735df2Sopenharmony_ci NmeaCallbackDeathRecipient(); 1085c735df2Sopenharmony_ci ~NmeaCallbackDeathRecipient() override; 1095c735df2Sopenharmony_ci}; 1105c735df2Sopenharmony_ci 1115c735df2Sopenharmony_ciclass CachedLocationCallbackDeathRecipient : public IRemoteObject::DeathRecipient { 1125c735df2Sopenharmony_cipublic: 1135c735df2Sopenharmony_ci void OnRemoteDied(const wptr<IRemoteObject> &remote) override; 1145c735df2Sopenharmony_ci CachedLocationCallbackDeathRecipient(); 1155c735df2Sopenharmony_ci ~CachedLocationCallbackDeathRecipient() override; 1165c735df2Sopenharmony_ci}; 1175c735df2Sopenharmony_ci 1185c735df2Sopenharmony_ciclass GnssGeofenceCallbackDeathRecipient : public IRemoteObject::DeathRecipient { 1195c735df2Sopenharmony_cipublic: 1205c735df2Sopenharmony_ci void OnRemoteDied(const wptr<IRemoteObject> &remote) override; 1215c735df2Sopenharmony_ci GnssGeofenceCallbackDeathRecipient(); 1225c735df2Sopenharmony_ci ~GnssGeofenceCallbackDeathRecipient() override; 1235c735df2Sopenharmony_ci}; 1245c735df2Sopenharmony_ci} // namespace Location 1255c735df2Sopenharmony_ci} // namespace OHOS 1265c735df2Sopenharmony_ci#endif // FEATURE_GNSS_SUPPORT 1275c735df2Sopenharmony_ci#endif // GNSS_ABILITY_SKELETON_H 128