From e7b06539da77aca49d6fb7ae3bb8b6a03ea92469 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Sun, 12 Sep 2021 12:37:50 +0000 Subject: enable auto-recording feature Change-Id: Ie625437f422daaffb7b751776ad76039b0ac6041 --- .../android/dialer/app/res/values/cm_strings.xml | 4 ++++ .../android/dialer/app/res/xml/sound_settings.xml | 5 ++++ java/com/android/incallui/CallButtonPresenter.java | 27 ++++++++++++++++++++++ 3 files changed, 36 insertions(+) (limited to 'java/com/android') diff --git a/java/com/android/dialer/app/res/values/cm_strings.xml b/java/com/android/dialer/app/res/values/cm_strings.xml index 84d6ef735..3b6e88527 100644 --- a/java/com/android/dialer/app/res/values/cm_strings.xml +++ b/java/com/android/dialer/app/res/values/cm_strings.xml @@ -36,6 +36,10 @@ Call recording call_recording_format Audio format + + Record automatically + auto_call_recording + AMR-WB AAC diff --git a/java/com/android/dialer/app/res/xml/sound_settings.xml b/java/com/android/dialer/app/res/xml/sound_settings.xml index aa025874f..d31ea9e5c 100644 --- a/java/com/android/dialer/app/res/xml/sound_settings.xml +++ b/java/com/android/dialer/app/res/xml/sound_settings.xml @@ -83,6 +83,11 @@ android:entryValues="@array/call_recording_encoder_values" android:defaultValue="0" /> + + diff --git a/java/com/android/incallui/CallButtonPresenter.java b/java/com/android/incallui/CallButtonPresenter.java index cff283c21..c3ccdc1eb 100644 --- a/java/com/android/incallui/CallButtonPresenter.java +++ b/java/com/android/incallui/CallButtonPresenter.java @@ -22,6 +22,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.Bundle; import android.os.Trace; +import android.os.Handler; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.support.v4.os.UserManagerCompat; @@ -74,6 +75,7 @@ public class CallButtonPresenter private DialerCall call; private boolean isInCallButtonUiReady; private PhoneAccountHandle otherAccount; + private boolean isRecording = false; private CallRecorder.RecordingProgressListener recordingProgressListener = new CallRecorder.RecordingProgressListener() { @@ -115,6 +117,12 @@ public class CallButtonPresenter CallRecorder recorder = CallRecorder.getInstance(); recorder.addRecordingProgressListener(recordingProgressListener); + if (recorder.isRecording()) { + inCallButtonUi.setCallRecordingState(true); + } else { + inCallButtonUi.setCallRecordingState(false); + } + // Update the buttons state immediately for the current call onStateChange(InCallState.NO_CALLS, inCallPresenter.getInCallState(), CallList.getInstance()); isInCallButtonUiReady = true; @@ -144,6 +152,11 @@ public class CallButtonPresenter @Override public void onStateChange(InCallState oldState, InCallState newState, CallList callList) { Trace.beginSection("CallButtonPresenter.onStateChange"); + + CallRecorder recorder = CallRecorder.getInstance(); + boolean isEnabled = PreferenceManager.getDefaultSharedPreferences(context) + .getBoolean(context.getString(R.string.auto_call_recording_key), false); + if (call != null) { call.removeListener(this); } @@ -152,6 +165,17 @@ public class CallButtonPresenter } else if (newState == InCallState.INCALL) { call = callList.getActiveOrBackgroundCall(); + // Enable recording automatically according to preferences + if (!isRecording && isEnabled && call != null) { + isRecording = true; + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + callRecordClicked(true); + } + }, 500); + } + // When connected to voice mail, automatically shows the dialpad. // (On previous releases we showed it when in-call shows up, before waiting for // OUTGOING. We may want to do that once we start showing "Voice mail" label on @@ -167,6 +191,9 @@ public class CallButtonPresenter } call = callList.getIncomingCall(); } else { + if (isEnabled && recorder.isRecording()) { + recorder.finishRecording(); + } call = null; } -- cgit v1.2.3