OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.mojo.shell; |
| 6 |
| 7 import android.content.Context; |
| 8 |
| 9 import org.chromium.base.JNINamespace; |
| 10 |
| 11 import java.io.File; |
| 12 |
| 13 /** |
| 14 * Runnable used to bootstrap execution of Android Mojo application. For the JNI
to work, we need a |
| 15 * Java class with the application classloader in the call stack. We load this c
lass in the |
| 16 * application classloader and call into native from it to achieve that. |
| 17 */ |
| 18 @JNINamespace("mojo::shell") |
| 19 public class Bootstrap implements Runnable { |
| 20 private final Context mContext; |
| 21 private final File mBootstrapNativeLibrary; |
| 22 private final File mApplicationNativeLibrary; |
| 23 private final int mHandle; |
| 24 private final long mRunApplicationPtr; |
| 25 |
| 26 public Bootstrap(Context context, File bootstrapNativeLibrary, File applicat
ionNativeLibrary, |
| 27 Integer handle, Long runApplicationPtr) { |
| 28 mContext = context; |
| 29 mBootstrapNativeLibrary = bootstrapNativeLibrary; |
| 30 mApplicationNativeLibrary = applicationNativeLibrary; |
| 31 mHandle = handle; |
| 32 mRunApplicationPtr = runApplicationPtr; |
| 33 } |
| 34 |
| 35 @Override |
| 36 public void run() { |
| 37 System.load(mBootstrapNativeLibrary.getAbsolutePath()); |
| 38 System.load(mApplicationNativeLibrary.getAbsolutePath()); |
| 39 nativeBootstrap(mContext, mApplicationNativeLibrary.getAbsolutePath(), m
Handle, |
| 40 mRunApplicationPtr); |
| 41 } |
| 42 |
| 43 native void nativeBootstrap(Context context, String libraryPath, int handle, |
| 44 long runApplicationPtr); |
| 45 } |
OLD | NEW |