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>
14 #include "mozilla/jni/Utils.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
);
31 LOG("Failed to get arguments for GeckoStart\n");
36 XREShellData shellData
;
37 FILE* outFile
= fopen(outFilePath
, "w");
39 LOG("XRE_XPCShellMain cannot open %s", outFilePath
);
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
);
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
);