| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.jni; | 5 package org.chromium.chromoting.jni; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
| 9 | 9 |
| 10 import org.chromium.base.ContextUtils; | 10 import org.chromium.base.ContextUtils; |
| 11 import org.chromium.base.annotations.CalledByNative; | 11 import org.chromium.base.annotations.CalledByNative; |
| 12 import org.chromium.base.annotations.JNINamespace; | 12 import org.chromium.base.annotations.JNINamespace; |
| 13 | 13 |
| 14 import java.nio.ByteBuffer; | 14 import java.nio.ByteBuffer; |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * Initializes the Chromium remoting library, and provides JNI calls into it. | 17 * Initializes the Chromium remoting library, and provides JNI calls into it. |
| 18 * All interaction with the native code is centralized in this class. | 18 * All interaction with the native code is centralized in this class. |
| 19 */ | 19 */ |
| 20 @JNINamespace("remoting") | 20 @JNINamespace("remoting") |
| 21 public class JniInterface { | 21 public class JniInterface { |
| 22 /** | 22 /** |
| 23 * To be called once from the Application context singleton. Loads and initi
alizes the native | 23 * To be called once from the Application context singleton. Loads and initi
alizes the native |
| 24 * code. Called on the UI thread. | 24 * code. Called on the UI thread. |
| 25 * @param context The Application context. | 25 * @param context The Application context. |
| 26 */ | 26 */ |
| 27 public static void loadLibrary(Context context) { | 27 public static void loadLibrary(Context context) { |
| 28 ContextUtils.initApplicationContext(context.getApplicationContext()); | |
| 29 System.loadLibrary("remoting_client_jni"); | 28 System.loadLibrary("remoting_client_jni"); |
| 29 |
| 30 ContextUtils.initApplicationContext(context); |
| 30 nativeLoadNative(); | 31 nativeLoadNative(); |
| 31 } | 32 } |
| 32 | 33 |
| 33 /** Performs the native portion of the initialization. */ | 34 /** Performs the native portion of the initialization. */ |
| 34 private static native void nativeLoadNative(); | 35 private static native void nativeLoadNative(); |
| 35 | 36 |
| 36 /** Performs the native portion of the connection. */ | 37 /** Performs the native portion of the connection. */ |
| 37 static native void nativeConnect(String username, String authToken, String h
ostJid, | 38 static native void nativeConnect(String username, String authToken, String h
ostJid, |
| 38 String hostId, String hostPubkey, String pairId, String pairSecret, | 39 String hostId, String hostPubkey, String pairId, String pairSecret, |
| 39 String capabilities, String flags); | 40 String capabilities, String flags); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 @CalledByNative | 174 @CalledByNative |
| 174 private static void handleExtensionMessage(String type, String data) { | 175 private static void handleExtensionMessage(String type, String data) { |
| 175 if (Client.getInstance() != null) { | 176 if (Client.getInstance() != null) { |
| 176 Client.getInstance().handleExtensionMessage(type, data); | 177 Client.getInstance().handleExtensionMessage(type, data); |
| 177 } | 178 } |
| 178 } | 179 } |
| 179 | 180 |
| 180 /** Passes extension message to the native code. */ | 181 /** Passes extension message to the native code. */ |
| 181 static native void nativeSendExtensionMessage(String type, String data); | 182 static native void nativeSendExtensionMessage(String type, String data); |
| 182 } | 183 } |
| OLD | NEW |