1.提前关掉/dev/binder
IPCThreadState::self()->stopProcess();
- 如果此时有以下类似代码,还要去获取某一个service,会一直死循环
gAudioFlingerClient由于media server crash,会被clear,但是defaultServiceManager()是正常的,一直存在全局变量里
const sp<IAudioFlinger>& AudioSystem::get_audio_flinger() {
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.
会有几个Binder thread?
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); } }