From: Jan Altensen Date: Mon, 11 May 2020 09:16:01 +0000 (+0200) Subject: libfmjni: implement getPs, getLrText and readRds X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1f85f60a7dfa6dd455b81fac47e777e93e237dbe;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung_slsi_fm.git libfmjni: implement getPs, getLrText and readRds Change-Id: I6a60cdf2d5525f5eb6a868e1103f93790c55c0f4 --- diff --git a/FmRadioController_slsi.cpp b/FmRadioController_slsi.cpp index 1e402a5..40714e2 100644 --- a/FmRadioController_slsi.cpp +++ b/FmRadioController_slsi.cpp @@ -28,6 +28,9 @@ RadioText RT_Buffered; ServiceName PS_Final; ServiceName PS_Buffered; +bool is_ps_event_received = false; +bool is_rt_event_received = false; + unsigned char rt_flag; unsigned char ps_flag; @@ -1131,6 +1134,27 @@ fail: radio_state = FM_RADIO_ON; } +ServiceName FmRadioController_slsi::GetPs() { + is_ps_event_received = false; + return PS_Final; +} + +RadioText FmRadioController_slsi::GetLrText() { + is_rt_event_received = false; + return RT_Final; +} + +int FmRadioController_slsi::ReadRDS() { + int ret = 0; + + if (is_ps_event_received) + ret |= RDS_EVT_PS_UPDATE; + if (is_rt_event_received) + ret |= RDS_EVT_RT_UPDATE; + + return ret; +} + /******************************************************************************* * * Functions about RDS, AF, and DNS @@ -2066,6 +2090,7 @@ static void fm_radio_data_parsing(unsigned char *buf, radio_data_t *r_data) if ((RT_Final.bValidated == 1) || (RT_Final.bValidated % 10) == 0) { strcpy(final_rds_data[test_data_index_rds].RadioText, RT_Final.Text); rds_flag = 1; + is_rt_event_received = true; } } } @@ -2096,6 +2121,7 @@ static void fm_radio_data_parsing(unsigned char *buf, radio_data_t *r_data) if ((PS_Final.bValidated == 2) || (PS_Final.bValidated % 10) == 0) { strcpy(final_rds_data[test_data_index_rds].StationName, PS_Final.Text); rds_flag = 1; + is_ps_event_received = true; } } } diff --git a/FmRadioController_slsi.h b/FmRadioController_slsi.h index 21cef3d..2cb6aa6 100644 --- a/FmRadioController_slsi.h +++ b/FmRadioController_slsi.h @@ -118,6 +118,19 @@ enum fm_radio_rds_index FM_RADIO_RDS_BLER, }; +typedef enum { + RDS_EVT_UPDATE = 0x0001, + RDS_EVT_PI_UPDATE = 0x0002, + RDS_EVT_PTY_UPDATE = 0x0004, + RDS_EVT_PS_UPDATE = 0x0008, + RDS_EVT_RT_UPDATE = 0x0040, + RDS_EVT_AF_JUMP = 0x0080, + RDS_EVT_AF_LIST = 0x0100, + RDS_EVT_AF_LIST_UPDATE = 0x0200, + RDS_EVT_RDS_AVL = 0x2000, + RDS_EVT_RDS_NOT_AVL = 0x4000, +} RdsEvts; + #if !defined(FM_RADIO_TEST_MODE) extern void RDSDataReceived(Final_RDS_data rdsData); extern void RTPlusDataReceived(RTPlus_data rtplusData); @@ -234,6 +247,10 @@ public: int GetSNR_th(); int GetCnt_th(); void setScanning(bool value); + + ServiceName GetPs(); + RadioText GetLrText(); + int ReadRDS(); }; #endif /* __FM_RADIO_CONTROLLER_SLSI_H__ */ diff --git a/libfm_jni.cpp b/libfm_jni.cpp index b0a649f..02e6711 100644 --- a/libfm_jni.cpp +++ b/libfm_jni.cpp @@ -94,33 +94,33 @@ jshortArray autoScan(JNIEnv *env __unused, jobject thiz __unused) jshort readRds(JNIEnv *env __unused, jobject thiz __unused) { - ALOGD("%s not supported \n", __func__); + ALOGI("%s \n", __func__); - return JNI_FALSE; + return pFMRadio->ReadRDS(); } jbyteArray getPs(JNIEnv *env, jobject thiz __unused) { ALOGI("%s \n", __func__); - // TODO + jbyteArray PSName; - uint8_t *rt = NULL; - int rt_len = 0; - PSName = env->NewByteArray(rt_len); - env->SetByteArrayRegion(PSName, 0, rt_len, (const jbyte*)rt); + ServiceName ps = pFMRadio->GetPs(); + PSName = env->NewByteArray(ps.iLenght); + env->SetByteArrayRegion(PSName, 0, ps.iLenght, (const jbyte*)ps.Text); + return PSName; } jbyteArray getLrText(JNIEnv *env, jobject thiz __unused) { ALOGI("%s \n", __func__); - // TODO - jbyteArray PSName; - uint8_t *rt = NULL; - int rt_len = 0; - PSName = env->NewByteArray(rt_len); - env->SetByteArrayRegion(PSName, 0, rt_len, (const jbyte*)rt); - return PSName; + + jbyteArray SName; + RadioText rt = pFMRadio->GetLrText(); + SName = env->NewByteArray(rt.iLenght); + env->SetByteArrayRegion(SName, 0, rt.iLenght, (const jbyte*)rt.Text); + + return SName; } jshort activeAf(JNIEnv *env __unused, jobject thiz __unused) @@ -174,9 +174,9 @@ jint setMute(JNIEnv *env __unused, jobject thiz __unused, jboolean mute) jint isRdsSupport(JNIEnv *env __unused, jobject thiz __unused) { - ALOGD("%s not supported \n", __func__); + ALOGI("%s \n", __func__); - return JNI_FALSE; + return JNI_TRUE; } jint switchAntenna(JNIEnv *env __unused, jobject thiz __unused, jint antenna __unused)