static void* android_app_entry(void* param) { struct android_app* android_app = (struct android_app*)param; android_app->config = AConfiguration_new(); AConfiguration_fromAssetManager(android_app->config, android_app->activity->assetManager); print_cur_config(android_app); android_app->cmdPollSource.id = LOOPER_ID_MAIN; android_app->cmdPollSource.app = android_app; android_app->cmdPollSource.process = process_cmd; android_app->inputPollSource.id = LOOPER_ID_INPUT; android_app->inputPollSource.app = android_app; android_app->inputPollSource.process = process_input; ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN, ALOOPER_EVENT_INPUT, NULL, &android_app->cmdPollSource); android_app->looper = looper; pthread_mutex_lock(&android_app->mutex); android_app->running = 1; pthread_cond_broadcast(&android_app->cond); pthread_mutex_unlock(&android_app->mutex); android_main(android_app); android_app_destroy(android_app); return NULL; }
JNIEXPORT void JNICALL Java_com_seleuco_mame4droid_Emulator_runT (JNIEnv *env, jclass c){ #ifdef DEBUG __android_log_print(ANDROID_LOG_DEBUG, "mame4droid-jni", "runThread"); #endif if(android_main!=NULL) android_main(0, NULL); else __android_log_print(ANDROID_LOG_WARN, "mame4droid-jni", "error no android main!"); }
jstring Java_net_itskewpie_freerdp_FreeRDPActivity_test(JNIEnv* env, jobject thiz ) { //freerdp_new(); android_main(); //printf("%d",a); return (*env)->NewStringUTF(env, "HELLO~~~~~~~~~~~~~~~~~~~"); /* androidfreerdp_new( printf("freerdp jni"); return */ }
JNIEXPORT void JNICALL Java_com_seleuco_mame4all_Emulator_init (JNIEnv *env, jclass c, jstring s1, jstring s2) { __android_log_print(ANDROID_LOG_INFO, "mame4all-jni", "init"); const char *str1 = (*env)->GetStringUTFChars(env, s1, 0); load_lib(str1); (*env)->ReleaseStringUTFChars(env, s1, str1); setVideoCallbacks(&myJNI_initVideo,&myJNI_dumpVideo,&myJNI_changeVideo); setAudioCallbacks(&myJNI_openAudio,&myJNI_dumpAudio,&myJNI_closeAudio); const char *str2 = (*env)->GetStringUTFChars(env, s2, 0); __android_log_print(ANDROID_LOG_INFO, "mame4all-jni", "path %s",str2); setGlobalPath(str2); (*env)->ReleaseStringUTFChars(env, s2, str2); //int i = pthread_create(&main_tid, NULL, app_Thread_Start, NULL); //if(i!=0)__android_log_print(ANDROID_LOG_ERROR, "mame4all-jni", "Error setting creating pthread %d",i); //struct sched_param param; //param.sched_priority = 63; //param.sched_priority = 46; //param.sched_priority = 100; /* if(pthread_setschedparam(main_tid, SCHED_RR, ¶m) != 0) { __android_log_print(ANDROID_LOG_ERROR, "mame4all-jni", "Error setting pthread priority"); return; } */ android_main(0, NULL); }
int main( int argc, char* argv[] ) { int i; char screenres[128] = "640x480x24"; char clientcmd[PATH_MAX] = ""; char * cmd = ""; char fontpath[PATH_MAX] = ""; char* args[64] = { "XSDL", port, "-nolock", "-noreset", "-nopn", "-nolisten", "unix", "-fp", fontpath, "-screen", screenres, }; int argnum = 11; char * envp[] = { NULL }; int printHelp = 1; int screenResOverride = 0; int screenButtons = 0; int warnDiskSpaceMb = 0; int builtinKeyboard = 0; int resolutionW = atoi(getenv("DISPLAY_RESOLUTION_WIDTH")); int resolutionH = atoi(getenv("DISPLAY_RESOLUTION_HEIGHT")); int displayW = atoi(getenv("DISPLAY_WIDTH_MM")); int displayH = atoi(getenv("DISPLAY_HEIGHT_MM")); __android_log_print(ANDROID_LOG_INFO, "XSDL", "Actual video resolution %d/%dx%d/%d", resolutionW, displayW, resolutionH, displayH); setupEnv(); SDL_ANDROID_SetScreenKeyboardShown(0); XSDL_initSDL(); while( argc > 1 ) { if( argv[1][0] == ':') { strcpy(port, argv[1]); } else if( strcmp(argv[1], "-nohelp") == 0 ) { printHelp = 0; } else if( strcmp(argv[1], "-screen") == 0 ) { screenResOverride = 1; argc--; argv++; strcpy(screenres, argv[1]); } else if( strcmp(argv[1], "-screenbuttons") == 0 ) { screenButtons = 1; } else if( strcmp(argv[1], "-warndiskspacemb") == 0 && argc > 2 ) { warnDiskSpaceMb = atoi(argv[2]); argc--; argv++; } else { args[argnum] = argv[1]; argnum++; } argc--; argv++; } if (getenv("SDL_RESTART_PARAMS") && getenv("SDL_RESTART_PARAMS")[0]) strcpy(port, getenv("SDL_RESTART_PARAMS")); snprintf(fontpath, sizeof(fontpath), "%s/img/usr/share/fonts/X11/misc," "%s/img/usr/share/fonts/X11/Type1," "%s/img/usr/share/fonts/X11/100dpi," "%s/img/usr/share/fonts/X11/75dpi," "%s/img/usr/share/fonts/X11/cyrillic," "%s/usr/share/fonts", getenv("SECURE_STORAGE_DIR"), getenv("SECURE_STORAGE_DIR"), getenv("SECURE_STORAGE_DIR"), getenv("SECURE_STORAGE_DIR"), getenv("SECURE_STORAGE_DIR"), getenv("SECURE_STORAGE_DIR") ); XSDL_unpackFiles(warnDiskSpaceMb); if( !screenResOverride ) { XSDL_showConfigMenu(&resolutionW, &displayW, &resolutionH, &displayH, &builtinKeyboard, &screenButtons); sprintf( screenres, "%d/%dx%d/%dx%d", resolutionW, displayW, resolutionH, displayH, SDL_GetVideoInfo()->vfmt->BitsPerPixel ); } XSDL_generateBackground( port, printHelp, resolutionW, resolutionH ); XSDL_deinitSDL(); if( printHelp ) { sprintf( clientcmd, "%s/usr/bin/xhost + ; %s/usr/bin/xli -onroot -center %s/background.bmp", getenv("SECURE_STORAGE_DIR"), getenv("SECURE_STORAGE_DIR"), getenv("UNSECURE_STORAGE_DIR") ); args[argnum] = "-exec"; args[argnum+1] = clientcmd; argnum += 2; } SDL_ANDROID_SetScreenKeyboardShown( 1 ); if( screenButtons && !SDL_ANDROID_GetScreenKeyboardRedefinedByUser() ) { // Button coords are handled inside xserver/hw/kdrive/sdl/sdl.c SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, 1); } else { SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, 0); SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_1, 0); SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, 0); } { char s[16]; sprintf(s, "%d", builtinKeyboard); setenv("XSDL_BUILTIN_KEYBOARD", s, 1); } __android_log_print(ANDROID_LOG_INFO, "XSDL", "XSDL video resolution %s, args:", screenres); for( i = 0; i < argnum; i++ ) __android_log_print(ANDROID_LOG_INFO, "XSDL", "> %s", args[i]); // We should never quit. If that happens, then the server did not start - try with different port number. atexit( &retryLaunchWithDifferentPort ); __android_log_print(ANDROID_LOG_INFO, "XSDL", "XSDL chdir to: %s", getenv("SECURE_STORAGE_DIR")); chdir( getenv("SECURE_STORAGE_DIR") ); // Megahack: change /proc/self/cwd to the X.org data dir, and use /proc/self/cwd path in libX11 android_main( argnum, args, envp ); // Should never exit on success, if we want to terminate we kill ourselves return 0; }
void* app_Thread_Start(void* args) { android_main(0, NULL); return NULL; }
extern "C" void android_dummy() { android_main(NULL); main(0, NULL); }
int foundation_initialize(const memory_system_t memory, const application_t application, const foundation_config_t config) { int ret = 0; if (_initialized) return 0; process_set_exit_code(PROCESS_EXIT_SUCCESS); foundation_initialize_config(config); /*lint -e774 */ SUBSYSTEM_INIT(atomic); SUBSYSTEM_INIT_ARGS(memory, memory); SUBSYSTEM_INIT(static_hash); SUBSYSTEM_INIT(log); SUBSYSTEM_INIT(time); SUBSYSTEM_INIT(thread); SUBSYSTEM_INIT(random); SUBSYSTEM_INIT(stream); SUBSYSTEM_INIT(fs); SUBSYSTEM_INIT(stacktrace); SUBSYSTEM_INIT(exception); SUBSYSTEM_INIT_ARGS(environment, application); SUBSYSTEM_INIT(library); SUBSYSTEM_INIT(system); if (ret) return ret; //Parse built-in command line options { /*lint --e{613} */ const string_const_t* cmdline = environment_command_line(); size_t iarg, argsize; for (iarg = 0, argsize = array_size(cmdline); iarg < argsize; ++iarg) { string_const_t arg = cmdline[iarg]; if (string_equal(arg.str, arg.length, STRING_CONST("--log-debug"))) log_set_suppress(0, ERRORLEVEL_NONE); else if (string_equal(arg.str, arg.length, STRING_CONST("--log-info"))) log_set_suppress(0, ERRORLEVEL_DEBUG); else if (string_equal(arg.str, arg.length, STRING_CONST("--log-warning"))) log_set_suppress(0, ERRORLEVEL_WARNING); else if (string_equal(arg.str, arg.length, STRING_CONST("--log-error"))) log_set_suppress(0, ERRORLEVEL_ERROR); } } #if !BUILD_DYNAMIC_LINK //Artificial references /*lint -e506 */ #if FOUNDATION_PLATFORM_ANDROID android_main(0); #elif FOUNDATION_PLATFORM_PNACL if (((uintptr_t)PPP_InitializeModule < 1) || ((uintptr_t)PPP_GetInterface < 1) || ((uintptr_t)PPP_ShutdownModule < 1)) return -1; #else if ((uintptr_t)main < 1) return -1; #endif #endif _initialized = true; return 0; }
int main(int argc, char* argv[]) { char * envp[] = { NULL }; return android_main(argc, argv, envp); }