Merge changes from topics "radio-vendor-kvp", "radio-1.2"
* changes: Implement generic vendor-specific parameters. Branch out Broadcast Radio 1.2 HAL.
This commit is contained in:
committed by
Android (Google) Code Review
commit
35d35ab4b7
@@ -92,6 +92,7 @@ LOCAL_SHARED_LIBRARIES += \
|
||||
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.ir@1.0 \
|
||||
@@ -109,5 +110,5 @@ LOCAL_SHARED_LIBRARIES += \
|
||||
android.frameworks.sensorservice@1.0 \
|
||||
|
||||
LOCAL_STATIC_LIBRARIES += \
|
||||
android.hardware.broadcastradio@1.1-utils-lib \
|
||||
android.hardware.broadcastradio@common-utils-lib \
|
||||
libscrypt_static \
|
||||
|
||||
@@ -23,8 +23,9 @@
|
||||
#include "convert.h"
|
||||
|
||||
#include <android/hardware/broadcastradio/1.1/IBroadcastRadio.h>
|
||||
#include <android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h>
|
||||
#include <android/hardware/broadcastradio/1.2/IBroadcastRadioFactory.h>
|
||||
#include <android/hidl/manager/1.0/IServiceManager.h>
|
||||
#include <broadcastradio-utils/Utils.h>
|
||||
#include <core_jni_helpers.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#include <nativehelper/JNIHelp.h>
|
||||
@@ -44,14 +45,16 @@ using hardware::hidl_vec;
|
||||
|
||||
namespace V1_0 = hardware::broadcastradio::V1_0;
|
||||
namespace V1_1 = hardware::broadcastradio::V1_1;
|
||||
|
||||
using V1_0::Class;
|
||||
using V1_0::Result;
|
||||
namespace V1_2 = hardware::broadcastradio::V1_2;
|
||||
namespace utils = hardware::broadcastradio::utils;
|
||||
|
||||
using V1_0::BandConfig;
|
||||
using V1_0::ProgramInfo;
|
||||
using V1_0::MetaData;
|
||||
using V1_0::Class;
|
||||
using V1_0::ITuner;
|
||||
using V1_0::MetaData;
|
||||
using V1_0::ProgramInfo;
|
||||
using V1_0::Result;
|
||||
using utils::HalRevision;
|
||||
|
||||
static mutex gContextMutex;
|
||||
|
||||
@@ -67,10 +70,15 @@ static struct {
|
||||
} Tuner;
|
||||
} gjni;
|
||||
|
||||
struct Module {
|
||||
sp<V1_0::IBroadcastRadio> radioModule;
|
||||
HalRevision halRev;
|
||||
};
|
||||
|
||||
struct ServiceContext {
|
||||
ServiceContext() {}
|
||||
|
||||
std::vector<sp<V1_0::IBroadcastRadio>> mModules;
|
||||
std::vector<Module> mModules;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ServiceContext);
|
||||
@@ -139,6 +147,17 @@ static jobject nativeLoadModules(JNIEnv *env, jobject obj, jlong nativeContext)
|
||||
continue;
|
||||
}
|
||||
|
||||
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) {
|
||||
halRev = HalRevision::V1_1;
|
||||
halMinor = 1;
|
||||
}
|
||||
|
||||
// Second level of scanning - that's unfortunate.
|
||||
for (auto&& clazz : gAllClasses) {
|
||||
sp<V1_0::IBroadcastRadio> module10 = nullptr;
|
||||
@@ -155,9 +174,9 @@ static jobject nativeLoadModules(JNIEnv *env, jobject obj, jlong nativeContext)
|
||||
if (module10 == nullptr) continue;
|
||||
|
||||
auto idx = ctx.mModules.size();
|
||||
ctx.mModules.push_back(module10);
|
||||
ALOGI("loaded broadcast radio module %zu: %s:%s",
|
||||
idx, serviceName.c_str(), V1_0::toString(clazz).c_str());
|
||||
ctx.mModules.push_back({module10, halRev});
|
||||
ALOGI("loaded broadcast radio module %zu: %s:%s (HAL 1.%d)",
|
||||
idx, serviceName.c_str(), V1_0::toString(clazz).c_str(), halMinor);
|
||||
|
||||
JavaRef<jobject> jModule = nullptr;
|
||||
Result halResult = Result::OK;
|
||||
@@ -198,22 +217,15 @@ static jobject nativeOpenTuner(JNIEnv *env, jobject obj, long nativeContext, jin
|
||||
ALOGE("Invalid module ID: %d", moduleId);
|
||||
return nullptr;
|
||||
}
|
||||
auto module = ctx.mModules[moduleId];
|
||||
|
||||
HalRevision halRev;
|
||||
if (V1_1::IBroadcastRadio::castFrom(module).withDefault(nullptr) != nullptr) {
|
||||
ALOGI("Opening tuner %d with broadcast radio HAL 1.1", moduleId);
|
||||
halRev = HalRevision::V1_1;
|
||||
} else {
|
||||
ALOGI("Opening tuner %d with broadcast radio HAL 1.0", moduleId);
|
||||
halRev = HalRevision::V1_0;
|
||||
}
|
||||
ALOGI("Opening tuner %d", moduleId);
|
||||
auto module = ctx.mModules[moduleId];
|
||||
|
||||
Region region;
|
||||
BandConfig bandConfigHal = convert::BandConfigToHal(env, bandConfig, region);
|
||||
|
||||
auto tuner = make_javaref(env, env->NewObject(gjni.Tuner.clazz, gjni.Tuner.cstor,
|
||||
callback, halRev, region, withAudio, bandConfigHal.type));
|
||||
callback, module.halRev, region, withAudio, bandConfigHal.type));
|
||||
if (tuner == nullptr) {
|
||||
ALOGE("Unable to create new tuner object.");
|
||||
return nullptr;
|
||||
@@ -223,7 +235,7 @@ static jobject nativeOpenTuner(JNIEnv *env, jobject obj, long nativeContext, jin
|
||||
Result halResult;
|
||||
sp<ITuner> halTuner = nullptr;
|
||||
|
||||
auto hidlResult = module->openTuner(bandConfigHal, withAudio, tunerCb,
|
||||
auto hidlResult = module.radioModule->openTuner(bandConfigHal, withAudio, tunerCb,
|
||||
[&](Result result, const sp<ITuner>& tuner) {
|
||||
halResult = result;
|
||||
halTuner = tuner;
|
||||
@@ -235,7 +247,7 @@ static jobject nativeOpenTuner(JNIEnv *env, jobject obj, long nativeContext, jin
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Tuner::assignHalInterfaces(env, tuner, module, halTuner);
|
||||
Tuner::assignHalInterfaces(env, tuner, module.radioModule, halTuner);
|
||||
ALOGD("Opened tuner %p", halTuner.get());
|
||||
return tuner.release();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "convert.h"
|
||||
#include "TunerCallback.h"
|
||||
|
||||
#include <android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h>
|
||||
#include <android/hardware/broadcastradio/1.2/IBroadcastRadioFactory.h>
|
||||
#include <binder/IPCThreadState.h>
|
||||
#include <broadcastradio-utils/Utils.h>
|
||||
#include <core_jni_helpers.h>
|
||||
@@ -44,13 +44,16 @@ 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_2::ITunerCallback;
|
||||
using V1_1::ProgramListResult;
|
||||
using utils::HalRevision;
|
||||
|
||||
static mutex gContextMutex;
|
||||
|
||||
@@ -310,7 +313,7 @@ static void nativeTune(JNIEnv *env, jobject obj, jlong nativeContext, jobject jS
|
||||
convert::ThrowIfFailed(env, halTuner11->tuneByProgramSelector(selector));
|
||||
} else {
|
||||
uint32_t channel, subChannel;
|
||||
if (!V1_1::utils::getLegacyChannel(selector, &channel, &subChannel)) {
|
||||
if (!utils::getLegacyChannel(selector, &channel, &subChannel)) {
|
||||
jniThrowException(env, "java/lang/IllegalArgumentException",
|
||||
"Can't tune to non-AM/FM channel with HAL<1.1");
|
||||
return;
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#include "JavaRef.h"
|
||||
|
||||
#include <android/hardware/broadcastradio/1.1/IBroadcastRadio.h>
|
||||
#include <android/hardware/broadcastradio/1.1/ITuner.h>
|
||||
#include <android/hardware/broadcastradio/1.1/ITunerCallback.h>
|
||||
#include <android/hardware/broadcastradio/1.2/ITuner.h>
|
||||
#include <android/hardware/broadcastradio/1.2/ITunerCallback.h>
|
||||
#include <jni.h>
|
||||
#include <utils/StrongPointer.h>
|
||||
|
||||
@@ -39,7 +39,7 @@ void assignHalInterfaces(JNIEnv *env, JavaRef<jobject> const &jTuner,
|
||||
sp<hardware::broadcastradio::V1_0::IBroadcastRadio> halModule,
|
||||
sp<hardware::broadcastradio::V1_0::ITuner> halTuner);
|
||||
|
||||
sp<hardware::broadcastradio::V1_1::ITunerCallback>
|
||||
sp<hardware::broadcastradio::V1_2::ITunerCallback>
|
||||
getNativeCallback(JNIEnv *env, JavaRef<jobject> const &tuner);
|
||||
|
||||
Region getRegion(JNIEnv *env, jobject obj);
|
||||
|
||||
@@ -40,15 +40,19 @@ 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::ProgramInfo;
|
||||
using V1_1::ProgramListResult;
|
||||
using V1_1::ProgramSelector;
|
||||
using V1_1::VendorKeyValue;
|
||||
using V1_2::ITunerCallback;
|
||||
using utils::HalRevision;
|
||||
|
||||
static JavaVM *gvm = nullptr;
|
||||
|
||||
@@ -117,6 +121,7 @@ public:
|
||||
virtual Return<void> backgroundScanComplete(ProgramListResult result);
|
||||
virtual Return<void> programListChanged();
|
||||
virtual Return<void> currentProgramInfoChanged(const ProgramInfo& info);
|
||||
virtual Return<void> parametersUpdated(const hidl_vec<VendorKeyValue>& parameters);
|
||||
};
|
||||
|
||||
struct TunerCallbackContext {
|
||||
@@ -203,7 +208,7 @@ Return<void> NativeCallback::tuneComplete(Result result, const V1_0::ProgramInfo
|
||||
return {};
|
||||
}
|
||||
|
||||
auto selector = V1_1::utils::make_selector(mBand, info.channel, info.subChannel);
|
||||
auto selector = utils::make_selector(mBand, info.channel, info.subChannel);
|
||||
return tuneComplete_1_1(result, selector);
|
||||
}
|
||||
|
||||
@@ -338,6 +343,14 @@ Return<void> NativeCallback::currentProgramInfoChanged(const ProgramInfo& info)
|
||||
return Return<void>();
|
||||
}
|
||||
|
||||
Return<void> NativeCallback::parametersUpdated(const hidl_vec<VendorKeyValue>& parameters) {
|
||||
ALOGV("%s", __func__);
|
||||
|
||||
// TODO(b/65862441): pass this callback to the front-end
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
static TunerCallbackContext& getNativeContext(jlong nativeContextHandle) {
|
||||
auto nativeContext = reinterpret_cast<TunerCallbackContext*>(nativeContextHandle);
|
||||
LOG_ALWAYS_FATAL_IF(nativeContext == nullptr, "Native context not initialized");
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "NativeCallbackThread.h"
|
||||
#include "types.h"
|
||||
|
||||
#include <android/hardware/broadcastradio/1.1/ITunerCallback.h>
|
||||
#include <android/hardware/broadcastradio/1.2/ITunerCallback.h>
|
||||
#include <jni.h>
|
||||
|
||||
namespace android {
|
||||
@@ -32,7 +32,7 @@ namespace server {
|
||||
namespace BroadcastRadio {
|
||||
namespace TunerCallback {
|
||||
|
||||
sp<hardware::broadcastradio::V1_1::ITunerCallback>
|
||||
sp<hardware::broadcastradio::V1_2::ITunerCallback>
|
||||
getNativeCallback(JNIEnv *env, jobject jTunerCallback);
|
||||
|
||||
} // namespace TunerCallback
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace server {
|
||||
namespace BroadcastRadio {
|
||||
namespace convert {
|
||||
|
||||
namespace utils = V1_1::utils;
|
||||
namespace utils = hardware::broadcastradio::utils;
|
||||
|
||||
using hardware::Return;
|
||||
using hardware::hidl_vec;
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace server {
|
||||
namespace BroadcastRadio {
|
||||
namespace regions {
|
||||
|
||||
namespace utils = hardware::broadcastradio::V1_1::utils;
|
||||
namespace utils = hardware::broadcastradio::utils;
|
||||
|
||||
using hardware::hidl_vec;
|
||||
|
||||
|
||||
@@ -27,11 +27,6 @@ namespace BroadcastRadio {
|
||||
* frameworks/base/core/java/android/hardware/radio/RadioManager.java.
|
||||
*/
|
||||
|
||||
enum class HalRevision : jint {
|
||||
V1_0,
|
||||
V1_1,
|
||||
};
|
||||
|
||||
// Keep in sync with STATUS_* constants from RadioManager.java.
|
||||
enum class Status : jint {
|
||||
OK = 0,
|
||||
|
||||
Reference in New Issue
Block a user