From e54b0e286ba7e07dcc32d12d8c68f6ca45cdbdf7 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Tue, 1 Nov 2016 17:11:56 -0700 Subject: [PATCH] Roll Dart (#3194) Update DartServiceIsolate/FlutterView because VMServiceIO_NotifyServerState now provides a URI for the observatory --- DEPS | 2 +- runtime/dart_service_isolate.cc | 12 ++++++------ runtime/dart_service_isolate.h | 2 +- .../android/io/flutter/view/FlutterView.java | 6 ++++-- shell/platform/android/platform_view_android.cc | 5 +++-- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/DEPS b/DEPS index 6b76d67750e..cbd0519cbb5 100644 --- a/DEPS +++ b/DEPS @@ -27,7 +27,7 @@ vars = { # Note: When updating the Dart revision, ensure that all entries that are # dependencies of dart are also updated - 'dart_revision': '9f0e4e1162298625c2d90213076c3dcac4dc41a5', + 'dart_revision': '823bb1a0a2f0cd6d41b9150be3ae89771257a31c', 'dart_boringssl_gen_revision': '62c20247d582444cb2804f9ea4e3abaa6e47f6a5', 'dart_boringssl_revision': '8d343b44bbab829d1a28fdef650ca95f7db4412e', 'dart_observatory_packages_revision': '26aad88f1c1915d39bbcbff3cad589e2402fdcf1', diff --git a/runtime/dart_service_isolate.cc b/runtime/dart_service_isolate.cc index 1dd8498446a..8d1300c1e8f 100644 --- a/runtime/dart_service_isolate.cc +++ b/runtime/dart_service_isolate.cc @@ -41,7 +41,7 @@ namespace { static Dart_LibraryTagHandler g_embedder_tag_handler; static tonic::DartLibraryNatives* g_natives; static EmbedderResources* g_resources; -static int observatory_port_; +static std::string observatory_uri_; Dart_NativeFunction GetNativeFunction(Dart_Handle name, int argument_count, @@ -66,14 +66,14 @@ void DartServiceIsolate::TriggerResourceLoad(Dart_NativeArguments args) { void DartServiceIsolate::NotifyServerState(Dart_NativeArguments args) { Dart_Handle exception = nullptr; - int port = tonic::DartConverter::FromArguments(args, 1, exception); + std::string uri = tonic::DartConverter::FromArguments(args, 0, exception); if (!exception) { - observatory_port_ = port; + observatory_uri_ = uri; } } -int DartServiceIsolate::GetObservatoryPort() { - return observatory_port_; +std::string DartServiceIsolate::GetObservatoryUri() { + return observatory_uri_; } void DartServiceIsolate::Shutdown(Dart_NativeArguments args) { @@ -97,7 +97,7 @@ bool DartServiceIsolate::Startup(std::string server_ip, if (!g_natives) { g_natives = new tonic::DartLibraryNatives(); g_natives->Register({ - {"VMServiceIO_NotifyServerState", NotifyServerState, 2, true}, + {"VMServiceIO_NotifyServerState", NotifyServerState, 1, true}, {"VMServiceIO_Shutdown", Shutdown, 0, true}, }); } diff --git a/runtime/dart_service_isolate.h b/runtime/dart_service_isolate.h index aeaaba292e8..b820ab64871 100644 --- a/runtime/dart_service_isolate.h +++ b/runtime/dart_service_isolate.h @@ -22,7 +22,7 @@ class DartServiceIsolate { bool disable_origin_check, char** error); - static int GetObservatoryPort(); + static std::string GetObservatoryUri(); private: // Native entries. diff --git a/shell/platform/android/io/flutter/view/FlutterView.java b/shell/platform/android/io/flutter/view/FlutterView.java index 6df396e52e8..fe8055dc1b4 100644 --- a/shell/platform/android/io/flutter/view/FlutterView.java +++ b/shell/platform/android/io/flutter/view/FlutterView.java @@ -37,6 +37,7 @@ import org.json.JSONObject; import org.chromium.base.CalledByNative; import org.chromium.base.JNINamespace; +import java.net.URI; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; @@ -492,7 +493,7 @@ public class FlutterView extends SurfaceView } private static native long nativeAttach(FlutterView view); - private static native int nativeGetObservatoryPort(); + private static native String nativeGetObservatoryUri(); private static native void nativeDetach(long nativePlatformViewAndroid); private static native void nativeSurfaceCreated(long nativePlatformViewAndroid, Surface surface, @@ -758,10 +759,11 @@ public class FlutterView extends SurfaceView private class DiscoveryReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + URI observatoryUri = URI.create(nativeGetObservatoryUri()); JSONObject discover = new JSONObject(); try { discover.put("id", getContext().getPackageName()); - discover.put("observatoryPort", nativeGetObservatoryPort()); + discover.put("observatoryPort", observatoryUri.getPort()); Log.i(TAG, "DISCOVER: " + discover); } catch (JSONException e) {} } diff --git a/shell/platform/android/platform_view_android.cc b/shell/platform/android/platform_view_android.cc index 1b0a8bc47ef..56936353e1d 100644 --- a/shell/platform/android/platform_view_android.cc +++ b/shell/platform/android/platform_view_android.cc @@ -521,8 +521,9 @@ void PlatformViewAndroid::GetBitmapGpuTask(ftl::AutoResetWaitableEvent* latch, latch->Signal(); } -jint GetObservatoryPort(JNIEnv* env, jclass clazz) { - return blink::DartServiceIsolate::GetObservatoryPort(); +jstring GetObservatoryUri(JNIEnv* env, jclass clazz) { + return env->NewStringUTF( + blink::DartServiceIsolate::GetObservatoryUri().c_str()); } bool PlatformViewAndroid::Register(JNIEnv* env) {