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

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

Issue 1407233017: Define a Java-side global application context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo changes to ApplicationStatus Created 5 years 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
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 import android.graphics.Point; 9 import android.graphics.Point;
10 import android.os.Looper; 10 import android.os.Looper;
11 11
12 import org.chromium.base.ContextUtils;
12 import org.chromium.base.Log; 13 import org.chromium.base.Log;
13 import org.chromium.base.annotations.CalledByNative; 14 import org.chromium.base.annotations.CalledByNative;
14 import org.chromium.base.annotations.JNINamespace; 15 import org.chromium.base.annotations.JNINamespace;
15 import org.chromium.chromoting.CapabilityManager; 16 import org.chromium.chromoting.CapabilityManager;
16 import org.chromium.chromoting.R; 17 import org.chromium.chromoting.R;
17 import org.chromium.chromoting.SessionAuthenticator; 18 import org.chromium.chromoting.SessionAuthenticator;
18 19
19 import java.nio.ByteBuffer; 20 import java.nio.ByteBuffer;
20 import java.nio.ByteOrder; 21 import java.nio.ByteOrder;
21 22
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 /** Position of cursor hot-spot. Accessed on the graphics thread. */ 135 /** Position of cursor hot-spot. Accessed on the graphics thread. */
135 private static Point sCursorHotspot = new Point(); 136 private static Point sCursorHotspot = new Point();
136 137
137 /** Bitmap holding the cursor shape. Accessed on the graphics thread. */ 138 /** Bitmap holding the cursor shape. Accessed on the graphics thread. */
138 private static Bitmap sCursorBitmap = null; 139 private static Bitmap sCursorBitmap = null;
139 140
140 /** Capability Manager through which capabilities and extensions are handled . */ 141 /** Capability Manager through which capabilities and extensions are handled . */
141 private static CapabilityManager sCapabilityManager = CapabilityManager.getI nstance(); 142 private static CapabilityManager sCapabilityManager = CapabilityManager.getI nstance();
142 143
143 /** 144 /**
144 * To be called once from the main Activity. Any subsequent calls will updat e the application 145 * To be called once from the main Activity. Loads and initializes the nativ e code.
145 * context, but not reload the library. This is useful e.g. when the activit y is closed and the 146 * Called on the UI thread.
146 * user later wants to return to the application. Called on the UI thread.
147 */ 147 */
148 public static void loadLibrary(Context context) { 148 public static void loadLibrary(Context context) {
149 if (sLoaded) return; 149 if (sLoaded) return;
150 150
151 System.loadLibrary("remoting_client_jni"); 151 System.loadLibrary("remoting_client_jni");
152 152
153 nativeLoadNative(context); 153 ContextUtils.initApplicationContext(context.getApplicationContext());
154 nativeLoadNative();
154 sLoaded = true; 155 sLoaded = true;
155 } 156 }
156 157
157 /** Performs the native portion of the initialization. */ 158 /** Performs the native portion of the initialization. */
158 private static native void nativeLoadNative(Context context); 159 private static native void nativeLoadNative();
159 160
160 /* 161 /*
161 * API/OAuth2 keys access. 162 * API/OAuth2 keys access.
162 */ 163 */
163 public static native String nativeGetApiKey(); 164 public static native String nativeGetApiKey();
164 public static native String nativeGetClientId(); 165 public static native String nativeGetClientId();
165 public static native String nativeGetClientSecret(); 166 public static native String nativeGetClientSecret();
166 167
167 /** Returns whether the client is connected. */ 168 /** Returns whether the client is connected. */
168 public static boolean isConnected() { 169 public static boolean isConnected() {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 public static void sendExtensionMessage(String type, String data) { 484 public static void sendExtensionMessage(String type, String data) {
484 if (!sConnected) { 485 if (!sConnected) {
485 return; 486 return;
486 } 487 }
487 488
488 nativeSendExtensionMessage(type, data); 489 nativeSendExtensionMessage(type, data);
489 } 490 }
490 491
491 private static native void nativeSendExtensionMessage(String type, String da ta); 492 private static native void nativeSendExtensionMessage(String type, String da ta);
492 } 493 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698