Update slice states when on Voip calling

This CL is used to register intent of AudioManager.STREAM_DEVICES_CHANGED_ACTION
to know that phone is on VOIP call. When received this intent, media slice will
to update UI. Then if audio mode is on-going call, we will hide the slice UI.

Bug: 132198606
Test: Test: make -j42 RunSettingsRoboTests
Change-Id: Ic17ebd319b3da8f42089d36ba530cfb57c93c4c6
This commit is contained in:
hughchen
2019-09-02 15:23:42 +08:00
parent cb3574c7d6
commit 059cb397cd
8 changed files with 131 additions and 44 deletions

View File

@@ -24,7 +24,6 @@ import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.telephony.TelephonyManager;
import android.util.Log;
import androidx.core.graphics.drawable.IconCompat;
@@ -115,13 +114,11 @@ public class MediaOutputIndicatorSlice implements CustomSliceable {
private boolean isVisible() {
// To decide Slice's visibility.
// Return true if
// 1. phone is not in ongoing call mode
// 1. AudioMode is not in on-going call
// 2. Bluetooth device is connected
final TelephonyManager telephonyManager =
(TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
return telephonyManager.getCallState() == TelephonyManager.CALL_STATE_IDLE
&& (!CollectionUtils.isEmpty(getConnectedA2dpDevices())
|| !CollectionUtils.isEmpty(getConnectedHearingAidDevices()));
return (!CollectionUtils.isEmpty(getConnectedA2dpDevices())
|| !CollectionUtils.isEmpty(getConnectedHearingAidDevices()))
&& !com.android.settingslib.Utils.isAudioModeOngoingCall(mContext);
}
private List<BluetoothDevice> getConnectedA2dpDevices() {