Merge "[Audiosharing] Clean up dup codes" into main
This commit is contained in:
@@ -23,7 +23,6 @@ import android.util.Log;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
||||||
import com.android.settings.connecteddevice.audiosharing.AudioSharingUtils;
|
|
||||||
import com.android.settingslib.bluetooth.BluetoothUtils;
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
@@ -77,7 +76,7 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
|||||||
// It would show in Available Devices group if the audio sharing flag is disabled or
|
// It would show in Available Devices group if the audio sharing flag is disabled or
|
||||||
// the device is not in the audio sharing session.
|
// the device is not in the audio sharing session.
|
||||||
if (cachedDevice.isConnectedLeAudioDevice()) {
|
if (cachedDevice.isConnectedLeAudioDevice()) {
|
||||||
if (AudioSharingUtils.isFeatureEnabled()
|
if (BluetoothUtils.isAudioSharingEnabled()
|
||||||
&& BluetoothUtils.hasConnectedBroadcastSource(
|
&& BluetoothUtils.hasConnectedBroadcastSource(
|
||||||
cachedDevice, mLocalBtManager)) {
|
cachedDevice, mLocalBtManager)) {
|
||||||
Log.d(
|
Log.d(
|
||||||
|
@@ -45,7 +45,6 @@ import com.android.settings.bluetooth.BluetoothDevicePreference;
|
|||||||
import com.android.settings.bluetooth.BluetoothDeviceUpdater;
|
import com.android.settings.bluetooth.BluetoothDeviceUpdater;
|
||||||
import com.android.settings.bluetooth.Utils;
|
import com.android.settings.bluetooth.Utils;
|
||||||
import com.android.settings.connecteddevice.audiosharing.AudioSharingDialogHandler;
|
import com.android.settings.connecteddevice.audiosharing.AudioSharingDialogHandler;
|
||||||
import com.android.settings.connecteddevice.audiosharing.AudioSharingUtils;
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
@@ -180,7 +179,7 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
|||||||
super(context, KEY);
|
super(context, KEY);
|
||||||
mBtManager = Utils.getLocalBtManager(mContext);
|
mBtManager = Utils.getLocalBtManager(mContext);
|
||||||
mExecutor = Executors.newSingleThreadExecutor();
|
mExecutor = Executors.newSingleThreadExecutor();
|
||||||
if (AudioSharingUtils.isFeatureEnabled()) {
|
if (BluetoothUtils.isAudioSharingEnabled()) {
|
||||||
mBroadcast =
|
mBroadcast =
|
||||||
mBtManager == null
|
mBtManager == null
|
||||||
? null
|
? null
|
||||||
@@ -201,7 +200,7 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
|||||||
Log.d(TAG, "onStart() Bluetooth is not supported on this device");
|
Log.d(TAG, "onStart() Bluetooth is not supported on this device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (AudioSharingUtils.isFeatureEnabled()) {
|
if (BluetoothUtils.isAudioSharingEnabled()) {
|
||||||
registerAudioSharingCallbacks();
|
registerAudioSharingCallbacks();
|
||||||
}
|
}
|
||||||
mBtManager.getEventManager().registerCallback(this);
|
mBtManager.getEventManager().registerCallback(this);
|
||||||
@@ -217,7 +216,7 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
|||||||
Log.d(TAG, "onStop() Bluetooth is not supported on this device");
|
Log.d(TAG, "onStop() Bluetooth is not supported on this device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (AudioSharingUtils.isFeatureEnabled()) {
|
if (BluetoothUtils.isAudioSharingEnabled()) {
|
||||||
unregisterAudioSharingCallbacks();
|
unregisterAudioSharingCallbacks();
|
||||||
}
|
}
|
||||||
if (mBluetoothDeviceUpdater != null) {
|
if (mBluetoothDeviceUpdater != null) {
|
||||||
@@ -279,7 +278,7 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
|||||||
public void onDeviceClick(Preference preference) {
|
public void onDeviceClick(Preference preference) {
|
||||||
final CachedBluetoothDevice cachedDevice =
|
final CachedBluetoothDevice cachedDevice =
|
||||||
((BluetoothDevicePreference) preference).getBluetoothDevice();
|
((BluetoothDevicePreference) preference).getBluetoothDevice();
|
||||||
if (AudioSharingUtils.isFeatureEnabled() && mDialogHandler != null) {
|
if (BluetoothUtils.isAudioSharingEnabled() && mDialogHandler != null) {
|
||||||
mDialogHandler.handleDeviceConnected(cachedDevice, /* userTriggered= */ true);
|
mDialogHandler.handleDeviceConnected(cachedDevice, /* userTriggered= */ true);
|
||||||
FeatureFactory.getFeatureFactory().getMetricsFeatureProvider()
|
FeatureFactory.getFeatureFactory().getMetricsFeatureProvider()
|
||||||
.action(mContext, SettingsEnums.ACTION_MEDIA_DEVICE_CLICK);
|
.action(mContext, SettingsEnums.ACTION_MEDIA_DEVICE_CLICK);
|
||||||
@@ -295,7 +294,7 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
|||||||
fragment.getContext(),
|
fragment.getContext(),
|
||||||
AvailableMediaDeviceGroupController.this,
|
AvailableMediaDeviceGroupController.this,
|
||||||
fragment.getMetricsCategory());
|
fragment.getMetricsCategory());
|
||||||
if (AudioSharingUtils.isFeatureEnabled()) {
|
if (BluetoothUtils.isAudioSharingEnabled()) {
|
||||||
mDialogHandler = new AudioSharingDialogHandler(mContext, fragment);
|
mDialogHandler = new AudioSharingDialogHandler(mContext, fragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -342,8 +341,8 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
|||||||
if (isAudioModeOngoingCall(mContext)) {
|
if (isAudioModeOngoingCall(mContext)) {
|
||||||
// in phone call
|
// in phone call
|
||||||
titleResId = R.string.connected_device_call_device_title;
|
titleResId = R.string.connected_device_call_device_title;
|
||||||
} else if (AudioSharingUtils.isFeatureEnabled()
|
} else if (BluetoothUtils.isAudioSharingEnabled()
|
||||||
&& AudioSharingUtils.isBroadcasting(mBtManager)) {
|
&& BluetoothUtils.isBroadcasting(mBtManager)) {
|
||||||
// without phone call, in audio sharing
|
// without phone call, in audio sharing
|
||||||
titleResId = R.string.audio_sharing_media_device_group_title;
|
titleResId = R.string.audio_sharing_media_device_group_title;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -28,13 +28,13 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.connecteddevice.audiosharing.AudioSharingDevicePreferenceController;
|
import com.android.settings.connecteddevice.audiosharing.AudioSharingDevicePreferenceController;
|
||||||
import com.android.settings.connecteddevice.audiosharing.AudioSharingUtils;
|
|
||||||
import com.android.settings.core.SettingsUIDeviceConfig;
|
import com.android.settings.core.SettingsUIDeviceConfig;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.overlay.SurveyFeatureProvider;
|
import com.android.settings.overlay.SurveyFeatureProvider;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.slices.SlicePreferenceController;
|
import com.android.settings.slices.SlicePreferenceController;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.HearingAidStatsLogUtils;
|
import com.android.settingslib.bluetooth.HearingAidStatsLogUtils;
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
|||||||
+ ", action : "
|
+ ", action : "
|
||||||
+ action);
|
+ action);
|
||||||
}
|
}
|
||||||
if (AudioSharingUtils.isFeatureEnabled()) {
|
if (BluetoothUtils.isAudioSharingEnabled()) {
|
||||||
use(AudioSharingDevicePreferenceController.class).init(this);
|
use(AudioSharingDevicePreferenceController.class).init(this);
|
||||||
}
|
}
|
||||||
use(AvailableMediaDeviceGroupController.class).init(this);
|
use(AvailableMediaDeviceGroupController.class).init(this);
|
||||||
|
@@ -19,12 +19,13 @@ package com.android.settings.connecteddevice.audiosharing;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
|
|
||||||
public class AudioSharingActivity extends SettingsActivity {
|
public class AudioSharingActivity extends SettingsActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedState) {
|
protected void onCreate(Bundle savedState) {
|
||||||
super.onCreate(savedState);
|
super.onCreate(savedState);
|
||||||
if (!AudioSharingUtils.isFeatureEnabled()) {
|
if (!BluetoothUtils.isAudioSharingEnabled()) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,6 +29,7 @@ import androidx.preference.PreferenceScreen;
|
|||||||
|
|
||||||
import com.android.settings.bluetooth.Utils;
|
import com.android.settings.bluetooth.Utils;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||||
@@ -54,7 +55,7 @@ public abstract class AudioSharingBasePreferenceController extends BasePreferenc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AudioSharingUtils.isFeatureEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -55,7 +55,7 @@ public class AudioSharingBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
|||||||
if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) {
|
if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) {
|
||||||
// If device is LE audio device and has a broadcast source,
|
// If device is LE audio device and has a broadcast source,
|
||||||
// it would show in audio sharing devices group.
|
// it would show in audio sharing devices group.
|
||||||
if (AudioSharingUtils.isFeatureEnabled()
|
if (BluetoothUtils.isAudioSharingEnabled()
|
||||||
&& cachedDevice.isConnectedLeAudioDevice()
|
&& cachedDevice.isConnectedLeAudioDevice()
|
||||||
&& BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, mLocalBtManager)) {
|
&& BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, mLocalBtManager)) {
|
||||||
isFilterMatched = true;
|
isFilterMatched = true;
|
||||||
|
@@ -29,6 +29,7 @@ import androidx.fragment.app.FragmentManager;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ import java.util.List;
|
|||||||
public class AudioSharingCallAudioDialogFragment extends InstrumentedDialogFragment {
|
public class AudioSharingCallAudioDialogFragment extends InstrumentedDialogFragment {
|
||||||
private static final String TAG = "CallsAndAlarmsDialog";
|
private static final String TAG = "CallsAndAlarmsDialog";
|
||||||
private static final String BUNDLE_KEY_DEVICE_ITEMS = "bundle_key_device_items";
|
private static final String BUNDLE_KEY_DEVICE_ITEMS = "bundle_key_device_items";
|
||||||
|
private static final String BUNDLE_KEY_CHECKED_ITEM_INDEX = "bundle_key_checked_index";
|
||||||
|
|
||||||
// The host creates an instance of this dialog fragment must implement this interface to receive
|
// The host creates an instance of this dialog fragment must implement this interface to receive
|
||||||
// event callbacks.
|
// event callbacks.
|
||||||
@@ -65,8 +67,9 @@ public class AudioSharingCallAudioDialogFragment extends InstrumentedDialogFragm
|
|||||||
public static void show(
|
public static void show(
|
||||||
@NonNull Fragment host,
|
@NonNull Fragment host,
|
||||||
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
||||||
|
int checkedItemIndex,
|
||||||
@NonNull DialogEventListener listener) {
|
@NonNull DialogEventListener listener) {
|
||||||
if (!AudioSharingUtils.isFeatureEnabled()) return;
|
if (!BluetoothUtils.isAudioSharingEnabled()) return;
|
||||||
final FragmentManager manager;
|
final FragmentManager manager;
|
||||||
try {
|
try {
|
||||||
manager = host.getChildFragmentManager();
|
manager = host.getChildFragmentManager();
|
||||||
@@ -78,6 +81,7 @@ public class AudioSharingCallAudioDialogFragment extends InstrumentedDialogFragm
|
|||||||
if (manager.findFragmentByTag(TAG) == null) {
|
if (manager.findFragmentByTag(TAG) == null) {
|
||||||
final Bundle bundle = new Bundle();
|
final Bundle bundle = new Bundle();
|
||||||
bundle.putParcelableList(BUNDLE_KEY_DEVICE_ITEMS, deviceItems);
|
bundle.putParcelableList(BUNDLE_KEY_DEVICE_ITEMS, deviceItems);
|
||||||
|
bundle.putInt(BUNDLE_KEY_CHECKED_ITEM_INDEX, checkedItemIndex);
|
||||||
final AudioSharingCallAudioDialogFragment dialog =
|
final AudioSharingCallAudioDialogFragment dialog =
|
||||||
new AudioSharingCallAudioDialogFragment();
|
new AudioSharingCallAudioDialogFragment();
|
||||||
dialog.setArguments(bundle);
|
dialog.setArguments(bundle);
|
||||||
@@ -91,6 +95,7 @@ public class AudioSharingCallAudioDialogFragment extends InstrumentedDialogFragm
|
|||||||
Bundle arguments = requireArguments();
|
Bundle arguments = requireArguments();
|
||||||
List<AudioSharingDeviceItem> deviceItems =
|
List<AudioSharingDeviceItem> deviceItems =
|
||||||
arguments.getParcelable(BUNDLE_KEY_DEVICE_ITEMS, List.class);
|
arguments.getParcelable(BUNDLE_KEY_DEVICE_ITEMS, List.class);
|
||||||
|
int checkedItemIndex = arguments.getInt(BUNDLE_KEY_CHECKED_ITEM_INDEX, -1);
|
||||||
AlertDialog.Builder builder =
|
AlertDialog.Builder builder =
|
||||||
new AlertDialog.Builder(getActivity())
|
new AlertDialog.Builder(getActivity())
|
||||||
.setTitle(R.string.audio_sharing_call_audio_title);
|
.setTitle(R.string.audio_sharing_call_audio_title);
|
||||||
@@ -98,18 +103,11 @@ public class AudioSharingCallAudioDialogFragment extends InstrumentedDialogFragm
|
|||||||
Log.d(TAG, "Create dialog error: null deviceItems");
|
Log.d(TAG, "Create dialog error: null deviceItems");
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
int checkedItem = -1;
|
|
||||||
for (AudioSharingDeviceItem item : deviceItems) {
|
|
||||||
int fallbackActiveGroupId = AudioSharingUtils.getFallbackActiveGroupId(getContext());
|
|
||||||
if (item.getGroupId() == fallbackActiveGroupId) {
|
|
||||||
checkedItem = deviceItems.indexOf(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String[] choices =
|
String[] choices =
|
||||||
deviceItems.stream().map(AudioSharingDeviceItem::getName).toArray(String[]::new);
|
deviceItems.stream().map(AudioSharingDeviceItem::getName).toArray(String[]::new);
|
||||||
builder.setSingleChoiceItems(
|
builder.setSingleChoiceItems(
|
||||||
choices,
|
choices,
|
||||||
checkedItem,
|
checkedItemIndex,
|
||||||
(dialog, which) -> {
|
(dialog, which) -> {
|
||||||
if (sListener != null) {
|
if (sListener != null) {
|
||||||
sListener.onItemClick(deviceItems.get(which));
|
sListener.onItemClick(deviceItems.get(which));
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.connecteddevice.audiosharing;
|
package com.android.settings.connecteddevice.audiosharing;
|
||||||
|
|
||||||
import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtils.SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID;
|
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothCsipSetCoordinator;
|
import android.bluetooth.BluetoothCsipSetCoordinator;
|
||||||
@@ -197,13 +195,15 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
|||||||
}
|
}
|
||||||
updateDeviceItemsInSharingSession();
|
updateDeviceItemsInSharingSession();
|
||||||
if (!mDeviceItemsInSharingSession.isEmpty()) {
|
if (!mDeviceItemsInSharingSession.isEmpty()) {
|
||||||
|
int checkedItemIndex = getActiveItemIndex(mDeviceItemsInSharingSession);
|
||||||
AudioSharingCallAudioDialogFragment.show(
|
AudioSharingCallAudioDialogFragment.show(
|
||||||
mFragment,
|
mFragment,
|
||||||
mDeviceItemsInSharingSession,
|
mDeviceItemsInSharingSession,
|
||||||
|
checkedItemIndex,
|
||||||
(AudioSharingDeviceItem item) -> {
|
(AudioSharingDeviceItem item) -> {
|
||||||
int currentGroupId =
|
int currentGroupId =
|
||||||
AudioSharingUtils.getFallbackActiveGroupId(
|
BluetoothUtils.getPrimaryGroupIdForBroadcast(
|
||||||
mContext);
|
mContext.getContentResolver());
|
||||||
if (item.getGroupId() == currentGroupId) {
|
if (item.getGroupId() == currentGroupId) {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
@@ -220,7 +220,7 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
|||||||
TAG,
|
TAG,
|
||||||
"Set fallback active device: "
|
"Set fallback active device: "
|
||||||
+ lead.getDevice()
|
+ lead.getDevice()
|
||||||
.getAnonymizedAddress());
|
.getAnonymizedAddress());
|
||||||
lead.setActive();
|
lead.setActive();
|
||||||
logCallAudioDeviceChange(currentGroupId, lead);
|
logCallAudioDeviceChange(currentGroupId, lead);
|
||||||
} else {
|
} else {
|
||||||
@@ -300,7 +300,7 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
|||||||
Log.d(TAG, "registerCallbacks()");
|
Log.d(TAG, "registerCallbacks()");
|
||||||
mEventManager.registerCallback(this);
|
mEventManager.registerCallback(this);
|
||||||
mContentResolver.registerContentObserver(
|
mContentResolver.registerContentObserver(
|
||||||
Settings.Secure.getUriFor(SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID),
|
Settings.Secure.getUriFor(BluetoothUtils.getPrimaryGroupIdUriForBroadcast()),
|
||||||
false,
|
false,
|
||||||
mSettingsObserver);
|
mSettingsObserver);
|
||||||
mAssistant.registerServiceCallBack(mExecutor, mBroadcastAssistantCallback);
|
mAssistant.registerServiceCallBack(mExecutor, mBroadcastAssistantCallback);
|
||||||
@@ -347,7 +347,8 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
|||||||
*/
|
*/
|
||||||
private void updateSummary() {
|
private void updateSummary() {
|
||||||
updateDeviceItemsInSharingSession();
|
updateDeviceItemsInSharingSession();
|
||||||
int fallbackActiveGroupId = AudioSharingUtils.getFallbackActiveGroupId(mContext);
|
int fallbackActiveGroupId = BluetoothUtils.getPrimaryGroupIdForBroadcast(
|
||||||
|
mContext.getContentResolver());
|
||||||
if (fallbackActiveGroupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
|
if (fallbackActiveGroupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
|
||||||
for (AudioSharingDeviceItem item : mDeviceItemsInSharingSession) {
|
for (AudioSharingDeviceItem item : mDeviceItemsInSharingSession) {
|
||||||
if (item.getGroupId() == fallbackActiveGroupId) {
|
if (item.getGroupId() == fallbackActiveGroupId) {
|
||||||
@@ -386,6 +387,18 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
|||||||
mBtManager, mGroupedConnectedDevices, /* filterByInSharing= */ true);
|
mBtManager, mGroupedConnectedDevices, /* filterByInSharing= */ true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getActiveItemIndex(List<AudioSharingDeviceItem> deviceItems) {
|
||||||
|
int checkedItemIndex = -1;
|
||||||
|
int fallbackActiveGroupId =
|
||||||
|
BluetoothUtils.getPrimaryGroupIdForBroadcast(mContext.getContentResolver());
|
||||||
|
for (AudioSharingDeviceItem item : deviceItems) {
|
||||||
|
if (item.getGroupId() == fallbackActiveGroupId) {
|
||||||
|
return deviceItems.indexOf(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return checkedItemIndex;
|
||||||
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void logCallAudioDeviceChange(int currentGroupId, CachedBluetoothDevice target) {
|
void logCallAudioDeviceChange(int currentGroupId, CachedBluetoothDevice target) {
|
||||||
var unused =
|
var unused =
|
||||||
@@ -393,7 +406,7 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
|||||||
() -> {
|
() -> {
|
||||||
ChangeCallAudioType type = ChangeCallAudioType.UNKNOWN;
|
ChangeCallAudioType type = ChangeCallAudioType.UNKNOWN;
|
||||||
if (mCacheManager != null) {
|
if (mCacheManager != null) {
|
||||||
int targetDeviceGroupId = AudioSharingUtils.getGroupId(target);
|
int targetDeviceGroupId = BluetoothUtils.getGroupId(target);
|
||||||
List<BluetoothDevice> mostRecentDevices =
|
List<BluetoothDevice> mostRecentDevices =
|
||||||
BluetoothAdapter.getDefaultAdapter()
|
BluetoothAdapter.getDefaultAdapter()
|
||||||
.getMostRecentlyConnectedDevices();
|
.getMostRecentlyConnectedDevices();
|
||||||
@@ -405,7 +418,7 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
|||||||
mCacheManager.findDevice(device);
|
mCacheManager.findDevice(device);
|
||||||
int groupId =
|
int groupId =
|
||||||
cachedDevice != null
|
cachedDevice != null
|
||||||
? AudioSharingUtils.getGroupId(cachedDevice)
|
? BluetoothUtils.getGroupId(cachedDevice)
|
||||||
: BluetoothCsipSetCoordinator.GROUP_ID_INVALID;
|
: BluetoothCsipSetCoordinator.GROUP_ID_INVALID;
|
||||||
if (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
|
if (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
|
||||||
if (groupId == targetDeviceGroupId) {
|
if (groupId == targetDeviceGroupId) {
|
||||||
|
@@ -34,6 +34,7 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.bluetooth.Utils;
|
import com.android.settings.bluetooth.Utils;
|
||||||
import com.android.settings.core.TogglePreferenceController;
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||||
@@ -154,7 +155,7 @@ public class AudioSharingCompatibilityPreferenceController extends TogglePrefere
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AudioSharingUtils.isFeatureEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -242,7 +243,7 @@ public class AudioSharingCompatibilityPreferenceController extends TogglePrefere
|
|||||||
var unused =
|
var unused =
|
||||||
ThreadUtils.postOnBackgroundThread(
|
ThreadUtils.postOnBackgroundThread(
|
||||||
() -> {
|
() -> {
|
||||||
boolean isBroadcasting = AudioSharingUtils.isBroadcasting(mBtManager);
|
boolean isBroadcasting = BluetoothUtils.isBroadcasting(mBtManager);
|
||||||
AudioSharingUtils.postOnMainThread(
|
AudioSharingUtils.postOnMainThread(
|
||||||
mContext,
|
mContext,
|
||||||
() -> {
|
() -> {
|
||||||
|
@@ -29,6 +29,7 @@ import androidx.fragment.app.FragmentManager;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
|
|
||||||
public class AudioSharingConfirmDialogFragment extends InstrumentedDialogFragment {
|
public class AudioSharingConfirmDialogFragment extends InstrumentedDialogFragment {
|
||||||
private static final String TAG = "AudioSharingConfirmDialog";
|
private static final String TAG = "AudioSharingConfirmDialog";
|
||||||
@@ -44,7 +45,7 @@ public class AudioSharingConfirmDialogFragment extends InstrumentedDialogFragmen
|
|||||||
* @param host The Fragment this dialog will be hosted.
|
* @param host The Fragment this dialog will be hosted.
|
||||||
*/
|
*/
|
||||||
public static void show(Fragment host) {
|
public static void show(Fragment host) {
|
||||||
if (!AudioSharingUtils.isFeatureEnabled()) return;
|
if (!BluetoothUtils.isAudioSharingEnabled()) return;
|
||||||
final FragmentManager manager;
|
final FragmentManager manager;
|
||||||
try {
|
try {
|
||||||
manager = host.getChildFragmentManager();
|
manager = host.getChildFragmentManager();
|
||||||
|
@@ -296,7 +296,7 @@ public class AudioSharingDevicePreferenceController extends BasePreferenceContro
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AudioSharingUtils.isFeatureEnabled() && mBluetoothDeviceUpdater != null
|
return BluetoothUtils.isAudioSharingEnabled() && mBluetoothDeviceUpdater != null
|
||||||
? AVAILABLE_UNSEARCHABLE
|
? AVAILABLE_UNSEARCHABLE
|
||||||
: UNSUPPORTED_ON_DEVICE;
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
@@ -67,7 +67,7 @@ public class AudioSharingDeviceVolumeControlUpdater extends BluetoothDeviceUpdat
|
|||||||
// If device is LE audio device and in a sharing session on current sharing device,
|
// If device is LE audio device and in a sharing session on current sharing device,
|
||||||
// it would show in volume control group.
|
// it would show in volume control group.
|
||||||
if (cachedDevice.isConnectedLeAudioDevice()
|
if (cachedDevice.isConnectedLeAudioDevice()
|
||||||
&& AudioSharingUtils.isBroadcasting(mBtManager)
|
&& BluetoothUtils.isBroadcasting(mBtManager)
|
||||||
&& BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, mBtManager)) {
|
&& BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, mBtManager)) {
|
||||||
isFilterMatched = true;
|
isFilterMatched = true;
|
||||||
}
|
}
|
||||||
@@ -103,11 +103,11 @@ public class AudioSharingDeviceVolumeControlUpdater extends BluetoothDeviceUpdat
|
|||||||
@Override
|
@Override
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
int progress = seekBar.getProgress();
|
int progress = seekBar.getProgress();
|
||||||
int groupId = AudioSharingUtils.getGroupId(cachedDevice);
|
int groupId = BluetoothUtils.getGroupId(cachedDevice);
|
||||||
if (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID
|
if (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID
|
||||||
&& groupId
|
&& groupId
|
||||||
== AudioSharingUtils.getFallbackActiveGroupId(
|
== BluetoothUtils.getPrimaryGroupIdForBroadcast(
|
||||||
mContext)) {
|
mContext.getContentResolver())) {
|
||||||
// Set media stream volume for primary buds, audio manager will
|
// Set media stream volume for primary buds, audio manager will
|
||||||
// update all buds volume in the audio sharing.
|
// update all buds volume in the audio sharing.
|
||||||
setAudioManagerStreamVolume(progress);
|
setAudioManagerStreamVolume(progress);
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.connecteddevice.audiosharing;
|
package com.android.settings.connecteddevice.audiosharing;
|
||||||
|
|
||||||
import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtils.SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID;
|
|
||||||
|
|
||||||
import android.annotation.IntRange;
|
import android.annotation.IntRange;
|
||||||
import android.bluetooth.BluetoothCsipSetCoordinator;
|
import android.bluetooth.BluetoothCsipSetCoordinator;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
@@ -91,11 +89,11 @@ public class AudioSharingDeviceVolumeGroupController extends AudioSharingBasePre
|
|||||||
? null
|
? null
|
||||||
: mBtManager.getCachedDeviceManager().findDevice(device);
|
: mBtManager.getCachedDeviceManager().findDevice(device);
|
||||||
if (cachedDevice == null) return;
|
if (cachedDevice == null) return;
|
||||||
int groupId = AudioSharingUtils.getGroupId(cachedDevice);
|
int groupId = BluetoothUtils.getGroupId(cachedDevice);
|
||||||
mValueMap.put(groupId, volume);
|
mValueMap.put(groupId, volume);
|
||||||
for (AudioSharingDeviceVolumePreference preference : mVolumePreferences) {
|
for (AudioSharingDeviceVolumePreference preference : mVolumePreferences) {
|
||||||
if (preference.getCachedDevice() != null
|
if (preference.getCachedDevice() != null
|
||||||
&& AudioSharingUtils.getGroupId(preference.getCachedDevice())
|
&& BluetoothUtils.getGroupId(preference.getCachedDevice())
|
||||||
== groupId) {
|
== groupId) {
|
||||||
// If the callback return invalid volume, try to
|
// If the callback return invalid volume, try to
|
||||||
// get the volume from AudioManager.STREAM_MUSIC
|
// get the volume from AudioManager.STREAM_MUSIC
|
||||||
@@ -256,7 +254,7 @@ public class AudioSharingDeviceVolumeGroupController extends AudioSharingBasePre
|
|||||||
volumePref.setOrder(getPreferenceOrderForDevice(cachedDevice));
|
volumePref.setOrder(getPreferenceOrderForDevice(cachedDevice));
|
||||||
mVolumePreferences.add(volumePref);
|
mVolumePreferences.add(volumePref);
|
||||||
if (volumePref.getProgress() > 0) return;
|
if (volumePref.getProgress() > 0) return;
|
||||||
int volume = mValueMap.getOrDefault(AudioSharingUtils.getGroupId(cachedDevice), -1);
|
int volume = mValueMap.getOrDefault(BluetoothUtils.getGroupId(cachedDevice), -1);
|
||||||
// If the volume is invalid, try to get the volume from AudioManager.STREAM_MUSIC
|
// If the volume is invalid, try to get the volume from AudioManager.STREAM_MUSIC
|
||||||
int finalVolume = getAudioVolumeIfNeeded(volume);
|
int finalVolume = getAudioVolumeIfNeeded(volume);
|
||||||
Log.d(
|
Log.d(
|
||||||
@@ -369,7 +367,7 @@ public class AudioSharingDeviceVolumeGroupController extends AudioSharingBasePre
|
|||||||
mVolumeControl.registerCallback(mExecutor, mVolumeControlCallback);
|
mVolumeControl.registerCallback(mExecutor, mVolumeControlCallback);
|
||||||
mBluetoothDeviceUpdater.registerCallback();
|
mBluetoothDeviceUpdater.registerCallback();
|
||||||
mContentResolver.registerContentObserver(
|
mContentResolver.registerContentObserver(
|
||||||
Settings.Secure.getUriFor(SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID),
|
Settings.Secure.getUriFor(BluetoothUtils.getPrimaryGroupIdUriForBroadcast()),
|
||||||
false,
|
false,
|
||||||
mSettingsObserver);
|
mSettingsObserver);
|
||||||
mCallbacksRegistered.set(true);
|
mCallbacksRegistered.set(true);
|
||||||
@@ -415,10 +413,10 @@ public class AudioSharingDeviceVolumeGroupController extends AudioSharingBasePre
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getPreferenceOrderForDevice(@NonNull CachedBluetoothDevice cachedDevice) {
|
private int getPreferenceOrderForDevice(@NonNull CachedBluetoothDevice cachedDevice) {
|
||||||
int groupId = AudioSharingUtils.getGroupId(cachedDevice);
|
int groupId = BluetoothUtils.getGroupId(cachedDevice);
|
||||||
// The fallback device rank first among the audio sharing device list.
|
// The fallback device rank first among the audio sharing device list.
|
||||||
return (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID
|
return (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID
|
||||||
&& groupId == AudioSharingUtils.getFallbackActiveGroupId(mContext))
|
&& groupId == BluetoothUtils.getPrimaryGroupIdForBroadcast(mContentResolver))
|
||||||
? 0
|
? 0
|
||||||
: 1;
|
: 1;
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@ import androidx.fragment.app.FragmentManager;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ public class AudioSharingDialogFragment extends InstrumentedDialogFragment {
|
|||||||
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
||||||
@NonNull DialogEventListener listener,
|
@NonNull DialogEventListener listener,
|
||||||
@NonNull Pair<Integer, Object>[] eventData) {
|
@NonNull Pair<Integer, Object>[] eventData) {
|
||||||
if (!AudioSharingUtils.isFeatureEnabled()) return;
|
if (!BluetoothUtils.isAudioSharingEnabled()) return;
|
||||||
final FragmentManager manager;
|
final FragmentManager manager;
|
||||||
try {
|
try {
|
||||||
manager = host.getChildFragmentManager();
|
manager = host.getChildFragmentManager();
|
||||||
|
@@ -263,7 +263,7 @@ public class AudioSharingDialogHandler {
|
|||||||
if (isBroadcasting) {
|
if (isBroadcasting) {
|
||||||
// If another device within the same is already in the sharing session, add source to
|
// If another device within the same is already in the sharing session, add source to
|
||||||
// the device automatically.
|
// the device automatically.
|
||||||
int groupId = AudioSharingUtils.getGroupId(cachedDevice);
|
int groupId = BluetoothUtils.getGroupId(cachedDevice);
|
||||||
if (groupedDevices.containsKey(groupId)
|
if (groupedDevices.containsKey(groupId)
|
||||||
&& groupedDevices.get(groupId).stream()
|
&& groupedDevices.get(groupId).stream()
|
||||||
.anyMatch(
|
.anyMatch(
|
||||||
@@ -355,8 +355,8 @@ public class AudioSharingDialogHandler {
|
|||||||
for (List<CachedBluetoothDevice> devices : groupedDevices.values()) {
|
for (List<CachedBluetoothDevice> devices : groupedDevices.values()) {
|
||||||
// Use random device in the group within the sharing session to represent the group.
|
// Use random device in the group within the sharing session to represent the group.
|
||||||
CachedBluetoothDevice device = devices.get(0);
|
CachedBluetoothDevice device = devices.get(0);
|
||||||
if (AudioSharingUtils.getGroupId(device)
|
if (BluetoothUtils.getGroupId(device)
|
||||||
== AudioSharingUtils.getGroupId(cachedDevice)) {
|
== BluetoothUtils.getGroupId(cachedDevice)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
deviceItems.add(AudioSharingUtils.buildAudioSharingDeviceItem(device));
|
deviceItems.add(AudioSharingUtils.buildAudioSharingDeviceItem(device));
|
||||||
@@ -435,7 +435,7 @@ public class AudioSharingDialogHandler {
|
|||||||
/** Close opening dialogs for le audio device */
|
/** Close opening dialogs for le audio device */
|
||||||
public void closeOpeningDialogsForLeaDevice(@NonNull CachedBluetoothDevice cachedDevice) {
|
public void closeOpeningDialogsForLeaDevice(@NonNull CachedBluetoothDevice cachedDevice) {
|
||||||
if (mHostFragment == null) return;
|
if (mHostFragment == null) return;
|
||||||
int groupId = AudioSharingUtils.getGroupId(cachedDevice);
|
int groupId = BluetoothUtils.getGroupId(cachedDevice);
|
||||||
List<Fragment> fragments;
|
List<Fragment> fragments;
|
||||||
try {
|
try {
|
||||||
fragments = mHostFragment.getChildFragmentManager().getFragments();
|
fragments = mHostFragment.getChildFragmentManager().getFragments();
|
||||||
@@ -447,7 +447,7 @@ public class AudioSharingDialogHandler {
|
|||||||
CachedBluetoothDevice device = getCachedBluetoothDeviceFromDialog(fragment);
|
CachedBluetoothDevice device = getCachedBluetoothDeviceFromDialog(fragment);
|
||||||
if (device != null
|
if (device != null
|
||||||
&& groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID
|
&& groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID
|
||||||
&& AudioSharingUtils.getGroupId(device) == groupId) {
|
&& BluetoothUtils.getGroupId(device) == groupId) {
|
||||||
Log.d(TAG, "Remove staled opening dialog for group " + groupId);
|
Log.d(TAG, "Remove staled opening dialog for group " + groupId);
|
||||||
((DialogFragment) fragment).dismiss();
|
((DialogFragment) fragment).dismiss();
|
||||||
logDialogDismissEvent(fragment);
|
logDialogDismissEvent(fragment);
|
||||||
|
@@ -32,6 +32,7 @@ import androidx.fragment.app.FragmentManager;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.utils.ThreadUtils;
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
|
|
||||||
@@ -83,7 +84,7 @@ public class AudioSharingDisconnectDialogFragment extends InstrumentedDialogFrag
|
|||||||
@NonNull CachedBluetoothDevice newDevice,
|
@NonNull CachedBluetoothDevice newDevice,
|
||||||
@NonNull DialogEventListener listener,
|
@NonNull DialogEventListener listener,
|
||||||
@NonNull Pair<Integer, Object>[] eventData) {
|
@NonNull Pair<Integer, Object>[] eventData) {
|
||||||
if (!AudioSharingUtils.isFeatureEnabled()) return;
|
if (!BluetoothUtils.isAudioSharingEnabled()) return;
|
||||||
final FragmentManager manager;
|
final FragmentManager manager;
|
||||||
try {
|
try {
|
||||||
manager = host.getChildFragmentManager();
|
manager = host.getChildFragmentManager();
|
||||||
@@ -93,8 +94,8 @@ public class AudioSharingDisconnectDialogFragment extends InstrumentedDialogFrag
|
|||||||
}
|
}
|
||||||
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
int newGroupId = AudioSharingUtils.getGroupId(newDevice);
|
int newGroupId = BluetoothUtils.getGroupId(newDevice);
|
||||||
if (sNewDevice != null && newGroupId == AudioSharingUtils.getGroupId(sNewDevice)) {
|
if (sNewDevice != null && newGroupId == BluetoothUtils.getGroupId(sNewDevice)) {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
String.format(
|
String.format(
|
||||||
|
@@ -32,6 +32,7 @@ import androidx.fragment.app.FragmentManager;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.bluetooth.Utils;
|
import com.android.settings.bluetooth.Utils;
|
||||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -58,7 +59,7 @@ public class AudioSharingJoinDialogFragment extends InstrumentedDialogFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return AudioSharingUtils.isBroadcasting(Utils.getLocalBtManager(getContext()))
|
return BluetoothUtils.isBroadcasting(Utils.getLocalBtManager(getContext()))
|
||||||
? SettingsEnums.DIALOG_AUDIO_SHARING_ADD_DEVICE
|
? SettingsEnums.DIALOG_AUDIO_SHARING_ADD_DEVICE
|
||||||
: SettingsEnums.DIALOG_START_AUDIO_SHARING;
|
: SettingsEnums.DIALOG_START_AUDIO_SHARING;
|
||||||
}
|
}
|
||||||
@@ -80,7 +81,7 @@ public class AudioSharingJoinDialogFragment extends InstrumentedDialogFragment {
|
|||||||
@NonNull CachedBluetoothDevice newDevice,
|
@NonNull CachedBluetoothDevice newDevice,
|
||||||
@NonNull DialogEventListener listener,
|
@NonNull DialogEventListener listener,
|
||||||
@NonNull Pair<Integer, Object>[] eventData) {
|
@NonNull Pair<Integer, Object>[] eventData) {
|
||||||
if (!AudioSharingUtils.isFeatureEnabled()) return;
|
if (!BluetoothUtils.isAudioSharingEnabled()) return;
|
||||||
final FragmentManager manager;
|
final FragmentManager manager;
|
||||||
try {
|
try {
|
||||||
manager = host.getChildFragmentManager();
|
manager = host.getChildFragmentManager();
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.connecteddevice.audiosharing;
|
package com.android.settings.connecteddevice.audiosharing;
|
||||||
|
|
||||||
import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtils.isBroadcasting;
|
import static com.android.settingslib.bluetooth.BluetoothUtils.isBroadcasting;
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.bluetooth.BluetoothLeBroadcast;
|
import android.bluetooth.BluetoothLeBroadcast;
|
||||||
@@ -174,7 +174,7 @@ public class AudioSharingNamePreferenceController extends BasePreferenceControll
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AudioSharingUtils.isFeatureEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.connecteddevice.audiosharing;
|
package com.android.settings.connecteddevice.audiosharing;
|
||||||
|
|
||||||
import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtils.isBroadcasting;
|
import static com.android.settingslib.bluetooth.BluetoothUtils.isBroadcasting;
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
@@ -39,6 +39,7 @@ import com.android.settings.bluetooth.Utils;
|
|||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.widget.ValidatedEditTextPreference;
|
import com.android.settings.widget.ValidatedEditTextPreference;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
@@ -112,7 +113,7 @@ public class AudioSharingPasswordPreferenceController extends BasePreferenceCont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AudioSharingUtils.isFeatureEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -33,6 +33,7 @@ import androidx.preference.PreferenceScreen;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
|
|
||||||
public class AudioSharingPlaySoundPreferenceController
|
public class AudioSharingPlaySoundPreferenceController
|
||||||
@@ -56,7 +57,7 @@ public class AudioSharingPlaySoundPreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return (mRingtone != null && AudioSharingUtils.isFeatureEnabled())
|
return (mRingtone != null && BluetoothUtils.isAudioSharingEnabled())
|
||||||
? AVAILABLE
|
? AVAILABLE
|
||||||
: UNSUPPORTED_ON_DEVICE;
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,7 @@ import com.android.settings.bluetooth.Utils;
|
|||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settingslib.bluetooth.BluetoothCallback;
|
import com.android.settingslib.bluetooth.BluetoothCallback;
|
||||||
import com.android.settingslib.bluetooth.BluetoothEventManager;
|
import com.android.settingslib.bluetooth.BluetoothEventManager;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
import com.android.settingslib.utils.ThreadUtils;
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
@@ -134,12 +135,12 @@ public class AudioSharingPreferenceController extends BasePreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AudioSharingUtils.isFeatureEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
return AudioSharingUtils.isBroadcasting(mBtManager)
|
return BluetoothUtils.isBroadcasting(mBtManager)
|
||||||
? mContext.getString(R.string.audio_sharing_summary_on)
|
? mContext.getString(R.string.audio_sharing_summary_on)
|
||||||
: mContext.getString(R.string.audio_sharing_summary_off);
|
: mContext.getString(R.string.audio_sharing_summary_off);
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,7 @@ import androidx.core.app.NotificationCompat;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.bluetooth.Utils;
|
import com.android.settings.bluetooth.Utils;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
@@ -48,7 +49,7 @@ public class AudioSharingReceiver extends BroadcastReceiver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (!AudioSharingUtils.isFeatureEnabled()) {
|
if (!BluetoothUtils.isAudioSharingEnabled()) {
|
||||||
Log.w(TAG, "Skip handling received intent, flag is off.");
|
Log.w(TAG, "Skip handling received intent, flag is off.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,7 @@ import androidx.fragment.app.FragmentManager;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.utils.ThreadUtils;
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ public class AudioSharingStopDialogFragment extends InstrumentedDialogFragment {
|
|||||||
@NonNull CachedBluetoothDevice newDevice,
|
@NonNull CachedBluetoothDevice newDevice,
|
||||||
@NonNull DialogEventListener listener,
|
@NonNull DialogEventListener listener,
|
||||||
@NonNull Pair<Integer, Object>[] eventData) {
|
@NonNull Pair<Integer, Object>[] eventData) {
|
||||||
if (!AudioSharingUtils.isFeatureEnabled()) return;
|
if (!BluetoothUtils.isAudioSharingEnabled()) return;
|
||||||
final FragmentManager manager;
|
final FragmentManager manager;
|
||||||
try {
|
try {
|
||||||
manager = host.getChildFragmentManager();
|
manager = host.getChildFragmentManager();
|
||||||
@@ -90,9 +91,9 @@ public class AudioSharingStopDialogFragment extends InstrumentedDialogFragment {
|
|||||||
}
|
}
|
||||||
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
int newGroupId = AudioSharingUtils.getGroupId(newDevice);
|
int newGroupId = BluetoothUtils.getGroupId(newDevice);
|
||||||
if (sCachedDevice != null
|
if (sCachedDevice != null
|
||||||
&& newGroupId == AudioSharingUtils.getGroupId(sCachedDevice)) {
|
&& newGroupId == BluetoothUtils.getGroupId(sCachedDevice)) {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
String.format(
|
String.format(
|
||||||
|
@@ -23,7 +23,6 @@ import android.bluetooth.BluetoothLeBroadcast;
|
|||||||
import android.bluetooth.BluetoothLeBroadcastAssistant;
|
import android.bluetooth.BluetoothLeBroadcastAssistant;
|
||||||
import android.bluetooth.BluetoothLeBroadcastMetadata;
|
import android.bluetooth.BluetoothLeBroadcastMetadata;
|
||||||
import android.bluetooth.BluetoothLeBroadcastReceiveState;
|
import android.bluetooth.BluetoothLeBroadcastReceiveState;
|
||||||
import android.bluetooth.BluetoothProfile;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -45,6 +44,7 @@ import com.android.settings.bluetooth.Utils;
|
|||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.widget.SettingsMainSwitchBar;
|
import com.android.settings.widget.SettingsMainSwitchBar;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant;
|
||||||
@@ -327,7 +327,7 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mSwitchBar.setEnabled(false);
|
mSwitchBar.setEnabled(false);
|
||||||
boolean isBroadcasting = AudioSharingUtils.isBroadcasting(mBtManager);
|
boolean isBroadcasting = BluetoothUtils.isBroadcasting(mBtManager);
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
if (isBroadcasting) {
|
if (isBroadcasting) {
|
||||||
Log.d(TAG, "Skip startAudioSharing, already broadcasting.");
|
Log.d(TAG, "Skip startAudioSharing, already broadcasting.");
|
||||||
@@ -339,10 +339,7 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
|
|||||||
if (FeatureFlagUtils.isEnabled(
|
if (FeatureFlagUtils.isEnabled(
|
||||||
mContext,
|
mContext,
|
||||||
FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST)
|
FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST)
|
||||||
&& mAssistant
|
&& mAssistant.getAllConnectedDevices().isEmpty()) {
|
||||||
.getDevicesMatchingConnectionStates(
|
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED})
|
|
||||||
.isEmpty()) {
|
|
||||||
// Pop up dialog to ask users to connect at least one lea buds before audio sharing.
|
// Pop up dialog to ask users to connect at least one lea buds before audio sharing.
|
||||||
AudioSharingUtils.postOnMainThread(
|
AudioSharingUtils.postOnMainThread(
|
||||||
mContext,
|
mContext,
|
||||||
@@ -368,7 +365,7 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AudioSharingUtils.isFeatureEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -483,7 +480,7 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
|
|||||||
var unused =
|
var unused =
|
||||||
ThreadUtils.postOnBackgroundThread(
|
ThreadUtils.postOnBackgroundThread(
|
||||||
() -> {
|
() -> {
|
||||||
boolean isBroadcasting = AudioSharingUtils.isBroadcasting(mBtManager);
|
boolean isBroadcasting = BluetoothUtils.isBroadcasting(mBtManager);
|
||||||
boolean isStateReady =
|
boolean isStateReady =
|
||||||
isBluetoothOn()
|
isBluetoothOn()
|
||||||
&& AudioSharingUtils.isAudioSharingProfileReady(
|
&& AudioSharingUtils.isAudioSharingProfileReady(
|
||||||
|
@@ -22,14 +22,10 @@ import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtil
|
|||||||
import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtils.MetricKey.METRIC_KEY_SOURCE_PAGE_ID;
|
import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtils.MetricKey.METRIC_KEY_SOURCE_PAGE_ID;
|
||||||
import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtils.MetricKey.METRIC_KEY_USER_TRIGGERED;
|
import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtils.MetricKey.METRIC_KEY_USER_TRIGGERED;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
|
||||||
import android.bluetooth.BluetoothCsipSetCoordinator;
|
import android.bluetooth.BluetoothCsipSetCoordinator;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothLeBroadcastMetadata;
|
import android.bluetooth.BluetoothLeBroadcastMetadata;
|
||||||
import android.bluetooth.BluetoothProfile;
|
|
||||||
import android.bluetooth.BluetoothStatusCodes;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@@ -44,10 +40,8 @@ import com.android.settingslib.bluetooth.LeAudioProfile;
|
|||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
|
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||||
import com.android.settingslib.bluetooth.VolumeControlProfile;
|
import com.android.settingslib.bluetooth.VolumeControlProfile;
|
||||||
import com.android.settingslib.flags.Flags;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -56,8 +50,6 @@ import java.util.Map;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class AudioSharingUtils {
|
public class AudioSharingUtils {
|
||||||
public static final String SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID =
|
|
||||||
"bluetooth_le_broadcast_fallback_active_group_id";
|
|
||||||
private static final String TAG = "AudioSharingUtils";
|
private static final String TAG = "AudioSharingUtils";
|
||||||
private static final boolean DEBUG = BluetoothUtils.D;
|
private static final boolean DEBUG = BluetoothUtils.D;
|
||||||
|
|
||||||
@@ -89,9 +81,7 @@ public class AudioSharingUtils {
|
|||||||
Log.d(TAG, "Skip fetchConnectedDevicesByGroupId due to assistant profile is null");
|
Log.d(TAG, "Skip fetchConnectedDevicesByGroupId due to assistant profile is null");
|
||||||
return groupedDevices;
|
return groupedDevices;
|
||||||
}
|
}
|
||||||
List<BluetoothDevice> connectedDevices =
|
List<BluetoothDevice> connectedDevices = assistant.getAllConnectedDevices();
|
||||||
assistant.getDevicesMatchingConnectionStates(
|
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED});
|
|
||||||
CachedBluetoothDeviceManager cacheManager = localBtManager.getCachedDeviceManager();
|
CachedBluetoothDeviceManager cacheManager = localBtManager.getCachedDeviceManager();
|
||||||
for (BluetoothDevice device : connectedDevices) {
|
for (BluetoothDevice device : connectedDevices) {
|
||||||
CachedBluetoothDevice cachedDevice = cacheManager.findDevice(device);
|
CachedBluetoothDevice cachedDevice = cacheManager.findDevice(device);
|
||||||
@@ -99,7 +89,7 @@ public class AudioSharingUtils {
|
|||||||
Log.d(TAG, "Skip device due to not being cached: " + device.getAnonymizedAddress());
|
Log.d(TAG, "Skip device due to not being cached: " + device.getAnonymizedAddress());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int groupId = getGroupId(cachedDevice);
|
int groupId = BluetoothUtils.getGroupId(cachedDevice);
|
||||||
if (groupId == BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
|
if (groupId == BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
@@ -230,7 +220,7 @@ public class AudioSharingUtils {
|
|||||||
CachedBluetoothDevice cachedDevice) {
|
CachedBluetoothDevice cachedDevice) {
|
||||||
return new AudioSharingDeviceItem(
|
return new AudioSharingDeviceItem(
|
||||||
cachedDevice.getName(),
|
cachedDevice.getName(),
|
||||||
getGroupId(cachedDevice),
|
BluetoothUtils.getGroupId(cachedDevice),
|
||||||
isActiveLeAudioDevice(cachedDevice));
|
isActiveLeAudioDevice(cachedDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,16 +240,6 @@ public class AudioSharingUtils {
|
|||||||
.execute(() -> Toast.makeText(context, message, Toast.LENGTH_LONG).show());
|
.execute(() -> Toast.makeText(context, message, Toast.LENGTH_LONG).show());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns if the le audio sharing is enabled. */
|
|
||||||
public static boolean isFeatureEnabled() {
|
|
||||||
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
|
||||||
return Flags.enableLeAudioSharing()
|
|
||||||
&& adapter.isLeAudioBroadcastSourceSupported()
|
|
||||||
== BluetoothStatusCodes.FEATURE_SUPPORTED
|
|
||||||
&& adapter.isLeAudioBroadcastAssistantSupported()
|
|
||||||
== BluetoothStatusCodes.FEATURE_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Add source to target sinks. */
|
/** Add source to target sinks. */
|
||||||
public static void addSourceToTargetSinks(
|
public static void addSourceToTargetSinks(
|
||||||
List<BluetoothDevice> sinks, @Nullable LocalBluetoothManager localBtManager) {
|
List<BluetoothDevice> sinks, @Nullable LocalBluetoothManager localBtManager) {
|
||||||
@@ -289,9 +269,7 @@ public class AudioSharingUtils {
|
|||||||
Log.d(TAG, "skip addSourceToTargetDevices: There is no broadcastMetadata.");
|
Log.d(TAG, "skip addSourceToTargetDevices: There is no broadcastMetadata.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<BluetoothDevice> connectedDevices =
|
List<BluetoothDevice> connectedDevices = assistant.getAllConnectedDevices();
|
||||||
assistant.getDevicesMatchingConnectionStates(
|
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED});
|
|
||||||
for (BluetoothDevice sink : sinks) {
|
for (BluetoothDevice sink : sinks) {
|
||||||
if (connectedDevices.contains(sink)) {
|
if (connectedDevices.contains(sink)) {
|
||||||
Log.d(
|
Log.d(
|
||||||
@@ -312,14 +290,6 @@ public class AudioSharingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns if the broadcast is on-going. */
|
|
||||||
public static boolean isBroadcasting(@Nullable LocalBluetoothManager manager) {
|
|
||||||
if (manager == null) return false;
|
|
||||||
LocalBluetoothLeBroadcast broadcast =
|
|
||||||
manager.getProfileManager().getLeAudioBroadcastProfile();
|
|
||||||
return broadcast != null && broadcast.isEnabled(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Stops the latest broadcast. */
|
/** Stops the latest broadcast. */
|
||||||
public static void stopBroadcasting(@Nullable LocalBluetoothManager manager) {
|
public static void stopBroadcasting(@Nullable LocalBluetoothManager manager) {
|
||||||
if (manager == null) {
|
if (manager == null) {
|
||||||
@@ -335,37 +305,6 @@ public class AudioSharingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get CSIP group id for {@link CachedBluetoothDevice}.
|
|
||||||
*
|
|
||||||
* <p>If CachedBluetoothDevice#getGroupId is invalid, fetch group id from
|
|
||||||
* LeAudioProfile#getGroupId.
|
|
||||||
*/
|
|
||||||
public static int getGroupId(CachedBluetoothDevice cachedDevice) {
|
|
||||||
int groupId = cachedDevice.getGroupId();
|
|
||||||
String anonymizedAddress = cachedDevice.getDevice().getAnonymizedAddress();
|
|
||||||
if (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
|
|
||||||
Log.d(TAG, "getGroupId by CSIP profile for device: " + anonymizedAddress);
|
|
||||||
return groupId;
|
|
||||||
}
|
|
||||||
for (LocalBluetoothProfile profile : cachedDevice.getProfiles()) {
|
|
||||||
if (profile instanceof LeAudioProfile) {
|
|
||||||
Log.d(TAG, "getGroupId by LEA profile for device: " + anonymizedAddress);
|
|
||||||
return ((LeAudioProfile) profile).getGroupId(cachedDevice.getDevice());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Log.d(TAG, "getGroupId return invalid id for device: " + anonymizedAddress);
|
|
||||||
return BluetoothCsipSetCoordinator.GROUP_ID_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get the fallback active group id from SettingsProvider. */
|
|
||||||
public static int getFallbackActiveGroupId(@NonNull Context context) {
|
|
||||||
return Settings.Secure.getInt(
|
|
||||||
context.getContentResolver(),
|
|
||||||
SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID,
|
|
||||||
BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Post the runnable to main thread. */
|
/** Post the runnable to main thread. */
|
||||||
public static void postOnMainThread(@NonNull Context context, @NonNull Runnable runnable) {
|
public static void postOnMainThread(@NonNull Context context, @NonNull Runnable runnable) {
|
||||||
context.getMainExecutor().execute(runnable);
|
context.getMainExecutor().execute(runnable);
|
||||||
|
@@ -33,6 +33,7 @@ import androidx.preference.PreferenceScreen;
|
|||||||
|
|
||||||
import com.android.settings.bluetooth.Utils;
|
import com.android.settings.bluetooth.Utils;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@ public class StreamSettingsCategoryController extends BasePreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AudioSharingUtils.isFeatureEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -23,7 +23,6 @@ import android.app.Dialog;
|
|||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothLeBroadcastMetadata;
|
import android.bluetooth.BluetoothLeBroadcastMetadata;
|
||||||
import android.bluetooth.BluetoothProfile;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -36,10 +35,10 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.bluetooth.Utils;
|
import com.android.settings.bluetooth.Utils;
|
||||||
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
|
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
|
||||||
import com.android.settings.connecteddevice.audiosharing.AudioSharingUtils;
|
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||||
import com.android.settingslib.bluetooth.BluetoothLeBroadcastMetadataExt;
|
import com.android.settingslib.bluetooth.BluetoothLeBroadcastMetadataExt;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant;
|
||||||
|
|
||||||
public class AudioStreamConfirmDialog extends InstrumentedDialogFragment {
|
public class AudioStreamConfirmDialog extends InstrumentedDialogFragment {
|
||||||
@@ -211,7 +210,7 @@ public class AudioStreamConfirmDialog extends InstrumentedDialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getDialogId(boolean hasMetadata, boolean hasConnectedDevice) {
|
private int getDialogId(boolean hasMetadata, boolean hasConnectedDevice) {
|
||||||
if (!AudioSharingUtils.isFeatureEnabled()) {
|
if (!BluetoothUtils.isAudioSharingEnabled()) {
|
||||||
return SettingsEnums.DIALOG_AUDIO_STREAM_CONFIRM_FEATURE_UNSUPPORTED;
|
return SettingsEnums.DIALOG_AUDIO_STREAM_CONFIRM_FEATURE_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
if (!hasConnectedDevice) {
|
if (!hasConnectedDevice) {
|
||||||
@@ -233,9 +232,7 @@ public class AudioStreamConfirmDialog extends InstrumentedDialogFragment {
|
|||||||
if (assistant == null) {
|
if (assistant == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var devices =
|
var devices = assistant.getAllConnectedDevices();
|
||||||
assistant.getDevicesMatchingConnectionStates(
|
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED});
|
|
||||||
return devices.isEmpty() ? null : devices.get(0);
|
return devices.isEmpty() ? null : devices.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@ import androidx.annotation.Nullable;
|
|||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.bluetooth.Utils;
|
import com.android.settings.bluetooth.Utils;
|
||||||
import com.android.settings.connecteddevice.audiosharing.AudioSharingUtils;
|
import com.android.settings.connecteddevice.audiosharing.AudioSharingUtils;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||||
|
|
||||||
public class AudioStreamConfirmDialogActivity extends SettingsActivity
|
public class AudioStreamConfirmDialogActivity extends SettingsActivity
|
||||||
@@ -49,7 +50,7 @@ public class AudioStreamConfirmDialogActivity extends SettingsActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createUiFromIntent(@Nullable Bundle savedState, Intent intent) {
|
protected void createUiFromIntent(@Nullable Bundle savedState, Intent intent) {
|
||||||
if (AudioSharingUtils.isFeatureEnabled()
|
if (BluetoothUtils.isAudioSharingEnabled()
|
||||||
&& !AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
&& !AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
||||||
Log.d(TAG, "createUiFromIntent() : supported but not ready, skip createUiFromIntent");
|
Log.d(TAG, "createUiFromIntent() : supported but not ready, skip createUiFromIntent");
|
||||||
mSavedState = savedState;
|
mSavedState = savedState;
|
||||||
@@ -66,7 +67,7 @@ public class AudioStreamConfirmDialogActivity extends SettingsActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
if (AudioSharingUtils.isFeatureEnabled()
|
if (BluetoothUtils.isAudioSharingEnabled()
|
||||||
&& !AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
&& !AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
||||||
Log.d(TAG, "onStart() : supported but not ready, listen to service ready");
|
Log.d(TAG, "onStart() : supported but not ready, listen to service ready");
|
||||||
if (mProfileManager != null) {
|
if (mProfileManager != null) {
|
||||||
@@ -86,7 +87,7 @@ public class AudioStreamConfirmDialogActivity extends SettingsActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected() {
|
public void onServiceConnected() {
|
||||||
if (AudioSharingUtils.isFeatureEnabled()
|
if (BluetoothUtils.isAudioSharingEnabled()
|
||||||
&& AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
&& AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
||||||
if (mProfileManager != null) {
|
if (mProfileManager != null) {
|
||||||
mProfileManager.removeServiceListener(this);
|
mProfileManager.removeServiceListener(this);
|
||||||
|
@@ -43,9 +43,9 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.bluetooth.Utils;
|
import com.android.settings.bluetooth.Utils;
|
||||||
import com.android.settings.connecteddevice.audiosharing.AudioSharingUtils;
|
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.bluetooth.BluetoothCallback;
|
import com.android.settingslib.bluetooth.BluetoothCallback;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant;
|
||||||
@@ -122,7 +122,7 @@ public class AudioStreamMediaService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
if (!AudioSharingUtils.isFeatureEnabled()) {
|
if (!BluetoothUtils.isAudioSharingEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ public class AudioStreamMediaService extends Service {
|
|||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
Log.d(TAG, "onDestroy()");
|
Log.d(TAG, "onDestroy()");
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
if (!AudioSharingUtils.isFeatureEnabled()) {
|
if (!BluetoothUtils.isAudioSharingEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mLocalBtManager != null) {
|
if (mLocalBtManager != null) {
|
||||||
|
@@ -26,7 +26,6 @@ import android.bluetooth.BluetoothDevice;
|
|||||||
import android.bluetooth.BluetoothLeAudioContentMetadata;
|
import android.bluetooth.BluetoothLeAudioContentMetadata;
|
||||||
import android.bluetooth.BluetoothLeBroadcastMetadata;
|
import android.bluetooth.BluetoothLeBroadcastMetadata;
|
||||||
import android.bluetooth.BluetoothLeBroadcastReceiveState;
|
import android.bluetooth.BluetoothLeBroadcastReceiveState;
|
||||||
import android.bluetooth.BluetoothProfile;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -277,9 +276,7 @@ public class AudioStreamsHelper {
|
|||||||
Log.w(TAG, "getConnectedBluetoothDevices(): LeBroadcastAssistant is null!");
|
Log.w(TAG, "getConnectedBluetoothDevices(): LeBroadcastAssistant is null!");
|
||||||
return emptyList();
|
return emptyList();
|
||||||
}
|
}
|
||||||
List<BluetoothDevice> connectedDevices =
|
List<BluetoothDevice> connectedDevices = leBroadcastAssistant.getAllConnectedDevices();
|
||||||
leBroadcastAssistant.getDevicesMatchingConnectionStates(
|
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED});
|
|
||||||
Optional<CachedBluetoothDevice> cachedBluetoothDevice =
|
Optional<CachedBluetoothDevice> cachedBluetoothDevice =
|
||||||
inSharingOnly
|
inSharingOnly
|
||||||
? getCachedBluetoothDeviceInSharing(manager)
|
? getCachedBluetoothDeviceInSharing(manager)
|
||||||
|
@@ -99,7 +99,7 @@ public class AudioSharingCallAudioDialogFragmentTest {
|
|||||||
mParent = new Fragment();
|
mParent = new Fragment();
|
||||||
FragmentController.setupFragment(
|
FragmentController.setupFragment(
|
||||||
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
||||||
AudioSharingCallAudioDialogFragment.show(mParent, new ArrayList<>(), (item) -> {});
|
AudioSharingCallAudioDialogFragment.show(mParent, new ArrayList<>(), -1, (item) -> {});
|
||||||
shadowMainLooper().idle();
|
shadowMainLooper().idle();
|
||||||
AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||||
assertThat(dialog).isNull();
|
assertThat(dialog).isNull();
|
||||||
@@ -109,7 +109,7 @@ public class AudioSharingCallAudioDialogFragmentTest {
|
|||||||
public void onCreateDialog_unattachedFragment_dialogNotExist() {
|
public void onCreateDialog_unattachedFragment_dialogNotExist() {
|
||||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||||
mParent = new Fragment();
|
mParent = new Fragment();
|
||||||
AudioSharingCallAudioDialogFragment.show(mParent, new ArrayList<>(), (item) -> {});
|
AudioSharingCallAudioDialogFragment.show(mParent, new ArrayList<>(), -1, (item) -> {});
|
||||||
shadowMainLooper().idle();
|
shadowMainLooper().idle();
|
||||||
AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||||
assertThat(dialog).isNull();
|
assertThat(dialog).isNull();
|
||||||
@@ -138,7 +138,7 @@ public class AudioSharingCallAudioDialogFragmentTest {
|
|||||||
ArrayList<AudioSharingDeviceItem> deviceItemList = new ArrayList<>();
|
ArrayList<AudioSharingDeviceItem> deviceItemList = new ArrayList<>();
|
||||||
deviceItemList.add(TEST_DEVICE_ITEM1);
|
deviceItemList.add(TEST_DEVICE_ITEM1);
|
||||||
deviceItemList.add(TEST_DEVICE_ITEM2);
|
deviceItemList.add(TEST_DEVICE_ITEM2);
|
||||||
AudioSharingCallAudioDialogFragment.show(mParent, deviceItemList, (item) -> {});
|
AudioSharingCallAudioDialogFragment.show(mParent, deviceItemList, 0, (item) -> {});
|
||||||
shadowMainLooper().idle();
|
shadowMainLooper().idle();
|
||||||
AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||||
assertThat(dialog).isNotNull();
|
assertThat(dialog).isNotNull();
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.connecteddevice.audiosharing;
|
package com.android.settings.connecteddevice.audiosharing;
|
||||||
|
|
||||||
import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtils.SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID;
|
|
||||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||||
|
|
||||||
@@ -64,6 +63,7 @@ import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
|||||||
import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
|
import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
|
||||||
import com.android.settings.testutils.shadow.ShadowThreadUtils;
|
import com.android.settings.testutils.shadow.ShadowThreadUtils;
|
||||||
import com.android.settingslib.bluetooth.BluetoothEventManager;
|
import com.android.settingslib.bluetooth.BluetoothEventManager;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||||
@@ -197,7 +197,8 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
|||||||
verify(mBtEventManager, never()).registerCallback(mController);
|
verify(mBtEventManager, never()).registerCallback(mController);
|
||||||
verify(mContentResolver, never())
|
verify(mContentResolver, never())
|
||||||
.registerContentObserver(
|
.registerContentObserver(
|
||||||
Settings.Secure.getUriFor(SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID),
|
Settings.Secure.getUriFor(
|
||||||
|
BluetoothUtils.getPrimaryGroupIdUriForBroadcast()),
|
||||||
false,
|
false,
|
||||||
mContentObserver);
|
mContentObserver);
|
||||||
verify(mAssistant, never())
|
verify(mAssistant, never())
|
||||||
@@ -211,7 +212,8 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
|||||||
verify(mBtEventManager).registerCallback(mController);
|
verify(mBtEventManager).registerCallback(mController);
|
||||||
verify(mContentResolver)
|
verify(mContentResolver)
|
||||||
.registerContentObserver(
|
.registerContentObserver(
|
||||||
Settings.Secure.getUriFor(SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID),
|
Settings.Secure.getUriFor(
|
||||||
|
BluetoothUtils.getPrimaryGroupIdUriForBroadcast()),
|
||||||
false,
|
false,
|
||||||
mContentObserver);
|
mContentObserver);
|
||||||
verify(mAssistant)
|
verify(mAssistant)
|
||||||
@@ -319,9 +321,7 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
|||||||
public void onProfileConnectionStateChanged_noDeviceInSharing_updateSummary() {
|
public void onProfileConnectionStateChanged_noDeviceInSharing_updateSummary() {
|
||||||
Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY, TEST_DEVICE_GROUP_ID1);
|
Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY, TEST_DEVICE_GROUP_ID1);
|
||||||
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of());
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of());
|
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
mPreference.setSummary("test");
|
mPreference.setSummary("test");
|
||||||
mController.onProfileConnectionStateChanged(
|
mController.onProfileConnectionStateChanged(
|
||||||
@@ -340,9 +340,7 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
|||||||
when(mCachedDevice1.getName()).thenReturn(TEST_DEVICE_NAME1);
|
when(mCachedDevice1.getName()).thenReturn(TEST_DEVICE_NAME1);
|
||||||
when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
|
when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
|
||||||
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1));
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of(mDevice1));
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
mContentObserver.onChange(true);
|
mContentObserver.onChange(true);
|
||||||
@@ -369,8 +367,7 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
|||||||
when(mCacheManager.findDevice(mDevice2)).thenReturn(mCachedDevice2);
|
when(mCacheManager.findDevice(mDevice2)).thenReturn(mCachedDevice2);
|
||||||
when(mCacheManager.findDevice(mDevice3)).thenReturn(mCachedDevice3);
|
when(mCacheManager.findDevice(mDevice3)).thenReturn(mCachedDevice3);
|
||||||
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices())
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of(mDevice1, mDevice2, mDevice3));
|
.thenReturn(ImmutableList.of(mDevice1, mDevice2, mDevice3));
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
@@ -389,9 +386,7 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
|||||||
when(mCachedDevice1.getName()).thenReturn(TEST_DEVICE_NAME1);
|
when(mCachedDevice1.getName()).thenReturn(TEST_DEVICE_NAME1);
|
||||||
when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
|
when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
|
||||||
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1));
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of(mDevice1));
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -403,9 +398,7 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
|||||||
Settings.Secure.putInt(
|
Settings.Secure.putInt(
|
||||||
mContentResolver, TEST_SETTINGS_KEY, BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
|
mContentResolver, TEST_SETTINGS_KEY, BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
|
||||||
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of());
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of());
|
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
assertThat(mPreference.getSummary().toString()).isEmpty();
|
assertThat(mPreference.getSummary().toString()).isEmpty();
|
||||||
@@ -429,9 +422,7 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
|||||||
when(mCacheManager.findDevice(mDevice2)).thenReturn(mCachedDevice2);
|
when(mCacheManager.findDevice(mDevice2)).thenReturn(mCachedDevice2);
|
||||||
mShadowBluetoothAdapter.setMostRecentlyConnectedDevices(List.of(mDevice1, mDevice2));
|
mShadowBluetoothAdapter.setMostRecentlyConnectedDevices(List.of(mDevice1, mDevice2));
|
||||||
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1, mDevice2));
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of(mDevice1, mDevice2));
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
||||||
mController.init(mParentFragment);
|
mController.init(mParentFragment);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
@@ -521,18 +512,14 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
|||||||
Settings.Secure.putInt(
|
Settings.Secure.putInt(
|
||||||
mContentResolver, TEST_SETTINGS_KEY, BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
|
mContentResolver, TEST_SETTINGS_KEY, BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
|
||||||
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of());
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of());
|
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
assertThat(mPreference.getSummary().toString()).isEmpty();
|
assertThat(mPreference.getSummary().toString()).isEmpty();
|
||||||
|
|
||||||
// onReceiveStateChanged will update summary
|
// onReceiveStateChanged will update summary
|
||||||
Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY, TEST_DEVICE_GROUP_ID1);
|
Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY, TEST_DEVICE_GROUP_ID1);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1));
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of(mDevice1));
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
||||||
mController.mBroadcastAssistantCallback.onReceiveStateChanged(
|
mController.mBroadcastAssistantCallback.onReceiveStateChanged(
|
||||||
mDevice1, /* sourceId= */ 1, mState);
|
mDevice1, /* sourceId= */ 1, mState);
|
||||||
@@ -552,17 +539,13 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
|||||||
Settings.Secure.putInt(
|
Settings.Secure.putInt(
|
||||||
mContentResolver, TEST_SETTINGS_KEY, BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
|
mContentResolver, TEST_SETTINGS_KEY, BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
|
||||||
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
when(mBroadcast.isEnabled(any())).thenReturn(true);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of());
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of());
|
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
assertThat(mPreference.getSummary().toString()).isEmpty();
|
assertThat(mPreference.getSummary().toString()).isEmpty();
|
||||||
|
|
||||||
Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY, TEST_DEVICE_GROUP_ID1);
|
Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY, TEST_DEVICE_GROUP_ID1);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1));
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of(mDevice1));
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
||||||
mController.mBroadcastAssistantCallback.onSearchStarted(/* reason= */ 1);
|
mController.mBroadcastAssistantCallback.onSearchStarted(/* reason= */ 1);
|
||||||
mController.mBroadcastAssistantCallback.onSearchStartFailed(/* reason= */ 1);
|
mController.mBroadcastAssistantCallback.onSearchStartFailed(/* reason= */ 1);
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.connecteddevice.audiosharing;
|
package com.android.settings.connecteddevice.audiosharing;
|
||||||
|
|
||||||
import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtils.SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
@@ -59,6 +57,7 @@ import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
|||||||
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
||||||
import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
|
import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
|
||||||
import com.android.settings.testutils.shadow.ShadowThreadUtils;
|
import com.android.settings.testutils.shadow.ShadowThreadUtils;
|
||||||
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||||
@@ -208,7 +207,8 @@ public class AudioSharingDeviceVolumeGroupControllerTest {
|
|||||||
.registerCallback(any(Executor.class), any(BluetoothVolumeControl.Callback.class));
|
.registerCallback(any(Executor.class), any(BluetoothVolumeControl.Callback.class));
|
||||||
verify(mContentResolver, never())
|
verify(mContentResolver, never())
|
||||||
.registerContentObserver(
|
.registerContentObserver(
|
||||||
Settings.Secure.getUriFor(SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID),
|
Settings.Secure.getUriFor(
|
||||||
|
BluetoothUtils.getPrimaryGroupIdUriForBroadcast()),
|
||||||
false,
|
false,
|
||||||
mContentObserver);
|
mContentObserver);
|
||||||
}
|
}
|
||||||
@@ -223,11 +223,9 @@ public class AudioSharingDeviceVolumeGroupControllerTest {
|
|||||||
verify(mDeviceUpdater).registerCallback();
|
verify(mDeviceUpdater).registerCallback();
|
||||||
verify(mVolumeControl)
|
verify(mVolumeControl)
|
||||||
.registerCallback(any(Executor.class), any(BluetoothVolumeControl.Callback.class));
|
.registerCallback(any(Executor.class), any(BluetoothVolumeControl.Callback.class));
|
||||||
verify(mContentResolver)
|
verify(mContentResolver).registerContentObserver(
|
||||||
.registerContentObserver(
|
Settings.Secure.getUriFor(BluetoothUtils.getPrimaryGroupIdUriForBroadcast()), false,
|
||||||
Settings.Secure.getUriFor(SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID),
|
mContentObserver);
|
||||||
false,
|
|
||||||
mContentObserver);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -242,7 +240,8 @@ public class AudioSharingDeviceVolumeGroupControllerTest {
|
|||||||
.registerCallback(any(Executor.class), any(BluetoothVolumeControl.Callback.class));
|
.registerCallback(any(Executor.class), any(BluetoothVolumeControl.Callback.class));
|
||||||
verify(mContentResolver)
|
verify(mContentResolver)
|
||||||
.registerContentObserver(
|
.registerContentObserver(
|
||||||
Settings.Secure.getUriFor(SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID),
|
Settings.Secure.getUriFor(
|
||||||
|
BluetoothUtils.getPrimaryGroupIdUriForBroadcast()),
|
||||||
false,
|
false,
|
||||||
mContentObserver);
|
mContentObserver);
|
||||||
}
|
}
|
||||||
@@ -317,7 +316,8 @@ public class AudioSharingDeviceVolumeGroupControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onDeviceAdded_rankFallbackDeviceOnTop() {
|
public void onDeviceAdded_rankFallbackDeviceOnTop() {
|
||||||
Settings.Secure.putInt(
|
Settings.Secure.putInt(
|
||||||
mContentResolver, SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID, TEST_DEVICE_GROUP_ID2);
|
mContentResolver, BluetoothUtils.getPrimaryGroupIdUriForBroadcast(),
|
||||||
|
TEST_DEVICE_GROUP_ID2);
|
||||||
when(mPreference1.getProgress()).thenReturn(TEST_VOLUME_VALUE);
|
when(mPreference1.getProgress()).thenReturn(TEST_VOLUME_VALUE);
|
||||||
when(mPreference2.getProgress()).thenReturn(TEST_VOLUME_VALUE);
|
when(mPreference2.getProgress()).thenReturn(TEST_VOLUME_VALUE);
|
||||||
mController.setPreferenceGroup(mPreferenceGroup);
|
mController.setPreferenceGroup(mPreferenceGroup);
|
||||||
@@ -427,7 +427,8 @@ public class AudioSharingDeviceVolumeGroupControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void settingsObserverOnChange_updatePreferenceOrder() {
|
public void settingsObserverOnChange_updatePreferenceOrder() {
|
||||||
Settings.Secure.putInt(
|
Settings.Secure.putInt(
|
||||||
mContentResolver, SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID, TEST_DEVICE_GROUP_ID2);
|
mContentResolver, BluetoothUtils.getPrimaryGroupIdUriForBroadcast(),
|
||||||
|
TEST_DEVICE_GROUP_ID2);
|
||||||
when(mPreference1.getProgress()).thenReturn(TEST_VOLUME_VALUE);
|
when(mPreference1.getProgress()).thenReturn(TEST_VOLUME_VALUE);
|
||||||
when(mPreference2.getProgress()).thenReturn(TEST_VOLUME_VALUE);
|
when(mPreference2.getProgress()).thenReturn(TEST_VOLUME_VALUE);
|
||||||
mController.setPreferenceGroup(mPreferenceGroup);
|
mController.setPreferenceGroup(mPreferenceGroup);
|
||||||
@@ -435,8 +436,8 @@ public class AudioSharingDeviceVolumeGroupControllerTest {
|
|||||||
mController.onDeviceAdded(mPreference2);
|
mController.onDeviceAdded(mPreference2);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
Settings.Secure.putInt(
|
Settings.Secure.putInt(mContentResolver, BluetoothUtils.getPrimaryGroupIdUriForBroadcast(),
|
||||||
mContentResolver, SETTINGS_KEY_FALLBACK_DEVICE_GROUP_ID, TEST_DEVICE_GROUP_ID1);
|
TEST_DEVICE_GROUP_ID1);
|
||||||
mContentObserver.onChange(true);
|
mContentObserver.onChange(true);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
|
@@ -35,7 +35,6 @@ import android.bluetooth.BluetoothDevice;
|
|||||||
import android.bluetooth.BluetoothLeBroadcast;
|
import android.bluetooth.BluetoothLeBroadcast;
|
||||||
import android.bluetooth.BluetoothLeBroadcastMetadata;
|
import android.bluetooth.BluetoothLeBroadcastMetadata;
|
||||||
import android.bluetooth.BluetoothLeBroadcastReceiveState;
|
import android.bluetooth.BluetoothLeBroadcastReceiveState;
|
||||||
import android.bluetooth.BluetoothProfile;
|
|
||||||
import android.bluetooth.BluetoothStatusCodes;
|
import android.bluetooth.BluetoothStatusCodes;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
@@ -187,9 +186,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void handleUserTriggeredNonLeaDeviceConnected_noSharing_setActive() {
|
public void handleUserTriggeredNonLeaDeviceConnected_noSharing_setActive() {
|
||||||
setUpBroadcast(false);
|
setUpBroadcast(false);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice2);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice2);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||||
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ true);
|
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ true);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -200,9 +197,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void handleUserTriggeredNonLeaDeviceConnected_sharing_showStopDialog() {
|
public void handleUserTriggeredNonLeaDeviceConnected_sharing_showStopDialog() {
|
||||||
setUpBroadcast(true);
|
setUpBroadcast(true);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice2);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice2);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
||||||
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ true);
|
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ true);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -239,9 +234,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void handleUserTriggeredLeaDeviceConnected_noSharingNoTwoLeaDevices_setActive() {
|
public void handleUserTriggeredLeaDeviceConnected_noSharingNoTwoLeaDevices_setActive() {
|
||||||
setUpBroadcast(false);
|
setUpBroadcast(false);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||||
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
|
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -254,9 +247,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
when(mCachedDevice1.getGroupId()).thenReturn(-1);
|
when(mCachedDevice1.getGroupId()).thenReturn(-1);
|
||||||
when(mLeAudioProfile.getGroupId(mDevice1)).thenReturn(-1);
|
when(mLeAudioProfile.getGroupId(mDevice1)).thenReturn(-1);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||||
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
|
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -269,9 +260,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void handleUserTriggeredLeaDeviceConnected_noSharingTwoLeaDevices_showJoinDialog() {
|
public void handleUserTriggeredLeaDeviceConnected_noSharingTwoLeaDevices_showJoinDialog() {
|
||||||
setUpBroadcast(false);
|
setUpBroadcast(false);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||||
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
|
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -314,9 +303,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void handleUserTriggeredLeaDeviceConnected_sharing_showJoinDialog() {
|
public void handleUserTriggeredLeaDeviceConnected_sharing_showJoinDialog() {
|
||||||
setUpBroadcast(true);
|
setUpBroadcast(true);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(mDevice1)).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(mDevice1)).thenReturn(ImmutableList.of());
|
||||||
when(mAssistant.getAllSources(mDevice3)).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(mDevice3)).thenReturn(ImmutableList.of(mState));
|
||||||
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
|
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
|
||||||
@@ -361,9 +348,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
handleUserTriggeredLeaDeviceConnected_sharingWithTwoLeaDevices_showDisconnectDialog() {
|
handleUserTriggeredLeaDeviceConnected_sharingWithTwoLeaDevices_showDisconnectDialog() {
|
||||||
setUpBroadcast(true);
|
setUpBroadcast(true);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3, mDevice4);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3, mDevice4);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(mDevice1)).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(mDevice1)).thenReturn(ImmutableList.of());
|
||||||
when(mAssistant.getAllSources(mDevice3)).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(mDevice3)).thenReturn(ImmutableList.of(mState));
|
||||||
when(mAssistant.getAllSources(mDevice4)).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(mDevice4)).thenReturn(ImmutableList.of(mState));
|
||||||
@@ -407,9 +392,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void handleNonLeaDeviceConnected_noSharing_doNothing() {
|
public void handleNonLeaDeviceConnected_noSharing_doNothing() {
|
||||||
setUpBroadcast(false);
|
setUpBroadcast(false);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice2);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice2);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||||
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ false);
|
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ false);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -420,9 +403,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void handleNonLeaDeviceConnected_sharing_showStopDialog() {
|
public void handleNonLeaDeviceConnected_sharing_showStopDialog() {
|
||||||
setUpBroadcast(true);
|
setUpBroadcast(true);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
||||||
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ false);
|
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ false);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -459,9 +440,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void handleLeaDeviceConnected_noSharingNoTwoLeaDevices_doNothing() {
|
public void handleLeaDeviceConnected_noSharingNoTwoLeaDevices_doNothing() {
|
||||||
setUpBroadcast(false);
|
setUpBroadcast(false);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||||
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ false);
|
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ false);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -474,9 +453,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
when(mCachedDevice1.getGroupId()).thenReturn(-1);
|
when(mCachedDevice1.getGroupId()).thenReturn(-1);
|
||||||
when(mLeAudioProfile.getGroupId(mDevice1)).thenReturn(-1);
|
when(mLeAudioProfile.getGroupId(mDevice1)).thenReturn(-1);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||||
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ false);
|
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ false);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -489,9 +466,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void handleLeaDeviceConnected_noSharingTwoLeaDevices_showJoinDialog() {
|
public void handleLeaDeviceConnected_noSharingTwoLeaDevices_showJoinDialog() {
|
||||||
setUpBroadcast(false);
|
setUpBroadcast(false);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||||
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ false);
|
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ false);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -534,9 +509,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void handleLeaDeviceConnected_sharing_showJoinDialog() {
|
public void handleLeaDeviceConnected_sharing_showJoinDialog() {
|
||||||
setUpBroadcast(true);
|
setUpBroadcast(true);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(mDevice1)).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(mDevice1)).thenReturn(ImmutableList.of());
|
||||||
when(mAssistant.getAllSources(mDevice3)).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(mDevice3)).thenReturn(ImmutableList.of(mState));
|
||||||
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ false);
|
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ false);
|
||||||
@@ -580,9 +553,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void handleLeaDeviceConnected_sharingWithTwoLeaDevices_showDisconnectDialog() {
|
public void handleLeaDeviceConnected_sharingWithTwoLeaDevices_showDisconnectDialog() {
|
||||||
setUpBroadcast(true);
|
setUpBroadcast(true);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3, mDevice4);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3, mDevice4);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(mDevice1)).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(mDevice1)).thenReturn(ImmutableList.of());
|
||||||
when(mAssistant.getAllSources(mDevice3)).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(mDevice3)).thenReturn(ImmutableList.of(mState));
|
||||||
when(mAssistant.getAllSources(mDevice4)).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(mDevice4)).thenReturn(ImmutableList.of(mState));
|
||||||
@@ -627,9 +598,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
// Show join dialog
|
// Show join dialog
|
||||||
setUpBroadcast(false);
|
setUpBroadcast(false);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||||
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
|
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -661,9 +630,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
// Show disconnect dialog
|
// Show disconnect dialog
|
||||||
setUpBroadcast(true);
|
setUpBroadcast(true);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3, mDevice4);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3, mDevice4);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(mDevice1)).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(mDevice1)).thenReturn(ImmutableList.of());
|
||||||
when(mAssistant.getAllSources(mDevice3)).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(mDevice3)).thenReturn(ImmutableList.of(mState));
|
||||||
when(mAssistant.getAllSources(mDevice4)).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(mDevice4)).thenReturn(ImmutableList.of(mState));
|
||||||
@@ -697,9 +664,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
// Show stop dialog
|
// Show stop dialog
|
||||||
setUpBroadcast(true);
|
setUpBroadcast(true);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
||||||
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ true);
|
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ true);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -721,9 +686,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void closeOpeningDialogsOtherThan() {
|
public void closeOpeningDialogsOtherThan() {
|
||||||
setUpBroadcast(true);
|
setUpBroadcast(true);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice3);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice3);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(mDevice3)).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(mDevice3)).thenReturn(ImmutableList.of(mState));
|
||||||
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ true);
|
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ true);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -733,9 +696,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
.containsExactly(AudioSharingStopDialogFragment.tag());
|
.containsExactly(AudioSharingStopDialogFragment.tag());
|
||||||
|
|
||||||
deviceList = ImmutableList.of(mDevice1, mDevice3);
|
deviceList = ImmutableList.of(mDevice1, mDevice3);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(mDevice1)).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(mDevice1)).thenReturn(ImmutableList.of());
|
||||||
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ false);
|
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ false);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -769,9 +730,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void onBroadcastStartFailed_logAction() {
|
public void onBroadcastStartFailed_logAction() {
|
||||||
setUpBroadcast(false);
|
setUpBroadcast(false);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||||
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ false);
|
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ false);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -797,9 +756,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void onPlaybackStarted_addSource() {
|
public void onPlaybackStarted_addSource() {
|
||||||
setUpBroadcast(false);
|
setUpBroadcast(false);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1, mDevice3);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||||
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
|
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
@@ -825,9 +782,7 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
public void onBroadcastStopFailed_logAction() {
|
public void onBroadcastStopFailed_logAction() {
|
||||||
setUpBroadcast(true);
|
setUpBroadcast(true);
|
||||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1);
|
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(deviceList);
|
|
||||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
||||||
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ false);
|
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ false);
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
@@ -378,9 +378,7 @@ public class AudioSharingSwitchBarControllerTest {
|
|||||||
FeatureFlagUtils.setEnabled(
|
FeatureFlagUtils.setEnabled(
|
||||||
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
||||||
when(mBtnView.isEnabled()).thenReturn(true);
|
when(mBtnView.isEnabled()).thenReturn(true);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of());
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of());
|
|
||||||
doNothing().when(mBroadcast).startPrivateBroadcast();
|
doNothing().when(mBroadcast).startPrivateBroadcast();
|
||||||
mController.onCheckedChanged(mBtnView, /* isChecked= */ true);
|
mController.onCheckedChanged(mBtnView, /* isChecked= */ true);
|
||||||
assertThat(mSwitchBar.isChecked()).isFalse();
|
assertThat(mSwitchBar.isChecked()).isFalse();
|
||||||
@@ -392,9 +390,7 @@ public class AudioSharingSwitchBarControllerTest {
|
|||||||
FeatureFlagUtils.setEnabled(
|
FeatureFlagUtils.setEnabled(
|
||||||
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, false);
|
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, false);
|
||||||
when(mBtnView.isEnabled()).thenReturn(true);
|
when(mBtnView.isEnabled()).thenReturn(true);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of());
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of());
|
|
||||||
doNothing().when(mBroadcast).startPrivateBroadcast();
|
doNothing().when(mBroadcast).startPrivateBroadcast();
|
||||||
mController.onCheckedChanged(mBtnView, /* isChecked= */ true);
|
mController.onCheckedChanged(mBtnView, /* isChecked= */ true);
|
||||||
verify(mBroadcast).startPrivateBroadcast();
|
verify(mBroadcast).startPrivateBroadcast();
|
||||||
@@ -405,9 +401,7 @@ public class AudioSharingSwitchBarControllerTest {
|
|||||||
FeatureFlagUtils.setEnabled(
|
FeatureFlagUtils.setEnabled(
|
||||||
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
||||||
when(mBtnView.isEnabled()).thenReturn(true);
|
when(mBtnView.isEnabled()).thenReturn(true);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1));
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of(mDevice1));
|
|
||||||
doNothing().when(mBroadcast).startPrivateBroadcast();
|
doNothing().when(mBroadcast).startPrivateBroadcast();
|
||||||
mController.onCheckedChanged(mBtnView, /* isChecked= */ true);
|
mController.onCheckedChanged(mBtnView, /* isChecked= */ true);
|
||||||
verify(mBroadcast).startPrivateBroadcast();
|
verify(mBroadcast).startPrivateBroadcast();
|
||||||
@@ -437,9 +431,7 @@ public class AudioSharingSwitchBarControllerTest {
|
|||||||
FeatureFlagUtils.setEnabled(
|
FeatureFlagUtils.setEnabled(
|
||||||
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
||||||
when(mBtnView.isEnabled()).thenReturn(true);
|
when(mBtnView.isEnabled()).thenReturn(true);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice2, mDevice1));
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of(mDevice2, mDevice1));
|
|
||||||
doNothing().when(mBroadcast).startPrivateBroadcast();
|
doNothing().when(mBroadcast).startPrivateBroadcast();
|
||||||
mController =
|
mController =
|
||||||
new AudioSharingSwitchBarController(
|
new AudioSharingSwitchBarController(
|
||||||
@@ -469,9 +461,7 @@ public class AudioSharingSwitchBarControllerTest {
|
|||||||
FeatureFlagUtils.setEnabled(
|
FeatureFlagUtils.setEnabled(
|
||||||
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
||||||
when(mBtnView.isEnabled()).thenReturn(true);
|
when(mBtnView.isEnabled()).thenReturn(true);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(
|
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice2, mDevice1));
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED}))
|
|
||||||
.thenReturn(ImmutableList.of(mDevice2, mDevice1));
|
|
||||||
doNothing().when(mBroadcast).startPrivateBroadcast();
|
doNothing().when(mBroadcast).startPrivateBroadcast();
|
||||||
mController.onCheckedChanged(mBtnView, /* isChecked= */ true);
|
mController.onCheckedChanged(mBtnView, /* isChecked= */ true);
|
||||||
verify(mBroadcast).startPrivateBroadcast();
|
verify(mBroadcast).startPrivateBroadcast();
|
||||||
|
@@ -219,7 +219,7 @@ public class AudioStreamConfirmDialogTest {
|
|||||||
public void showDialog_noMetadata() {
|
public void showDialog_noMetadata() {
|
||||||
List<BluetoothDevice> devices = new ArrayList<>();
|
List<BluetoothDevice> devices = new ArrayList<>();
|
||||||
devices.add(mBluetoothDevice);
|
devices.add(mBluetoothDevice);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(any())).thenReturn(devices);
|
when(mAssistant.getAllConnectedDevices()).thenReturn(devices);
|
||||||
when(mBluetoothDevice.getAlias()).thenReturn(DEVICE_NAME);
|
when(mBluetoothDevice.getAlias()).thenReturn(DEVICE_NAME);
|
||||||
|
|
||||||
FragmentController.setupFragment(
|
FragmentController.setupFragment(
|
||||||
@@ -267,7 +267,7 @@ public class AudioStreamConfirmDialogTest {
|
|||||||
public void showDialog_invalidMetadata() {
|
public void showDialog_invalidMetadata() {
|
||||||
List<BluetoothDevice> devices = new ArrayList<>();
|
List<BluetoothDevice> devices = new ArrayList<>();
|
||||||
devices.add(mBluetoothDevice);
|
devices.add(mBluetoothDevice);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(any())).thenReturn(devices);
|
when(mAssistant.getAllConnectedDevices()).thenReturn(devices);
|
||||||
when(mBluetoothDevice.getAlias()).thenReturn(DEVICE_NAME);
|
when(mBluetoothDevice.getAlias()).thenReturn(DEVICE_NAME);
|
||||||
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
@@ -318,7 +318,7 @@ public class AudioStreamConfirmDialogTest {
|
|||||||
public void showDialog_confirmListen() {
|
public void showDialog_confirmListen() {
|
||||||
List<BluetoothDevice> devices = new ArrayList<>();
|
List<BluetoothDevice> devices = new ArrayList<>();
|
||||||
devices.add(mBluetoothDevice);
|
devices.add(mBluetoothDevice);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(any())).thenReturn(devices);
|
when(mAssistant.getAllConnectedDevices()).thenReturn(devices);
|
||||||
when(mBluetoothDevice.getAlias()).thenReturn("");
|
when(mBluetoothDevice.getAlias()).thenReturn("");
|
||||||
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
|
@@ -91,7 +91,7 @@ public class AudioStreamsHelperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addSource_noDevice_doNothing() {
|
public void addSource_noDevice_doNothing() {
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(any()))
|
when(mAssistant.getAllConnectedDevices())
|
||||||
.thenReturn(Collections.emptyList());
|
.thenReturn(Collections.emptyList());
|
||||||
mHelper.addSource(mMetadata);
|
mHelper.addSource(mMetadata);
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ public class AudioStreamsHelperTest {
|
|||||||
public void addSource_hasDevice() {
|
public void addSource_hasDevice() {
|
||||||
List<BluetoothDevice> devices = new ArrayList<>();
|
List<BluetoothDevice> devices = new ArrayList<>();
|
||||||
devices.add(mDevice);
|
devices.add(mDevice);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(any())).thenReturn(devices);
|
when(mAssistant.getAllConnectedDevices()).thenReturn(devices);
|
||||||
when(mDeviceManager.findDevice(any())).thenReturn(mCachedDevice);
|
when(mDeviceManager.findDevice(any())).thenReturn(mCachedDevice);
|
||||||
when(mCachedDevice.getDevice()).thenReturn(mDevice);
|
when(mCachedDevice.getDevice()).thenReturn(mDevice);
|
||||||
when(mCachedDevice.getGroupId()).thenReturn(GROUP_ID);
|
when(mCachedDevice.getGroupId()).thenReturn(GROUP_ID);
|
||||||
@@ -114,7 +114,7 @@ public class AudioStreamsHelperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeSource_noDevice_doNothing() {
|
public void removeSource_noDevice_doNothing() {
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(any()))
|
when(mAssistant.getAllConnectedDevices())
|
||||||
.thenReturn(Collections.emptyList());
|
.thenReturn(Collections.emptyList());
|
||||||
mHelper.removeSource(BROADCAST_ID_1);
|
mHelper.removeSource(BROADCAST_ID_1);
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ public class AudioStreamsHelperTest {
|
|||||||
public void removeSource_noConnectedSource_doNothing() {
|
public void removeSource_noConnectedSource_doNothing() {
|
||||||
List<BluetoothDevice> devices = new ArrayList<>();
|
List<BluetoothDevice> devices = new ArrayList<>();
|
||||||
devices.add(mDevice);
|
devices.add(mDevice);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(any())).thenReturn(devices);
|
when(mAssistant.getAllConnectedDevices()).thenReturn(devices);
|
||||||
BluetoothLeBroadcastReceiveState source = mock(BluetoothLeBroadcastReceiveState.class);
|
BluetoothLeBroadcastReceiveState source = mock(BluetoothLeBroadcastReceiveState.class);
|
||||||
when(source.getBroadcastId()).thenReturn(BROADCAST_ID_2);
|
when(source.getBroadcastId()).thenReturn(BROADCAST_ID_2);
|
||||||
when(mDeviceManager.findDevice(any())).thenReturn(mCachedDevice);
|
when(mDeviceManager.findDevice(any())).thenReturn(mCachedDevice);
|
||||||
@@ -142,7 +142,7 @@ public class AudioStreamsHelperTest {
|
|||||||
public void removeSource_hasConnectedSource() {
|
public void removeSource_hasConnectedSource() {
|
||||||
List<BluetoothDevice> devices = new ArrayList<>();
|
List<BluetoothDevice> devices = new ArrayList<>();
|
||||||
devices.add(mDevice);
|
devices.add(mDevice);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(any())).thenReturn(devices);
|
when(mAssistant.getAllConnectedDevices()).thenReturn(devices);
|
||||||
BluetoothLeBroadcastReceiveState source = mock(BluetoothLeBroadcastReceiveState.class);
|
BluetoothLeBroadcastReceiveState source = mock(BluetoothLeBroadcastReceiveState.class);
|
||||||
when(source.getBroadcastId()).thenReturn(BROADCAST_ID_2);
|
when(source.getBroadcastId()).thenReturn(BROADCAST_ID_2);
|
||||||
when(mDeviceManager.findDevice(any())).thenReturn(mCachedDevice);
|
when(mDeviceManager.findDevice(any())).thenReturn(mCachedDevice);
|
||||||
@@ -164,7 +164,7 @@ public class AudioStreamsHelperTest {
|
|||||||
var memberDevice = mock(BluetoothDevice.class);
|
var memberDevice = mock(BluetoothDevice.class);
|
||||||
devices.add(mDevice);
|
devices.add(mDevice);
|
||||||
devices.add(memberDevice);
|
devices.add(memberDevice);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(any())).thenReturn(devices);
|
when(mAssistant.getAllConnectedDevices()).thenReturn(devices);
|
||||||
BluetoothLeBroadcastReceiveState source = mock(BluetoothLeBroadcastReceiveState.class);
|
BluetoothLeBroadcastReceiveState source = mock(BluetoothLeBroadcastReceiveState.class);
|
||||||
when(source.getBroadcastId()).thenReturn(BROADCAST_ID_2);
|
when(source.getBroadcastId()).thenReturn(BROADCAST_ID_2);
|
||||||
when(mDeviceManager.findDevice(any())).thenReturn(mCachedDevice);
|
when(mDeviceManager.findDevice(any())).thenReturn(mCachedDevice);
|
||||||
@@ -196,7 +196,7 @@ public class AudioStreamsHelperTest {
|
|||||||
public void getAllConnectedSources_returnSource() {
|
public void getAllConnectedSources_returnSource() {
|
||||||
List<BluetoothDevice> devices = new ArrayList<>();
|
List<BluetoothDevice> devices = new ArrayList<>();
|
||||||
devices.add(mDevice);
|
devices.add(mDevice);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(any())).thenReturn(devices);
|
when(mAssistant.getAllConnectedDevices()).thenReturn(devices);
|
||||||
BluetoothLeBroadcastReceiveState source = mock(BluetoothLeBroadcastReceiveState.class);
|
BluetoothLeBroadcastReceiveState source = mock(BluetoothLeBroadcastReceiveState.class);
|
||||||
when(mDeviceManager.findDevice(any())).thenReturn(mCachedDevice);
|
when(mDeviceManager.findDevice(any())).thenReturn(mCachedDevice);
|
||||||
when(mCachedDevice.getDevice()).thenReturn(mDevice);
|
when(mCachedDevice.getDevice()).thenReturn(mDevice);
|
||||||
@@ -222,7 +222,7 @@ public class AudioStreamsHelperTest {
|
|||||||
public void startMediaService_hasDevice() {
|
public void startMediaService_hasDevice() {
|
||||||
List<BluetoothDevice> devices = new ArrayList<>();
|
List<BluetoothDevice> devices = new ArrayList<>();
|
||||||
devices.add(mDevice);
|
devices.add(mDevice);
|
||||||
when(mAssistant.getDevicesMatchingConnectionStates(any())).thenReturn(devices);
|
when(mAssistant.getAllConnectedDevices()).thenReturn(devices);
|
||||||
BluetoothLeBroadcastReceiveState source = mock(BluetoothLeBroadcastReceiveState.class);
|
BluetoothLeBroadcastReceiveState source = mock(BluetoothLeBroadcastReceiveState.class);
|
||||||
when(mDeviceManager.findDevice(any())).thenReturn(mCachedDevice);
|
when(mDeviceManager.findDevice(any())).thenReturn(mCachedDevice);
|
||||||
when(mCachedDevice.getDevice()).thenReturn(mDevice);
|
when(mCachedDevice.getDevice()).thenReturn(mDevice);
|
||||||
|
Reference in New Issue
Block a user