• 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 
24 namespace OHOS {
25 namespace NFC {
26 namespace HCE {
27 class HceSessionStub : public OHOS::IRemoteStub<OHOS::NFC::HCE::IHceSession> {
28 public:
29     int OnRemoteRequest(uint32_t code,                         /* [in] */
30                         OHOS::MessageParcel& data,             /* [in] */
31                         OHOS::MessageParcel& reply,            /* [out] */
32                         OHOS::MessageOption& option) override; /* [in] */
HceSessionStub()33     HceSessionStub() {}
~HceSessionStub()34     virtual ~HceSessionStub() {}
35 
36     virtual KITS::ErrorCode RegHceCmdCallbackByToken(const sptr<KITS::IHceCmdCallback>& callback,
37                                                      const std::string& type,
38                                                      Security::AccessToken::AccessTokenID callerToken) = 0;
39 
40     virtual KITS::ErrorCode UnRegHceCmdCallback(const std::string& type,
41                                                 Security::AccessToken::AccessTokenID callerToken) = 0;
42     virtual KITS::ErrorCode UnRegAllCallback(Security::AccessToken::AccessTokenID callerToken) = 0;
43 
44     virtual int SendRawFrameByToken(std::string hexCmdData, bool raw, std::string& hexRespData,
45                                     Security::AccessToken::AccessTokenID callerToken) = 0;
46 
47     void RemoveHceDeathRecipient(const wptr<IRemoteObject>& remote);
48 
49 private:
50     int HandleRegHceCmdCallback(MessageParcel& data, MessageParcel& reply);
51 
52     int HandleSendRawFrame(OHOS::MessageParcel& data, OHOS::MessageParcel& reply);
53 
54     int HandleGetPaymentServices(MessageParcel& data, MessageParcel& reply);
55 
56     int HandleStopHce(MessageParcel& data, MessageParcel& reply);
57 
58     int HandleIsDefaultService(MessageParcel& data, MessageParcel& reply);
59 
60     KITS::ErrorCode RegHceCmdCallback(const sptr<KITS::IHceCmdCallback>& callback,
61                                       const std::string& type) override;
62 
63     int SendRawFrame(std::string hexCmdData, bool raw, std::string& hexRespData) override;
64     KITS::ErrorCode StopHce(ElementName &element) override;
65 
66 private:
67     std::mutex mutex_{};
68     sptr<KITS::IHceCmdCallback> hceCmdCallback_;
69     sptr<IRemoteObject::DeathRecipient> deathRecipient_{nullptr};
70 };
71 } // namespace HCE
72 } // namespace NFC
73 } // namespace OHOS
74 #endif // HCE_SESSION_STUB_H
75