Bug 1867925 - Mark some storage-access-api tests as intermittent after wpt-sync....
[gecko.git] / toolkit / xre / nsAndroidStartup.cpp
blobd581dc47a48ce532d608e96e928280bd96a1d7d2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include <android/log.h>
8 #include <jni.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <pthread.h>
14 #include "mozilla/jni/Utils.h"
15 #include "nsTArray.h"
16 #include "nsString.h"
17 #include "nsAppRunner.h"
18 #include "mozilla/Bootstrap.h"
19 #include "XREShellData.h"
21 #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, MOZ_APP_NAME, args)
23 using namespace mozilla;
25 extern "C" NS_EXPORT void GeckoStart(JNIEnv* env, char** argv, int argc,
26 const StaticXREAppData& aAppData,
27 bool xpcshell, const char* outFilePath) {
28 mozilla::jni::SetGeckoThreadEnv(env);
30 if (!argv) {
31 LOG("Failed to get arguments for GeckoStart\n");
32 return;
35 if (xpcshell) {
36 XREShellData shellData;
37 FILE* outFile = fopen(outFilePath, "w");
38 if (!outFile) {
39 LOG("XRE_XPCShellMain cannot open %s", outFilePath);
40 return;
42 // We redirect both stdout and stderr to the same file, to conform with
43 // what runxpcshell.py does on Desktop.
44 shellData.outFile = outFile;
45 shellData.errFile = outFile;
46 int result = XRE_XPCShellMain(argc, argv, nullptr, &shellData);
47 fclose(shellData.outFile);
48 if (result) LOG("XRE_XPCShellMain returned %d", result);
49 } else {
50 BootstrapConfig config;
51 config.appData = &aAppData;
52 config.appDataPath = nullptr;
54 int result = XRE_main(argc, argv, config);
55 if (result) LOG("XRE_main returned %d", result);