shadows/framework/src/main/java/org/robolectric/shadows/ShadowInstrumentation.java
private ListenableFuture<BroadcastResultHolder> postIntent(
      final Wrapper wrapper,
      final Intent intent,
      ListenableFuture<BroadcastResultHolder> oldResult,
      final AtomicBoolean abort,
      final Context context) {
    final Handler scheduler =
        (wrapper.scheduler != null) ? wrapper.scheduler : getMainHandler(context);
    return Futures.transformAsync(
        oldResult,
        new AsyncFunction<BroadcastResultHolder, BroadcastResultHolder>() {
          @Override
          public ListenableFuture<BroadcastResultHolder> apply(
              BroadcastResultHolder broadcastResultHolder) throws Exception {
            final BroadcastReceiver.PendingResult result =
                ShadowBroadcastPendingResult.create(
                    broadcastResultHolder.resultCode,
                    broadcastResultHolder.resultData,
                    broadcastResultHolder.resultExtras,
                    true /*ordered */);
            wrapper.broadcastReceiver.setPendingResult(result);
            scheduler.post(
                () -> {
                  ShadowBroadcastReceiver shadowBroadcastReceiver =
                      Shadow.extract(wrapper.broadcastReceiver);
                  shadowBroadcastReceiver.onReceive(context, intent, abort);
                });
            return BroadcastResultHolder.transform(result);
          }
        },
        directExecutor());
  }
private ListenableFuture<BroadcastResultHolder> postIntent(
      final Wrapper wrapper,
      final Intent intent,
      ListenableFuture<BroadcastResultHolder> oldResult,
      final AtomicBoolean abort,
      final Context context) {
    final Handler scheduler =
        (wrapper.scheduler != null) ? wrapper.scheduler : getMainHandler(context);
    return Futures.transformAsync(
        oldResult,
        new AsyncFunction<BroadcastResultHolder, BroadcastResultHolder>() {
          @Override
          public ListenableFuture<BroadcastResultHolder> apply(
              BroadcastResultHolder broadcastResultHolder) throws Exception {
            final BroadcastReceiver.PendingResult result =
                ShadowBroadcastPendingResult.create(
                    broadcastResultHolder.resultCode,
                    broadcastResultHolder.resultData,
                    broadcastResultHolder.resultExtras,
                    true /*ordered */);
            wrapper.broadcastReceiver.setPendingResult(result);
            scheduler.post(
                () -> {
                  ShadowBroadcastReceiver shadowBroadcastReceiver =
                      Shadow.extract(wrapper.broadcastReceiver);
                  shadowBroadcastReceiver.onReceive(context, intent, abort);
                });
            return BroadcastResultHolder.transform(result);
          }
        },
        directExecutor());
  }
private ListenableFuture < BroadcastResultHolder > postIntent ( final Wrapper wrapper , final Intent intent , ListenableFuture < BroadcastResultHolder > oldResult , final AtomicBoolean abort , final Context context ) { final Handler scheduler = ( wrapper . scheduler != null ) ? wrapper . scheduler : getMainHandler ( context ) ; return Futures . transformAsync ( oldResult , new AsyncFunction < BroadcastResultHolder , BroadcastResultHolder > ( ) { @ Override public ListenableFuture < BroadcastResultHolder > apply ( BroadcastResultHolder broadcastResultHolder ) throws Exception { final BroadcastReceiver . PendingResult result = ShadowBroadcastPendingResult . create ( broadcastResultHolder . resultCode , broadcastResultHolder . resultData , broadcastResultHolder . resultExtras , true /*ordered */ ) ; wrapper . broadcastReceiver . setPendingResult ( result ) ; scheduler . post ( ( ) -> { ShadowBroadcastReceiver shadowBroadcastReceiver = Shadow . extract ( wrapper . broadcastReceiver ) ; shadowBroadcastReceiver . onReceive ( context , intent , abort ) ; } ) ; return BroadcastResultHolder . transform ( result ) ; } } , directExecutor ( ) ) ; }
Enforces that BroadcastReceivers invoked during an ordered broadcast run serially, passing
along their results.
Enforces that BroadcastReceivers invoked during an ordered broadcast run serially passing along their results .