// GENERATED CODE
// Generated by the Java program at /build/annotationProcessors at compile time from
// annotations on Java methods. To update, change the annotations on the corresponding Java
// methods and rerun the build. Manually updating this file will cause your build to fail.

#include "GeneratedJNIWrappers.h"
#include "AndroidBridgeUtilities.h"
#include "nsXPCOMStrings.h"
#include "AndroidBridge.h"

namespace mozilla {
namespace widget {
namespace android {
jclass GeckoAppShell::mGeckoAppShellClass = 0;
jmethodID GeckoAppShell::jAcknowledgeEvent = 0;
jmethodID GeckoAppShell::jAddPluginViewWrapper = 0;
jmethodID GeckoAppShell::jAlertsProgressListener_OnProgress = 0;
jmethodID GeckoAppShell::jCancelVibrate = 0;
jmethodID GeckoAppShell::jCheckURIVisited = 0;
jmethodID GeckoAppShell::jClearMessageList = 0;
jmethodID GeckoAppShell::jCloseCamera = 0;
jmethodID GeckoAppShell::jCloseNotification = 0;
jmethodID GeckoAppShell::jConnectionGetMimeType = 0;
jmethodID GeckoAppShell::jCreateInputStream = 0;
jmethodID GeckoAppShell::jCreateMessageListWrapper = 0;
jmethodID GeckoAppShell::jCreateShortcut = 0;
jmethodID GeckoAppShell::jDeleteMessageWrapper = 0;
jmethodID GeckoAppShell::jDisableBatteryNotifications = 0;
jmethodID GeckoAppShell::jDisableNetworkNotifications = 0;
jmethodID GeckoAppShell::jDisableScreenOrientationNotifications = 0;
jmethodID GeckoAppShell::jDisableSensor = 0;
jmethodID GeckoAppShell::jEnableBatteryNotifications = 0;
jmethodID GeckoAppShell::jEnableLocation = 0;
jmethodID GeckoAppShell::jEnableLocationHighAccuracy = 0;
jmethodID GeckoAppShell::jEnableNetworkNotifications = 0;
jmethodID GeckoAppShell::jEnableScreenOrientationNotifications = 0;
jmethodID GeckoAppShell::jEnableSensor = 0;
jmethodID GeckoAppShell::jGamepadAdded = 0;
jmethodID GeckoAppShell::jGetConnection = 0;
jmethodID GeckoAppShell::jGetContext = 0;
jmethodID GeckoAppShell::jGetCurrentBatteryInformationWrapper = 0;
jmethodID GeckoAppShell::jGetCurrentNetworkInformationWrapper = 0;
jmethodID GeckoAppShell::jGetDensity = 0;
jmethodID GeckoAppShell::jGetDpiWrapper = 0;
jmethodID GeckoAppShell::jGetExtensionFromMimeTypeWrapper = 0;
jmethodID GeckoAppShell::jGetExternalPublicDirectory = 0;
jmethodID GeckoAppShell::jGetHandlersForMimeTypeWrapper = 0;
jmethodID GeckoAppShell::jGetHandlersForURLWrapper = 0;
jmethodID GeckoAppShell::jGetIconForExtensionWrapper = 0;
jmethodID GeckoAppShell::jGetMessageWrapper = 0;
jmethodID GeckoAppShell::jGetMimeTypeFromExtensionsWrapper = 0;
jmethodID GeckoAppShell::jGetNextMessageInListWrapper = 0;
jmethodID GeckoAppShell::jGetProxyForURIWrapper = 0;
jmethodID GeckoAppShell::jGetScreenDepthWrapper = 0;
jmethodID GeckoAppShell::jGetScreenOrientationWrapper = 0;
jmethodID GeckoAppShell::jGetShowPasswordSetting = 0;
jmethodID GeckoAppShell::jGetSystemColoursWrapper = 0;
jmethodID GeckoAppShell::jGetUserRestrictions = 0;
jmethodID GeckoAppShell::jHandleGeckoMessageWrapper = 0;
jmethodID GeckoAppShell::jHandleUncaughtException = 0;
jmethodID GeckoAppShell::jHideProgressDialog = 0;
jmethodID GeckoAppShell::jInitCameraWrapper = 0;
jmethodID GeckoAppShell::jIsNetworkLinkKnown = 0;
jmethodID GeckoAppShell::jIsNetworkLinkUp = 0;
jmethodID GeckoAppShell::jIsTablet = 0;
jmethodID GeckoAppShell::jIsUserRestricted = 0;
jmethodID GeckoAppShell::jKillAnyZombies = 0;
jmethodID GeckoAppShell::jLoadPluginClass = 0;
jmethodID GeckoAppShell::jLockScreenOrientation = 0;
jmethodID GeckoAppShell::jMarkURIVisited = 0;
jmethodID GeckoAppShell::jMoveTaskToBack = 0;
jmethodID GeckoAppShell::jNetworkLinkType = 0;
jmethodID GeckoAppShell::jNotifyDefaultPrevented = 0;
jmethodID GeckoAppShell::jNotifyIME = 0;
jmethodID GeckoAppShell::jNotifyIMEChange = 0;
jmethodID GeckoAppShell::jNotifyIMEContext = 0;
jmethodID GeckoAppShell::jNotifyWakeLockChanged = 0;
jmethodID GeckoAppShell::jNotifyXreExit = 0;
jmethodID GeckoAppShell::jOpenUriExternal = 0;
jmethodID GeckoAppShell::jPerformHapticFeedback = 0;
jmethodID GeckoAppShell::jPumpMessageLoop = 0;
jmethodID GeckoAppShell::jRegisterSurfaceTextureFrameListener = 0;
jmethodID GeckoAppShell::jRemovePluginView = 0;
jmethodID GeckoAppShell::jRequestUiThreadCallback = 0;
jmethodID GeckoAppShell::jScanMedia = 0;
jmethodID GeckoAppShell::jScheduleRestart = 0;
jmethodID GeckoAppShell::jSendMessageWrapper = 0;
jmethodID GeckoAppShell::jSetFullScreen = 0;
jmethodID GeckoAppShell::jSetKeepScreenOn = 0;
jmethodID GeckoAppShell::jSetURITitle = 0;
jmethodID GeckoAppShell::jShowAlertNotificationWrapper = 0;
jmethodID GeckoAppShell::jShowInputMethodPicker = 0;
jmethodID GeckoAppShell::jStartMonitoringGamepad = 0;
jmethodID GeckoAppShell::jStopMonitoringGamepad = 0;
jmethodID GeckoAppShell::jUnlockProfile = 0;
jmethodID GeckoAppShell::jUnlockScreenOrientation = 0;
jmethodID GeckoAppShell::jUnregisterSurfaceTextureFrameListener = 0;
jmethodID GeckoAppShell::jVibrate1 = 0;
jmethodID GeckoAppShell::jVibrateA = 0;
void GeckoAppShell::InitStubs(JNIEnv *jEnv) {
    initInit();

    mGeckoAppShellClass = getClassGlobalRef("org/mozilla/gecko/GeckoAppShell");
    jAcknowledgeEvent = getStaticMethod("acknowledgeEvent", "()V");
    jAddPluginViewWrapper = getStaticMethod("addPluginView", "(Landroid/view/View;FFFFZ)V");
    jAlertsProgressListener_OnProgress = getStaticMethod("alertsProgressListener_OnProgress", "(Ljava/lang/String;JJLjava/lang/String;)V");
    jCancelVibrate = getStaticMethod("cancelVibrate", "()V");
    jCheckURIVisited = getStaticMethod("checkUriVisited", "(Ljava/lang/String;)V");
    jClearMessageList = getStaticMethod("clearMessageList", "(I)V");
    jCloseCamera = getStaticMethod("closeCamera", "()V");
    jCloseNotification = getStaticMethod("closeNotification", "(Ljava/lang/String;)V");
    jConnectionGetMimeType = getStaticMethod("connectionGetMimeType", "(Ljava/net/URLConnection;)Ljava/lang/String;");
    jCreateInputStream = getStaticMethod("createInputStream", "(Ljava/net/URLConnection;)Ljava/io/InputStream;");
    jCreateMessageListWrapper = getStaticMethod("createMessageList", "(JJ[Ljava/lang/String;ILjava/lang/String;ZZJZI)V");
    jCreateShortcut = getStaticMethod("createShortcut", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
    jDeleteMessageWrapper = getStaticMethod("deleteMessage", "(II)V");
    jDisableBatteryNotifications = getStaticMethod("disableBatteryNotifications", "()V");
    jDisableNetworkNotifications = getStaticMethod("disableNetworkNotifications", "()V");
    jDisableScreenOrientationNotifications = getStaticMethod("disableScreenOrientationNotifications", "()V");
    jDisableSensor = getStaticMethod("disableSensor", "(I)V");
    jEnableBatteryNotifications = getStaticMethod("enableBatteryNotifications", "()V");
    jEnableLocation = getStaticMethod("enableLocation", "(Z)V");
    jEnableLocationHighAccuracy = getStaticMethod("enableLocationHighAccuracy", "(Z)V");
    jEnableNetworkNotifications = getStaticMethod("enableNetworkNotifications", "()V");
    jEnableScreenOrientationNotifications = getStaticMethod("enableScreenOrientationNotifications", "()V");
    jEnableSensor = getStaticMethod("enableSensor", "(I)V");
    jGamepadAdded = getStaticMethod("gamepadAdded", "(II)V");
    jGetConnection = getStaticMethod("getConnection", "(Ljava/lang/String;)Ljava/net/URLConnection;");
    jGetContext = getStaticMethod("getContext", "()Landroid/content/Context;");
    jGetCurrentBatteryInformationWrapper = getStaticMethod("getCurrentBatteryInformation", "()[D");
    jGetCurrentNetworkInformationWrapper = getStaticMethod("getCurrentNetworkInformation", "()[D");
    jGetDensity = getStaticMethod("getDensity", "()F");
    jGetDpiWrapper = getStaticMethod("getDpi", "()I");
    jGetExtensionFromMimeTypeWrapper = getStaticMethod("getExtensionFromMimeType", "(Ljava/lang/String;)Ljava/lang/String;");
    jGetExternalPublicDirectory = getStaticMethod("getExternalPublicDirectory", "(Ljava/lang/String;)Ljava/lang/String;");
    jGetHandlersForMimeTypeWrapper = getStaticMethod("getHandlersForMimeType", "(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;");
    jGetHandlersForURLWrapper = getStaticMethod("getHandlersForURL", "(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;");
    jGetIconForExtensionWrapper = getStaticMethod("getIconForExtension", "(Ljava/lang/String;I)[B");
    jGetMessageWrapper = getStaticMethod("getMessage", "(II)V");
    jGetMimeTypeFromExtensionsWrapper = getStaticMethod("getMimeTypeFromExtensions", "(Ljava/lang/String;)Ljava/lang/String;");
    jGetNextMessageInListWrapper = getStaticMethod("getNextMessageInList", "(II)V");
    jGetProxyForURIWrapper = getStaticMethod("getProxyForURI", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;");
    jGetScreenDepthWrapper = getStaticMethod("getScreenDepth", "()I");
    jGetScreenOrientationWrapper = getStaticMethod("getScreenOrientation", "()S");
    jGetShowPasswordSetting = getStaticMethod("getShowPasswordSetting", "()Z");
    jGetSystemColoursWrapper = getStaticMethod("getSystemColors", "()[I");
    jGetUserRestrictions = getStaticMethod("getUserRestrictions", "()Ljava/lang/String;");
    jHandleGeckoMessageWrapper = getStaticMethod("handleGeckoMessage", "(Lorg/mozilla/gecko/util/NativeJSContainer;)V");
    jHandleUncaughtException = getStaticMethod("handleUncaughtException", "(Ljava/lang/Thread;Ljava/lang/Throwable;)V");
    jHideProgressDialog = getStaticMethod("hideProgressDialog", "()V");
    jInitCameraWrapper = getStaticMethod("initCamera", "(Ljava/lang/String;III)[I");
    jIsNetworkLinkKnown = getStaticMethod("isNetworkLinkKnown", "()Z");
    jIsNetworkLinkUp = getStaticMethod("isNetworkLinkUp", "()Z");
    jIsTablet = getStaticMethod("isTablet", "()Z");
    jIsUserRestricted = getStaticMethod("isUserRestricted", "()Z");
    jKillAnyZombies = getStaticMethod("killAnyZombies", "()V");
    jLoadPluginClass = getStaticMethod("loadPluginClass", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Class;");
    jLockScreenOrientation = getStaticMethod("lockScreenOrientation", "(I)V");
    jMarkURIVisited = getStaticMethod("markUriVisited", "(Ljava/lang/String;)V");
    jMoveTaskToBack = getStaticMethod("moveTaskToBack", "()V");
    jNetworkLinkType = getStaticMethod("networkLinkType", "()I");
    jNotifyDefaultPrevented = getStaticMethod("notifyDefaultPrevented", "(Z)V");
    jNotifyIME = getStaticMethod("notifyIME", "(I)V");
    jNotifyIMEChange = getStaticMethod("notifyIMEChange", "(Ljava/lang/String;III)V");
    jNotifyIMEContext = getStaticMethod("notifyIMEContext", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
    jNotifyWakeLockChanged = getStaticMethod("notifyWakeLockChanged", "(Ljava/lang/String;Ljava/lang/String;)V");
    jNotifyXreExit = getStaticMethod("onXreExit", "()V");
    jOpenUriExternal = getStaticMethod("openUriExternal", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z");
    jPerformHapticFeedback = getStaticMethod("performHapticFeedback", "(Z)V");
    jPumpMessageLoop = getStaticMethod("pumpMessageLoop", "()Z");
    jRegisterSurfaceTextureFrameListener = getStaticMethod("registerSurfaceTextureFrameListener", "(Ljava/lang/Object;I)V");
    jRemovePluginView = getStaticMethod("removePluginView", "(Landroid/view/View;Z)V");
    jRequestUiThreadCallback = getStaticMethod("requestUiThreadCallback", "(J)V");
    jScanMedia = getStaticMethod("scanMedia", "(Ljava/lang/String;Ljava/lang/String;)V");
    jScheduleRestart = getStaticMethod("scheduleRestart", "()V");
    jSendMessageWrapper = getStaticMethod("sendMessage", "(Ljava/lang/String;Ljava/lang/String;I)V");
    jSetFullScreen = getStaticMethod("setFullScreen", "(Z)V");
    jSetKeepScreenOn = getStaticMethod("setKeepScreenOn", "(Z)V");
    jSetURITitle = getStaticMethod("setUriTitle", "(Ljava/lang/String;Ljava/lang/String;)V");
    jShowAlertNotificationWrapper = getStaticMethod("showAlertNotification", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
    jShowInputMethodPicker = getStaticMethod("showInputMethodPicker", "()V");
    jStartMonitoringGamepad = getStaticMethod("startMonitoringGamepad", "()V");
    jStopMonitoringGamepad = getStaticMethod("stopMonitoringGamepad", "()V");
    jUnlockProfile = getStaticMethod("unlockProfile", "()Z");
    jUnlockScreenOrientation = getStaticMethod("unlockScreenOrientation", "()V");
    jUnregisterSurfaceTextureFrameListener = getStaticMethod("unregisterSurfaceTextureFrameListener", "(Ljava/lang/Object;)V");
    jVibrate1 = getStaticMethod("vibrate", "(J)V");
    jVibrateA = getStaticMethod("vibrate", "([JI)V");
}

GeckoAppShell* GeckoAppShell::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    GeckoAppShell* ret = new GeckoAppShell(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

void GeckoAppShell::AcknowledgeEvent() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jAcknowledgeEvent);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::AddPluginViewWrapper(jobject a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4, bool a5) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[6];
    args[0].l = a0;
    args[1].f = a1;
    args[2].f = a2;
    args[3].f = a3;
    args[4].f = a4;
    args[5].z = a5;

    env->CallStaticVoidMethodA(mGeckoAppShellClass, jAddPluginViewWrapper, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::AlertsProgressListener_OnProgress(const nsAString& a0, int64_t a1, int64_t a2, const nsAString& a3) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[4];
    args[0].l = AndroidBridge::NewJavaString(env, a0);
    args[1].j = a1;
    args[2].j = a2;
    args[3].l = AndroidBridge::NewJavaString(env, a3);

    env->CallStaticVoidMethodA(mGeckoAppShellClass, jAlertsProgressListener_OnProgress, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::CancelVibrate() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jCancelVibrate);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::CheckURIVisited(const nsAString& a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);

    env->CallStaticVoidMethod(mGeckoAppShellClass, jCheckURIVisited, j0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::ClearMessageList(int32_t a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jClearMessageList, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::CloseCamera() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jCloseCamera);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::CloseNotification(const nsAString& a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);

    env->CallStaticVoidMethod(mGeckoAppShellClass, jCloseNotification, j0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

jstring GeckoAppShell::ConnectionGetMimeType(jobject a0) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jConnectionGetMimeType, a0);
    AndroidBridge::HandleUncaughtException(env);
    jstring ret = static_cast<jstring>(env->PopLocalFrame(temp));
    return ret;
}

jobject GeckoAppShell::CreateInputStream(jobject a0) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jCreateInputStream, a0);
    AndroidBridge::HandleUncaughtException(env);
    jobject ret = static_cast<jobject>(env->PopLocalFrame(temp));
    return ret;
}

void GeckoAppShell::CreateMessageListWrapper(int64_t a0, int64_t a1, jobjectArray a2, int32_t a3, const nsAString& a4, bool a5, bool a6, int64_t a7, bool a8, int32_t a9) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[10];
    args[0].j = a0;
    args[1].j = a1;
    args[2].l = a2;
    args[3].i = a3;
    args[4].l = AndroidBridge::NewJavaString(env, a4);
    args[5].z = a5;
    args[6].z = a6;
    args[7].j = a7;
    args[8].z = a8;
    args[9].i = a9;

    env->CallStaticVoidMethodA(mGeckoAppShellClass, jCreateMessageListWrapper, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::CreateShortcut(const nsAString& a0, const nsAString& a1, const nsAString& a2) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(3) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[3];
    args[0].l = AndroidBridge::NewJavaString(env, a0);
    args[1].l = AndroidBridge::NewJavaString(env, a1);
    args[2].l = AndroidBridge::NewJavaString(env, a2);

    env->CallStaticVoidMethodA(mGeckoAppShellClass, jCreateShortcut, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::DeleteMessageWrapper(int32_t a0, int32_t a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jDeleteMessageWrapper, a0, a1);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::DisableBatteryNotifications() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jDisableBatteryNotifications);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::DisableNetworkNotifications() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jDisableNetworkNotifications);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::DisableScreenOrientationNotifications() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jDisableScreenOrientationNotifications);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::DisableSensor(int32_t a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jDisableSensor, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::EnableBatteryNotifications() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jEnableBatteryNotifications);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::EnableLocation(bool a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jEnableLocation, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::EnableLocationHighAccuracy(bool a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jEnableLocationHighAccuracy, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::EnableNetworkNotifications() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jEnableNetworkNotifications);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::EnableScreenOrientationNotifications() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jEnableScreenOrientationNotifications);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::EnableSensor(int32_t a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jEnableSensor, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::GamepadAdded(int32_t a0, int32_t a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jGamepadAdded, a0, a1);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

jobject GeckoAppShell::GetConnection(const nsACString& a0) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jGetConnection, j0);
    AndroidBridge::HandleUncaughtException(env);
    jobject ret = static_cast<jobject>(env->PopLocalFrame(temp));
    return ret;
}

jobject GeckoAppShell::GetContext() {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jGetContext);
    AndroidBridge::HandleUncaughtException(env);
    jobject ret = static_cast<jobject>(env->PopLocalFrame(temp));
    return ret;
}

jdoubleArray GeckoAppShell::GetCurrentBatteryInformationWrapper() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jGetCurrentBatteryInformationWrapper);
    AndroidBridge::HandleUncaughtException(env);
    jdoubleArray ret = static_cast<jdoubleArray>(env->PopLocalFrame(temp));
    return ret;
}

jdoubleArray GeckoAppShell::GetCurrentNetworkInformationWrapper() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jGetCurrentNetworkInformationWrapper);
    AndroidBridge::HandleUncaughtException(env);
    jdoubleArray ret = static_cast<jdoubleArray>(env->PopLocalFrame(temp));
    return ret;
}

jfloat GeckoAppShell::GetDensity() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jfloat temp = env->CallStaticFloatMethod(mGeckoAppShellClass, jGetDensity);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

int32_t GeckoAppShell::GetDpiWrapper() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    int32_t temp = env->CallStaticIntMethod(mGeckoAppShellClass, jGetDpiWrapper);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

jstring GeckoAppShell::GetExtensionFromMimeTypeWrapper(const nsAString& a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jGetExtensionFromMimeTypeWrapper, j0);
    AndroidBridge::HandleUncaughtException(env);
    jstring ret = static_cast<jstring>(env->PopLocalFrame(temp));
    return ret;
}

jstring GeckoAppShell::GetExternalPublicDirectory(const nsAString& a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jGetExternalPublicDirectory, j0);
    AndroidBridge::HandleUncaughtException(env);
    jstring ret = static_cast<jstring>(env->PopLocalFrame(temp));
    return ret;
}

jobjectArray GeckoAppShell::GetHandlersForMimeTypeWrapper(const nsAString& a0, const nsAString& a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(3) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);
    jstring j1 = AndroidBridge::NewJavaString(env, a1);

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jGetHandlersForMimeTypeWrapper, j0, j1);
    AndroidBridge::HandleUncaughtException(env);
    jobjectArray ret = static_cast<jobjectArray>(env->PopLocalFrame(temp));
    return ret;
}

jobjectArray GeckoAppShell::GetHandlersForURLWrapper(const nsAString& a0, const nsAString& a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(3) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);
    jstring j1 = AndroidBridge::NewJavaString(env, a1);

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jGetHandlersForURLWrapper, j0, j1);
    AndroidBridge::HandleUncaughtException(env);
    jobjectArray ret = static_cast<jobjectArray>(env->PopLocalFrame(temp));
    return ret;
}

jbyteArray GeckoAppShell::GetIconForExtensionWrapper(const nsAString& a0, int32_t a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jGetIconForExtensionWrapper, j0, a1);
    AndroidBridge::HandleUncaughtException(env);
    jbyteArray ret = static_cast<jbyteArray>(env->PopLocalFrame(temp));
    return ret;
}

void GeckoAppShell::GetMessageWrapper(int32_t a0, int32_t a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jGetMessageWrapper, a0, a1);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

jstring GeckoAppShell::GetMimeTypeFromExtensionsWrapper(const nsAString& a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jGetMimeTypeFromExtensionsWrapper, j0);
    AndroidBridge::HandleUncaughtException(env);
    jstring ret = static_cast<jstring>(env->PopLocalFrame(temp));
    return ret;
}

void GeckoAppShell::GetNextMessageInListWrapper(int32_t a0, int32_t a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jGetNextMessageInListWrapper, a0, a1);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

jstring GeckoAppShell::GetProxyForURIWrapper(const nsAString& a0, const nsAString& a1, const nsAString& a2, int32_t a3) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(4) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[4];
    args[0].l = AndroidBridge::NewJavaString(env, a0);
    args[1].l = AndroidBridge::NewJavaString(env, a1);
    args[2].l = AndroidBridge::NewJavaString(env, a2);
    args[3].i = a3;

    jobject temp = env->CallStaticObjectMethodA(mGeckoAppShellClass, jGetProxyForURIWrapper, args);
    AndroidBridge::HandleUncaughtException(env);
    jstring ret = static_cast<jstring>(env->PopLocalFrame(temp));
    return ret;
}

int32_t GeckoAppShell::GetScreenDepthWrapper() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    int32_t temp = env->CallStaticIntMethod(mGeckoAppShellClass, jGetScreenDepthWrapper);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

int16_t GeckoAppShell::GetScreenOrientationWrapper() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    int16_t temp = env->CallStaticShortMethod(mGeckoAppShellClass, jGetScreenOrientationWrapper);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

bool GeckoAppShell::GetShowPasswordSetting() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    bool temp = env->CallStaticBooleanMethod(mGeckoAppShellClass, jGetShowPasswordSetting);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

jintArray GeckoAppShell::GetSystemColoursWrapper() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jGetSystemColoursWrapper);
    AndroidBridge::HandleUncaughtException(env);
    jintArray ret = static_cast<jintArray>(env->PopLocalFrame(temp));
    return ret;
}

jstring GeckoAppShell::GetUserRestrictions() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jGetUserRestrictions);
    AndroidBridge::HandleUncaughtException(env);
    jstring ret = static_cast<jstring>(env->PopLocalFrame(temp));
    return ret;
}

void GeckoAppShell::HandleGeckoMessageWrapper(jobject a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jHandleGeckoMessageWrapper, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::HandleUncaughtException(jobject a0, jthrowable a1) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(2) != 0) {
        return;
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jHandleUncaughtException, a0, a1);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::HideProgressDialog() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jHideProgressDialog);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

jintArray GeckoAppShell::InitCameraWrapper(const nsAString& a0, int32_t a1, int32_t a2, int32_t a3) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[4];
    args[0].l = AndroidBridge::NewJavaString(env, a0);
    args[1].i = a1;
    args[2].i = a2;
    args[3].i = a3;

    jobject temp = env->CallStaticObjectMethodA(mGeckoAppShellClass, jInitCameraWrapper, args);
    AndroidBridge::HandleUncaughtException(env);
    jintArray ret = static_cast<jintArray>(env->PopLocalFrame(temp));
    return ret;
}

bool GeckoAppShell::IsNetworkLinkKnown() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    bool temp = env->CallStaticBooleanMethod(mGeckoAppShellClass, jIsNetworkLinkKnown);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

bool GeckoAppShell::IsNetworkLinkUp() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    bool temp = env->CallStaticBooleanMethod(mGeckoAppShellClass, jIsNetworkLinkUp);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

bool GeckoAppShell::IsTablet() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    bool temp = env->CallStaticBooleanMethod(mGeckoAppShellClass, jIsTablet);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

bool GeckoAppShell::IsUserRestricted() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    bool temp = env->CallStaticBooleanMethod(mGeckoAppShellClass, jIsUserRestricted);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

void GeckoAppShell::KillAnyZombies() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jKillAnyZombies);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

jclass GeckoAppShell::LoadPluginClass(const nsAString& a0, const nsAString& a1) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(3) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);
    jstring j1 = AndroidBridge::NewJavaString(env, a1);

    jobject temp = env->CallStaticObjectMethod(mGeckoAppShellClass, jLoadPluginClass, j0, j1);
    AndroidBridge::HandleUncaughtException(env);
    jclass ret = static_cast<jclass>(env->PopLocalFrame(temp));
    return ret;
}

void GeckoAppShell::LockScreenOrientation(int32_t a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jLockScreenOrientation, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::MarkURIVisited(const nsAString& a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);

    env->CallStaticVoidMethod(mGeckoAppShellClass, jMarkURIVisited, j0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::MoveTaskToBack() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jMoveTaskToBack);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

int32_t GeckoAppShell::NetworkLinkType() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    int32_t temp = env->CallStaticIntMethod(mGeckoAppShellClass, jNetworkLinkType);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

void GeckoAppShell::NotifyDefaultPrevented(bool a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jNotifyDefaultPrevented, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::NotifyIME(int32_t a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jNotifyIME, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::NotifyIMEChange(const nsAString& a0, int32_t a1, int32_t a2, int32_t a3) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[4];
    args[0].l = AndroidBridge::NewJavaString(env, a0);
    args[1].i = a1;
    args[2].i = a2;
    args[3].i = a3;

    env->CallStaticVoidMethodA(mGeckoAppShellClass, jNotifyIMEChange, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::NotifyIMEContext(int32_t a0, const nsAString& a1, const nsAString& a2, const nsAString& a3) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(3) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[4];
    args[0].i = a0;
    args[1].l = AndroidBridge::NewJavaString(env, a1);
    args[2].l = AndroidBridge::NewJavaString(env, a2);
    args[3].l = AndroidBridge::NewJavaString(env, a3);

    env->CallStaticVoidMethodA(mGeckoAppShellClass, jNotifyIMEContext, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::NotifyWakeLockChanged(const nsAString& a0, const nsAString& a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);
    jstring j1 = AndroidBridge::NewJavaString(env, a1);

    env->CallStaticVoidMethod(mGeckoAppShellClass, jNotifyWakeLockChanged, j0, j1);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::NotifyXreExit() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jNotifyXreExit);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

bool GeckoAppShell::OpenUriExternal(const nsAString& a0, const nsAString& a1, const nsAString& a2, const nsAString& a3, const nsAString& a4, const nsAString& a5) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(6) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[6];
    args[0].l = AndroidBridge::NewJavaString(env, a0);
    args[1].l = AndroidBridge::NewJavaString(env, a1);
    args[2].l = AndroidBridge::NewJavaString(env, a2);
    args[3].l = AndroidBridge::NewJavaString(env, a3);
    args[4].l = AndroidBridge::NewJavaString(env, a4);
    args[5].l = AndroidBridge::NewJavaString(env, a5);

    bool temp = env->CallStaticBooleanMethodA(mGeckoAppShellClass, jOpenUriExternal, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

void GeckoAppShell::PerformHapticFeedback(bool a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jPerformHapticFeedback, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

bool GeckoAppShell::PumpMessageLoop() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    bool temp = env->CallStaticBooleanMethod(mGeckoAppShellClass, jPumpMessageLoop);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

void GeckoAppShell::RegisterSurfaceTextureFrameListener(jobject a0, int32_t a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jRegisterSurfaceTextureFrameListener, a0, a1);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::RemovePluginView(jobject a0, bool a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jRemovePluginView, a0, a1);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::RequestUiThreadCallback(int64_t a0) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jRequestUiThreadCallback, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::ScanMedia(const nsAString& a0, const nsAString& a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);
    jstring j1 = AndroidBridge::NewJavaString(env, a1);

    env->CallStaticVoidMethod(mGeckoAppShellClass, jScanMedia, j0, j1);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::ScheduleRestart() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jScheduleRestart);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::SendMessageWrapper(const nsAString& a0, const nsAString& a1, int32_t a2) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[3];
    args[0].l = AndroidBridge::NewJavaString(env, a0);
    args[1].l = AndroidBridge::NewJavaString(env, a1);
    args[2].i = a2;

    env->CallStaticVoidMethodA(mGeckoAppShellClass, jSendMessageWrapper, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::SetFullScreen(bool a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jSetFullScreen, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::SetKeepScreenOn(bool a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jSetKeepScreenOn, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::SetURITitle(const nsAString& a0, const nsAString& a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);
    jstring j1 = AndroidBridge::NewJavaString(env, a1);

    env->CallStaticVoidMethod(mGeckoAppShellClass, jSetURITitle, j0, j1);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::ShowAlertNotificationWrapper(const nsAString& a0, const nsAString& a1, const nsAString& a2, const nsAString& a3, const nsAString& a4) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(5) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[5];
    args[0].l = AndroidBridge::NewJavaString(env, a0);
    args[1].l = AndroidBridge::NewJavaString(env, a1);
    args[2].l = AndroidBridge::NewJavaString(env, a2);
    args[3].l = AndroidBridge::NewJavaString(env, a3);
    args[4].l = AndroidBridge::NewJavaString(env, a4);

    env->CallStaticVoidMethodA(mGeckoAppShellClass, jShowAlertNotificationWrapper, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::ShowInputMethodPicker() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jShowInputMethodPicker);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::StartMonitoringGamepad() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jStartMonitoringGamepad);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::StopMonitoringGamepad() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jStopMonitoringGamepad);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

bool GeckoAppShell::UnlockProfile() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    bool temp = env->CallStaticBooleanMethod(mGeckoAppShellClass, jUnlockProfile);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

void GeckoAppShell::UnlockScreenOrientation() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jUnlockScreenOrientation);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::UnregisterSurfaceTextureFrameListener(jobject a0) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jUnregisterSurfaceTextureFrameListener, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::Vibrate1(int64_t a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jVibrate1, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoAppShell::VibrateA(jlongArray a0, int32_t a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoAppShellClass, jVibrateA, a0, a1);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}
jclass JavaDomKeyLocation::mDomKeyLocationClass = 0;
jmethodID JavaDomKeyLocation::jvalueOf = 0;
jmethodID JavaDomKeyLocation::jvalues = 0;
jfieldID JavaDomKeyLocation::jDOM_KEY_LOCATION_JOYSTICK = 0;
jfieldID JavaDomKeyLocation::jDOM_KEY_LOCATION_LEFT = 0;
jfieldID JavaDomKeyLocation::jDOM_KEY_LOCATION_MOBILE = 0;
jfieldID JavaDomKeyLocation::jDOM_KEY_LOCATION_NUMPAD = 0;
jfieldID JavaDomKeyLocation::jDOM_KEY_LOCATION_RIGHT = 0;
jfieldID JavaDomKeyLocation::jDOM_KEY_LOCATION_STANDARD = 0;
jfieldID JavaDomKeyLocation::jvalue = 0;
void JavaDomKeyLocation::InitStubs(JNIEnv *jEnv) {
    initInit();

    mDomKeyLocationClass = getClassGlobalRef("org/mozilla/gecko/GeckoEvent$DomKeyLocation");
    jvalueOf = getStaticMethod("valueOf", "(Ljava/lang/String;)Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
    jvalues = getStaticMethod("values", "()[Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
    jDOM_KEY_LOCATION_JOYSTICK = getStaticField("DOM_KEY_LOCATION_JOYSTICK", "Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
    jDOM_KEY_LOCATION_LEFT = getStaticField("DOM_KEY_LOCATION_LEFT", "Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
    jDOM_KEY_LOCATION_MOBILE = getStaticField("DOM_KEY_LOCATION_MOBILE", "Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
    jDOM_KEY_LOCATION_NUMPAD = getStaticField("DOM_KEY_LOCATION_NUMPAD", "Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
    jDOM_KEY_LOCATION_RIGHT = getStaticField("DOM_KEY_LOCATION_RIGHT", "Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
    jDOM_KEY_LOCATION_STANDARD = getStaticField("DOM_KEY_LOCATION_STANDARD", "Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
    jvalue = getField("value", "I");
}

JavaDomKeyLocation* JavaDomKeyLocation::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    JavaDomKeyLocation* ret = new JavaDomKeyLocation(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

jobject JavaDomKeyLocation::valueOf(const nsAString& a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);

    jobject temp = env->CallStaticObjectMethod(mDomKeyLocationClass, jvalueOf, j0);
    AndroidBridge::HandleUncaughtException(env);
    jobject ret = static_cast<jobject>(env->PopLocalFrame(temp));
    return ret;
}

jobjectArray JavaDomKeyLocation::values() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallStaticObjectMethod(mDomKeyLocationClass, jvalues);
    AndroidBridge::HandleUncaughtException(env);
    jobjectArray ret = static_cast<jobjectArray>(env->PopLocalFrame(temp));
    return ret;
}

jobject JavaDomKeyLocation::getDOM_KEY_LOCATION_JOYSTICK() {
    JNIEnv *env = GetJNIForThread();
    return static_cast<jobject>(env->GetStaticObjectField(mDomKeyLocationClass, jDOM_KEY_LOCATION_JOYSTICK));
}

jobject JavaDomKeyLocation::getDOM_KEY_LOCATION_LEFT() {
    JNIEnv *env = GetJNIForThread();
    return static_cast<jobject>(env->GetStaticObjectField(mDomKeyLocationClass, jDOM_KEY_LOCATION_LEFT));
}

jobject JavaDomKeyLocation::getDOM_KEY_LOCATION_MOBILE() {
    JNIEnv *env = GetJNIForThread();
    return static_cast<jobject>(env->GetStaticObjectField(mDomKeyLocationClass, jDOM_KEY_LOCATION_MOBILE));
}

jobject JavaDomKeyLocation::getDOM_KEY_LOCATION_NUMPAD() {
    JNIEnv *env = GetJNIForThread();
    return static_cast<jobject>(env->GetStaticObjectField(mDomKeyLocationClass, jDOM_KEY_LOCATION_NUMPAD));
}

jobject JavaDomKeyLocation::getDOM_KEY_LOCATION_RIGHT() {
    JNIEnv *env = GetJNIForThread();
    return static_cast<jobject>(env->GetStaticObjectField(mDomKeyLocationClass, jDOM_KEY_LOCATION_RIGHT));
}

jobject JavaDomKeyLocation::getDOM_KEY_LOCATION_STANDARD() {
    JNIEnv *env = GetJNIForThread();
    return static_cast<jobject>(env->GetStaticObjectField(mDomKeyLocationClass, jDOM_KEY_LOCATION_STANDARD));
}

int32_t JavaDomKeyLocation::getvalue() {
    JNIEnv *env = GetJNIForThread();
    return env->GetIntField(wrapped_obj, jvalue);
}
jclass GeckoJavaSampler::mGeckoJavaSamplerClass = 0;
jmethodID GeckoJavaSampler::jGetFrameNameJavaProfilingWrapper = 0;
jmethodID GeckoJavaSampler::jGetSampleTimeJavaProfiling = 0;
jmethodID GeckoJavaSampler::jGetThreadNameJavaProfilingWrapper = 0;
jmethodID GeckoJavaSampler::jPauseJavaProfiling = 0;
jmethodID GeckoJavaSampler::jStartJavaProfiling = 0;
jmethodID GeckoJavaSampler::jStopJavaProfiling = 0;
jmethodID GeckoJavaSampler::jUnpauseJavaProfiling = 0;
void GeckoJavaSampler::InitStubs(JNIEnv *jEnv) {
    initInit();

    mGeckoJavaSamplerClass = getClassGlobalRef("org/mozilla/gecko/GeckoJavaSampler");
    jGetFrameNameJavaProfilingWrapper = getStaticMethod("getFrameName", "(III)Ljava/lang/String;");
    jGetSampleTimeJavaProfiling = getStaticMethod("getSampleTime", "(II)D");
    jGetThreadNameJavaProfilingWrapper = getStaticMethod("getThreadName", "(I)Ljava/lang/String;");
    jPauseJavaProfiling = getStaticMethod("pause", "()V");
    jStartJavaProfiling = getStaticMethod("start", "(II)V");
    jStopJavaProfiling = getStaticMethod("stop", "()V");
    jUnpauseJavaProfiling = getStaticMethod("unpause", "()V");
}

GeckoJavaSampler* GeckoJavaSampler::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    GeckoJavaSampler* ret = new GeckoJavaSampler(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

jstring GeckoJavaSampler::GetFrameNameJavaProfilingWrapper(int32_t a0, int32_t a1, int32_t a2) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[3];
    args[0].i = a0;
    args[1].i = a1;
    args[2].i = a2;

    jobject temp = env->CallStaticObjectMethodA(mGeckoJavaSamplerClass, jGetFrameNameJavaProfilingWrapper, args);
    AndroidBridge::HandleUncaughtException(env);
    jstring ret = static_cast<jstring>(env->PopLocalFrame(temp));
    return ret;
}

jdouble GeckoJavaSampler::GetSampleTimeJavaProfiling(int32_t a0, int32_t a1) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jdouble temp = env->CallStaticDoubleMethod(mGeckoJavaSamplerClass, jGetSampleTimeJavaProfiling, a0, a1);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

jstring GeckoJavaSampler::GetThreadNameJavaProfilingWrapper(int32_t a0) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallStaticObjectMethod(mGeckoJavaSamplerClass, jGetThreadNameJavaProfilingWrapper, a0);
    AndroidBridge::HandleUncaughtException(env);
    jstring ret = static_cast<jstring>(env->PopLocalFrame(temp));
    return ret;
}

void GeckoJavaSampler::PauseJavaProfiling() {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoJavaSamplerClass, jPauseJavaProfiling);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoJavaSampler::StartJavaProfiling(int32_t a0, int32_t a1) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoJavaSamplerClass, jStartJavaProfiling, a0, a1);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoJavaSampler::StopJavaProfiling() {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoJavaSamplerClass, jStopJavaProfiling);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoJavaSampler::UnpauseJavaProfiling() {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mGeckoJavaSamplerClass, jUnpauseJavaProfiling);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}
jclass SurfaceBits::mSurfaceBitsClass = 0;
jmethodID SurfaceBits::jSurfaceBits = 0;
jfieldID SurfaceBits::jbuffer = 0;
jfieldID SurfaceBits::jformat = 0;
jfieldID SurfaceBits::jheight = 0;
jfieldID SurfaceBits::jwidth = 0;
void SurfaceBits::InitStubs(JNIEnv *jEnv) {
    initInit();

    mSurfaceBitsClass = getClassGlobalRef("org/mozilla/gecko/SurfaceBits");
    jSurfaceBits = getMethod("<init>", "()V");
    jbuffer = getField("buffer", "Ljava/nio/ByteBuffer;");
    jformat = getField("format", "I");
    jheight = getField("height", "I");
    jwidth = getField("width", "I");
}

SurfaceBits* SurfaceBits::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    SurfaceBits* ret = new SurfaceBits(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

SurfaceBits::SurfaceBits() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    Init(env->NewObject(mSurfaceBitsClass, jSurfaceBits), env);
    env->PopLocalFrame(nullptr);
}

jobject SurfaceBits::getbuffer() {
    JNIEnv *env = GetJNIForThread();
    return static_cast<jobject>(env->GetObjectField(wrapped_obj, jbuffer));
}

void SurfaceBits::setbuffer(jobject a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetObjectField(wrapped_obj, jbuffer, a0);
}

int32_t SurfaceBits::getformat() {
    JNIEnv *env = GetJNIForThread();
    return env->GetIntField(wrapped_obj, jformat);
}

void SurfaceBits::setformat(int32_t a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetIntField(wrapped_obj, jformat, a0);
}

int32_t SurfaceBits::getheight() {
    JNIEnv *env = GetJNIForThread();
    return env->GetIntField(wrapped_obj, jheight);
}

void SurfaceBits::setheight(int32_t a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetIntField(wrapped_obj, jheight, a0);
}

int32_t SurfaceBits::getwidth() {
    JNIEnv *env = GetJNIForThread();
    return env->GetIntField(wrapped_obj, jwidth);
}

void SurfaceBits::setwidth(int32_t a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetIntField(wrapped_obj, jwidth, a0);
}
jclass ThumbnailHelper::mThumbnailHelperClass = 0;
jmethodID ThumbnailHelper::jSendThumbnail = 0;
void ThumbnailHelper::InitStubs(JNIEnv *jEnv) {
    initInit();

    mThumbnailHelperClass = getClassGlobalRef("org/mozilla/gecko/ThumbnailHelper");
    jSendThumbnail = getStaticMethod("notifyThumbnail", "(Ljava/nio/ByteBuffer;IZZ)V");
}

ThumbnailHelper* ThumbnailHelper::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    ThumbnailHelper* ret = new ThumbnailHelper(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

void ThumbnailHelper::SendThumbnail(jobject a0, int32_t a1, bool a2, bool a3) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[4];
    args[0].l = a0;
    args[1].i = a1;
    args[2].z = a2;
    args[3].z = a3;

    env->CallStaticVoidMethodA(mThumbnailHelperClass, jSendThumbnail, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}
jclass DisplayPortMetrics::mDisplayPortMetricsClass = 0;
jmethodID DisplayPortMetrics::jDisplayPortMetrics = 0;
jfieldID DisplayPortMetrics::jMPosition = 0;
jfieldID DisplayPortMetrics::jResolution = 0;
void DisplayPortMetrics::InitStubs(JNIEnv *jEnv) {
    initInit();

    mDisplayPortMetricsClass = getClassGlobalRef("org/mozilla/gecko/gfx/DisplayPortMetrics");
    jDisplayPortMetrics = getMethod("<init>", "(FFFFF)V");
    jMPosition = getField("mPosition", "Landroid/graphics/RectF;");
    jResolution = getField("resolution", "F");
}

DisplayPortMetrics* DisplayPortMetrics::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    DisplayPortMetrics* ret = new DisplayPortMetrics(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

DisplayPortMetrics::DisplayPortMetrics(jfloat a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[5];
    args[0].f = a0;
    args[1].f = a1;
    args[2].f = a2;
    args[3].f = a3;
    args[4].f = a4;

    Init(env->NewObjectA(mDisplayPortMetricsClass, jDisplayPortMetrics, args), env);
    env->PopLocalFrame(nullptr);
}

jobject DisplayPortMetrics::getMPosition() {
    JNIEnv *env = GetJNIForThread();
    return static_cast<jobject>(env->GetObjectField(wrapped_obj, jMPosition));
}

jfloat DisplayPortMetrics::getResolution() {
    JNIEnv *env = GetJNIForThread();
    return env->GetFloatField(wrapped_obj, jResolution);
}
jclass GLController::mGLControllerClass = 0;
jmethodID GLController::jCreateEGLSurfaceForCompositorWrapper = 0;
void GLController::InitStubs(JNIEnv *jEnv) {
    initInit();

    mGLControllerClass = getClassGlobalRef("org/mozilla/gecko/gfx/GLController");
    jCreateEGLSurfaceForCompositorWrapper = getMethod("createEGLSurfaceForCompositor", "()Ljavax/microedition/khronos/egl/EGLSurface;");
}

GLController* GLController::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    GLController* ret = new GLController(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

jobject GLController::CreateEGLSurfaceForCompositorWrapper() {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallObjectMethod(wrapped_obj, jCreateEGLSurfaceForCompositorWrapper);
    AndroidBridge::HandleUncaughtException(env);
    jobject ret = static_cast<jobject>(env->PopLocalFrame(temp));
    return ret;
}
jclass GeckoLayerClient::mGeckoLayerClientClass = 0;
jmethodID GeckoLayerClient::jActivateProgram = 0;
jmethodID GeckoLayerClient::jContentDocumentChanged = 0;
jmethodID GeckoLayerClient::jCreateFrame = 0;
jmethodID GeckoLayerClient::jDeactivateProgramAndRestoreState = 0;
jmethodID GeckoLayerClient::jGetDisplayPort = 0;
jmethodID GeckoLayerClient::jIsContentDocumentDisplayed = 0;
jmethodID GeckoLayerClient::jProgressiveUpdateCallback = 0;
jmethodID GeckoLayerClient::jSetFirstPaintViewport = 0;
jmethodID GeckoLayerClient::jSetPageRect = 0;
jmethodID GeckoLayerClient::jSyncFrameMetrics = 0;
jmethodID GeckoLayerClient::jSyncViewportInfo = 0;
void GeckoLayerClient::InitStubs(JNIEnv *jEnv) {
    initInit();

    mGeckoLayerClientClass = getClassGlobalRef("org/mozilla/gecko/gfx/GeckoLayerClient");
    jActivateProgram = getMethod("activateProgram", "()V");
    jContentDocumentChanged = getMethod("contentDocumentChanged", "()V");
    jCreateFrame = getMethod("createFrame", "()Lorg/mozilla/gecko/gfx/LayerRenderer$Frame;");
    jDeactivateProgramAndRestoreState = getMethod("deactivateProgramAndRestoreState", "(ZIIII)V");
    jGetDisplayPort = getMethod("getDisplayPort", "(ZZILorg/mozilla/gecko/gfx/ImmutableViewportMetrics;)Lorg/mozilla/gecko/gfx/DisplayPortMetrics;");
    jIsContentDocumentDisplayed = getMethod("isContentDocumentDisplayed", "()Z");
    jProgressiveUpdateCallback = getMethod("progressiveUpdateCallback", "(ZFFFFFZ)Lorg/mozilla/gecko/gfx/ProgressiveUpdateData;");
    jSetFirstPaintViewport = getMethod("setFirstPaintViewport", "(FFFFFFF)V");
    jSetPageRect = getMethod("setPageRect", "(FFFF)V");
    jSyncFrameMetrics = getMethod("syncFrameMetrics", "(FFFFFFFZIIIIFZ)Lorg/mozilla/gecko/gfx/ViewTransform;");
    jSyncViewportInfo = getMethod("syncViewportInfo", "(IIIIFZ)Lorg/mozilla/gecko/gfx/ViewTransform;");
}

GeckoLayerClient* GeckoLayerClient::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    GeckoLayerClient* ret = new GeckoLayerClient(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

void GeckoLayerClient::ActivateProgram() {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallVoidMethod(wrapped_obj, jActivateProgram);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoLayerClient::ContentDocumentChanged() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallVoidMethod(wrapped_obj, jContentDocumentChanged);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

jobject GeckoLayerClient::CreateFrame() {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallObjectMethod(wrapped_obj, jCreateFrame);
    AndroidBridge::HandleUncaughtException(env);
    jobject ret = static_cast<jobject>(env->PopLocalFrame(temp));
    return ret;
}

void GeckoLayerClient::DeactivateProgramAndRestoreState(bool a0, int32_t a1, int32_t a2, int32_t a3, int32_t a4) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[5];
    args[0].z = a0;
    args[1].i = a1;
    args[2].i = a2;
    args[3].i = a3;
    args[4].i = a4;

    env->CallVoidMethodA(wrapped_obj, jDeactivateProgramAndRestoreState, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

jobject GeckoLayerClient::GetDisplayPort(bool a0, bool a1, int32_t a2, jobject a3) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[4];
    args[0].z = a0;
    args[1].z = a1;
    args[2].i = a2;
    args[3].l = a3;

    jobject temp = env->CallObjectMethodA(wrapped_obj, jGetDisplayPort, args);
    AndroidBridge::HandleUncaughtException(env);
    jobject ret = static_cast<jobject>(env->PopLocalFrame(temp));
    return ret;
}

bool GeckoLayerClient::IsContentDocumentDisplayed() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    bool temp = env->CallBooleanMethod(wrapped_obj, jIsContentDocumentDisplayed);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

jobject GeckoLayerClient::ProgressiveUpdateCallback(bool a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4, jfloat a5, bool a6) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[7];
    args[0].z = a0;
    args[1].f = a1;
    args[2].f = a2;
    args[3].f = a3;
    args[4].f = a4;
    args[5].f = a5;
    args[6].z = a6;

    jobject temp = env->CallObjectMethodA(wrapped_obj, jProgressiveUpdateCallback, args);
    AndroidBridge::HandleUncaughtException(env);
    jobject ret = static_cast<jobject>(env->PopLocalFrame(temp));
    return ret;
}

void GeckoLayerClient::SetFirstPaintViewport(jfloat a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4, jfloat a5, jfloat a6) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[7];
    args[0].f = a0;
    args[1].f = a1;
    args[2].f = a2;
    args[3].f = a3;
    args[4].f = a4;
    args[5].f = a5;
    args[6].f = a6;

    env->CallVoidMethodA(wrapped_obj, jSetFirstPaintViewport, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void GeckoLayerClient::SetPageRect(jfloat a0, jfloat a1, jfloat a2, jfloat a3) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[4];
    args[0].f = a0;
    args[1].f = a1;
    args[2].f = a2;
    args[3].f = a3;

    env->CallVoidMethodA(wrapped_obj, jSetPageRect, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

jobject GeckoLayerClient::SyncFrameMetrics(jfloat a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4, jfloat a5, jfloat a6, bool a7, int32_t a8, int32_t a9, int32_t a10, int32_t a11, jfloat a12, bool a13) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[14];
    args[0].f = a0;
    args[1].f = a1;
    args[2].f = a2;
    args[3].f = a3;
    args[4].f = a4;
    args[5].f = a5;
    args[6].f = a6;
    args[7].z = a7;
    args[8].i = a8;
    args[9].i = a9;
    args[10].i = a10;
    args[11].i = a11;
    args[12].f = a12;
    args[13].z = a13;

    jobject temp = env->CallObjectMethodA(wrapped_obj, jSyncFrameMetrics, args);
    AndroidBridge::HandleUncaughtException(env);
    jobject ret = static_cast<jobject>(env->PopLocalFrame(temp));
    return ret;
}

jobject GeckoLayerClient::SyncViewportInfo(int32_t a0, int32_t a1, int32_t a2, int32_t a3, jfloat a4, bool a5) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[6];
    args[0].i = a0;
    args[1].i = a1;
    args[2].i = a2;
    args[3].i = a3;
    args[4].f = a4;
    args[5].z = a5;

    jobject temp = env->CallObjectMethodA(wrapped_obj, jSyncViewportInfo, args);
    AndroidBridge::HandleUncaughtException(env);
    jobject ret = static_cast<jobject>(env->PopLocalFrame(temp));
    return ret;
}
jclass ImmutableViewportMetrics::mImmutableViewportMetricsClass = 0;
jmethodID ImmutableViewportMetrics::jImmutableViewportMetrics = 0;
void ImmutableViewportMetrics::InitStubs(JNIEnv *jEnv) {
    initInit();

    mImmutableViewportMetricsClass = getClassGlobalRef("org/mozilla/gecko/gfx/ImmutableViewportMetrics");
    jImmutableViewportMetrics = getMethod("<init>", "(FFFFFFFFFFFFF)V");
}

ImmutableViewportMetrics* ImmutableViewportMetrics::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    ImmutableViewportMetrics* ret = new ImmutableViewportMetrics(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

ImmutableViewportMetrics::ImmutableViewportMetrics(jfloat a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4, jfloat a5, jfloat a6, jfloat a7, jfloat a8, jfloat a9, jfloat a10, jfloat a11, jfloat a12) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[13];
    args[0].f = a0;
    args[1].f = a1;
    args[2].f = a2;
    args[3].f = a3;
    args[4].f = a4;
    args[5].f = a5;
    args[6].f = a6;
    args[7].f = a7;
    args[8].f = a8;
    args[9].f = a9;
    args[10].f = a10;
    args[11].f = a11;
    args[12].f = a12;

    Init(env->NewObjectA(mImmutableViewportMetricsClass, jImmutableViewportMetrics, args), env);
    env->PopLocalFrame(nullptr);
}
jclass LayerView::mLayerViewClass = 0;
jmethodID LayerView::jRegisterCompositorWrapper = 0;
void LayerView::InitStubs(JNIEnv *jEnv) {
    initInit();

    mLayerViewClass = getClassGlobalRef("org/mozilla/gecko/gfx/LayerView");
    jRegisterCompositorWrapper = getStaticMethod("registerCxxCompositor", "()Lorg/mozilla/gecko/gfx/GLController;");
}

LayerView* LayerView::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    LayerView* ret = new LayerView(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

jobject LayerView::RegisterCompositorWrapper() {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallStaticObjectMethod(mLayerViewClass, jRegisterCompositorWrapper);
    AndroidBridge::HandleUncaughtException(env);
    jobject ret = static_cast<jobject>(env->PopLocalFrame(temp));
    return ret;
}
jclass NativePanZoomController::mNativePanZoomControllerClass = 0;
jmethodID NativePanZoomController::jRequestContentRepaintWrapper = 0;
void NativePanZoomController::InitStubs(JNIEnv *jEnv) {
    initInit();

    mNativePanZoomControllerClass = getClassGlobalRef("org/mozilla/gecko/gfx/NativePanZoomController");
    jRequestContentRepaintWrapper = getMethod("requestContentRepaint", "(FFFFF)V");
}

NativePanZoomController* NativePanZoomController::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    NativePanZoomController* ret = new NativePanZoomController(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

void NativePanZoomController::RequestContentRepaintWrapper(jfloat a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4) {
    JNIEnv *env = GetJNIForThread();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[5];
    args[0].f = a0;
    args[1].f = a1;
    args[2].f = a2;
    args[3].f = a3;
    args[4].f = a4;

    env->CallVoidMethodA(wrapped_obj, jRequestContentRepaintWrapper, args);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}
jclass ProgressiveUpdateData::mProgressiveUpdateDataClass = 0;
jmethodID ProgressiveUpdateData::jProgressiveUpdateData = 0;
jmethodID ProgressiveUpdateData::jsetViewport = 0;
jfieldID ProgressiveUpdateData::jabort = 0;
jfieldID ProgressiveUpdateData::jscale = 0;
jfieldID ProgressiveUpdateData::jx = 0;
jfieldID ProgressiveUpdateData::jy = 0;
void ProgressiveUpdateData::InitStubs(JNIEnv *jEnv) {
    initInit();

    mProgressiveUpdateDataClass = getClassGlobalRef("org/mozilla/gecko/gfx/ProgressiveUpdateData");
    jProgressiveUpdateData = getMethod("<init>", "()V");
    jsetViewport = getMethod("setViewport", "(Lorg/mozilla/gecko/gfx/ImmutableViewportMetrics;)V");
    jabort = getField("abort", "Z");
    jscale = getField("scale", "F");
    jx = getField("x", "F");
    jy = getField("y", "F");
}

ProgressiveUpdateData* ProgressiveUpdateData::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    ProgressiveUpdateData* ret = new ProgressiveUpdateData(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

ProgressiveUpdateData::ProgressiveUpdateData() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    Init(env->NewObject(mProgressiveUpdateDataClass, jProgressiveUpdateData), env);
    env->PopLocalFrame(nullptr);
}

void ProgressiveUpdateData::setViewport(jobject a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallVoidMethod(wrapped_obj, jsetViewport, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

bool ProgressiveUpdateData::getabort() {
    JNIEnv *env = GetJNIForThread();
    return env->GetBooleanField(wrapped_obj, jabort);
}

void ProgressiveUpdateData::setabort(bool a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetBooleanField(wrapped_obj, jabort, a0);
}

jfloat ProgressiveUpdateData::getscale() {
    JNIEnv *env = GetJNIForThread();
    return env->GetFloatField(wrapped_obj, jscale);
}

void ProgressiveUpdateData::setscale(jfloat a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetFloatField(wrapped_obj, jscale, a0);
}

jfloat ProgressiveUpdateData::getx() {
    JNIEnv *env = GetJNIForThread();
    return env->GetFloatField(wrapped_obj, jx);
}

void ProgressiveUpdateData::setx(jfloat a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetFloatField(wrapped_obj, jx, a0);
}

jfloat ProgressiveUpdateData::gety() {
    JNIEnv *env = GetJNIForThread();
    return env->GetFloatField(wrapped_obj, jy);
}

void ProgressiveUpdateData::sety(jfloat a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetFloatField(wrapped_obj, jy, a0);
}
jclass ViewTransform::mViewTransformClass = 0;
jmethodID ViewTransform::jViewTransform = 0;
jfieldID ViewTransform::jfixedLayerMarginBottom = 0;
jfieldID ViewTransform::jfixedLayerMarginLeft = 0;
jfieldID ViewTransform::jfixedLayerMarginRight = 0;
jfieldID ViewTransform::jfixedLayerMarginTop = 0;
jfieldID ViewTransform::joffsetX = 0;
jfieldID ViewTransform::joffsetY = 0;
jfieldID ViewTransform::jscale = 0;
jfieldID ViewTransform::jx = 0;
jfieldID ViewTransform::jy = 0;
void ViewTransform::InitStubs(JNIEnv *jEnv) {
    initInit();

    mViewTransformClass = getClassGlobalRef("org/mozilla/gecko/gfx/ViewTransform");
    jViewTransform = getMethod("<init>", "(FFF)V");
    jfixedLayerMarginBottom = getField("fixedLayerMarginBottom", "F");
    jfixedLayerMarginLeft = getField("fixedLayerMarginLeft", "F");
    jfixedLayerMarginRight = getField("fixedLayerMarginRight", "F");
    jfixedLayerMarginTop = getField("fixedLayerMarginTop", "F");
    joffsetX = getField("offsetX", "F");
    joffsetY = getField("offsetY", "F");
    jscale = getField("scale", "F");
    jx = getField("x", "F");
    jy = getField("y", "F");
}

ViewTransform* ViewTransform::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    ViewTransform* ret = new ViewTransform(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

ViewTransform::ViewTransform(jfloat a0, jfloat a1, jfloat a2) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jvalue args[3];
    args[0].f = a0;
    args[1].f = a1;
    args[2].f = a2;

    Init(env->NewObjectA(mViewTransformClass, jViewTransform, args), env);
    env->PopLocalFrame(nullptr);
}

jfloat ViewTransform::getfixedLayerMarginBottom() {
    JNIEnv *env = GetJNIForThread();
    return env->GetFloatField(wrapped_obj, jfixedLayerMarginBottom);
}

void ViewTransform::setfixedLayerMarginBottom(jfloat a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetFloatField(wrapped_obj, jfixedLayerMarginBottom, a0);
}

jfloat ViewTransform::getfixedLayerMarginLeft() {
    JNIEnv *env = GetJNIForThread();
    return env->GetFloatField(wrapped_obj, jfixedLayerMarginLeft);
}

void ViewTransform::setfixedLayerMarginLeft(jfloat a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetFloatField(wrapped_obj, jfixedLayerMarginLeft, a0);
}

jfloat ViewTransform::getfixedLayerMarginRight() {
    JNIEnv *env = GetJNIForThread();
    return env->GetFloatField(wrapped_obj, jfixedLayerMarginRight);
}

void ViewTransform::setfixedLayerMarginRight(jfloat a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetFloatField(wrapped_obj, jfixedLayerMarginRight, a0);
}

jfloat ViewTransform::getfixedLayerMarginTop() {
    JNIEnv *env = GetJNIForThread();
    return env->GetFloatField(wrapped_obj, jfixedLayerMarginTop);
}

void ViewTransform::setfixedLayerMarginTop(jfloat a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetFloatField(wrapped_obj, jfixedLayerMarginTop, a0);
}

jfloat ViewTransform::getoffsetX() {
    JNIEnv *env = GetJNIForThread();
    return env->GetFloatField(wrapped_obj, joffsetX);
}

void ViewTransform::setoffsetX(jfloat a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetFloatField(wrapped_obj, joffsetX, a0);
}

jfloat ViewTransform::getoffsetY() {
    JNIEnv *env = GetJNIForThread();
    return env->GetFloatField(wrapped_obj, joffsetY);
}

void ViewTransform::setoffsetY(jfloat a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetFloatField(wrapped_obj, joffsetY, a0);
}

jfloat ViewTransform::getscale() {
    JNIEnv *env = GetJNIForThread();
    return env->GetFloatField(wrapped_obj, jscale);
}

void ViewTransform::setscale(jfloat a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetFloatField(wrapped_obj, jscale, a0);
}

jfloat ViewTransform::getx() {
    JNIEnv *env = GetJNIForThread();
    return env->GetFloatField(wrapped_obj, jx);
}

void ViewTransform::setx(jfloat a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetFloatField(wrapped_obj, jx, a0);
}

jfloat ViewTransform::gety() {
    JNIEnv *env = GetJNIForThread();
    return env->GetFloatField(wrapped_obj, jy);
}

void ViewTransform::sety(jfloat a0) {
    JNIEnv *env = GetJNIForThread();
    env->SetFloatField(wrapped_obj, jy, a0);
}
jclass NativeZip::mNativeZipClass = 0;
jmethodID NativeZip::jCreateInputStream = 0;
void NativeZip::InitStubs(JNIEnv *jEnv) {
    initInit();

    mNativeZipClass = getClassGlobalRef("org/mozilla/gecko/mozglue/NativeZip");
    jCreateInputStream = getMethod("createInputStream", "(Ljava/nio/ByteBuffer;I)Ljava/io/InputStream;");
}

NativeZip* NativeZip::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    NativeZip* ret = new NativeZip(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

jobject NativeZip::CreateInputStream(jobject a0, int32_t a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(2) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallObjectMethod(wrapped_obj, jCreateInputStream, a0, a1);
    AndroidBridge::HandleUncaughtException(env);
    jobject ret = static_cast<jobject>(env->PopLocalFrame(temp));
    return ret;
}
jclass MatrixBlobCursor::mMatrixBlobCursorClass = 0;
jmethodID MatrixBlobCursor::jMatrixBlobCursor = 0;
jmethodID MatrixBlobCursor::jMatrixBlobCursor0 = 0;
jmethodID MatrixBlobCursor::jAddRow = 0;
jmethodID MatrixBlobCursor::jAddRow1 = 0;
jmethodID MatrixBlobCursor::jAddRow2 = 0;
void MatrixBlobCursor::InitStubs(JNIEnv *jEnv) {
    initInit();

    mMatrixBlobCursorClass = getClassGlobalRef("org/mozilla/gecko/sqlite/MatrixBlobCursor");
    jMatrixBlobCursor = getMethod("<init>", "([Ljava/lang/String;)V");
    jMatrixBlobCursor0 = getMethod("<init>", "([Ljava/lang/String;I)V");
    jAddRow = getMethod("addRow", "(Ljava/lang/Iterable;)V");
    jAddRow1 = getMethod("addRow", "(Ljava/util/ArrayList;I)V");
    jAddRow2 = getMethod("addRow", "([Ljava/lang/Object;)V");
}

MatrixBlobCursor* MatrixBlobCursor::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    MatrixBlobCursor* ret = new MatrixBlobCursor(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

MatrixBlobCursor::MatrixBlobCursor(jobjectArray a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    Init(env->NewObject(mMatrixBlobCursorClass, jMatrixBlobCursor, a0), env);
    env->PopLocalFrame(nullptr);
}

MatrixBlobCursor::MatrixBlobCursor(jobjectArray a0, int32_t a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    Init(env->NewObject(mMatrixBlobCursorClass, jMatrixBlobCursor0, a0, a1), env);
    env->PopLocalFrame(nullptr);
}

void MatrixBlobCursor::AddRow(jobject a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallVoidMethod(wrapped_obj, jAddRow, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void MatrixBlobCursor::AddRow(jobject a0, int32_t a1) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallVoidMethod(wrapped_obj, jAddRow1, a0, a1);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void MatrixBlobCursor::AddRow(jobjectArray a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallVoidMethod(wrapped_obj, jAddRow2, a0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}
jclass SQLiteBridgeException::mSQLiteBridgeExceptionClass = 0;
jmethodID SQLiteBridgeException::jSQLiteBridgeException = 0;
jmethodID SQLiteBridgeException::jSQLiteBridgeException0 = 0;
jfieldID SQLiteBridgeException::jserialVersionUID = 0;
void SQLiteBridgeException::InitStubs(JNIEnv *jEnv) {
    initInit();

    mSQLiteBridgeExceptionClass = getClassGlobalRef("org/mozilla/gecko/sqlite/SQLiteBridgeException");
    jSQLiteBridgeException = getMethod("<init>", "()V");
    jSQLiteBridgeException0 = getMethod("<init>", "(Ljava/lang/String;)V");
    jserialVersionUID = getStaticField("serialVersionUID", "J");
}

SQLiteBridgeException* SQLiteBridgeException::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    SQLiteBridgeException* ret = new SQLiteBridgeException(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

SQLiteBridgeException::SQLiteBridgeException() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    Init(env->NewObject(mSQLiteBridgeExceptionClass, jSQLiteBridgeException), env);
    env->PopLocalFrame(nullptr);
}

SQLiteBridgeException::SQLiteBridgeException(const nsAString& a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);

    Init(env->NewObject(mSQLiteBridgeExceptionClass, jSQLiteBridgeException0, j0), env);
    env->PopLocalFrame(nullptr);
}

int64_t SQLiteBridgeException::getserialVersionUID() {
    JNIEnv *env = GetJNIForThread();
    return env->GetStaticLongField(mSQLiteBridgeExceptionClass, jserialVersionUID);
}
jclass Clipboard::mClipboardClass = 0;
jmethodID Clipboard::jClearText = 0;
jmethodID Clipboard::jGetClipboardTextWrapper = 0;
jmethodID Clipboard::jHasText = 0;
jmethodID Clipboard::jSetClipboardText = 0;
void Clipboard::InitStubs(JNIEnv *jEnv) {
    initInit();

    mClipboardClass = getClassGlobalRef("org/mozilla/gecko/util/Clipboard");
    jClearText = getStaticMethod("clearText", "()V");
    jGetClipboardTextWrapper = getStaticMethod("getText", "()Ljava/lang/String;");
    jHasText = getStaticMethod("hasText", "()Z");
    jSetClipboardText = getStaticMethod("setText", "(Ljava/lang/CharSequence;)V");
}

Clipboard* Clipboard::Wrap(jobject obj) {
    JNIEnv *env = GetJNIForThread();
    Clipboard* ret = new Clipboard(obj, env);
    env->DeleteLocalRef(obj);
    return ret;
}

void Clipboard::ClearText() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    env->CallStaticVoidMethod(mClipboardClass, jClearText);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

jstring Clipboard::GetClipboardTextWrapper() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jobject temp = env->CallStaticObjectMethod(mClipboardClass, jGetClipboardTextWrapper);
    AndroidBridge::HandleUncaughtException(env);
    jstring ret = static_cast<jstring>(env->PopLocalFrame(temp));
    return ret;
}

bool Clipboard::HasText() {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(0) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    bool temp = env->CallStaticBooleanMethod(mClipboardClass, jHasText);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
    return temp;
}

void Clipboard::SetClipboardText(const nsAString& a0) {
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (env->PushLocalFrame(1) != 0) {
        AndroidBridge::HandleUncaughtException(env);
        MOZ_CRASH("Exception should have caused crash.");
    }

    jstring j0 = AndroidBridge::NewJavaString(env, a0);

    env->CallStaticVoidMethod(mClipboardClass, jSetClipboardText, j0);
    AndroidBridge::HandleUncaughtException(env);
    env->PopLocalFrame(nullptr);
}

void InitStubs(JNIEnv *jEnv) {
    GeckoAppShell::InitStubs(jEnv);
    JavaDomKeyLocation::InitStubs(jEnv);
    GeckoJavaSampler::InitStubs(jEnv);
    SurfaceBits::InitStubs(jEnv);
    ThumbnailHelper::InitStubs(jEnv);
    DisplayPortMetrics::InitStubs(jEnv);
    GLController::InitStubs(jEnv);
    GeckoLayerClient::InitStubs(jEnv);
    ImmutableViewportMetrics::InitStubs(jEnv);
    LayerView::InitStubs(jEnv);
    NativePanZoomController::InitStubs(jEnv);
    ProgressiveUpdateData::InitStubs(jEnv);
    ViewTransform::InitStubs(jEnv);
    NativeZip::InitStubs(jEnv);
    MatrixBlobCursor::InitStubs(jEnv);
    SQLiteBridgeException::InitStubs(jEnv);
    Clipboard::InitStubs(jEnv);
}
} /* android */
} /* widget */
} /* mozilla */
