1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include "RadioCompatBase.h"
19 
20 #include <aidl/android/hardware/radio/sim/BnRadioSim.h>
21 
22 namespace android::hardware::radio::compat {
23 
24 class RadioSim : public RadioCompatBase, public aidl::android::hardware::radio::sim::BnRadioSim {
25     ::ndk::ScopedAStatus areUiccApplicationsEnabled(int32_t serial) override;
26     ::ndk::ScopedAStatus changeIccPin2ForApp(int32_t serial, const std::string& oldPin2,
27                                              const std::string& newPin2,
28                                              const std::string& aid) override;
29     ::ndk::ScopedAStatus changeIccPinForApp(int32_t serial, const std::string& oldPin,
30                                             const std::string& newPin,
31                                             const std::string& aid) override;
32     ::ndk::ScopedAStatus enableUiccApplications(int32_t serial, bool enable) override;
33     ::ndk::ScopedAStatus getAllowedCarriers(int32_t serial) override;
34     ::ndk::ScopedAStatus getCdmaSubscription(int32_t serial) override;
35     ::ndk::ScopedAStatus getCdmaSubscriptionSource(int32_t serial) override;
36     ::ndk::ScopedAStatus getFacilityLockForApp(int32_t serial, const std::string& facility,
37                                                const std::string& password, int32_t serviceClass,
38                                                const std::string& appId) override;
39     ::ndk::ScopedAStatus getIccCardStatus(int32_t serial) override;
40     ::ndk::ScopedAStatus getImsiForApp(int32_t serial, const std::string& aid) override;
41     ::ndk::ScopedAStatus getSimPhonebookCapacity(int32_t serial) override;
42     ::ndk::ScopedAStatus getSimPhonebookRecords(int32_t serial) override;
43     ::ndk::ScopedAStatus iccCloseLogicalChannelWithSessionInfo(int32_t serial,
44             const ::aidl::android::hardware::radio::sim::SessionInfo& recordInfo) override;
45     ::ndk::ScopedAStatus iccIoForApp(
46             int32_t serial, const ::aidl::android::hardware::radio::sim::IccIo& iccIo) override;
47     ::ndk::ScopedAStatus iccOpenLogicalChannel(int32_t serial, const std::string& aid,
48                                                int32_t p2) override;
49     ::ndk::ScopedAStatus iccTransmitApduBasicChannel(
50             int32_t serial, const ::aidl::android::hardware::radio::sim::SimApdu& message) override;
51     ::ndk::ScopedAStatus iccTransmitApduLogicalChannel(
52             int32_t serial, const ::aidl::android::hardware::radio::sim::SimApdu& message) override;
53     ::ndk::ScopedAStatus reportStkServiceIsRunning(int32_t serial) override;
54     ::ndk::ScopedAStatus requestIccSimAuthentication(int32_t serial, int32_t authContext,
55                                                      const std::string& authData,
56                                                      const std::string& aid) override;
57     ::ndk::ScopedAStatus responseAcknowledgement() override;
58     ::ndk::ScopedAStatus sendEnvelope(int32_t serial, const std::string& command) override;
59     ::ndk::ScopedAStatus sendEnvelopeWithStatus(int32_t serial,
60                                                 const std::string& contents) override;
61     ::ndk::ScopedAStatus sendTerminalResponseToSim(int32_t serial,
62                                                    const std::string& commandResponse) override;
63     ::ndk::ScopedAStatus setAllowedCarriers(
64             int32_t serial,
65             const ::aidl::android::hardware::radio::sim::CarrierRestrictions& carriers,
66             ::aidl::android::hardware::radio::sim::SimLockMultiSimPolicy multiSimPolicy) override;
67     ::ndk::ScopedAStatus setCarrierInfoForImsiEncryption(
68             int32_t serial,
69             const ::aidl::android::hardware::radio::sim::ImsiEncryptionInfo& imsiEncryptionInfo)
70             override;
71     ::ndk::ScopedAStatus setCdmaSubscriptionSource(
72             int32_t serial,
73             ::aidl::android::hardware::radio::sim::CdmaSubscriptionSource cdmaSub) override;
74     ::ndk::ScopedAStatus setFacilityLockForApp(  //
75             int32_t serial, const std::string& facility, bool lockState, const std::string& passwd,
76             int32_t serviceClass, const std::string& appId) override;
77     ::ndk::ScopedAStatus setResponseFunctions(
78             const std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimResponse>&
79                     radioSimResponse,
80             const std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimIndication>&
81                     radioSimIndication) override;
82     ::ndk::ScopedAStatus setSimCardPower(
83             int32_t serial, ::aidl::android::hardware::radio::sim::CardPowerState powerUp) override;
84     ::ndk::ScopedAStatus setUiccSubscription(
85             int32_t serial,
86             const ::aidl::android::hardware::radio::sim::SelectUiccSub& uiccSub) override;
87     ::ndk::ScopedAStatus supplyIccPin2ForApp(int32_t serial, const std::string& pin2,
88                                              const std::string& aid) override;
89     ::ndk::ScopedAStatus supplyIccPinForApp(int32_t serial, const std::string& pin,
90                                             const std::string& aid) override;
91     ::ndk::ScopedAStatus supplyIccPuk2ForApp(int32_t serial, const std::string& puk2,
92                                              const std::string& pin2,
93                                              const std::string& aid) override;
94     ::ndk::ScopedAStatus supplyIccPukForApp(int32_t serial, const std::string& puk,
95                                             const std::string& pin,
96                                             const std::string& aid) override;
97     ::ndk::ScopedAStatus supplySimDepersonalization(
98             int32_t serial, ::aidl::android::hardware::radio::sim::PersoSubstate persoType,
99             const std::string& controlKey) override;
100     ::ndk::ScopedAStatus updateSimPhonebookRecords(
101             int32_t serial,
102             const ::aidl::android::hardware::radio::sim::PhonebookRecordInfo& recordInfo) override;
103 
104   protected:
105     std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimResponse> respond();
106     ::ndk::ScopedAStatus iccCloseLogicalChannel(int32_t serial, int32_t channelId) override;
107 
108   public:
109     using RadioCompatBase::RadioCompatBase;
110 };
111 
112 }  // namespace android::hardware::radio::compat
113