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:
@@ -16,9 +16,16 @@
|
||||
|
||||
package com.android.settings.media;
|
||||
|
||||
import static android.media.AudioManager.STREAM_DEVICES_CHANGED_ACTION;
|
||||
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.bluetooth.Utils;
|
||||
@@ -36,10 +43,15 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements
|
||||
|
||||
private static final String TAG = "MediaOutputIndicatorWorker";
|
||||
|
||||
private final DevicesChangedBroadcastReceiver mReceiver;
|
||||
private final Context mContext;
|
||||
|
||||
private LocalBluetoothManager mLocalBluetoothManager;
|
||||
|
||||
public MediaOutputIndicatorWorker(Context context, Uri uri) {
|
||||
super(context, uri);
|
||||
mReceiver = new DevicesChangedBroadcastReceiver();
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,6 +61,8 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements
|
||||
Log.e(TAG, "Bluetooth is not supported on this device");
|
||||
return;
|
||||
}
|
||||
final IntentFilter intentFilter = new IntentFilter(STREAM_DEVICES_CHANGED_ACTION);
|
||||
mContext.registerReceiver(mReceiver, intentFilter);
|
||||
mLocalBluetoothManager.getEventManager().registerCallback(this);
|
||||
}
|
||||
|
||||
@@ -59,10 +73,11 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements
|
||||
return;
|
||||
}
|
||||
mLocalBluetoothManager.getEventManager().unregisterCallback(this);
|
||||
mContext.unregisterReceiver(mReceiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
public void close() {
|
||||
mLocalBluetoothManager = null;
|
||||
}
|
||||
|
||||
@@ -84,4 +99,14 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements
|
||||
public void onAudioModeChanged() {
|
||||
notifySliceChange();
|
||||
}
|
||||
|
||||
private class DevicesChangedBroadcastReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
final String action = intent.getAction();
|
||||
if (TextUtils.equals(AudioManager.STREAM_DEVICES_CHANGED_ACTION, action)) {
|
||||
notifySliceChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user