1 /* 2 * Copyright (C) 2024 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 17 #pragma once 18 19 #include <aidl/android/hardware/radio/RadioError.h> 20 #include <aidl/android/hardware/radio/sim/IccIo.h> 21 #include <android-base/macros.h> 22 #include <libminradio/sim/App.h> 23 24 #include <map> 25 26 namespace android::hardware::radio::minimal::sim { 27 28 class AppManager { 29 public: 30 AppManager(); 31 32 void addApp(std::shared_ptr<App> app); 33 34 std::pair<::aidl::android::hardware::radio::RadioError, std::shared_ptr<App::Channel>> 35 openLogicalChannel(std::string_view aid, int32_t p2); 36 ::aidl::android::hardware::radio::RadioError closeLogicalChannel(int32_t channelId); 37 38 ::aidl::android::hardware::radio::sim::IccIoResult transmit( 39 const ::aidl::android::hardware::radio::sim::SimApdu& message); 40 ::aidl::android::hardware::radio::sim::IccIoResult iccIo( 41 const ::aidl::android::hardware::radio::sim::IccIo& iccIo); 42 43 private: 44 std::map<std::string, std::shared_ptr<App>, std::less<>> mApps; 45 mutable std::mutex mChannelsGuard; 46 std::map<int32_t, std::shared_ptr<App::Channel>> mChannels; 47 48 ::aidl::android::hardware::radio::sim::IccIoResult commandManageChannel(int32_t p1, int32_t p2); 49 50 DISALLOW_COPY_AND_ASSIGN(AppManager); 51 }; 52 53 } // namespace android::hardware::radio::minimal::sim 54