Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ LOCAL_SRC_FILES += $(call all-proto-files-under, $(BASE_DIR))
LOCAL_SRC_FILES += $(call all-Iaidl-files-under, $(BASE_DIR))
LOCAL_SRC_FILES := $(filter-out $(EXCLUDE_FILES),$(LOCAL_SRC_FILES))

LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/java

LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)

LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(RES_DIRS))
Expand Down
9 changes: 9 additions & 0 deletions assets/quantum/res/drawable/quantum_ic_record_white_36.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="36dp"
android:width="36dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M19,12C19,15.86 15.86,19 12,19C8.14,19 5,15.86 5,12C5,8.14 8.14,5 12,5C15.86,5 19,8.14 19,12Z" />
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
1 change: 1 addition & 0 deletions java/com/android/dialer/app/res/values/ids.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
<item name="context_menu_report_not_spam" type="id"/>
<item name="context_menu_delete" type="id"/>
<item name="settings_header_sounds_and_vibration" type="id"/>
<item name="settings_header_call_recording" type="id"/>
<item name="block_id" type="id"/>
</resources>
49 changes: 49 additions & 0 deletions java/com/android/dialer/app/res/values/strings_ext.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2013-2014 The CyanogenMod Project
Copyright (C) 2018 The LineageOS Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="call_recording_header_title">Call recording</string>

<string name="call_recording_output_format_title">Audio output format</string>

<string-array name="call_recording_output_format_entries" translatable="false">
<item>AAC in MPEG-4 container</item>
<item>AMR-WB</item>
</string-array>

<string-array name="call_recording_output_format_values" translatable="false">
<item>"0"</item>
<item>"1"</item>
</string-array>

<string name="call_recording_output_format_default" translatable="false">"0"</string>

<string name="call_recording_audio_source_title">Audio source</string>

<string-array name="call_recording_audio_source_entries" translatable="false">
<item>MIC (1)</item>
<item>VOICE_CALL (4)</item>
</string-array>

<string-array name="call_recording_audio_source_values" translatable="false">
<item>"1"</item>
<item>"4"</item>
</string-array>

<string name="call_recording_audio_source_default">"4"</string>

</resources>
27 changes: 27 additions & 0 deletions java/com/android/dialer/app/res/xml/call_recording_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

<ListPreference
android:key="call_recording_output_format"
android:title="@string/call_recording_output_format_title"
android:summary="%s"
android:entries="@array/call_recording_output_format_entries"
android:entryValues="@array/call_recording_output_format_values"
android:defaultValue="@string/call_recording_output_format_default" />

<ListPreference
android:key="call_recording_audio_source"
android:title="@string/call_recording_audio_source_title"
android:summary="%s"
android:entries="@array/call_recording_audio_source_entries"
android:entryValues="@array/call_recording_audio_source_values"
android:defaultValue="@string/call_recording_audio_source_default" />

<Preference
android:key="call_recording_warning"
android:persistent="false"
android:title="@string/call_recording_warning_settings_title"
android:summary="@string/recording_warning_text" />

</PreferenceScreen>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.android.dialer.app.settings;

import android.os.Bundle;
import android.preference.PreferenceFragment;
import com.android.dialer.app.R;
import com.android.dialer.callrecord.impl.CallRecorderService;

public class CallRecordingSettingsFragment extends PreferenceFragment {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.call_recording_settings);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ public void onBuildHeaders(List<Header> target) {
soundSettingsHeader.id = R.id.settings_header_sounds_and_vibration;
target.add(soundSettingsHeader);

Header callRecordingHeader = new Header();
callRecordingHeader.titleRes = R.string.call_recording_header_title;
callRecordingHeader.fragment = CallRecordingSettingsFragment.class.getName();
callRecordingHeader.id = R.id.settings_header_call_recording;
target.add(callRecordingHeader);

Header quickResponseSettingsHeader = new Header();
Intent quickResponseSettingsIntent =
new Intent(TelecomManager.ACTION_SHOW_RESPOND_VIA_SMS_SETTINGS);
Expand Down
26 changes: 26 additions & 0 deletions java/com/android/dialer/callrecord/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- Copyright (C) 2018 The LineageOS Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.dialer">

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />

<application>
<service android:name="com.android.dialer.callrecord.impl.CallRecorderService"
android:process="com.android.incallui" />
</application>
</manifest>
3 changes: 3 additions & 0 deletions java/com/android/dialer/callrecord/CallRecording.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.android.dialer.callrecord;

parcelable CallRecording;
107 changes: 107 additions & 0 deletions java/com/android/dialer/callrecord/CallRecording.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.android.dialer.callrecord;

import android.content.ContentValues;
import android.os.Environment;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.webkit.MimeTypeMap;

import java.io.File;

public final class CallRecording implements Parcelable {
public String phoneNumber;
public long creationTime;
public String fileName;
public long startRecordingTime;
public long mediaId;

public static final Parcelable.Creator<CallRecording> CREATOR =
new Parcelable.Creator<CallRecording>() {
@Override
public CallRecording createFromParcel(Parcel in) {
return new CallRecording(in);
}

@Override
public CallRecording[] newArray(int size) {
return new CallRecording[size];
}
};

public CallRecording(String phoneNumber, long creationTime,
String fileName, long startRecordingTime, long mediaId) {
this.phoneNumber = phoneNumber;
this.creationTime = creationTime;
this.fileName = fileName;
this.startRecordingTime = startRecordingTime;
this.mediaId = mediaId;
}

public CallRecording(Parcel in) {
phoneNumber = in.readString();
creationTime = in.readLong();
fileName = in.readString();
startRecordingTime = in.readLong();
mediaId = in.readLong();
}

public static ContentValues generateMediaInsertValues(String fileName, long creationTime) {
final ContentValues cv = new ContentValues(5);

cv.put(MediaStore.Audio.Media.RELATIVE_PATH, "Recordings/CallRecordings");
cv.put(MediaStore.Audio.Media.DISPLAY_NAME, fileName);
cv.put(MediaStore.Audio.Media.DATE_TAKEN, creationTime);
cv.put(MediaStore.Audio.Media.IS_PENDING, 1);

final String extension = MimeTypeMap.getFileExtensionFromUrl(fileName);
final String mime = !TextUtils.isEmpty(extension)
? MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension) : "audio/*";
cv.put(MediaStore.Audio.Media.MIME_TYPE, mime);

return cv;
}

public static ContentValues generateCompletedValues() {
final ContentValues cv = new ContentValues(1);
cv.put(MediaStore.Audio.Media.IS_PENDING, 0);
return cv;
}

@Override
public void writeToParcel(Parcel out, int flags) {
out.writeString(phoneNumber);
out.writeLong(creationTime);
out.writeString(fileName);
out.writeLong(startRecordingTime);
out.writeLong(mediaId);
}

@Override
public int describeContents() {
return 0;
}

@Override
public String toString() {
return "phoneNumber=" + phoneNumber + ", creationTime=" + creationTime +
", fileName=" + fileName + ", startRecordingTime=" + startRecordingTime;
}
}
37 changes: 37 additions & 0 deletions java/com/android/dialer/callrecord/ICallRecorderService.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.android.dialer.callrecord;

import com.android.dialer.callrecord.CallRecording;

/**
* Service for recording phone calls. Only one recording may be active at a time
* (i.e. every call to startRecording should be followed by a call to stopRecording).
*/
interface ICallRecorderService {
/**
* Start a recording.
*
* @return true if recording started successfully
*/
boolean startRecording(String phoneNumber, long creationTime);

/**
* stops the current recording
*
* @return call recording data including the output filename
*/
CallRecording stopRecording();

/**
* Recording status
*
* @return true if there is an active recording
*/
boolean isRecording();

/**
* Get recording currently in progress
*
* @return call recording object
*/
CallRecording getActiveRecording();
}
Loading