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

Commit ec7335dd authored by Benson Huang's avatar Benson Huang Committed by Nicholas Sauer
Browse files

[FM] FM recording time will display incorrectly when recording time is beyond 60 minutes

Launch FM from Launcher and power up FM -> Select "Start
Recording" in options menu, check the Recording Timer Text
("00m00s" is OK) -> Wait for FM recording more than 60 minutes
(e.g. 61 minutes 20 seconds), click power key to unlock screen
and check the recording timer text in FM record, the recording
timer text will be "00m20s".

The fix is to follow SoundRecorder's way to show recording timer.

from: https://partner-android-review.googlesource.com/#/c/192375/1



Bug 18842895

Change-Id: Iefb385ab855e2e940d23632502c35bc3e27ad8a5
Signed-off-by: default avatarBenson Huang <benson.huang@mediatek.com>
parent 0dedb6b1
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ public class FmRecordActivity extends Activity implements
    private static final String FM_ENTER_RECORD_SCREEN = "fmradio.enter.record.screen";
    private static final String TAG_SAVE_RECORDINGD = "SaveRecording";
    private static final int MSG_UPDATE_NOTIFICATION = 1000;
    private static final int TIME_BASE = 60;
    private Context mContext;
    private TextView mMintues;
    private TextView mSeconds;
@@ -226,6 +227,7 @@ public class FmRecordActivity extends Activity implements
        }
        // Trigger to refreshing timer text if still in record
        if (!isStopRecording()) {
            mHandler.removeMessages(FmListener.MSGID_REFRESH);
            mHandler.sendEmptyMessage(FmListener.MSGID_REFRESH);
        }
        // Clear notification, it only need show when in background
@@ -331,6 +333,7 @@ public class FmRecordActivity extends Activity implements
            }
            mPlayIndicator.startAnimation();
            mStopRecordButton.setEnabled(true);
            mHandler.removeMessages(FmListener.MSGID_REFRESH);
            mHandler.sendEmptyMessage(FmListener.MSGID_REFRESH);
        };

@@ -340,6 +343,14 @@ public class FmRecordActivity extends Activity implements
        };
    };

    private String addPaddingForString(long time) {
        StringBuilder builder = new StringBuilder();
        if (time >= 0 && time < 10) {
            builder.append("0");
        }
        return builder.append(time).toString();
    }

    private final Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
@@ -347,11 +358,9 @@ public class FmRecordActivity extends Activity implements
                case FmListener.MSGID_REFRESH:
                    if (mService != null) {
                        long recordTime = mService.getRecordTime();
                        Date date = new Date(recordTime);
                        SimpleDateFormat format = new SimpleDateFormat("mm:ss");
                        String[] timeText = format.format(date).split(":");
                        mMintues.setText(timeText[0]);
                        mSeconds.setText(timeText[1]);
                        recordTime = recordTime / 1000L;
                        mMintues.setText(addPaddingForString(recordTime / TIME_BASE));
                        mSeconds.setText(addPaddingForString(recordTime % TIME_BASE));

                        // Check storage free space
                        String recordingSdcard = FmUtils.getDefaultStoragePath();