MCPcopy Create free account
hub / github.com/ConfettiFX/The-Forge / AndroidMain

Function AndroidMain

Common_3/OS/Android/AndroidBase.cpp:613–999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611const char** IApp::argv;
612
613int AndroidMain(void* param, IApp* app)
614{
615 if (!initMemAlloc(app->GetName()))
616 {
617 while (0 > __android_log_print(ANDROID_LOG_ERROR, "The-Forge", "Error starting application"))
618 ;
619 return EXIT_FAILURE;
620 }
621
622 struct android_app* android_app = (struct android_app*)param;
623
624 FileSystemInitDesc fsDesc = {};
625 fsDesc.pPlatformData = android_app->activity;
626 fsDesc.pAppName = app->GetName();
627 if (!initFileSystem(&fsDesc))
628 {
629 while (0 > __android_log_print(ANDROID_LOG_ERROR, "The-Forge", "Error starting application"))
630 ;
631 return EXIT_FAILURE;
632 }
633
634 initLog(app->GetName(), DEFAULT_LOG_LEVEL);
635
636 snprintf(gOsInfo.osName, 256, "Android");
637 bool knownVersion = __system_property_get("ro.build.version.sdk", gOsInfo.osVersion);
638 bool knownModel = __system_property_get("ro.product.model", gOsInfo.osDeviceName);
639 LOGF(LogLevel::eINFO, "Operating System: %s. Version: %s. Device Name: %s.", gOsInfo.osName,
640 knownVersion ? gOsInfo.osVersion : "Unknown Version", knownModel ? gOsInfo.osDeviceName : "Unknown Model");
641
642 android_app->activity->vm->AttachCurrentThread(&pMainJavaEnv, NULL);
643
644 // Set the callback to process system events
645 gWindow.handle.type = WINDOW_HANDLE_TYPE_ANDROID;
646 gWindow.handle.activity = android_app->activity;
647 gWindow.handle.configuration = android_app->config;
648 gWindow.cursorCaptured = false;
649 gWindowDesc = &gWindow;
650
651 android_app->onAppCmd = handle_cmd;
652 pApp = app;
653 pWindowAppRef = app;
654
655 MemoryAdvice_ErrorCode code = MemoryAdvice_init(pMainJavaEnv, gWindow.handle.activity->clazz);
656 if (code == MEMORYADVICE_ERROR_OK)
657 {
658 code = MemoryAdvice_registerWatcher(1000.0f, memoryStateWatcherCallback, NULL);
659 gMemoryState = MEMORY_STATE_OK;
660 if (code != MEMORYADVICE_ERROR_OK)
661 {
662 LOGF(eWARNING, "Unable to register Memory Advice watcher.");
663 }
664 }
665
666 // Used for automated testing, if enabled app will exit after DEFAULT_AUTOMATION_FRAME_COUNT (240) frames
667#ifdef AUTOMATED_TESTING
668 uint32_t testingFrameCount = 0;
669 uint32_t targetFrameCount = DEFAULT_AUTOMATION_FRAME_COUNT;
670#endif

Callers

nothing calls this directly

Calls 15

initLogFunction · 0.85
initCpuInfoFunction · 0.85
initHiresTimerFunction · 0.85
InitOpenXRLoaderFunction · 0.85
CreateOpenXRInstanceFunction · 0.85
InitOpenXRSystemFunction · 0.85
getRecommendedResolutionFunction · 0.85
getRectWidthFunction · 0.85
getRectHeightFunction · 0.85
getBenchmarkArgumentsFunction · 0.85
processAllEventsFunction · 0.85

Tested by

no test coverage detected