[LE Audio] Add entry point in Media Volume slice for broadcast sink
Bug: 228274114 Test: make RunSettingsRoboTests Test: Manual test Change-Id: I331232c30291348faf7166d4de8060a1cfe12bff
This commit is contained in:
@@ -579,6 +579,9 @@
|
|||||||
<!-- Padding for indeterminate progress bar -->
|
<!-- Padding for indeterminate progress bar -->
|
||||||
<item name="progressBarStartPadding">12dp</item>
|
<item name="progressBarStartPadding">12dp</item>
|
||||||
<item name="progressBarEndPadding">16dp</item>
|
<item name="progressBarEndPadding">16dp</item>
|
||||||
|
|
||||||
|
<!-- Title icon size -->
|
||||||
|
<item name="iconSize">25dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="SliceRow.Slider.LargeIcon">
|
<style name="SliceRow.Slider.LargeIcon">
|
||||||
|
@@ -17,6 +17,7 @@ package com.android.settings.core;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
import androidx.slice.builders.SliceAction;
|
||||||
|
|
||||||
import com.android.settings.slices.SliceData;
|
import com.android.settings.slices.SliceData;
|
||||||
|
|
||||||
@@ -70,4 +71,11 @@ public abstract class SliderPreferenceController extends BasePreferenceControlle
|
|||||||
public int getSliceType() {
|
public int getSliceType() {
|
||||||
return SliceData.SliceType.SLIDER;
|
return SliceData.SliceType.SLIDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the SliceAction for the end item of the slice.
|
||||||
|
*/
|
||||||
|
public SliceAction getSliceEndItem(Context context) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,7 @@ import androidx.annotation.Nullable;
|
|||||||
import com.android.settings.bluetooth.Utils;
|
import com.android.settings.bluetooth.Utils;
|
||||||
import com.android.settings.slices.SliceBackgroundWorker;
|
import com.android.settings.slices.SliceBackgroundWorker;
|
||||||
import com.android.settingslib.bluetooth.BluetoothCallback;
|
import com.android.settingslib.bluetooth.BluetoothCallback;
|
||||||
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
import com.android.settingslib.media.LocalMediaManager;
|
import com.android.settingslib.media.LocalMediaManager;
|
||||||
import com.android.settingslib.media.MediaDevice;
|
import com.android.settingslib.media.MediaDevice;
|
||||||
@@ -126,7 +127,7 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
MediaController getActiveLocalMediaController() {
|
public MediaController getActiveLocalMediaController() {
|
||||||
return MediaOutputUtils.getActiveLocalMediaController(mContext.getSystemService(
|
return MediaOutputUtils.getActiveLocalMediaController(mContext.getSystemService(
|
||||||
MediaSessionManager.class));
|
MediaSessionManager.class));
|
||||||
}
|
}
|
||||||
@@ -156,7 +157,7 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements
|
|||||||
return mMediaDevices;
|
return mMediaDevices;
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaDevice getCurrentConnectedMediaDevice() {
|
public MediaDevice getCurrentConnectedMediaDevice() {
|
||||||
return mLocalMediaManager.getCurrentConnectedDevice();
|
return mLocalMediaManager.getCurrentConnectedDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +165,15 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements
|
|||||||
return mPackageName;
|
return mPackageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDeviceBroadcasting() {
|
||||||
|
LocalBluetoothLeBroadcast broadcast =
|
||||||
|
mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile();
|
||||||
|
if (broadcast == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return broadcast.isEnabled(null);
|
||||||
|
}
|
||||||
|
|
||||||
private class DevicesChangedBroadcastReceiver extends BroadcastReceiver {
|
private class DevicesChangedBroadcastReceiver extends BroadcastReceiver {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
@@ -16,16 +16,32 @@
|
|||||||
|
|
||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
|
import android.net.Uri;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.core.graphics.drawable.IconCompat;
|
||||||
|
import androidx.slice.builders.ListBuilder;
|
||||||
|
import androidx.slice.builders.SliceAction;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settings.media.MediaOutputIndicatorWorker;
|
||||||
|
import com.android.settings.slices.CustomSliceRegistry;
|
||||||
|
import com.android.settings.slices.SliceBackgroundWorker;
|
||||||
|
import com.android.settingslib.media.MediaDevice;
|
||||||
|
|
||||||
public class MediaVolumePreferenceController extends VolumeSeekBarPreferenceController {
|
public class MediaVolumePreferenceController extends VolumeSeekBarPreferenceController {
|
||||||
|
private static final String TAG = "MediaVolumePreCtrl";
|
||||||
private static final String KEY_MEDIA_VOLUME = "media_volume";
|
private static final String KEY_MEDIA_VOLUME = "media_volume";
|
||||||
|
|
||||||
|
private MediaOutputIndicatorWorker mWorker;
|
||||||
|
|
||||||
public MediaVolumePreferenceController(Context context) {
|
public MediaVolumePreferenceController(Context context) {
|
||||||
super(context, KEY_MEDIA_VOLUME);
|
super(context, KEY_MEDIA_VOLUME);
|
||||||
}
|
}
|
||||||
@@ -66,4 +82,66 @@ public class MediaVolumePreferenceController extends VolumeSeekBarPreferenceCont
|
|||||||
public int getMuteIcon() {
|
public int getMuteIcon() {
|
||||||
return R.drawable.ic_media_stream_off;
|
return R.drawable.ic_media_stream_off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isSupportEndItem() {
|
||||||
|
return getWorker() != null
|
||||||
|
&& getWorker().getActiveLocalMediaController() != null
|
||||||
|
&& isConnectedBLEDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isConnectedBLEDevice() {
|
||||||
|
final MediaDevice device = getWorker().getCurrentConnectedMediaDevice();
|
||||||
|
if (device != null) {
|
||||||
|
return device.isBLEDevice();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SliceAction getSliceEndItem(Context context) {
|
||||||
|
if (!isSupportEndItem()) {
|
||||||
|
Log.d(TAG, "The slice doesn't support end item");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Intent intent = new Intent();
|
||||||
|
if (getWorker().isDeviceBroadcasting()) {
|
||||||
|
// TODO(b/229577323) : Get the intent action for the Media Output Broadcast Dialog
|
||||||
|
// in SystemUI
|
||||||
|
} else {
|
||||||
|
// TODO(b/229577518) : Get the intent action of the Bluetooth Broadcast Dialog
|
||||||
|
// for user to choose the action
|
||||||
|
}
|
||||||
|
final PendingIntent pi = PendingIntent.getBroadcast(context, 0 /* requestCode */, intent,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
|
||||||
|
final IconCompat icon = getBroadcastIcon(context);
|
||||||
|
|
||||||
|
return SliceAction.createDeeplink(pi, icon, ListBuilder.ICON_IMAGE, getPreferenceKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
private IconCompat getBroadcastIcon(Context context) {
|
||||||
|
final Drawable drawable = context.getDrawable(
|
||||||
|
com.android.settingslib.R.drawable.settings_input_antenna);
|
||||||
|
if (drawable != null) {
|
||||||
|
drawable.setTint(Utils.getColorAccentDefaultColor(context));
|
||||||
|
return Utils.createIconWithDrawable(drawable);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MediaOutputIndicatorWorker getWorker() {
|
||||||
|
if (mWorker == null) {
|
||||||
|
mWorker = SliceBackgroundWorker.getInstance(getUri());
|
||||||
|
}
|
||||||
|
return mWorker;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Uri getUri() {
|
||||||
|
return CustomSliceRegistry.VOLUME_MEDIA_URI;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends SliceBackgroundWorker> getBackgroundWorkerClass() {
|
||||||
|
return MediaOutputIndicatorWorker.class;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -143,6 +143,9 @@ public class PanelSlicesAdapter
|
|||||||
sliceView.setVisibility(View.GONE);
|
sliceView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add divider for the end icon
|
||||||
|
sliceView.setShowActionDividers(true);
|
||||||
|
|
||||||
// Log Panel interaction
|
// Log Panel interaction
|
||||||
sliceView.setOnSliceActionListener(
|
sliceView.setOnSliceActionListener(
|
||||||
((eventInfo, sliceItem) -> {
|
((eventInfo, sliceItem) -> {
|
||||||
|
@@ -339,6 +339,11 @@ public class SliceBuilderUtils {
|
|||||||
inputRangeBuilder.setSubtitle(subtitleText);
|
inputRangeBuilder.setSubtitle(subtitleText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SliceAction endItemAction = sliderController.getSliceEndItem(context);
|
||||||
|
if (endItemAction != null) {
|
||||||
|
inputRangeBuilder.addEndItem(endItemAction);
|
||||||
|
}
|
||||||
|
|
||||||
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
|
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
|
||||||
.setAccentColor(color)
|
.setAccentColor(color)
|
||||||
.addInputRange(inputRangeBuilder)
|
.addInputRange(inputRangeBuilder)
|
||||||
|
Reference in New Issue
Block a user