@Override public void run() { receiver.onReceive(RuntimeEnvironment.application, broadcastIntent); } });
public void onReceive(Context context, Intent intent, AtomicBoolean abort) { this.abort = abort; onReceive(context, intent); // If the underlying receiver has called goAsync(), we should not finish the pending result yet - they'll do that // for us. if (receiver.getPendingResult() != null) { receiver.getPendingResult().finish(); } } }
private Intent processStickyIntents( IntentFilter filter, BroadcastReceiver receiver, Context context) { Intent result = null; for (Intent stickyIntent : stickyIntents.values()) { if (filter.matchAction(stickyIntent.getAction())) { if (result == null) { result = stickyIntent; } if (receiver != null) { receiver.setPendingResult(ShadowBroadcastPendingResult.createSticky(stickyIntent)); receiver.onReceive(context, stickyIntent); receiver.setPendingResult(null); } else if (result != null) { break; } } } return result; }
@Override public void run() { receiver.setPendingResult(ShadowBroadcastPendingResult.create(0, null, null, false)); shReceiver.onReceive(context, broadcastIntent, abort); } });
/** * Calls {@link BroadcastReceiver#abortBroadcast()} */ public void abortBroadcast() { broadcastReceiver.abortBroadcast(); }
@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); } },
device.setPin(convertPinToBytes(pinHint)); Log.d(TAG, "Setting pairing pin to " + pinHint); broadcastReceiver.abortBroadcast(); device.setPairingConfirmation(true); JoH.static_toast_short("xDrip Pairing"); broadcastReceiver.abortBroadcast(); } else { Log.d(TAG, "Attempting to passthrough PIN pairing");
@Implementation protected void onReceive(Context context, Intent intent) { if (abort == null || !abort.get()) { receiver.onReceive(context, intent); } }
private Intent processStickyIntents( IntentFilter filter, BroadcastReceiver receiver, Context context) { Intent result = null; for (Intent stickyIntent : stickyIntents.values()) { if (filter.matchAction(stickyIntent.getAction())) { if (result == null) { result = stickyIntent; } if (receiver != null) { receiver.setPendingResult(ShadowBroadcastPendingResult.createSticky(stickyIntent)); receiver.onReceive(context, stickyIntent); receiver.setPendingResult(null); } else if (result != null) { break; } } } return result; }
@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(new Runnable() { @Override public void run() { Shadows.shadowOf(wrapper.broadcastReceiver).onReceive(realApplication, intent, abort); } }); return BroadcastResultHolder.transform(result); }
public void onReceive(Context context, Intent intent, AtomicBoolean abort) { this.abort = abort; onReceive(context, intent); // If the underlying receiver has called goAsync(), we should not finish the pending result yet - they'll do that // for us. if (receiver.getPendingResult() != null) { receiver.getPendingResult().finish(); } } }
device.setPin(convertPinToBytes(pinHint)); Log.d(TAG, "Setting pairing pin to " + pinHint); broadcastReceiver.abortBroadcast(); device.setPairingConfirmation(true); JoH.static_toast_short("xDrip Pairing"); broadcastReceiver.abortBroadcast(); } else { Log.d(TAG, "Attempting to passthrough PIN pairing");
void proceedBroadcast(final Context context, final Intent intent, final WrappedValueProcedure<Boolean> procedure, final @Nullable BroadcastReceiver resultReceiver) { if (proceed(OutboundType.BROADCAST, intent, Boolean.FALSE, procedure) == Boolean.FALSE && resultReceiver != null) resultReceiver.onReceive(new ReceiverRestrictedContext(context), intent); }
@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(new Runnable() { @Override public void run() { Shadows.shadowOf(wrapper.broadcastReceiver).onReceive(realApplication, intent, abort); } }); return BroadcastResultHolder.transform(result); }
public void onReceive(Context context, Intent intent, AtomicBoolean abort) { this.abort = abort; onReceive(context, intent); // If the underlying receiver has called goAsync(), we should not finish the pending result yet - they'll do that // for us. if (receiver.getPendingResult() != null) { receiver.getPendingResult().finish(); } } }
device.setPin(convertPinToBytes(pinHint)); Log.d(TAG, "Setting pairing pin to " + pinHint); broadcastReceiver.abortBroadcast(); device.setPairingConfirmation(true); JoH.static_toast_short("xDrip Pairing"); broadcastReceiver.abortBroadcast(); } else { Log.d(TAG, "Attempting to passthrough PIN pairing");
private void handleReceiver(ReceiverData data) { BroadcastReceiver.PendingResult result = data.resultData.build(); try { if (!isBound()) { bindApplication(data.component.getPackageName(), data.processName); } Context context = mInitialApplication.getBaseContext(); Context receiverContext = ContextImpl.getReceiverRestrictedContext.call(context); String className = data.component.getClassName(); BroadcastReceiver receiver = (BroadcastReceiver) context.getClassLoader().loadClass(className).newInstance(); mirror.android.content.BroadcastReceiver.setPendingResult.call(receiver, result); data.intent.setExtrasClassLoader(context.getClassLoader()); if (data.intent.getComponent() == null) { data.intent.setComponent(data.component); } receiver.onReceive(receiverContext, data.intent); if (mirror.android.content.BroadcastReceiver.getPendingResult.call(receiver) != null) { result.finish(); } } catch (Exception e) { // must be this for misjudge of anti-virus!! throw new RuntimeException(String.format("Unable to start receiver: %s ", data.component), e); } VActivityManager.get().broadcastFinish(data.resultData); }
@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(new Runnable() { @Override public void run() { Shadows.shadowOf(wrapper.broadcastReceiver).onReceive(realApplication, intent, abort); } }); return BroadcastResultHolder.transform(result); }
public void onReceive(Context context, Intent intent, AtomicBoolean abort) { this.abort = abort; onReceive(context, intent); // If the underlying receiver has called goAsync(), we should not finish the pending result yet - they'll do that // for us. if (receiver.getPendingResult() != null) { receiver.getPendingResult().finish(); } } }
@Test public void shouldReceiveIntentInIdleMode() { // given preparePowerManagerMocks(Boolean.TRUE, Boolean.FALSE); BroadcastReceiver broadcastReceiver = strategy.createIdleBroadcastReceiver(); // when broadcastReceiver.onReceive(contextMock, intent); // then verify(strategy).onNext(any(Connectivity.class)); }