Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mobile: Go based replacement for MKAsyncTask #347

Merged
merged 45 commits into from
Feb 18, 2020
Merged

Conversation

bassosimone
Copy link
Contributor

@bassosimone bassosimone commented Feb 18, 2020

This PR introduces a new API in ./mobile/oonimkall. This API satisfies the requirements described by #339 and, hence, closes #339. It is called oonimkall because it's a OONI reimplementation of the mkall API implemented at https://github.com/measurement-kit/mkall-ios and at https://github.com/measurement-kit/android-libs. This reimplementation just focuses on the AsyncTask class in such MK API, which is the one allowing to run experiments.

In the PRs that prepared this PR we have already seen that we've now the possibility of generating a probe-engine library that does not link MK. This allows OONI to use MK as before and to add, on the side, probe-engine, incrementally delegating more functionality to it.

Such new new API is as follows:

package oonimkall // import "github.com/ooni/probe-engine/mobile/oonimkall"
type Task struct{ ... }
  func StartTask(input string) (*Task, error)
  func (t *Task) Interrupt()
  func (t *Task) IsDone() bool
  func (t *Task) WaitForNextEvent() string

Passing this API to gomobile bind yields the following:

public abstract class Oonimkall {
  public static native Task startTask(String input) throws Exception;
}

public final class Task implements Seq.Proxy {
  public native void interrupt();
  public native boolean isDone();
  public native String waitForNextEvent();
}

Whereas https://github.com/measurement-kit/android-libs is:

public class MKAsyncTask {
  public static MKAsyncTask start(String settings); // throws RuntimeException
  public boolean isDone();
  public String waitForNextEvent();
  public void interrupt();
}

The result is close enough. Perhaps, we should adjust https://github.com/measurement-kit/android-libs to throw explicitly Exception rather than throwing RuntimeException implicitly.

The new code is fully tested but the tests do not stress all we care about. There is a bunch of places in which we could improve, by making sure we emit the right events in sequence.

We also extended the example experiment to help with writing tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mobile: Go based replacement for MKAsyncTask
1 participant