static void invokeService(final IBinder binder, final Procedure procedure) {
		final Parcel data = Parcel.obtain(), reply = Parcel.obtain();
		final Class<? extends Procedure> clazz = procedure.getClass();
		data.writeString(clazz.getName());
		final Constructor<?>[] constructors = clazz.getDeclaredConstructors();
		if (constructors.length < 1) throw new IllegalArgumentException("Invalid lambda class: " + clazz);
		final Field[] fields = clazz.getDeclaredFields();
		if (fields.length != constructors[0].getParameterTypes().length)
			throw new IllegalArgumentException("Lambda parameters mismatch: " + Arrays.deepToString(fields));

		final Class<?> enclosing_class = clazz.getEnclosingClass();
		for (final Field field : fields) {
			field.setAccessible(true);
			final Object value;
			try {
				value = field.get(procedure);
			} catch (final IllegalAccessException e) {
				throw new RuntimeException(e);
			}
			// Enclosing class is always carried by anonymous inner class, but useless here.
			final Class<?> type = Objects.requireNonNull(value).getClass();
			if (type == enclosing_class || type == Context.class || type == Application.class) data.writeValue(null);
			else try {
				data.writeValue(value);
			} catch (final RuntimeException e) {
				throw new RuntimeException("Invalid lambda parameter type: " + value.getClass().getCanonicalName(), e);
			}
		}

		try {
			binder.transact(0, data, reply, 0);
		} catch (final RemoteException e) {
			throw new RuntimeException(e);	// Avoid throwing RemoteException everywhere.
		}

		data.recycle();
		final Throwable e = (Throwable) reply.readValue(TestService.class.getClassLoader());
		if (e instanceof Error) throw (Error) e;
		if (e instanceof RuntimeException) throw (RuntimeException) e;
		if (e != null) throw new RuntimeException("Exception thrown by remote procedure", e);
		reply.recycle();
	}
A simple service to mimic the real-world service to be wrapped by {@link com.oasisfeng.condom.CondomProcess CondomProcess}.

Created by Oasis on 2017/10/2.
library/src/androidTest/java/com/oasisfeng/condom/TestService.java