FM: Fix ANR due to incorrect error handling in stopRecording
stopRecording() API gets called from onRecordingStopped() callback
function. As a result, when recording can't be stopped successfully
in error scenarios, stopRecording() gets called in loop.
This fix removes the call stopRecording() from callback function and
does the required UI update.
CRs-Fixed: 943288
Change-Id: I0e2ea2adeb0c603f16541d04a5a244bc1fcd51d7
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index b025d4f..ff48847 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -1811,15 +1811,6 @@
}
private void stopRecording() {
- mRecording = false;
- DebugToasts("Stopped Recording", Toast.LENGTH_SHORT);
- if(null != mRecordUpdateHandlerThread) {
- mRecordUpdateHandlerThread.interrupt();
- }
- if(null != mRecordingMsgTV) {
- mRecordingMsgTV.setText("");
- setRecordingStartImage();
- }
if (mService != null) {
try {
mService.stopRecording();
@@ -1827,7 +1818,6 @@
e.printStackTrace();
}
}
- invalidateOptionsMenu();
}
private boolean isRecording() {
@@ -3155,7 +3145,15 @@
}
public void onRecordingStopped() {
Log.d(LOGTAG, "mServiceCallbacks.onRecordingStopped:");
- stopRecording();
+ mRecording = false;
+ if(null != mRecordUpdateHandlerThread) {
+ mRecordUpdateHandlerThread.interrupt();
+ }
+ if(null != mRecordingMsgTV) {
+ mRecordingMsgTV.setText("");
+ setRecordingStartImage();
+ }
+ invalidateOptionsMenu();
}
public void onRecordingStarted()
{