Merge "[LeAudio Broadcast] Shows the broadcast icon on output switcher" into tm-qpr-dev am: 1e7afc3a20 am: 6440837108
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19255508 Change-Id: I2c87e22a8bc818e701d979a9ee43937c2cc53782 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -42,12 +42,35 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="12dp"
|
||||
android:orientation="vertical">
|
||||
<ImageView
|
||||
android:id="@+id/app_source_icon"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:importantForAccessibility="no"/>
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/app_source_icon"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:gravity="center_vertical"
|
||||
android:importantForAccessibility="no"/>
|
||||
|
||||
<Space
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/broadcast_icon"
|
||||
android:src="@drawable/settings_input_antenna"
|
||||
android:contentDescription="@string/broadcasting_description_is_broadcasting"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:padding="12dp"
|
||||
android:gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/header_title"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -91,6 +91,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
||||
private TextView mHeaderSubtitle;
|
||||
private ImageView mHeaderIcon;
|
||||
private ImageView mAppResourceIcon;
|
||||
private ImageView mBroadcastIcon;
|
||||
private RecyclerView mDevicesRecyclerView;
|
||||
private LinearLayout mDeviceListLayout;
|
||||
private LinearLayout mCastAppLayout;
|
||||
@@ -239,6 +240,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
||||
mAppButton = mDialogView.requireViewById(R.id.launch_app_button);
|
||||
mAppResourceIcon = mDialogView.requireViewById(R.id.app_source_icon);
|
||||
mCastAppLayout = mDialogView.requireViewById(R.id.cast_app_section);
|
||||
mBroadcastIcon = mDialogView.requireViewById(R.id.broadcast_icon);
|
||||
|
||||
mDeviceListLayout.getViewTreeObserver().addOnGlobalLayoutListener(
|
||||
mDeviceListLayoutListener);
|
||||
@@ -366,6 +368,9 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
||||
mStopButton.setEnabled(true);
|
||||
mStopButton.setText(getStopButtonText());
|
||||
mStopButton.setOnClickListener(v -> onStopButtonClick());
|
||||
|
||||
mBroadcastIcon.setVisibility(getBroadcastIconVisibility());
|
||||
mBroadcastIcon.setOnClickListener(v -> onBroadcastIconClick());
|
||||
}
|
||||
|
||||
private void updateButtonBackgroundColorFilter() {
|
||||
@@ -490,6 +495,14 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
||||
dismiss();
|
||||
}
|
||||
|
||||
public int getBroadcastIconVisibility() {
|
||||
return View.GONE;
|
||||
}
|
||||
|
||||
public void onBroadcastIconClick() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public boolean isBroadcastSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -134,6 +134,17 @@ public class MediaOutputDialog extends MediaOutputBaseDialog {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBroadcastIconVisibility() {
|
||||
return (isBroadcastSupported() && mMediaOutputController.isBluetoothLeBroadcastEnabled())
|
||||
? View.VISIBLE : View.GONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBroadcastIconClick() {
|
||||
startLeBroadcastDialog();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public enum MediaOutputEvent implements UiEventLogger.UiEventEnum {
|
||||
@UiEvent(doc = "The MediaOutput dialog became visible on the screen.")
|
||||
|
||||
@@ -43,6 +43,8 @@ import android.widget.TextView;
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||
@@ -98,10 +100,17 @@ public class MediaOutputBaseDialogTest extends SysuiTestCase {
|
||||
private CharSequence mHeaderSubtitle;
|
||||
private String mStopText;
|
||||
private boolean mIsBroadcasting;
|
||||
private boolean mIsBroadcastIconVisibility;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
|
||||
final CachedBluetoothDeviceManager cachedBluetoothDeviceManager = mock(
|
||||
CachedBluetoothDeviceManager.class);
|
||||
when(mLocalBluetoothManager.getCachedDeviceManager()).thenReturn(
|
||||
cachedBluetoothDeviceManager);
|
||||
when(cachedBluetoothDeviceManager.findDevice(any())).thenReturn(null);
|
||||
when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(null);
|
||||
when(mMediaController.getPlaybackState()).thenReturn(mPlaybackState);
|
||||
when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_NONE);
|
||||
@@ -152,6 +161,27 @@ public class MediaOutputBaseDialogTest extends SysuiTestCase {
|
||||
assertThat(view.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refresh_broadcastIconVisibilityOff_broadcastIconLayoutNotVisible() {
|
||||
mIsBroadcastIconVisibility = false;
|
||||
|
||||
mMediaOutputBaseDialogImpl.refresh();
|
||||
final ImageView view = mMediaOutputBaseDialogImpl.mDialogView.requireViewById(
|
||||
R.id.broadcast_icon);
|
||||
|
||||
assertThat(view.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
@Test
|
||||
public void refresh_broadcastIconVisibilityOn_broadcastIconLayoutVisible() {
|
||||
mIsBroadcastIconVisibility = true;
|
||||
|
||||
mMediaOutputBaseDialogImpl.refresh();
|
||||
final ImageView view = mMediaOutputBaseDialogImpl.mDialogView.requireViewById(
|
||||
R.id.broadcast_icon);
|
||||
|
||||
assertThat(view.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refresh_checkTitle() {
|
||||
mHeaderTitle = "test_string";
|
||||
@@ -308,5 +338,10 @@ public class MediaOutputBaseDialogTest extends SysuiTestCase {
|
||||
public CharSequence getStopButtonText() {
|
||||
return mStopText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBroadcastIconVisibility() {
|
||||
return mIsBroadcastIconVisibility ? View.VISIBLE : View.GONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,6 +171,39 @@ public class MediaOutputDialogTest extends SysuiTestCase {
|
||||
assertThat(mMediaOutputDialog.getStopButtonVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBroadcastIconVisibility_isBroadcasting_returnVisible() {
|
||||
when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
|
||||
mLocalBluetoothLeBroadcast);
|
||||
when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(true);
|
||||
when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PLAYING);
|
||||
when(mMediaDevice.isBLEDevice()).thenReturn(true);
|
||||
|
||||
assertThat(mMediaOutputDialog.getBroadcastIconVisibility()).isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBroadcastIconVisibility_noBroadcasting_returnGone() {
|
||||
when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
|
||||
mLocalBluetoothLeBroadcast);
|
||||
when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(false);
|
||||
when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PLAYING);
|
||||
when(mMediaDevice.isBLEDevice()).thenReturn(true);
|
||||
|
||||
assertThat(mMediaOutputDialog.getBroadcastIconVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBroadcastIconVisibility_remoteNonLeDevice_returnGone() {
|
||||
when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
|
||||
mLocalBluetoothLeBroadcast);
|
||||
when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(false);
|
||||
when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PLAYING);
|
||||
when(mMediaDevice.isBLEDevice()).thenReturn(false);
|
||||
|
||||
assertThat(mMediaOutputDialog.getBroadcastIconVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
// Check the visibility metric logging by creating a new MediaOutput dialog,
|
||||
// and verify if the calling times increases.
|
||||
|
||||
Reference in New Issue
Block a user