Fix some Tuner JNI/Client issues found with CTS
Test: atest android.media.tv.tuner.cts
Bug: 181088182
Change-Id: I29249ed270eb9bbea6447cde094fc83af1fef815
diff --git a/media/jni/android_media_tv_Tuner.cpp b/media/jni/android_media_tv_Tuner.cpp
index 177b00a..3669bf4 100644
--- a/media/jni/android_media_tv_Tuner.cpp
+++ b/media/jni/android_media_tv_Tuner.cpp
@@ -226,7 +226,6 @@
} else {
ALOGE("LnbClientCallbackImpl::onEvent:"
"Lnb object has been freed. Ignoring callback.");
- env->DeleteWeakGlobalRef(mLnbObj);
}
}
@@ -245,7 +244,6 @@
} else {
ALOGE("LnbClientCallbackImpl::onDiseqcMessage:"
"Lnb object has been freed. Ignoring callback.");
- env->DeleteWeakGlobalRef(mLnbObj);
}
}
@@ -276,7 +274,6 @@
} else {
ALOGE("DvrClientCallbackImpl::onRecordStatus:"
"Dvr object has been freed. Ignoring callback.");
- env->DeleteWeakGlobalRef(mDvrObj);
}
}
@@ -292,7 +289,6 @@
} else {
ALOGE("DvrClientCallbackImpl::onPlaybackStatus:"
"Dvr object has been freed. Ignoring callback.");
- env->DeleteWeakGlobalRef(mDvrObj);
}
}
@@ -846,7 +842,6 @@
} else {
ALOGE("FilterClientCallbackImpl::onFilterEvent_1_1:"
"Filter object has been freed. Ignoring callback.");
- env->DeleteWeakGlobalRef(mFilterObj);
}
}
@@ -871,7 +866,6 @@
} else {
ALOGE("FilterClientCallbackImpl::onFilterStatus:"
"Filter object has been freed. Ignoring callback.");
- env->DeleteWeakGlobalRef(mFilterObj);
}
}
@@ -907,7 +901,6 @@
} else {
ALOGE("FrontendClientCallbackImpl::onEvent:"
"Frontend object has been freed. Ignoring callback.");
- env->DeleteWeakGlobalRef(mObject);
}
}
@@ -920,7 +913,6 @@
if (env->IsSameObject(frontend, nullptr)) {
ALOGE("FrontendClientCallbackImpl::onScanMessage:"
"Frontend object has been freed. Ignoring callback.");
- env->DeleteWeakGlobalRef(mObject);
return;
}
switch(type) {
@@ -1078,7 +1070,6 @@
if (env->IsSameObject(frontend, nullptr)) {
ALOGE("FrontendClientCallbackImpl::onScanMessageExt1_1:"
"Frontend object has been freed. Ignoring callback.");
- env->DeleteWeakGlobalRef(mObject);
return;
}
switch(type) {
@@ -1243,7 +1234,6 @@
if (env->IsSameObject(tuner, nullptr)) {
ALOGE("openFrontendByHandle"
"Tuner object has been freed. Failed to open frontend.");
- env->DeleteWeakGlobalRef(mObject);
return NULL;
}
@@ -2211,6 +2201,10 @@
intBandwidth = static_cast<jint>(bandwidth.dvbt());
break;
}
+ case FrontendBandwidth::hidl_discriminator::dvbc: {
+ intBandwidth = static_cast<jint>(bandwidth.dvbc());
+ break;
+ }
case FrontendBandwidth::hidl_discriminator::isdbt: {
intBandwidth = static_cast<jint>(bandwidth.isdbt());
break;
@@ -2731,12 +2725,10 @@
FrontendDvbsVcmMode vcmMode =
static_cast<FrontendDvbsVcmMode>(
env->GetIntField(settings, env->GetFieldID(clazz, "mVcmMode", "I")));
- FrontendDvbsCodeRate coderate = getDvbsCodeRate(env, settings);
FrontendDvbsSettings frontendDvbsSettings {
.frequency = freq,
.modulation = modulation,
- .coderate = coderate,
.symbolRate = symbolRate,
.rolloff = rolloff,
.pilot = pilot,
@@ -2744,6 +2736,13 @@
.standard = standard,
.vcmMode = vcmMode,
};
+
+ jobject jcodeRate = env->GetObjectField(settings, env->GetFieldID(clazz, "mCodeRate",
+ "Landroid/media/tv/tuner/frontend/DvbsCodeRate;"));
+ if (jcodeRate != NULL) {
+ frontendDvbsSettings.coderate = getDvbsCodeRate(env, settings);
+ }
+
frontendSettings.dvbs(frontendDvbsSettings);
return frontendSettings;
}
@@ -2755,7 +2754,7 @@
static_cast<FrontendDvbsScanType>(
env->GetIntField(settings, env->GetFieldID(clazz, "mScanType", "I")));
bool isDiseqcRxMessage = static_cast<bool>(env->GetBooleanField(
- settings, env->GetFieldID(clazz, "mIsDiseqcRxMessage", "B")));
+ settings, env->GetFieldID(clazz, "mIsDiseqcRxMessage", "Z")));
FrontendDvbsSettingsExt1_1 dvbsExt1_1 {
.scanType = scanType,
@@ -2995,6 +2994,10 @@
static FrontendSettings getFrontendSettings(JNIEnv *env, int type, jobject settings) {
ALOGD("getFrontendSettings %d", type);
+ if (type == static_cast<int>(::android::hardware::tv::tuner::V1_1::FrontendType::DTMB)) {
+ return FrontendSettings();
+ }
+
FrontendType feType = static_cast<FrontendType>(type);
switch(feType) {
case FrontendType::ANALOG:
diff --git a/media/jni/tuner/FrontendClient.cpp b/media/jni/tuner/FrontendClient.cpp
index f400a71..f54e266 100644
--- a/media/jni/tuner/FrontendClient.cpp
+++ b/media/jni/tuner/FrontendClient.cpp
@@ -588,14 +588,15 @@
break;
}
case TunerFrontendStatus::codeRates: {
- int size = s.get<TunerFrontendStatus::codeRates>().size();
- status.codeRates().resize(size);
- for (int i = 0; i < size; i++) {
- auto aidlCodeRate = s.get<TunerFrontendStatus::codeRates>()[i];
- status.codeRates()[i] =
- static_cast<hardware::tv::tuner::V1_1::FrontendInnerFec>(aidlCodeRate);
+ vector<hardware::tv::tuner::V1_1::FrontendInnerFec> codeRates;
+ for (auto aidlCodeRate : s.get<TunerFrontendStatus::codeRates>()) {
+ codeRates.push_back(
+ static_cast<hardware::tv::tuner::V1_1::FrontendInnerFec>(aidlCodeRate));
}
- hidlStatus.push_back(status);
+ if (codeRates.size() > 0) {
+ status.codeRates(codeRates);
+ hidlStatus.push_back(status);
+ }
break;
}
case TunerFrontendStatus::bandwidth: {