[Audiosharing] Route to audio sharing page to start broadcast.
Since we already support auto start sharing and add source from QS pill click. We can reuse the intent when user click on the second LEA headset to start audio sharing from Connected devices page. Test: atest Bug: 331892035 Flag: com.android.settingslib.flags.enable_le_audio_sharing Change-Id: I83f7ae25ed96bbddb3c631b69b409f09577f421b
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.connecteddevice.audiosharing;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast.EXTRA_START_LE_AUDIO_SHARING;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.bluetooth.BluetoothCsipSetCoordinator;
|
||||
@@ -25,6 +25,7 @@ import android.bluetooth.BluetoothLeBroadcast;
|
||||
import android.bluetooth.BluetoothLeBroadcastMetadata;
|
||||
import android.bluetooth.BluetoothLeBroadcastReceiveState;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
@@ -34,6 +35,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.bluetooth.Utils;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
@@ -63,8 +65,6 @@ public class AudioSharingDialogHandler {
|
||||
@Nullable private final LocalBluetoothLeBroadcast mBroadcast;
|
||||
@Nullable private final LocalBluetoothLeBroadcastAssistant mAssistant;
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
// The target sinks to join broadcast onPlaybackStarted
|
||||
@Nullable private List<BluetoothDevice> mTargetSinks;
|
||||
private boolean mIsStoppingBroadcast = false;
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -83,15 +83,6 @@ public class AudioSharingDialogHandler {
|
||||
@Override
|
||||
public void onBroadcastStartFailed(int reason) {
|
||||
Log.d(TAG, "onBroadcastStartFailed(), reason = " + reason);
|
||||
if (mTargetSinks != null) {
|
||||
mMetricsFeatureProvider.action(
|
||||
mContext,
|
||||
SettingsEnums.ACTION_AUDIO_SHARING_START_FAILED,
|
||||
SettingsEnums.SETTINGS_CONNECTED_DEVICE_CATEGORY);
|
||||
AudioSharingUtils.toastMessage(
|
||||
mContext, "Fail to start broadcast, reason " + reason);
|
||||
mTargetSinks = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,6 +104,9 @@ public class AudioSharingDialogHandler {
|
||||
+ reason
|
||||
+ ", broadcastId = "
|
||||
+ broadcastId);
|
||||
AudioSharingUtils.toastMessage(
|
||||
mContext,
|
||||
mContext.getString(R.string.audio_sharing_sharing_stopped_label));
|
||||
mIsStoppingBroadcast = false;
|
||||
}
|
||||
|
||||
@@ -144,18 +138,6 @@ public class AudioSharingDialogHandler {
|
||||
+ reason
|
||||
+ ", broadcastId = "
|
||||
+ broadcastId);
|
||||
if (mTargetSinks != null) {
|
||||
AudioSharingUtils.addSourceToTargetSinks(mTargetSinks, mLocalBtManager);
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(AudioSharingDashboardFragment.class.getName())
|
||||
.setSourceMetricsCategory(
|
||||
(mHostFragment instanceof DashboardFragment)
|
||||
? ((DashboardFragment) mHostFragment)
|
||||
.getMetricsCategory()
|
||||
: SettingsEnums.PAGE_UNKNOWN)
|
||||
.launch();
|
||||
mTargetSinks = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -375,14 +357,18 @@ public class AudioSharingDialogHandler {
|
||||
new AudioSharingJoinDialogFragment.DialogEventListener() {
|
||||
@Override
|
||||
public void onShareClick() {
|
||||
mTargetSinks =
|
||||
groupedDevices.values().stream()
|
||||
.flatMap(items -> items.stream())
|
||||
.collect(toList());
|
||||
Log.d(TAG, "Start broadcast with sinks = " + mTargetSinks.size());
|
||||
if (mBroadcast != null) {
|
||||
mBroadcast.startPrivateBroadcast();
|
||||
}
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(EXTRA_START_LE_AUDIO_SHARING, true);
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(
|
||||
AudioSharingDashboardFragment.class.getName())
|
||||
.setSourceMetricsCategory(
|
||||
(mHostFragment instanceof DashboardFragment)
|
||||
? ((DashboardFragment) mHostFragment)
|
||||
.getMetricsCategory()
|
||||
: SettingsEnums.PAGE_UNKNOWN)
|
||||
.setArguments(args)
|
||||
.launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user