audio service详解

本文基于android11

一 audio service

android源码frameworks/base/services/java/com/android/server/SystemServer.java,

         普通client或者server在获得servicemanger的proxy对象后,肯定就要使用了。对于server来说,主要是调用addService,向serivceManager注册。而client则是通过serivcemanager查询所需server的信息,然后得到server的proxy对象。
         关注ServiceManager.addService和mSystemServiceManager.startService

// Create the system service manager.
mSystemServiceManager = new SystemServiceManager(mSystemContext);
mSystemServiceManager.setStartInfo(mRuntimeRestart,
mRuntimeStartElapsedTime, mRuntimeStartUptime);
LocalServices.addService(SystemServiceManager.class, mSystemServiceManager);

// Start services.
startBootstrapServices();
startCoreServices();
startOtherServices();


 

ServiceManager.addService(Context.PLATFORM_COMPAT_SERVICE, platformCompat);  in startBootstrapServices()
ServiceManager.addService(Context.PLATFORM_COMPAT_NATIVE_SERVICE,  in startBootstrapServices()
ServiceManager.addService("sec_key_att_app_id_provider",  in startOtherServices()
ServiceManager.addService("scheduling_policy", new SchedulingPolicyService());  in startOtherServices()
ServiceManager.addService("telephony.registry", telephonyRegistry);  in startOtherServices()
ServiceManager.addService(Context.TBOX_SERVICE, new TboxService());  in startOtherServices()
ServiceManager.addService(Context.XCALL_SERVICE, new TboxXCallService());  in startOtherServices()
ServiceManager.addService("vibrator", vibrator);  in startOtherServices()
ServiceManager.addService("dynamic_system", dynamicSystem);  in startOtherServices()
ServiceManager.addService(Context.CONSUMER_IR_SERVICE, consumerIr);  in startOtherServices()
ServiceManager.addService(Context.WINDOW_SERVICE, wm, /* allowIsolated= */ false,  in startOtherServices()
ServiceManager.addService(Context.INPUT_SERVICE, inputManager,  in startOtherServices()
ServiceManager.addService(Context.STATUS_BAR_SERVICE, statusBar);  in startOtherServices()
ServiceManager.addService(Context.NETWORKMANAGEMENT_SERVICE, networkManagement);  in startOtherServices()
ServiceManager.addService(Context.IPSEC_SERVICE, ipSecService);  in startOtherServices()
ServiceManager.addService(Context.NETWORK_STATS_SERVICE, networkStats);  in startOtherServices()
ServiceManager.addService(Context.NETWORK_POLICY_SERVICE, networkPolicy);  in startOtherServices()
ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity,  in startOtherServices()
ServiceManager.addService(  in startOtherServices()
ServiceManager.addService(Context.SYSTEM_UPDATE_SERVICE,  in startOtherServices()
ServiceManager.addService(Context.UPDATE_LOCK_SERVICE,  in startOtherServices()
ServiceManager.addService(Context.COUNTRY_DETECTOR, countryDetector);  in startOtherServices()
ServiceManager.addService(Context.SERIAL_SERVICE, serial);  in startOtherServices()
ServiceManager.addService(Context.HARDWARE_PROPERTIES_SERVICE,  in startOtherServices()
ServiceManager.addService("diskstats", new DiskStatsService(context));  in startOtherServices()
ServiceManager.addService("runtime", new RuntimeService(context));  in startOtherServices()
ServiceManager.addService("network_time_update_service", networkTimeUpdater);  in startOtherServices()
ServiceManager.addService(GraphicsStatsService.GRAPHICS_STATS_SERVICE,  in startOtherServices()
ServiceManager.addService(CoverageService.COVERAGE_SERVICE, new CoverageService());  in startOtherServices()
ServiceManager.addService(Context.MEDIA_ROUTER_SERVICE, mediaRouter);  in startOtherServices()
ServiceManager.addService(Context.TETHERING_SERVICE, service,  in startOtherServices()

mSystemServiceManager.startService(FileIntegrityService.class);  in startBootstrapServices()
Installer installer = mSystemServiceManager.startService(Installer.class);  in startBootstrapServices()
mSystemServiceManager.startService(DeviceIdentifiersPolicyService.class);  in startBootstrapServices()
mSystemServiceManager.startService(UriGrantsManagerService.Lifecycle.class);  in startBootstrapServices()
ActivityTaskManagerService atm = mSystemServiceManager.startService(  in startBootstrapServices()
mActivityManagerService = ActivityManagerService.Lifecycle.startService(  in startBootstrapServices()
mDataLoaderManagerService = mSystemServiceManager.startService(  in startBootstrapServices()
mPowerManagerService = mSystemServiceManager.startService(PowerManagerService.class);  in startBootstrapServices()
mSystemServiceManager.startService(ThermalManagerService.class);  in startBootstrapServices()
mSystemServiceManager.startService(RecoverySystemService.Lifecycle.class);  in startBootstrapServices()
mSystemServiceManager.startService(LightsService.class);  in startBootstrapServices()
mSystemServiceManager.startService(WEAR_SIDEKICK_SERVICE_CLASS);  in startBootstrapServices()
mDisplayManagerService = mSystemServiceManager.startService(DisplayManagerService.class);  in startBootstrapServices()
mSystemServiceManager.startService(UserManagerService.LifeCycle.class);  in startBootstrapServices()
mSystemServiceManager.startService(new OverlayManagerService(mSystemContext));  in startBootstrapServices()
mSystemServiceManager.startService(new SensorPrivacyService(mSystemContext));  in startBootstrapServices()
mSystemServiceManager.startService(SystemConfigService.class);  in startCoreServices()
mSystemServiceManager.startService(BatteryService.class);  in startCoreServices()
mSystemServiceManager.startService(UsageStatsService.class);  in startCoreServices()
mWebViewUpdateService = mSystemServiceManager.startService(WebViewUpdateService.class);  in startCoreServices()
mSystemServiceManager.startService(CachedDeviceStateService.class);  in startCoreServices()
mSystemServiceManager.startService(BinderCallsStatsService.LifeCycle.class);  in startCoreServices()
mSystemServiceManager.startService(LooperStatsService.Lifecycle.class);  in startCoreServices()
mSystemServiceManager.startService(ROLLBACK_MANAGER_SERVICE_CLASS);  in startCoreServices()
mSystemServiceManager.startService(BugreportManagerService.class);  in startCoreServices()
mSystemServiceManager.startService(GpuService.class);  in startCoreServices()
mSystemServiceManager.startService(KeyChainSystemService.class);  in startOtherServices()
mSystemServiceManager.startService(TelecomLoaderService.class);  in startOtherServices()
mSystemServiceManager.startService(ACCOUNT_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(CONTENT_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(DropBoxManagerService.class);  in startOtherServices()
mSystemServiceManager.startService(new AlarmManagerService(context));  in startOtherServices()
mSystemServiceManager.startService(VrManagerService.class);  in startOtherServices()
mSystemServiceManager.startService(BluetoothService.class);  in startOtherServices()
mSystemServiceManager.startService(IpConnectivityMetrics.class);  in startOtherServices()
mSystemServiceManager.startService(NetworkWatchlistService.Lifecycle.class);  in startOtherServices()
mSystemServiceManager.startService(PinnerService.class);  in startOtherServices()
mSystemServiceManager.startService(IorapForwardingService.class);  in startOtherServices()
mSystemServiceManager.startService(AppIntegrityManagerService.class);  in startOtherServices()
mSystemServiceManager.startService(  in startOtherServices()
mSystemServiceManager.startService(InputMethodManagerService.Lifecycle.class);  in startOtherServices()
mSystemServiceManager.startService(ACCESSIBILITY_MANAGER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(STORAGE_MANAGER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(STORAGE_STATS_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(UiModeManagerService.class);  in startOtherServices()
mSystemServiceManager.startService(LOCK_SETTINGS_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(PersistentDataBlockService.class);  in startOtherServices()
mSystemServiceManager.startService(TestHarnessModeService.class);  in startOtherServices()
mSystemServiceManager.startService(OemLockService.class);  in startOtherServices()
mSystemServiceManager.startService(DEVICE_IDLE_CONTROLLER_CLASS);  in startOtherServices()
mSystemServiceManager.startService(DevicePolicyManagerService.Lifecycle.class);  in startOtherServices()
mSystemServiceManager.startService(APP_PREDICTION_MANAGER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(CONTENT_SUGGESTIONS_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(TextServicesManagerService.Lifecycle.class);  in startOtherServices()
startService(TextClassificationManagerService.Lifecycle.class);  in startOtherServices()
mSystemServiceManager.startService(NetworkScoreService.Lifecycle.class);  in startOtherServices()
mSystemServiceManager.startService(LOWPAN_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(ETHERNET_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(NotificationManagerService.class);  in startOtherServices()
mSystemServiceManager.startService(DeviceStorageMonitorService.class);  in startOtherServices()
mSystemServiceManager.startService(LocationManagerService.Lifecycle.class);  in startOtherServices()
mSystemServiceManager.startService(TIME_DETECTOR_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(TIME_ZONE_DETECTOR_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(SEARCH_MANAGER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(WALLPAPER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(AudioService.Lifecycle.class);  in startOtherServices()
mSystemServiceManager.startService(className + "$Lifecycle");  in startOtherServices()
mSystemServiceManager.startService(SoundTriggerMiddlewareService.Lifecycle.class);  in startOtherServices()
mSystemServiceManager.startService(BroadcastRadioService.class);  in startOtherServices()
mSystemServiceManager.startService(DockObserver.class);  in startOtherServices()
mSystemServiceManager.startService(THERMAL_OBSERVER_CLASS);  in startOtherServices()
mSystemServiceManager.startService(MIDI_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(ADB_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(USB_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(TwilightService.class);  in startOtherServices()
mSystemServiceManager.startService(ColorDisplayService.class);  in startOtherServices()
mSystemServiceManager.startService(JOB_SCHEDULER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(SoundTriggerService.class);  in startOtherServices()
mSystemServiceManager.startService(TrustManagerService.class);  in startOtherServices()
mSystemServiceManager.startService(BACKUP_MANAGER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(APPWIDGET_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(new RoleManagerService(  in startOtherServices()
mSystemServiceManager.startService(VOICE_RECOGNITION_MANAGER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(GestureLauncherService.class);  in startOtherServices()
mSystemServiceManager.startService(SensorNotificationService.class);  in startOtherServices()
mSystemServiceManager.startService(ContextHubSystemService.class);  in startOtherServices()
mSystemServiceManager.startService(TIME_ZONE_RULES_MANAGER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(EmergencyAffordanceService.class);  in startOtherServices()
mSystemServiceManager.startService(BLOB_STORE_MANAGER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(DreamManagerService.class);  in startOtherServices()
mSystemServiceManager.startService(PRINT_MANAGER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(COMPANION_DEVICE_MANAGER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(RestrictionsManagerService.class);  in startOtherServices()
mSystemServiceManager.startService(MediaSessionService.class);  in startOtherServices()
mSystemServiceManager.startService(HdmiControlService.class);  in startOtherServices()
mSystemServiceManager.startService(TvInputManagerService.class);  in startOtherServices()
mSystemServiceManager.startService(TunerResourceManagerService.class);  in startOtherServices()
mSystemServiceManager.startService(MediaResourceMonitorService.class);  in startOtherServices()
mSystemServiceManager.startService(TvRemoteService.class);  in startOtherServices()
mSystemServiceManager.startService(FaceService.class);  in startOtherServices()
mSystemServiceManager.startService(IrisService.class);  in startOtherServices()
mSystemServiceManager.startService(FingerprintService.class);  in startOtherServices()
mSystemServiceManager.startService(BiometricService.class);  in startOtherServices()
mSystemServiceManager.startService(AuthService.class);  in startOtherServices()
mSystemServiceManager.startService(ShortcutService.Lifecycle.class);  in startOtherServices()
mSystemServiceManager.startService(LauncherAppsService.class);  in startOtherServices()
mSystemServiceManager.startService(CrossProfileAppsService.class);  in startOtherServices()
mSystemServiceManager.startService(PeopleService.class);  in startOtherServices()
mSystemServiceManager.startService(MediaProjectionManagerService.class);  in startOtherServices()
mSystemServiceManager.startService(WEAR_POWER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(WEAR_CONNECTIVITY_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(WEAR_DISPLAY_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(WEAR_TIME_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(WEAR_LEFTY_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(WEAR_GLOBAL_ACTIONS_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(SLICE_MANAGER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(CameraServiceProxy.class);  in startOtherServices()
mSystemServiceManager.startService(IOT_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(STATS_PULL_ATOM_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(IncidentCompanionService.class);  in startOtherServices()
mmsService = mSystemServiceManager.startService(MmsServiceBroker.class);  in startOtherServices()
mSystemServiceManager.startService(AUTO_FILL_MANAGER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(ClipboardService.class);  in startOtherServices()
mSystemServiceManager.startService(AppBindingService.Lifecycle.class);  in startOtherServices()
mSystemServiceManager.startService(PermissionPolicyService.class);  in startOtherServices()
mSystemServiceManager.startService(className);  in startOtherServices()
mSystemServiceManager.startService(CAR_SERVICE_HELPER_SERVICE_CLASS);  in startOtherServices()
mSystemServiceManager.startService(QisiServiceHelperService.class);  in startOtherServices()
mSystemServiceManager.startService(QisiSystemManagerService.class);  in startOtherServices()
mSystemServiceManager.startService(SYSTEM_CAPTIONS_MANAGER_SERVICE_CLASS);  in startSystemCaptionsManagerService()
mSystemServiceManager.startService(CONTENT_CAPTURE_MANAGER_SERVICE_CLASS);  in startContentCaptureService()
mSystemServiceManager.startService(AttentionManagerService.class);  in startAttentionService()

二 car audio service

framework java层

public CarAudioManager(Car car, IBinder service) {

mService = ICarAudio.Stub.asInterface(service);}-----bp,调用服务

public class CarAudioService extends ICarAudio.Stub implements CarServiceBase ---bn提供服务

public class AppFocusService extends IAppFocus.Stub implements CarServiceBase,BinderInterfaceContainer.BinderEventHandler<IAppFocusOwnershipCallback>

public class CarBluetoothService extends ICarBluetooth.Stub implements CarServiceBase

public class CarMediaService extends ICarMedia.Stub implements CarServiceBase

public final class CarUserService extends ICarUserService.Stub implements CarServiceBase

CarLocalServices.addService(CarFeatureController.class, mFeatureController);  in ICarImpl()
CarLocalServices.addService(CarPowerManagementService.class, mCarPowerManagementService);  in ICarImpl()
CarLocalServices.addService(CarPropertyService.class, mCarPropertyService);  in ICarImpl()
CarLocalServices.addService(CarUserService.class, mCarUserService);  in ICarImpl()
CarLocalServices.addService(CarTrustedDeviceService.class, mCarTrustedDeviceService); 
CarLocalServices.addService(CarUserNoticeService.class, mCarUserNoticeService);
 CarLocalServices.addService(SystemInterface.class, mSystemInterface);  in ICarImpl()
 CarLocalServices.addService(CarDrivingStateService.class, mCarDrivingStateService); 
CarLocalServices.addService(PerUserCarServiceHelper.class, mPerUserCarServiceHelper);
 CarLocalServices.addService(FixedActivityService.class, mFixedActivityService); 
CarLocalServices.addService(VmsBrokerService.class, mVmsBrokerService);  in ICarImpl()
CarLocalServices.addService(CarOccupantZoneService.class, mCarOccupantZoneService);
 CarLocalServices.addService(AppFocusService.class, mAppFocusService);  in ICarImpl()

framework native层

/frameworks/av/media/libaudioclient/IAudioFlinger.cpp

class BpAudioFlingerClient : public BpInterface<IAudioFlingerClient>

class BpAudioFlinger : public BpInterface<IAudioFlinger>-----bp

class AudioFlinger :public BinderService<AudioFlinger>,public BnAudioFlinger---bn

class AudioPolicyService :public BinderService<AudioPolicyService>,

public BnAudioPolicyService,public IBinder::DeathRecipient

class CameraService :public BinderService<CameraService>,

public virtual ::android::hardware::BnCameraService,

public virtual IBinder::DeathRecipient,public virtual CameraProviderManager::StatusListener

class MediaExtractorService : public BinderService<MediaExtractorService>, public BnMediaExtractorService

class MediaLogService : public BinderService<MediaLogService>, public BnMediaLogService

class AAudioService :public BinderService<AAudioService>,public BnAAudioService,

public aaudio::AAudioServiceInterface

class NetdNativeService : public BinderService<NetdNativeService>, public BnNetd

class VRAudioServiceNative :public BinderService<VRAudioServiceNative>,

public BnVRAudioService

猜你喜欢

转载自blog.csdn.net/wangbuji/article/details/126172160