Add state tracking plumbing

Summary:
The plan is to get SonarState to take update events and aggregate them into an object, that can be displayed in the UI so you can see what sonar is currently trying to do, and what if anything is failing.
This is pretty rubbish right now, as it just uses a single string to represent state, this is just the initial version I'll iterate on.
I also need to pass the SonarState into the SonarWebSocketImpl, since that's where a lot of the heavy lifting is done, but as long as something is logging state updates here, it proves the concept.
SonarStateUpdateListener is the interface that will be implemented by android and iOS implementations. These implementations will notify an activity or screen that the state has changed and they should reflect that.

Reviewed By: passy

Differential Revision: D8932114

fbshipit-source-id: fb03babfe92be53771eb4d8f10de7ecdc7f1a6d8
This commit is contained in:
John Knox
2018-08-03 07:34:32 -07:00
committed by Facebook Github Bot
parent 3d66b1c9d0
commit fb447e4f84
11 changed files with 259 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ import com.facebook.soloader.SoLoader;
import com.facebook.sonar.BuildConfig;
import com.facebook.sonar.core.SonarClient;
import com.facebook.sonar.core.SonarPlugin;
import com.facebook.sonar.core.SonarStateUpdateListener;
@DoNotStrip
class SonarClientImpl implements SonarClient {
@@ -55,4 +56,13 @@ class SonarClientImpl implements SonarClient {
@Override
public native void stop();
@Override
public native void subscribeForUpdates(SonarStateUpdateListener stateListener);
@Override
public native void unsubscribe();
@Override
public native String getState();
}

View File

@@ -17,4 +17,10 @@ public interface SonarClient {
void start();
void stop();
void subscribeForUpdates(SonarStateUpdateListener stateListener);
void unsubscribe();
String getState();
}

View File

@@ -0,0 +1,7 @@
package com.facebook.sonar.core;
public interface SonarStateUpdateListener {
void onUpdate();
}