[Android]Binder提早关掉致使通信失败

1.提早关掉/dev/binderandroid

IPCThreadState::self()->stopProcess();atom

  1. 若是此时有如下相似代码,还要去获取某一个service,会一直死循环

gAudioFlingerClient因为media server crash,会被clear,可是defaultServiceManager()是正常的,一直存在全局变量里spa

const sp<IAudioFlinger>& AudioSystem::get_audio_flinger() {code

Mutex::Autolock _l(gLock);
if (gAudioFlinger == 0) {
    sp<IServiceManager> sm = defaultServiceManager();
    sp<IBinder> binder;
    do {
        binder = sm->getService(String16("media.audio_flinger"));
        if (binder != 0)
            break;
        ALOGW("AudioFlinger not published, waiting...");
        usleep(500000); 
    } while (true);

Binder thread如何起来? 经过spawnPooledThread()能够起来相似"Binder_2"名字的thread.server

会有几个Binder thread?get

void ProcessState::spawnPooledThread(bool isMain) { if (mThreadPoolStarted) { int32_t s = android_atomic_add(1, &mThreadPoolSeq); char buf[16]; snprintf(buf, sizeof(buf), "Binder_%X", s); ALOGV("Spawning new pooled thread, name=%s\n", buf); sp<Thread> t = new PoolThread(isMain); t->run(buf); } }it

相关文章
相关标签/搜索