Android Automotive架构与流程:VehicleHAL,CarService,CarAPI,EVS

}

@Override

public void onErrorEvent(int i, int i1) { }

};

  1. SET 和 GET,以HVAC空调为例:

mCarHvacManager.setIntProperty(ID_HVAC_LOCK_VENTILATION_ON, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL, HVAC_ON);

float temp = mCarHvacManager.getFloatProperty(ID_HVAC_TEMPERATURE_SET, SEAT_ROW_1_LEFT);

VehicleAreaType分为GLOBAL(全局)、WINDOW(车窗)、MIRROR(镜子)、SEAT(座椅)、DOOR(车门)、WHEEL(车轮)等:

enum VehicleArea : int32_t {

GLOBAL = 0x01000000,

/** WINDOW maps to enum VehicleAreaWindow */

WINDOW = 0x03000000,

/** MIRROR maps to enum VehicleAreaMirror */

MIRROR = 0x04000000,

/** SEAT maps to enum VehicleAreaSeat */

SEAT = 0x05000000,

/** DOOR maps to enum VehicleAreaDoor */

DOOR = 0x06000000,

/** WHEEL maps to enum VehicleAreaWheel */

WHEEL = 0x07000000,

/** IN_OUT_CAR maps to enum VehicleAreaInOutCar,车内外 */

IN_OUT_CAR = 0x08000000,

MASK = 0x0f000000,

};

CarAPI (car-lib:android.car.jar)

1.createCar:

public static Car createCar(Context context, ServiceConnection serviceConnectionListener, @Nullable Handler handler) {

if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {

Log.e(CarLibLog.TAG_CAR, “FEATURE_AUTOMOTIVE not declared while android.car is used”);

return null;

}

try {

return new Car(context, serviceConnectionListener, handler);

} catch (IllegalArgumentException e) { // Expected when car service loader is not available.

}

return null;

}

  1. getCarManager(“serviceName”) -> createCarManager(“serviceName”, IBinder)

public Object getCarManager(String serviceName) throws CarNotConnectedException {

CarManagerBase manager;

ICar service = getICarOrThrow();

synchronized (mCarManagerLock) {

manager = mServiceMap.get(serviceName);

if (manager == null) {

try {

if(TBOX_SERVICE.equals(serviceName)){

manager = createCarManager(serviceName, null);

return manager;

}

IBinder binder = service.getCarService(serviceName);

if (binder == null) {

Log.w(CarLibLog.TAG_CAR, “could not get binder for service:” + serviceName);

return null;

}

manager = createCarManager(serviceName, binder);

if (manager == null) {

Log.w(CarLibLog.TAG_CAR, “could not create manager for service:” + serviceName);

return null;

}

mServiceMap.put(serviceName, manager);

} catch (RemoteException e) {

handleRemoteException(e);

}

}

}

return manager;

}

private CarManagerBase createCarManager(String serviceName, IBinder binder) throws CarNotConnectedException {

CarManagerBase manager = null;

Log.d(“liueg”, "------------------createCarManager()serviceName "+serviceName);

switch (serviceName) {

case AUDIO_SERVICE: manager = new CarAudioManager(binder, mContext, mEventHandler);break;

case SENSOR_SERVICE: manager = new CarSensorManager(binder, mContext, mEventHandler);break;

case DYSENSOR_SERVICE: manager = new CarDYSensorManager(binder, mContext, mEventHandler);break;

case INFO_SERVICE: manager = new CarInfoManager(binder);break;

case APP_FOCUS_SERVICE: manager = new CarAppFocusManager(binder, mEventHandler);break;

case PACKAGE_SERVICE: manager = new CarPackageManager(binder, mContext);break;

case CAR_NAVIGATION_SERVICE: manager = new CarNavigationStatusManager(binder);break;

case CABIN_SERVICE: manager = new CarCabinManager(binder, mContext, mEventHandler);break;

case DIAGNOSTIC_SERVICE: manager = new CarDiagnosticManager(binder, mContext, mEventHandler);break;

case HVAC_SERVICE: manager = new CarHvacManager(binder, mContext, mEventHandler);break;

case DYHVAC_SERVICE: manager = new CarDYHvacManager(binder, mContext, mEventHandler);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值