• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef HCE_SESSION_STUB_H
16 #define HCE_SESSION_STUB_H
17 
18 #include "access_token.h"
19 #include "ihce_cmd_callback.h"
20 #include "iremote_stub.h"
21 #include "ihce_session.h"
22 #include "message_parcel.h"
23 #include "start_hce_info_parcelable.h"
24 
25 namespace OHOS {
26 namespace NFC {
27 namespace HCE {
28 class HceSessionStub : public OHOS::IRemoteStub<OHOS::NFC::HCE::IHceSession> {
29 public:
30     int OnRemoteRequest(uint32_t code,                         /* [in] */
31                         OHOS::MessageParcel& data,             /* [in] */
32                         OHOS::MessageParcel& reply,            /* [out] */
33                         OHOS::MessageOption& option) override; /* [in] */
HceSessionStub()34     HceSessionStub() {}
~HceSessionStub()35     virtual ~HceSessionStub() {}
36 
37     virtual KITS::ErrorCode RegHceCmdCallbackByToken(const sptr<KITS::IHceCmdCallback>& callback,
38                                                      const std::string& type,
39                                                      Security::AccessToken::AccessTokenID callerToken) = 0;
40     virtual KITS::ErrorCode UnRegHceCmdCallbackByToken(const std::string& type,
41                                                         Security::AccessToken::AccessTokenID callerToken) = 0;
42     virtual KITS::ErrorCode UnRegAllCallback(Security::AccessToken::AccessTokenID callerToken) = 0;
43     virtual KITS::ErrorCode HandleWhenRemoteDie(Security::AccessToken::AccessTokenID callerToken) = 0;
44 
45     virtual KITS::ErrorCode StopHce(const ElementName& element,
46                                     Security::AccessToken::AccessTokenID callerToken) = 0;
47 
48     virtual int SendRawFrameByToken(std::string hexCmdData, bool raw, std::string& hexRespData,
49                                     Security::AccessToken::AccessTokenID callerToken) = 0;
50 
51     void RemoveHceDeathRecipient(const wptr<IRemoteObject>& remote);
52 
53 private:
54     int HandleRegHceCmdCallback(MessageParcel& data, MessageParcel& reply);
55 
56     int HandleUnRegHceCmdCallback(MessageParcel& data, MessageParcel& reply);
57 
58     int HandleSendRawFrame(OHOS::MessageParcel& data, OHOS::MessageParcel& reply);
59 
60     int HandleGetPaymentServices(MessageParcel& data, MessageParcel& reply);
61 
62     int HandleStopHce(MessageParcel& data, MessageParcel& reply);
63 
64     int HandleStartHce(MessageParcel& data, MessageParcel& reply);
65 
66     KITS::ErrorCode StartHceInner(std::shared_ptr<KITS::StartHceInfoParcelable> startHceInfo);
67 
68     int HandleIsDefaultService(MessageParcel& data, MessageParcel& reply);
69 
70     KITS::ErrorCode RegHceCmdCallback(const sptr<KITS::IHceCmdCallback>& callback, const std::string& type) override;
71     KITS::ErrorCode UnregHceCmdCallback(const sptr<KITS::IHceCmdCallback>& callback, const std::string& type) override;
72     int SendRawFrame(std::string hexCmdData, bool raw, std::string& hexRespData) override;
73     KITS::ErrorCode StopHce(ElementName &element) override;
74 
75 private:
76     std::mutex mutex_{};
77     sptr<KITS::IHceCmdCallback> hceCmdCallback_;
78     sptr<IRemoteObject::DeathRecipient> deathRecipient_{nullptr};
79 };
80 } // namespace HCE
81 } // namespace NFC
82 } // namespace OHOS
83 #endif // HCE_SESSION_STUB_H
84