Hide audio switcher entry-point in the volume slice when in call am: c007158819

am: a60471e1e5

Change-Id: I29dc0c5d3f5ed9f5f37eedda06bdaf59575d074b
This commit is contained in:
Tim Peng
2019-05-12 19:22:41 -07:00
committed by android-build-merger
3 changed files with 49 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ 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;
@@ -113,9 +114,14 @@ public class MediaOutputIndicatorSlice implements CustomSliceable {
private boolean isVisible() {
// To decide Slice's visibility.
// return true if device is connected or previously connected, false for other cases.
return !CollectionUtils.isEmpty(getConnectedA2dpDevices())
|| !CollectionUtils.isEmpty(getConnectedHearingAidDevices());
// Return true if
// 1. phone is not in ongoing call mode
// 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()));
}
private List<BluetoothDevice> getConnectedA2dpDevices() {

View File

@@ -78,4 +78,9 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements
notifySliceChange();
}
}
@Override
public void onAudioModeChanged() {
notifySliceChange();
}
}