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

Commit a42ff998 authored by Aayush Gupta's avatar Aayush Gupta Committed by Michael Bestas
Browse files

GoodQualityRecorder: Init MediaRecorder with context

Current constructor is deprecated.
Ref: https://developer.android.com/reference/android/media/MediaRecorder#public-constructors



Signed-off-by: default avatarAayush Gupta <aayushgupta219@gmail.com>
Change-Id: I7c2dbb2973fe3878e84323b120eb04ed52b6eed9
parent be019e15
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@
package org.lineageos.recorder.service;

import android.Manifest;
import android.content.Context;
import android.media.MediaRecorder;
import android.os.Build;

import androidx.annotation.RequiresPermission;

@@ -29,11 +31,20 @@ public class GoodQualityRecorder implements SoundRecording {

    private MediaRecorder mRecorder = null;
    private boolean mIsPaused = false;
    private final Context mContext;

    public GoodQualityRecorder(Context context) {
        this.mContext = context;
    }

    @Override
    @RequiresPermission(Manifest.permission.RECORD_AUDIO)
    public void startRecording(Path path) throws IOException {
        if (Build.VERSION.SDK_INT >= 31) {
            mRecorder = new MediaRecorder(mContext);
        } else {
            mRecorder = new MediaRecorder();
        }
        mRecorder.setOutputFile(path.toFile());
        mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
+1 −1
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@ public class SoundRecorderService extends Service {

        mRecorder = mPreferencesManager.getRecordInHighQuality()
                ? new HighQualityRecorder()
                : new GoodQualityRecorder();
                : new GoodQualityRecorder(this);

        final Optional<Path> optPath = createNewAudioFile(fileName, mRecorder.getFileExtension());
        if (optPath.isPresent()) {