Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(979)

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java

Issue 1873383002: [remoting android] Move JNI loading to Application.onCreate() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@android-host-add-native
Patch Set: rebase, (c) 2016 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/Chromoting.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /*
23 * Library-loading state machine.
24 */
25 /** Whether the library has been loaded. Accessed on the UI thread. */
26 private static boolean sLoaded = false;
27
28 /** 22 /**
29 * To be called once from the main Activity. Loads and initializes the nativ e code. 23 * To be called once from the Application context singleton. Loads and initi alizes the native
30 * Called on the UI thread. 24 * code. Called on the UI thread.
25 * @param context The Application context.
31 */ 26 */
32 public static void loadLibrary(Context context) { 27 public static void loadLibrary(Context context) {
33 if (sLoaded) return;
34
35 System.loadLibrary("remoting_client_jni"); 28 System.loadLibrary("remoting_client_jni");
36 29
37 ContextUtils.initApplicationContext(context.getApplicationContext()); 30 ContextUtils.initApplicationContext(context);
38 nativeLoadNative(); 31 nativeLoadNative();
39 sLoaded = true;
40 } 32 }
41 33
42 /** Performs the native portion of the initialization. */ 34 /** Performs the native portion of the initialization. */
43 private static native void nativeLoadNative(); 35 private static native void nativeLoadNative();
44 36
45 /** Performs the native portion of the connection. */ 37 /** Performs the native portion of the connection. */
46 static native void nativeConnect(String username, String authToken, String h ostJid, 38 static native void nativeConnect(String username, String authToken, String h ostJid,
47 String hostId, String hostPubkey, String pairId, String pairSecret, 39 String hostId, String hostPubkey, String pairId, String pairSecret,
48 String capabilities, String flags); 40 String capabilities, String flags);
49 41
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 @CalledByNative 174 @CalledByNative
183 private static void handleExtensionMessage(String type, String data) { 175 private static void handleExtensionMessage(String type, String data) {
184 if (Client.getInstance() != null) { 176 if (Client.getInstance() != null) {
185 Client.getInstance().handleExtensionMessage(type, data); 177 Client.getInstance().handleExtensionMessage(type, data);
186 } 178 }
187 } 179 }
188 180
189 /** Passes extension message to the native code. */ 181 /** Passes extension message to the native code. */
190 static native void nativeSendExtensionMessage(String type, String data); 182 static native void nativeSendExtensionMessage(String type, String data);
191 } 183 }
OLDNEW
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/Chromoting.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698