From 2d1668246da18e93f09b82bd57f057ff3b24302f Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 27 Jun 2018 11:06:15 -0700 Subject: [PATCH] Remove some unused code from the Android host (flutter/engine#5619) These functions were made obsolete by the engine refactoring (https://github.com/flutter/engine/commit/077d29581c35a08a076c5aeb5186855975756b55) --- .../platform/android/android_shell_holder.cc | 17 ----- .../io/flutter/view/FlutterNativeView.java | 23 ------ .../android/io/flutter/view/FlutterView.java | 49 ------------ .../android/platform_view_android_jni.cc | 74 ------------------- 4 files changed, 163 deletions(-) diff --git a/engine/src/flutter/shell/platform/android/android_shell_holder.cc b/engine/src/flutter/shell/platform/android/android_shell_holder.cc index 2414e018ed..248949535d 100644 --- a/engine/src/flutter/shell/platform/android/android_shell_holder.cc +++ b/engine/src/flutter/shell/platform/android/android_shell_holder.cc @@ -181,21 +181,4 @@ fml::WeakPtr AndroidShellHolder::GetPlatformView() { return platform_view_; } -void AndroidShellHolder::UpdateAssetManager( - fml::RefPtr asset_manager) { - if (!IsValid() || !asset_manager) { - return; - } - - shell_->GetTaskRunners().GetUITaskRunner()->PostTask( - [engine = shell_->GetEngine(), - asset_manager = std::move(asset_manager)]() { - if (engine) { - if (!engine->UpdateAssetManager(std::move(asset_manager))) { - FXL_DLOG(ERROR) << "Could not update asset asset manager."; - } - } - }); -} - } // namespace shell diff --git a/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterNativeView.java b/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterNativeView.java index b9908b5531..3d00312a08 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterNativeView.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterNativeView.java @@ -81,25 +81,10 @@ public class FlutterNativeView implements BinaryMessenger { applicationIsRunning = true; } - public void runFromSource(final String assetsDirectory, final String main, final String packages) { - assertAttached(); - if (applicationIsRunning) - throw new AssertionError("This Flutter engine instance is already running an application"); - - nativeRunBundleAndSource(mNativePlatformView, assetsDirectory, main, packages); - - applicationIsRunning = true; - } - public boolean isApplicationRunning() { return applicationIsRunning; } - public void setAssetBundlePathOnUI(final String assetsDirectory) { - assertAttached(); - nativeSetAssetBundlePathOnUI(mNativePlatformView, assetsDirectory); - } - public static String getObservatoryUri() { return nativeGetObservatoryUri(); } @@ -216,14 +201,6 @@ public class FlutterNativeView implements BinaryMessenger { boolean reuseRuntimeController, AssetManager manager); - private static native void nativeRunBundleAndSource(long nativePlatformViewAndroid, - String bundlePath, - String main, - String packages); - - private static native void nativeSetAssetBundlePathOnUI(long nativePlatformViewAndroid, - String bundlePath); - private static native String nativeGetObservatoryUri(); // Send an empty platform message to Dart. diff --git a/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java b/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java index e80ccc0ab1..8ce1c80e65 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java @@ -646,55 +646,6 @@ public class FlutterView extends SurfaceView postRun(); } - private void runFromSource(final String assetsDirectory, final String main, final String packages) { - Runnable runnable = new Runnable() { - public void run() { - assertAttached(); - preRun(); - mNativeView.runFromSource(assetsDirectory, main, packages); - postRun(); - synchronized (this) { - notify(); - } - } - }; - - try { - synchronized (runnable) { - // Post to the Android UI thread and wait for the response. - post(runnable); - runnable.wait(); - } - } catch (InterruptedException e) { - Log.e(TAG, "Thread got interrupted waiting for " + - "RunFromSourceRunnable to finish", e); - } - } - - private void setAssetBundlePath(final String assetsDirectory) { - Runnable runnable = new Runnable() { - public void run() { - assertAttached(); - mNativeView.setAssetBundlePathOnUI(assetsDirectory); - synchronized (this) { - notify(); - } - } - }; - - try { - synchronized (runnable) { - // Post to the Android UI thread and wait for the response. - post(runnable); - runnable.wait(); - } - } catch (InterruptedException e) { - Log.e(TAG, "Thread got interrupted waiting for " + - "setAssetBundlePath to finish", e); - } - } - - /** * Return the most recent frame as a bitmap. * diff --git a/engine/src/flutter/shell/platform/android/platform_view_android_jni.cc b/engine/src/flutter/shell/platform/android/platform_view_android_jni.cc index 30648d5bd2..7b0f0d7ae1 100644 --- a/engine/src/flutter/shell/platform/android/platform_view_android_jni.cc +++ b/engine/src/flutter/shell/platform/android/platform_view_android_jni.cc @@ -254,69 +254,6 @@ static void RunBundleAndSnapshot( ANDROID_SHELL_HOLDER->Launch(std::move(config)); } -static void RunBundleAndSource(JNIEnv* env, - jobject jcaller, - jlong shell_holder, - jstring jBundlePath, - jstring main, - jstring packages) { - auto asset_manager = fml::MakeRefCounted(); - - const auto bundlepath = fml::jni::JavaStringToString(env, jBundlePath); - - if (bundlepath.size() > 0) { - auto directory = - fml::OpenFile(bundlepath.c_str(), fml::OpenPermission::kRead, true); - asset_manager->PushBack( - std::make_unique(std::move(directory))); - } - - auto main_file_path = fml::jni::JavaStringToString(env, main); - auto packages_file_path = fml::jni::JavaStringToString(env, packages); - - auto config = - IsolateConfiguration::CreateForSource(main_file_path, packages_file_path); - - if (!config) { - return; - } - - RunConfiguration run_configuration(std::move(config), - std::move(asset_manager)); - - ANDROID_SHELL_HOLDER->Launch(std::move(run_configuration)); -} - -void SetAssetBundlePathOnUI(JNIEnv* env, - jobject jcaller, - jlong shell_holder, - jstring jBundlePath) { - const auto bundlepath = fml::jni::JavaStringToString(env, jBundlePath); - - if (bundlepath.size() == 0) { - return; - } - - auto directory = - fml::OpenFile(bundlepath.c_str(), fml::OpenPermission::kRead, true); - - if (!directory.is_valid()) { - return; - } - - std::unique_ptr directory_asset_bundle = - std::make_unique(std::move(directory)); - - if (!directory_asset_bundle->IsValid()) { - return; - } - - auto asset_manager = fml::MakeRefCounted(); - asset_manager->PushBack(std::move(directory_asset_bundle)); - - ANDROID_SHELL_HOLDER->UpdateAssetManager(std::move(asset_manager)); -} - static void SetViewportMetrics(JNIEnv* env, jobject jcaller, jlong shell_holder, @@ -578,17 +515,6 @@ bool PlatformViewAndroid::Register(JNIEnv* env) { "String;ZLandroid/content/res/AssetManager;)V", .fnPtr = reinterpret_cast(&shell::RunBundleAndSnapshot), }, - { - .name = "nativeRunBundleAndSource", - .signature = - "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", - .fnPtr = reinterpret_cast(&shell::RunBundleAndSource), - }, - { - .name = "nativeSetAssetBundlePathOnUI", - .signature = "(JLjava/lang/String;)V", - .fnPtr = reinterpret_cast(&shell::SetAssetBundlePathOnUI), - }, { .name = "nativeDetach", .signature = "(J)V",