Merge "Move android.telecom.Response to internal impl" into main
diff --git a/Android.bp b/Android.bp
index f46c206..7e57a3f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -10,19 +10,12 @@
out: ["com/android/server/telecom/TelecomStatsLog.java"],
}
-filegroup {
- name: "Telecom-srcs",
+android_library {
+ name: "TelecomLib",
+ manifest: "AndroidManifestLib.xml",
srcs: [
"src/**/*.java",
":statslog-telecom-java-gen",
- ],
-}
-
-// Build the Telecom service.
-android_app {
- name: "Telecom",
- srcs: [
- ":Telecom-srcs",
"proto/**/*.proto",
],
static_libs: [
@@ -30,9 +23,6 @@
"androidx.core_core",
"telecom_flags_core_java_lib",
],
- libs: [
- "services",
- ],
resource_dirs: ["res"],
proto: {
type: "nano",
@@ -40,6 +30,22 @@
output_params: ["optional_field_style=accessors"],
},
platform_apis: true,
+}
+
+
+// Build the Telecom service.
+android_app {
+ name: "Telecom",
+ srcs: [
+ ],
+ static_libs: [
+ "TelecomLib",
+ ],
+ libs: [
+ "services",
+ ],
+ resource_dirs: [],
+ platform_apis: true,
certificate: "platform",
privileged: true,
optimize: {
@@ -50,6 +56,7 @@
android_test {
name: "TelecomUnitTests",
static_libs: [
+ "TelecomLib",
"android-ex-camera2",
"flag-junit",
"guava",
@@ -58,25 +65,15 @@
"platform-test-annotations",
"androidx.legacy_legacy-support-core-ui",
"androidx.legacy_legacy-support-core-utils",
- "androidx.core_core",
"androidx.fragment_fragment",
"androidx.test.ext.junit",
"platform-compat-test-rules",
- "telecom_flags_core_java_lib",
],
srcs: [
"tests/src/**/*.java",
- ":Telecom-srcs",
- "proto/**/*.proto",
],
- proto: {
- type: "nano",
- local_include_dirs: ["proto/"],
- output_params: ["optional_field_style=accessors"],
- },
resource_dirs: [
"tests/res",
- "res",
],
libs: [
"android.test.mock",
@@ -89,11 +86,6 @@
"libstaticjvmtiagent",
],
- aaptflags: [
- "--auto-add-overlay",
- "--extra-packages",
- "com.android.server.telecom",
- ],
manifest: "tests/AndroidManifest.xml",
optimize: {
enabled: false,
diff --git a/AndroidManifestLib.xml b/AndroidManifestLib.xml
new file mode 100644
index 0000000..9b40f6b
--- /dev/null
+++ b/AndroidManifestLib.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2024 The Android Open Source 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 package="com.android.server.telecom">
+</manifest>
diff --git a/flags/telecom_api_flags.aconfig b/flags/telecom_api_flags.aconfig
index 74cb447..36f20d8 100644
--- a/flags/telecom_api_flags.aconfig
+++ b/flags/telecom_api_flags.aconfig
@@ -27,3 +27,11 @@
description: "The key is used for dialer apps to mark missed calls as read when it gets the notification on reboot."
bug: "292597423"
}
+
+
+flag{
+ name: "set_mute_state"
+ namespace: "telecom"
+ description: "transactional calls need the ability to mute the call audio input"
+ bug: "310669304"
+}
diff --git a/flags/telecom_callaudioroutestatemachine_flags.aconfig b/flags/telecom_callaudioroutestatemachine_flags.aconfig
index 6f2c7fc..fe21c92 100644
--- a/flags/telecom_callaudioroutestatemachine_flags.aconfig
+++ b/flags/telecom_callaudioroutestatemachine_flags.aconfig
@@ -62,3 +62,10 @@
description: "Update supported route mask when Bluetooth devices audio connected."
bug: "301695370"
}
+
+flag {
+ name: "clear_communication_device_after_audio_ops_complete"
+ namespace: "telecom"
+ description: "Clear the requested communication device after the audio operations are completed."
+ bug: "315865533"
+}
diff --git a/src/com/android/server/telecom/CallAudioModeStateMachine.java b/src/com/android/server/telecom/CallAudioModeStateMachine.java
index 71956a1..6420f2e 100644
--- a/src/com/android/server/telecom/CallAudioModeStateMachine.java
+++ b/src/com/android/server/telecom/CallAudioModeStateMachine.java
@@ -280,7 +280,10 @@
mLocalLog.log("Enter UNFOCUSED");
if (mIsInitialized) {
// Clear any communication device that was requested previously.
- if (mFeatureFlags.callAudioCommunicationDeviceRefactor()) {
+ // Todo: Remove once clearCommunicationDeviceAfterAudioOpsComplete is
+ // completely rolled out.
+ if (mFeatureFlags.callAudioCommunicationDeviceRefactor()
+ && !mFeatureFlags.clearCommunicationDeviceAfterAudioOpsComplete()) {
mCommunicationDeviceTracker.clearCommunicationDevice(mCommunicationDeviceTracker
.getCurrentLocallyRequestedCommunicationDevice());
}
@@ -353,6 +356,12 @@
} else {
mAudioManager.abandonAudioFocusForCall();
}
+ // Clear requested communication device after the call ends.
+ if (mFeatureFlags.clearCommunicationDeviceAfterAudioOpsComplete()) {
+ mCommunicationDeviceTracker.clearCommunicationDevice(
+ mCommunicationDeviceTracker
+ .getCurrentLocallyRequestedCommunicationDevice());
+ }
return HANDLED;
default:
// The forced focus switch commands are handled by BaseState.
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
old mode 100755
new mode 100644
index 5231a8a..5734405
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -73,6 +73,7 @@
import android.os.Process;
import android.os.ResultReceiver;
import android.os.SystemClock;
+import android.os.SystemProperties;
import android.os.SystemVibrator;
import android.os.Trace;
import android.os.UserHandle;
@@ -2999,10 +3000,6 @@
Log.d(this, "answerCall: Incoming call = %s Ongoing call %s", call, activeCall);
}
// Hold or disconnect the active call and request call focus for the incoming call.
- Bundle bundle = new Bundle();
- bundle.putLong(TelecomManager.EXTRA_CALL_ANSWERED_TIME_MILLIS,
- mClockProxy.currentTimeMillis());
- call.putConnectionServiceExtras(bundle);
holdActiveCallForNewCall(call);
mConnectionSvrFocusMgr.requestFocus(
call,
@@ -3154,9 +3151,8 @@
* @return {@code true} if the speakerphone should automatically be enabled.
*/
private static boolean isSpeakerEnabledForVideoCalls() {
- return TelephonyProperties.videocall_audio_output()
- .orElse(TelecomManager.AUDIO_OUTPUT_DEFAULT)
- == TelecomManager.AUDIO_OUTPUT_ENABLE_SPEAKER;
+ return SystemProperties.getInt(TelecomManager.PROPERTY_VIDEOCALL_AUDIO_OUTPUT,
+ TelecomManager.AUDIO_OUTPUT_DEFAULT) == TelecomManager.AUDIO_OUTPUT_ENABLE_SPEAKER;
}
/**
@@ -3523,7 +3519,7 @@
}
/** Called by the in-call UI to change the mute state. */
- void mute(boolean shouldMute) {
+ public void mute(boolean shouldMute) {
if (isInEmergencyCall() && shouldMute) {
Log.i(this, "Refusing to turn on mute because we're in an emergency call");
shouldMute = false;
diff --git a/src/com/android/server/telecom/TransactionalServiceWrapper.java b/src/com/android/server/telecom/TransactionalServiceWrapper.java
index 02ccef7..938ee58 100644
--- a/src/com/android/server/telecom/TransactionalServiceWrapper.java
+++ b/src/com/android/server/telecom/TransactionalServiceWrapper.java
@@ -46,6 +46,7 @@
import com.android.server.telecom.voip.ParallelTransaction;
import com.android.server.telecom.voip.RequestNewActiveCallTransaction;
import com.android.server.telecom.voip.SerialTransaction;
+import com.android.server.telecom.voip.SetMuteStateTransaction;
import com.android.server.telecom.voip.TransactionManager;
import com.android.server.telecom.voip.VoipCallTransaction;
import com.android.server.telecom.voip.VoipCallTransactionResult;
@@ -225,6 +226,18 @@
}
@Override
+ public void setMuteState(boolean isMuted, android.os.ResultReceiver callback)
+ throws RemoteException {
+ try {
+ Log.startSession("TSW.sMS");
+ addTransactionsToManager(
+ new SetMuteStateTransaction(mCallsManager, isMuted), callback);
+ } finally {
+ Log.endSession();
+ }
+ }
+
+ @Override
public void startCallStreaming(String callId, android.os.ResultReceiver callback)
throws RemoteException {
try {
diff --git a/src/com/android/server/telecom/voip/SetMuteStateTransaction.java b/src/com/android/server/telecom/voip/SetMuteStateTransaction.java
new file mode 100644
index 0000000..d9f7329
--- /dev/null
+++ b/src/com/android/server/telecom/voip/SetMuteStateTransaction.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2024 The Android Open Source 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.server.telecom.voip;
+
+import android.util.Log;
+
+import com.android.server.telecom.CallsManager;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
+
+/**
+ * This transaction should be used to change the global mute state for transactional
+ * calls. There is currently no way for this transaction to fail.
+ */
+public class SetMuteStateTransaction extends VoipCallTransaction {
+
+ private static final String TAG = SetMuteStateTransaction.class.getSimpleName();
+ private final CallsManager mCallsManager;
+ private final boolean mIsMuted;
+
+ public SetMuteStateTransaction(CallsManager callsManager, boolean isMuted) {
+ super(callsManager.getLock());
+ mCallsManager = callsManager;
+ mIsMuted = isMuted;
+ }
+
+ @Override
+ public CompletionStage<VoipCallTransactionResult> processTransaction(Void v) {
+ Log.d(TAG, "processTransaction");
+ CompletableFuture<VoipCallTransactionResult> future = new CompletableFuture<>();
+
+ mCallsManager.mute(mIsMuted);
+
+ future.complete(new VoipCallTransactionResult(
+ VoipCallTransactionResult.RESULT_SUCCEED,
+ "The Mute State was changed successfully"));
+
+ return future;
+ }
+}