Merge "[Audiosharing] Start join handler activity from receiver" into main
This commit is contained in:
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.connecteddevice.audiosharing;
|
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 static com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast.EXTRA_BLUETOOTH_DEVICE;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
@@ -143,8 +145,12 @@ public class AudioSharingReceiver extends BroadcastReceiver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isAppInForeground(context)) {
|
if (isAppInForeground(context)) {
|
||||||
// TODO: show dialog
|
|
||||||
Log.d(TAG, "App in foreground, show share audio 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 {
|
} else {
|
||||||
Log.d(TAG, "App not in foreground, show share audio notification");
|
Log.d(TAG, "App not in foreground, show share audio notification");
|
||||||
LocalBluetoothManager manager = Utils.getLocalBtManager(context);
|
LocalBluetoothManager manager = Utils.getLocalBtManager(context);
|
||||||
|
@@ -74,6 +74,7 @@ import org.junit.Before;
|
|||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.MockitoJUnit;
|
import org.mockito.junit.MockitoJUnit;
|
||||||
import org.mockito.junit.MockitoRule;
|
import org.mockito.junit.MockitoRule;
|
||||||
@@ -370,7 +371,12 @@ public class AudioSharingReceiverTest {
|
|||||||
verify(mNm, never()).notify(
|
verify(mNm, never()).notify(
|
||||||
eq(com.android.settings.R.string.share_audio_notification_title),
|
eq(com.android.settings.R.string.share_audio_notification_title),
|
||||||
any(Notification.class));
|
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
|
@Test
|
||||||
@@ -513,7 +519,7 @@ public class AudioSharingReceiverTest {
|
|||||||
AudioSharingReceiver audioSharingReceiver = getAudioSharingReceiver(intent);
|
AudioSharingReceiver audioSharingReceiver = getAudioSharingReceiver(intent);
|
||||||
audioSharingReceiver.onReceive(mContext, 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),
|
verify(mNm).notify(eq(com.android.settings.R.string.share_audio_notification_title),
|
||||||
any(Notification.class));
|
any(Notification.class));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user