Add a standalone SkyShell.apk for testing
This CL adds a SkyShell.apk, which will become a direct embedding of Sky on Android that will let us run performance tests on the Sky engine in a self-contained environment on a real device. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/893643002
This commit is contained in:
@@ -18,6 +18,11 @@ group("sky") {
|
||||
"//sky/tools/tester",
|
||||
"//sky/viewer",
|
||||
]
|
||||
|
||||
if (is_android) {
|
||||
deps += [ "//sky/shell" ]
|
||||
}
|
||||
|
||||
if (!is_android) {
|
||||
deps += [ "//third_party/mesa:osmesa" ]
|
||||
}
|
||||
|
||||
69
engine/src/flutter/shell/BUILD.gn
Normal file
69
engine/src/flutter/shell/BUILD.gn
Normal file
@@ -0,0 +1,69 @@
|
||||
# Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
assert(is_android)
|
||||
|
||||
import("//build/config/android/config.gni")
|
||||
import("//build/config/android/rules.gni")
|
||||
|
||||
group("shell") {
|
||||
deps = [
|
||||
":sky_shell_apk",
|
||||
]
|
||||
}
|
||||
|
||||
generate_jni("jni_headers") {
|
||||
sources = [
|
||||
"apk/src/org/domokit/sky/shell/SkyMain.java",
|
||||
]
|
||||
jni_package = "sky/shell"
|
||||
}
|
||||
|
||||
shared_library("sky_shell") {
|
||||
sources = [
|
||||
"library_loader.cc",
|
||||
"sky_main.cc",
|
||||
"sky_main.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base",
|
||||
"//build/config/sanitizers:deps",
|
||||
"//ui/gl",
|
||||
":jni_headers",
|
||||
]
|
||||
}
|
||||
|
||||
android_library("java") {
|
||||
java_files = [
|
||||
"apk/src/org/domokit/sky/shell/SkyMain.java",
|
||||
"apk/src/org/domokit/sky/shell/SkyShellActivity.java",
|
||||
"apk/src/org/domokit/sky/shell/SkyShellApplication.java",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base:base_java",
|
||||
]
|
||||
}
|
||||
|
||||
android_resources("resources") {
|
||||
resource_dirs = [ "apk/res" ]
|
||||
custom_package = "org.domokit.sky.shell"
|
||||
}
|
||||
|
||||
android_apk("sky_shell_apk") {
|
||||
apk_name = "SkyShell"
|
||||
|
||||
android_manifest = "apk/AndroidManifest.xml"
|
||||
native_libs = [ "libsky_shell.so" ]
|
||||
|
||||
asset_location = "apk/res"
|
||||
|
||||
deps = [
|
||||
":sky_shell",
|
||||
":java",
|
||||
":resources",
|
||||
"//base:base_java",
|
||||
]
|
||||
}
|
||||
24
engine/src/flutter/shell/apk/AndroidManifest.xml
Normal file
24
engine/src/flutter/shell/apk/AndroidManifest.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.domokit.sky.shell">
|
||||
|
||||
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<application android:name="SkyShellApplication" android:label="Sky">
|
||||
<activity android:name="SkyShellActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@android:style/Theme.Holo.Light.NoActionBar"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize"
|
||||
android:hardwareAccelerated="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
7
engine/src/flutter/shell/apk/res/values/strings.xml
Normal file
7
engine/src/flutter/shell/apk/res/values/strings.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<resources>
|
||||
</resources>
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright 2013 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.domokit.sky.shell;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import org.chromium.base.JNINamespace;
|
||||
|
||||
/**
|
||||
* A class to intialize the native code.
|
||||
**/
|
||||
@JNINamespace("sky::shell")
|
||||
public class SkyMain {
|
||||
private static final String TAG = "SkyMain";
|
||||
|
||||
/**
|
||||
* A guard flag for calling nativeInit() only once.
|
||||
**/
|
||||
private static boolean sInitialized = false;
|
||||
|
||||
/**
|
||||
* Initializes the native system.
|
||||
**/
|
||||
static void ensureInitialized(Context applicationContext) {
|
||||
if (sInitialized)
|
||||
return;
|
||||
try {
|
||||
nativeInit(applicationContext);
|
||||
sInitialized = true;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "SkyMain initialization failed.", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the specified application in the specified context.
|
||||
*
|
||||
* @return <code>true</code> if an application has been launched.
|
||||
**/
|
||||
static boolean start() {
|
||||
return nativeStart();
|
||||
}
|
||||
|
||||
private static native void nativeInit(Context context);
|
||||
private static native boolean nativeStart();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.domokit.sky.shell;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* Main activity for SkyShell.
|
||||
*/
|
||||
public class SkyShellActivity extends Activity {
|
||||
/**
|
||||
* @see android.app.Activity#onCreate(android.os.Bundle)
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
SkyMain.ensureInitialized(this);
|
||||
SkyMain.start();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.domokit.sky.shell;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.chromium.base.BaseChromiumApplication;
|
||||
import org.chromium.base.PathUtils;
|
||||
import org.chromium.base.library_loader.LibraryLoader;
|
||||
import org.chromium.base.library_loader.ProcessInitException;
|
||||
|
||||
/**
|
||||
* MojoShell implementation of {@link android.app.Application}, managing application-level global
|
||||
* state and initializations.
|
||||
*/
|
||||
public class SkyShellApplication extends BaseChromiumApplication {
|
||||
private static final String TAG = "SkyShellApplication";
|
||||
private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "sky_shell";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
initializeJavaUtils();
|
||||
initializeNative();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes Java-side utils.
|
||||
*/
|
||||
private void initializeJavaUtils() {
|
||||
PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the native library.
|
||||
*/
|
||||
private void initializeNative() {
|
||||
try {
|
||||
LibraryLoader.ensureInitialized();
|
||||
} catch (ProcessInitException e) {
|
||||
Log.e(TAG, "sky_shell initialization failed.", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
40
engine/src/flutter/shell/library_loader.cc
Normal file
40
engine/src/flutter/shell/library_loader.cc
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/android/base_jni_registrar.h"
|
||||
#include "base/android/jni_android.h"
|
||||
#include "base/android/jni_registrar.h"
|
||||
#include "base/android/library_loader/library_loader_hooks.h"
|
||||
#include "base/logging.h"
|
||||
#include "sky/shell/sky_main.h"
|
||||
|
||||
namespace {
|
||||
|
||||
base::android::RegistrationMethod kSkyRegisteredMethods[] = {
|
||||
{"SkyMain", sky::shell::RegisterSkyMain},
|
||||
};
|
||||
|
||||
bool RegisterMojoJni(JNIEnv* env) {
|
||||
return RegisterNativeMethods(env, kSkyRegisteredMethods,
|
||||
arraysize(kSkyRegisteredMethods));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// This is called by the VM when the shared library is first loaded.
|
||||
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
base::android::InitVM(vm);
|
||||
JNIEnv* env = base::android::AttachCurrentThread();
|
||||
|
||||
if (!base::android::RegisterLibraryLoaderEntryHook(env))
|
||||
return -1;
|
||||
|
||||
if (!base::android::RegisterJni(env))
|
||||
return -1;
|
||||
|
||||
if (!RegisterMojoJni(env))
|
||||
return -1;
|
||||
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
73
engine/src/flutter/shell/sky_main.cc
Normal file
73
engine/src/flutter/shell/sky_main.cc
Normal file
@@ -0,0 +1,73 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "sky/shell/sky_main.h"
|
||||
|
||||
#include "base/android/jni_android.h"
|
||||
#include "base/android/jni_array.h"
|
||||
#include "base/android/jni_string.h"
|
||||
#include "base/at_exit.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/threading/simple_thread.h"
|
||||
#include "jni/SkyMain_jni.h"
|
||||
|
||||
using base::LazyInstance;
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
namespace {
|
||||
|
||||
LazyInstance<scoped_ptr<base::MessageLoop>> g_java_message_loop =
|
||||
LAZY_INSTANCE_INITIALIZER;
|
||||
|
||||
LazyInstance<base::android::ScopedJavaGlobalRef<jobject>> g_main_activiy =
|
||||
LAZY_INSTANCE_INITIALIZER;
|
||||
|
||||
void InitializeLogging() {
|
||||
logging::LoggingSettings settings;
|
||||
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
|
||||
logging::InitLogging(settings);
|
||||
// To view log output with IDs and timestamps use "adb logcat -v threadtime".
|
||||
logging::SetLogItems(false, // Process ID
|
||||
false, // Thread ID
|
||||
false, // Timestamp
|
||||
false); // Tick count
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
static void Init(JNIEnv* env,
|
||||
jclass clazz,
|
||||
jobject activity) {
|
||||
g_main_activiy.Get().Reset(env, activity);
|
||||
|
||||
base::android::ScopedJavaLocalRef<jobject> scoped_activity(env, activity);
|
||||
base::android::InitApplicationContext(env, scoped_activity);
|
||||
|
||||
base::CommandLine::Init(0, nullptr);
|
||||
|
||||
InitializeLogging();
|
||||
|
||||
g_java_message_loop.Get().reset(new base::MessageLoopForUI);
|
||||
base::MessageLoopForUI::current()->Start();
|
||||
}
|
||||
|
||||
static jboolean Start(JNIEnv* env, jclass clazz) {
|
||||
LOG(INFO) << "Native code started!";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RegisterSkyMain(JNIEnv* env) {
|
||||
return RegisterNativesImpl(env);
|
||||
}
|
||||
|
||||
} // namespace sky
|
||||
} // namespace mojo
|
||||
18
engine/src/flutter/shell/sky_main.h
Normal file
18
engine/src/flutter/shell/sky_main.h
Normal file
@@ -0,0 +1,18 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SKY_SHELL_SKY_MAIN_H_
|
||||
#define SKY_SHELL_SKY_MAIN_H_
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
bool RegisterSkyMain(JNIEnv* env);
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
|
||||
#endif // SKY_SHELL_SKY_MAIN_H_
|
||||
Reference in New Issue
Block a user