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.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -197,15 +196,13 @@ public class MediaOutputSlice 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. worker is not null
// 3. Bluetooth is enabled
final TelephonyManager telephonyManager =
(TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
return telephonyManager.getCallState() == TelephonyManager.CALL_STATE_IDLE
&& adapter.isEnabled()
return adapter.isEnabled()
&& !com.android.settingslib.Utils.isAudioModeOngoingCall(mContext)
&& getWorker() != null;
}
}