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; |
(...skipping 13 matching lines...) Expand all Loading... |
24 */ | 24 */ |
25 /** Whether the library has been loaded. Accessed on the UI thread. */ | 25 /** Whether the library has been loaded. Accessed on the UI thread. */ |
26 private static boolean sLoaded = false; | 26 private static boolean sLoaded = false; |
27 | 27 |
28 /** | 28 /** |
29 * To be called once from the main Activity. Loads and initializes the nativ
e code. | 29 * To be called once from the main Activity. Loads and initializes the nativ
e code. |
30 * Called on the UI thread. | 30 * Called on the UI thread. |
31 */ | 31 */ |
32 public static void loadLibrary(Context context) { | 32 public static void loadLibrary(Context context) { |
33 if (sLoaded) return; | 33 if (sLoaded) return; |
34 | 34 ContextUtils.initApplicationContext(context.getApplicationContext()); |
35 System.loadLibrary("remoting_client_jni"); | 35 System.loadLibrary("remoting_client_jni"); |
36 | |
37 ContextUtils.initApplicationContext(context.getApplicationContext()); | |
38 nativeLoadNative(); | 36 nativeLoadNative(); |
39 sLoaded = true; | 37 sLoaded = true; |
40 } | 38 } |
41 | 39 |
42 /** Performs the native portion of the initialization. */ | 40 /** Performs the native portion of the initialization. */ |
43 private static native void nativeLoadNative(); | 41 private static native void nativeLoadNative(); |
44 | 42 |
45 /** Performs the native portion of the connection. */ | 43 /** Performs the native portion of the connection. */ |
46 static native void nativeConnect(String username, String authToken, String h
ostJid, | 44 static native void nativeConnect(String username, String authToken, String h
ostJid, |
47 String hostId, String hostPubkey, String pairId, String pairSecret, | 45 String hostId, String hostPubkey, String pairId, String pairSecret, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 @CalledByNative | 180 @CalledByNative |
183 private static void handleExtensionMessage(String type, String data) { | 181 private static void handleExtensionMessage(String type, String data) { |
184 if (Client.getInstance() != null) { | 182 if (Client.getInstance() != null) { |
185 Client.getInstance().handleExtensionMessage(type, data); | 183 Client.getInstance().handleExtensionMessage(type, data); |
186 } | 184 } |
187 } | 185 } |
188 | 186 |
189 /** Passes extension message to the native code. */ | 187 /** Passes extension message to the native code. */ |
190 static native void nativeSendExtensionMessage(String type, String data); | 188 static native void nativeSendExtensionMessage(String type, String data); |
191 } | 189 } |
OLD | NEW |