Beispiel #1
0
static void *thread_wrapper ( void* value)
{
    LOGE("thread wrapper");
    int pts;
    char** thread_arg = (char**)value;

    global_vm->AttachCurrentThread(&global_env, NULL);

        setsid();
        
        pts = open(thread_arg[0], O_RDWR);
        if(pts < 0){
            LOGE("PTY open failed");
            pth_exit(-1);
        }

        dup2(pts, 0);
        dup2(pts, 1);
        dup2(pts, 2);

        char* argv[3];
        argv[0] = (char*)"vim";
        argv[1] = (char*)thread_arg[1];
        argv[2] = NULL;

        int val = setjmp(longjmp_env);

        if (val == 0)
            AndroidMain(argv[1]?2:1, (char**)argv);

    global_vm->DetachCurrentThread();
    LOGE("thread leave");
    pthread_mutex_destroy(&global_mutex);
    pth_exit(0);
}
void android_main(struct android_app* state)
{
	FPlatformMisc::LowLevelOutputDebugString(L"Entering native app glue main function");
	
	GNativeAndroidApp = state;
	check(GNativeAndroidApp);

	pthread_attr_t otherAttr; 
	pthread_attr_init(&otherAttr);
	pthread_attr_setdetachstate(&otherAttr, PTHREAD_CREATE_DETACHED);
	pthread_create(&G_AndroidEventThread, &otherAttr, AndroidEventThreadWorker, state);

	FPlatformMisc::LowLevelOutputDebugString(L"Created event thread");

	// Make sure glue isn't stripped.
	app_dummy();

	//@todo android: replace with native activity, main loop off of UI thread, etc.
	AndroidMain(state);
}