Bug 913985: Part 1 - Introduce a nicer annotation API for the generator, and migrate all existing annotations to it. r=kats

--HG--
rename : mobile/android/base/mozglue/OptionalGeneratedParameter.java => mobile/android/base/mozglue/generatorannotations/OptionalGeneratedParameter.java
rename : mobile/android/base/mozglue/GeneratableAndroidBridgeTarget.java => mobile/android/base/mozglue/generatorannotations/WrapElementForJNI.java
This commit is contained in:
Chris Kitching 2013-11-12 10:40:59 -08:00
parent 0b39465cc3
commit d522296441
12 changed files with 135 additions and 104 deletions

View File

@ -10,10 +10,10 @@ import org.mozilla.gecko.gfx.BitmapUtils;
import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.LayerView;
import org.mozilla.gecko.gfx.PanZoomController;
import org.mozilla.gecko.mozglue.generatorannotations.OptionalGeneratedParameter;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import org.mozilla.gecko.prompts.PromptService;
import org.mozilla.gecko.mozglue.GeckoLoader;
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
import org.mozilla.gecko.mozglue.OptionalGeneratedParameter;
import org.mozilla.gecko.util.EventDispatcher;
import org.mozilla.gecko.util.GeckoEventListener;
import org.mozilla.gecko.util.HardwareUtils;
@ -402,14 +402,14 @@ public class GeckoAppShell
/*
* The Gecko-side API: API methods that Gecko calls
*/
@GeneratableAndroidBridgeTarget(generateStatic = true)
@WrapElementForJNI(generateStatic = true)
public static void notifyIME(int type) {
if (mEditableListener != null) {
mEditableListener.notifyIME(type);
}
}
@GeneratableAndroidBridgeTarget(generateStatic = true)
@WrapElementForJNI(generateStatic = true)
public static void notifyIMEContext(int state, String typeHint,
String modeHint, String actionHint) {
if (mEditableListener != null) {
@ -418,7 +418,7 @@ public class GeckoAppShell
}
}
@GeneratableAndroidBridgeTarget(generateStatic = true)
@WrapElementForJNI(generateStatic = true)
public static void notifyIMEChange(String text, int start, int end, int newEnd) {
if (newEnd < 0) { // Selection change
mEditableListener.onSelectionChange(start, end);
@ -462,7 +462,7 @@ public class GeckoAppShell
}
// Signal the Java thread that it's time to wake up
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void acknowledgeEvent() {
synchronized (sEventAckLock) {
sWaitingForEventAck = false;
@ -501,7 +501,7 @@ public class GeckoAppShell
return lastKnownLocation;
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void enableLocation(final boolean enable) {
ThreadUtils.postToUiThread(new Runnable() {
@Override
@ -557,12 +557,12 @@ public class GeckoAppShell
}
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void enableLocationHighAccuracy(final boolean enable) {
mLocationHighAccuracy = enable;
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void enableSensor(int aSensortype) {
GeckoInterface gi = getGeckoInterface();
if (gi == null)
@ -617,7 +617,7 @@ public class GeckoAppShell
}
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void disableSensor(int aSensortype) {
GeckoInterface gi = getGeckoInterface();
if (gi == null)
@ -661,7 +661,7 @@ public class GeckoAppShell
}
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void moveTaskToBack() {
if (getGeckoInterface() != null)
getGeckoInterface().getActivity().moveTaskToBack(true);
@ -672,7 +672,7 @@ public class GeckoAppShell
// Native Fennec doesn't care because the Java code already knows the selection indexes.
}
@GeneratableAndroidBridgeTarget(stubName = "NotifyXreExit")
@WrapElementForJNI(stubName = "NotifyXreExit")
static void onXreExit() {
// The launch state can only be Launched or GeckoRunning at this point
GeckoThread.setLaunchState(GeckoThread.LaunchState.GeckoExiting);
@ -688,7 +688,7 @@ public class GeckoAppShell
System.exit(0);
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
static void scheduleRestart() {
gRestartScheduled = true;
}
@ -731,7 +731,7 @@ public class GeckoAppShell
// "Installs" an application by creating a shortcut
// This is the entry point from AndroidBridge.h
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
static void createShortcut(String aTitle, String aURI, String aIconData, String aType) {
if ("webapp".equals(aType)) {
Log.w(LOGTAG, "createShortcut with no unique URI should not be used for aType = webapp!");
@ -926,7 +926,7 @@ public class GeckoAppShell
return bitmap;
}
@GeneratableAndroidBridgeTarget(stubName = "GetHandlersForMimeTypeWrapper")
@WrapElementForJNI(stubName = "GetHandlersForMimeTypeWrapper")
static String[] getHandlersForMimeType(String aMimeType, String aAction) {
Intent intent = getIntentForActionString(aAction);
if (aMimeType != null && aMimeType.length() > 0)
@ -934,7 +934,7 @@ public class GeckoAppShell
return getHandlersForIntent(intent);
}
@GeneratableAndroidBridgeTarget(stubName = "GetHandlersForURLWrapper")
@WrapElementForJNI(stubName = "GetHandlersForURLWrapper")
static String[] getHandlersForURL(String aURL, String aAction) {
// aURL may contain the whole URL or just the protocol
Uri uri = aURL.indexOf(':') >= 0 ? Uri.parse(aURL) : new Uri.Builder().scheme(aURL).build();
@ -977,12 +977,12 @@ public class GeckoAppShell
return new Intent(aAction);
}
@GeneratableAndroidBridgeTarget(stubName = "GetExtensionFromMimeTypeWrapper")
@WrapElementForJNI(stubName = "GetExtensionFromMimeTypeWrapper")
static String getExtensionFromMimeType(String aMimeType) {
return MimeTypeMap.getSingleton().getExtensionFromMimeType(aMimeType);
}
@GeneratableAndroidBridgeTarget(stubName = "GetMimeTypeFromExtensionsWrapper")
@WrapElementForJNI(stubName = "GetMimeTypeFromExtensionsWrapper")
static String getMimeTypeFromExtensions(String aFileExt) {
StringTokenizer st = new StringTokenizer(aFileExt, ".,; ");
String type = null;
@ -1115,7 +1115,7 @@ public class GeckoAppShell
* @param title the title to use in <code>ACTION_SEND</code> intents.
* @return true if the activity started successfully; false otherwise.
*/
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static boolean openUriExternal(String targetURI,
String mimeType,
@OptionalGeneratedParameter String packageName,
@ -1301,7 +1301,7 @@ public class GeckoAppShell
}
}
@GeneratableAndroidBridgeTarget(stubName = "ShowAlertNotificationWrapper")
@WrapElementForJNI(stubName = "ShowAlertNotificationWrapper")
public static void showAlertNotification(String aImageUrl, String aAlertTitle, String aAlertText,
String aAlertCookie, String aAlertName) {
// The intent to launch when the user clicks the expanded notification
@ -1328,13 +1328,13 @@ public class GeckoAppShell
sNotificationClient.add(notificationID, aImageUrl, aAlertTitle, aAlertText, contentIntent);
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void alertsProgressListener_OnProgress(String aAlertName, long aProgress, long aProgressMax, String aAlertText) {
int notificationID = aAlertName.hashCode();
sNotificationClient.update(notificationID, aProgress, aProgressMax, aAlertText);
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void closeNotification(String aAlertName) {
String alertCookie = mAlertCookies.get(aAlertName);
if (alertCookie != null) {
@ -1362,7 +1362,7 @@ public class GeckoAppShell
closeNotification(aAlertName);
}
@GeneratableAndroidBridgeTarget(stubName = "GetDpiWrapper")
@WrapElementForJNI(stubName = "GetDpiWrapper")
public static int getDpi() {
if (sDensityDpi == 0) {
sDensityDpi = getContext().getResources().getDisplayMetrics().densityDpi;
@ -1371,7 +1371,7 @@ public class GeckoAppShell
return sDensityDpi;
}
@GeneratableAndroidBridgeTarget()
@WrapElementForJNI
public static float getDensity() {
return getContext().getResources().getDisplayMetrics().density;
}
@ -1406,7 +1406,7 @@ public class GeckoAppShell
* Returns the colour depth of the default screen. This will either be
* 24 or 16.
*/
@GeneratableAndroidBridgeTarget(stubName = "GetScreenDepthWrapper")
@WrapElementForJNI(stubName = "GetScreenDepthWrapper")
public static synchronized int getScreenDepth() {
if (sScreenDepth == 0) {
sScreenDepth = 16;
@ -1429,27 +1429,27 @@ public class GeckoAppShell
sScreenDepth = aScreenDepth;
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void setFullScreen(boolean fullscreen) {
if (getGeckoInterface() != null)
getGeckoInterface().setFullScreen(fullscreen);
}
@GeneratableAndroidBridgeTarget(stubName = "ShowFilePickerForExtensionsWrapper")
@WrapElementForJNI(stubName = "ShowFilePickerForExtensionsWrapper")
public static String showFilePickerForExtensions(String aExtensions) {
if (getGeckoInterface() != null)
return sActivityHelper.showFilePicker(getGeckoInterface().getActivity(), getMimeTypeFromExtensions(aExtensions));
return "";
}
@GeneratableAndroidBridgeTarget(stubName = "ShowFilePickerForMimeTypeWrapper")
@WrapElementForJNI(stubName = "ShowFilePickerForMimeTypeWrapper")
public static String showFilePickerForMimeType(String aMimeType) {
if (getGeckoInterface() != null)
return sActivityHelper.showFilePicker(getGeckoInterface().getActivity(), aMimeType);
return "";
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void performHapticFeedback(boolean aIsLongPress) {
// Don't perform haptic feedback if a vibration is currently playing,
// because the haptic feedback will nuke the vibration.
@ -1466,14 +1466,14 @@ public class GeckoAppShell
return (Vibrator) layerView.getContext().getSystemService(Context.VIBRATOR_SERVICE);
}
@GeneratableAndroidBridgeTarget(stubName = "Vibrate1")
@WrapElementForJNI(stubName = "Vibrate1")
public static void vibrate(long milliseconds) {
sVibrationEndTime = System.nanoTime() + milliseconds * 1000000;
sVibrationMaybePlaying = true;
vibrator().vibrate(milliseconds);
}
@GeneratableAndroidBridgeTarget(stubName = "VibrateA")
@WrapElementForJNI(stubName = "VibrateA")
public static void vibrate(long[] pattern, int repeat) {
// If pattern.length is even, the last element in the pattern is a
// meaningless delay, so don't include it in vibrationDuration.
@ -1488,21 +1488,21 @@ public class GeckoAppShell
vibrator().vibrate(pattern, repeat);
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void cancelVibrate() {
sVibrationMaybePlaying = false;
sVibrationEndTime = 0;
vibrator().cancel();
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void showInputMethodPicker() {
InputMethodManager imm = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showInputMethodPicker();
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void setKeepScreenOn(final boolean on) {
ThreadUtils.postToUiThread(new Runnable() {
@Override
@ -1512,7 +1512,7 @@ public class GeckoAppShell
});
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void notifyDefaultPrevented(final boolean defaultPrevented) {
ThreadUtils.postToUiThread(new Runnable() {
@Override
@ -1526,7 +1526,7 @@ public class GeckoAppShell
});
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static boolean isNetworkLinkUp() {
ConnectivityManager cm = (ConnectivityManager)
getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
@ -1536,7 +1536,7 @@ public class GeckoAppShell
return true;
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static boolean isNetworkLinkKnown() {
ConnectivityManager cm = (ConnectivityManager)
getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
@ -1545,7 +1545,7 @@ public class GeckoAppShell
return true;
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static int networkLinkType() {
ConnectivityManager cm = (ConnectivityManager)
getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
@ -1604,7 +1604,7 @@ public class GeckoAppShell
}
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void setSelectedLocale(String localeCode) {
/* Bug 713464: This method is still called from Gecko side.
Earlier we had an option to run Firefox in a language other than system's language.
@ -1643,7 +1643,7 @@ public class GeckoAppShell
}
@GeneratableAndroidBridgeTarget(stubName = "GetSystemColoursWrapper")
@WrapElementForJNI(stubName = "GetSystemColoursWrapper")
public static int[] getSystemColors() {
// attrsAppearance[] must correspond to AndroidSystemColors structure in android/AndroidBridge.h
final int[] attrsAppearance = {
@ -1680,7 +1680,7 @@ public class GeckoAppShell
return result;
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void killAnyZombies() {
GeckoProcessesVisitor visitor = new GeckoProcessesVisitor() {
@Override
@ -1836,7 +1836,7 @@ public class GeckoAppShell
} catch (Exception e) { }
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void scanMedia(String aFile, String aMimeType) {
// If the platform didn't give us a mimetype, try to guess one from the filename
if (TextUtils.isEmpty(aMimeType)) {
@ -1850,7 +1850,7 @@ public class GeckoAppShell
GeckoMediaScannerClient.startScan(context, aFile, aMimeType);
}
@GeneratableAndroidBridgeTarget(stubName = "GetIconForExtensionWrapper")
@WrapElementForJNI(stubName = "GetIconForExtensionWrapper")
public static byte[] getIconForExtension(String aExt, int iconSize) {
try {
if (iconSize <= 0)
@ -1908,7 +1908,7 @@ public class GeckoAppShell
return activityInfo.loadIcon(pm);
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static boolean getShowPasswordSetting() {
try {
int showPassword =
@ -1921,7 +1921,7 @@ public class GeckoAppShell
}
}
@GeneratableAndroidBridgeTarget(stubName = "AddPluginViewWrapper")
@WrapElementForJNI(stubName = "AddPluginViewWrapper")
public static void addPluginView(View view,
float x, float y,
float w, float h,
@ -1930,7 +1930,7 @@ public class GeckoAppShell
getGeckoInterface().addPluginView(view, new RectF(x, y, x + w, y + h), isFullScreen);
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void removePluginView(View view, boolean isFullScreen) {
if (getGeckoInterface() != null)
getGeckoInterface().removePluginView(view, isFullScreen);
@ -2154,7 +2154,7 @@ public class GeckoAppShell
private static ContextGetter sContextGetter;
@GeneratableAndroidBridgeTarget(allowMultithread = true)
@WrapElementForJNI(allowMultithread = true)
public static Context getContext() {
return sContextGetter.getContext();
}
@ -2212,7 +2212,7 @@ public class GeckoAppShell
static byte[] sCameraBuffer = null;
@GeneratableAndroidBridgeTarget(stubName = "InitCameraWrapper")
@WrapElementForJNI(stubName = "InitCameraWrapper")
static int[] initCamera(String aContentType, int aCamera, int aWidth, int aHeight) {
ThreadUtils.postToUiThread(new Runnable() {
@Override
@ -2313,7 +2313,7 @@ public class GeckoAppShell
return result;
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
static synchronized void closeCamera() {
ThreadUtils.postToUiThread(new Runnable() {
@Override
@ -2365,32 +2365,32 @@ public class GeckoAppShell
/*
* Battery API related methods.
*/
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void enableBatteryNotifications() {
GeckoBatteryManager.enableNotifications();
}
@GeneratableAndroidBridgeTarget(stubName = "HandleGeckoMessageWrapper")
@WrapElementForJNI(stubName = "HandleGeckoMessageWrapper")
public static String handleGeckoMessage(String message) {
return sEventDispatcher.dispatchEvent(message);
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void disableBatteryNotifications() {
GeckoBatteryManager.disableNotifications();
}
@GeneratableAndroidBridgeTarget(stubName = "GetCurrentBatteryInformationWrapper")
@WrapElementForJNI(stubName = "GetCurrentBatteryInformationWrapper")
public static double[] getCurrentBatteryInformation() {
return GeckoBatteryManager.getCurrentInformation();
}
@GeneratableAndroidBridgeTarget(stubName = "CheckURIVisited")
@WrapElementForJNI(stubName = "CheckURIVisited")
static void checkUriVisited(String uri) {
GlobalHistory.getInstance().checkUriVisited(uri);
}
@GeneratableAndroidBridgeTarget(stubName = "MarkURIVisited")
@WrapElementForJNI(stubName = "MarkURIVisited")
static void markUriVisited(final String uri) {
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
@ -2400,7 +2400,7 @@ public class GeckoAppShell
});
}
@GeneratableAndroidBridgeTarget(stubName = "SetURITitle")
@WrapElementForJNI(stubName = "SetURITitle")
static void setUriTitle(final String uri, final String title) {
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
@ -2410,7 +2410,7 @@ public class GeckoAppShell
});
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
static void hideProgressDialog() {
// unused stub
}
@ -2418,7 +2418,7 @@ public class GeckoAppShell
/*
* WebSMS related methods.
*/
@GeneratableAndroidBridgeTarget(stubName = "SendMessageWrapper")
@WrapElementForJNI(stubName = "SendMessageWrapper")
public static void sendMessage(String aNumber, String aMessage, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
@ -2427,7 +2427,7 @@ public class GeckoAppShell
SmsManager.getInstance().send(aNumber, aMessage, aRequestId);
}
@GeneratableAndroidBridgeTarget(stubName = "GetMessageWrapper")
@WrapElementForJNI(stubName = "GetMessageWrapper")
public static void getMessage(int aMessageId, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
@ -2436,7 +2436,7 @@ public class GeckoAppShell
SmsManager.getInstance().getMessage(aMessageId, aRequestId);
}
@GeneratableAndroidBridgeTarget(stubName = "DeleteMessageWrapper")
@WrapElementForJNI(stubName = "DeleteMessageWrapper")
public static void deleteMessage(int aMessageId, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
@ -2445,7 +2445,7 @@ public class GeckoAppShell
SmsManager.getInstance().deleteMessage(aMessageId, aRequestId);
}
@GeneratableAndroidBridgeTarget(stubName = "CreateMessageListWrapper")
@WrapElementForJNI(stubName = "CreateMessageListWrapper")
public static void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
@ -2454,7 +2454,7 @@ public class GeckoAppShell
SmsManager.getInstance().createMessageList(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId);
}
@GeneratableAndroidBridgeTarget(stubName = "GetNextMessageInListWrapper")
@WrapElementForJNI(stubName = "GetNextMessageInListWrapper")
public static void getNextMessageInList(int aListId, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
@ -2463,7 +2463,7 @@ public class GeckoAppShell
SmsManager.getInstance().getNextMessageInList(aListId, aRequestId);
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void clearMessageList(int aListId) {
if (SmsManager.getInstance() == null) {
return;
@ -2473,7 +2473,7 @@ public class GeckoAppShell
}
/* Called by JNI from AndroidBridge, and by reflection from tests/BaseTest.java.in */
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static boolean isTablet() {
return HardwareUtils.isTablet();
}
@ -2486,17 +2486,17 @@ public class GeckoAppShell
}
}
@GeneratableAndroidBridgeTarget(stubName = "GetCurrentNetworkInformationWrapper")
@WrapElementForJNI(stubName = "GetCurrentNetworkInformationWrapper")
public static double[] getCurrentNetworkInformation() {
return GeckoNetworkManager.getInstance().getCurrentInformation();
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void enableNetworkNotifications() {
GeckoNetworkManager.getInstance().enableNotifications();
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void disableNetworkNotifications() {
GeckoNetworkManager.getInstance().disableNotifications();
}
@ -2610,32 +2610,32 @@ public class GeckoAppShell
return decodeBase64(s.getBytes(), flags);
}
@GeneratableAndroidBridgeTarget(stubName = "GetScreenOrientationWrapper")
@WrapElementForJNI(stubName = "GetScreenOrientationWrapper")
public static short getScreenOrientation() {
return GeckoScreenOrientationListener.getInstance().getScreenOrientation();
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void enableScreenOrientationNotifications() {
GeckoScreenOrientationListener.getInstance().enableNotifications();
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void disableScreenOrientationNotifications() {
GeckoScreenOrientationListener.getInstance().disableNotifications();
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void lockScreenOrientation(int aOrientation) {
GeckoScreenOrientationListener.getInstance().lockScreenOrientation(aOrientation);
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void unlockScreenOrientation() {
GeckoScreenOrientationListener.getInstance().unlockScreenOrientation();
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static boolean pumpMessageLoop() {
Handler geckoHandler = ThreadUtils.sGeckoHandler;
Message msg = getNextMessageFromQueue(ThreadUtils.sGeckoQueue);
@ -2657,7 +2657,7 @@ public class GeckoAppShell
static native void notifyFilePickerResult(String filePath, long id);
@GeneratableAndroidBridgeTarget(stubName = "ShowFilePickerAsyncWrapper")
@WrapElementForJNI(stubName = "ShowFilePickerAsyncWrapper")
public static void showFilePickerAsync(String aMimeType, final long id) {
sActivityHelper.showFilePickerAsync(getGeckoInterface().getActivity(), aMimeType, new ActivityHandlerHelper.FileResultHandler() {
public void gotFile(String filename) {
@ -2666,13 +2666,13 @@ public class GeckoAppShell
});
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void notifyWakeLockChanged(String topic, String state) {
if (getGeckoInterface() != null)
getGeckoInterface().notifyWakeLockChanged(topic, state);
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static void registerSurfaceTextureFrameListener(Object surfaceTexture, final int id) {
((SurfaceTexture)surfaceTexture).setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
@Override
@ -2682,12 +2682,12 @@ public class GeckoAppShell
});
}
@GeneratableAndroidBridgeTarget(allowMultithread = true)
@WrapElementForJNI(allowMultithread = true)
public static void unregisterSurfaceTextureFrameListener(Object surfaceTexture) {
((SurfaceTexture)surfaceTexture).setOnFrameAvailableListener(null);
}
@GeneratableAndroidBridgeTarget
@WrapElementForJNI
public static boolean unlockProfile() {
// Try to kill any zombie Fennec's that might be running
GeckoAppShell.killAnyZombies();
@ -2701,7 +2701,7 @@ public class GeckoAppShell
return false;
}
@GeneratableAndroidBridgeTarget(stubName = "GetProxyForURIWrapper")
@WrapElementForJNI(stubName = "GetProxyForURIWrapper")
public static String getProxyForURI(String spec, String scheme, String host, int port) {
URI uri = null;
try {

View File

@ -8,7 +8,7 @@ package org.mozilla.gecko;
import android.os.SystemClock;
import android.util.Log;
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import java.lang.Thread;
import java.util.HashMap;
@ -126,7 +126,7 @@ public class GeckoJavaSampler {
}
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "GetThreadNameJavaProfilingWrapper")
@WrapElementForJNI(allowMultithread = true, stubName = "GetThreadNameJavaProfilingWrapper")
public synchronized static String getThreadName(int aThreadId) {
if (aThreadId == 0 && sMainThread != null) {
return sMainThread.getName();
@ -138,7 +138,7 @@ public class GeckoJavaSampler {
return sSamplingRunnable.getSample(aThreadId, aSampleId);
}
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "GetSampleTimeJavaProfiling")
@WrapElementForJNI(allowMultithread = true, stubName = "GetSampleTimeJavaProfiling")
public synchronized static double getSampleTime(int aThreadId, int aSampleId) {
Sample sample = getSample(aThreadId, aSampleId);
if (sample != null) {
@ -152,7 +152,7 @@ public class GeckoJavaSampler {
return 0;
}
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "GetFrameNameJavaProfilingWrapper")
@WrapElementForJNI(allowMultithread = true, stubName = "GetFrameNameJavaProfilingWrapper")
public synchronized static String getFrameName(int aThreadId, int aSampleId, int aFrameId) {
Sample sample = getSample(aThreadId, aSampleId);
if (sample != null && aFrameId < sample.mFrames.length) {
@ -165,7 +165,7 @@ public class GeckoJavaSampler {
return null;
}
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "StartJavaProfiling")
@WrapElementForJNI(allowMultithread = true, stubName = "StartJavaProfiling")
public static void start(int aInterval, int aSamples) {
synchronized (GeckoJavaSampler.class) {
if (sSamplingRunnable != null) {
@ -177,21 +177,21 @@ public class GeckoJavaSampler {
}
}
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "PauseJavaProfiling")
@WrapElementForJNI(allowMultithread = true, stubName = "PauseJavaProfiling")
public static void pause() {
synchronized (GeckoJavaSampler.class) {
sSamplingRunnable.mPauseSampler = true;
}
}
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "UnpauseJavaProfiling")
@WrapElementForJNI(allowMultithread = true, stubName = "UnpauseJavaProfiling")
public static void unpause() {
synchronized (GeckoJavaSampler.class) {
sSamplingRunnable.mPauseSampler = false;
}
}
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "StopJavaProfiling")
@WrapElementForJNI(allowMultithread = true, stubName = "StopJavaProfiling")
public static void stop() {
synchronized (GeckoJavaSampler.class) {
if (sSamplingThread == null) {

View File

@ -9,7 +9,7 @@ import org.mozilla.gecko.db.BrowserDB;
import org.mozilla.gecko.gfx.BitmapUtils;
import org.mozilla.gecko.gfx.IntSize;
import org.mozilla.gecko.mozglue.DirectBufferAllocator;
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import android.graphics.Bitmap;
import android.util.Log;
@ -151,7 +151,7 @@ public final class ThumbnailHelper {
}
/* This method is invoked by JNI once the thumbnail data is ready. */
@GeneratableAndroidBridgeTarget(stubName = "SendThumbnail")
@WrapElementForJNI(stubName = "SendThumbnail")
public static void notifyThumbnail(ByteBuffer data, int tabId, boolean success) {
Tab tab = Tabs.getInstance().getTab(tabId);
ThumbnailHelper helper = ThumbnailHelper.getInstance();

View File

@ -8,7 +8,7 @@ package org.mozilla.gecko.gfx;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.GeckoThread;
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import org.mozilla.gecko.util.ThreadUtils;
import android.util.Log;
@ -215,7 +215,7 @@ public class GLController {
throw new GLControllerException("No suitable EGL configuration found");
}
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "CreateEGLSurfaceForCompositorWrapper")
@WrapElementForJNI(allowMultithread = true, stubName = "CreateEGLSurfaceForCompositorWrapper")
private EGLSurface createEGLSurfaceForCompositor() {
initEGL();
return mEGL.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, mView.getNativeWindow(), null);

View File

@ -14,7 +14,7 @@ import org.mozilla.gecko.Tab;
import org.mozilla.gecko.Tabs;
import org.mozilla.gecko.TouchEventInterceptor;
import org.mozilla.gecko.ZoomConstraints;
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import org.mozilla.gecko.util.EventDispatcher;
import android.content.Context;
@ -562,7 +562,7 @@ public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener
return mTextureView.getSurfaceTexture();
}
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "RegisterCompositorWrapper")
@WrapElementForJNI(allowMultithread = true, stubName = "RegisterCompositorWrapper")
public static GLController registerCxxCompositor() {
try {
LayerView layerView = GeckoAppShell.getLayerView();

View File

@ -7,7 +7,7 @@ package org.mozilla.gecko.gfx;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.GeckoThread;
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import org.mozilla.gecko.util.EventDispatcher;
import org.mozilla.gecko.util.GeckoEventListener;
@ -83,12 +83,12 @@ class NativePanZoomController implements PanZoomController, GeckoEventListener {
public native void setOverScrollMode(int overscrollMode);
public native int getOverScrollMode();
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "RequestContentRepaintWrapper")
@WrapElementForJNI(allowMultithread = true, stubName = "RequestContentRepaintWrapper")
private void requestContentRepaint(float x, float y, float width, float height, float resolution) {
mTarget.forceRedraw(new DisplayPortMetrics(x, y, x + width, y + height, resolution));
}
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "PostDelayedCallbackWrapper")
@WrapElementForJNI(allowMultithread = true, stubName = "PostDelayedCallbackWrapper")
private void postDelayedCallback(long delay) {
mTarget.postDelayed(mCallbackRunnable, delay);
}

View File

@ -14,10 +14,12 @@ mgjar = add_java_jar('gecko-mozglue')
mgjar.sources += [
'mozglue/ByteBufferInputStream.java',
'mozglue/DirectBufferAllocator.java',
'mozglue/GeneratableAndroidBridgeTarget.java',
'mozglue/generatorannotations/GeneratorOptions.java',
'mozglue/generatorannotations/OptionalGeneratedParameter.java',
'mozglue/generatorannotations/WrapElementForJNI.java',
'mozglue/generatorannotations/WrapEntireClassForJNI.java',
'mozglue/NativeReference.java',
'mozglue/NativeZip.java',
'mozglue/OptionalGeneratedParameter.java',
]
mgjar.generated_sources += [
'org/mozilla/gecko/mozglue/GeckoLoader.java',

View File

@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.mozglue.generatorannotations;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface GeneratorOptions {
// Specifies a custom name for the generated C++ class. If left empty, is AndroidJavaClassName.
String generatedClassName() default "";
}

View File

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.mozglue;
package org.mozilla.gecko.mozglue.generatorannotations;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

View File

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.mozglue;
package org.mozilla.gecko.mozglue.generatorannotations;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@ -21,7 +21,7 @@ import java.lang.annotation.RetentionPolicy;
* and may lead to subtle bugs.
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface GeneratableAndroidBridgeTarget {
public @interface WrapElementForJNI {
// Optional parameter specifying the name of the generated method stub. If omitted, the name
// of the Java method will be used.
String stubName() default "";

View File

@ -0,0 +1,15 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.mozglue.generatorannotations;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Handy shortcut annotation. Functionally equivalent to tagging every member individually with default
* settings.
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface WrapEntireClassForJNI {}

View File

@ -9,7 +9,7 @@ import android.content.Context;
import android.os.Build;
import android.util.Log;
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import java.util.concurrent.SynchronousQueue;
@ -29,7 +29,7 @@ public final class Clipboard {
mContext = c;
}
@GeneratableAndroidBridgeTarget(stubName = "GetClipboardTextWrapper")
@WrapElementForJNI(stubName = "GetClipboardTextWrapper")
public static String getText() {
// If we're on the UI thread or the background thread, we have a looper on the thread
// and can just call this directly. For any other threads, post the call to the
@ -55,7 +55,7 @@ public final class Clipboard {
}
}
@GeneratableAndroidBridgeTarget(stubName = "SetClipboardText")
@WrapElementForJNI(stubName = "SetClipboardText")
public static void setText(final CharSequence text) {
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override