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.annotation.SuppressLint; |
7 import android.content.Context; | 8 import android.content.Context; |
8 | 9 |
9 import org.chromium.base.ContextUtils; | 10 import org.chromium.base.ContextUtils; |
10 import org.chromium.base.Log; | 11 import org.chromium.base.Log; |
11 import org.chromium.base.annotations.CalledByNative; | 12 import org.chromium.base.annotations.CalledByNative; |
12 import org.chromium.base.annotations.JNINamespace; | 13 import org.chromium.base.annotations.JNINamespace; |
13 import org.chromium.chromoting.OAuthTokenConsumer; | 14 import org.chromium.chromoting.OAuthTokenConsumer; |
14 import org.chromium.chromoting.base.OAuthTokenFetcher; | 15 import org.chromium.chromoting.base.OAuthTokenFetcher; |
15 | 16 |
16 /** | 17 /** |
17 * Initializes the Chromium remoting library, and provides JNI calls into it. | 18 * Initializes the Chromium remoting library, and provides JNI calls into it. |
18 * All interaction with the native code is centralized in this class. | 19 * All interaction with the native code is centralized in this class. |
19 */ | 20 */ |
20 @JNINamespace("remoting") | 21 @JNINamespace("remoting") |
21 public class JniInterface { | 22 public class JniInterface { |
22 private static final String TAG = "Chromoting"; | 23 private static final String TAG = "Chromoting"; |
23 | 24 |
24 private static final String TOKEN_SCOPE = "oauth2:https://www.googleapis.com
/auth/chromoting"; | 25 private static final String TOKEN_SCOPE = "oauth2:https://www.googleapis.com
/auth/chromoting"; |
25 | 26 |
26 private static final String LIBRARY_NAME = "remoting_client_jni"; | 27 private static final String LIBRARY_NAME = "remoting_client_jni"; |
27 | 28 |
28 // Used to fetch auth token for native client. | 29 // Used to fetch auth token for native client. |
| 30 @SuppressLint("StaticFieldLeak") |
29 private static OAuthTokenConsumer sLoggerTokenConsumer; | 31 private static OAuthTokenConsumer sLoggerTokenConsumer; |
30 | 32 |
31 private static String sAccount; | 33 private static String sAccount; |
32 | 34 |
33 /** | 35 /** |
34 * To be called once from the Application context singleton. Loads and initi
alizes the native | 36 * To be called once from the Application context singleton. Loads and initi
alizes the native |
35 * code. Called on the UI thread. | 37 * code. Called on the UI thread. |
36 * @param context The Application context. | 38 * @param context The Application context. |
37 */ | 39 */ |
38 public static void loadLibrary(Context context) { | 40 public static void loadLibrary(Context context) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 79 } |
78 }); | 80 }); |
79 } | 81 } |
80 | 82 |
81 /** Performs the native portion of the initialization. */ | 83 /** Performs the native portion of the initialization. */ |
82 private static native void nativeLoadNative(); | 84 private static native void nativeLoadNative(); |
83 | 85 |
84 /** Notifies the native client with the new auth token */ | 86 /** Notifies the native client with the new auth token */ |
85 private static native void nativeOnAuthTokenFetched(String token); | 87 private static native void nativeOnAuthTokenFetched(String token); |
86 } | 88 } |
OLD | NEW |