Index: remoting/android/java/src/org/chromium/chromoting/jni/Client.java |
diff --git a/remoting/android/java/src/org/chromium/chromoting/jni/Client.java b/remoting/android/java/src/org/chromium/chromoting/jni/Client.java |
index 451a5d4670b675ead9099a2ef40f16b54197ca78..742e93e8202193acf026426e1f8c8e2185fb0d1b 100644 |
--- a/remoting/android/java/src/org/chromium/chromoting/jni/Client.java |
+++ b/remoting/android/java/src/org/chromium/chromoting/jni/Client.java |
@@ -9,6 +9,7 @@ import android.graphics.Point; |
import android.os.Looper; |
import org.chromium.base.Log; |
+import org.chromium.base.annotations.CalledByNative; |
import org.chromium.base.annotations.JNINamespace; |
import org.chromium.base.annotations.SuppressFBWarnings; |
import org.chromium.chromoting.CapabilityManager; |
@@ -44,8 +45,6 @@ public class Client { |
mNativeJniClient = nativeInit(); |
} |
- private native long nativeInit(); |
- |
// Called on the UI thread. Suppress FindBugs warning, since |sClient| is only used on the |
// UI thread. |
@SuppressFBWarnings("LI_LAZY_INIT_STATIC") |
@@ -57,8 +56,6 @@ public class Client { |
} |
} |
- private native void nativeDestroy(long nativeJniClient); |
- |
/** Returns the current Client instance, or null. */ |
public static Client getInstance() { |
return sClient; |
@@ -111,7 +108,7 @@ public class Client { |
mConnectionListener = listener; |
mAuthenticator = authenticator; |
- JniInterface.nativeConnect(username, authToken, hostJid, hostId, hostPubkey, |
+ nativeConnect(mNativeJniClient, username, authToken, hostJid, hostId, hostPubkey, |
mAuthenticator.getPairingId(hostId), mAuthenticator.getPairingSecret(hostId), |
mCapabilityManager.getLocalCapabilities(), flags); |
mConnected = true; |
@@ -135,7 +132,7 @@ public class Client { |
return; |
} |
- JniInterface.nativeDisconnect(); |
+ nativeDisconnect(mNativeJniClient); |
mConnectionListener = null; |
mConnected = false; |
mCapabilityManager.onHostDisconnect(); |
@@ -147,6 +144,7 @@ public class Client { |
} |
/** Called by native code whenever the connection status changes. Called on the UI thread. */ |
Lambros
2016/05/25 20:51:49
The CalledByNative annotation means you can remove
Yuwei
2016/05/25 21:19:53
Done.
|
+ @CalledByNative |
void onConnectionState(int stateCode, int errorCode) { |
ConnectionListener.State state = ConnectionListener.State.fromValue(stateCode); |
ConnectionListener.Error error = ConnectionListener.Error.fromValue(errorCode); |
@@ -166,6 +164,7 @@ public class Client { |
* Called by JniInterface (from native code) to prompt the user to enter a PIN. Called on the |
* UI thread. |
*/ |
+ @CalledByNative |
Lambros
2016/05/25 20:51:50
No longer called by JniInterface. Comment can be s
Yuwei
2016/05/25 21:19:52
Done.
|
void displayAuthenticationPrompt(boolean pairingSupported) { |
mAuthenticator.displayAuthenticationPrompt(pairingSupported); |
} |
@@ -180,13 +179,14 @@ public class Client { |
public void handleAuthenticationResponse( |
String pin, boolean createPair, String deviceName) { |
assert mConnected; |
- JniInterface.nativeAuthenticationResponse(pin, createPair, deviceName); |
+ nativeAuthenticationResponse(mNativeJniClient, pin, createPair, deviceName); |
} |
/** |
* Called by JniInterface (from native code), to save newly-received pairing credentials to |
* permanent storage. Called on the UI thread. |
*/ |
+ @CalledByNative |
Lambros
2016/05/25 20:51:50
Saves newly-received ...
Yuwei
2016/05/25 21:19:52
Done.
|
void commitPairingCredentials(String host, String id, String secret) { |
mAuthenticator.commitPairingCredentials(host, id, secret); |
} |
@@ -200,7 +200,7 @@ public class Client { |
return; |
} |
- JniInterface.nativeSendMouseEvent(x, y, whichButton, buttonDown); |
+ nativeSendMouseEvent(mNativeJniClient, x, y, whichButton, buttonDown); |
} |
/** Injects a mouse-wheel event with delta values. Called on the UI thread. */ |
@@ -209,7 +209,7 @@ public class Client { |
return; |
} |
- JniInterface.nativeSendMouseWheelEvent(deltaX, deltaY); |
+ nativeSendMouseWheelEvent(mNativeJniClient, deltaX, deltaY); |
} |
/** |
@@ -221,7 +221,7 @@ public class Client { |
return false; |
} |
- return JniInterface.nativeSendKeyEvent(scanCode, keyCode, keyDown); |
+ return nativeSendKeyEvent(mNativeJniClient, scanCode, keyCode, keyDown); |
} |
/** Sends TextEvent to the host. Called on the UI thread. */ |
@@ -230,7 +230,7 @@ public class Client { |
return; |
} |
- JniInterface.nativeSendTextEvent(text); |
+ nativeSendTextEvent(mNativeJniClient, text); |
} |
/** Sends an array of TouchEvents to the host. Called on the UI thread. */ |
@@ -239,7 +239,7 @@ public class Client { |
return; |
} |
- JniInterface.nativeSendTouchEvent(eventType.value(), data); |
+ nativeSendTouchEvent(mNativeJniClient, eventType.value(), data); |
} |
/** |
@@ -251,7 +251,7 @@ public class Client { |
return; |
} |
- JniInterface.nativeEnableVideoChannel(enable); |
+ nativeEnableVideoChannel(mNativeJniClient, enable); |
} |
/** |
@@ -267,7 +267,7 @@ public class Client { |
public boolean redrawGraphics() { |
if (!mConnected || mRedrawCallback == null) return false; |
- JniInterface.nativeScheduleRedraw(); |
+ nativeScheduleRedraw(mNativeJniClient); |
return true; |
} |
@@ -276,6 +276,7 @@ public class Client { |
* {@link #redrawGraphics}. This is a no-op if the window isn't visible (the callback is null). |
* Called on the graphics thread. |
*/ |
+ @CalledByNative |
void redrawGraphicsInternal() { |
Runnable callback = mRedrawCallback; |
if (callback != null) { |
@@ -301,6 +302,7 @@ public class Client { |
* Called by JniInterface (from native code) to set a new video frame. Called on the native |
* graphics thread when a new frame is allocated. |
*/ |
+ @CalledByNative |
Lambros
2016/05/25 20:51:49
Sets a new video frame. ...
Yuwei
2016/05/25 21:19:52
Done.
|
void setVideoFrame(Bitmap bitmap) { |
if (Looper.myLooper() == Looper.getMainLooper()) { |
Log.w(TAG, "Video frame updated on UI thread"); |
@@ -316,6 +318,7 @@ public class Client { |
* and the returned Bitmap is referenced by native code which writes the decoded frame pixels |
Lambros
2016/05/25 20:51:49
Remove "Called by JniInterface (from native code)"
Yuwei
2016/05/25 21:19:52
Done.
|
* to it. |
*/ |
+ @CalledByNative |
static Bitmap newBitmap(int width, int height) { |
return Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); |
} |
@@ -324,8 +327,8 @@ public class Client { |
* Called by JniInterface (from native code) to update the cursor shape. This is called on the |
Lambros
2016/05/25 20:51:50
Updates the cursor shape.
Yuwei
2016/05/25 21:19:52
Done.
|
* graphics thread when receiving a new cursor shape from the host. |
*/ |
- void updateCursorShape( |
- int width, int height, int hotspotX, int hotspotY, ByteBuffer buffer) { |
+ @CalledByNative |
+ void updateCursorShape(int width, int height, int hotspotX, int hotspotY, ByteBuffer buffer) { |
mCursorHotspot = new Point(hotspotX, hotspotY); |
int[] data = new int[width * height]; |
@@ -352,6 +355,7 @@ public class Client { |
* Called by JniInterface (from native code), to pop up a third party login page to fetch the |
Lambros
2016/05/25 20:51:49
Pops up a third party ...
Yuwei
2016/05/25 21:19:52
Done.
|
* token required for authentication. |
*/ |
+ @CalledByNative |
void fetchThirdPartyToken(String tokenUrl, String clientId, String scope) { |
mAuthenticator.fetchThirdPartyToken(tokenUrl, clientId, scope); |
} |
@@ -365,7 +369,7 @@ public class Client { |
return; |
} |
- JniInterface.nativeOnThirdPartyTokenFetched(token, sharedSecret); |
+ nativeOnThirdPartyTokenFetched(mNativeJniClient, token, sharedSecret); |
} |
// |
@@ -376,6 +380,7 @@ public class Client { |
* Called by JniInterface (from native code) to set the list of negotiated capabilities between |
Lambros
2016/05/25 20:51:50
Sets the list...
Yuwei
2016/05/25 21:19:53
Done.
|
* host and client. Called on the UI thread. |
*/ |
+ @CalledByNative |
void setCapabilities(String capabilities) { |
mCapabilityManager.setNegotiatedCapabilities(capabilities); |
} |
@@ -388,6 +393,7 @@ public class Client { |
* Called by JniInterface (from native code), to pass on the deconstructed ExtensionMessage to |
Lambros
2016/05/25 20:51:50
Passes on the ...
Yuwei
2016/05/25 21:19:53
Done.
|
* the app. Called on the UI thread. |
*/ |
+ @CalledByNative |
void handleExtensionMessage(String type, String data) { |
mCapabilityManager.onExtensionMessage(type, data); |
} |
@@ -398,6 +404,55 @@ public class Client { |
return; |
} |
- JniInterface.nativeSendExtensionMessage(type, data); |
+ nativeSendExtensionMessage(mNativeJniClient, type, data); |
} |
+ |
+ // JNI Interface. |
Lambros
2016/05/25 20:51:49
Remove this comment.
Yuwei
2016/05/25 21:19:52
Done.
|
+ |
+ private native long nativeInit(); |
Lambros
2016/05/25 20:51:49
OK to group these native.. methods together, as lo
Yuwei
2016/05/25 21:19:52
Since it is just moving one line of code (i.e. pri
|
+ |
+ private native void nativeDestroy(long nativeJniClient); |
+ |
+ /** Performs the native portion of the connection. */ |
+ private native void nativeConnect(long nativeJniClient, String username, String authToken, |
+ String hostJid, String hostId, String hostPubkey, String pairId, String pairSecret, |
+ String capabilities, String flags); |
+ |
+ /** Native implementation of Client.handleAuthenticationResponse(). */ |
+ private native void nativeAuthenticationResponse( |
+ long nativeJniClient, String pin, boolean createPair, String deviceName); |
+ |
+ /** Performs the native portion of the cleanup. */ |
+ private native void nativeDisconnect(long nativeJniClient); |
+ |
+ /** Schedules a redraw on the native graphics thread. */ |
+ private native void nativeScheduleRedraw(long nativeJniClient); |
+ |
+ /** Passes authentication data to the native handling code. */ |
+ private native void nativeOnThirdPartyTokenFetched( |
+ long nativeJniClient, String token, String sharedSecret); |
+ |
+ /** Passes mouse information to the native handling code. */ |
+ private native void nativeSendMouseEvent( |
+ long nativeJniClient, int x, int y, int whichButton, boolean buttonDown); |
+ |
+ /** Passes mouse-wheel information to the native handling code. */ |
+ private native void nativeSendMouseWheelEvent(long nativeJniClient, int deltaX, int deltaY); |
+ |
+ /** Passes key press information to the native handling code. */ |
+ private native boolean nativeSendKeyEvent( |
+ long nativeJniClient, int scanCode, int keyCode, boolean keyDown); |
+ |
+ /** Passes text event information to the native handling code. */ |
+ private native void nativeSendTextEvent(long nativeJniClient, String text); |
+ |
+ /** Passes touch event information to the native handling code. */ |
+ private native void nativeSendTouchEvent( |
+ long nativeJniClient, int eventType, TouchEventData[] data); |
+ |
+ /** Native implementation of Client.enableVideoChannel() */ |
+ private native void nativeEnableVideoChannel(long nativeJniClient, boolean enable); |
+ |
+ /** Passes extension message to the native code. */ |
+ private native void nativeSendExtensionMessage(long nativeJniClient, String type, String data); |
} |