| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chromoting.host.jni; | 5 package org.chromium.chromoting.host.jni; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 | 8 |
| 9 import org.chromium.base.ContextUtils; | 9 import org.chromium.base.ContextUtils; |
| 10 import org.chromium.base.annotations.JNINamespace; | 10 import org.chromium.base.annotations.JNINamespace; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * Class to allow Java code to access the native C++ implementation of the Host
process. This class | 13 * Class to allow Java code to access the native C++ implementation of the Host
process. This class |
| 14 * controls the lifetime of the corresponding C++ object. | 14 * controls the lifetime of the corresponding C++ object. |
| 15 */ | 15 */ |
| 16 @JNINamespace("remoting") | 16 @JNINamespace("remoting") |
| 17 public class Host { | 17 public class Host { |
| 18 // Pointer to the C++ object, cast to a |long|. | 18 // Pointer to the C++ object, cast to a |long|. |
| 19 private long mNativeJniHost; | 19 private long mNativeJniHost; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * To be called once from the Application context singleton. Loads and initi
alizes the native | 22 * To be called once from the Application context singleton. Loads and initi
alizes the native |
| 23 * code. Called on the UI thread. | 23 * code. Called on the UI thread. |
| 24 * @param context The Application context. | 24 * @param context The Application context. |
| 25 */ | 25 */ |
| 26 public static void loadLibrary(Context context) { | 26 public static void loadLibrary(Context context) { |
| 27 ContextUtils.initApplicationContext(context.getApplicationContext()); |
| 27 System.loadLibrary("remoting_host_jni"); | 28 System.loadLibrary("remoting_host_jni"); |
| 28 ContextUtils.initApplicationContext(context); | |
| 29 } | 29 } |
| 30 | 30 |
| 31 public Host() { | 31 public Host() { |
| 32 mNativeJniHost = nativeInit(); | 32 mNativeJniHost = nativeInit(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 private native long nativeInit(); | 35 private native long nativeInit(); |
| 36 | 36 |
| 37 public void destroy() { | 37 public void destroy() { |
| 38 nativeDestroy(mNativeJniHost); | 38 nativeDestroy(mNativeJniHost); |
| 39 } | 39 } |
| 40 | 40 |
| 41 private native void nativeDestroy(long nativeJniHost); | 41 private native void nativeDestroy(long nativeJniHost); |
| 42 } | 42 } |
| OLD | NEW |