Merge branch 'lineage-21.0' of https://github.com/LineageOS/android_packages_apps_Dialer into leaf-3.2

Change-Id: Ic50dedd269bdcd3f718b2f4deeae0e1f48572885
diff --git a/java/com/android/dialer/app/res/drawable/ic_launcher_background.xml b/java/com/android/dialer/app/res/drawable/ic_launcher_background.xml
deleted file mode 100644
index 9e3a20f..0000000
--- a/java/com/android/dialer/app/res/drawable/ic_launcher_background.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     SPDX-FileCopyrightText: 2022 The LineageOS Project
-     SPDX-License-Identifier: Apache-2.0
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="108dp"
-    android:height="108dp"
-    android:viewportWidth="108"
-    android:viewportHeight="108">
-  <path
-      android:pathData="M0,0h108v108h-108z"
-      android:fillColor="#ffffff"/>
-  <path
-      android:pathData="M66.578,37.789C66.859,37.226 67,36.613 67,36H62V38C62,39.105 61.105,40 60,40H52C50.896,40 50,39.105 50,38V36H45C45,36.613 45.141,37.226 45.422,37.789L47.422,41.789C48.1,43.144 49.485,44 51,44H61C62.515,44 63.9,43.144 64.578,41.789L66.578,37.789ZM67,72H45C45,71.387 45.141,70.774 45.422,70.211L47.422,66.211C48.1,64.856 49.485,64 51,64H61C62.515,64 63.9,64.856 64.578,66.211L66.578,70.211C66.859,70.774 67,71.387 67,72Z"
-      android:fillColor="#CBDEFB"
-      android:fillType="evenOdd"/>
-</vector>
diff --git a/java/com/android/dialer/app/res/drawable/ic_launcher_foreground.xml b/java/com/android/dialer/app/res/drawable/ic_launcher_foreground.xml
deleted file mode 100644
index ca7d11c..0000000
--- a/java/com/android/dialer/app/res/drawable/ic_launcher_foreground.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     SPDX-FileCopyrightText: 2022 The LineageOS Project
-     SPDX-License-Identifier: Apache-2.0
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:aapt="http://schemas.android.com/aapt"
-    android:width="108dp"
-    android:height="108dp"
-    android:viewportWidth="108"
-    android:viewportHeight="108">
-  <group>
-    <clip-path
-        android:pathData="M0,0h108v108h-108z"/>
-    <path
-        android:pathData="M47.422,77.789C48.1,79.144 49.485,80 51,80H61C62.515,80 63.9,79.144 64.578,77.789L66.578,73.789C67.141,72.663 67.141,71.337 66.578,70.211L64.578,66.211C63.9,64.856 62.515,64 61,64H51C49.485,64 48.1,64.856 47.422,66.211L45.422,70.211C44.859,71.337 44.859,72.663 45.422,73.789L47.422,77.789Z"
-        android:fillColor="#193057"
-        android:fillType="evenOdd"/>
-    <path
-        android:pathData="M47.422,30.211C48.1,28.856 49.485,28 51,28H61C62.515,28 63.9,28.856 64.578,30.211L66.578,34.211C67.141,35.337 67.141,36.663 66.578,37.789L64.578,41.789C63.9,43.144 62.515,44 61,44H51C49.485,44 48.1,43.144 47.422,41.789L45.422,37.789C44.859,36.663 44.859,35.337 45.422,34.211L47.422,30.211Z"
-        android:fillColor="#193057"
-        android:fillType="evenOdd"/>
-    <path
-        android:pathData="M41,54C41,43.751 43.836,37.383 45.422,34.211L47.425,30.209C48.102,28.855 49.486,28 51,28H61C59.486,28 58.102,28.855 57.425,30.209L55.422,34.211C53.836,37.383 51,43.751 51,54C51,64.249 53.836,70.617 55.422,73.789L57.425,77.791C58.102,79.145 59.486,80 61,80H51C49.486,80 48.102,79.145 47.425,77.791L45.422,73.789C43.836,70.617 41,64.249 41,54Z"
-        android:fillColor="#4D84E9"/>
-    <path
-        android:pathData="M28.54,28.54m-72,0a72,72 0,1 1,144 0a72,72 0,1 1,-144 0"
-        android:fillAlpha="0.6">
-      <aapt:attr name="android:fillColor">
-        <gradient
-            android:gradientRadius="72"
-            android:centerX="28.54"
-            android:centerY="28.54"
-            android:type="radial">
-          <item android:offset="0" android:color="#19FFFFFF"/>
-          <item android:offset="1" android:color="#00FFFFFF"/>
-        </gradient>
-      </aapt:attr>
-    </path>
-  </group>
-</vector>
diff --git a/java/com/android/dialer/app/res/drawable/ic_launcher_monochrome.xml b/java/com/android/dialer/app/res/drawable/ic_launcher_monochrome.xml
deleted file mode 100644
index 7b3ef38..0000000
--- a/java/com/android/dialer/app/res/drawable/ic_launcher_monochrome.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     SPDX-FileCopyrightText: 2022 The LineageOS Project
-     SPDX-License-Identifier: Apache-2.0
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="108dp"
-    android:height="108dp"
-    android:viewportWidth="108"
-    android:viewportHeight="108">
-  <path
-      android:pathData="M57.53,28H57.175H50C48.486,28 47.102,28.855 46.425,30.209L44.422,34.211C42.836,37.383 40,43.751 40,54C40,64.249 42.836,70.617 44.422,73.789L46.425,77.791C47.102,79.145 48.486,80 50,80H57.172H57.53H60.53H61C62.515,80 63.9,79.144 64.578,77.789L66.578,73.789C67.141,72.663 67.141,71.337 66.578,70.211L64.578,66.211C63.9,64.856 62.515,64 61,64H53.996C53.406,61.197 53,57.876 53,54C53,50.124 53.406,46.803 53.996,44H61C62.515,44 63.9,43.144 64.578,41.789L66.578,37.789C67.141,36.663 67.141,35.337 66.578,34.211L64.578,30.211C63.9,28.856 62.515,28 61,28H60.53H57.53ZM54.739,75.132L55.674,77H50C49.622,77 49.277,76.787 49.108,76.449L47.105,72.447L47.105,72.447C45.65,69.537 43,63.636 43,54C43,44.364 45.65,38.463 47.105,35.553L47.105,35.553L49.108,31.551C49.277,31.213 49.622,31 50,31H55.674L54.739,32.868L54.739,32.869C53.022,36.303 50,43.139 50,54C50,64.861 53.022,71.697 54.739,75.131L54.739,75.132Z"
-      android:fillColor="#ffffffff"
-      android:fillType="evenOdd"/>
-</vector>
diff --git a/java/com/android/dialer/app/res/drawable/ic_monochrome.xml b/java/com/android/dialer/app/res/drawable/ic_monochrome.xml
new file mode 100644
index 0000000..087208c
--- /dev/null
+++ b/java/com/android/dialer/app/res/drawable/ic_monochrome.xml
@@ -0,0 +1,20 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt"
+    android:viewportWidth="432"
+    android:viewportHeight="432"
+    android:width="108dp"
+    android:height="108dp">
+    <path
+        android:pathData="M148.5 144L184.5 144L188 146.5L191 171.5L194 179.5L194 187.5L175 207.5Q184.6 224.9 198.5 238Q209.8 249.7 225.5 257L244.5 238L252.5 238L266.5 242L283.5 243L287 245.5L288 247.5L288 283.5L285.5 287L283.5 288L262.5 288L241.5 284L222.5 277L202.5 265L183 249L167 229.5L152 202.5L145 176.5Q146.5 171 144 169.5L144 148.5L146.5 145L148.5 144ZM151 145L149 146L145 151L146 173L152 198Q163 226 182 246Q200 264 225 276L249 284L260 286L268 286L269 287L282 287L284 286L287 282L287 250L286 248L282 244L269 244L258 242L251 239L245 240L226 259L204 245Q184 230 173 207L191 189L193 185L188 164L188 151L187 149L183 145L151 145Z"
+        android:fillColor="#FFFFFE"
+        android:fillAlpha="0.3764706"
+        android:strokeColor="#FFFFFE"
+        android:strokeAlpha="0.3764706"
+        android:strokeWidth="1" />
+    <path
+        android:pathData="M150.5 145L182.5 145L187 148.5L188 150.5L188 163.5L193 184.5L191 188.5L173 206.5Q184.4 229.6 203.5 245L225.5 259L244.5 240L250.5 239L257.5 242L268.5 244L281.5 244L286 247.5L287 249.5L287 281.5L283.5 286L281.5 287L268.5 287L267.5 286L259.5 286L248.5 284L224.5 276Q199.6 264.4 182 245.5Q162.5 226 152 197.5L146 172.5L145 150.5L148.5 146L150.5 145Z"
+        android:fillColor="#FEFEFF"
+        android:fillAlpha="0.9960784"
+        android:strokeColor="#FEFEFF"
+        android:strokeAlpha="0.9960784"
+        android:strokeWidth="1" />
+</vector>
diff --git a/java/com/android/dialer/app/res/mipmap-anydpi/ic_launcher.xml b/java/com/android/dialer/app/res/mipmap-anydpi/ic_launcher.xml
index b58c81f..c8b5591 100644
--- a/java/com/android/dialer/app/res/mipmap-anydpi/ic_launcher.xml
+++ b/java/com/android/dialer/app/res/mipmap-anydpi/ic_launcher.xml
@@ -1,10 +1,21 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--
-     SPDX-FileCopyrightText: 2022 The LineageOS Project
-     SPDX-License-Identifier: Apache-2.0
+<!-- 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.
 -->
 <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
-    <background android:drawable="@drawable/ic_launcher_background"/>
-    <foreground android:drawable="@drawable/ic_launcher_foreground"/>
-    <monochrome android:drawable="@drawable/ic_launcher_monochrome"/>
+    <background android:drawable="@mipmap/ic_background"/>
+    <foreground android:drawable="@mipmap/ic_foreground"/>
+    <monochrome android:drawable="@drawable/ic_monochrome" />
 </adaptive-icon>
+
diff --git a/java/com/android/dialer/app/res/mipmap-hdpi/ic_background.png b/java/com/android/dialer/app/res/mipmap-hdpi/ic_background.png
new file mode 100644
index 0000000..d0f68ba
--- /dev/null
+++ b/java/com/android/dialer/app/res/mipmap-hdpi/ic_background.png
Binary files differ
diff --git a/java/com/android/dialer/app/res/mipmap-hdpi/ic_foreground.png b/java/com/android/dialer/app/res/mipmap-hdpi/ic_foreground.png
new file mode 100644
index 0000000..65f15fc
--- /dev/null
+++ b/java/com/android/dialer/app/res/mipmap-hdpi/ic_foreground.png
Binary files differ
diff --git a/java/com/android/dialer/app/res/mipmap-mdpi/ic_background.png b/java/com/android/dialer/app/res/mipmap-mdpi/ic_background.png
new file mode 100644
index 0000000..55f05fe
--- /dev/null
+++ b/java/com/android/dialer/app/res/mipmap-mdpi/ic_background.png
Binary files differ
diff --git a/java/com/android/dialer/app/res/mipmap-mdpi/ic_foreground.png b/java/com/android/dialer/app/res/mipmap-mdpi/ic_foreground.png
new file mode 100644
index 0000000..049a633
--- /dev/null
+++ b/java/com/android/dialer/app/res/mipmap-mdpi/ic_foreground.png
Binary files differ
diff --git a/java/com/android/dialer/app/res/mipmap-xhdpi/ic_background.png b/java/com/android/dialer/app/res/mipmap-xhdpi/ic_background.png
new file mode 100644
index 0000000..6076ed3
--- /dev/null
+++ b/java/com/android/dialer/app/res/mipmap-xhdpi/ic_background.png
Binary files differ
diff --git a/java/com/android/dialer/app/res/mipmap-xhdpi/ic_foreground.png b/java/com/android/dialer/app/res/mipmap-xhdpi/ic_foreground.png
new file mode 100644
index 0000000..4dc42ff
--- /dev/null
+++ b/java/com/android/dialer/app/res/mipmap-xhdpi/ic_foreground.png
Binary files differ
diff --git a/java/com/android/dialer/app/res/mipmap-xxhdpi/ic_background.png b/java/com/android/dialer/app/res/mipmap-xxhdpi/ic_background.png
new file mode 100644
index 0000000..83d4bb9
--- /dev/null
+++ b/java/com/android/dialer/app/res/mipmap-xxhdpi/ic_background.png
Binary files differ
diff --git a/java/com/android/dialer/app/res/mipmap-xxhdpi/ic_foreground.png b/java/com/android/dialer/app/res/mipmap-xxhdpi/ic_foreground.png
new file mode 100644
index 0000000..0bb6676
--- /dev/null
+++ b/java/com/android/dialer/app/res/mipmap-xxhdpi/ic_foreground.png
Binary files differ
diff --git a/java/com/android/dialer/app/res/mipmap-xxxhdpi/ic_background.png b/java/com/android/dialer/app/res/mipmap-xxxhdpi/ic_background.png
new file mode 100644
index 0000000..fba7110
--- /dev/null
+++ b/java/com/android/dialer/app/res/mipmap-xxxhdpi/ic_background.png
Binary files differ
diff --git a/java/com/android/dialer/app/res/mipmap-xxxhdpi/ic_foreground.png b/java/com/android/dialer/app/res/mipmap-xxxhdpi/ic_foreground.png
new file mode 100644
index 0000000..1de54c0
--- /dev/null
+++ b/java/com/android/dialer/app/res/mipmap-xxxhdpi/ic_foreground.png
Binary files differ
diff --git a/java/com/android/dialer/app/res/values/leaf_strings.xml b/java/com/android/dialer/app/res/values/leaf_strings.xml
new file mode 100644
index 0000000..093a139
--- /dev/null
+++ b/java/com/android/dialer/app/res/values/leaf_strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2024 The LeafOS 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="auto_call_recording_title">Auto call recording</string>
+    <string name="auto_call_recording_key" translatable="false">auto_call_recording</string>
+</resources>
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 86f9284..45cba58 100644
--- a/java/com/android/dialer/app/res/xml/sound_settings.xml
+++ b/java/com/android/dialer/app/res/xml/sound_settings.xml
@@ -91,6 +91,11 @@
             android:title="@string/call_recording_format"
             app:iconSpaceReserved="false" />
 
+    <SwitchPreference
+      android:defaultValue="false"
+      android:key="@string/auto_call_recording_key"
+      android:title="@string/auto_call_recording_title"/>
+
     </PreferenceCategory>
 
 </PreferenceScreen>
diff --git a/java/com/android/incallui/CallButtonPresenter.java b/java/com/android/incallui/CallButtonPresenter.java
index 13b4977..23678fe 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.Trace;
+import android.os.Handler;
 import android.telecom.CallAudioState;
 import android.telecom.PhoneAccountHandle;
 
@@ -74,6 +75,7 @@
   private DialerCall call;
   private boolean isInCallButtonUiReady;
   private PhoneAccountHandle otherAccount;
+  private boolean isRecording = false;
 
   private final CallRecorder.RecordingProgressListener recordingProgressListener =
       new CallRecorder.RecordingProgressListener() {
@@ -114,6 +116,11 @@
 
     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());
@@ -144,6 +151,9 @@
   @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 +162,15 @@
     } else if (newState == InCallState.INCALL) {
       call = callList.getActiveOrBackgroundCall();
 
+    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 +186,9 @@
       }
       call = callList.getIncomingCall();
     } else {
+      if (isEnabled && recorder.isRecording()) {
+         recorder.finishRecording();
+      }
       call = null;
     }
 
@@ -299,21 +321,7 @@
   public void callRecordClicked(boolean checked) {
     CallRecorder recorder = CallRecorder.getInstance();
     if (checked) {
-      final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
-      boolean warningPresented = prefs.getBoolean(KEY_RECORDING_WARNING_PRESENTED, false);
-      if (!warningPresented) {
-        new AlertDialog.Builder(getActivity())
-            .setTitle(R.string.recording_warning_title)
-            .setMessage(R.string.recording_warning_text)
-            .setPositiveButton(R.string.onscreenCallRecordText, (dialog, which) -> {
-              prefs.edit()
-                  .putBoolean(KEY_RECORDING_WARNING_PRESENTED, true)
-                  .apply();
-              startCallRecordingOrAskForPermission();
-            })
-            .setNegativeButton(android.R.string.cancel, null)
-            .show();
-      } else {
+       if(!recorder.isRecording()) {
         startCallRecordingOrAskForPermission();
       }
     } else {