protected boolean bindService( final Intent intent, final ServiceConnection serviceConnection, int i) { boundServiceConnections.add(serviceConnection); unboundServiceConnections.remove(serviceConnection); if (unbindableActions.contains(intent.getAction())) { return false; } startedServices.add(new Intent.FilterComparison(intent)); ShadowLooper shadowLooper = Shadow.extract(Looper.getMainLooper()); shadowLooper.post( () -> { final ServiceConnectionDataWrapper serviceConnectionDataWrapper; final Intent.FilterComparison filterComparison = new Intent.FilterComparison(intent); if (serviceConnectionDataForIntent.containsKey(filterComparison)) { serviceConnectionDataWrapper = serviceConnectionDataForIntent.get(filterComparison); } else { serviceConnectionDataWrapper = defaultServiceConnectionData; } serviceConnectionDataForServiceConnection.put( serviceConnection, serviceConnectionDataWrapper); serviceConnection.onServiceConnected( serviceConnectionDataWrapper.componentNameForBindService, serviceConnectionDataWrapper.binderForBindService); }, 0); return true; }
/** * Returns the most recent {@code Intent} started by {@link #startService(android.content.Intent)} * without consuming it. * * @return the most recently started {@code Intent} */ Intent peekNextStartedService() { if (startedServices.isEmpty()) { return null; } else { return startedServices.get(0).getIntent(); } }
protected boolean bindService( final Intent intent, final ServiceConnection serviceConnection, int i) { boundServiceConnections.add(serviceConnection); unboundServiceConnections.remove(serviceConnection); if (unbindableActions.contains(intent.getAction())) { return false; } startedServices.add(new Intent.FilterComparison(intent)); ShadowLooper shadowLooper = Shadow.extract(Looper.getMainLooper()); shadowLooper.post( () -> { final ServiceConnectionDataWrapper serviceConnectionDataWrapper; final Intent.FilterComparison filterComparison = new Intent.FilterComparison(intent); if (serviceConnectionDataForIntent.containsKey(filterComparison)) { serviceConnectionDataWrapper = serviceConnectionDataForIntent.get(filterComparison); } else { serviceConnectionDataWrapper = defaultServiceConnectionData; } serviceConnectionDataForServiceConnection.put( serviceConnection, serviceConnectionDataWrapper); serviceConnection.onServiceConnected( serviceConnectionDataWrapper.componentNameForBindService, serviceConnectionDataWrapper.binderForBindService); }, 0); return true; }
@Implementation public boolean bindService(final Intent intent, final ServiceConnection serviceConnection, int i) { boundServiceConnections.add(serviceConnection); unboundServiceConnections.remove(serviceConnection); if (unbindableActions.contains(intent.getAction())) { return false; } startedServices.add(new Intent.FilterComparison(intent)); shadowOf(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { final ServiceConnectionDataWrapper serviceConnectionDataWrapper; final Intent.FilterComparison filterComparison = new Intent.FilterComparison(intent); if (serviceConnectionDataForIntent.containsKey(filterComparison)) { serviceConnectionDataWrapper = serviceConnectionDataForIntent.get(filterComparison); } else { serviceConnectionDataWrapper = defaultServiceConnectionData; } serviceConnectionDataForServiceConnection.put(serviceConnection, serviceConnectionDataWrapper); serviceConnection.onServiceConnected(serviceConnectionDataWrapper.componentNameForBindService, serviceConnectionDataWrapper.binderForBindService); } }, 0); return true; }
@Implementation public boolean bindService(final Intent intent, final ServiceConnection serviceConnection, int i) { boundServiceConnections.add(serviceConnection); unboundServiceConnections.remove(serviceConnection); if (unbindableActions.contains(intent.getAction())) { return false; } startedServices.add(new Intent.FilterComparison(intent)); shadowOf(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { final ServiceConnectionDataWrapper serviceConnectionDataWrapper; final Intent.FilterComparison filterComparison = new Intent.FilterComparison(intent); if (serviceConnectionDataForIntent.containsKey(filterComparison)) { serviceConnectionDataWrapper = serviceConnectionDataForIntent.get(filterComparison); } else { serviceConnectionDataWrapper = defaultServiceConnectionData; } serviceConnectionDataForServiceConnection.put(serviceConnection, serviceConnectionDataWrapper); serviceConnection.onServiceConnected(serviceConnectionDataWrapper.componentNameForBindService, serviceConnectionDataWrapper.binderForBindService); } }, 0); return true; }
@Implementation public boolean bindService(final Intent intent, final ServiceConnection serviceConnection, int i) { boundServiceConnections.add(serviceConnection); unboundServiceConnections.remove(serviceConnection); if (unbindableActions.contains(intent.getAction())) { return false; } startedServices.add(new Intent.FilterComparison(intent)); shadowOf(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { final ServiceConnectionDataWrapper serviceConnectionDataWrapper; final Intent.FilterComparison filterComparison = new Intent.FilterComparison(intent); if (serviceConnectionDataForIntent.containsKey(filterComparison)) { serviceConnectionDataWrapper = serviceConnectionDataForIntent.get(filterComparison); } else { serviceConnectionDataWrapper = defaultServiceConnectionData; } serviceConnectionDataForServiceConnection.put(serviceConnection, serviceConnectionDataWrapper); serviceConnection.onServiceConnected(serviceConnectionDataWrapper.componentNameForBindService, serviceConnectionDataWrapper.binderForBindService); } }, 0); return true; }
/** * Returns the most recent {@code Intent} started by {@link #startService(android.content.Intent)} without * consuming it. * * @return the most recently started {@code Intent} */ @Override public Intent peekNextStartedService() { if (startedServices.isEmpty()) { return null; } else { return startedServices.get(0).getIntent(); } }
@Override public void run() { final ServiceConnectionDataWrapper serviceConnectionDataWrapper; final Intent.FilterComparison filterComparison = new Intent.FilterComparison(intent); if (serviceConnectionDataForIntent.containsKey(filterComparison)) { serviceConnectionDataWrapper = serviceConnectionDataForIntent.get(filterComparison); } else { serviceConnectionDataWrapper = defaultServiceConnectionData; } serviceConnectionDataForServiceConnection.put(serviceConnection, serviceConnectionDataWrapper); serviceConnection.onServiceConnected(serviceConnectionDataWrapper.componentNameForBindService, serviceConnectionDataWrapper.binderForBindService); } }, 0);
public void setComponentNameAndServiceForBindServiceForIntent(Intent intent, ComponentName name, IBinder service) { serviceConnectionDataForIntent.put(new Intent.FilterComparison(intent), new ServiceConnectionDataWrapper(name, service)); }
boolean stopService(Intent name) { stoppedServices.add(new Intent.FilterComparison(name)); return startedServices.contains(new Intent.FilterComparison(name)); }
/** * Returns the most recent {@code Intent} started by {@link #startService(android.content.Intent)} without * consuming it. * * @return the most recently started {@code Intent} */ @Override public Intent peekNextStartedService() { if (startedServices.isEmpty()) { return null; } else { return startedServices.get(0).getIntent(); } }
/** * Returns the most recent {@code Intent} started by {@link #startService(android.content.Intent)} without * consuming it. * * @return the most recently started {@code Intent} */ @Override public Intent peekNextStartedService() { if (startedServices.isEmpty()) { return null; } else { return startedServices.get(0).getIntent(); } }
/** * Returns the most recent {@code Intent} started by {@link #startService(android.content.Intent)} * without consuming it. * * @return the most recently started {@code Intent} */ Intent peekNextStartedService() { if (startedServices.isEmpty()) { return null; } else { return startedServices.get(0).getIntent(); } }
@Override public void run() { final ServiceConnectionDataWrapper serviceConnectionDataWrapper; final Intent.FilterComparison filterComparison = new Intent.FilterComparison(intent); if (serviceConnectionDataForIntent.containsKey(filterComparison)) { serviceConnectionDataWrapper = serviceConnectionDataForIntent.get(filterComparison); } else { serviceConnectionDataWrapper = defaultServiceConnectionData; } serviceConnectionDataForServiceConnection.put(serviceConnection, serviceConnectionDataWrapper); serviceConnection.onServiceConnected(serviceConnectionDataWrapper.componentNameForBindService, serviceConnectionDataWrapper.binderForBindService); } }, 0);
/** * Consumes the most recent {@code Intent} started by {@link #startService(android.content.Intent)} and returns it. * * @return the most recently started {@code Intent} */ @Override public Intent getNextStartedService() { if (startedServices.isEmpty()) { return null; } else { return startedServices.remove(0).getIntent(); } }
public void setComponentNameAndServiceForBindServiceForIntent(Intent intent, ComponentName name, IBinder service) { serviceConnectionDataForIntent.put(new Intent.FilterComparison(intent), new ServiceConnectionDataWrapper(name, service)); }
/** * Consumes the most recent {@code Intent} started by {@link #startService(android.content.Intent)} and returns it. * * @return the most recently started {@code Intent} */ @Override public Intent getNextStartedService() { if (startedServices.isEmpty()) { return null; } else { return startedServices.remove(0).getIntent(); } }
/** * Consumes the most recent {@code Intent} started by {@link * #startService(android.content.Intent)} and returns it. * * @return the most recently started {@code Intent} */ Intent getNextStartedService() { if (startedServices.isEmpty()) { return null; } else { return startedServices.remove(0).getIntent(); } }
@Override public void run() { final ServiceConnectionDataWrapper serviceConnectionDataWrapper; final Intent.FilterComparison filterComparison = new Intent.FilterComparison(intent); if (serviceConnectionDataForIntent.containsKey(filterComparison)) { serviceConnectionDataWrapper = serviceConnectionDataForIntent.get(filterComparison); } else { serviceConnectionDataWrapper = defaultServiceConnectionData; } serviceConnectionDataForServiceConnection.put(serviceConnection, serviceConnectionDataWrapper); serviceConnection.onServiceConnected(serviceConnectionDataWrapper.componentNameForBindService, serviceConnectionDataWrapper.binderForBindService); } }, 0);
/** * Consumes the most recent {@code Intent} started by {@link #startService(android.content.Intent)} and returns it. * * @return the most recently started {@code Intent} */ @Override public Intent getNextStartedService() { if (startedServices.isEmpty()) { return null; } else { return startedServices.remove(0).getIntent(); } }