wpa_supplicant AIDL service的启动流程,这里直接从startSupplicant
开始
中间没什么好说的,在getSupplicantMockable
中会调用ServiceManager.waitForDeclaredService(HAL_INSTANCE_NAME))
,它会启动AIDL service并返回IBinder对象
packages/modules/Wifi/service/java/com/android/server/wifi/SupplicantStaIfaceHalAidlImpl.java
protected ISupplicant getSupplicantMockable() {
synchronized (mLock) {
try {
if (SdkLevel.isAtLeastT()) {
return ISupplicant.Stub.asInterface(
ServiceManager.waitForDeclaredService(HAL_INSTANCE_NAME));
} else {
return null;
}
} catch (Exception e) {
Log.e(TAG, "Unable to get ISupplicant service, " + e);
return null;
}
}
}
wpa_supplicant AIDL service的注册是在 aidl_manager.cpp中的registerAidlService
中完成的。
int AidlManager::registerAidlService(struct wpa_global *global)
{
// Create the main aidl service object and register it.
wpa_printf(MSG_INFO, "Starting AIDL supplicant");
wpa_printf(MSG_INFO, "Interface version: %d", Supplicant::version);
supplicant_object_ = ndk::SharedRefBase::make<Supplicant>(global);
wpa_global_ = global;
std::string instance = std::string() + Supplicant::descriptor + "/default";
if (AServiceManager_addService(supplicant_object_->asBinder().get(),//在这里进行注册
instance.c_str()) != STATUS_OK)
{
return 1;
}
// Initialize the death notifier.
death_notifier_ = AIBinder_DeathRecipient_new(onDeath);
return 0;
}