Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d10db60 authored by Pomai Ahlo's avatar Pomai Ahlo
Browse files

[ISap hidl2aidl] Compat Support

Add support for ISap in the compat shim.

Test: atest VtsHalRadioTargetTest:PerInstance/SapTest
Bug: 241969533
Change-Id: I9fe5fe194de877bcd2b85ccfa822bd6565e2dc72
Merged-In: I9fe5fe194de877bcd2b85ccfa822bd6565e2dc72
parent 26ae1275
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -589,6 +589,16 @@
            <instance>slot3</instance>
        </interface>
    </hal>
    <hal format="aidl" optional="true">
        <name>android.hardware.radio.sap</name>
        <version>1</version>
        <interface>
            <name>ISap</name>
            <instance>slot1</instance>
            <instance>slot2</instance>
            <instance>slot3</instance>
        </interface>
    </hal>
    <hal format="aidl" optional="true">
        <name>android.hardware.radio.voice</name>
        <version>1</version>
+4 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ cc_library {
        "android.hardware.radio.messaging-V1-ndk",
        "android.hardware.radio.modem-V1-ndk",
        "android.hardware.radio.network-V1-ndk",
        "android.hardware.radio.sap-V1-ndk",
        "android.hardware.radio.sim-V1-ndk",
        "android.hardware.radio.voice-V1-ndk",
        "android.hardware.radio@1.0",
@@ -82,6 +83,9 @@ cc_library {
        "network/RadioResponse-network.cpp",
        "network/structs.cpp",
        "network/utils.cpp",
        "sap/Sap.cpp",
        "sap/SapCallback.cpp",
        "sap/structs.cpp",
        "sim/RadioIndication-sim.cpp",
        "sim/RadioResponse-sim.cpp",
        "sim/RadioSim.cpp",
+4 −0
Original line number Diff line number Diff line
@@ -48,6 +48,10 @@ int32_t toAidl(uint32_t v) {
    return v;
}

uint8_t toHidl(int8_t v) {
    return v;
}

aidl::RadioIndicationType toAidl(V1_0::RadioIndicationType type) {
    return aidl::RadioIndicationType(type);
}
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ hidl_string toHidl(const std::string& str);
uint8_t toAidl(int8_t v);
int8_t toAidl(uint8_t v);
int32_t toAidl(uint32_t v);
uint8_t toHidl(int8_t v);

aidl::android::hardware::radio::RadioIndicationType toAidl(V1_0::RadioIndicationType type);
aidl::android::hardware::radio::RadioResponseType toAidl(V1_0::RadioResponseType type);
+64 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#pragma once

#include "RadioCompatBase.h"
#include "SapCallback.h"

#include <aidl/android/hardware/radio/sap/BnSap.h>
#include <android/hardware/radio/1.0/ISap.h>
#include <android/hardware/radio/1.0/ISapCallback.h>

namespace android::hardware::radio::compat {

/**
 * HAL translator from HIDL ISap to AIDL ISap
 *
 * This class wraps existing HIDL implementation (either a binder stub or real
 * class implementing the HAL) and implements AIDL HAL. It's up to the caller to
 * fetch source implementation and publish resulting HAL instance.
 */
class Sap : public aidl::android::hardware::radio::sap::BnSap {
    const sp<radio::V1_0::ISap> mHal;

    const sp<SapCallback> mSapCallback;

    ::ndk::ScopedAStatus apduReq(int32_t serial,
                                 aidl::android::hardware::radio::sap::SapApduType type,
                                 const std::vector<uint8_t>& command) override;
    ::ndk::ScopedAStatus connectReq(int32_t serial, int32_t maxMsgSize) override;
    ::ndk::ScopedAStatus disconnectReq(int32_t serial) override;
    ::ndk::ScopedAStatus powerReq(int32_t serial, bool state) override;
    ::ndk::ScopedAStatus resetSimReq(int32_t serial) override;
    ::ndk::ScopedAStatus setCallback(
            const std::shared_ptr<::aidl::android::hardware::radio::sap::ISapCallback>& sapCallback)
            override;
    ::ndk::ScopedAStatus setTransferProtocolReq(
            int32_t serial,
            aidl::android::hardware::radio::sap::SapTransferProtocol transferProtocol) override;
    ::ndk::ScopedAStatus transferAtrReq(int32_t serial) override;
    ::ndk::ScopedAStatus transferCardReaderStatusReq(int32_t serial) override;

  public:
    /**
     * Constructs AIDL ISap instance wrapping existing HIDL ISap instance.
     *
     * \param hidlHal existing HIDL ISap HAL instance
     */
    Sap(sp<V1_0::ISap> hidlHal);
};

}  // namespace android::hardware::radio::compat
Loading