2010-06-04 05:16:20 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-06-04 05:16:20 +04:00
|
|
|
|
|
|
|
#include <android/log.h>
|
|
|
|
|
|
|
|
#include <jni.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
|
2015-08-13 07:53:40 +03:00
|
|
|
#include "mozilla/jni/Utils.h"
|
2010-06-04 05:16:20 +04:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsString.h"
|
2012-06-06 06:08:30 +04:00
|
|
|
#include "nsIFile.h"
|
2010-06-04 05:16:20 +04:00
|
|
|
#include "nsAppRunner.h"
|
2010-10-21 04:44:03 +04:00
|
|
|
#include "APKOpen.h"
|
|
|
|
#include "nsExceptionHandler.h"
|
2010-06-04 05:16:20 +04:00
|
|
|
|
|
|
|
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, MOZ_APP_NAME, args)
|
|
|
|
|
2012-02-22 11:12:15 +04:00
|
|
|
extern "C" NS_EXPORT void
|
2015-08-13 07:53:40 +03:00
|
|
|
GeckoStart(JNIEnv* env, char* data, const nsXREAppData* appData)
|
2010-06-04 05:16:20 +04:00
|
|
|
{
|
2015-08-13 07:53:40 +03:00
|
|
|
mozilla::jni::SetGeckoThreadEnv(env);
|
|
|
|
|
2010-10-21 04:44:03 +04:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2010-10-29 23:22:28 +04:00
|
|
|
const struct mapping_info *info = getLibraryMapping();
|
2010-10-21 04:44:03 +04:00
|
|
|
while (info->name) {
|
2013-04-09 16:04:53 +04:00
|
|
|
CrashReporter::AddLibraryMapping(info->name, info->base,
|
2010-10-21 04:44:03 +04:00
|
|
|
info->len, info->offset);
|
|
|
|
info++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-06-04 05:16:20 +04:00
|
|
|
if (!data) {
|
|
|
|
LOG("Failed to get arguments for GeckoStart\n");
|
2012-02-22 11:12:15 +04:00
|
|
|
return;
|
2010-06-04 05:16:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<char *> targs;
|
2015-08-13 07:53:40 +03:00
|
|
|
char *arg = strtok(data, " ");
|
2010-06-04 05:16:20 +04:00
|
|
|
while (arg) {
|
|
|
|
targs.AppendElement(arg);
|
2013-10-11 00:36:42 +04:00
|
|
|
arg = strtok(nullptr, " ");
|
2010-06-04 05:16:20 +04:00
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
targs.AppendElement(static_cast<char *>(nullptr));
|
2010-10-21 04:44:03 +04:00
|
|
|
|
2012-05-25 14:01:29 +04:00
|
|
|
int result = XRE_main(targs.Length() - 1, targs.Elements(), appData, 0);
|
2010-06-04 05:16:20 +04:00
|
|
|
|
|
|
|
if (result)
|
|
|
|
LOG("XRE_main returned %d", result);
|
|
|
|
}
|