Remove some unused code from the Android host (flutter/engine#5619)

These functions were made obsolete by the engine refactoring
(077d29581c)
This commit is contained in:
Jason Simmons
2018-06-27 11:06:15 -07:00
committed by GitHub
parent a6253370a7
commit 2d1668246d
4 changed files with 0 additions and 163 deletions

View File

@@ -181,21 +181,4 @@ fml::WeakPtr<PlatformViewAndroid> AndroidShellHolder::GetPlatformView() {
return platform_view_;
}
void AndroidShellHolder::UpdateAssetManager(
fml::RefPtr<blink::AssetManager> 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

View File

@@ -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.

View File

@@ -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.
*

View File

@@ -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<blink::AssetManager>();
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<blink::DirectoryAssetBundle>(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<blink::AssetResolver> directory_asset_bundle =
std::make_unique<blink::DirectoryAssetBundle>(std::move(directory));
if (!directory_asset_bundle->IsValid()) {
return;
}
auto asset_manager = fml::MakeRefCounted<blink::AssetManager>();
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<void*>(&shell::RunBundleAndSnapshot),
},
{
.name = "nativeRunBundleAndSource",
.signature =
"(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
.fnPtr = reinterpret_cast<void*>(&shell::RunBundleAndSource),
},
{
.name = "nativeSetAssetBundlePathOnUI",
.signature = "(JLjava/lang/String;)V",
.fnPtr = reinterpret_cast<void*>(&shell::SetAssetBundlePathOnUI),
},
{
.name = "nativeDetach",
.signature = "(J)V",