Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e35b6c7d authored by Nicholas Sauer's avatar Nicholas Sauer Committed by Android (Google) Code Review
Browse files

Merge "[FM] "Can't play the track you requested" pops up after tapping "LISTEN"" into lmp-mr1-dev

parents 85622165 3cf7f5aa
Loading
Loading
Loading
Loading
+25 −18
Original line number Diff line number Diff line
@@ -263,6 +263,7 @@ public class FmRecordActivity extends Activity implements
        mHandler.removeMessages(MSG_UPDATE_NOTIFICATION);
        if (mService != null) {
            mService.removeNotification();
            mService.updatePlayingNotification();
        }
    }

@@ -362,24 +363,11 @@ public class FmRecordActivity extends Activity implements
            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 @@ public class FmRecordActivity extends Activity implements
                case MSG_UPDATE_NOTIFICATION:
                    if (mService != null) {
                        updateRecordingNotification(mService.getRecordTime());
                        checkStorageSpaceAndStop();
                    }
                    mHandler.sendEmptyMessageDelayed(MSG_UPDATE_NOTIFICATION, 1000);
                    break;
@@ -420,6 +409,24 @@ public class FmRecordActivity extends Activity implements
        };
    };

    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;