// static
void *TimedEventQueue::ThreadWrapper(void *me) {

#ifdef ANDROID_SIMULATOR
    // The simulator runs everything as one process, so any
    // Binder calls happen on this thread instead of a thread
    // in another process. We therefore need to make sure that
    // this thread can do calls into interpreted code.
    // On the device this is not an issue because the remote
    // thread will already be set up correctly for this.
    JavaVM *vm;
    int numvms;
    JNI_GetCreatedJavaVMs(&vm, 1, &numvms);
    JNIEnv *env;
    vm->AttachCurrentThread(&env, NULL);
#endif

#ifndef TARGET_OMAP4
    setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_FOREGROUND);
#else
    setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_URGENT_AUDIO);
#endif
    set_sched_policy(androidGetTid(), SP_FOREGROUND);

    static_cast<TimedEventQueue *>(me)->threadEntry();

#ifdef ANDROID_SIMULATOR
    vm->DetachCurrentThread();
#endif
    return NULL;
}
예제 #2
0
 AutoPrioritySaver()
     : mTID(androidGetTid()),
       mPrevPriority(androidGetThreadPriority(mTID)) {
     androidSetThreadPriority(mTID, ANDROID_PRIORITY_NORMAL);
 }