Fixes BugreportReceiverTest failed

Instead of sending INTENT_BUGREPORT_REQUESTED, invoke
BugreportRequestedReceiver instance directly.

Bug: 174832302
Test: atest BugreportReceiverTest
Change-Id: I99a052d74b71d503a655a769064a74246da150e5
This commit is contained in:
Rhed Jao
2020-12-04 21:32:12 +08:00
parent 82f20411b5
commit bc1f3bff51

View File

@@ -576,9 +576,10 @@ public class BugreportReceiverTest {
*/ */
private void sendBugreportStarted() throws Exception { private void sendBugreportStarted() throws Exception {
Intent intent = new Intent(INTENT_BUGREPORT_REQUESTED); Intent intent = new Intent(INTENT_BUGREPORT_REQUESTED);
intent.setPackage("com.android.shell"); // Ideally, we should invoke BugreportRequestedReceiver by sending
intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND); // INTENT_BUGREPORT_REQUESTED. But the intent has been protected broadcast by the system
mContext.sendBroadcast(intent); // starting from S.
new BugreportRequestedReceiver().onReceive(mContext, intent);
ArgumentCaptor<IDumpstateListener> listenerCap = ArgumentCaptor.forClass( ArgumentCaptor<IDumpstateListener> listenerCap = ArgumentCaptor.forClass(
IDumpstateListener.class); IDumpstateListener.class);