Chromium Code Reviews| Index: remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java |
| diff --git a/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java b/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java |
| index 34bf0df1feac9300ad4b996dc266666c3094ee2d..a6bab4d01a4d3abd34cd0416904ff4c30aaffe99 100644 |
| --- a/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java |
| +++ b/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java |
| @@ -22,6 +22,7 @@ import android.widget.Toast; |
| import org.chromium.base.CalledByNative; |
| import org.chromium.base.JNINamespace; |
| +import org.chromium.chromoting.CapabilityManager; |
| import org.chromium.chromoting.Chromoting; |
| import org.chromium.chromoting.R; |
| @@ -143,6 +144,9 @@ public class JniInterface { |
| /** Bitmap holding the cursor shape. Accessed on the graphics thread. */ |
| private static Bitmap sCursorBitmap = null; |
| + /** Capability Manager through which capabilities and extensions are handled. */ |
| + private static CapabilityManager sCapabilityManager = CapabilityManager.getInstance(); |
| + |
| /** |
| * To be called once from the main Activity. Any subsequent calls will update the application |
| * context, but not reload the library. This is useful e.g. when the activity is closed and the |
| @@ -177,13 +181,15 @@ public class JniInterface { |
| sConnectionListener = listener; |
| SharedPreferences prefs = sContext.getPreferences(Activity.MODE_PRIVATE); |
| nativeConnect(username, authToken, hostJid, hostId, hostPubkey, |
| - prefs.getString(hostId + "_id", ""), prefs.getString(hostId + "_secret", "")); |
| + prefs.getString(hostId + "_id", ""), prefs.getString(hostId + "_secret", ""), |
|
Lambros
2014/08/14 23:54:25
nit: 8-space indent
aiguha
2014/08/15 03:37:30
Done.
|
| + sCapabilityManager.getLocalCapabilities()); |
| sConnected = true; |
| } |
| /** Performs the native portion of the connection. */ |
| - private static native void nativeConnect(String username, String authToken, String hostJid, |
| - String hostId, String hostPubkey, String pairId, String pairSecret); |
| + private static native void nativeConnect( |
| + String username, String authToken, String hostJid, String hostId, String hostPubkey, |
|
Lambros
2014/08/14 23:54:25
nit: 8-space indent. Also you can begin the parame
aiguha
2014/08/15 03:37:30
Done.
|
| + String pairId, String pairSecret, String capabilities); |
| /** Severs the connection and cleans up. Called on the UI thread. */ |
| public static void disconnectFromHost() { |
| @@ -490,4 +496,34 @@ public class JniInterface { |
| /** Passes authentication data to the native handling code. */ |
| private static native void nativeOnThirdPartyTokenFetched(String token, String sharedSecret); |
| + |
| + // |
| + // Host and Client Capabilities |
| + // |
| + |
| + /** Set the list of negotiated capabilities between host and client. Called on the UI thread. */ |
| + @CalledByNative |
| + public static void setCapabilities(String capabilities) { |
| + sCapabilityManager.setNegotiatedCapabilities(capabilities); |
| + } |
| + |
| + // |
| + // Extension Message Handling |
| + // |
| + |
| + /** Passes on the deconstructed ExtensionMessage to the app. Called on the UI thread. */ |
| + @CalledByNative |
| + public static void handleExtensionMessage(String type, String data) { |
| + sCapabilityManager.onExtensionMessage(type, data); |
| + } |
| + |
|
Lambros
2014/08/14 23:54:25
nit: only one blank line
aiguha
2014/08/15 03:37:30
Done.
|
| + |
| + public static void sendExtensionMessage(String type, String data) { |
|
Lambros
2014/08/14 23:54:25
Add some JavaDoc. And say which thread this should
aiguha
2014/08/15 03:37:30
Done.
|
| + if (!sConnected) |
|
Lambros
2014/08/14 23:54:25
nit: Add braces, consistent with above.
aiguha
2014/08/15 03:37:30
Done.
|
| + return; |
| + |
| + nativeSendExtensionMessage(type, data); |
| + } |
| + |
| + private static native void nativeSendExtensionMessage(String type, String data); |
| } |