Skip to content

Commit

Permalink
Remove some unused code from the Android host (flutter#5619)
Browse files Browse the repository at this point in the history
These functions were made obsolete by the engine refactoring
(flutter@6baff4c)
  • Loading branch information
jason-simmons authored Jun 27, 2018
1 parent 36f3f95 commit fbb3436
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 163 deletions.
17 changes: 0 additions & 17 deletions shell/platform/android/android_shell_holder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 0 additions & 23 deletions shell/platform/android/io/flutter/view/FlutterNativeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,10 @@ public void runFromBundle(String bundlePath, String snapshotOverride, String ent
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();
}
Expand Down Expand Up @@ -216,14 +201,6 @@ private static native void nativeRunBundleAndSnapshot(long nativePlatformViewAnd
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.
Expand Down
49 changes: 0 additions & 49 deletions shell/platform/android/io/flutter/view/FlutterView.java
Original file line number Diff line number Diff line change
Expand Up @@ -646,55 +646,6 @@ public void runFromBundle(String bundlePath, String snapshotOverride, String ent
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.
*
Expand Down
74 changes: 0 additions & 74 deletions shell/platform/android/platform_view_android_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit fbb3436

Please sign in to comment.