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

Commit e6a72cce authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk
Browse files

Remove broadcastradio HAL 1.2 support from the framework.

Bug: 62945293
Test: it boots
Change-Id: I7f434ed7ef07d0cf9afa93c17e78f2bf80f43b36
parent 606a3846
Loading
Loading
Loading
Loading
+2 −21
Original line number Diff line number Diff line
@@ -98,10 +98,6 @@ class Tuner extends ITuner.Stub {
    private native boolean nativeIsAnalogForced(long nativeContext);
    private native void nativeSetAnalogForced(long nativeContext, boolean isForced);

    private native Map<String, String> nativeSetParameters(long nativeContext,
            Map<String, String> parameters);
    private native Map<String, String> nativeGetParameters(long nativeContext, List<String> keys);

    @Override
    public void close() {
        synchronized (mLock) {
@@ -291,26 +287,11 @@ class Tuner extends ITuner.Stub {

    @Override
    public Map setParameters(Map parameters) {
        Map<String, String> results;
        synchronized (mLock) {
            checkNotClosedLocked();
            results = nativeSetParameters(mNativeContext, Objects.requireNonNull(parameters));
        }
        if (results == null) return Collections.emptyMap();
        return results;
        throw new UnsupportedOperationException("Not supported by HAL 1.x");
    }

    @Override
    public Map getParameters(List<String> keys) {
        if (keys == null) {
            throw new IllegalArgumentException("The argument must not be a null pointer");
        }
        Map<String, String> results;
        synchronized (mLock) {
            checkNotClosedLocked();
            results = nativeGetParameters(mNativeContext, keys);
        }
        if (results == null) return Collections.emptyMap();
        return results;
        throw new UnsupportedOperationException("Not supported by HAL 1.x");
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ class TunerCallback implements ITunerCallback {

    @Override
    public void onParametersUpdated(Map parameters) {
        dispatch(() -> mClientCallback.onParametersUpdated(parameters));
        Slog.e(TAG, "Not applicable for HAL 1.x");
    }

    @Override
+0 −1
Original line number Diff line number Diff line
@@ -110,7 +110,6 @@ cc_defaults {
        "android.hardware.audio.common@2.0",
        "android.hardware.broadcastradio@1.0",
        "android.hardware.broadcastradio@1.1",
        "android.hardware.broadcastradio@1.2",
        "android.hardware.contexthub@1.0",
        "android.hardware.gnss@1.0",
        "android.hardware.gnss@1.1",
+2 −7
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
#include "convert.h"

#include <android/hardware/broadcastradio/1.1/IBroadcastRadio.h>
#include <android/hardware/broadcastradio/1.2/IBroadcastRadioFactory.h>
#include <android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h>
#include <android/hidl/manager/1.0/IServiceManager.h>
#include <broadcastradio-utils-1x/Utils.h>
#include <core_jni_helpers.h>
@@ -45,7 +45,6 @@ using hardware::hidl_vec;

namespace V1_0 = hardware::broadcastradio::V1_0;
namespace V1_1 = hardware::broadcastradio::V1_1;
namespace V1_2 = hardware::broadcastradio::V1_2;
namespace utils = hardware::broadcastradio::utils;

using V1_0::BandConfig;
@@ -149,11 +148,7 @@ static jobject nativeLoadModules(JNIEnv *env, jobject obj, jlong nativeContext)

        auto halRev = HalRevision::V1_0;
        auto halMinor = 0;
        if (V1_2::IBroadcastRadioFactory::castFrom(factory).withDefault(nullptr) != nullptr) {
            halRev = HalRevision::V1_2;
            halMinor = 2;
        } else if (V1_1::IBroadcastRadioFactory::castFrom(factory).withDefault(nullptr)
                != nullptr) {
        if (V1_1::IBroadcastRadioFactory::castFrom(factory).withDefault(nullptr) != nullptr) {
            halRev = HalRevision::V1_1;
            halMinor = 1;
        }
+2 −57
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@
#include "convert.h"
#include "TunerCallback.h"

#include <android/hardware/broadcastradio/1.2/IBroadcastRadioFactory.h>
#include <android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h>
#include <binder/IPCThreadState.h>
#include <broadcastradio-utils-1x/Utils.h>
#include <core_jni_helpers.h>
@@ -44,16 +44,15 @@ using hardware::hidl_vec;

namespace V1_0 = hardware::broadcastradio::V1_0;
namespace V1_1 = hardware::broadcastradio::V1_1;
namespace V1_2 = hardware::broadcastradio::V1_2;
namespace utils = hardware::broadcastradio::utils;

using V1_0::Band;
using V1_0::BandConfig;
using V1_0::MetaData;
using V1_0::Result;
using V1_1::ITunerCallback;
using V1_1::ProgramListResult;
using V1_1::VendorKeyValue;
using V1_2::ITunerCallback;
using utils::HalRevision;

static mutex gContextMutex;
@@ -94,7 +93,6 @@ struct TunerContext {
    wp<V1_1::IBroadcastRadio> mHalModule11;
    sp<V1_0::ITuner> mHalTuner;
    sp<V1_1::ITuner> mHalTuner11;
    sp<V1_2::ITuner> mHalTuner12;
    sp<HalDeathRecipient> mHalDeathRecipient;

private:
@@ -181,11 +179,8 @@ void assignHalInterfaces(JNIEnv *env, JavaRef<jobject> const &jTuner,

    ctx.mHalTuner = halTuner;
    ctx.mHalTuner11 = V1_1::ITuner::castFrom(halTuner).withDefault(nullptr);
    ctx.mHalTuner12 = V1_2::ITuner::castFrom(halTuner).withDefault(nullptr);
    ALOGW_IF(ctx.mHalRev >= HalRevision::V1_1 && ctx.mHalTuner11 == nullptr,
            "Provided tuner does not implement 1.1 HAL");
    ALOGW_IF(ctx.mHalRev >= HalRevision::V1_2 && ctx.mHalTuner12 == nullptr,
            "Provided tuner does not implement 1.2 HAL");

    ctx.mHalDeathRecipient = new HalDeathRecipient(getNativeCallback(env, jTuner));
    halTuner->linkToDeath(ctx.mHalDeathRecipient, 0);
@@ -209,11 +204,6 @@ static sp<V1_1::ITuner> getHalTuner11(jlong nativeContext) {
    return getNativeContext(nativeContext).mHalTuner11;
}

static sp<V1_2::ITuner> getHalTuner12(jlong nativeContext) {
    lock_guard<mutex> lk(gContextMutex);
    return getNativeContext(nativeContext).mHalTuner12;
}

sp<ITunerCallback> getNativeCallback(JNIEnv *env, JavaRef<jobject> const &tuner) {
    return TunerCallback::getNativeCallback(env,
            env->GetObjectField(tuner.get(), gjni.Tuner.tunerCallback));
@@ -243,7 +233,6 @@ static void nativeClose(JNIEnv *env, jobject obj, jlong nativeContext) {
    ctx.mHalDeathRecipient = nullptr;

    ctx.mHalTuner11 = nullptr;
    ctx.mHalTuner12 = nullptr;
    ctx.mHalTuner = nullptr;
}

@@ -466,48 +455,6 @@ static void nativeSetAnalogForced(JNIEnv *env, jobject obj, jlong nativeContext,
    convert::ThrowIfFailed(env, halResult);
}

static jobject nativeSetParameters(JNIEnv *env, jobject obj, jlong nativeContext, jobject jParameters) {
    ALOGV("%s", __func__);

    auto halTuner = getHalTuner12(nativeContext);
    if (halTuner == nullptr) {
        ALOGI("Parameters are not supported with HAL < 1.2");
        return nullptr;
    }

    JavaRef<jobject> jResults = nullptr;
    auto parameters = convert::VendorInfoToHal(env, jParameters);
    auto hidlResult = halTuner->setParameters(parameters,
            [&](const hidl_vec<VendorKeyValue> results) {
        jResults = convert::VendorInfoFromHal(env, results);
    });

    if (convert::ThrowIfFailed(env, hidlResult)) return nullptr;

    return jResults.release();
}

static jobject nativeGetParameters(JNIEnv *env, jobject obj, jlong nativeContext, jobject jKeys) {
    ALOGV("%s", __func__);

    auto halTuner = getHalTuner12(nativeContext);
    if (halTuner == nullptr) {
        ALOGI("Parameters are not supported with HAL < 1.2");
        return nullptr;
    }

    JavaRef<jobject> jResults = nullptr;
    auto keys = convert::StringListToHal(env, jKeys);
    auto hidlResult = halTuner->getParameters(keys,
            [&](const hidl_vec<VendorKeyValue> parameters) {
        jResults = convert::VendorInfoFromHal(env, parameters);
    });

    if (convert::ThrowIfFailed(env, hidlResult)) return nullptr;

    return jResults.release();
}

static const JNINativeMethod gTunerMethods[] = {
    { "nativeInit", "(IZI)J", (void*)nativeInit },
    { "nativeFinalize", "(J)V", (void*)nativeFinalize },
@@ -528,8 +475,6 @@ static const JNINativeMethod gTunerMethods[] = {
    { "nativeGetImage", "(JI)[B", (void*)nativeGetImage},
    { "nativeIsAnalogForced", "(J)Z", (void*)nativeIsAnalogForced },
    { "nativeSetAnalogForced", "(JZ)V", (void*)nativeSetAnalogForced },
    { "nativeSetParameters", "(JLjava/util/Map;)Ljava/util/Map;", (void*)nativeSetParameters },
    { "nativeGetParameters", "(JLjava/util/List;)Ljava/util/Map;", (void*)nativeGetParameters },
};

} // namespace Tuner
Loading