IVICar.java获取Car相关服务和对应管理器

Posted xhBruce

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IVICar.java获取Car相关服务和对应管理器相关的知识,希望对你有一定的参考价值。

【IVI】Car.java获取Car相关服务和对应管理器

android12-release
Android Automotive OS知识体系
Android 知识体系


1、获取Car对象方式

packages/services/Car/car-lib/src/android/car/Car.java

  • 使用类中静态方法createCar()
  • 获取CarService/CarImpl服务String CAR_SERVICE_BINDER_SERVICE_NAME = "car_service"
  • 若服务没有启动,执行绑定服务startCarService(),与 【IVI】CarService启动 绑定一样


2、通过CarService/CarImpl获取相关服务Binder

packages/services/Car/service/src/com/android/car/ICarImpl.java

public IBinder getCarService(String serviceName) 
    if (!mFeatureController.isFeatureEnabled(serviceName)) 
        Slog.w(CarLog.TAG_SERVICE, "getCarService for disabled service:" + serviceName);
        return null;
    
    switch (serviceName) 
        case Car.AUDIO_SERVICE:
            return mCarAudioservice;
        case Car.APP_FOCUS_SERVICE:
            return mAppFocusService;
        case Car.PACKAGE_SERVICE:
            return mCarPackageManagerService;
        case Car.DIAGNOSTIC_SERVICE:
            assertAnyDiagnosticPermission(mContext);
            return mCarDiagnosticService;
        case Car.POWER_SERVICE:
            return mCarPowerManagementService;
        case Car.CABIN_SERVICE:
        case Car.HVAC_SERVICE:
        case Car.INFO_SERVICE:
        case Car.PROPERTY_SERVICE:
        case Car.SENSOR_SERVICE:
        case Car.VENDOR_EXTENSION_SERVICE:
            return mCarPropertyService;
        case Car.CAR_NAVIGATION_SERVICE:
            assertNavigationManagerPermission(mContext);
            return mClusterNavigationService;
        case Car.CAR_INSTRUMENT_CLUSTER_SERVICE:
            assertClusterManagerPermission(mContext);
            return mInstrumentClusterService.getManagerService();
        case Car.PROJECTION_SERVICE:
            return mCarProjectionService;
        case Car.VEHICLE_MAP_SERVICE:
            assertAnyVmsPermission(mContext);
            return mVmsBrokerService;
        case Car.VMS_SUBSCRIBER_SERVICE:
            assertVmsSubscriberPermission(mContext);
            return mVmsBrokerService;
        case Car.TEST_SERVICE: 
            assertPermission(mContext, Car.PERMISSION_CAR_TEST_SERVICE);
            synchronized (mLock) 
                if (mCarTestService == null) 
                    mCarTestService = new CarTestService(mContext, this);
                
                return mCarTestService;
            
        
        case Car.BLUETOOTH_SERVICE:
            return mCarBluetoothService;
        case Car.STORAGE_MONITORING_SERVICE:
            assertPermission(mContext, Car.PERMISSION_STORAGE_MONITORING);
            return mCarStorageMonitoringService;
        case Car.CAR_DRIVING_STATE_SERVICE:
            assertDrivingStatePermission(mContext);
            return mCarDrivingStateService;
        case Car.CAR_UX_RESTRICTION_SERVICE:
            return mCarUXRestrictionsService;
        case Car.OCCUPANT_AWARENESS_SERVICE:
            return mOccupantAwarenessService;
        case Car.CAR_MEDIA_SERVICE:
            return mCarMediaService;
        case Car.CAR_OCCUPANT_ZONE_SERVICE:
            return mCarOccupantZoneService;
        case Car.CAR_BUGREPORT_SERVICE:
            return mCarBugreportManagerService;
        case Car.CAR_USER_SERVICE:
            return mCarUserService;
        case Car.CAR_WATCHDOG_SERVICE:
            return mCarWatchdogService;
        case Car.CAR_INPUT_SERVICE:
            return mCarInputService;
        case Car.CAR_DEVICE_POLICY_SERVICE:
            return mCarDevicePolicyService;
        case Car.CLUSTER_HOME_SERVICE:
            return mClusterHomeService;
        case Car.CAR_EVS_SERVICE:
            return mCarEvsService;
        case Car.CAR_TELEMETRY_SERVICE:
            return mCarTelemetryService;
        default:
            IBinder service = null;
            if (mCarExperimentalFeatureServiceController != null) 
                service = mCarExperimentalFeatureServiceController.getCarService(serviceName);
            
            if (service == null) 
                Slog.w(CarLog.TAG_SERVICE, "getCarService for unknown service:"
                        + serviceName);
            
            return service;
    

3、获取到相关服务后创建相关Manager

packages/services/Car/car-lib/src/android/car/Car.java

private CarManagerBase createCarManagerLocked(String serviceName, IBinder binder) 
    CarManagerBase manager = null;
    switch (serviceName) 
        case AUDIO_SERVICE:
            manager = new CarAudioManager(this, binder);
            break;
        case SENSOR_SERVICE:
            manager = new CarSensorManager(this, binder);
            break;
        case INFO_SERVICE:
            manager = new CarInfoManager(this, binder);
            break;
        case APP_FOCUS_SERVICE:
            manager = new CarAppFocusManager(this, binder);
            break;
        case PACKAGE_SERVICE:
            manager = new CarPackageManager(this, binder);
            break;
        case CAR_OCCUPANT_ZONE_SERVICE:
            manager = new CarOccupantZoneManager(this, binder);
            break;
        case CAR_NAVIGATION_SERVICE:
            manager = new CarNavigationStatusManager(this, binder);
            break;
        case CABIN_SERVICE:
            manager = new CarCabinManager(this, binder);
            break;
        case DIAGNOSTIC_SERVICE:
            manager = new CarDiagnosticManager(this, binder);
            break;
        case HVAC_SERVICE:
            manager = new CarHvacManager(this, binder);
            break;
        case POWER_SERVICE:
            manager = new CarPowerManager(this, binder);
            break;
        case PROJECTION_SERVICE:
            manager = new CarProjectionManager(this, binder);
            break;
        case PROPERTY_SERVICE:
            manager = new CarPropertyManager(this, ICarProperty.Stub.asInterface(binder));
            break;
        case VENDOR_EXTENSION_SERVICE:
            manager = new CarVendorExtensionManager(this, binder);
            break;
        case CAR_INSTRUMENT_CLUSTER_SERVICE:
            manager = new CarInstrumentClusterManager(this, binder);
            break;
        case TEST_SERVICE:
            /* CarTestManager exist in static library. So instead of constructing it here,
             * only pass binder wrapper so that CarTestManager can be constructed outside. */
            manager = new CarTestManagerBinderWrapper(this, binder);
            break;
        case VEHICLE_MAP_SERVICE:
            manager = new VmsClientManager(this, binder);
            break;
        case VMS_SUBSCRIBER_SERVICE:
            manager = VmsSubscriberManager.wrap(this,
                    (VmsClientManager) getCarManager(VEHICLE_MAP_SERVICE));
            break;
        case BLUETOOTH_SERVICE:
            manager = new CarBluetoothManager(this, binder);
            break;
        case STORAGE_MONITORING_SERVICE:
            manager = new CarStorageMonitoringManager(this, binder);
            break;
        case CAR_DRIVING_STATE_SERVICE:
            manager = new CarDrivingStateManager(this, binder);
            break;
        case CAR_UX_RESTRICTION_SERVICE:
            manager = new CarUxRestrictionsManager(this, binder);
            break;
        case OCCUPANT_AWARENESS_SERVICE:
            manager = new OccupantAwarenessManager(this, binder);
            break;
        case CAR_MEDIA_SERVICE:
            manager = new CarMediaManager(this, binder);
            break;
        case CAR_BUGREPORT_SERVICE:
            manager = new CarBugreportManager(this, binder);
            break;
        case CAR_USER_SERVICE:
            manager = new CarUserManager(this, binder);
            break;
        case CAR_WATCHDOG_SERVICE:
            manager = new CarWatchdogManager(this, binder);
            break;
        case CAR_INPUT_SERVICE:
            manager = new CarInputManager(this, binder);
            break;
        case CAR_DEVICE_POLICY_SERVICE:
            manager = new CarDevicePolicyManager(this, binder);
            break;
        case CLUSTER_HOME_SERVICE:
            manager = new ClusterHomeManager(this, binder);
            break;
        case CAR_EVS_SERVICE:
            manager = new CarEvsManager(this, binder);
            break;
        case CAR_TELEMETRY_SERVICE:
            manager = new CarTelemetryManager(this, binder);
            break;
        default:
            // Experimental or non-existing
            String className = null;
            try 
                className = mService.getCarManagerClassForFeature(serviceName);
             catch (RemoteException e) 
                handleRemoteExceptionFromCarService(e);
                return null;
            
            if (className == null) 
                Log.e(TAG_CAR, "Cannot construct CarManager for service:" + serviceName
                        + " : no class defined");
                return null;
            
            manager = constructCarManager(className, binder);
            break;
    
    return manager;

4、简要时序图

以上是关于IVICar.java获取Car相关服务和对应管理器的主要内容,如果未能解决你的问题,请参考以下文章

IVICar.java获取Car相关服务和对应管理器

MySQL:获取对应于某个 ID 的值的平均值

解压Assets.car获取App中的图片资源

AD用户属性对照表

Python40 1.数据库相关概念--非常重要 2.数据库与文件系统的对应关系---非常重要 3.数据库安装方式--掌握 4. 连接服务器的指令 必要掌握 5.修改管理员密码---了解

Django模型中的OneToOneField和ForeignKey有什么区别?