Commit 3b2612ed authored by Eric Stevenson's avatar Eric Stevenson Committed by Commit Bot

JNI refactor: @NativeMethods conversion (//remoting).

This CL was generated by
//base/android/jni_generator/jni_refactorer.py.

Bug: 929661
Change-Id: Ib26cd65ad27cb8f339a701654e5b65d20559e5f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1809497Reviewed-by: default avatarLambros Lambrou <lambroslambrou@chromium.org>
Commit-Queue: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697610}
parent 3900bde0
...@@ -6,6 +6,7 @@ package org.chromium.chromoting.jni; ...@@ -6,6 +6,7 @@ package org.chromium.chromoting.jni;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chromoting.CapabilityManager; import org.chromium.chromoting.CapabilityManager;
import org.chromium.chromoting.InputStub; import org.chromium.chromoting.InputStub;
import org.chromium.chromoting.Preconditions; import org.chromium.chromoting.Preconditions;
...@@ -36,14 +37,14 @@ public class Client implements InputStub { ...@@ -36,14 +37,14 @@ public class Client implements InputStub {
} }
sClient = this; sClient = this;
mNativeJniClient = nativeInit(); mNativeJniClient = ClientJni.get().init(Client.this);
} }
// Suppress FindBugs warning, since |sClient| is only used on the UI thread. // Suppress FindBugs warning, since |sClient| is only used on the UI thread.
public void destroy() { public void destroy() {
if (sClient != null) { if (sClient != null) {
disconnectFromHost(); disconnectFromHost();
nativeDestroy(mNativeJniClient); ClientJni.get().destroy(mNativeJniClient, Client.this);
sClient = null; sClient = null;
} }
} }
...@@ -92,10 +93,10 @@ public class Client implements InputStub { ...@@ -92,10 +93,10 @@ public class Client implements InputStub {
mConnectionListener = listener; mConnectionListener = listener;
mAuthenticator = authenticator; mAuthenticator = authenticator;
nativeConnect(mNativeJniClient, username, authToken, hostJid, hostFtlId, hostId, hostPubkey, ClientJni.get().connect(mNativeJniClient, Client.this, username, authToken, hostJid,
mAuthenticator.getPairingId(hostId), mAuthenticator.getPairingSecret(hostId), hostFtlId, hostId, hostPubkey, mAuthenticator.getPairingId(hostId),
mCapabilityManager.getLocalCapabilities(), flags, hostVersion, hostOs, mAuthenticator.getPairingSecret(hostId), mCapabilityManager.getLocalCapabilities(),
hostOsVersion); flags, hostVersion, hostOs, hostOsVersion);
mConnected = true; mConnected = true;
} }
...@@ -117,7 +118,7 @@ public class Client implements InputStub { ...@@ -117,7 +118,7 @@ public class Client implements InputStub {
return; return;
} }
nativeDisconnect(mNativeJniClient); ClientJni.get().disconnect(mNativeJniClient, Client.this);
mConnectionListener = null; mConnectionListener = null;
mConnected = false; mConnected = false;
mCapabilityManager.onHostDisconnect(); mCapabilityManager.onHostDisconnect();
...@@ -157,7 +158,8 @@ public class Client implements InputStub { ...@@ -157,7 +158,8 @@ public class Client implements InputStub {
public void handleAuthenticationResponse( public void handleAuthenticationResponse(
String pin, boolean createPair, String deviceName) { String pin, boolean createPair, String deviceName) {
assert mConnected; assert mConnected;
nativeAuthenticationResponse(mNativeJniClient, pin, createPair, deviceName); ClientJni.get().authenticationResponse(
mNativeJniClient, Client.this, pin, createPair, deviceName);
} }
/** /**
...@@ -177,7 +179,8 @@ public class Client implements InputStub { ...@@ -177,7 +179,8 @@ public class Client implements InputStub {
return; return;
} }
nativeSendMouseEvent(mNativeJniClient, x, y, whichButton, buttonDown); ClientJni.get().sendMouseEvent(
mNativeJniClient, Client.this, x, y, whichButton, buttonDown);
} }
/** Injects a mouse-wheel event with delta values. */ /** Injects a mouse-wheel event with delta values. */
...@@ -187,7 +190,7 @@ public class Client implements InputStub { ...@@ -187,7 +190,7 @@ public class Client implements InputStub {
return; return;
} }
nativeSendMouseWheelEvent(mNativeJniClient, deltaX, deltaY); ClientJni.get().sendMouseWheelEvent(mNativeJniClient, Client.this, deltaX, deltaY);
} }
/** /**
...@@ -200,7 +203,8 @@ public class Client implements InputStub { ...@@ -200,7 +203,8 @@ public class Client implements InputStub {
return false; return false;
} }
return nativeSendKeyEvent(mNativeJniClient, scanCode, keyCode, keyDown); return ClientJni.get().sendKeyEvent(
mNativeJniClient, Client.this, scanCode, keyCode, keyDown);
} }
/** Sends TextEvent to the host. */ /** Sends TextEvent to the host. */
...@@ -210,7 +214,7 @@ public class Client implements InputStub { ...@@ -210,7 +214,7 @@ public class Client implements InputStub {
return; return;
} }
nativeSendTextEvent(mNativeJniClient, text); ClientJni.get().sendTextEvent(mNativeJniClient, Client.this, text);
} }
/** Sends an array of TouchEvents to the host. */ /** Sends an array of TouchEvents to the host. */
...@@ -220,7 +224,7 @@ public class Client implements InputStub { ...@@ -220,7 +224,7 @@ public class Client implements InputStub {
return; return;
} }
nativeSendTouchEvent(mNativeJniClient, eventType, data); ClientJni.get().sendTouchEvent(mNativeJniClient, Client.this, eventType, data);
} }
/** /**
...@@ -231,7 +235,7 @@ public class Client implements InputStub { ...@@ -231,7 +235,7 @@ public class Client implements InputStub {
return; return;
} }
nativeEnableVideoChannel(mNativeJniClient, enable); ClientJni.get().enableVideoChannel(mNativeJniClient, Client.this, enable);
} }
// //
...@@ -255,7 +259,8 @@ public class Client implements InputStub { ...@@ -255,7 +259,8 @@ public class Client implements InputStub {
return; return;
} }
nativeOnThirdPartyTokenFetched(mNativeJniClient, token, sharedSecret); ClientJni.get().onThirdPartyTokenFetched(
mNativeJniClient, Client.this, token, sharedSecret);
} }
// //
...@@ -288,7 +293,7 @@ public class Client implements InputStub { ...@@ -288,7 +293,7 @@ public class Client implements InputStub {
return; return;
} }
nativeSendExtensionMessage(mNativeJniClient, type, data); ClientJni.get().sendExtensionMessage(mNativeJniClient, Client.this, type, data);
} }
/** /**
...@@ -304,55 +309,57 @@ public class Client implements InputStub { ...@@ -304,55 +309,57 @@ public class Client implements InputStub {
return; return;
} }
nativeSendClientResolution(mNativeJniClient, dipsWidth, dipsHeight, density); ClientJni.get().sendClientResolution(
mNativeJniClient, Client.this, dipsWidth, dipsHeight, density);
} }
private native long nativeInit(); @NativeMethods
interface Natives {
private native void nativeDestroy(long nativeJniClient); long init(Client caller);
void destroy(long nativeJniClient, Client caller);
/** Performs the native portion of the connection. */ /** Performs the native portion of the connection. */
private native void nativeConnect(long nativeJniClient, String username, String authToken, void connect(long nativeJniClient, Client caller, String username, String authToken,
String hostJid, String hostFtlId, String hostId, String hostPubkey, String pairId, String hostJid, String hostFtlId, String hostId, String hostPubkey, String pairId,
String pairSecret, String capabilities, String flags, String hostVersion, String hostOs, String pairSecret, String capabilities, String flags, String hostVersion,
String hostOsVersion); String hostOs, String hostOsVersion);
/** Native implementation of Client.handleAuthenticationResponse(). */ /** Native implementation of Client.handleAuthenticationResponse(). */
private native void nativeAuthenticationResponse( void authenticationResponse(long nativeJniClient, Client caller, String pin,
long nativeJniClient, String pin, boolean createPair, String deviceName); boolean createPair, String deviceName);
/** Performs the native portion of the cleanup. */ /** Performs the native portion of the cleanup. */
private native void nativeDisconnect(long nativeJniClient); void disconnect(long nativeJniClient, Client caller);
/** Passes authentication data to the native handling code. */ /** Passes authentication data to the native handling code. */
private native void nativeOnThirdPartyTokenFetched( void onThirdPartyTokenFetched(
long nativeJniClient, String token, String sharedSecret); long nativeJniClient, Client caller, String token, String sharedSecret);
/** Passes mouse information to the native handling code. */ /** Passes mouse information to the native handling code. */
private native void nativeSendMouseEvent( void sendMouseEvent(long nativeJniClient, Client caller, int x, int y, int whichButton,
long nativeJniClient, int x, int y, int whichButton, boolean buttonDown); boolean buttonDown);
/** Passes mouse-wheel information to the native handling code. */ /** Passes mouse-wheel information to the native handling code. */
private native void nativeSendMouseWheelEvent(long nativeJniClient, int deltaX, int deltaY); void sendMouseWheelEvent(long nativeJniClient, Client caller, int deltaX, int deltaY);
/** Passes key press information to the native handling code. */ /** Passes key press information to the native handling code. */
private native boolean nativeSendKeyEvent( boolean sendKeyEvent(
long nativeJniClient, int scanCode, int keyCode, boolean keyDown); long nativeJniClient, Client caller, int scanCode, int keyCode, boolean keyDown);
/** Passes text event information to the native handling code. */ /** Passes text event information to the native handling code. */
private native void nativeSendTextEvent(long nativeJniClient, String text); void sendTextEvent(long nativeJniClient, Client caller, String text);
/** Passes touch event information to the native handling code. */ /** Passes touch event information to the native handling code. */
private native void nativeSendTouchEvent( void sendTouchEvent(
long nativeJniClient, int eventType, TouchEventData[] data); long nativeJniClient, Client caller, int eventType, TouchEventData[] data);
/** Native implementation of Client.enableVideoChannel() */ /** Native implementation of Client.enableVideoChannel() */
private native void nativeEnableVideoChannel(long nativeJniClient, boolean enable); void enableVideoChannel(long nativeJniClient, Client caller, boolean enable);
/** Passes extension message to the native code. */ /** Passes extension message to the native code. */
private native void nativeSendExtensionMessage(long nativeJniClient, String type, String data); void sendExtensionMessage(long nativeJniClient, Client caller, String type, String data);
/** Sends client resolution to the host. */ /** Sends client resolution to the host. */
private native void nativeSendClientResolution( void sendClientResolution(
long nativeJniClient, int dipsWidth, int dipsHeight, float scale); long nativeJniClient, Client caller, int dipsWidth, int dipsHeight, float scale);
}
} }
...@@ -11,6 +11,7 @@ import android.view.SurfaceHolder; ...@@ -11,6 +11,7 @@ import android.view.SurfaceHolder;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chromoting.DesktopView; import org.chromium.chromoting.DesktopView;
import org.chromium.chromoting.Event; import org.chromium.chromoting.Event;
import org.chromium.chromoting.InputFeedbackRadiusMapper; import org.chromium.chromoting.InputFeedbackRadiusMapper;
...@@ -55,7 +56,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub { ...@@ -55,7 +56,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
@Override @Override
public void surfaceCreated(SurfaceHolder holder) { public void surfaceCreated(SurfaceHolder holder) {
if (mNativeJniGlDisplay != 0) { if (mNativeJniGlDisplay != 0) {
nativeOnSurfaceCreated(mNativeJniGlDisplay, holder.getSurface()); GlDisplayJni.get().onSurfaceCreated(
mNativeJniGlDisplay, GlDisplay.this, holder.getSurface());
} }
} }
...@@ -69,7 +71,7 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub { ...@@ -69,7 +71,7 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
mOnClientSizeChanged.raise(new SizeChangedEventParameter(width, height)); mOnClientSizeChanged.raise(new SizeChangedEventParameter(width, height));
if (mNativeJniGlDisplay != 0) { if (mNativeJniGlDisplay != 0) {
nativeOnSurfaceChanged(mNativeJniGlDisplay, width, height); GlDisplayJni.get().onSurfaceChanged(mNativeJniGlDisplay, GlDisplay.this, width, height);
} }
} }
...@@ -79,7 +81,7 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub { ...@@ -79,7 +81,7 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
@Override @Override
public void surfaceDestroyed(SurfaceHolder holder) { public void surfaceDestroyed(SurfaceHolder holder) {
if (mNativeJniGlDisplay != 0) { if (mNativeJniGlDisplay != 0) {
nativeOnSurfaceDestroyed(mNativeJniGlDisplay); GlDisplayJni.get().onSurfaceDestroyed(mNativeJniGlDisplay, GlDisplay.this);
} }
} }
...@@ -98,7 +100,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub { ...@@ -98,7 +100,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
if (mNativeJniGlDisplay != 0) { if (mNativeJniGlDisplay != 0) {
float[] matrixArray = new float[9]; float[] matrixArray = new float[9];
matrix.getValues(matrixArray); matrix.getValues(matrixArray);
nativeOnPixelTransformationChanged(mNativeJniGlDisplay, matrixArray); GlDisplayJni.get().onPixelTransformationChanged(
mNativeJniGlDisplay, GlDisplay.this, matrixArray);
mScaleFactor = matrix.mapRadius(1); mScaleFactor = matrix.mapRadius(1);
} }
} }
...@@ -107,7 +110,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub { ...@@ -107,7 +110,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
@Override @Override
public void moveCursor(PointF position) { public void moveCursor(PointF position) {
if (mNativeJniGlDisplay != 0) { if (mNativeJniGlDisplay != 0) {
nativeOnCursorPixelPositionChanged(mNativeJniGlDisplay, position.x, position.y); GlDisplayJni.get().onCursorPixelPositionChanged(
mNativeJniGlDisplay, GlDisplay.this, position.x, position.y);
} }
} }
...@@ -117,7 +121,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub { ...@@ -117,7 +121,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
@Override @Override
public void setCursorVisibility(boolean visible) { public void setCursorVisibility(boolean visible) {
if (mNativeJniGlDisplay != 0) { if (mNativeJniGlDisplay != 0) {
nativeOnCursorVisibilityChanged(mNativeJniGlDisplay, visible); GlDisplayJni.get().onCursorVisibilityChanged(
mNativeJniGlDisplay, GlDisplay.this, visible);
} }
} }
...@@ -135,7 +140,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub { ...@@ -135,7 +140,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
if (diameter <= 0.0f) { if (diameter <= 0.0f) {
return; return;
} }
nativeOnCursorInputFeedback(mNativeJniGlDisplay, pos.x, pos.y, diameter); GlDisplayJni.get().onCursorInputFeedback(
mNativeJniGlDisplay, GlDisplay.this, pos.x, pos.y, diameter);
} }
@Override @Override
...@@ -183,16 +189,19 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub { ...@@ -183,16 +189,19 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
return new GlDisplay(nativeDisplayHandler); return new GlDisplay(nativeDisplayHandler);
} }
private native void nativeOnSurfaceCreated(long nativeJniGlDisplayHandler, Surface surface); @NativeMethods
private native void nativeOnSurfaceChanged(long nativeJniGlDisplayHandler, interface Natives {
int width, int height); void onSurfaceCreated(long nativeJniGlDisplayHandler, GlDisplay caller, Surface surface);
private native void nativeOnSurfaceDestroyed(long nativeJniGlDisplayHandler); void onSurfaceChanged(
private native void nativeOnPixelTransformationChanged(long nativeJniGlDisplayHandler, long nativeJniGlDisplayHandler, GlDisplay caller, int width, int height);
float[] matrix); void onSurfaceDestroyed(long nativeJniGlDisplayHandler, GlDisplay caller);
private native void nativeOnCursorPixelPositionChanged(long nativeJniGlDisplayHandler, void onPixelTransformationChanged(
float x, float y); long nativeJniGlDisplayHandler, GlDisplay caller, float[] matrix);
private native void nativeOnCursorInputFeedback(long nativeJniGlDisplayHandler, void onCursorPixelPositionChanged(
float x, float y, float diameter); long nativeJniGlDisplayHandler, GlDisplay caller, float x, float y);
private native void nativeOnCursorVisibilityChanged(long nativeJniGlDisplayHandler, void onCursorInputFeedback(
boolean visible); long nativeJniGlDisplayHandler, GlDisplay caller, float x, float y, float diameter);
void onCursorVisibilityChanged(
long nativeJniGlDisplayHandler, GlDisplay caller, boolean visible);
}
} }
...@@ -9,6 +9,7 @@ import android.content.Context; ...@@ -9,6 +9,7 @@ import android.content.Context;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
/** /**
* Initializes the Chromium remoting library, and provides JNI calls into it. * Initializes the Chromium remoting library, and provides JNI calls into it.
...@@ -33,9 +34,12 @@ public class JniInterface { ...@@ -33,9 +34,12 @@ public class JniInterface {
Log.w(TAG, "Couldn't load " + LIBRARY_NAME + ", trying " + LIBRARY_NAME + ".cr"); Log.w(TAG, "Couldn't load " + LIBRARY_NAME + ", trying " + LIBRARY_NAME + ".cr");
System.loadLibrary(LIBRARY_NAME + ".cr"); System.loadLibrary(LIBRARY_NAME + ".cr");
} }
nativeLoadNative(); JniInterfaceJni.get().loadNative();
} }
@NativeMethods
interface Natives {
/** Performs the native portion of the initialization. */ /** Performs the native portion of the initialization. */
private static native void nativeLoadNative(); void loadNative();
}
} }
...@@ -8,6 +8,7 @@ import org.chromium.base.ContextUtils; ...@@ -8,6 +8,7 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chromoting.Preconditions; import org.chromium.chromoting.Preconditions;
import org.chromium.chromoting.base.OAuthTokenFetcher; import org.chromium.chromoting.base.OAuthTokenFetcher;
import org.chromium.chromoting.base.OAuthTokenFetcher.Callback; import org.chromium.chromoting.base.OAuthTokenFetcher.Callback;
...@@ -46,7 +47,7 @@ public class JniOAuthTokenGetter { ...@@ -46,7 +47,7 @@ public class JniOAuthTokenGetter {
@Override @Override
public void onTokenFetched(String token) { public void onTokenFetched(String token) {
sLatestToken = token; sLatestToken = token;
nativeResolveOAuthTokenCallback( JniOAuthTokenGetterJni.get().resolveOAuthTokenCallback(
callbackPtr, OAuthTokenStatus.SUCCESS, sAccount, token); callbackPtr, OAuthTokenStatus.SUCCESS, sAccount, token);
} }
...@@ -67,7 +68,8 @@ public class JniOAuthTokenGetter { ...@@ -67,7 +68,8 @@ public class JniOAuthTokenGetter {
assert false : "Unreached"; assert false : "Unreached";
status = -1; status = -1;
} }
nativeResolveOAuthTokenCallback(callbackPtr, status, null, null); JniOAuthTokenGetterJni.get().resolveOAuthTokenCallback(
callbackPtr, status, null, null);
} }
}) })
.fetch(); .fetch();
...@@ -95,6 +97,9 @@ public class JniOAuthTokenGetter { ...@@ -95,6 +97,9 @@ public class JniOAuthTokenGetter {
.clearAndFetch(sLatestToken); .clearAndFetch(sLatestToken);
} }
private static native void nativeResolveOAuthTokenCallback( @NativeMethods
interface Natives {
void resolveOAuthTokenCallback(
long callbackPtr, int status, String userEmail, String accessToken); long callbackPtr, int status, String userEmail, String accessToken);
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment