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;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chromoting.CapabilityManager;
import org.chromium.chromoting.InputStub;
import org.chromium.chromoting.Preconditions;
......@@ -36,14 +37,14 @@ public class Client implements InputStub {
}
sClient = this;
mNativeJniClient = nativeInit();
mNativeJniClient = ClientJni.get().init(Client.this);
}
// Suppress FindBugs warning, since |sClient| is only used on the UI thread.
public void destroy() {
if (sClient != null) {
disconnectFromHost();
nativeDestroy(mNativeJniClient);
ClientJni.get().destroy(mNativeJniClient, Client.this);
sClient = null;
}
}
......@@ -92,10 +93,10 @@ public class Client implements InputStub {
mConnectionListener = listener;
mAuthenticator = authenticator;
nativeConnect(mNativeJniClient, username, authToken, hostJid, hostFtlId, hostId, hostPubkey,
mAuthenticator.getPairingId(hostId), mAuthenticator.getPairingSecret(hostId),
mCapabilityManager.getLocalCapabilities(), flags, hostVersion, hostOs,
hostOsVersion);
ClientJni.get().connect(mNativeJniClient, Client.this, username, authToken, hostJid,
hostFtlId, hostId, hostPubkey, mAuthenticator.getPairingId(hostId),
mAuthenticator.getPairingSecret(hostId), mCapabilityManager.getLocalCapabilities(),
flags, hostVersion, hostOs, hostOsVersion);
mConnected = true;
}
......@@ -117,7 +118,7 @@ public class Client implements InputStub {
return;
}
nativeDisconnect(mNativeJniClient);
ClientJni.get().disconnect(mNativeJniClient, Client.this);
mConnectionListener = null;
mConnected = false;
mCapabilityManager.onHostDisconnect();
......@@ -157,7 +158,8 @@ public class Client implements InputStub {
public void handleAuthenticationResponse(
String pin, boolean createPair, String deviceName) {
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 {
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. */
......@@ -187,7 +190,7 @@ public class Client implements InputStub {
return;
}
nativeSendMouseWheelEvent(mNativeJniClient, deltaX, deltaY);
ClientJni.get().sendMouseWheelEvent(mNativeJniClient, Client.this, deltaX, deltaY);
}
/**
......@@ -200,7 +203,8 @@ public class Client implements InputStub {
return false;
}
return nativeSendKeyEvent(mNativeJniClient, scanCode, keyCode, keyDown);
return ClientJni.get().sendKeyEvent(
mNativeJniClient, Client.this, scanCode, keyCode, keyDown);
}
/** Sends TextEvent to the host. */
......@@ -210,7 +214,7 @@ public class Client implements InputStub {
return;
}
nativeSendTextEvent(mNativeJniClient, text);
ClientJni.get().sendTextEvent(mNativeJniClient, Client.this, text);
}
/** Sends an array of TouchEvents to the host. */
......@@ -220,7 +224,7 @@ public class Client implements InputStub {
return;
}
nativeSendTouchEvent(mNativeJniClient, eventType, data);
ClientJni.get().sendTouchEvent(mNativeJniClient, Client.this, eventType, data);
}
/**
......@@ -231,7 +235,7 @@ public class Client implements InputStub {
return;
}
nativeEnableVideoChannel(mNativeJniClient, enable);
ClientJni.get().enableVideoChannel(mNativeJniClient, Client.this, enable);
}
//
......@@ -255,7 +259,8 @@ public class Client implements InputStub {
return;
}
nativeOnThirdPartyTokenFetched(mNativeJniClient, token, sharedSecret);
ClientJni.get().onThirdPartyTokenFetched(
mNativeJniClient, Client.this, token, sharedSecret);
}
//
......@@ -288,7 +293,7 @@ public class Client implements InputStub {
return;
}
nativeSendExtensionMessage(mNativeJniClient, type, data);
ClientJni.get().sendExtensionMessage(mNativeJniClient, Client.this, type, data);
}
/**
......@@ -304,55 +309,57 @@ public class Client implements InputStub {
return;
}
nativeSendClientResolution(mNativeJniClient, dipsWidth, dipsHeight, density);
ClientJni.get().sendClientResolution(
mNativeJniClient, Client.this, dipsWidth, dipsHeight, density);
}
private native long nativeInit();
private native void nativeDestroy(long nativeJniClient);
@NativeMethods
interface Natives {
long init(Client caller);
void destroy(long nativeJniClient, Client caller);
/** 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 pairSecret, String capabilities, String flags, String hostVersion, String hostOs,
String hostOsVersion);
String pairSecret, String capabilities, String flags, String hostVersion,
String hostOs, String hostOsVersion);
/** Native implementation of Client.handleAuthenticationResponse(). */
private native void nativeAuthenticationResponse(
long nativeJniClient, String pin, boolean createPair, String deviceName);
void authenticationResponse(long nativeJniClient, Client caller, String pin,
boolean createPair, String deviceName);
/** 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. */
private native void nativeOnThirdPartyTokenFetched(
long nativeJniClient, String token, String sharedSecret);
void onThirdPartyTokenFetched(
long nativeJniClient, Client caller, 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);
void sendMouseEvent(long nativeJniClient, Client caller, 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);
void sendMouseWheelEvent(long nativeJniClient, Client caller, 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);
boolean sendKeyEvent(
long nativeJniClient, Client caller, int scanCode, int keyCode, boolean keyDown);
/** 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. */
private native void nativeSendTouchEvent(
long nativeJniClient, int eventType, TouchEventData[] data);
void sendTouchEvent(
long nativeJniClient, Client caller, int eventType, TouchEventData[] data);
/** 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. */
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. */
private native void nativeSendClientResolution(
long nativeJniClient, int dipsWidth, int dipsHeight, float scale);
void sendClientResolution(
long nativeJniClient, Client caller, int dipsWidth, int dipsHeight, float scale);
}
}
......@@ -11,6 +11,7 @@ import android.view.SurfaceHolder;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chromoting.DesktopView;
import org.chromium.chromoting.Event;
import org.chromium.chromoting.InputFeedbackRadiusMapper;
......@@ -55,7 +56,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
@Override
public void surfaceCreated(SurfaceHolder holder) {
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 {
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
mOnClientSizeChanged.raise(new SizeChangedEventParameter(width, height));
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 {
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
if (mNativeJniGlDisplay != 0) {
nativeOnSurfaceDestroyed(mNativeJniGlDisplay);
GlDisplayJni.get().onSurfaceDestroyed(mNativeJniGlDisplay, GlDisplay.this);
}
}
......@@ -98,7 +100,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
if (mNativeJniGlDisplay != 0) {
float[] matrixArray = new float[9];
matrix.getValues(matrixArray);
nativeOnPixelTransformationChanged(mNativeJniGlDisplay, matrixArray);
GlDisplayJni.get().onPixelTransformationChanged(
mNativeJniGlDisplay, GlDisplay.this, matrixArray);
mScaleFactor = matrix.mapRadius(1);
}
}
......@@ -107,7 +110,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
@Override
public void moveCursor(PointF position) {
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 {
@Override
public void setCursorVisibility(boolean visible) {
if (mNativeJniGlDisplay != 0) {
nativeOnCursorVisibilityChanged(mNativeJniGlDisplay, visible);
GlDisplayJni.get().onCursorVisibilityChanged(
mNativeJniGlDisplay, GlDisplay.this, visible);
}
}
......@@ -135,7 +140,8 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
if (diameter <= 0.0f) {
return;
}
nativeOnCursorInputFeedback(mNativeJniGlDisplay, pos.x, pos.y, diameter);
GlDisplayJni.get().onCursorInputFeedback(
mNativeJniGlDisplay, GlDisplay.this, pos.x, pos.y, diameter);
}
@Override
......@@ -183,16 +189,19 @@ public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
return new GlDisplay(nativeDisplayHandler);
}
private native void nativeOnSurfaceCreated(long nativeJniGlDisplayHandler, Surface surface);
private native void nativeOnSurfaceChanged(long nativeJniGlDisplayHandler,
int width, int height);
private native void nativeOnSurfaceDestroyed(long nativeJniGlDisplayHandler);
private native void nativeOnPixelTransformationChanged(long nativeJniGlDisplayHandler,
float[] matrix);
private native void nativeOnCursorPixelPositionChanged(long nativeJniGlDisplayHandler,
float x, float y);
private native void nativeOnCursorInputFeedback(long nativeJniGlDisplayHandler,
float x, float y, float diameter);
private native void nativeOnCursorVisibilityChanged(long nativeJniGlDisplayHandler,
boolean visible);
@NativeMethods
interface Natives {
void onSurfaceCreated(long nativeJniGlDisplayHandler, GlDisplay caller, Surface surface);
void onSurfaceChanged(
long nativeJniGlDisplayHandler, GlDisplay caller, int width, int height);
void onSurfaceDestroyed(long nativeJniGlDisplayHandler, GlDisplay caller);
void onPixelTransformationChanged(
long nativeJniGlDisplayHandler, GlDisplay caller, float[] matrix);
void onCursorPixelPositionChanged(
long nativeJniGlDisplayHandler, GlDisplay caller, float x, float y);
void onCursorInputFeedback(
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;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
/**
* Initializes the Chromium remoting library, and provides JNI calls into it.
......@@ -33,9 +34,12 @@ public class JniInterface {
Log.w(TAG, "Couldn't load " + LIBRARY_NAME + ", trying " + LIBRARY_NAME + ".cr");
System.loadLibrary(LIBRARY_NAME + ".cr");
}
nativeLoadNative();
JniInterfaceJni.get().loadNative();
}
@NativeMethods
interface Natives {
/** Performs the native portion of the initialization. */
private static native void nativeLoadNative();
void loadNative();
}
}
......@@ -8,6 +8,7 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chromoting.Preconditions;
import org.chromium.chromoting.base.OAuthTokenFetcher;
import org.chromium.chromoting.base.OAuthTokenFetcher.Callback;
......@@ -46,7 +47,7 @@ public class JniOAuthTokenGetter {
@Override
public void onTokenFetched(String token) {
sLatestToken = token;
nativeResolveOAuthTokenCallback(
JniOAuthTokenGetterJni.get().resolveOAuthTokenCallback(
callbackPtr, OAuthTokenStatus.SUCCESS, sAccount, token);
}
......@@ -67,7 +68,8 @@ public class JniOAuthTokenGetter {
assert false : "Unreached";
status = -1;
}
nativeResolveOAuthTokenCallback(callbackPtr, status, null, null);
JniOAuthTokenGetterJni.get().resolveOAuthTokenCallback(
callbackPtr, status, null, null);
}
})
.fetch();
......@@ -95,6 +97,9 @@ public class JniOAuthTokenGetter {
.clearAndFetch(sLatestToken);
}
private static native void nativeResolveOAuthTokenCallback(
@NativeMethods
interface Natives {
void resolveOAuthTokenCallback(
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