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

Unified Diff: remoting/android/java/src/org/chromium/chromoting/jni/Client.java

Issue 2027783002: Revert of [Android Client] Move session-scoped native interface into JniClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 24911e2833a5e8903c75339dbca075cefe068c67..451a5d4670b675ead9099a2ef40f16b54197ca78 100644
--- a/remoting/android/java/src/org/chromium/chromoting/jni/Client.java
+++ b/remoting/android/java/src/org/chromium/chromoting/jni/Client.java
@@ -9,7 +9,6 @@
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;
@@ -45,6 +44,8 @@
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")
@@ -56,6 +57,8 @@
}
}
+ private native void nativeDestroy(long nativeJniClient);
+
/** Returns the current Client instance, or null. */
public static Client getInstance() {
return sClient;
@@ -108,7 +111,7 @@
mConnectionListener = listener;
mAuthenticator = authenticator;
- nativeConnect(mNativeJniClient, username, authToken, hostJid, hostId, hostPubkey,
+ JniInterface.nativeConnect(username, authToken, hostJid, hostId, hostPubkey,
mAuthenticator.getPairingId(hostId), mAuthenticator.getPairingSecret(hostId),
mCapabilityManager.getLocalCapabilities(), flags);
mConnected = true;
@@ -132,7 +135,7 @@
return;
}
- nativeDisconnect(mNativeJniClient);
+ JniInterface.nativeDisconnect();
mConnectionListener = null;
mConnected = false;
mCapabilityManager.onHostDisconnect();
@@ -143,8 +146,7 @@
}
}
- /** Called on the UI thread whenever the connection status changes. */
- @CalledByNative
+ /** Called by native code whenever the connection status changes. Called on the UI thread. */
void onConnectionState(int stateCode, int errorCode) {
ConnectionListener.State state = ConnectionListener.State.fromValue(stateCode);
ConnectionListener.Error error = ConnectionListener.Error.fromValue(errorCode);
@@ -161,9 +163,9 @@
}
/**
- * Called on the UI thread to prompt the user to enter a PIN.
- */
- @CalledByNative
+ * Called by JniInterface (from native code) to prompt the user to enter a PIN. Called on the
+ * UI thread.
+ */
void displayAuthenticationPrompt(boolean pairingSupported) {
mAuthenticator.displayAuthenticationPrompt(pairingSupported);
}
@@ -178,13 +180,13 @@
public void handleAuthenticationResponse(
String pin, boolean createPair, String deviceName) {
assert mConnected;
- nativeAuthenticationResponse(mNativeJniClient, pin, createPair, deviceName);
- }
-
- /**
- * Called on the UI thread to save newly-received pairing credentials to permanent storage.
- */
- @CalledByNative
+ JniInterface.nativeAuthenticationResponse(pin, createPair, deviceName);
+ }
+
+ /**
+ * Called by JniInterface (from native code), to save newly-received pairing credentials to
+ * permanent storage. Called on the UI thread.
+ */
void commitPairingCredentials(String host, String id, String secret) {
mAuthenticator.commitPairingCredentials(host, id, secret);
}
@@ -198,7 +200,7 @@
return;
}
- nativeSendMouseEvent(mNativeJniClient, x, y, whichButton, buttonDown);
+ JniInterface.nativeSendMouseEvent(x, y, whichButton, buttonDown);
}
/** Injects a mouse-wheel event with delta values. Called on the UI thread. */
@@ -207,7 +209,7 @@
return;
}
- nativeSendMouseWheelEvent(mNativeJniClient, deltaX, deltaY);
+ JniInterface.nativeSendMouseWheelEvent(deltaX, deltaY);
}
/**
@@ -219,7 +221,7 @@
return false;
}
- return nativeSendKeyEvent(mNativeJniClient, scanCode, keyCode, keyDown);
+ return JniInterface.nativeSendKeyEvent(scanCode, keyCode, keyDown);
}
/** Sends TextEvent to the host. Called on the UI thread. */
@@ -228,7 +230,7 @@
return;
}
- nativeSendTextEvent(mNativeJniClient, text);
+ JniInterface.nativeSendTextEvent(text);
}
/** Sends an array of TouchEvents to the host. Called on the UI thread. */
@@ -237,7 +239,7 @@
return;
}
- nativeSendTouchEvent(mNativeJniClient, eventType.value(), data);
+ JniInterface.nativeSendTouchEvent(eventType.value(), data);
}
/**
@@ -249,7 +251,7 @@
return;
}
- nativeEnableVideoChannel(mNativeJniClient, enable);
+ JniInterface.nativeEnableVideoChannel(enable);
}
/**
@@ -265,15 +267,15 @@
public boolean redrawGraphics() {
if (!mConnected || mRedrawCallback == null) return false;
- nativeScheduleRedraw(mNativeJniClient);
+ JniInterface.nativeScheduleRedraw();
return true;
}
/**
- * Called on the graphics thread to perform the redrawing callback requested by
+ * Called by JniInterface to perform the redrawing callback requested by
* {@link #redrawGraphics}. This is a no-op if the window isn't visible (the callback is null).
- */
- @CalledByNative
+ * Called on the graphics thread.
+ */
void redrawGraphicsInternal() {
Runnable callback = mRedrawCallback;
if (callback != null) {
@@ -296,9 +298,9 @@
}
/**
- * Set a new video frame. Called on the native graphics thread when a new frame is allocated.
- */
- @CalledByNative
+ * Called by JniInterface (from native code) to set a new video frame. Called on the native
+ * graphics thread when a new frame is allocated.
+ */
void setVideoFrame(Bitmap bitmap) {
if (Looper.myLooper() == Looper.getMainLooper()) {
Log.w(TAG, "Video frame updated on UI thread");
@@ -310,20 +312,20 @@
}
/**
- * Creates a new Bitmap to hold video frame pixels. The returned Bitmap is referenced by native
- * code which writes the decoded frame pixels to it.
- */
- @CalledByNative
+ * Creates a new Bitmap to hold video frame pixels. Called by JniInterface (from native code),
+ * and the returned Bitmap is referenced by native code which writes the decoded frame pixels
+ * to it.
+ */
static Bitmap newBitmap(int width, int height) {
return Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
}
/**
- * Updates the cursor shape. This is called on the graphics thread when receiving a new cursor
- * shape from the host.
- */
- @CalledByNative
- void updateCursorShape(int width, int height, int hotspotX, int hotspotY, ByteBuffer buffer) {
+ * Called by JniInterface (from native code) to update the cursor shape. This is called on the
+ * graphics thread when receiving a new cursor shape from the host.
+ */
+ void updateCursorShape(
+ int width, int height, int hotspotX, int hotspotY, ByteBuffer buffer) {
mCursorHotspot = new Point(hotspotX, hotspotY);
int[] data = new int[width * height];
@@ -347,9 +349,9 @@
//
/**
- * Pops up a third party login page to fetch the token required for authentication.
- */
- @CalledByNative
+ * Called by JniInterface (from native code), to pop up a third party login page to fetch the
+ * token required for authentication.
+ */
void fetchThirdPartyToken(String tokenUrl, String clientId, String scope) {
mAuthenticator.fetchThirdPartyToken(tokenUrl, clientId, scope);
}
@@ -363,7 +365,7 @@
return;
}
- nativeOnThirdPartyTokenFetched(mNativeJniClient, token, sharedSecret);
+ JniInterface.nativeOnThirdPartyTokenFetched(token, sharedSecret);
}
//
@@ -371,9 +373,9 @@
//
/**
- * Sets the list of negotiated capabilities between host and client. Called on the UI thread.
- */
- @CalledByNative
+ * Called by JniInterface (from native code) to set the list of negotiated capabilities between
+ * host and client. Called on the UI thread.
+ */
void setCapabilities(String capabilities) {
mCapabilityManager.setNegotiatedCapabilities(capabilities);
}
@@ -383,9 +385,9 @@
//
/**
- * Passes on the deconstructed ExtensionMessage to the app. Called on the UI thread.
- */
- @CalledByNative
+ * Called by JniInterface (from native code), to pass on the deconstructed ExtensionMessage to
+ * the app. Called on the UI thread.
+ */
void handleExtensionMessage(String type, String data) {
mCapabilityManager.onExtensionMessage(type, data);
}
@@ -396,53 +398,6 @@
return;
}
- nativeSendExtensionMessage(mNativeJniClient, type, data);
- }
-
- private native long nativeInit();
-
- 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);
+ JniInterface.nativeSendExtensionMessage(type, data);
+ }
}
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698