提交 26863b09 编写于 作者: A Adam Barth

Add a --checked argument to sky_tool start

The --checked argument runs SkyShell in checked mode, which turns on type
checking and asserts.
上级 1bc102e5
......@@ -127,6 +127,7 @@ class StartSky(object):
help='launch %s on the device' % APK_NAME)
start_parser.add_argument('--install', action='store_true')
start_parser.add_argument('--poke', action='store_true')
start_parser.add_argument('--checked', action='store_true')
start_parser.add_argument('project_or_path', nargs='?', type=str,
default='.')
start_parser.set_defaults(func=self.run)
......@@ -212,11 +213,19 @@ class StartSky(object):
if args.poke:
url += '?rand=%s' % random.random()
subprocess.check_call([ADB_PATH, 'shell',
cmd = [
ADB_PATH, 'shell',
'am', 'start',
'-a', 'android.intent.action.VIEW',
'-d', url,
ANDROID_COMPONENT])
]
if args.checked:
cmd += [ '--ez', 'enable-checked-mode', 'true' ]
cmd += [ ANDROID_COMPONENT ]
print cmd
subprocess.check_call(cmd)
class StopSky(object):
......
......@@ -26,6 +26,17 @@ public class SkyActivity extends Activity {
private TracingController mTracingController;
private PlatformViewAndroid mView;
private String[] getArgsFromIntent(Intent intent) {
// Before adding more entries to this list, consider that arbitrary
// Android applications can generate intents with extra data and that
// there are many security-sensitive args in the binary.
if (intent.getBooleanExtra("enable-checked-mode", false)) {
String[] args = { "--enable-checked-mode"};
return args;
}
return null;
}
/**
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
......@@ -47,7 +58,8 @@ public class SkyActivity extends Activity {
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
SkyMain.ensureInitialized(getApplicationContext());
String[] args = getArgsFromIntent(getIntent());
SkyMain.ensureInitialized(getApplicationContext(), args);
mView = new PlatformViewAndroid(this, edgeDims);
ActivityImpl.setCurrentActivity(this);
setContentView(mView);
......
......@@ -25,14 +25,14 @@ public class SkyMain {
/**
* Initializes the native system.
**/
public static void ensureInitialized(Context applicationContext) {
public static void ensureInitialized(Context applicationContext, String[] args) {
if (sInitialized) {
return;
}
try {
SkyApplication app = (SkyApplication) applicationContext;
app.getResourceExtractor().waitForCompletion();
nativeInit(applicationContext);
nativeInit(applicationContext, args);
// Create the mojo run loop.
CoreImpl.getInstance().createDefaultRunLoop();
sInitialized = true;
......@@ -42,5 +42,5 @@ public class SkyMain {
}
}
private static native void nativeInit(Context context);
private static native void nativeInit(Context context, String[] args);
}
......@@ -43,11 +43,20 @@ void InitializeLogging() {
} // namespace
static void Init(JNIEnv* env, jclass clazz, jobject context) {
static void Init(JNIEnv* env,
jclass clazz,
jobject context,
jobjectArray jargs) {
base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context);
base::android::InitApplicationContext(env, scoped_context);
std::vector<std::string> args;
args.push_back("sky_shell");
base::android::AppendJavaStringArrayToStringVector(env, jargs, &args);
base::CommandLine::Init(0, nullptr);
base::CommandLine::ForCurrentProcess()->InitFromArgv(args);
InitializeLogging();
g_java_message_loop.Get().reset(new base::MessageLoopForUI);
......
......@@ -87,13 +87,13 @@ base::WeakPtr<Engine> Engine::GetWeakPtr() {
void Engine::Init() {
TRACE_EVENT0("sky", "Engine::Init");
DCHECK(!g_platform_impl);
g_platform_impl = new PlatformImpl();
blink::initialize(g_platform_impl);
base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
blink::WebRuntimeFeatures::enableDartCheckedMode(
command_line.HasSwitch(switches::kEnableCheckedMode));
DCHECK(!g_platform_impl);
g_platform_impl = new PlatformImpl();
blink::initialize(g_platform_impl);
}
void Engine::BeginFrame(base::TimeTicks frame_time) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册