Add runInBackground Interface method
Summary: Add support for plugins to opt in to background for android. This diff does the following - Adds a method `runInBackground` in java interface of `FlipperPlugin` - Make the network plugin opt in to run in background Reviewed By: danielbuechele Differential Revision: D10360033 fbshipit-source-id: b31c7550d00b760b7033c150232e3925b6272d24
This commit is contained in:
committed by
Facebook Github Bot
parent
e58961e184
commit
14e38c087f
@@ -198,6 +198,11 @@ class JFlipperPlugin : public jni::JavaClass<JFlipperPlugin> {
|
|||||||
static const auto method = javaClassStatic()->getMethod<void()>("onDisconnect");
|
static const auto method = javaClassStatic()->getMethod<void()>("onDisconnect");
|
||||||
method(self());
|
method(self());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool runInBackground() {
|
||||||
|
static const auto method = javaClassStatic()->getMethod<jboolean()>("runInBackground");
|
||||||
|
return method(self()) == JNI_TRUE;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class JFlipperStateUpdateListener : public jni::JavaClass<JFlipperStateUpdateListener> {
|
class JFlipperStateUpdateListener : public jni::JavaClass<JFlipperStateUpdateListener> {
|
||||||
@@ -247,6 +252,10 @@ class JFlipperPluginWrapper : public FlipperPlugin {
|
|||||||
jplugin->didDisconnect();
|
jplugin->didDisconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool runInBackground() override {
|
||||||
|
return jplugin->runInBackground();
|
||||||
|
}
|
||||||
|
|
||||||
JFlipperPluginWrapper(jni::global_ref<JFlipperPlugin> plugin): jplugin(plugin) {}
|
JFlipperPluginWrapper(jni::global_ref<JFlipperPlugin> plugin): jplugin(plugin) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -34,4 +34,9 @@ public interface FlipperPlugin {
|
|||||||
* longer valid. Do not try to use the connection in or after this method has been called.
|
* longer valid. Do not try to use the connection in or after this method has been called.
|
||||||
*/
|
*/
|
||||||
void onDisconnect() throws Exception;
|
void onDisconnect() throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns true if the plugin is meant to be run in background too, otherwise it returns false.
|
||||||
|
*/
|
||||||
|
boolean runInBackground();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ public abstract class BufferingFlipperPlugin implements FlipperPlugin {
|
|||||||
mConnection = null;
|
mConnection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean runInBackground() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized FlipperConnection getConnection() {
|
public synchronized FlipperConnection getConnection() {
|
||||||
return mConnection;
|
return mConnection;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,4 +31,9 @@ public class ConsoleFlipperPlugin implements FlipperPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onDisconnect() throws Exception {}
|
public void onDisconnect() throws Exception {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean runInBackground() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,6 +171,11 @@ public class InspectorFlipperPlugin implements FlipperPlugin {
|
|||||||
mConnection = null;
|
mConnection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean runInBackground() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final FlipperReceiver mShouldShowLithoAccessibilitySettings =
|
final FlipperReceiver mShouldShowLithoAccessibilitySettings =
|
||||||
new MainThreadFlipperReceiver(mConnection) {
|
new MainThreadFlipperReceiver(mConnection) {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ public class LeakCanaryFlipperPlugin implements FlipperPlugin {
|
|||||||
mConnection = null;
|
mConnection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean runInBackground() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void sendLeakList() {
|
private void sendLeakList() {
|
||||||
if (mConnection != null) {
|
if (mConnection != null) {
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
|
|||||||
@@ -68,4 +68,9 @@ public class SandboxFlipperPlugin implements FlipperPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisconnect() {}
|
public void onDisconnect() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean runInBackground() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,6 +200,11 @@ public class SharedPreferencesFlipperPlugin implements FlipperPlugin {
|
|||||||
mConnection = null;
|
mConnection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean runInBackground() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static class SharedPreferencesDescriptor {
|
public static class SharedPreferencesDescriptor {
|
||||||
public final String name;
|
public final String name;
|
||||||
public final int mode;
|
public final int mode;
|
||||||
|
|||||||
Reference in New Issue
Block a user