Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc78ca78 authored by Yiyi Shen's avatar Yiyi Shen Committed by Android (Google) Code Review
Browse files

Merge "[Audiosharing] Start join handler activity from receiver" into main

parents 829a924d ab466747
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.settings.connecteddevice.audiosharing;

import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;

import static com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast.EXTRA_BLUETOOTH_DEVICE;

import android.Manifest;
@@ -143,8 +145,12 @@ public class AudioSharingReceiver extends BroadcastReceiver {
                    return;
                }
                if (isAppInForeground(context)) {
                    // TODO: show dialog
                    Log.d(TAG, "App in foreground, show share audio dialog");
                    Intent dialogIntent = new Intent();
                    dialogIntent.setClass(context, AudioSharingJoinHandlerActivity.class);
                    dialogIntent.addFlags(FLAG_ACTIVITY_NEW_TASK);
                    dialogIntent.putExtra(EXTRA_BLUETOOTH_DEVICE, device);
                    context.startActivity(dialogIntent);
                } else {
                    Log.d(TAG, "App not in foreground, show share audio notification");
                    LocalBluetoothManager manager = Utils.getLocalBtManager(context);
+8 −2
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@@ -370,7 +371,12 @@ public class AudioSharingReceiverTest {
        verify(mNm, never()).notify(
                eq(com.android.settings.R.string.share_audio_notification_title),
                any(Notification.class));
        // TODO: verify show dialog once impl complete
        ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
        verify(mContext).startActivity(intentCaptor.capture());
        assertThat(intentCaptor.getValue().getComponent().getClassName()).isEqualTo(
                AudioSharingJoinHandlerActivity.class.getName());
        assertThat(intentCaptor.getValue().getParcelableExtra(EXTRA_BLUETOOTH_DEVICE,
                BluetoothDevice.class)).isEqualTo(mDevice);
    }

    @Test
@@ -513,7 +519,7 @@ public class AudioSharingReceiverTest {
        AudioSharingReceiver audioSharingReceiver = getAudioSharingReceiver(intent);
        audioSharingReceiver.onReceive(mContext, intent);

        // TODO: verify no dialog once impl complete
        verify(mContext, never()).startActivity(any());
        verify(mNm).notify(eq(com.android.settings.R.string.share_audio_notification_title),
                any(Notification.class));
    }