am 3b221981: am abc57dfd: am e35b6c7d: Merge "[FM] "Can\'t play the track you requested" pops up after tapping "LISTEN"" into lmp-mr1-dev
* commit '3b221981acbb147cded601008d9f32aa5e8e9327':
[FM] "Can't play the track you requested" pops up after tapping "LISTEN"
diff --git a/src/com/android/fmradio/FmRecordActivity.java b/src/com/android/fmradio/FmRecordActivity.java
index 06e4a8b..f82bf29 100644
--- a/src/com/android/fmradio/FmRecordActivity.java
+++ b/src/com/android/fmradio/FmRecordActivity.java
@@ -263,6 +263,7 @@
mHandler.removeMessages(MSG_UPDATE_NOTIFICATION);
if (mService != null) {
mService.removeNotification();
+ mService.updatePlayingNotification();
}
}
@@ -362,24 +363,11 @@
switch (msg.what) {
case FmListener.MSGID_REFRESH:
if (mService != null) {
- long recordTime = mService.getRecordTime();
- recordTime = recordTime / 1000L;
- mMintues.setText(addPaddingForString(recordTime / TIME_BASE));
- mSeconds.setText(addPaddingForString(recordTime % TIME_BASE));
-
- // Check storage free space
- String recordingSdcard = FmUtils.getDefaultStoragePath();
- if (!FmUtils.hasEnoughSpace(recordingSdcard)) {
- // Need to record more than 1s.
- // Avoid calling MediaRecorder.stop() before native record starts.
- if (recordTime > 1000) {
- // Insufficient storage
- mService.stopRecordingAsync();
- Toast.makeText(FmRecordActivity.this,
- R.string.toast_sdcard_insufficient_space,
- Toast.LENGTH_SHORT).show();
- }
- }
+ long recordTimeInMillis = mService.getRecordTime();
+ long recordTimeInSec = recordTimeInMillis / 1000L;
+ mMintues.setText(addPaddingForString(recordTimeInSec / TIME_BASE));
+ mSeconds.setText(addPaddingForString(recordTimeInSec % TIME_BASE));
+ checkStorageSpaceAndStop();
}
mHandler.sendEmptyMessageDelayed(FmListener.MSGID_REFRESH, 1000);
break;
@@ -387,6 +375,7 @@
case MSG_UPDATE_NOTIFICATION:
if (mService != null) {
updateRecordingNotification(mService.getRecordTime());
+ checkStorageSpaceAndStop();
}
mHandler.sendEmptyMessageDelayed(MSG_UPDATE_NOTIFICATION, 1000);
break;
@@ -420,6 +409,24 @@
};
};
+ private void checkStorageSpaceAndStop() {
+ long recordTimeInMillis = mService.getRecordTime();
+ long recordTimeInSec = recordTimeInMillis / 1000L;
+ // Check storage free space
+ String recordingSdcard = FmUtils.getDefaultStoragePath();
+ if (!FmUtils.hasEnoughSpace(recordingSdcard)) {
+ // Need to record more than 1s.
+ // Avoid calling MediaRecorder.stop() before native record starts.
+ if (recordTimeInSec >= 1) {
+ // Insufficient storage
+ mService.stopRecordingAsync();
+ Toast.makeText(FmRecordActivity.this,
+ R.string.toast_sdcard_insufficient_space,
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ }
+
private void handleRecordError(int errorType) {
Log.d(TAG, "handleRecordError, errorType = " + errorType);
String showString = null;