summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2016-12-06 01:06:58 -0700
committerLinux Build Service Account <lnxbuild@localhost>2016-12-06 01:06:58 -0700
commit5d222c017027fcb8c879ef8fa04f4f7910d0bc2b (patch)
treec1e31ba82aa555ad4423624d17a097ff9a68403e
parentda6d31bbdfdc70788c90031c65edd1aec7e254dc (diff)
parentf22df87b2f992733059195d71a8fef2369f5368b (diff)
downloadandroid_hardware_qcom_fm-5d222c017027fcb8c879ef8fa04f4f7910d0bc2b.tar.gz
android_hardware_qcom_fm-5d222c017027fcb8c879ef8fa04f4f7910d0bc2b.tar.bz2
android_hardware_qcom_fm-5d222c017027fcb8c879ef8fa04f4f7910d0bc2b.zip
Merge f22df87b2f992733059195d71a8fef2369f5368b on remote branch
Change-Id: Ic97c1fbc4e7e11e083abeaf61e42db2701d3e81e
-rw-r--r--fm_hci/fm_hci.c10
-rw-r--r--fmapp2/src/com/caf/fmradio/FMRadio.java29
-rw-r--r--fmapp2/src/com/caf/fmradio/FMRadioService.java35
-rw-r--r--helium/radio_helium_hal.c2
-rw-r--r--jni/FmIoctlsInterface.cpp3
-rw-r--r--jni/android_hardware_fm.cpp13
-rw-r--r--qcom/fmradio/FmReceiverJNI.java23
7 files changed, 85 insertions, 30 deletions
diff --git a/fm_hci/fm_hci.c b/fm_hci/fm_hci.c
index 2fafe83..c48edd5 100644
--- a/fm_hci/fm_hci.c
+++ b/fm_hci/fm_hci.c
@@ -57,6 +57,7 @@ static int fm_hal_fd =0;
#define WAIT_TIMEOUT 200000 /* 200*1000us */
static void fm_hci_exit(void *arg);
+static int power(struct fm_hci_t *hci, fm_power_state_t state);
static void event_notification(struct fm_hci_t *hci, uint16_t event)
{
@@ -178,7 +179,7 @@ static int read_fm_event(struct fm_hci_t *hci, struct fm_event_header_t *pbuf, i
{
fd_set readFds;
sigset_t sigmask, emptymask;
- int n = 0, ret = -1, evt_len = -1;
+ int n = 0, ret = -1, evt_len = -1,status=0;
volatile int fd = hci->fd;
struct sigaction action;
@@ -230,6 +231,10 @@ static int read_fm_event(struct fm_hci_t *hci, struct fm_event_header_t *pbuf, i
ALOGI("%s: FM H/w Err Event Recvd. Event Code: 0x%2x", __func__, pbuf->evt_code);
lib_running =0;
hci->vendor->ssr_cleanup(0x22);
+ status = power(hci, FM_RADIO_DISABLE);
+ if (status < 0) {
+ ALOGE("power off fm radio failed during SSR ");
+ }
} else {
ALOGE("%s: Not CS/CC Event: Recvd. Event Code: 0x%2x", __func__, pbuf->evt_code);
}
@@ -333,7 +338,8 @@ static void* hci_tx_thread(void *arg)
while (lib_running) {
pthread_mutex_lock(&hci->event_lock);
- pthread_cond_wait(&hci->event_cond, &hci->event_lock);
+ if (!(ready_events & HC_EVENT_TX))
+ pthread_cond_wait(&hci->event_cond, &hci->event_lock);
ALOGE("%s: ready_events= %d", __func__, ready_events);
events = ready_events;
if (ready_events & HC_EVENT_TX)
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index 43fd2ef..1da839b 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -439,7 +439,7 @@ public class FMRadio extends Activity
public void onRestart() {
Log.d(LOGTAG, "FMRadio: onRestart");
try {
- if (null != mService) {
+ if (null != mService && isAntennaAvailable()) {
mService.requestFocus();
}
} catch (Exception e) {
@@ -505,13 +505,25 @@ public class FMRadio extends Activity
super.onResume();
- // TODO: We should return on exception or continue?
- try {
- if (mService != null)
- mService.registerCallbacks(mServiceCallbacks);
- } catch (RemoteException e) {
- e.printStackTrace();
+ if (mService == null) {
+ Log.d(LOGTAG,"bind callback has not received yet - wait for 100ms");
+ mHandler.postDelayed(UpdateFm, 100);
+ return;
}
+ mHandler.post(UpdateFm);
+ }
+ Runnable UpdateFm = new Runnable() {
+ public void run() {
+ // TODO: We should return on exception or continue?
+ if (!isAntennaAvailable()) {
+ return;
+ }
+ try {
+ if (mService != null)
+ mService.registerCallbacks(mServiceCallbacks);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
if (isSleepTimerActive()) {
Log.d(LOGTAG, "isSleepTimerActive is true");
@@ -556,7 +568,8 @@ public class FMRadio extends Activity
mUpdatePickerValue = true;
updateStationInfoToUI();
enableRadioOnOffUI();
- }
+ }
+ };
private static class LoadedDataAndState {
public LoadedDataAndState(){};
public boolean onOrOff;
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 2b9fb83..54654fa 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2015, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2009-2016, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -608,6 +608,7 @@ public class FMRadioService extends Service
*/
public void registerHeadsetListener() {
if (mHeadsetReceiver == null) {
+ boolean fm_a2dp_disabled = SystemProperties.getBoolean("fm.a2dp.conc.disabled",true);
mHeadsetReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -682,7 +683,9 @@ public class FMRadioService extends Service
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
IntentFilter iFilter = new IntentFilter();
iFilter.addAction(Intent.ACTION_HEADSET_PLUG);
- iFilter.addAction(mA2dpDeviceState.getActionSinkStateChangedString());
+ if (!fm_a2dp_disabled) {
+ iFilter.addAction(mA2dpDeviceState.getActionSinkStateChangedString());
+ }
iFilter.addAction("HDMI_CONNECTED");
iFilter.addAction(Intent.ACTION_SHUTDOWN);
iFilter.addCategory(Intent.CATEGORY_DEFAULT);
@@ -1604,8 +1607,6 @@ public class FMRadioService extends Service
case AudioManager.AUDIOFOCUS_LOSS:
Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS");
//intentional fall through.
- if (true == isFmRecordingOn())
- stopRecording();
if (mSpeakerPhoneOn) {
mSpeakerDisableHandler.removeCallbacks(mSpeakerDisableTask);
mSpeakerDisableHandler.postDelayed(mSpeakerDisableTask, 0);
@@ -1613,6 +1614,9 @@ public class FMRadioService extends Service
if (true == mPlaybackInProgress) {
stopFM();
}
+ if (true == isFmRecordingOn())
+ stopRecording();
+
if (mSpeakerPhoneOn) {
if (isAnalogModeSupported())
setAudioPath(false);
@@ -2247,6 +2251,17 @@ public class FMRadioService extends Service
* Turn OFF FM Operations: This disables all the current FM operations .
*/
private void fmOperationsOff() {
+ // disable audio path
+ AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+ if(audioManager != null)
+ {
+ Log.d(LOGTAG, "audioManager.setFmRadioOn = false \n" );
+ stopFM();
+ unMute();
+ audioManager.abandonAudioFocus(mAudioFocusListener);
+ //audioManager.setParameters("FMRadioOn=false");
+ Log.d(LOGTAG, "audioManager.setFmRadioOn false done \n" );
+ }
// stop recording
if (isFmRecordingOn())
{
@@ -2258,17 +2273,6 @@ public class FMRadioService extends Service
return;
}
}
- // disable audio path
- AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- if(audioManager != null)
- {
- Log.d(LOGTAG, "audioManager.setFmRadioOn = false \n" );
- stopFM();
- unMute();
- audioManager.abandonAudioFocus(mAudioFocusListener);
- //audioManager.setParameters("FMRadioOn=false");
- Log.d(LOGTAG, "audioManager.setFmRadioOn false done \n" );
- }
// reset FM audio settings
resetAudioRoute();
@@ -2281,6 +2285,7 @@ public class FMRadioService extends Service
}
}
+
/*
* Reset (OFF) FM Operations: This resets all the current FM operations .
*/
diff --git a/helium/radio_helium_hal.c b/helium/radio_helium_hal.c
index 3f68812..3fa4587 100644
--- a/helium/radio_helium_hal.c
+++ b/helium/radio_helium_hal.c
@@ -623,7 +623,7 @@ static inline void hci_ev_program_service(char *buff)
memcpy(data+RDS_OFFSET, &buff[RDS_PS_DATA_OFFSET], len-RDS_OFFSET);
- ALOGE("SSK call ps-callback");
+ ALOGV("call ps-callback");
hal->jni_cb->ps_update_cb(data);
free(data);
diff --git a/jni/FmIoctlsInterface.cpp b/jni/FmIoctlsInterface.cpp
index 046ca1e..640a90f 100644
--- a/jni/FmIoctlsInterface.cpp
+++ b/jni/FmIoctlsInterface.cpp
@@ -111,6 +111,9 @@ int FmIoctlsInterface :: set_calibration
struct v4l2_ext_controls v4l2_ctls;
char cal_data[CAL_DATA_SIZE] = {0};
+ memset(&v4l2_ctls, 0, sizeof(v4l2_ctls));
+ memset(&ext_ctl, 0, sizeof(ext_ctl));
+
cal_fp = fopen(CALIB_DATA_NAME, "r");
if(cal_fp != NULL) {
if(fread(&cal_data[0], 1, CAL_DATA_SIZE, cal_fp)
diff --git a/jni/android_hardware_fm.cpp b/jni/android_hardware_fm.cpp
index 9e469ed..b5b0a5e 100644
--- a/jni/android_hardware_fm.cpp
+++ b/jni/android_hardware_fm.cpp
@@ -194,7 +194,16 @@ void fm_scan_next_cb()
void fm_srch_list_cb(uint16_t *scan_tbl)
{
ALOGI("SRCH_LIST");
- //mCallbackEnv->CallVoidMethod(javaObjectRef, method_srchListCallback);
+ jbyteArray srch_buffer = NULL;
+
+ srch_buffer = mCallbackEnv->NewByteArray(STD_BUF_SIZE);
+ if (srch_buffer == NULL) {
+ ALOGE(" af list allocate failed :");
+ return;
+ }
+ mCallbackEnv->SetByteArrayRegion(srch_buffer, 0, STD_BUF_SIZE, (jbyte *)scan_tbl);
+ mCallbackEnv->CallVoidMethod(mCallbacksObj, method_srchListCallback, srch_buffer);
+ mCallbackEnv->DeleteLocalRef(srch_buffer);
}
void fm_stereo_status_cb(bool stereo)
@@ -1519,7 +1528,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) {
method_tuneCallback = env->GetMethodID(javaClassRef, "tuneCallback", "(I)V");
method_seekCmplCallback = env->GetMethodID(javaClassRef, "seekCmplCallback", "(I)V");
method_scanNxtCallback = env->GetMethodID(javaClassRef, "scanNxtCallback", "()V");
- //method_srchListCallback = env->GetMethodID(javaClassRef, "srchListCallback", "([B)V");
+ method_srchListCallback = env->GetMethodID(javaClassRef, "srchListCallback", "([B)V");
method_stereostsCallback = env->GetMethodID(javaClassRef, "stereostsCallback", "(Z)V");
method_rdsAvlStsCallback = env->GetMethodID(javaClassRef, "rdsAvlStsCallback", "(Z)V");
method_disableCallback = env->GetMethodID(javaClassRef, "disableCallback", "()V");
diff --git a/qcom/fmradio/FmReceiverJNI.java b/qcom/fmradio/FmReceiverJNI.java
index e587b44..c5835ff 100644
--- a/qcom/fmradio/FmReceiverJNI.java
+++ b/qcom/fmradio/FmReceiverJNI.java
@@ -193,7 +193,6 @@ class FmReceiverJNI {
public void tuneCallback(int freq) {
int state;
-
Log.d(TAG, "tuneCallback enter");
state = FmReceiver.getSearchState();
switch(state) {
@@ -222,7 +221,7 @@ class FmReceiverJNI {
Log.d(TAG, "seekCmplCallback enter");
state = FmReceiver.getSearchState();
- switch(state) {
+ switch (state) {
case FmTransceiver.subSrchLevel_ScanInProg:
Log.v(TAG, "Current state is " + state);
FmReceiver.setSearchState(FmTransceiver.subSrchLevel_SrchComplete);
@@ -240,6 +239,26 @@ class FmReceiverJNI {
Log.d(TAG, "seekCmplCallback exit");
}
+ public void srchListCallback(byte[] scan_tbl) {
+ int state;
+ state = FmReceiver.getSearchState();
+ switch (state) {
+ case FmTransceiver.subSrchLevel_SrchListInProg:
+ Log.v(TAG, "FmRxEventListener: Current state is AUTO_PRESET_INPROGRESS");
+ FmReceiver.setSearchState(FmTransceiver.subSrchLevel_SrchComplete);
+ Log.v(TAG, "RxEvtList: CURRENT-STATE : Search ---> NEW-STATE : FMRxOn");
+ FmReceiver.mCallback.FmRxEvSearchListComplete();
+ break;
+ case FmTransceiver.subSrchLevel_SrchAbort:
+ Log.v(TAG, "Current state is SRCH_ABORTED");
+ Log.v(TAG, "Aborting on-going SearchList command...");
+ FmReceiver.setSearchState(FmTransceiver.subSrchLevel_SrchComplete);
+ Log.v(TAG, "RxEvtList: CURRENT-STATE : Search ---> NEW-STATE : FMRxOn");
+ FmReceiver.mCallback.FmRxEvSearchCancelled();
+ break;
+ }
+ }
+
public void scanNxtCallback() {
Log.d(TAG, "scanNxtCallback enter");
FmReceiver.mCallback.FmRxEvSearchInProgress();