diff options
44 files changed, 1083 insertions, 1197 deletions
diff --git a/car-lib/api/current.txt b/car-lib/api/current.txt index b2be6f7bc7..556aaae3c2 100644 --- a/car-lib/api/current.txt +++ b/car-lib/api/current.txt @@ -23,12 +23,12 @@ package android.car { } public final class CarAppFocusManager { - method public void abandonAppFocus(android.car.CarAppFocusManager.OnAppFocusOwnershipCallback, int) throws android.car.CarNotConnectedException; - method public void abandonAppFocus(android.car.CarAppFocusManager.OnAppFocusOwnershipCallback) throws android.car.CarNotConnectedException; + method public void abandonAppFocus(android.car.CarAppFocusManager.OnAppFocusOwnershipCallback, int); + method public void abandonAppFocus(android.car.CarAppFocusManager.OnAppFocusOwnershipCallback); method public void addFocusListener(android.car.CarAppFocusManager.OnAppFocusChangedListener, int) throws android.car.CarNotConnectedException; method public boolean isOwningFocus(android.car.CarAppFocusManager.OnAppFocusOwnershipCallback, int) throws android.car.CarNotConnectedException; - method public void removeFocusListener(android.car.CarAppFocusManager.OnAppFocusChangedListener, int) throws android.car.CarNotConnectedException; - method public void removeFocusListener(android.car.CarAppFocusManager.OnAppFocusChangedListener) throws android.car.CarNotConnectedException; + method public void removeFocusListener(android.car.CarAppFocusManager.OnAppFocusChangedListener, int); + method public void removeFocusListener(android.car.CarAppFocusManager.OnAppFocusChangedListener); method public int requestAppFocus(int, android.car.CarAppFocusManager.OnAppFocusOwnershipCallback) throws android.car.CarNotConnectedException, java.lang.SecurityException; field public static final int APP_FOCUS_REQUEST_FAILED = 0; // 0x0 field public static final int APP_FOCUS_REQUEST_SUCCEEDED = 1; // 0x1 @@ -59,20 +59,6 @@ package android.car { ctor public CarNotConnectedException(java.lang.Exception); } - public class CarOperationNotSupportedException extends java.lang.Exception { - ctor public CarOperationNotSupportedException(); - ctor public CarOperationNotSupportedException(java.lang.String); - ctor public CarOperationNotSupportedException(java.lang.String, java.lang.Throwable); - ctor public CarOperationNotSupportedException(java.lang.Exception); - } - -} - -package android.car.annotation { - - public abstract class ValueTypeDef implements java.lang.annotation.Annotation { - } - } package android.car.app.menu { @@ -239,8 +225,8 @@ package android.car.hardware { method public boolean isSensorSupported(int) throws android.car.CarNotConnectedException; method public static boolean isSensorSupported(int[], int); method public boolean registerListener(android.car.hardware.CarSensorManager.OnSensorChangedListener, int, int) throws android.car.CarNotConnectedException, java.lang.IllegalArgumentException; - method public void unregisterListener(android.car.hardware.CarSensorManager.OnSensorChangedListener) throws android.car.CarNotConnectedException; - method public void unregisterListener(android.car.hardware.CarSensorManager.OnSensorChangedListener, int) throws android.car.CarNotConnectedException; + method public void unregisterListener(android.car.hardware.CarSensorManager.OnSensorChangedListener); + method public void unregisterListener(android.car.hardware.CarSensorManager.OnSensorChangedListener, int); field public static final int SENSOR_RATE_FAST = 1; // 0x1 field public static final int SENSOR_RATE_FASTEST = 0; // 0x0 field public static final int SENSOR_RATE_NORMAL = 3; // 0x3 @@ -266,12 +252,12 @@ package android.car.hardware { package android.car.media { public final class CarAudioManager { - method public int abandonAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes); - method public android.media.AudioAttributes getAudioAttributesForCarUsage(int); + method public void abandonAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes); + method public android.media.AudioAttributes getAudioAttributesForCarUsage(int) throws android.car.CarNotConnectedException; method public int getStreamMaxVolume(int) throws android.car.CarNotConnectedException; method public int getStreamMinVolume(int) throws android.car.CarNotConnectedException; method public int getStreamVolume(int) throws android.car.CarNotConnectedException; - method public int requestAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes, int, int) throws java.lang.IllegalArgumentException; + method public int requestAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes, int, int) throws android.car.CarNotConnectedException, java.lang.IllegalArgumentException; method public void setStreamVolume(int, int, int) throws android.car.CarNotConnectedException; field public static final int CAR_AUDIO_USAGE_ALARM = 6; // 0x6 field public static final int CAR_AUDIO_USAGE_DEFAULT = 0; // 0x0 diff --git a/car-lib/api/system-current.txt b/car-lib/api/system-current.txt index d1e4dd7f57..8a66984631 100644 --- a/car-lib/api/system-current.txt +++ b/car-lib/api/system-current.txt @@ -38,12 +38,12 @@ package android.car { } public final class CarAppFocusManager { - method public void abandonAppFocus(android.car.CarAppFocusManager.OnAppFocusOwnershipCallback, int) throws android.car.CarNotConnectedException; - method public void abandonAppFocus(android.car.CarAppFocusManager.OnAppFocusOwnershipCallback) throws android.car.CarNotConnectedException; + method public void abandonAppFocus(android.car.CarAppFocusManager.OnAppFocusOwnershipCallback, int); + method public void abandonAppFocus(android.car.CarAppFocusManager.OnAppFocusOwnershipCallback); method public void addFocusListener(android.car.CarAppFocusManager.OnAppFocusChangedListener, int) throws android.car.CarNotConnectedException; method public boolean isOwningFocus(android.car.CarAppFocusManager.OnAppFocusOwnershipCallback, int) throws android.car.CarNotConnectedException; - method public void removeFocusListener(android.car.CarAppFocusManager.OnAppFocusChangedListener, int) throws android.car.CarNotConnectedException; - method public void removeFocusListener(android.car.CarAppFocusManager.OnAppFocusChangedListener) throws android.car.CarNotConnectedException; + method public void removeFocusListener(android.car.CarAppFocusManager.OnAppFocusChangedListener, int); + method public void removeFocusListener(android.car.CarAppFocusManager.OnAppFocusChangedListener); method public int requestAppFocus(int, android.car.CarAppFocusManager.OnAppFocusOwnershipCallback) throws android.car.CarNotConnectedException, java.lang.SecurityException; field public static final int APP_FOCUS_REQUEST_FAILED = 0; // 0x0 field public static final int APP_FOCUS_REQUEST_SUCCEEDED = 1; // 0x1 @@ -74,19 +74,12 @@ package android.car { ctor public CarNotConnectedException(java.lang.Exception); } - public class CarOperationNotSupportedException extends java.lang.Exception { - ctor public CarOperationNotSupportedException(); - ctor public CarOperationNotSupportedException(java.lang.String); - ctor public CarOperationNotSupportedException(java.lang.String, java.lang.Throwable); - ctor public CarOperationNotSupportedException(java.lang.Exception); - } - public final class CarProjectionManager { method public void onCarDisconnected(); method public void registerProjectionRunner(android.content.Intent) throws android.car.CarNotConnectedException; method public void regsiterProjectionListener(android.car.CarProjectionManager.CarProjectionListener, int) throws android.car.CarNotConnectedException; - method public void unregisterProjectionRunner(android.content.Intent) throws android.car.CarNotConnectedException; - method public void unregsiterProjectionListener() throws android.car.CarNotConnectedException; + method public void unregisterProjectionRunner(android.content.Intent); + method public void unregsiterProjectionListener(); field public static final int PROJECTION_LONG_PRESS_VOICE_SEARCH = 2; // 0x2 field public static final int PROJECTION_VOICE_SEARCH = 1; // 0x1 } @@ -121,17 +114,15 @@ package android.car { } public final class VehicleSeat { - field public static final int SEAT_DRIVER_LHD = 1; // 0x1 - field public static final int SEAT_DRIVER_RHD = 2; // 0x2 - field public static final int SEAT_ROW_1_PASSENGER_CENTER = 32; // 0x20 - field public static final int SEAT_ROW_1_PASSENGER_LEFT = 16; // 0x10 - field public static final int SEAT_ROW_1_PASSENGER_RIGHT = 64; // 0x40 - field public static final int SEAT_ROW_2_PASSENGER_CENTER = 512; // 0x200 - field public static final int SEAT_ROW_2_PASSENGER_LEFT = 256; // 0x100 - field public static final int SEAT_ROW_2_PASSENGER_RIGHT = 1024; // 0x400 - field public static final int SEAT_ROW_3_PASSENGER_CENTER = 8192; // 0x2000 - field public static final int SEAT_ROW_3_PASSENGER_LEFT = 4096; // 0x1000 - field public static final int SEAT_ROW_3_PASSENGER_RIGHT = 16384; // 0x4000 + field public static final int SEAT_ROW_1_CENTER = 2; // 0x2 + field public static final int SEAT_ROW_1_LEFT = 1; // 0x1 + field public static final int SEAT_ROW_1_RIGHT = 4; // 0x4 + field public static final int SEAT_ROW_2_CENTER = 32; // 0x20 + field public static final int SEAT_ROW_2_LEFT = 16; // 0x10 + field public static final int SEAT_ROW_2_RIGHT = 64; // 0x40 + field public static final int SEAT_ROW_3_CENTER = 512; // 0x200 + field public static final int SEAT_ROW_3_LEFT = 256; // 0x100 + field public static final int SEAT_ROW_3_RIGHT = 1024; // 0x400 } public final class VehicleWindow { @@ -176,13 +167,6 @@ package android.car { } -package android.car.annotation { - - public abstract class ValueTypeDef implements java.lang.annotation.Annotation { - } - -} - package android.car.app.menu { public abstract class CarMenuCallbacks { @@ -474,8 +458,8 @@ package android.car.hardware { method public boolean isSensorSupported(int) throws android.car.CarNotConnectedException; method public static boolean isSensorSupported(int[], int); method public boolean registerListener(android.car.hardware.CarSensorManager.OnSensorChangedListener, int, int) throws android.car.CarNotConnectedException, java.lang.IllegalArgumentException; - method public void unregisterListener(android.car.hardware.CarSensorManager.OnSensorChangedListener) throws android.car.CarNotConnectedException; - method public void unregisterListener(android.car.hardware.CarSensorManager.OnSensorChangedListener, int) throws android.car.CarNotConnectedException; + method public void unregisterListener(android.car.hardware.CarSensorManager.OnSensorChangedListener); + method public void unregisterListener(android.car.hardware.CarSensorManager.OnSensorChangedListener, int); field public static final int SENSOR_RATE_FAST = 1; // 0x1 field public static final int SENSOR_RATE_FASTEST = 0; // 0x0 field public static final int SENSOR_RATE_NORMAL = 3; // 0x3 @@ -500,13 +484,13 @@ package android.car.hardware { method public <E> E getGlobalProperty(java.lang.Class<E>, int) throws android.car.CarNotConnectedException; method public java.util.List<android.car.hardware.CarPropertyConfig> getProperties() throws android.car.CarNotConnectedException; method public <E> E getProperty(java.lang.Class<E>, int, int) throws android.car.CarNotConnectedException; - method public void registerListener(android.car.hardware.CarVendorExtensionManager.CarVendorExtensionListener) throws android.car.CarNotConnectedException; + method public void registerCallback(android.car.hardware.CarVendorExtensionManager.CarVendorExtensionCallback) throws android.car.CarNotConnectedException; method public <E> void setGlobalProperty(java.lang.Class<E>, int, E) throws android.car.CarNotConnectedException; method public <E> void setProperty(java.lang.Class<E>, int, int, E) throws android.car.CarNotConnectedException; - method public void unregisterListener(android.car.hardware.CarVendorExtensionManager.CarVendorExtensionListener) throws android.car.CarNotConnectedException; + method public void unregisterCallback(android.car.hardware.CarVendorExtensionManager.CarVendorExtensionCallback); } - public static abstract interface CarVendorExtensionManager.CarVendorExtensionListener { + public static abstract interface CarVendorExtensionManager.CarVendorExtensionCallback { method public abstract void onChangeEvent(android.car.hardware.CarPropertyValue); method public abstract void onErrorEvent(int, int); } @@ -521,58 +505,55 @@ package android.car.hardware.cabin { method public int getIntProperty(int, int) throws android.car.CarNotConnectedException; method public java.util.List<android.car.hardware.CarPropertyConfig> getPropertyList() throws android.car.CarNotConnectedException; method public static boolean isZonedProperty(int); - method public synchronized void registerListener(android.car.hardware.cabin.CarCabinManager.CarCabinEventListener) throws android.car.CarNotConnectedException; + method public synchronized void registerCallback(android.car.hardware.cabin.CarCabinManager.CarCabinEventCallback) throws android.car.CarNotConnectedException; method public void setBooleanProperty(int, int, boolean) throws android.car.CarNotConnectedException; method public void setFloatProperty(int, int, float) throws android.car.CarNotConnectedException; method public void setIntProperty(int, int, int) throws android.car.CarNotConnectedException; - method public synchronized void unregisterListener(android.car.hardware.cabin.CarCabinManager.CarCabinEventListener) throws android.car.CarNotConnectedException; - } - - public static abstract class CarCabinManager.CabinPropertyId implements java.lang.annotation.Annotation { - field public static final int DOOR_LOCK = 3; // 0x3 - field public static final int DOOR_MOVE = 2; // 0x2 - field public static final int DOOR_POS = 1; // 0x1 - field public static final int MIRROR_FOLD = 4102; // 0x1006 - field public static final int MIRROR_LOCK = 4101; // 0x1005 - field public static final int MIRROR_Y_MOVE = 4100; // 0x1004 - field public static final int MIRROR_Y_POS = 4099; // 0x1003 - field public static final int MIRROR_Z_MOVE = 4098; // 0x1002 - field public static final int MIRROR_Z_POS = 4097; // 0x1001 - field public static final int SEAT_BACKREST_ANGLE_1_MOVE = 8201; // 0x2009 - field public static final int SEAT_BACKREST_ANGLE_1_POS = 8200; // 0x2008 - field public static final int SEAT_BACKREST_ANGLE_2_MOVE = 8203; // 0x200b - field public static final int SEAT_BACKREST_ANGLE_2_POS = 8202; // 0x200a - field public static final int SEAT_BELT_BUCKLED = 8195; // 0x2003 - field public static final int SEAT_BELT_HEIGHT_MOVE = 8197; // 0x2005 - field public static final int SEAT_BELT_HEIGHT_POS = 8196; // 0x2004 - field public static final int SEAT_DEPTH_MOVE = 8207; // 0x200f - field public static final int SEAT_DEPTH_POS = 8206; // 0x200e - field public static final int SEAT_FORE_AFT_MOVE = 8199; // 0x2007 - field public static final int SEAT_FORE_AFT_POS = 8198; // 0x2006 - field public static final int SEAT_HEADREST_ANGLE_MOVE = 8217; // 0x2019 - field public static final int SEAT_HEADREST_ANGLE_POS = 8216; // 0x2018 - field public static final int SEAT_HEADREST_FORE_AFT_MOVE = 8219; // 0x201b - field public static final int SEAT_HEADREST_FORE_AFT_POS = 8218; // 0x201a - field public static final int SEAT_HEADREST_HEIGHT_MOVE = 8215; // 0x2017 - field public static final int SEAT_HEADREST_HEIGHT_POS = 8214; // 0x2016 - field public static final int SEAT_HEIGHT_MOVE = 8205; // 0x200d - field public static final int SEAT_HEIGHT_POS = 8204; // 0x200c - field public static final int SEAT_LUMBAR_FORE_AFT_MOVE = 8211; // 0x2013 - field public static final int SEAT_LUMBAR_FORE_AFT_POS = 8210; // 0x2012 - field public static final int SEAT_LUMBAR_SIDE_SUPPORT_MOVE = 8213; // 0x2015 - field public static final int SEAT_LUMBAR_SIDE_SUPPORT_POS = 8212; // 0x2014 - field public static final int SEAT_MEMORY_SELECT = 8193; // 0x2001 - field public static final int SEAT_MEMORY_SET = 8194; // 0x2002 - field public static final int SEAT_TILT_MOVE = 8209; // 0x2011 - field public static final int SEAT_TILT_POS = 8208; // 0x2010 - field public static final int WINDOW_LOCK = 12293; // 0x3005 - field public static final int WINDOW_MOVE = 12290; // 0x3002 - field public static final int WINDOW_POS = 12289; // 0x3001 - field public static final int WINDOW_VENT_MOVE = 12292; // 0x3004 - field public static final int WINDOW_VENT_POS = 12291; // 0x3003 - } - - public static abstract interface CarCabinManager.CarCabinEventListener { + method public synchronized void unregisterCallback(android.car.hardware.cabin.CarCabinManager.CarCabinEventCallback); + field public static final int ID_DOOR_LOCK = 3; // 0x3 + field public static final int ID_DOOR_MOVE = 2; // 0x2 + field public static final int ID_DOOR_POS = 1; // 0x1 + field public static final int ID_MIRROR_FOLD = 4102; // 0x1006 + field public static final int ID_MIRROR_LOCK = 4101; // 0x1005 + field public static final int ID_MIRROR_Y_MOVE = 4100; // 0x1004 + field public static final int ID_MIRROR_Y_POS = 4099; // 0x1003 + field public static final int ID_MIRROR_Z_MOVE = 4098; // 0x1002 + field public static final int ID_MIRROR_Z_POS = 4097; // 0x1001 + field public static final int ID_SEAT_BACKREST_ANGLE_1_MOVE = 8201; // 0x2009 + field public static final int ID_SEAT_BACKREST_ANGLE_1_POS = 8200; // 0x2008 + field public static final int ID_SEAT_BACKREST_ANGLE_2_MOVE = 8203; // 0x200b + field public static final int ID_SEAT_BACKREST_ANGLE_2_POS = 8202; // 0x200a + field public static final int ID_SEAT_BELT_BUCKLED = 8195; // 0x2003 + field public static final int ID_SEAT_BELT_HEIGHT_MOVE = 8197; // 0x2005 + field public static final int ID_SEAT_BELT_HEIGHT_POS = 8196; // 0x2004 + field public static final int ID_SEAT_DEPTH_MOVE = 8207; // 0x200f + field public static final int ID_SEAT_DEPTH_POS = 8206; // 0x200e + field public static final int ID_SEAT_FORE_AFT_MOVE = 8199; // 0x2007 + field public static final int ID_SEAT_FORE_AFT_POS = 8198; // 0x2006 + field public static final int ID_SEAT_HEADREST_ANGLE_MOVE = 8217; // 0x2019 + field public static final int ID_SEAT_HEADREST_ANGLE_POS = 8216; // 0x2018 + field public static final int ID_SEAT_HEADREST_FORE_AFT_MOVE = 8219; // 0x201b + field public static final int ID_SEAT_HEADREST_FORE_AFT_POS = 8218; // 0x201a + field public static final int ID_SEAT_HEADREST_HEIGHT_MOVE = 8215; // 0x2017 + field public static final int ID_SEAT_HEADREST_HEIGHT_POS = 8214; // 0x2016 + field public static final int ID_SEAT_HEIGHT_MOVE = 8205; // 0x200d + field public static final int ID_SEAT_HEIGHT_POS = 8204; // 0x200c + field public static final int ID_SEAT_LUMBAR_FORE_AFT_MOVE = 8211; // 0x2013 + field public static final int ID_SEAT_LUMBAR_FORE_AFT_POS = 8210; // 0x2012 + field public static final int ID_SEAT_LUMBAR_SIDE_SUPPORT_MOVE = 8213; // 0x2015 + field public static final int ID_SEAT_LUMBAR_SIDE_SUPPORT_POS = 8212; // 0x2014 + field public static final int ID_SEAT_MEMORY_SELECT = 8193; // 0x2001 + field public static final int ID_SEAT_MEMORY_SET = 8194; // 0x2002 + field public static final int ID_SEAT_TILT_MOVE = 8209; // 0x2011 + field public static final int ID_SEAT_TILT_POS = 8208; // 0x2010 + field public static final int ID_WINDOW_LOCK = 12293; // 0x3005 + field public static final int ID_WINDOW_MOVE = 12290; // 0x3002 + field public static final int ID_WINDOW_POS = 12289; // 0x3001 + field public static final int ID_WINDOW_VENT_MOVE = 12292; // 0x3004 + field public static final int ID_WINDOW_VENT_POS = 12291; // 0x3003 + } + + public static abstract interface CarCabinManager.CarCabinEventCallback { method public abstract void onChangeEvent(android.car.hardware.CarPropertyValue); method public abstract void onErrorEvent(int, int); } @@ -597,8 +578,8 @@ package android.car.hardware.camera { public final class CarCameraManager { method public void closeCamera(android.car.hardware.camera.CarCamera); method public int getCameraCapabilities(int) throws android.car.CarNotConnectedException; - method public int[] getCameraList(); - method public android.car.hardware.camera.CarCamera openCamera(int); + method public int[] getCameraList() throws android.car.CarNotConnectedException; + method public android.car.hardware.camera.CarCamera openCamera(int) throws android.car.CarNotConnectedException; field public static final int ANDROID_OVERLAY_SUPPORT_FLAG = 1; // 0x1 field public static final int CAMERA_CROP_SUPPORT_FLAG = 2; // 0x2 field public static final int CAMERA_POSITIONING_SUPPORT_FLAG = 4; // 0x4 @@ -639,41 +620,37 @@ package android.car.hardware.hvac { method public int getIntProperty(int, int) throws android.car.CarNotConnectedException; method public java.util.List<android.car.hardware.CarPropertyConfig> getPropertyList() throws android.car.CarNotConnectedException; method public static boolean isZonedProperty(int); - method public synchronized void registerListener(android.car.hardware.hvac.CarHvacManager.CarHvacEventListener) throws android.car.CarNotConnectedException; + method public synchronized void registerCallback(android.car.hardware.hvac.CarHvacManager.CarHvacEventCallback) throws android.car.CarNotConnectedException; method public void setBooleanProperty(int, int, boolean) throws android.car.CarNotConnectedException; method public void setFloatProperty(int, int, float) throws android.car.CarNotConnectedException; method public void setIntProperty(int, int, int) throws android.car.CarNotConnectedException; - method public synchronized void unregisterListener(android.car.hardware.hvac.CarHvacManager.CarHvacEventListener) throws android.car.CarNotConnectedException; - } - - public static abstract interface CarHvacManager.CarHvacEventListener { + method public synchronized void unregisterCallback(android.car.hardware.hvac.CarHvacManager.CarHvacEventCallback); + field public static final int ID_MIRROR_DEFROSTER_ON = 1; // 0x1 + field public static final int ID_OUTSIDE_AIR_TEMP = 3; // 0x3 + field public static final int ID_STEERING_WHEEL_TEMP = 2; // 0x2 + field public static final int ID_TEMPERATURE_UNITS = 4; // 0x4 + field public static final int ID_WINDOW_DEFROSTER_ON = 20481; // 0x5001 + field public static final int ID_ZONED_AC_ON = 16393; // 0x4009 + field public static final int ID_ZONED_AIR_RECIRCULATION_ON = 16395; // 0x400b + field public static final int ID_ZONED_AUTOMATIC_MODE_ON = 16394; // 0x400a + field public static final int ID_ZONED_DUAL_ZONE_ON = 16397; // 0x400d + field public static final int ID_ZONED_FAN_POSITION = 16391; // 0x4007 + field public static final int ID_ZONED_FAN_POSITION_AVAILABLE = 16390; // 0x4006 + field public static final int ID_ZONED_FAN_SPEED_RPM = 16389; // 0x4005 + field public static final int ID_ZONED_FAN_SPEED_SETPOINT = 16388; // 0x4004 + field public static final int ID_ZONED_HVAC_POWER_ON = 16387; // 0x4003 + field public static final int ID_ZONED_MAX_AC_ON = 16396; // 0x400c + field public static final int ID_ZONED_MAX_DEFROST_ON = 16398; // 0x400e + field public static final int ID_ZONED_SEAT_TEMP = 16392; // 0x4008 + field public static final int ID_ZONED_TEMP_ACTUAL = 16386; // 0x4002 + field public static final int ID_ZONED_TEMP_SETPOINT = 16385; // 0x4001 + } + + public static abstract interface CarHvacManager.CarHvacEventCallback { method public abstract void onChangeEvent(android.car.hardware.CarPropertyValue); method public abstract void onErrorEvent(int, int); } - public static abstract class CarHvacManager.HvacPropertyId implements java.lang.annotation.Annotation { - field public static final int MAX_GLOBAL_PROPERTY_ID = 16383; // 0x3fff - field public static final int MIRROR_DEFROSTER_ON = 1; // 0x1 - field public static final int OUTSIDE_AIR_TEMP = 3; // 0x3 - field public static final int STEERING_WHEEL_TEMP = 2; // 0x2 - field public static final int TEMPERATURE_UNITS = 4; // 0x4 - field public static final int WINDOW_DEFROSTER_ON = 20481; // 0x5001 - field public static final int ZONED_AC_ON = 16393; // 0x4009 - field public static final int ZONED_AIR_RECIRCULATION_ON = 16395; // 0x400b - field public static final int ZONED_AUTOMATIC_MODE_ON = 16394; // 0x400a - field public static final int ZONED_DUAL_ZONE_ON = 16397; // 0x400d - field public static final int ZONED_FAN_POSITION = 16391; // 0x4007 - field public static final int ZONED_FAN_POSITION_AVAILABLE = 16390; // 0x4006 - field public static final int ZONED_FAN_SPEED_RPM = 16389; // 0x4005 - field public static final int ZONED_FAN_SPEED_SETPOINT = 16388; // 0x4004 - field public static final int ZONED_HVAC_POWER_ON = 16387; // 0x4003 - field public static final int ZONED_MAX_AC_ON = 16396; // 0x400c - field public static final int ZONED_MAX_DEFROST_ON = 16398; // 0x400e - field public static final int ZONED_SEAT_TEMP = 16392; // 0x4008 - field public static final int ZONED_TEMP_ACTUAL = 16386; // 0x4002 - field public static final int ZONED_TEMP_SETPOINT = 16385; // 0x4001 - } - } package android.car.hardware.radio { @@ -690,10 +667,10 @@ package android.car.hardware.radio { public final class CarRadioManager { method public android.car.hardware.radio.CarRadioPreset getPreset(int) throws android.car.CarNotConnectedException; - method public int getPresetCount(); + method public int getPresetCount() throws android.car.CarNotConnectedException; method public synchronized void registerListener(android.car.hardware.radio.CarRadioManager.CarRadioEventListener) throws android.car.CarNotConnectedException; method public boolean setPreset(android.car.hardware.radio.CarRadioPreset) throws android.car.CarNotConnectedException, java.lang.IllegalArgumentException; - method public synchronized void unregisterListener() throws android.car.CarNotConnectedException; + method public synchronized void unregisterListener(); } public static abstract interface CarRadioManager.CarRadioEventListener { @@ -737,13 +714,13 @@ package android.car.input { package android.car.media { public final class CarAudioManager { - method public int abandonAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes); - method public android.media.AudioAttributes getAudioAttributesForCarUsage(int); + method public void abandonAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes); + method public android.media.AudioAttributes getAudioAttributesForCarUsage(int) throws android.car.CarNotConnectedException; method public int getStreamMaxVolume(int) throws android.car.CarNotConnectedException; method public int getStreamMinVolume(int) throws android.car.CarNotConnectedException; method public int getStreamVolume(int) throws android.car.CarNotConnectedException; method public boolean isMediaMuted() throws android.car.CarNotConnectedException; - method public int requestAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes, int, int) throws java.lang.IllegalArgumentException; + method public int requestAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes, int, int) throws android.car.CarNotConnectedException, java.lang.IllegalArgumentException; method public boolean setMediaMute(boolean) throws android.car.CarNotConnectedException; method public void setStreamVolume(int, int, int) throws android.car.CarNotConnectedException; method public void setVolumeController(android.media.IVolumeController) throws android.car.CarNotConnectedException; diff --git a/car-lib/src/android/car/Car.java b/car-lib/src/android/car/Car.java index 1d87ef7979..ab4f9c97fe 100644 --- a/car-lib/src/android/car/Car.java +++ b/car-lib/src/android/car/Car.java @@ -492,6 +492,17 @@ public final class Car { } } + /** @hide */ + public static void hideCarNotConnectedExceptionFromCarService( + IllegalStateException e) throws IllegalStateException { + String message = e.getMessage(); + if (CAR_NOT_CONNECTED_EXCEPTION_MSG.equals(message)) { + return; //ignore + } else { + throw e; + } + } + private CarManagerBase createCarManager(String serviceName, IBinder binder) throws CarNotConnectedException { CarManagerBase manager = null; diff --git a/car-lib/src/android/car/CarApiUtil.java b/car-lib/src/android/car/CarApiUtil.java index e4a7a60624..81305075e5 100644 --- a/car-lib/src/android/car/CarApiUtil.java +++ b/car-lib/src/android/car/CarApiUtil.java @@ -33,35 +33,6 @@ public final class CarApiUtil { public static final String CAR_NOT_CONNECTED_EXCEPTION_MSG = "CarNotConnected"; /** - * CarService throw IllegalStateException with this message is re-thrown as - * {@link CarOperationNotSupportedException}. - * - * @hide - */ - public static final String CAR_NOT_SUPPORTED_EXCEPTION_MSG = "CarNotSupported"; - - /** - * IllegalStateException from CarService with special message is re-thrown as a different - * exception. - * - * @param e exception from CarService - * @throws CarNotConnectedException if the connection to the car service has been lost. - * @throws CarOperationNotSupportedException - * @hide - */ - public static void checkAllIllegalStateExceptionsFromCarService(IllegalStateException e) - throws CarNotConnectedException, CarOperationNotSupportedException { - String message = e.getMessage(); - if (message.equals(CAR_NOT_CONNECTED_EXCEPTION_MSG)) { - throw new CarNotConnectedException(); - } else if (message.equals(CAR_NOT_SUPPORTED_EXCEPTION_MSG)) { - throw new CarOperationNotSupportedException(); - } else { - throw e; - } - } - - /** * Re-throw IllegalStateException from CarService with * {@link #CAR_NOT_CONNECTED_EXCEPTION_MSG} message as {@link CarNotConnectedException}. * exception. diff --git a/car-lib/src/android/car/CarAppFocusManager.java b/car-lib/src/android/car/CarAppFocusManager.java index e6ddd158fb..d07b5e2f49 100644 --- a/car-lib/src/android/car/CarAppFocusManager.java +++ b/car-lib/src/android/car/CarAppFocusManager.java @@ -159,8 +159,7 @@ public final class CarAppFocusManager implements CarManagerBase { * @param appType * @throws CarNotConnectedException if the connection to the car service has been lost. */ - public void removeFocusListener(OnAppFocusChangedListener listener, @AppFocusType int appType) - throws CarNotConnectedException { + public void removeFocusListener(OnAppFocusChangedListener listener, @AppFocusType int appType) { IAppFocusListenerImpl binder; synchronized (this) { binder = mChangeBinders.get(listener); @@ -171,7 +170,7 @@ public final class CarAppFocusManager implements CarManagerBase { try { mService.unregisterFocusListener(binder, appType); } catch (RemoteException e) { - throw new CarNotConnectedException(e); + //ignore } synchronized (this) { binder.removeAppType(appType); @@ -187,8 +186,7 @@ public final class CarAppFocusManager implements CarManagerBase { * @param listener * @throws CarNotConnectedException if the connection to the car service has been lost. */ - public void removeFocusListener(OnAppFocusChangedListener listener) - throws CarNotConnectedException { + public void removeFocusListener(OnAppFocusChangedListener listener) { IAppFocusListenerImpl binder; synchronized (this) { binder = mChangeBinders.remove(listener); @@ -201,7 +199,7 @@ public final class CarAppFocusManager implements CarManagerBase { mService.unregisterFocusListener(binder, appType); } } catch (RemoteException e) { - throw new CarNotConnectedException(e); + //ignore } } @@ -282,8 +280,7 @@ public final class CarAppFocusManager implements CarManagerBase { * @throws CarNotConnectedException if the connection to the car service has been lost. */ public void abandonAppFocus(OnAppFocusOwnershipCallback ownershipCallback, - @AppFocusType int appType) - throws CarNotConnectedException { + @AppFocusType int appType) { if (ownershipCallback == null) { throw new IllegalArgumentException("null callback"); } @@ -297,7 +294,7 @@ public final class CarAppFocusManager implements CarManagerBase { try { mService.abandonAppFocus(binder, appType); } catch (RemoteException e) { - throw new CarNotConnectedException(e); + //ignore } synchronized (this) { binder.removeAppType(appType); @@ -313,8 +310,7 @@ public final class CarAppFocusManager implements CarManagerBase { * @param ownershipCallback * @throws CarNotConnectedException if the connection to the car service has been lost. */ - public void abandonAppFocus(OnAppFocusOwnershipCallback ownershipCallback) - throws CarNotConnectedException { + public void abandonAppFocus(OnAppFocusOwnershipCallback ownershipCallback) { IAppFocusOwnershipCallbackImpl binder; synchronized (this) { binder = mOwnershipBinders.remove(ownershipCallback); @@ -327,7 +323,7 @@ public final class CarAppFocusManager implements CarManagerBase { mService.abandonAppFocus(binder, appType); } } catch (RemoteException e) { - throw new CarNotConnectedException(e); + //ignore } } diff --git a/car-lib/src/android/car/CarOperationNotSupportedException.java b/car-lib/src/android/car/CarOperationNotSupportedException.java deleted file mode 100644 index 3fca5a5b1b..0000000000 --- a/car-lib/src/android/car/CarOperationNotSupportedException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.car; - - -/** - * Exception thrown when car is not supporting the requested operation. - */ -public class CarOperationNotSupportedException extends Exception { - private static final long serialVersionUID = -8120487541467522808L; - - public CarOperationNotSupportedException() { - } - - public CarOperationNotSupportedException(String name) { - super(name); - } - - public CarOperationNotSupportedException(String name, Throwable cause) { - super(name, cause); - } - - public CarOperationNotSupportedException(Exception cause) { - super(cause); - } -} diff --git a/car-lib/src/android/car/CarProjectionManager.java b/car-lib/src/android/car/CarProjectionManager.java index 5a78b39ac5..1e40fcd2b8 100644 --- a/car-lib/src/android/car/CarProjectionManager.java +++ b/car-lib/src/android/car/CarProjectionManager.java @@ -97,12 +97,12 @@ public final class CarProjectionManager implements CarManagerBase { * Unregister listener and stop listening projection events. * @throws CarNotConnectedException if the connection to the car service has been lost. */ - public void unregsiterProjectionListener() throws CarNotConnectedException { + public void unregsiterProjectionListener() { synchronized (this) { try { mService.unregsiterProjectionListener(mBinderListener); } catch (RemoteException e) { - throw new CarNotConnectedException(e); + //ignore } mListener = null; mVoiceSearchFilter = 0; @@ -134,7 +134,7 @@ public final class CarProjectionManager implements CarManagerBase { * @param serviceIntent * @throws CarNotConnectedException if the connection to the car service has been lost. */ - public void unregisterProjectionRunner(Intent serviceIntent) throws CarNotConnectedException { + public void unregisterProjectionRunner(Intent serviceIntent) { if (serviceIntent == null) { throw new IllegalArgumentException("null serviceIntent"); } @@ -142,7 +142,7 @@ public final class CarProjectionManager implements CarManagerBase { try { mService.unregisterProjectionRunner(serviceIntent); } catch (RemoteException e) { - throw new CarNotConnectedException(e); + //ignore } } } diff --git a/car-lib/src/android/car/VehicleSeat.java b/car-lib/src/android/car/VehicleSeat.java index 99531597ca..3707454163 100644 --- a/car-lib/src/android/car/VehicleSeat.java +++ b/car-lib/src/android/car/VehicleSeat.java @@ -26,17 +26,15 @@ import android.car.hardware.CarPropertyValue; */ @SystemApi public final class VehicleSeat { - public static final int SEAT_DRIVER_LHD = 0x0001; - public static final int SEAT_DRIVER_RHD = 0x0002; - public static final int SEAT_ROW_1_PASSENGER_LEFT = 0x0010; - public static final int SEAT_ROW_1_PASSENGER_CENTER = 0x0020; - public static final int SEAT_ROW_1_PASSENGER_RIGHT = 0x0040; - public static final int SEAT_ROW_2_PASSENGER_LEFT = 0x0100; - public static final int SEAT_ROW_2_PASSENGER_CENTER = 0x0200; - public static final int SEAT_ROW_2_PASSENGER_RIGHT = 0x0400; - public static final int SEAT_ROW_3_PASSENGER_LEFT = 0x1000; - public static final int SEAT_ROW_3_PASSENGER_CENTER = 0x2000; - public static final int SEAT_ROW_3_PASSENGER_RIGHT = 0x4000; + public static final int SEAT_ROW_1_LEFT = 0x0001; + public static final int SEAT_ROW_1_CENTER = 0x0002; + public static final int SEAT_ROW_1_RIGHT = 0x0004; + public static final int SEAT_ROW_2_LEFT = 0x0010; + public static final int SEAT_ROW_2_CENTER = 0x0020; + public static final int SEAT_ROW_2_RIGHT = 0x0040; + public static final int SEAT_ROW_3_LEFT = 0x0100; + public static final int SEAT_ROW_3_CENTER = 0x0200; + public static final int SEAT_ROW_3_RIGHT = 0x0400; private VehicleSeat() {} } diff --git a/car-lib/src/android/car/annotation/ValueTypeDef.java b/car-lib/src/android/car/annotation/ValueTypeDef.java index b06cc98b6a..de17a0d656 100644 --- a/car-lib/src/android/car/annotation/ValueTypeDef.java +++ b/car-lib/src/android/car/annotation/ValueTypeDef.java @@ -24,6 +24,7 @@ import java.lang.annotation.Target; /** * Annotation for specifying value type for key - value pair. * Key definition will have this annotation to specify what kind of value is expected from the key. + * @hide */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.SOURCE) diff --git a/car-lib/src/android/car/hardware/CarSensorManager.java b/car-lib/src/android/car/hardware/CarSensorManager.java index b353295135..5baf08e14e 100644 --- a/car-lib/src/android/car/hardware/CarSensorManager.java +++ b/car-lib/src/android/car/hardware/CarSensorManager.java @@ -17,6 +17,7 @@ package android.car.hardware; import android.Manifest; +import android.annotation.IntDef; import android.annotation.RequiresPermission; import android.car.Car; import android.car.CarApiUtil; @@ -31,6 +32,8 @@ import android.os.Message; import android.os.RemoteException; import android.util.Log; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.lang.ref.WeakReference; import java.util.HashMap; import java.util.Iterator; @@ -138,6 +141,21 @@ public final class CarSensorManager implements CarManagerBase { public static final int SENSOR_TYPE_VENDOR_EXTENSION_START = 0x60000000; public static final int SENSOR_TYPE_VENDOR_EXTENSION_END = 0x6fffffff; + /** @hide */ + @IntDef({ + SENSOR_TYPE_CAR_SPEED, + SENSOR_TYPE_RPM, + SENSOR_TYPE_ODOMETER, + SENSOR_TYPE_FUEL_LEVEL, + SENSOR_TYPE_PARKING_BRAKE, + SENSOR_TYPE_GEAR, + SENSOR_TYPE_NIGHT, + SENSOR_TYPE_DRIVING_STATUS, + SENSOR_TYPE_ENVIRONMENT + }) + @Retention(RetentionPolicy.SOURCE) + public @interface SensorType {} + /** Read sensor in default normal rate set for each sensors. This is default rate. */ public static final int SENSOR_RATE_NORMAL = 3; public static final int SENSOR_RATE_UI = 2; @@ -145,6 +163,16 @@ public final class CarSensorManager implements CarManagerBase { /** Read sensor at the maximum rate. Actual rate will be different depending on the sensor. */ public static final int SENSOR_RATE_FASTEST = 0; + /** @hide */ + @IntDef({ + SENSOR_RATE_NORMAL, + SENSOR_RATE_UI, + SENSOR_RATE_FAST, + SENSOR_RATE_FASTEST + }) + @Retention(RetentionPolicy.SOURCE) + public @interface SensorRate {} + private static final int MSG_SENSOR_EVENTS = 0; private final ICarSensor mService; @@ -221,7 +249,7 @@ public final class CarSensorManager implements CarManagerBase { * @return true if the sensor is supported. * @throws CarNotConnectedException if the connection to the car service has been lost. */ - public boolean isSensorSupported(int sensorType) throws CarNotConnectedException { + public boolean isSensorSupported(@SensorType int sensorType) throws CarNotConnectedException { int[] sensors = getSupportedSensors(); for (int sensorSupported: sensors) { if (sensorType == sensorSupported) { @@ -237,7 +265,7 @@ public final class CarSensorManager implements CarManagerBase { * @param sensorType * @return */ - public static boolean isSensorSupported(int[] sensorList, int sensorType) { + public static boolean isSensorSupported(int[] sensorList, @SensorType int sensorType) { for (int sensorSupported: sensorList) { if (sensorType == sensorSupported) { return true; @@ -281,8 +309,8 @@ public final class CarSensorManager implements CarManagerBase { */ @RequiresPermission(anyOf={Manifest.permission.ACCESS_FINE_LOCATION, Car.PERMISSION_SPEED, Car.PERMISSION_MILEAGE, Car.PERMISSION_FUEL}, conditional=true) - public boolean registerListener(OnSensorChangedListener listener, int sensorType, int rate) - throws CarNotConnectedException, IllegalArgumentException { + public boolean registerListener(OnSensorChangedListener listener, @SensorType int sensorType, + @SensorRate int rate) throws CarNotConnectedException, IllegalArgumentException { assertSensorType(sensorType); if (rate != SENSOR_RATE_FASTEST && rate != SENSOR_RATE_NORMAL) { throw new IllegalArgumentException("wrong rate " + rate); @@ -317,8 +345,7 @@ public final class CarSensorManager implements CarManagerBase { * @param listener * @throws CarNotConnectedException if the connection to the car service has been lost. */ - public void unregisterListener(OnSensorChangedListener listener) - throws CarNotConnectedException { + public void unregisterListener(OnSensorChangedListener listener) { //TODO: removing listener should reset update rate synchronized(mActiveSensorListeners) { Iterator<Integer> sensorIterator = mActiveSensorListeners.keySet().iterator(); @@ -336,15 +363,14 @@ public final class CarSensorManager implements CarManagerBase { * @param sensorType * @throws CarNotConnectedException if the connection to the car service has been lost. */ - public void unregisterListener(OnSensorChangedListener listener, int sensorType) - throws CarNotConnectedException { + public void unregisterListener(OnSensorChangedListener listener, @SensorType int sensorType) { synchronized(mActiveSensorListeners) { doUnregisterListenerLocked(listener, sensorType, null); } } private void doUnregisterListenerLocked(OnSensorChangedListener listener, Integer sensor, - Iterator<Integer> sensorIterator) throws CarNotConnectedException { + Iterator<Integer> sensorIterator) { CarSensorListeners listeners = mActiveSensorListeners.get(sensor); if (listeners != null) { if (listeners.contains(listener)) { @@ -355,7 +381,7 @@ public final class CarSensorManager implements CarManagerBase { mService.unregisterSensorListener(sensor.intValue(), mCarSensorEventListenerToService); } catch (RemoteException e) { - throw new CarNotConnectedException(e); + //ignore } if (sensorIterator == null) { mActiveSensorListeners.remove(sensor); @@ -389,7 +415,8 @@ public final class CarSensorManager implements CarManagerBase { * @return null if there was no sensor update since connected to the car. * @throws CarNotConnectedException if the connection to the car service has been lost. */ - public CarSensorEvent getLatestSensorEvent(int type) throws CarNotConnectedException { + public CarSensorEvent getLatestSensorEvent(@SensorType int type) + throws CarNotConnectedException { assertSensorType(type); try { return mService.getLatestSensorEvent(type); diff --git a/car-lib/src/android/car/hardware/CarVendorExtensionManager.java b/car-lib/src/android/car/hardware/CarVendorExtensionManager.java index 57c701a694..1235fcd952 100644 --- a/car-lib/src/android/car/hardware/CarVendorExtensionManager.java +++ b/car-lib/src/android/car/hardware/CarVendorExtensionManager.java @@ -21,7 +21,7 @@ import android.car.Car; import android.car.CarManagerBase; import android.car.CarNotConnectedException; import android.car.hardware.property.CarPropertyManagerBase; -import android.car.hardware.property.CarPropertyManagerBase.CarPropertyEventListener; +import android.car.hardware.property.CarPropertyManagerBase.CarPropertyEventCallback; import android.os.Handler; import android.os.IBinder; import android.os.Looper; @@ -46,7 +46,7 @@ public final class CarVendorExtensionManager implements CarManagerBase { private final CarPropertyManagerBase mPropertyManager; @GuardedBy("mLock") - private ArraySet<CarVendorExtensionListener> mListeners; + private ArraySet<CarVendorExtensionCallback> mCallbacks; private final Object mLock = new Object(); /** @@ -63,7 +63,7 @@ public final class CarVendorExtensionManager implements CarManagerBase { * Contains callback functions that will be called when some event happens with vehicle * property. */ - public interface CarVendorExtensionListener { + public interface CarVendorExtensionCallback { /** Called when a property is updated */ void onChangeEvent(CarPropertyValue value); @@ -75,46 +75,46 @@ public final class CarVendorExtensionManager implements CarManagerBase { * Registers listener. The methods of the listener will be called when new events arrived in * the main thread. */ - public void registerListener(CarVendorExtensionListener listener) throws CarNotConnectedException { + public void registerCallback(CarVendorExtensionCallback callback) + throws CarNotConnectedException { synchronized (mLock) { - if (mListeners == null) { - mPropertyManager.registerListener(new CarPropertyEventListener() { + if (mCallbacks == null) { + mPropertyManager.registerCallback(new CarPropertyEventCallback() { @Override public void onChangeEvent(CarPropertyValue value) { - for (CarVendorExtensionListener listener: getListeners()) { + for (CarVendorExtensionCallback listener: getCallbacks()) { listener.onChangeEvent(value); } } @Override public void onErrorEvent(int propertyId, int zone) { - for (CarVendorExtensionListener listener: getListeners()) { + for (CarVendorExtensionCallback listener: getCallbacks()) { listener.onErrorEvent(propertyId, zone); } } }); - mListeners = new ArraySet<>(1 /* We expect at least one element */); + mCallbacks = new ArraySet<>(1 /* We expect at least one element */); } - mListeners.add(listener); + mCallbacks.add(callback); } } /** Unregisters listener that was previously registered. */ - public void unregisterListener(CarVendorExtensionListener listener) - throws CarNotConnectedException { + public void unregisterCallback(CarVendorExtensionCallback callback) { synchronized (mLock) { - mListeners.remove(listener); - if (mListeners.isEmpty()) { - mPropertyManager.unregisterListener(); - mListeners = null; + mCallbacks.remove(callback); + if (mCallbacks.isEmpty()) { + mPropertyManager.unregisterCallback(); + mCallbacks = null; } } } /** Returns copy of listeners. Thread safe. */ - private CarVendorExtensionListener[] getListeners() { + private CarVendorExtensionCallback[] getCallbacks() { synchronized (mLock) { - return mListeners.toArray(new CarVendorExtensionListener[mListeners.size()]); + return mCallbacks.toArray(new CarVendorExtensionCallback[mCallbacks.size()]); } } diff --git a/car-lib/src/android/car/hardware/cabin/CarCabinManager.java b/car-lib/src/android/car/hardware/cabin/CarCabinManager.java index 152d607e18..0991856ab9 100644 --- a/car-lib/src/android/car/hardware/cabin/CarCabinManager.java +++ b/car-lib/src/android/car/hardware/cabin/CarCabinManager.java @@ -24,19 +24,34 @@ import android.car.CarNotConnectedException; import android.car.hardware.CarPropertyConfig; import android.car.hardware.CarPropertyValue; import android.car.hardware.property.CarPropertyManagerBase; -import android.car.hardware.property.CarPropertyManagerBase.CarPropertyEventListener; +import android.car.hardware.property.CarPropertyManagerBase.CarPropertyEventCallback; import android.content.Context; import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.util.ArraySet; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.lang.ref.WeakReference; import java.util.Collection; import java.util.List; /** - * API for controlling Cabin system in cars + * API for controlling Cabin system in cars. + * Most Car Cabin properties have both a MOVE and POSITION parameter associated with them. + * + * The MOVE parameter will start moving the device in the indicated direction. Magnitude + * indicates relative speed. For instance, setting the WINDOW_MOVE parameter to +1 rolls + * the window up. Setting it to +2 (if available) will roll it up faster. + * + * POSITION parameter will move the device to the desired position. For instance, if the + * WINDOW_POS has a range of 0-100, setting this parameter to 50 will open the window + * halfway. Depending upon the initial position, the window may move up or down to the + * 50% value. + * + * One or both of the MOVE/POSITION parameters may be implemented depending upon the + * capability of the hardware. * @hide */ @SystemApi @@ -44,284 +59,267 @@ public final class CarCabinManager implements CarManagerBase { private final static boolean DBG = false; private final static String TAG = "CarCabinManager"; private final CarPropertyManagerBase mMgr; - private final ArraySet<CarCabinEventListener> mListeners = new ArraySet<>(); + private final ArraySet<CarCabinEventCallback> mCallbacks = new ArraySet<>(); private CarPropertyEventListenerToBase mListenerToBase = null; + /** Door properties are zoned by VehicleDoor */ /** - * Cabin property IDs for get/set methods + * door position, int + * This is an integer in case a door may be set to a particular position. + * Max value indicates fully open, min value (0) indicates fully closed. + * + * Some vehicles (minivans) can open the door electronically. Hence, the ability + * to write this property. + * */ - @IntDef({ - CabinPropertyId.DOOR_POS, - CabinPropertyId.DOOR_MOVE, - CabinPropertyId.DOOR_LOCK, - CabinPropertyId.MIRROR_Z_POS, - CabinPropertyId.MIRROR_Z_MOVE, - CabinPropertyId.MIRROR_Y_POS, - CabinPropertyId.MIRROR_Y_MOVE, - CabinPropertyId.MIRROR_LOCK, - CabinPropertyId.MIRROR_FOLD, - CabinPropertyId.SEAT_MEMORY_SELECT, - CabinPropertyId.SEAT_MEMORY_SET, - CabinPropertyId.SEAT_BELT_BUCKLED, - CabinPropertyId.SEAT_BELT_HEIGHT_POS, - CabinPropertyId.SEAT_BELT_HEIGHT_MOVE, - CabinPropertyId.SEAT_FORE_AFT_POS, - CabinPropertyId.SEAT_FORE_AFT_MOVE, - CabinPropertyId.SEAT_BACKREST_ANGLE_1_POS, - CabinPropertyId.SEAT_BACKREST_ANGLE_1_MOVE, - CabinPropertyId.SEAT_BACKREST_ANGLE_2_POS, - CabinPropertyId.SEAT_BACKREST_ANGLE_2_MOVE, - CabinPropertyId.SEAT_HEIGHT_POS, - CabinPropertyId.SEAT_HEIGHT_MOVE, - CabinPropertyId.SEAT_DEPTH_POS, - CabinPropertyId.SEAT_DEPTH_MOVE, - CabinPropertyId.SEAT_TILT_POS, - CabinPropertyId.SEAT_TILT_MOVE, - CabinPropertyId.SEAT_LUMBAR_FORE_AFT_POS, - CabinPropertyId.SEAT_LUMBAR_FORE_AFT_MOVE, - CabinPropertyId.SEAT_LUMBAR_SIDE_SUPPORT_POS, - CabinPropertyId.SEAT_LUMBAR_SIDE_SUPPORT_MOVE, - CabinPropertyId.SEAT_HEADREST_HEIGHT_POS, - CabinPropertyId.SEAT_HEADREST_HEIGHT_MOVE, - CabinPropertyId.SEAT_HEADREST_ANGLE_POS, - CabinPropertyId.SEAT_HEADREST_ANGLE_MOVE, - CabinPropertyId.SEAT_HEADREST_FORE_AFT_POS, - CabinPropertyId.SEAT_HEADREST_FORE_AFT_MOVE, - CabinPropertyId.WINDOW_POS, - CabinPropertyId.WINDOW_MOVE, - CabinPropertyId.WINDOW_VENT_POS, - CabinPropertyId.WINDOW_VENT_MOVE, - CabinPropertyId.WINDOW_LOCK - }) - public @interface CabinPropertyId { - /** - * Most Car Cabin properties have both a MOVE and POSITION parameter associated with them. - * - * The MOVE parameter will start moving the device in the indicated direction. Magnitude - * indicates relative speed. For instance, setting the WINDOW_MOVE parameter to +1 rolls - * the window up. Setting it to +2 (if available) will roll it up faster. - * - * POSITION parameter will move the device to the desired position. For instance, if the - * WINDOW_POS has a range of 0-100, setting this parameter to 50 will open the window - * halfway. Depending upon the initial position, the window may move up or down to the - * 50% value. - * - * One or both of the MOVE/POSITION parameters may be implemented depending upon the - * capability of the hardware. - */ + public static final int ID_DOOR_POS = 0x0001; + /** door move, int */ + public static final int ID_DOOR_MOVE = 0x0002; + /** door lock, bool + * 'true' indicates door is locked + */ + public static final int ID_DOOR_LOCK = 0x0003; - /** Door properties are zoned by VehicleDoor */ - /** - * door position, int - * This is an integer in case a door may be set to a particular position. - * Max value indicates fully open, min value (0) indicates fully closed. - * - * Some vehicles (minivans) can open the door electronically. Hence, the ability - * to write this property. - * - */ - int DOOR_POS = 0x0001; - /** door move, int */ - int DOOR_MOVE = 0x0002; - /** door lock, bool - * 'true' indicates door is locked - */ - int DOOR_LOCK = 0x0003; + /** Mirror properties are zoned by VehicleMirror */ + /** + * mirror z position, int + * Positive value indicates tilt upwards, negative value is downwards + */ + public static final int ID_MIRROR_Z_POS = 0x1001; + /** mirror z move, int */ + public static final int ID_MIRROR_Z_MOVE = 0x1002; + /** + * mirror y position, int + * Positive value indicate tilt right, negative value is left + */ + public static final int ID_MIRROR_Y_POS = 0x1003; + /** mirror y move, int */ + public static final int ID_MIRROR_Y_MOVE = 0x1004; + /** + * mirror lock, bool + * True indicates mirror positions are locked and not changeable + */ + public static final int ID_MIRROR_LOCK = 0x1005; + /** + * mirror fold, bool + * True indicates mirrors are folded + */ + public static final int ID_MIRROR_FOLD = 0x1006; - /** Mirror properties are zoned by VehicleMirror */ - /** - * mirror z position, int - * Positive value indicates tilt upwards, negative value is downwards - */ - int MIRROR_Z_POS = 0x1001; - /** mirror z move, int */ - int MIRROR_Z_MOVE = 0x1002; - /** - * mirror y position, int - * Positive value indicate tilt right, negative value is left - */ - int MIRROR_Y_POS = 0x1003; - /** mirror y move, int */ - int MIRROR_Y_MOVE = 0x1004; - /** - * mirror lock, bool - * True indicates mirror positions are locked and not changeable - */ - int MIRROR_LOCK = 0x1005; - /** - * mirror fold, bool - * True indicates mirrors are folded - */ - int MIRROR_FOLD = 0x1006; + /** Seat properties are zoned by VehicleSeat */ + /** + * seat memory select, int + * This parameter selects the memory preset to use to select the seat position. + * The minValue is always 0, and the maxValue determines the number of seat + * positions available. + * + * For instance, if the driver's seat has 3 memory presets, the maxValue will be 3. + * When the user wants to select a preset, the desired preset number (1, 2, or 3) + * is set. + */ + public static final int ID_SEAT_MEMORY_SELECT = 0x2001; + /** + * seat memory set, int + * This setting allows the user to save the current seat position settings into + * the selected preset slot. The maxValue for each seat position shall match + * the maxValue for VEHICLE_PROPERTY_SEAT_MEMORY_SELECT. + */ + public static final int ID_SEAT_MEMORY_SET = 0x2002; + /** + * seat belt buckled, bool + * True indicates belt is buckled. + */ + public static final int ID_SEAT_BELT_BUCKLED = 0x2003; + /** + * seat belt height position, int + * Adjusts the shoulder belt anchor point. + * Max value indicates highest position + * Min value indicates lowest position + */ + public static final int ID_SEAT_BELT_HEIGHT_POS = 0x2004; + /** seat belt height move, int */ + public static final int ID_SEAT_BELT_HEIGHT_MOVE = 0x2005; + /** + * seat fore/aft position, int + * Sets the seat position forward (closer to steering wheel) and backwards. + * Max value indicates closest to wheel, min value indicates most rearward + * position. + */ + public static final int ID_SEAT_FORE_AFT_POS = 0x2006; + /** seat fore/aft move, int */ + public static final int ID_SEAT_FORE_AFT_MOVE = 0x2007; + /** + * seat backrest angle #1 position, int + * Backrest angle 1 is the actuator closest to the bottom of the seat. + * Max value indicates angling forward towards the steering wheel. + * Min value indicates full recline. + */ + public static final int ID_SEAT_BACKREST_ANGLE_1_POS = 0x2008; + /** seat backrest angle #1 move, int */ + public static final int ID_SEAT_BACKREST_ANGLE_1_MOVE = 0x2009; + /** + * seat backrest angle #2 position, int + * Backrest angle 2 is the next actuator up from the bottom of the seat. + * Max value indicates angling forward towards the steering wheel. + * Min value indicates full recline. + */ + public static final int ID_SEAT_BACKREST_ANGLE_2_POS = 0x200A; + /** seat backrest angle #2 move, int */ + public static final int ID_SEAT_BACKREST_ANGLE_2_MOVE = 0x200B; + /** + * seat height position, int + * Sets the seat height. + * Max value indicates highest position. + * Min value indicates lowest position. + */ + public static final int ID_SEAT_HEIGHT_POS = 0x200C; + /** seat height move, int */ + public static final int ID_SEAT_HEIGHT_MOVE = 0x200D; + /** + * seat depth position, int + * Sets the seat depth, distance from back rest to front edge of seat. + * Max value indicates longest depth position. + * Min value indicates shortest position. + */ + public static final int ID_SEAT_DEPTH_POS = 0x200E; + /** seat depth move, int */ + public static final int ID_SEAT_DEPTH_MOVE = 0x200F; + /** + * seat tilt position, int + * Sets the seat tilt. + * Max value indicates front edge of seat higher than back edge. + * Min value indicates front edge of seat lower than back edge. + */ + public static final int ID_SEAT_TILT_POS = 0x2010; + /** seat tilt move, int */ + public static final int ID_SEAT_TILT_MOVE = 0x2011; + /** + * seat lumbar fore/aft position, int + * Pushes the lumbar support forward and backwards + * Max value indicates most forward position. + * Min value indicates most rearward position. + */ + public static final int ID_SEAT_LUMBAR_FORE_AFT_POS = 0x2012; + /** seat lumbar fore/aft move, int */ + public static final int ID_SEAT_LUMBAR_FORE_AFT_MOVE = 0x2013; + /** + * seat lumbar side support position, int + * Sets the amount of lateral lumbar support. + * Max value indicates widest lumbar setting (i.e. least support) + * Min value indicates thinnest lumbar setting. + */ + public static final int ID_SEAT_LUMBAR_SIDE_SUPPORT_POS = 0x2014; + /** seat lumbar side support move, int */ + public static final int ID_SEAT_LUMBAR_SIDE_SUPPORT_MOVE = 0x2015; + /** + * seat headrest height position, int + * Sets the headrest height. + * Max value indicates tallest setting. + * Min value indicates shortest setting. + */ + public static final int ID_SEAT_HEADREST_HEIGHT_POS = 0x2016; + /** seat headrest heigh move, int */ + public static final int ID_SEAT_HEADREST_HEIGHT_MOVE = 0x2017; + /** + * seat headrest angle position, int + * Sets the angle of the headrest. + * Max value indicates most upright angle. + * Min value indicates shallowest headrest angle. + */ + public static final int ID_SEAT_HEADREST_ANGLE_POS = 0x2018; + /** seat headrest angle move, int */ + public static final int ID_SEAT_HEADREST_ANGLE_MOVE = 0x2019; + /** + * seat headrest fore/aft position, int + * Adjusts the headrest forwards and backwards. + * Max value indicates position closest to front of car. + * Min value indicates position closest to rear of car. + */ + public static final int ID_SEAT_HEADREST_FORE_AFT_POS = 0x201A; + /** seat headrest fore/aft move, int */ + public static final int ID_SEAT_HEADREST_FORE_AFT_MOVE = 0x201B; - /** Seat properties are zoned by VehicleSeat */ - /** - * seat memory select, int - * This parameter selects the memory preset to use to select the seat position. - * The minValue is always 0, and the maxValue determines the number of seat - * positions available. - * - * For instance, if the driver's seat has 3 memory presets, the maxValue will be 3. - * When the user wants to select a preset, the desired preset number (1, 2, or 3) - * is set. - */ - int SEAT_MEMORY_SELECT = 0x2001; - /** - * seat memory set, int - * This setting allows the user to save the current seat position settings into - * the selected preset slot. The maxValue for each seat position shall match - * the maxValue for VEHICLE_PROPERTY_SEAT_MEMORY_SELECT. - */ - int SEAT_MEMORY_SET = 0x2002; - /** - * seat belt buckled, bool - * True indicates belt is buckled. - */ - int SEAT_BELT_BUCKLED = 0x2003; - /** - * seat belt height position, int - * Adjusts the shoulder belt anchor point. - * Max value indicates highest position - * Min value indicates lowest position - */ - int SEAT_BELT_HEIGHT_POS = 0x2004; - /** seat belt height move, int */ - int SEAT_BELT_HEIGHT_MOVE = 0x2005; - /** - * seat fore/aft position, int - * Sets the seat position forward (closer to steering wheel) and backwards. - * Max value indicates closest to wheel, min value indicates most rearward - * position. - */ - int SEAT_FORE_AFT_POS = 0x2006; - /** seat fore/aft move, int */ - int SEAT_FORE_AFT_MOVE = 0x2007; - /** - * seat backrest angle #1 position, int - * Backrest angle 1 is the actuator closest to the bottom of the seat. - * Max value indicates angling forward towards the steering wheel. - * Min value indicates full recline. - */ - int SEAT_BACKREST_ANGLE_1_POS = 0x2008; - /** seat backrest angle #1 move, int */ - int SEAT_BACKREST_ANGLE_1_MOVE = 0x2009; - /** - * seat backrest angle #2 position, int - * Backrest angle 2 is the next actuator up from the bottom of the seat. - * Max value indicates angling forward towards the steering wheel. - * Min value indicates full recline. - */ - int SEAT_BACKREST_ANGLE_2_POS = 0x200A; - /** seat backrest angle #2 move, int */ - int SEAT_BACKREST_ANGLE_2_MOVE = 0x200B; - /** - * seat height position, int - * Sets the seat height. - * Max value indicates highest position. - * Min value indicates lowest position. - */ - int SEAT_HEIGHT_POS = 0x200C; - /** seat height move, int */ - int SEAT_HEIGHT_MOVE = 0x200D; - /** - * seat depth position, int - * Sets the seat depth, distance from back rest to front edge of seat. - * Max value indicates longest depth position. - * Min value indicates shortest position. - */ - int SEAT_DEPTH_POS = 0x200E; - /** seat depth move, int */ - int SEAT_DEPTH_MOVE = 0x200F; - /** - * seat tilt position, int - * Sets the seat tilt. - * Max value indicates front edge of seat higher than back edge. - * Min value indicates front edge of seat lower than back edge. - */ - int SEAT_TILT_POS = 0x2010; - /** seat tilt move, int */ - int SEAT_TILT_MOVE = 0x2011; - /** - * seat lumbar fore/aft position, int - * Pushes the lumbar support forward and backwards - * Max value indicates most forward position. - * Min value indicates most rearward position. - */ - int SEAT_LUMBAR_FORE_AFT_POS = 0x2012; - /** seat lumbar fore/aft move, int */ - int SEAT_LUMBAR_FORE_AFT_MOVE = 0x2013; - /** - * seat lumbar side support position, int - * Sets the amount of lateral lumbar support. - * Max value indicates widest lumbar setting (i.e. least support) - * Min value indicates thinnest lumbar setting. - */ - int SEAT_LUMBAR_SIDE_SUPPORT_POS = 0x2014; - /** seat lumbar side support move, int */ - int SEAT_LUMBAR_SIDE_SUPPORT_MOVE = 0x2015; - /** - * seat headrest height position, int - * Sets the headrest height. - * Max value indicates tallest setting. - * Min value indicates shortest setting. - */ - int SEAT_HEADREST_HEIGHT_POS = 0x2016; - /** seat headrest heigh move, int */ - int SEAT_HEADREST_HEIGHT_MOVE = 0x2017; - /** - * seat headrest angle position, int - * Sets the angle of the headrest. - * Max value indicates most upright angle. - * Min value indicates shallowest headrest angle. - */ - int SEAT_HEADREST_ANGLE_POS = 0x2018; - /** seat headrest angle move, int */ - int SEAT_HEADREST_ANGLE_MOVE = 0x2019; - /** - * seat headrest fore/aft position, int - * Adjusts the headrest forwards and backwards. - * Max value indicates position closest to front of car. - * Min value indicates position closest to rear of car. - */ - int SEAT_HEADREST_FORE_AFT_POS = 0x201A; - /** seat headrest fore/aft move, int */ - int SEAT_HEADREST_FORE_AFT_MOVE = 0x201B; + /** Window properties are zoned by VehicleWindow */ + /** + * window position, int + * Max = window up / closed + * Min = window down / open + */ + public static final int ID_WINDOW_POS = 0x3001; + /** window move, int */ + public static final int ID_WINDOW_MOVE = 0x3002; + /** + * window vent position, int + * This feature is used to control the vent feature on a sunroof. + * + * Max = vent open + * Min = vent closed + */ + public static final int ID_WINDOW_VENT_POS = 0x3003; + /** window vent move, int */ + public static final int ID_WINDOW_VENT_MOVE = 0x3004; + /** + * window lock, bool + * True indicates windows are locked and can't be moved. + */ + public static final int ID_WINDOW_LOCK = 0x3005; - /** Window properties are zoned by VehicleWindow */ - /** - * window position, int - * Max = window up / closed - * Min = window down / open - */ - int WINDOW_POS = 0x3001; - /** window move, int */ - int WINDOW_MOVE = 0x3002; - /** - * window vent position, int - * This feature is used to control the vent feature on a sunroof. - * - * Max = vent open - * Min = vent closed - */ - int WINDOW_VENT_POS = 0x3003; - /** window vent move, int */ - int WINDOW_VENT_MOVE = 0x3004; - /** - * window lock, bool - * True indicates windows are locked and can't be moved. - */ - int WINDOW_LOCK = 0x3005; - } + /** @hide */ + @IntDef({ + ID_DOOR_POS, + ID_DOOR_MOVE, + ID_DOOR_LOCK, + ID_MIRROR_Z_POS, + ID_MIRROR_Z_MOVE, + ID_MIRROR_Y_POS, + ID_MIRROR_Y_MOVE, + ID_MIRROR_LOCK, + ID_MIRROR_FOLD, + ID_SEAT_MEMORY_SELECT, + ID_SEAT_MEMORY_SET, + ID_SEAT_BELT_BUCKLED, + ID_SEAT_BELT_HEIGHT_POS, + ID_SEAT_BELT_HEIGHT_MOVE, + ID_SEAT_FORE_AFT_POS, + ID_SEAT_FORE_AFT_MOVE, + ID_SEAT_BACKREST_ANGLE_1_POS, + ID_SEAT_BACKREST_ANGLE_1_MOVE, + ID_SEAT_BACKREST_ANGLE_2_POS, + ID_SEAT_BACKREST_ANGLE_2_MOVE, + ID_SEAT_HEIGHT_POS, + ID_SEAT_HEIGHT_MOVE, + ID_SEAT_DEPTH_POS, + ID_SEAT_DEPTH_MOVE, + ID_SEAT_TILT_POS, + ID_SEAT_TILT_MOVE, + ID_SEAT_LUMBAR_FORE_AFT_POS, + ID_SEAT_LUMBAR_FORE_AFT_MOVE, + ID_SEAT_LUMBAR_SIDE_SUPPORT_POS, + ID_SEAT_LUMBAR_SIDE_SUPPORT_MOVE, + ID_SEAT_HEADREST_HEIGHT_POS, + ID_SEAT_HEADREST_HEIGHT_MOVE, + ID_SEAT_HEADREST_ANGLE_POS, + ID_SEAT_HEADREST_ANGLE_MOVE, + ID_SEAT_HEADREST_FORE_AFT_POS, + ID_SEAT_HEADREST_FORE_AFT_MOVE, + ID_WINDOW_POS, + ID_WINDOW_MOVE, + ID_WINDOW_VENT_POS, + ID_WINDOW_VENT_MOVE, + ID_WINDOW_LOCK + }) + @Retention(RetentionPolicy.SOURCE) + public @interface PropertyId {} - public interface CarCabinEventListener { + public interface CarCabinEventCallback { /** Called when a property is updated */ void onChangeEvent(CarPropertyValue value); /** Called when an error is detected with a property */ - void onErrorEvent(int propertyId, int zone); + void onErrorEvent(@PropertyId int propertyId, int zone); } - private static class CarPropertyEventListenerToBase implements CarPropertyEventListener { + private static class CarPropertyEventListenerToBase implements CarPropertyEventCallback { private final WeakReference<CarCabinManager> mManager; public CarPropertyEventListenerToBase(CarCabinManager manager) { @@ -346,22 +344,22 @@ public final class CarCabinManager implements CarManagerBase { } void handleOnChangeEvent(CarPropertyValue value) { - Collection<CarCabinEventListener> listeners; + Collection<CarCabinEventCallback> callbacks; synchronized (this) { - listeners = new ArraySet<>(mListeners); + callbacks = new ArraySet<>(mCallbacks); } - for (CarCabinEventListener l: listeners) { + for (CarCabinEventCallback l: callbacks) { l.onChangeEvent(value); } } void handleOnErrorEvent(int propertyId, int zone) { - Collection<CarCabinEventListener> listeners; + Collection<CarCabinEventCallback> listeners; synchronized (this) { - listeners = new ArraySet<>(mListeners); + listeners = new ArraySet<>(mCallbacks); } if (!listeners.isEmpty()) { - for (CarCabinEventListener l: listeners) { + for (CarCabinEventCallback l: listeners) { l.onErrorEvent(propertyId, zone); } } @@ -378,25 +376,24 @@ public final class CarCabinManager implements CarManagerBase { } /** Returns true if the property is a zoned type. */ - public static boolean isZonedProperty(int propertyId) { + public static boolean isZonedProperty(@PropertyId int propertyId) { return true; } /** Implement wrappers for contained CarPropertyManagerBase object */ - public synchronized void registerListener(CarCabinEventListener listener) throws + public synchronized void registerCallback(CarCabinEventCallback callback) throws CarNotConnectedException { - if (mListeners.isEmpty()) { + if (mCallbacks.isEmpty()) { mListenerToBase = new CarPropertyEventListenerToBase(this); - mMgr.registerListener(mListenerToBase); + mMgr.registerCallback(mListenerToBase); } - mListeners.add(listener); + mCallbacks.add(callback); } - public synchronized void unregisterListener(CarCabinEventListener listener) throws - CarNotConnectedException { - mListeners.remove(listener); - if (mListeners.isEmpty()) { - mMgr.unregisterListener(); + public synchronized void unregisterCallback(CarCabinEventCallback callback) { + mCallbacks.remove(callback); + if (mCallbacks.isEmpty()) { + mMgr.unregisterCallback(); mListenerToBase = null; } } @@ -405,29 +402,34 @@ public final class CarCabinManager implements CarManagerBase { return mMgr.getPropertyList(); } - public boolean getBooleanProperty(int prop, int area) throws CarNotConnectedException { - return mMgr.getBooleanProperty(prop, area); + public boolean getBooleanProperty(@PropertyId int propertyId, int area) + throws CarNotConnectedException { + return mMgr.getBooleanProperty(propertyId, area); } - public float getFloatProperty(int prop, int area) throws CarNotConnectedException { - return mMgr.getFloatProperty(prop, area); + public float getFloatProperty(@PropertyId int propertyId, int area) + throws CarNotConnectedException { + return mMgr.getFloatProperty(propertyId, area); } - public int getIntProperty(int prop, int area) throws CarNotConnectedException { - return mMgr.getIntProperty(prop, area); + public int getIntProperty(@PropertyId int propertyId, int area) + throws CarNotConnectedException { + return mMgr.getIntProperty(propertyId, area); } - public void setBooleanProperty(int prop, int area, boolean val) + public void setBooleanProperty(@PropertyId int propertyId, int area, boolean val) throws CarNotConnectedException { - mMgr.setBooleanProperty(prop, area, val); + mMgr.setBooleanProperty(propertyId, area, val); } - public void setFloatProperty(int prop, int area, float val) throws CarNotConnectedException { - mMgr.setFloatProperty(prop, area, val); + public void setFloatProperty(@PropertyId int propertyId, int area, float val) + throws CarNotConnectedException { + mMgr.setFloatProperty(propertyId, area, val); } - public void setIntProperty(int prop, int area, int val) throws CarNotConnectedException { - mMgr.setIntProperty(prop, area, val); + public void setIntProperty(@PropertyId int propertyId, int area, int val) + throws CarNotConnectedException { + mMgr.setIntProperty(propertyId, area, val); } /** @hide */ diff --git a/car-lib/src/android/car/hardware/camera/CarCameraManager.java b/car-lib/src/android/car/hardware/camera/CarCameraManager.java index ad9238314d..eed670d25d 100644 --- a/car-lib/src/android/car/hardware/camera/CarCameraManager.java +++ b/car-lib/src/android/car/hardware/camera/CarCameraManager.java @@ -67,7 +67,7 @@ public final class CarCameraManager implements CarManagerBase { * * @return Array of CAR_CAMERA_TYPE_* telling which cameras are present */ - public int[] getCameraList() { + public int[] getCameraList() throws CarNotConnectedException { return mCameraList; } @@ -88,7 +88,7 @@ public final class CarCameraManager implements CarManagerBase { return capabilities; } - public CarCamera openCamera(int cameraType) { + public CarCamera openCamera(int cameraType) throws CarNotConnectedException { CarCamera camera = null; // Find cameraType in the list of available cameras diff --git a/car-lib/src/android/car/hardware/hvac/CarHvacManager.java b/car-lib/src/android/car/hardware/hvac/CarHvacManager.java index 77703f7fe9..6fd3446a32 100644 --- a/car-lib/src/android/car/hardware/hvac/CarHvacManager.java +++ b/car-lib/src/android/car/hardware/hvac/CarHvacManager.java @@ -24,13 +24,15 @@ import android.car.CarNotConnectedException; import android.car.hardware.CarPropertyConfig; import android.car.hardware.CarPropertyValue; import android.car.hardware.property.CarPropertyManagerBase; -import android.car.hardware.property.CarPropertyManagerBase.CarPropertyEventListener; +import android.car.hardware.property.CarPropertyManagerBase.CarPropertyEventCallback; import android.content.Context; import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.util.ArraySet; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.lang.ref.WeakReference; import java.util.Collection; import java.util.List; @@ -44,109 +46,113 @@ public final class CarHvacManager implements CarManagerBase { private final static boolean DBG = false; private final static String TAG = "CarHvacManager"; private final CarPropertyManagerBase mMgr; - private final ArraySet<CarHvacEventListener> mListeners = new ArraySet<>(); + private final ArraySet<CarHvacEventCallback> mCallbacks = new ArraySet<>(); private CarPropertyEventListenerToBase mListenerToBase = null; /** * HVAC property IDs for get/set methods */ - @IntDef({ - HvacPropertyId.MIRROR_DEFROSTER_ON, - HvacPropertyId.STEERING_WHEEL_TEMP, - HvacPropertyId.OUTSIDE_AIR_TEMP, - HvacPropertyId.TEMPERATURE_UNITS, - HvacPropertyId.MAX_GLOBAL_PROPERTY_ID, - HvacPropertyId.ZONED_TEMP_SETPOINT, - HvacPropertyId.ZONED_TEMP_ACTUAL, - HvacPropertyId.ZONED_FAN_SPEED_SETPOINT, - HvacPropertyId.ZONED_FAN_SPEED_RPM, - HvacPropertyId.ZONED_FAN_POSITION_AVAILABLE, - HvacPropertyId.ZONED_FAN_POSITION, - HvacPropertyId.ZONED_SEAT_TEMP, - HvacPropertyId.ZONED_AC_ON, - HvacPropertyId.ZONED_AUTOMATIC_MODE_ON, - HvacPropertyId.ZONED_AIR_RECIRCULATION_ON, - HvacPropertyId.ZONED_MAX_AC_ON, - HvacPropertyId.ZONED_DUAL_ZONE_ON, - HvacPropertyId.ZONED_MAX_DEFROST_ON, - HvacPropertyId.ZONED_HVAC_POWER_ON, - HvacPropertyId.WINDOW_DEFROSTER_ON, - }) - public @interface HvacPropertyId { - /** - * Global HVAC properties. There is only a single instance in a car. - * Global properties are in the range of 0-0x3FFF. - */ - /** Mirror defrosters state, bool. */ - int MIRROR_DEFROSTER_ON = 0x0001; - /** Steering wheel temp: negative values indicate cooling, positive values indicate - * heat, int. */ - int STEERING_WHEEL_TEMP = 0x0002; - /** Outside air temperature, float. */ - int OUTSIDE_AIR_TEMP = 0x0003; - /** Temperature units being used, int - * 0x30 = Celsius - * 0x31 = Fahrenheit - */ - int TEMPERATURE_UNITS = 0x0004; + /** + * Global HVAC properties. There is only a single instance in a car. + * Global properties are in the range of 0-0x3FFF. + */ + /** Mirror defrosters state, bool. */ + public static final int ID_MIRROR_DEFROSTER_ON = 0x0001; + /** Steering wheel temp: negative values indicate cooling, positive values indicate + * heat, int. */ + public static final int ID_STEERING_WHEEL_TEMP = 0x0002; + /** Outside air temperature, float. */ + public static final int ID_OUTSIDE_AIR_TEMP = 0x0003; + /** Temperature units being used, int + * 0x30 = Celsius + * 0x31 = Fahrenheit + */ + public static final int ID_TEMPERATURE_UNITS = 0x0004; - /** The maximum id that can be assigned to global (non-zoned) property. */ - int MAX_GLOBAL_PROPERTY_ID = 0x3fff; + /** + * The maximum id that can be assigned to global (non-zoned) property. + * @hide + */ + public static final int ID_MAX_GLOBAL_PROPERTY_ID = 0x3fff; - /** - * ZONED_* represents properties available on a per-zone basis. All zones in a car are - * not required to have the same properties. Zone specific properties start at 0x4000. - */ - /** Temperature setpoint desired by the user, int - * Temperature units are determined by TEMPERTURE_UNITS property - */ - int ZONED_TEMP_SETPOINT = 0x4001; - /** Actual zone temperature is read only integer, in terms of F or C, int. */ - int ZONED_TEMP_ACTUAL = 0x4002; - /** HVAC system powered on / off, bool - * In many vehicles, if the HVAC system is powered off, the SET and GET command will - * throw an IllegalStateException. To correct this, need to turn on the HVAC module first - * before manipulating a parameter. - */ - int ZONED_HVAC_POWER_ON = 0x4003; - /** Fan speed setpoint is an integer from 0-n, depending on the number of fan speeds - * available. Selection determines the fan position, int. */ - int ZONED_FAN_SPEED_SETPOINT = 0x4004; - /** Actual fan speed is a read-only value, expressed in RPM, int. */ - int ZONED_FAN_SPEED_RPM = 0x4005; - /** Fan position available is a bitmask of positions available for each zone, int. */ - int ZONED_FAN_POSITION_AVAILABLE = 0x4006; - /** Current fan position setting, int. */ - int ZONED_FAN_POSITION = 0x4007; - /** Seat temperature is negative for cooling, positive for heating. Temperature is a - * setting, i.e. -3 to 3 for 3 levels of cooling and 3 levels of heating. int. */ - int ZONED_SEAT_TEMP = 0x4008; - /** Air conditioner state, bool */ - int ZONED_AC_ON = 0x4009; - /** HVAC is in automatic mode, bool. */ - int ZONED_AUTOMATIC_MODE_ON = 0x400A; - /** Air recirculation is active, bool. */ - int ZONED_AIR_RECIRCULATION_ON = 0x400B; - /** Max AC is active, bool. */ - int ZONED_MAX_AC_ON = 0x400C; - /** Dual zone is enabled, bool. */ - int ZONED_DUAL_ZONE_ON = 0x400D; - /** Max Defrost is active, bool. */ - int ZONED_MAX_DEFROST_ON = 0x400E; - /** Defroster is based off of window position, bool */ - int WINDOW_DEFROSTER_ON = 0x5001; - } + /** + * ID_ZONED_* represents properties available on a per-zone basis. All zones in a car are + * not required to have the same properties. Zone specific properties start at 0x4000. + */ + /** Temperature setpoint desired by the user, int + * Temperature units are determined by TEMPERTURE_UNITS property + */ + public static final int ID_ZONED_TEMP_SETPOINT = 0x4001; + /** Actual zone temperature is read only integer, in terms of F or C, int. */ + public static final int ID_ZONED_TEMP_ACTUAL = 0x4002; + /** HVAC system powered on / off, bool + * In many vehicles, if the HVAC system is powered off, the SET and GET command will + * throw an IllegalStateException. To correct this, need to turn on the HVAC module first + * before manipulating a parameter. + */ + public static final int ID_ZONED_HVAC_POWER_ON = 0x4003; + /** Fan speed setpoint is an integer from 0-n, depending on the number of fan speeds + * available. Selection determines the fan position, int. */ + public static final int ID_ZONED_FAN_SPEED_SETPOINT = 0x4004; + /** Actual fan speed is a read-only value, expressed in RPM, int. */ + public static final int ID_ZONED_FAN_SPEED_RPM = 0x4005; + /** Fan position available is a bitmask of positions available for each zone, int. */ + public static final int ID_ZONED_FAN_POSITION_AVAILABLE = 0x4006; + /** Current fan position setting, int. */ + public static final int ID_ZONED_FAN_POSITION = 0x4007; + /** Seat temperature is negative for cooling, positive for heating. Temperature is a + * setting, i.e. -3 to 3 for 3 levels of cooling and 3 levels of heating. int. */ + public static final int ID_ZONED_SEAT_TEMP = 0x4008; + /** Air conditioner state, bool */ + public static final int ID_ZONED_AC_ON = 0x4009; + /** HVAC is in automatic mode, bool. */ + public static final int ID_ZONED_AUTOMATIC_MODE_ON = 0x400A; + /** Air recirculation is active, bool. */ + public static final int ID_ZONED_AIR_RECIRCULATION_ON = 0x400B; + /** Max AC is active, bool. */ + public static final int ID_ZONED_MAX_AC_ON = 0x400C; + /** Dual zone is enabled, bool. */ + public static final int ID_ZONED_DUAL_ZONE_ON = 0x400D; + /** Max Defrost is active, bool. */ + public static final int ID_ZONED_MAX_DEFROST_ON = 0x400E; + /** Defroster is based off of window position, bool */ + public static final int ID_WINDOW_DEFROSTER_ON = 0x5001; + + /** @hide */ + @IntDef({ + ID_MIRROR_DEFROSTER_ON, + ID_STEERING_WHEEL_TEMP, + ID_OUTSIDE_AIR_TEMP, + ID_TEMPERATURE_UNITS, + ID_ZONED_TEMP_SETPOINT, + ID_ZONED_TEMP_ACTUAL, + ID_ZONED_FAN_SPEED_SETPOINT, + ID_ZONED_FAN_SPEED_RPM, + ID_ZONED_FAN_POSITION_AVAILABLE, + ID_ZONED_FAN_POSITION, + ID_ZONED_SEAT_TEMP, + ID_ZONED_AC_ON, + ID_ZONED_AUTOMATIC_MODE_ON, + ID_ZONED_AIR_RECIRCULATION_ON, + ID_ZONED_MAX_AC_ON, + ID_ZONED_DUAL_ZONE_ON, + ID_ZONED_MAX_DEFROST_ON, + ID_ZONED_HVAC_POWER_ON, + ID_WINDOW_DEFROSTER_ON, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface PropertyId {} - public interface CarHvacEventListener { + public interface CarHvacEventCallback { /** Called when a property is updated */ void onChangeEvent(CarPropertyValue value); /** Called when an error is detected with a property */ - void onErrorEvent(int propertyId, int zone); + void onErrorEvent(@PropertyId int propertyId, int zone); } - private static class CarPropertyEventListenerToBase implements CarPropertyEventListener { + private static class CarPropertyEventListenerToBase implements CarPropertyEventCallback { private final WeakReference<CarHvacManager> mManager; public CarPropertyEventListenerToBase(CarHvacManager manager) { @@ -171,24 +177,24 @@ public final class CarHvacManager implements CarManagerBase { } void handleOnChangeEvent(CarPropertyValue value) { - Collection<CarHvacEventListener> listeners; + Collection<CarHvacEventCallback> callbacks; synchronized (this) { - listeners = new ArraySet<>(mListeners); + callbacks = new ArraySet<>(mCallbacks); } - if (!listeners.isEmpty()) { - for (CarHvacEventListener l: listeners) { + if (!callbacks.isEmpty()) { + for (CarHvacEventCallback l: callbacks) { l.onChangeEvent(value); } } } void handleOnErrorEvent(int propertyId, int zone) { - Collection<CarHvacEventListener> listeners; + Collection<CarHvacEventCallback> callbacks; synchronized (this) { - listeners = new ArraySet<>(mListeners); + callbacks = new ArraySet<>(mCallbacks); } - if (!listeners.isEmpty()) { - for (CarHvacEventListener l: listeners) { + if (!callbacks.isEmpty()) { + for (CarHvacEventCallback l: callbacks) { l.onErrorEvent(propertyId, zone); } } @@ -205,25 +211,24 @@ public final class CarHvacManager implements CarManagerBase { } /** Returns true if the property is a zoned type. */ - public static boolean isZonedProperty(int propertyId) { - return propertyId > HvacPropertyId.MAX_GLOBAL_PROPERTY_ID; + public static boolean isZonedProperty(@PropertyId int propertyId) { + return propertyId > ID_MAX_GLOBAL_PROPERTY_ID; } /** Implement wrappers for contained CarPropertyManagerBase object */ - public synchronized void registerListener(CarHvacEventListener listener) throws + public synchronized void registerCallback(CarHvacEventCallback callback) throws CarNotConnectedException { - if (mListeners.isEmpty()) { + if (mCallbacks.isEmpty()) { mListenerToBase = new CarPropertyEventListenerToBase(this); - mMgr.registerListener(mListenerToBase); + mMgr.registerCallback(mListenerToBase); } - mListeners.add(listener); + mCallbacks.add(callback); } - public synchronized void unregisterListener(CarHvacEventListener listener) throws - CarNotConnectedException { - mListeners.remove(listener); - if (mListeners.isEmpty()) { - mMgr.unregisterListener(); + public synchronized void unregisterCallback(CarHvacEventCallback callback) { + mCallbacks.remove(callback); + if (mCallbacks.isEmpty()) { + mMgr.unregisterCallback(); mListenerToBase = null; } } @@ -232,29 +237,34 @@ public final class CarHvacManager implements CarManagerBase { return mMgr.getPropertyList(); } - public boolean getBooleanProperty(int prop, int area) throws CarNotConnectedException { - return mMgr.getBooleanProperty(prop, area); + public boolean getBooleanProperty(@PropertyId int propertyId, int area) + throws CarNotConnectedException { + return mMgr.getBooleanProperty(propertyId, area); } - public float getFloatProperty(int prop, int area) throws CarNotConnectedException { - return mMgr.getFloatProperty(prop, area); + public float getFloatProperty(@PropertyId int propertyId, int area) + throws CarNotConnectedException { + return mMgr.getFloatProperty(propertyId, area); } - public int getIntProperty(int prop, int area) throws CarNotConnectedException { - return mMgr.getIntProperty(prop, area); + public int getIntProperty(@PropertyId int propertyId, int area) + throws CarNotConnectedException { + return mMgr.getIntProperty(propertyId, area); } - public void setBooleanProperty(int prop, int area, boolean val) + public void setBooleanProperty(@PropertyId int propertyId, int area, boolean val) throws CarNotConnectedException { - mMgr.setBooleanProperty(prop, area, val); + mMgr.setBooleanProperty(propertyId, area, val); } - public void setFloatProperty(int prop, int area, float val) throws CarNotConnectedException { - mMgr.setFloatProperty(prop, area, val); + public void setFloatProperty(@PropertyId int propertyId, int area, float val) + throws CarNotConnectedException { + mMgr.setFloatProperty(propertyId, area, val); } - public void setIntProperty(int prop, int area, int val) throws CarNotConnectedException { - mMgr.setIntProperty(prop, area, val); + public void setIntProperty(@PropertyId int propertyId, int area, int val) + throws CarNotConnectedException { + mMgr.setIntProperty(propertyId, area, val); } /** @hide */ diff --git a/car-lib/src/android/car/hardware/property/CarPropertyManagerBase.java b/car-lib/src/android/car/hardware/property/CarPropertyManagerBase.java index 9240e98f99..c666bc2fbc 100644 --- a/car-lib/src/android/car/hardware/property/CarPropertyManagerBase.java +++ b/car-lib/src/android/car/hardware/property/CarPropertyManagerBase.java @@ -48,12 +48,12 @@ public class CarPropertyManagerBase { @GuardedBy("mLock") private ICarPropertyEventListener mListenerToService; @GuardedBy("mLock") - private CarPropertyEventListener mListener; + private CarPropertyEventCallback mCallback; private final Object mLock = new Object(); /** Callback functions for property events */ - public interface CarPropertyEventListener { + public interface CarPropertyEventCallback { /** Called when a property is updated */ void onChangeEvent(CarPropertyValue value); @@ -99,14 +99,14 @@ public class CarPropertyManagerBase { mHandler = new EventCallbackHandler(this, handler.getLooper()); } - public void registerListener(CarPropertyEventListener listener) + public void registerCallback(CarPropertyEventCallback callback) throws CarNotConnectedException { synchronized (mLock) { - if (mListener != null) { - throw new IllegalStateException("Listener is already registered."); + if (mCallback != null) { + throw new IllegalStateException("Callback is already registered."); } - mListener = listener; + mCallback = callback; mListenerToService = new ICarPropertyEventListener.Stub() { @Override public void onEvent(CarPropertyEvent event) throws RemoteException { @@ -125,11 +125,11 @@ public class CarPropertyManagerBase { } } - public void unregisterListener() throws CarNotConnectedException { + public void unregisterCallback() { ICarPropertyEventListener listenerToService; synchronized (mLock) { listenerToService = mListenerToService; - mListener = null; + mCallback = null; mListenerToService = null; } @@ -142,9 +142,9 @@ public class CarPropertyManagerBase { mService.unregisterListener(listenerToService); } catch (RemoteException ex) { Log.e(mTag, "Failed to unregister listener", ex); - throw new CarNotConnectedException(ex); + //ignore } catch (IllegalStateException ex) { - Car.checkCarNotConnectedExceptionFromCarService(ex); + Car.hideCarNotConnectedExceptionFromCarService(ex); } } @@ -257,9 +257,9 @@ public class CarPropertyManagerBase { } private void dispatchEventToClient(CarPropertyEvent event) { - CarPropertyEventListener listener; + CarPropertyEventCallback listener; synchronized (mLock) { - listener = mListener; + listener = mCallback; } if (listener == null) { @@ -284,18 +284,16 @@ public class CarPropertyManagerBase { mHandler.sendMessage(mHandler.obtainMessage(EventCallbackHandler.MSG_GENERIC_EVENT, event)); } + /** @hide */ public void onCarDisconnected() { - try { - ICarPropertyEventListener listenerToService; - synchronized (mLock) { - listenerToService = mListenerToService; - } - if (listenerToService != null) { - unregisterListener(); - } - } catch (CarNotConnectedException e) { - // Ignore, car is disconnecting. + ICarPropertyEventListener listenerToService; + synchronized (mLock) { + listenerToService = mListenerToService; + } + + if (listenerToService != null) { + unregisterCallback(); } } } diff --git a/car-lib/src/android/car/hardware/radio/CarRadioManager.java b/car-lib/src/android/car/hardware/radio/CarRadioManager.java index efe4d3da4a..a590864ea2 100644 --- a/car-lib/src/android/car/hardware/radio/CarRadioManager.java +++ b/car-lib/src/android/car/hardware/radio/CarRadioManager.java @@ -151,7 +151,7 @@ public final class CarRadioManager implements CarManagerBase { /** * Unregister {@link CarRadioEventListener}. */ - public synchronized void unregisterListener() throws CarNotConnectedException { + public synchronized void unregisterListener() { if (DBG) { Log.d(TAG, "unregisterListener"); } @@ -159,7 +159,7 @@ public final class CarRadioManager implements CarManagerBase { mService.unregisterListener(mListenerToService); } catch (RemoteException ex) { Log.e(TAG, "Could not connect: " + ex.toString()); - throw new CarNotConnectedException(ex); + //ignore } mListenerToService = null; mListener = null; @@ -170,7 +170,7 @@ public final class CarRadioManager implements CarManagerBase { * * @return: A positive value if the call succeeded, -1 if it failed. */ - public int getPresetCount() { + public int getPresetCount() throws CarNotConnectedException { return mCount; } diff --git a/car-lib/src/android/car/media/CarAudioManager.java b/car-lib/src/android/car/media/CarAudioManager.java index 33bea8d84e..9e1a6b3f28 100644 --- a/car-lib/src/android/car/media/CarAudioManager.java +++ b/car-lib/src/android/car/media/CarAudioManager.java @@ -127,12 +127,12 @@ public final class CarAudioManager implements CarManagerBase { * @param carUsage * @return */ - public AudioAttributes getAudioAttributesForCarUsage(@CarAudioUsage int carUsage) { + public AudioAttributes getAudioAttributesForCarUsage(@CarAudioUsage int carUsage) + throws CarNotConnectedException { try { return mService.getAudioAttributesForCarUsage(carUsage); } catch (RemoteException e) { - return createAudioAttributes(AudioAttributes.CONTENT_TYPE_UNKNOWN, - AudioAttributes.USAGE_UNKNOWN); + throw new CarNotConnectedException(); } } @@ -148,12 +148,11 @@ public final class CarAudioManager implements CarManagerBase { * @hide */ public AudioAttributes getAudioAttributesForRadio(String radioType) - throws IllegalArgumentException { + throws CarNotConnectedException, IllegalArgumentException { try { return mService.getAudioAttributesForRadio(radioType); } catch (RemoteException e) { - return createAudioAttributes(AudioAttributes.CONTENT_TYPE_UNKNOWN, - AudioAttributes.USAGE_UNKNOWN); + throw new CarNotConnectedException(); } } @@ -168,12 +167,11 @@ public final class CarAudioManager implements CarManagerBase { * @hide */ public AudioAttributes getAudioAttributesForExternalSource(String externalSourceType) - throws IllegalArgumentException { + throws CarNotConnectedException, IllegalArgumentException { try { return mService.getAudioAttributesForExternalSource(externalSourceType); } catch (RemoteException e) { - return createAudioAttributes(AudioAttributes.CONTENT_TYPE_UNKNOWN, - AudioAttributes.USAGE_UNKNOWN); + throw new CarNotConnectedException(); } } @@ -184,11 +182,11 @@ public final class CarAudioManager implements CarManagerBase { * * @hide */ - public String[] getSupportedExternalSourceTypes() { + public String[] getSupportedExternalSourceTypes() throws CarNotConnectedException { try { return mService.getSupportedExternalSourceTypes(); } catch (RemoteException e) { - return null; + throw new CarNotConnectedException(); } } @@ -199,11 +197,11 @@ public final class CarAudioManager implements CarManagerBase { * * @hide */ - public String[] getSupportedRadioTypes() { + public String[] getSupportedRadioTypes() throws CarNotConnectedException { try { return mService.getSupportedRadioTypes(); } catch (RemoteException e) { - return null; + throw new CarNotConnectedException(); } } @@ -218,7 +216,8 @@ public final class CarAudioManager implements CarManagerBase { public int requestAudioFocus(OnAudioFocusChangeListener l, AudioAttributes requestAttributes, int durationHint, - int flags) throws IllegalArgumentException { + int flags) + throws CarNotConnectedException, IllegalArgumentException { return mAudioManager.requestAudioFocus(l, requestAttributes, durationHint, flags); } @@ -226,10 +225,9 @@ public final class CarAudioManager implements CarManagerBase { * Abandon audio focus. Causes the previous focus owner, if any, to receive focus. * @param l * @param aa - * @return {@link #AUDIOFOCUS_REQUEST_FAILED} or {@link #AUDIOFOCUS_REQUEST_GRANTED} */ - public int abandonAudioFocus(OnAudioFocusChangeListener l, AudioAttributes aa) { - return mAudioManager.abandonAudioFocus(l, aa); + public void abandonAudioFocus(OnAudioFocusChangeListener l, AudioAttributes aa) { + mAudioManager.abandonAudioFocus(l, aa); } /** diff --git a/car-support-lib/api/current.txt b/car-support-lib/api/current.txt index 821eefb6c7..929d28b3e0 100644 --- a/car-support-lib/api/current.txt +++ b/car-support-lib/api/current.txt @@ -32,13 +32,13 @@ package android.support.car { public abstract class CarAppFocusManager { ctor public CarAppFocusManager(); - method public abstract void abandonAppFocus(android.support.car.CarAppFocusManager.OnAppFocusOwnershipCallback, int) throws android.support.car.CarNotConnectedException; - method public abstract void abandonAppFocus(android.support.car.CarAppFocusManager.OnAppFocusOwnershipCallback) throws android.support.car.CarNotConnectedException; + method public abstract void abandonAppFocus(android.support.car.CarAppFocusManager.OnAppFocusOwnershipCallback, int); + method public abstract void abandonAppFocus(android.support.car.CarAppFocusManager.OnAppFocusOwnershipCallback); method public abstract void addFocusListener(android.support.car.CarAppFocusManager.OnAppFocusChangedListener, int) throws android.support.car.CarNotConnectedException; method public abstract boolean isOwningFocus(int, android.support.car.CarAppFocusManager.OnAppFocusOwnershipCallback) throws android.support.car.CarNotConnectedException; - method public abstract void removeFocusListener(android.support.car.CarAppFocusManager.OnAppFocusChangedListener, int) throws android.support.car.CarNotConnectedException; - method public abstract void removeFocusListener(android.support.car.CarAppFocusManager.OnAppFocusChangedListener) throws android.support.car.CarNotConnectedException; - method public abstract int requestAppFocus(int, android.support.car.CarAppFocusManager.OnAppFocusOwnershipCallback) throws android.support.car.CarNotConnectedException, java.lang.IllegalStateException, java.lang.SecurityException; + method public abstract void removeFocusListener(android.support.car.CarAppFocusManager.OnAppFocusChangedListener, int); + method public abstract void removeFocusListener(android.support.car.CarAppFocusManager.OnAppFocusChangedListener); + method public abstract int requestAppFocus(int, android.support.car.CarAppFocusManager.OnAppFocusOwnershipCallback) throws android.support.car.CarNotConnectedException, java.lang.SecurityException; field public static final int APP_FOCUS_REQUEST_FAILED = 0; // 0x0 field public static final int APP_FOCUS_REQUEST_SUCCEEDED = 1; // 0x1 field public static final int APP_FOCUS_TYPE_NAVIGATION = 1; // 0x1 @@ -189,8 +189,8 @@ package android.support.car.hardware { method public abstract android.support.car.hardware.CarSensorEvent getLatestSensorEvent(int) throws android.support.car.CarNotConnectedException; method public abstract int[] getSupportedSensors() throws android.support.car.CarNotConnectedException; method public abstract boolean isSensorSupported(int) throws android.support.car.CarNotConnectedException; - method public abstract void removeListener(android.support.car.hardware.CarSensorManager.OnSensorChangedListener) throws android.support.car.CarNotConnectedException; - method public abstract void removeListener(android.support.car.hardware.CarSensorManager.OnSensorChangedListener, int) throws android.support.car.CarNotConnectedException; + method public abstract void removeListener(android.support.car.hardware.CarSensorManager.OnSensorChangedListener); + method public abstract void removeListener(android.support.car.hardware.CarSensorManager.OnSensorChangedListener, int); field public static final int SENSOR_RATE_FASTEST = 0; // 0x0 field public static final int SENSOR_RATE_NORMAL = 3; // 0x3 field public static final int SENSOR_TYPE_COMPASS = 1; // 0x1 @@ -209,15 +209,15 @@ package android.support.car.media { public abstract class CarAudioManager { ctor public CarAudioManager(); - method public abstract int abandonAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes); + method public abstract void abandonAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes); method public abstract android.support.car.media.CarAudioRecord createCarAudioRecord(int) throws android.support.car.CarNotConnectedException, java.lang.SecurityException; - method public abstract android.media.AudioAttributes getAudioAttributesForCarUsage(int); - method public abstract android.media.AudioFormat getAudioRecordAudioFormat(); + method public abstract android.media.AudioAttributes getAudioAttributesForCarUsage(int) throws android.support.car.CarNotConnectedException; + method public abstract android.media.AudioFormat getAudioRecordAudioFormat() throws android.support.car.CarNotConnectedException; method public abstract int getAudioRecordMaxBufferSize() throws android.support.car.CarNotConnectedException; method public abstract int getAudioRecordMinBufferSize() throws android.support.car.CarNotConnectedException; - method public abstract boolean isAudioRecordSupported(); + method public abstract boolean isAudioRecordSupported() throws android.support.car.CarNotConnectedException; method public abstract boolean isMediaMuted() throws android.support.car.CarNotConnectedException; - method public abstract int requestAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes, int) throws java.lang.IllegalArgumentException; + method public abstract int requestAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes, int) throws android.support.car.CarNotConnectedException, java.lang.IllegalArgumentException; field public static final int CAR_AUDIO_USAGE_ALARM = 6; // 0x6 field public static final int CAR_AUDIO_USAGE_DEFAULT = 0; // 0x0 field public static final int CAR_AUDIO_USAGE_MUSIC = 1; // 0x1 @@ -231,10 +231,10 @@ package android.support.car.media { public abstract class CarAudioRecord { ctor public CarAudioRecord(); - method public abstract int getAudioSessionId(); - method public abstract int getBufferSize(); - method public abstract int getRecordingState(); - method public abstract int getState(); + method public abstract int getAudioSessionId() throws android.support.car.CarNotConnectedException; + method public abstract int getBufferSize() throws android.support.car.CarNotConnectedException; + method public abstract int getRecordingState() throws android.support.car.CarNotConnectedException; + method public abstract int getState() throws android.support.car.CarNotConnectedException; method public abstract int read(byte[], int, int) throws android.support.car.CarNotConnectedException, java.lang.IllegalStateException; method public abstract void release(); method public abstract void startRecording() throws android.support.car.CarNotConnectedException; diff --git a/car-support-lib/src/android/support/car/CarAppFocusManager.java b/car-support-lib/src/android/support/car/CarAppFocusManager.java index 71e9a713a9..7059ea4260 100644 --- a/car-support-lib/src/android/support/car/CarAppFocusManager.java +++ b/car-support-lib/src/android/support/car/CarAppFocusManager.java @@ -126,18 +126,15 @@ public abstract class CarAppFocusManager implements CarManagerBase { * Unregister listener for app type and stop listening to focus change events. * @param listener Listener to unregister from focus events. * @param appType Application type to get notification for. - * @throws CarNotConnectedException if the connection to the car service has been lost. */ public abstract void removeFocusListener(OnAppFocusChangedListener listener, - @AppFocusType int appType) throws CarNotConnectedException; + @AppFocusType int appType); /** * Unregister listener for all app types and stop listening to focus change events. * @param listener Listener to unregister from focus events. - * @throws CarNotConnectedException if the connection to the car service has been lost. */ - public abstract void removeFocusListener(OnAppFocusChangedListener listener) - throws CarNotConnectedException; + public abstract void removeFocusListener(OnAppFocusChangedListener listener); /** * Check if the current process owns the given focus. @@ -171,28 +168,24 @@ public abstract class CarAppFocusManager implements CarManagerBase { * @param ownershipCallback Ownership callback to request app focus for. Cannot be null. * * @return {@link #APP_FOCUS_REQUEST_FAILED} or {@link #APP_FOCUS_REQUEST_SUCCEEDED} - * @throws IllegalStateException if callback was not registered. * @throws SecurityException if owner cannot be changed. * @throws CarNotConnectedException if the connection to the car service has been lost. */ public abstract int requestAppFocus(int appType, OnAppFocusOwnershipCallback ownershipCallback) - throws IllegalStateException, SecurityException, CarNotConnectedException; + throws SecurityException, CarNotConnectedException; /** * Abandon the given focus (mark it as inactive). * @param ownershipCallback Ownership callback to abandon app focus for. Cannot be null. * @param appType Application type to abandon focus for. - * @throws CarNotConnectedException if the connection to the car service has been lost. */ public abstract void abandonAppFocus(OnAppFocusOwnershipCallback ownershipCallback, - @AppFocusType int appType) throws CarNotConnectedException; + @AppFocusType int appType); /** * Abandon all focuses (mark them as inactive). * @param ownershipCallback Ownership callback to abandon focus for. Cannot be null. - * @throws CarNotConnectedException if the connection to the car service has been lost. */ - public abstract void abandonAppFocus(OnAppFocusOwnershipCallback ownershipCallback) - throws CarNotConnectedException; + public abstract void abandonAppFocus(OnAppFocusOwnershipCallback ownershipCallback); } diff --git a/car-support-lib/src/android/support/car/CarAppFocusManagerEmbedded.java b/car-support-lib/src/android/support/car/CarAppFocusManagerEmbedded.java index 5508697cd2..e866f4b40a 100644 --- a/car-support-lib/src/android/support/car/CarAppFocusManagerEmbedded.java +++ b/car-support-lib/src/android/support/car/CarAppFocusManagerEmbedded.java @@ -61,8 +61,7 @@ public class CarAppFocusManagerEmbedded extends CarAppFocusManager { } @Override - public void removeFocusListener(OnAppFocusChangedListener listener, int appType) - throws CarNotConnectedException { + public void removeFocusListener(OnAppFocusChangedListener listener, int appType) { OnAppFocusChangedListenerProxy proxy; synchronized (this) { proxy = mChangeListeners.get(listener); @@ -70,16 +69,11 @@ public class CarAppFocusManagerEmbedded extends CarAppFocusManager { return; } } - try { - mManager.removeFocusListener(proxy, appType); - } catch (android.car.CarNotConnectedException e) { - throw new CarNotConnectedException(e); - } + mManager.removeFocusListener(proxy, appType); } @Override - public void removeFocusListener(OnAppFocusChangedListener listener) - throws CarNotConnectedException { + public void removeFocusListener(OnAppFocusChangedListener listener) { OnAppFocusChangedListenerProxy proxy; synchronized (this) { proxy = mChangeListeners.remove(listener); @@ -87,11 +81,7 @@ public class CarAppFocusManagerEmbedded extends CarAppFocusManager { return; } } - try { - mManager.removeFocusListener(proxy); - } catch (android.car.CarNotConnectedException e) { - throw new CarNotConnectedException(e); - } + mManager.removeFocusListener(proxy); } @Override @@ -133,8 +123,7 @@ public class CarAppFocusManagerEmbedded extends CarAppFocusManager { } @Override - public void abandonAppFocus(OnAppFocusOwnershipCallback ownershipCallback, int appType) - throws CarNotConnectedException { + public void abandonAppFocus(OnAppFocusOwnershipCallback ownershipCallback, int appType) { if (ownershipCallback == null) { throw new IllegalArgumentException("null listener"); } @@ -145,16 +134,11 @@ public class CarAppFocusManagerEmbedded extends CarAppFocusManager { return; } } - try { - mManager.abandonAppFocus(proxy, appType); - } catch (android.car.CarNotConnectedException e) { - throw new CarNotConnectedException(e); - } + mManager.abandonAppFocus(proxy, appType); } @Override - public void abandonAppFocus(OnAppFocusOwnershipCallback ownershipCallback) - throws CarNotConnectedException { + public void abandonAppFocus(OnAppFocusOwnershipCallback ownershipCallback) { if (ownershipCallback == null) { throw new IllegalArgumentException("null listener"); } @@ -165,11 +149,7 @@ public class CarAppFocusManagerEmbedded extends CarAppFocusManager { return; } } - try { - mManager.abandonAppFocus(proxy); - } catch (android.car.CarNotConnectedException e) { - throw new CarNotConnectedException(e); - } + mManager.abandonAppFocus(proxy); } @Override diff --git a/car-support-lib/src/android/support/car/hardware/CarSensorManager.java b/car-support-lib/src/android/support/car/hardware/CarSensorManager.java index cecabbd983..09586bda5b 100644 --- a/car-support-lib/src/android/support/car/hardware/CarSensorManager.java +++ b/car-support-lib/src/android/support/car/hardware/CarSensorManager.java @@ -17,11 +17,15 @@ package android.support.car.hardware; import android.Manifest; +import android.support.annotation.IntDef; import android.support.annotation.RequiresPermission; import android.support.car.Car; import android.support.car.CarManagerBase; import android.support.car.CarNotConnectedException; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + /** * Enables applications to monitor car sensor data. Applications register listeners to this * manager to subscribe to individual sensor streams using the SENSOR_TYPE_* constants as the @@ -134,6 +138,26 @@ public abstract class CarSensorManager implements CarManagerBase { /** @hide */ public static final int SENSOR_TYPE_VENDOR_EXTENSION_END = 0x6fffffff; + /** @hide */ + @IntDef({ + SENSOR_TYPE_COMPASS, + SENSOR_TYPE_CAR_SPEED, + SENSOR_TYPE_RPM, + SENSOR_TYPE_ODOMETER, + SENSOR_TYPE_FUEL_LEVEL, + SENSOR_TYPE_PARKING_BRAKE, + SENSOR_TYPE_GEAR, + SENSOR_TYPE_NIGHT, + SENSOR_TYPE_LOCATION, + SENSOR_TYPE_DRIVING_STATUS, + SENSOR_TYPE_ENVIRONMENT, + SENSOR_TYPE_ACCELEROMETER, + SENSOR_TYPE_GPS_SATELLITE, + SENSOR_TYPE_GYROSCOPE + }) + @Retention(RetentionPolicy.SOURCE) + public @interface SensorType {} + /** Read sensor at the default normal rate set for each sensors. This is default rate. */ public static final int SENSOR_RATE_NORMAL = 3; /**@hide*/ @@ -143,6 +167,16 @@ public abstract class CarSensorManager implements CarManagerBase { /** Read sensor at the maximum rate. Actual rate will be different depending on the sensor. */ public static final int SENSOR_RATE_FASTEST = 0; + /** @hide */ + @IntDef({ + SENSOR_RATE_NORMAL, + SENSOR_RATE_UI, + SENSOR_RATE_FAST, + SENSOR_RATE_FASTEST + }) + @Retention(RetentionPolicy.SOURCE) + public @interface SensorRate {} + /** * Listener for car sensor data change. * Callbacks are called in the Looper context. @@ -170,7 +204,8 @@ public abstract class CarSensorManager implements CarManagerBase { * @return Returns {@code true} if the sensor is supported. * @throws CarNotConnectedException if the connection to the car service has been lost. */ - public abstract boolean isSensorSupported(int sensorType) throws CarNotConnectedException; + public abstract boolean isSensorSupported(@SensorType int sensorType) + throws CarNotConnectedException; /** * Register {@link OnSensorChangedListener} to get repeated sensor updates. Can register @@ -199,16 +234,16 @@ public abstract class CarSensorManager implements CarManagerBase { */ @RequiresPermission(anyOf={Manifest.permission.ACCESS_FINE_LOCATION, Car.PERMISSION_SPEED, Car.PERMISSION_MILEAGE, Car.PERMISSION_FUEL}, conditional=true) - public abstract boolean addListener(OnSensorChangedListener listener, int sensorType, - int rate) throws CarNotConnectedException, IllegalArgumentException; + public abstract boolean addListener(OnSensorChangedListener listener, + @SensorType int sensorType, @SensorRate int rate) + throws CarNotConnectedException, IllegalArgumentException; /** * Stop getting sensor updates for the given listener. If there are multiple registrations for * this listener, all listening is stopped. * @param listener The listener to remove. */ - public abstract void removeListener(OnSensorChangedListener listener) - throws CarNotConnectedException; + public abstract void removeListener(OnSensorChangedListener listener); /** * Stop getting sensor updates for the given listener and sensor. If the same listener is used @@ -216,8 +251,8 @@ public abstract class CarSensorManager implements CarManagerBase { * @param listener The listener to remove. * @param sensorType The type to stop receiving notifications for. */ - public abstract void removeListener(OnSensorChangedListener listener, int sensorType) - throws CarNotConnectedException; + public abstract void removeListener(OnSensorChangedListener listener, + @SensorType int sensorType); /** * Get the most recent CarSensorEvent for the given type. @@ -225,5 +260,6 @@ public abstract class CarSensorManager implements CarManagerBase { * @return null if no sensor update since connection to the car. * @throws CarNotConnectedException if the connection to the car service has been lost. */ - public abstract CarSensorEvent getLatestSensorEvent(int type) throws CarNotConnectedException; + public abstract CarSensorEvent getLatestSensorEvent(@SensorType int type) + throws CarNotConnectedException; } diff --git a/car-support-lib/src/android/support/car/hardware/CarSensorManagerEmbedded.java b/car-support-lib/src/android/support/car/hardware/CarSensorManagerEmbedded.java index 0be9ab2ab0..2692267b09 100644 --- a/car-support-lib/src/android/support/car/hardware/CarSensorManagerEmbedded.java +++ b/car-support-lib/src/android/support/car/hardware/CarSensorManagerEmbedded.java @@ -112,8 +112,7 @@ public class CarSensorManagerEmbedded extends CarSensorManager { } @Override - public void removeListener(OnSensorChangedListener listener) - throws CarNotConnectedException { + public void removeListener(OnSensorChangedListener listener) { mCarSensorsProxy.unregisterSensorListener(listener); OnSensorChangedListenerProxy proxy = null; synchronized (this) { @@ -123,16 +122,11 @@ public class CarSensorManagerEmbedded extends CarSensorManager { } mListeners.remove(proxy); } - try { - mManager.unregisterListener(proxy); - } catch (android.car.CarNotConnectedException e) { - throw new CarNotConnectedException(e); - } + mManager.unregisterListener(proxy); } @Override - public void removeListener(OnSensorChangedListener listener, int sensorType) - throws CarNotConnectedException { + public void removeListener(OnSensorChangedListener listener, int sensorType) { mCarSensorsProxy.unregisterSensorListener(listener, sensorType); OnSensorChangedListenerProxy proxy = null; synchronized (this) { @@ -145,11 +139,7 @@ public class CarSensorManagerEmbedded extends CarSensorManager { mListeners.remove(proxy); } } - try { - mManager.unregisterListener(proxy, sensorType); - } catch (android.car.CarNotConnectedException e) { - throw new CarNotConnectedException(e); - } + mManager.unregisterListener(proxy, sensorType); } @Override diff --git a/car-support-lib/src/android/support/car/media/CarAudioManager.java b/car-support-lib/src/android/support/car/media/CarAudioManager.java index a9df19de24..52173d4056 100644 --- a/car-support-lib/src/android/support/car/media/CarAudioManager.java +++ b/car-support-lib/src/android/support/car/media/CarAudioManager.java @@ -92,7 +92,8 @@ public abstract class CarAudioManager implements CarManagerBase { /** * Return {@link AudioAttributes} relevant for the given usage in car. */ - public abstract AudioAttributes getAudioAttributesForCarUsage(@CarAudioUsage int carUsage); + public abstract AudioAttributes getAudioAttributesForCarUsage(@CarAudioUsage int carUsage) + throws CarNotConnectedException; /** * Request audio focus. Send a request to obtain audio focus. @@ -118,7 +119,7 @@ public abstract class CarAudioManager implements CarManagerBase { */ public abstract int requestAudioFocus(OnAudioFocusChangeListener listener, AudioAttributes requestAttributes, - int durationHint) throws IllegalArgumentException; + int durationHint) throws CarNotConnectedException, IllegalArgumentException; /** * See @@ -128,24 +129,21 @@ public abstract class CarAudioManager implements CarManagerBase { public abstract int requestAudioFocus(OnAudioFocusChangeListener listener, AudioAttributes requestAttributes, int durationHint, - int flags) throws IllegalArgumentException; + int flags) throws CarNotConnectedException, IllegalArgumentException; /** * Abandon audio focus. Causes the previous focus owner (if any) to receive focus. * @param listener The listener with which focus was requested. * @param aa - * @return - * {@link AudioManager#AUDIOFOCUS_REQUEST_FAILED} or - * {@link AudioManager#AUDIOFOCUS_REQUEST_GRANTED} */ - public abstract int abandonAudioFocus(OnAudioFocusChangeListener listener, AudioAttributes aa); + public abstract void abandonAudioFocus(OnAudioFocusChangeListener listener, AudioAttributes aa); /** * Get {@link AudioFormat} for audio record. * @return {@link AudioFormat} for audio record. */ - public abstract AudioFormat getAudioRecordAudioFormat(); + public abstract AudioFormat getAudioRecordAudioFormat() throws CarNotConnectedException; - public abstract boolean isAudioRecordSupported(); + public abstract boolean isAudioRecordSupported() throws CarNotConnectedException; /** * Get minimum buffer size for {@link CarAudioRecord}. diff --git a/car-support-lib/src/android/support/car/media/CarAudioManagerEmbedded.java b/car-support-lib/src/android/support/car/media/CarAudioManagerEmbedded.java index 1781ecd521..2d172cd85b 100644 --- a/car-support-lib/src/android/support/car/media/CarAudioManagerEmbedded.java +++ b/car-support-lib/src/android/support/car/media/CarAudioManagerEmbedded.java @@ -45,54 +45,69 @@ public class CarAudioManagerEmbedded extends CarAudioManager { } @Override - public AudioAttributes getAudioAttributesForCarUsage(@CarAudioUsage int carUsage) { - return mManager.getAudioAttributesForCarUsage(carUsage); + public AudioAttributes getAudioAttributesForCarUsage(@CarAudioUsage int carUsage) + throws CarNotConnectedException { + try { + return mManager.getAudioAttributesForCarUsage(carUsage); + } catch (android.car.CarNotConnectedException e) { + throw new CarNotConnectedException(e); + } } @Override public int requestAudioFocus(OnAudioFocusChangeListener listener, AudioAttributes requestAttributes, int durationHint, - int flags) throws IllegalArgumentException { - return mManager.requestAudioFocus(listener, requestAttributes, durationHint, flags); + int flags) throws CarNotConnectedException, IllegalArgumentException { + try { + return mManager.requestAudioFocus(listener, requestAttributes, durationHint, flags); + } catch (android.car.CarNotConnectedException e) { + throw new CarNotConnectedException(e); + } } @Override public int requestAudioFocus(OnAudioFocusChangeListener listener, AudioAttributes requestAttributes, - int durationHint) throws IllegalArgumentException { - return mManager.requestAudioFocus(listener, requestAttributes, durationHint, 0 /*flags*/); + int durationHint) throws CarNotConnectedException, IllegalArgumentException { + try { + return mManager.requestAudioFocus(listener, requestAttributes, durationHint, + 0 /*flags*/); + } catch (android.car.CarNotConnectedException e) { + throw new CarNotConnectedException(e); + } } @Override - public int abandonAudioFocus(OnAudioFocusChangeListener listener, AudioAttributes aa) { - return mManager.abandonAudioFocus(listener, aa); + public void abandonAudioFocus(OnAudioFocusChangeListener listener, AudioAttributes aa) { + mManager.abandonAudioFocus(listener, aa); } @Override - public boolean isAudioRecordSupported(){ + public boolean isAudioRecordSupported() throws CarNotConnectedException { //always true in embedded return true; } @Override - public AudioFormat getAudioRecordAudioFormat() { + public AudioFormat getAudioRecordAudioFormat() throws CarNotConnectedException { return AUDIO_RECORD_FORMAT; } @Override - public int getAudioRecordMinBufferSize() { + public int getAudioRecordMinBufferSize() throws CarNotConnectedException { return AudioRecord.getMinBufferSize(SAMPLING_RATE, AUDIO_RECORD_FORMAT.getChannelMask(), AUDIO_RECORD_FORMAT.getEncoding()); } @Override - public int getAudioRecordMaxBufferSize() { + public int getAudioRecordMaxBufferSize() throws CarNotConnectedException { return Math.max(getAudioRecordMinBufferSize(), MAX_BUFFER_SIZE_BYTE); } @Override - public CarAudioRecord createCarAudioRecord(int bufferSize) throws SecurityException { + public CarAudioRecord createCarAudioRecord(int bufferSize) + throws CarNotConnectedException, SecurityException { if (bufferSize < getAudioRecordMinBufferSize() || bufferSize > getAudioRecordMaxBufferSize()) { throw new IllegalArgumentException("Bad bufferSize value"); diff --git a/car-support-lib/src/android/support/car/media/CarAudioRecord.java b/car-support-lib/src/android/support/car/media/CarAudioRecord.java index a87fbb1a3d..c3f09ca1b6 100644 --- a/car-support-lib/src/android/support/car/media/CarAudioRecord.java +++ b/car-support-lib/src/android/support/car/media/CarAudioRecord.java @@ -26,7 +26,7 @@ public abstract class CarAudioRecord { * Get the buffer size specified in {@link CarAudioManager#createCarAudioRecord(int)}. * @return Buffer size in bytes. */ - public abstract int getBufferSize(); + public abstract int getBufferSize() throws CarNotConnectedException; /** * Start audio recording. @@ -45,13 +45,13 @@ public abstract class CarAudioRecord { public abstract void release(); /** See {@link AudioRecord#getRecordingState() }. */ - public abstract int getRecordingState(); + public abstract int getRecordingState() throws CarNotConnectedException; /** See {@link AudioRecord#getState() }. */ - public abstract int getState(); + public abstract int getState() throws CarNotConnectedException; /** See {@link AudioRecord#getAudioSessionId() }. */ - public abstract int getAudioSessionId(); + public abstract int getAudioSessionId() throws CarNotConnectedException; /** * Read recorded audio. Be sure to start audio recording with {@link #startRecording()} diff --git a/car-support-lib/src/android/support/car/media/CarAudioRecordEmbedded.java b/car-support-lib/src/android/support/car/media/CarAudioRecordEmbedded.java index 85973b245f..a85bb8fb7b 100644 --- a/car-support-lib/src/android/support/car/media/CarAudioRecordEmbedded.java +++ b/car-support-lib/src/android/support/car/media/CarAudioRecordEmbedded.java @@ -18,6 +18,7 @@ package android.support.car.media; import android.media.AudioFormat; import android.media.AudioRecord; import android.support.annotation.RestrictTo; +import android.support.car.CarNotConnectedException; import static android.support.annotation.RestrictTo.Scope.GROUP_ID; @@ -43,12 +44,12 @@ public class CarAudioRecordEmbedded extends CarAudioRecord { } @Override - public int getBufferSize() { + public int getBufferSize() throws CarNotConnectedException { return mBufferSize; } @Override - public void startRecording() { + public void startRecording() throws CarNotConnectedException { mAudioRecord.startRecording(); } @@ -63,23 +64,23 @@ public class CarAudioRecordEmbedded extends CarAudioRecord { } @Override - public int getRecordingState() { + public int getRecordingState() throws CarNotConnectedException { return mAudioRecord.getRecordingState(); } @Override - public int getState() { + public int getState() throws CarNotConnectedException { return mAudioRecord.getState(); } @Override - public int getAudioSessionId() { + public int getAudioSessionId() throws CarNotConnectedException { return mAudioRecord.getAudioSessionId(); } @Override public int read(byte[] audioData, int offsetInBytes, int sizeInBytes) - throws IllegalStateException { + throws CarNotConnectedException, IllegalStateException { return mAudioRecord.read(audioData, offsetInBytes, sizeInBytes); } } diff --git a/libvehiclenetwork/java/src/com/android/car/vehiclenetwork/VehicleNetworkConsts.java b/libvehiclenetwork/java/src/com/android/car/vehiclenetwork/VehicleNetworkConsts.java index 9dcb2102d0..b0cd19bdbd 100644 --- a/libvehiclenetwork/java/src/com/android/car/vehiclenetwork/VehicleNetworkConsts.java +++ b/libvehiclenetwork/java/src/com/android/car/vehiclenetwork/VehicleNetworkConsts.java @@ -1126,30 +1126,26 @@ default: return "UNKNOWN"; } public static class VehicleSeat { -public static final int VEHICLE_SEAT_DRIVER_LHD = 0x0001; -public static final int VEHICLE_SEAT_DRIVER_RHD = 0x0002; -public static final int VEHICLE_SEAT_ROW_1_PASSENGER_LEFT = 0x0010; -public static final int VEHICLE_SEAT_ROW_1_PASSENGER_CENTER = 0x0020; -public static final int VEHICLE_SEAT_ROW_1_PASSENGER_RIGHT = 0x0040; -public static final int VEHICLE_SEAT_ROW_2_PASSENGER_LEFT = 0x0100; -public static final int VEHICLE_SEAT_ROW_2_PASSENGER_CENTER = 0x0200; -public static final int VEHICLE_SEAT_ROW_2_PASSENGER_RIGHT = 0x0400; -public static final int VEHICLE_SEAT_ROW_3_PASSENGER_LEFT = 0x1000; -public static final int VEHICLE_SEAT_ROW_3_PASSENGER_CENTER = 0x2000; -public static final int VEHICLE_SEAT_ROW_3_PASSENGER_RIGHT = 0x4000; +public static final int VEHICLE_SEAT_ROW_1_LEFT = 0x0001; +public static final int VEHICLE_SEAT_ROW_1_CENTER = 0x0002; +public static final int VEHICLE_SEAT_ROW_1_RIGHT = 0x0004; +public static final int VEHICLE_SEAT_ROW_2_LEFT = 0x0010; +public static final int VEHICLE_SEAT_ROW_2_CENTER = 0x0020; +public static final int VEHICLE_SEAT_ROW_2_RIGHT = 0x0040; +public static final int VEHICLE_SEAT_ROW_3_LEFT = 0x0100; +public static final int VEHICLE_SEAT_ROW_3_CENTER = 0x0200; +public static final int VEHICLE_SEAT_ROW_3_RIGHT = 0x0400; public static String enumToString(int v) { switch(v) { -case VEHICLE_SEAT_DRIVER_LHD: return "VEHICLE_SEAT_DRIVER_LHD"; -case VEHICLE_SEAT_DRIVER_RHD: return "VEHICLE_SEAT_DRIVER_RHD"; -case VEHICLE_SEAT_ROW_1_PASSENGER_LEFT: return "VEHICLE_SEAT_ROW_1_PASSENGER_LEFT"; -case VEHICLE_SEAT_ROW_1_PASSENGER_CENTER: return "VEHICLE_SEAT_ROW_1_PASSENGER_CENTER"; -case VEHICLE_SEAT_ROW_1_PASSENGER_RIGHT: return "VEHICLE_SEAT_ROW_1_PASSENGER_RIGHT"; -case VEHICLE_SEAT_ROW_2_PASSENGER_LEFT: return "VEHICLE_SEAT_ROW_2_PASSENGER_LEFT"; -case VEHICLE_SEAT_ROW_2_PASSENGER_CENTER: return "VEHICLE_SEAT_ROW_2_PASSENGER_CENTER"; -case VEHICLE_SEAT_ROW_2_PASSENGER_RIGHT: return "VEHICLE_SEAT_ROW_2_PASSENGER_RIGHT"; -case VEHICLE_SEAT_ROW_3_PASSENGER_LEFT: return "VEHICLE_SEAT_ROW_3_PASSENGER_LEFT"; -case VEHICLE_SEAT_ROW_3_PASSENGER_CENTER: return "VEHICLE_SEAT_ROW_3_PASSENGER_CENTER"; -case VEHICLE_SEAT_ROW_3_PASSENGER_RIGHT: return "VEHICLE_SEAT_ROW_3_PASSENGER_RIGHT"; +case VEHICLE_SEAT_ROW_1_LEFT: return "VEHICLE_SEAT_ROW_1_LEFT"; +case VEHICLE_SEAT_ROW_1_CENTER: return "VEHICLE_SEAT_ROW_1_CENTER"; +case VEHICLE_SEAT_ROW_1_RIGHT: return "VEHICLE_SEAT_ROW_1_RIGHT"; +case VEHICLE_SEAT_ROW_2_LEFT: return "VEHICLE_SEAT_ROW_2_LEFT"; +case VEHICLE_SEAT_ROW_2_CENTER: return "VEHICLE_SEAT_ROW_2_CENTER"; +case VEHICLE_SEAT_ROW_2_RIGHT: return "VEHICLE_SEAT_ROW_2_RIGHT"; +case VEHICLE_SEAT_ROW_3_LEFT: return "VEHICLE_SEAT_ROW_3_LEFT"; +case VEHICLE_SEAT_ROW_3_CENTER: return "VEHICLE_SEAT_ROW_3_CENTER"; +case VEHICLE_SEAT_ROW_3_RIGHT: return "VEHICLE_SEAT_ROW_3_RIGHT"; default: return "UNKNOWN"; } } diff --git a/service/src/com/android/car/SystemActivityMonitoringService.java b/service/src/com/android/car/SystemActivityMonitoringService.java index aa888305c4..24d2756bb3 100644 --- a/service/src/com/android/car/SystemActivityMonitoringService.java +++ b/service/src/com/android/car/SystemActivityMonitoringService.java @@ -30,6 +30,7 @@ import android.os.Looper; import android.os.Message; import android.os.RemoteException; import android.os.UserHandle; +import android.util.ArrayMap; import android.util.ArraySet; import android.util.Log; import android.util.Pair; @@ -37,10 +38,10 @@ import android.util.SparseArray; import java.io.PrintWriter; import java.util.Arrays; -import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; /** @@ -62,10 +63,11 @@ public class SystemActivityMonitoringService implements CarServiceBase { this.stackInfo = stackInfo; } - public boolean isMatching(ComponentName topActivity, int taskId, StackInfo stackInfo) { - return this.topActivity.equals(topActivity) && this.taskId == taskId && - this.stackInfo.stackId == stackInfo.stackId && - this.stackInfo.userId == stackInfo.userId; + public boolean isMatching(TopTaskInfoContainer taskInfo) { + return taskInfo != null + && Objects.equals(this.topActivity, taskInfo.topActivity) + && this.taskId == taskInfo.taskId + && this.stackInfo.userId == taskInfo.stackInfo.userId; } @Override @@ -99,7 +101,7 @@ public class SystemActivityMonitoringService implements CarServiceBase { /** K: stack id, V: top task */ private final SparseArray<TopTaskInfoContainer> mTopTasks = new SparseArray<>(); /** K: uid, V : list of pid */ - private final Map<Integer, Set<Integer>> mForegroundUidPids = new HashMap<>(); + private final Map<Integer, Set<Integer>> mForegroundUidPids = new ArrayMap<>(); private int mFocusedStackId = -1; /** @@ -222,22 +224,18 @@ public class SystemActivityMonitoringService implements CarServiceBase { mTopTasks.remove(stackId); continue; } - // Assume last activity as top activity. StackInfo.topAcvitiy does not represent - // visible Activity correctly. Things will break if this assumption does not work. - int topActivityTaskId = info.taskIds[info.taskIds.length -1]; - String topActivityName = info.taskNames[info.taskNames.length -1]; - ComponentName topActivity = ComponentName.unflattenFromString(topActivityName); + TopTaskInfoContainer newTopTaskInfo = new TopTaskInfoContainer( + info.topActivity, info.taskIds[info.taskIds.length - 1], info); TopTaskInfoContainer currentTopTaskInfo = mTopTasks.get(stackId); + // if a new task is added to stack or focused stack changes, should notify if (currentTopTaskInfo == null || - !currentTopTaskInfo.isMatching(topActivity, topActivityTaskId, info) || + !currentTopTaskInfo.isMatching(newTopTaskInfo) || (focusedStackId == stackId && focusedStackId != mFocusedStackId)) { - currentTopTaskInfo = new TopTaskInfoContainer(topActivity, - topActivityTaskId, info); - mTopTasks.put(stackId, currentTopTaskInfo); - mTasksToDispatch.add(currentTopTaskInfo); + mTopTasks.put(stackId, newTopTaskInfo); + mTasksToDispatch.add(newTopTaskInfo); if (DBG) { - Log.i(CarLog.TAG_AM, "top activity:" + topActivityName + " stack:" + info); + Log.i(CarLog.TAG_AM, "New top task: " + newTopTaskInfo); } } } diff --git a/service/src/com/android/car/hal/CabinHalService.java b/service/src/com/android/car/hal/CabinHalService.java index e6b07d1b5a..213f458b33 100644 --- a/service/src/com/android/car/hal/CabinHalService.java +++ b/service/src/com/android/car/hal/CabinHalService.java @@ -15,7 +15,7 @@ */ package com.android.car.hal; -import android.car.hardware.cabin.CarCabinManager.CabinPropertyId; +import android.car.hardware.cabin.CarCabinManager; import com.android.car.vehiclenetwork.VehicleNetworkConsts; @@ -24,127 +24,127 @@ public class CabinHalService extends PropertyHalServiceBase { private static final String TAG = "CAR.CABIN.HAL"; private final ManagerToHalPropIdMap mMgrHalPropIdMap = ManagerToHalPropIdMap.create(new int[] { - CabinPropertyId.DOOR_POS, + CarCabinManager.ID_DOOR_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_DOOR_POS, - CabinPropertyId.DOOR_MOVE, + CarCabinManager.ID_DOOR_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_DOOR_MOVE, - CabinPropertyId.DOOR_LOCK, + CarCabinManager.ID_DOOR_LOCK, VehicleNetworkConsts.VEHICLE_PROPERTY_DOOR_LOCK, - CabinPropertyId.MIRROR_Z_POS, + CarCabinManager.ID_MIRROR_Z_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_MIRROR_Z_POS, - CabinPropertyId.MIRROR_Z_MOVE, + CarCabinManager.ID_MIRROR_Z_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_MIRROR_Z_MOVE, - CabinPropertyId.MIRROR_Y_POS, + CarCabinManager.ID_MIRROR_Y_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_MIRROR_Y_POS, - CabinPropertyId.MIRROR_Y_MOVE, + CarCabinManager.ID_MIRROR_Y_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_MIRROR_Y_MOVE, - CabinPropertyId.MIRROR_LOCK, + CarCabinManager.ID_MIRROR_LOCK, VehicleNetworkConsts.VEHICLE_PROPERTY_MIRROR_LOCK, - CabinPropertyId.MIRROR_FOLD, + CarCabinManager.ID_MIRROR_FOLD, VehicleNetworkConsts.VEHICLE_PROPERTY_MIRROR_FOLD, - CabinPropertyId.SEAT_MEMORY_SELECT, + CarCabinManager.ID_SEAT_MEMORY_SELECT, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_MEMORY_SELECT, - CabinPropertyId.SEAT_MEMORY_SET, + CarCabinManager.ID_SEAT_MEMORY_SET, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_MEMORY_SET, - CabinPropertyId.SEAT_BELT_BUCKLED, + CarCabinManager.ID_SEAT_BELT_BUCKLED, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_BELT_BUCKLED, - CabinPropertyId.SEAT_BELT_HEIGHT_POS, + CarCabinManager.ID_SEAT_BELT_HEIGHT_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_BELT_HEIGHT_POS, - CabinPropertyId.SEAT_BELT_HEIGHT_MOVE, + CarCabinManager.ID_SEAT_BELT_HEIGHT_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_BELT_HEIGHT_MOVE, - CabinPropertyId.SEAT_FORE_AFT_POS, + CarCabinManager.ID_SEAT_FORE_AFT_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_FORE_AFT_POS, - CabinPropertyId.SEAT_FORE_AFT_MOVE, + CarCabinManager.ID_SEAT_FORE_AFT_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_FORE_AFT_MOVE, - CabinPropertyId.SEAT_BACKREST_ANGLE_1_POS, + CarCabinManager.ID_SEAT_BACKREST_ANGLE_1_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_BACKREST_ANGLE_1_POS, - CabinPropertyId.SEAT_BACKREST_ANGLE_1_MOVE, + CarCabinManager.ID_SEAT_BACKREST_ANGLE_1_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_BACKREST_ANGLE_1_MOVE, - CabinPropertyId.SEAT_BACKREST_ANGLE_2_POS, + CarCabinManager.ID_SEAT_BACKREST_ANGLE_2_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_BACKREST_ANGLE_2_POS, - CabinPropertyId.SEAT_BACKREST_ANGLE_2_MOVE, + CarCabinManager.ID_SEAT_BACKREST_ANGLE_2_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_BACKREST_ANGLE_2_MOVE, - CabinPropertyId.SEAT_HEIGHT_POS, + CarCabinManager.ID_SEAT_HEIGHT_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_HEIGHT_POS, - CabinPropertyId.SEAT_HEIGHT_MOVE, + CarCabinManager.ID_SEAT_HEIGHT_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_HEIGHT_MOVE, - CabinPropertyId.SEAT_DEPTH_POS, + CarCabinManager.ID_SEAT_DEPTH_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_DEPTH_POS, - CabinPropertyId.SEAT_DEPTH_MOVE, + CarCabinManager.ID_SEAT_DEPTH_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_DEPTH_MOVE, - CabinPropertyId.SEAT_TILT_POS, + CarCabinManager.ID_SEAT_TILT_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_TILT_POS, - CabinPropertyId.SEAT_TILT_MOVE, + CarCabinManager.ID_SEAT_TILT_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_TILT_MOVE, - CabinPropertyId.SEAT_LUMBAR_FORE_AFT_POS, + CarCabinManager.ID_SEAT_LUMBAR_FORE_AFT_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_LUMBAR_FORE_AFT_POS, - CabinPropertyId.SEAT_LUMBAR_FORE_AFT_MOVE, + CarCabinManager.ID_SEAT_LUMBAR_FORE_AFT_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_LUMBAR_FORE_AFT_MOVE, - CabinPropertyId.SEAT_LUMBAR_SIDE_SUPPORT_POS, + CarCabinManager.ID_SEAT_LUMBAR_SIDE_SUPPORT_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_LUMBAR_SIDE_SUPPORT_POS, - CabinPropertyId.SEAT_LUMBAR_SIDE_SUPPORT_MOVE, + CarCabinManager.ID_SEAT_LUMBAR_SIDE_SUPPORT_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_LUMBAR_SIDE_SUPPORT_MOVE, - CabinPropertyId.SEAT_HEADREST_HEIGHT_POS, + CarCabinManager.ID_SEAT_HEADREST_HEIGHT_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_HEADREST_HEIGHT_POS, - CabinPropertyId.SEAT_HEADREST_HEIGHT_MOVE, + CarCabinManager.ID_SEAT_HEADREST_HEIGHT_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_HEADREST_HEIGHT_MOVE, - CabinPropertyId.SEAT_HEADREST_ANGLE_POS, + CarCabinManager.ID_SEAT_HEADREST_ANGLE_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_HEADREST_ANGLE_POS, - CabinPropertyId.SEAT_HEADREST_ANGLE_MOVE, + CarCabinManager.ID_SEAT_HEADREST_ANGLE_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_HEADREST_ANGLE_MOVE, - CabinPropertyId.SEAT_HEADREST_FORE_AFT_POS, + CarCabinManager.ID_SEAT_HEADREST_FORE_AFT_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_HEADREST_FORE_AFT_POS, - CabinPropertyId.SEAT_HEADREST_FORE_AFT_MOVE, + CarCabinManager.ID_SEAT_HEADREST_FORE_AFT_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_SEAT_HEADREST_FORE_AFT_MOVE, - CabinPropertyId.WINDOW_POS, + CarCabinManager.ID_WINDOW_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_WINDOW_POS, - CabinPropertyId.WINDOW_MOVE, + CarCabinManager.ID_WINDOW_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_WINDOW_MOVE, - CabinPropertyId.WINDOW_VENT_POS, + CarCabinManager.ID_WINDOW_VENT_POS, VehicleNetworkConsts.VEHICLE_PROPERTY_WINDOW_VENT_POS, - CabinPropertyId.WINDOW_VENT_MOVE, + CarCabinManager.ID_WINDOW_VENT_MOVE, VehicleNetworkConsts.VEHICLE_PROPERTY_WINDOW_VENT_MOVE, - CabinPropertyId.WINDOW_LOCK, + CarCabinManager.ID_WINDOW_LOCK, VehicleNetworkConsts.VEHICLE_PROPERTY_WINDOW_LOCK }); diff --git a/service/src/com/android/car/hal/HvacHalService.java b/service/src/com/android/car/hal/HvacHalService.java index c6a565528e..b6996bf0c7 100644 --- a/service/src/com/android/car/hal/HvacHalService.java +++ b/service/src/com/android/car/hal/HvacHalService.java @@ -15,7 +15,7 @@ */ package com.android.car.hal; -import android.car.hardware.hvac.CarHvacManager.HvacPropertyId; +import android.car.hardware.hvac.CarHvacManager; import com.android.car.vehiclenetwork.VehicleNetworkConsts; @@ -24,61 +24,61 @@ public class HvacHalService extends PropertyHalServiceBase { private static final String TAG = "HvacHalService"; private final ManagerToHalPropIdMap mMgrHalPropIdMap = ManagerToHalPropIdMap.create(new int[] { - HvacPropertyId.MIRROR_DEFROSTER_ON, + CarHvacManager.ID_MIRROR_DEFROSTER_ON, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_SIDE_MIRROR_HEAT, - HvacPropertyId.STEERING_WHEEL_TEMP, + CarHvacManager.ID_STEERING_WHEEL_TEMP, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_STEERING_WHEEL_TEMP, - HvacPropertyId.OUTSIDE_AIR_TEMP, + CarHvacManager.ID_OUTSIDE_AIR_TEMP, VehicleNetworkConsts.VEHICLE_PROPERTY_ENV_OUTSIDE_TEMPERATURE, - HvacPropertyId.TEMPERATURE_UNITS, + CarHvacManager.ID_TEMPERATURE_UNITS, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_TEMPERATURE_UNITS, - HvacPropertyId.ZONED_TEMP_SETPOINT, + CarHvacManager.ID_ZONED_TEMP_SETPOINT, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_TEMPERATURE_SET, - HvacPropertyId.ZONED_TEMP_ACTUAL, + CarHvacManager.ID_ZONED_TEMP_ACTUAL, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_TEMPERATURE_CURRENT, - HvacPropertyId.ZONED_FAN_SPEED_SETPOINT, + CarHvacManager.ID_ZONED_FAN_SPEED_SETPOINT, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_FAN_SPEED, - HvacPropertyId.ZONED_FAN_SPEED_RPM, + CarHvacManager.ID_ZONED_FAN_SPEED_RPM, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_ACTUAL_FAN_SPEED_RPM, - HvacPropertyId.ZONED_FAN_POSITION_AVAILABLE, + CarHvacManager.ID_ZONED_FAN_POSITION_AVAILABLE, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_FAN_DIRECTION_AVAILABLE, - HvacPropertyId.ZONED_FAN_POSITION, + CarHvacManager.ID_ZONED_FAN_POSITION, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_FAN_DIRECTION, - HvacPropertyId.ZONED_SEAT_TEMP, + CarHvacManager.ID_ZONED_SEAT_TEMP, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_SEAT_TEMPERATURE, - HvacPropertyId.ZONED_AC_ON, + CarHvacManager.ID_ZONED_AC_ON, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_AC_ON, - HvacPropertyId.ZONED_AUTOMATIC_MODE_ON, + CarHvacManager.ID_ZONED_AUTOMATIC_MODE_ON, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_AUTO_ON, - HvacPropertyId.ZONED_AIR_RECIRCULATION_ON, + CarHvacManager.ID_ZONED_AIR_RECIRCULATION_ON, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_RECIRC_ON, - HvacPropertyId.ZONED_MAX_AC_ON, + CarHvacManager.ID_ZONED_MAX_AC_ON, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_MAX_AC_ON, - HvacPropertyId.ZONED_DUAL_ZONE_ON, + CarHvacManager.ID_ZONED_DUAL_ZONE_ON, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_DUAL_ON, - HvacPropertyId.ZONED_MAX_DEFROST_ON, + CarHvacManager.ID_ZONED_MAX_DEFROST_ON, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_MAX_DEFROST_ON, - HvacPropertyId.ZONED_HVAC_POWER_ON, + CarHvacManager.ID_ZONED_HVAC_POWER_ON, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_POWER_ON, - HvacPropertyId.WINDOW_DEFROSTER_ON, + CarHvacManager.ID_WINDOW_DEFROSTER_ON, VehicleNetworkConsts.VEHICLE_PROPERTY_HVAC_DEFROSTER }); diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/KitchenSinkActivity.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/KitchenSinkActivity.java index c9eab99bdc..d4ba6ad385 100644 --- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/KitchenSinkActivity.java +++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/KitchenSinkActivity.java @@ -160,11 +160,7 @@ public class KitchenSinkActivity extends CarDrawerActivity { protected void onDestroy() { super.onDestroy(); if (mCarSensorManager != null) { - try { - mCarSensorManager.removeListener(mListener); - } catch (CarNotConnectedException e) { - Log.e(TAG, "Failed to unregister car seonsor listener", e); - } + mCarSensorManager.removeListener(mListener); } if (mCarApi != null) { mCarApi.disconnect(); diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/audio/AudioTestFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/audio/AudioTestFragment.java index f53b6a6724..079cc1e15e 100644 --- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/audio/AudioTestFragment.java +++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/audio/AudioTestFragment.java @@ -159,16 +159,20 @@ public class AudioTestFragment extends Fragment { } catch (CarNotConnectedException e) { throw new RuntimeException("Failed to create audio manager", e); } - mMusicAudioAttrib = mCarAudioManager.getAudioAttributesForCarUsage( - CarAudioManager.CAR_AUDIO_USAGE_MUSIC); - mNavAudioAttrib = mCarAudioManager.getAudioAttributesForCarUsage( - CarAudioManager.CAR_AUDIO_USAGE_NAVIGATION_GUIDANCE); - mVrAudioAttrib = mCarAudioManager.getAudioAttributesForCarUsage( - CarAudioManager.CAR_AUDIO_USAGE_VOICE_COMMAND); - mRadioAudioAttrib = mCarAudioManager.getAudioAttributesForCarUsage( - CarAudioManager.CAR_AUDIO_USAGE_RADIO); - mSystemSoundAudioAttrib = mCarAudioManager.getAudioAttributesForCarUsage( - CarAudioManager.CAR_AUDIO_USAGE_SYSTEM_SOUND); + try { + mMusicAudioAttrib = mCarAudioManager.getAudioAttributesForCarUsage( + CarAudioManager.CAR_AUDIO_USAGE_MUSIC); + mNavAudioAttrib = mCarAudioManager.getAudioAttributesForCarUsage( + CarAudioManager.CAR_AUDIO_USAGE_NAVIGATION_GUIDANCE); + mVrAudioAttrib = mCarAudioManager.getAudioAttributesForCarUsage( + CarAudioManager.CAR_AUDIO_USAGE_VOICE_COMMAND); + mRadioAudioAttrib = mCarAudioManager.getAudioAttributesForCarUsage( + CarAudioManager.CAR_AUDIO_USAGE_RADIO); + mSystemSoundAudioAttrib = mCarAudioManager.getAudioAttributesForCarUsage( + CarAudioManager.CAR_AUDIO_USAGE_SYSTEM_SOUND); + } catch (CarNotConnectedException e) { + //ignore for now + } mMusicPlayer = new AudioPlayer(mContext, R.raw.john_harrison_with_the_wichita_state_university_chamber_players_05_summer_mvt_2_adagio, mMusicAudioAttrib); @@ -274,12 +278,8 @@ public class AudioTestFragment extends Fragment { new PlayStateListener() { @Override public void onCompletion() { - try { - mAppFocusManager.abandonAppFocus(mOwnershipCallbacks, - CarAppFocusManager.APP_FOCUS_TYPE_NAVIGATION); - } catch (CarNotConnectedException e) { - Log.e(TAG, "Failed to reset active focus", e); - } + mAppFocusManager.abandonAppFocus(mOwnershipCallbacks, + CarAppFocusManager.APP_FOCUS_TYPE_NAVIGATION); } }); } @@ -306,12 +306,8 @@ public class AudioTestFragment extends Fragment { new PlayStateListener() { @Override public void onCompletion() { - try { - mAppFocusManager.abandonAppFocus(mOwnershipCallbacks, - CarAppFocusManager.APP_FOCUS_TYPE_VOICE_COMMAND); - } catch (CarNotConnectedException e) { - Log.e(TAG, "Failed to reset active focus", e); - } + mAppFocusManager.abandonAppFocus(mOwnershipCallbacks, + CarAppFocusManager.APP_FOCUS_TYPE_VOICE_COMMAND); } }); } @@ -471,11 +467,7 @@ public class AudioTestFragment extends Fragment { mAudioFocusHandler = null; } if (mAppFocusManager != null) { - try { - mAppFocusManager.abandonAppFocus(mOwnershipCallbacks); - } catch (CarNotConnectedException e) { - Log.e(TAG, "Failed to reset active focus", e); - } + mAppFocusManager.abandonAppFocus(mOwnershipCallbacks); } } @@ -492,11 +484,11 @@ public class AudioTestFragment extends Fragment { try { mAppFocusManager.requestAppFocus(CarAppFocusManager.APP_FOCUS_TYPE_NAVIGATION, mOwnershipCallbacks); + mCarAudioManager.requestAudioFocus(mNavFocusListener, mNavAudioAttrib, + AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK, 0); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set active focus", e); } - mCarAudioManager.requestAudioFocus(mNavFocusListener, mNavAudioAttrib, - AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK, 0); } private void handleNavEnd() { @@ -509,12 +501,8 @@ public class AudioTestFragment extends Fragment { if (DBG) { Log.i(TAG, "Nav end"); } - try { - mAppFocusManager.abandonAppFocus(mOwnershipCallbacks, - CarAppFocusManager.APP_FOCUS_TYPE_NAVIGATION); - } catch (CarNotConnectedException e) { - Log.e(TAG, "Failed to reset active focus", e); - } + mAppFocusManager.abandonAppFocus(mOwnershipCallbacks, + CarAppFocusManager.APP_FOCUS_TYPE_NAVIGATION); mCarAudioManager.abandonAudioFocus(mNavFocusListener, mNavAudioAttrib); } @@ -531,11 +519,11 @@ public class AudioTestFragment extends Fragment { try { mAppFocusManager.requestAppFocus(CarAppFocusManager.APP_FOCUS_TYPE_VOICE_COMMAND, mOwnershipCallbacks); + mCarAudioManager.requestAudioFocus(mVrFocusListener, mVrAudioAttrib, + AudioManager.AUDIOFOCUS_GAIN_TRANSIENT, 0); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set active focus", e); } - mCarAudioManager.requestAudioFocus(mVrFocusListener, mVrAudioAttrib, - AudioManager.AUDIOFOCUS_GAIN_TRANSIENT, 0); } private void handleVrEnd() { @@ -548,12 +536,8 @@ public class AudioTestFragment extends Fragment { if (DBG) { Log.i(TAG, "VR end"); } - try { - mAppFocusManager.abandonAppFocus(mOwnershipCallbacks, - CarAppFocusManager.APP_FOCUS_TYPE_VOICE_COMMAND); - } catch (CarNotConnectedException e) { - Log.e(TAG, "Failed to reset active focus", e); - } + mAppFocusManager.abandonAppFocus(mOwnershipCallbacks, + CarAppFocusManager.APP_FOCUS_TYPE_VOICE_COMMAND); mCarAudioManager.abandonAudioFocus(mVrFocusListener, mVrAudioAttrib); } @@ -564,8 +548,12 @@ public class AudioTestFragment extends Fragment { if (DBG) { Log.i(TAG, "Radio start"); } - mCarAudioManager.requestAudioFocus(mRadioFocusListener, mRadioAudioAttrib, - AudioManager.AUDIOFOCUS_GAIN, 0); + try { + mCarAudioManager.requestAudioFocus(mRadioFocusListener, mRadioAudioAttrib, + AudioManager.AUDIOFOCUS_GAIN, 0); + } catch (CarNotConnectedException e) { + Log.e(TAG, "failed", e); + } } private void handleRadioEnd() { diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/camera/CameraTestFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/camera/CameraTestFragment.java index f9f1319c85..b7933497c5 100644 --- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/camera/CameraTestFragment.java +++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/camera/CameraTestFragment.java @@ -49,6 +49,15 @@ public class CameraTestFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) { View v = inflater.inflate(R.layout.camera_test, container, false); + try { + doCreateView(v); + } catch (CarNotConnectedException e) { + Log.e(TAG, "Car not connected", e); + } + return v; + } + + private void doCreateView(View v) throws CarNotConnectedException { int[] cameraList = mCarCameraManager.getCameraList(); for (int camera : cameraList) { if (camera == CarCameraManager.CAR_CAMERA_TYPE_RVC) { @@ -197,7 +206,6 @@ public class CameraTestFragment extends Fragment { if(DBG) { Log.d(TAG, "Starting CameraTestFragment"); } - return v; } public void setCameraManager(CarCameraManager cameraManager) { diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/hvac/HvacTestFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/hvac/HvacTestFragment.java index 6d8f218058..476cc43e4f 100644 --- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/hvac/HvacTestFragment.java +++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/hvac/HvacTestFragment.java @@ -22,7 +22,6 @@ import android.car.CarNotConnectedException; import android.car.hardware.CarPropertyConfig; import android.car.hardware.CarPropertyValue; import android.car.hardware.hvac.CarHvacManager; -import android.car.hardware.hvac.CarHvacManager.HvacPropertyId; import android.os.Bundle; import android.support.v4.app.Fragment; import android.util.Log; @@ -79,25 +78,25 @@ public class HvacTestFragment extends Fragment { private int mZoneForFanSpeed; private int mZoneForFanPosition; - private final CarHvacManager.CarHvacEventListener mHvacListener = - new CarHvacManager.CarHvacEventListener () { + private final CarHvacManager.CarHvacEventCallback mHvacCallback = + new CarHvacManager.CarHvacEventCallback () { @Override public void onChangeEvent(final CarPropertyValue value) { int zones = value.getAreaId(); switch(value.getPropertyId()) { - case HvacPropertyId.OUTSIDE_AIR_TEMP: + case CarHvacManager.ID_OUTSIDE_AIR_TEMP: mTvOutsideTemp.setText(String.valueOf(value.getValue())); break; - case HvacPropertyId.ZONED_DUAL_ZONE_ON: + case CarHvacManager.ID_ZONED_DUAL_ZONE_ON: mTbDual.setChecked((boolean)value.getValue()); break; - case HvacPropertyId.ZONED_AC_ON: + case CarHvacManager.ID_ZONED_AC_ON: mTbAc.setChecked((boolean)value.getValue()); break; - case HvacPropertyId.ZONED_AUTOMATIC_MODE_ON: + case CarHvacManager.ID_ZONED_AUTOMATIC_MODE_ON: mTbAuto.setChecked((boolean)value.getValue()); break; - case HvacPropertyId.ZONED_FAN_POSITION: + case CarHvacManager.ID_ZONED_FAN_POSITION: switch((int)value.getValue()) { case VehicleHvacFanDirection.VEHICLE_HVAC_FAN_DIRECTION_FACE: mRbFanPositionFace.setChecked(true); @@ -123,19 +122,19 @@ public class HvacTestFragment extends Fragment { break; } break; - case HvacPropertyId.ZONED_MAX_AC_ON: + case CarHvacManager.ID_ZONED_MAX_AC_ON: mTbMaxAc.setChecked((boolean)value.getValue()); break; - case HvacPropertyId.ZONED_AIR_RECIRCULATION_ON: + case CarHvacManager.ID_ZONED_AIR_RECIRCULATION_ON: mTbRecirc.setChecked((boolean)value.getValue()); break; - case HvacPropertyId.ZONED_FAN_SPEED_SETPOINT: + case CarHvacManager.ID_ZONED_FAN_SPEED_SETPOINT: if ((zones & mZoneForFanSpeed) != 0) { mCurFanSpeed = (int)value.getValue(); mTvFanSpeed.setText(String.valueOf(mCurFanSpeed)); } break; - case HvacPropertyId.ZONED_TEMP_SETPOINT: + case CarHvacManager.ID_ZONED_TEMP_SETPOINT: if ((zones & mZoneForSetTempD) != 0) { mCurDTemp = (float)value.getValue(); mTvDTemp.setText(String.valueOf(mCurDTemp)); @@ -145,10 +144,10 @@ public class HvacTestFragment extends Fragment { mTvPTemp.setText(String.valueOf(mCurPTemp)); } break; - case HvacPropertyId.ZONED_MAX_DEFROST_ON: + case CarHvacManager.ID_ZONED_MAX_DEFROST_ON: mTbMaxDefrost.setChecked((boolean)value.getValue()); break; - case HvacPropertyId.WINDOW_DEFROSTER_ON: + case CarHvacManager.ID_WINDOW_DEFROSTER_ON: if((zones & VehicleWindow.VEHICLE_WINDOW_FRONT_WINDSHIELD) == VehicleWindow.VEHICLE_WINDOW_FRONT_WINDSHIELD) { mTbDefrostFront.setChecked((boolean)value.getValue()); @@ -175,7 +174,7 @@ public class HvacTestFragment extends Fragment { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { - mCarHvacManager.registerListener(mHvacListener); + mCarHvacManager.registerCallback(mHvacCallback); } catch (CarNotConnectedException e) { Log.e(TAG, "Car is not connected!"); } @@ -184,11 +183,7 @@ public class HvacTestFragment extends Fragment { @Override public void onDestroy() { super.onDestroy(); - try { - mCarHvacManager.unregisterListener(mHvacListener); - } catch (CarNotConnectedException e) { - Log.e(TAG, "Failed to unregister listener", e); - } + mCarHvacManager.unregisterCallback(mHvacCallback); } @Override @@ -211,37 +206,37 @@ public class HvacTestFragment extends Fragment { } switch(propId) { - case HvacPropertyId.OUTSIDE_AIR_TEMP: + case CarHvacManager.ID_OUTSIDE_AIR_TEMP: configureOutsideTemp(v, prop); break; - case HvacPropertyId.ZONED_DUAL_ZONE_ON: + case CarHvacManager.ID_ZONED_DUAL_ZONE_ON: configureDualOn(v, prop); break; - case HvacPropertyId.ZONED_AC_ON: + case CarHvacManager.ID_ZONED_AC_ON: configureAcOn(v, prop); break; - case HvacPropertyId.ZONED_FAN_POSITION: + case CarHvacManager.ID_ZONED_FAN_POSITION: configureFanPosition(v, prop); break; - case HvacPropertyId.ZONED_FAN_SPEED_SETPOINT: + case CarHvacManager.ID_ZONED_FAN_SPEED_SETPOINT: configureFanSpeed(v, prop); break; - case HvacPropertyId.ZONED_TEMP_SETPOINT: + case CarHvacManager.ID_ZONED_TEMP_SETPOINT: configureTempSetpoint(v, prop); break; - case HvacPropertyId.ZONED_AUTOMATIC_MODE_ON: + case CarHvacManager.ID_ZONED_AUTOMATIC_MODE_ON: configureAutoModeOn(v, prop); break; - case HvacPropertyId.ZONED_AIR_RECIRCULATION_ON: + case CarHvacManager.ID_ZONED_AIR_RECIRCULATION_ON: configureRecircOn(v, prop); break; - case HvacPropertyId.ZONED_MAX_AC_ON: + case CarHvacManager.ID_ZONED_MAX_AC_ON: configureMaxAcOn(v, prop); break; - case HvacPropertyId.ZONED_MAX_DEFROST_ON: + case CarHvacManager.ID_ZONED_MAX_DEFROST_ON: configureMaxDefrostOn(v, prop); break; - case HvacPropertyId.WINDOW_DEFROSTER_ON: + case CarHvacManager.ID_WINDOW_DEFROSTER_ON: configureDefrosterOn(v, prop); break; default: @@ -283,7 +278,7 @@ public class HvacTestFragment extends Fragment { mTbDual.setOnClickListener(view -> { // TODO handle zone properly try { - mCarHvacManager.setBooleanProperty(HvacPropertyId.ZONED_DUAL_ZONE_ON,temp, + mCarHvacManager.setBooleanProperty(CarHvacManager.ID_ZONED_DUAL_ZONE_ON,temp, mTbDual.isChecked()); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set HVAC boolean property", e); @@ -299,7 +294,7 @@ public class HvacTestFragment extends Fragment { mTbAc.setOnClickListener(view -> { // TODO handle zone properly try { - mCarHvacManager.setBooleanProperty(HvacPropertyId.ZONED_AC_ON, mZoneForAcOn, + mCarHvacManager.setBooleanProperty(CarHvacManager.ID_ZONED_AC_ON, mZoneForAcOn, mTbAc.isChecked()); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set HVAC boolean property", e); @@ -315,7 +310,7 @@ public class HvacTestFragment extends Fragment { mTbAuto.setOnClickListener(view -> { // TODO handle zone properly try { - mCarHvacManager.setBooleanProperty(HvacPropertyId.ZONED_AUTOMATIC_MODE_ON,temp, + mCarHvacManager.setBooleanProperty(CarHvacManager.ID_ZONED_AUTOMATIC_MODE_ON,temp, mTbAuto.isChecked()); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set HVAC boolean property", e); @@ -348,7 +343,7 @@ public class HvacTestFragment extends Fragment { throw new IllegalStateException("Unexpected fan position: " + checkedId); } try { - mCarHvacManager.setIntProperty(HvacPropertyId.ZONED_FAN_POSITION, + mCarHvacManager.setIntProperty(CarHvacManager.ID_ZONED_FAN_POSITION, mZoneForFanPosition, position); } catch (CarNotConnectedException e) { @@ -374,7 +369,7 @@ public class HvacTestFragment extends Fragment { mZoneForFanSpeed = prop.getFirstAndOnlyAreaId(); try { mCurFanSpeed = mCarHvacManager.getIntProperty( - HvacPropertyId.ZONED_FAN_SPEED_SETPOINT, + CarHvacManager.ID_ZONED_FAN_SPEED_SETPOINT, mZoneForFanSpeed); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to get HVAC int property", e); @@ -387,7 +382,7 @@ public class HvacTestFragment extends Fragment { mCurFanSpeed++; mTvFanSpeed.setText(String.valueOf(mCurFanSpeed)); try { - mCarHvacManager.setIntProperty(HvacPropertyId.ZONED_FAN_SPEED_SETPOINT, + mCarHvacManager.setIntProperty(CarHvacManager.ID_ZONED_FAN_SPEED_SETPOINT, mZoneForFanSpeed, mCurFanSpeed); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set HVAC int property", e); @@ -402,7 +397,7 @@ public class HvacTestFragment extends Fragment { mCurFanSpeed--; mTvFanSpeed.setText(String.valueOf(mCurFanSpeed)); try { - mCarHvacManager.setIntProperty(HvacPropertyId.ZONED_FAN_SPEED_SETPOINT, + mCarHvacManager.setIntProperty(CarHvacManager.ID_ZONED_FAN_SPEED_SETPOINT, mZoneForFanSpeed, mCurFanSpeed); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set HVAC fan speed property", e); @@ -441,7 +436,7 @@ public class HvacTestFragment extends Fragment { if (mZoneForSetTempD != 0) { try { mCurDTemp = mCarHvacManager.getFloatProperty( - HvacPropertyId.ZONED_TEMP_SETPOINT, + CarHvacManager.ID_ZONED_TEMP_SETPOINT, mZoneForSetTempD); if (mCurDTemp < mMinTemp) { mCurDTemp = mMinTemp; @@ -458,7 +453,7 @@ public class HvacTestFragment extends Fragment { mTvDTemp.setText(String.valueOf(mCurDTemp)); try { mCarHvacManager.setFloatProperty( - HvacPropertyId.ZONED_TEMP_SETPOINT, + CarHvacManager.ID_ZONED_TEMP_SETPOINT, mZoneForSetTempD, mCurDTemp); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set HVAC zoned temp property", e); @@ -474,7 +469,7 @@ public class HvacTestFragment extends Fragment { mTvDTemp.setText(String.valueOf(mCurDTemp)); try { mCarHvacManager.setFloatProperty( - HvacPropertyId.ZONED_TEMP_SETPOINT, + CarHvacManager.ID_ZONED_TEMP_SETPOINT, mZoneForSetTempD, mCurDTemp); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set HVAC zoned temp property", e); @@ -489,7 +484,7 @@ public class HvacTestFragment extends Fragment { if (mZoneForSetTempP !=0 ) { try { mCurPTemp = mCarHvacManager.getFloatProperty( - HvacPropertyId.ZONED_TEMP_SETPOINT, + CarHvacManager.ID_ZONED_TEMP_SETPOINT, mZoneForSetTempP); if (mCurPTemp < mMinTemp) { mCurPTemp = mMinTemp; @@ -506,7 +501,7 @@ public class HvacTestFragment extends Fragment { mTvPTemp.setText(String.valueOf(mCurPTemp)); try { mCarHvacManager.setFloatProperty( - HvacPropertyId.ZONED_TEMP_SETPOINT, + CarHvacManager.ID_ZONED_TEMP_SETPOINT, mZoneForSetTempP, mCurPTemp); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set HVAC zoned temp property", e); @@ -522,7 +517,7 @@ public class HvacTestFragment extends Fragment { mTvPTemp.setText(String.valueOf(mCurPTemp)); try { mCarHvacManager.setFloatProperty( - HvacPropertyId.ZONED_TEMP_SETPOINT, + CarHvacManager.ID_ZONED_TEMP_SETPOINT, mZoneForSetTempP, mCurPTemp); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set HVAC zoned temp property", e); @@ -540,7 +535,7 @@ public class HvacTestFragment extends Fragment { mTbDefrostFront.setEnabled(true); mTbDefrostFront.setOnClickListener(view -> { try { - mCarHvacManager.setBooleanProperty(HvacPropertyId.WINDOW_DEFROSTER_ON, + mCarHvacManager.setBooleanProperty(CarHvacManager.ID_WINDOW_DEFROSTER_ON, VehicleWindow.VEHICLE_WINDOW_FRONT_WINDSHIELD, mTbDefrostFront.isChecked()); } catch (CarNotConnectedException e) { @@ -553,7 +548,7 @@ public class HvacTestFragment extends Fragment { mTbDefrostRear.setEnabled(true); mTbDefrostRear.setOnClickListener(view -> { try { - mCarHvacManager.setBooleanProperty(HvacPropertyId.WINDOW_DEFROSTER_ON, + mCarHvacManager.setBooleanProperty(CarHvacManager.ID_WINDOW_DEFROSTER_ON, VehicleWindow.VEHICLE_WINDOW_REAR_WINDSHIELD, mTbDefrostRear.isChecked()); } catch (CarNotConnectedException e) { @@ -571,8 +566,8 @@ public class HvacTestFragment extends Fragment { mTbRecirc.setOnClickListener(view -> { // TODO handle zone properly try { - mCarHvacManager.setBooleanProperty(HvacPropertyId.ZONED_AIR_RECIRCULATION_ON,temp, - mTbRecirc.isChecked()); + mCarHvacManager.setBooleanProperty(CarHvacManager.ID_ZONED_AIR_RECIRCULATION_ON, + temp, mTbRecirc.isChecked()); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set HVAC boolean property", e); } @@ -587,7 +582,7 @@ public class HvacTestFragment extends Fragment { mTbMaxAc.setOnClickListener(view -> { // TODO handle zone properly try { - mCarHvacManager.setBooleanProperty(HvacPropertyId.ZONED_MAX_AC_ON,temp, + mCarHvacManager.setBooleanProperty(CarHvacManager.ID_ZONED_MAX_AC_ON,temp, mTbMaxAc.isChecked()); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set HVAC boolean property", e); @@ -603,7 +598,7 @@ public class HvacTestFragment extends Fragment { mTbMaxDefrost.setOnClickListener(view -> { // TODO handle zone properly try { - mCarHvacManager.setBooleanProperty(HvacPropertyId.ZONED_MAX_DEFROST_ON,temp, + mCarHvacManager.setBooleanProperty(CarHvacManager.ID_ZONED_MAX_DEFROST_ON,temp, mTbMaxDefrost.isChecked()); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to set HVAC boolean property", e); diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/keyboard/KeyboardFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/keyboard/KeyboardFragment.java index b8b97086ea..87d54f16ed 100644 --- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/keyboard/KeyboardFragment.java +++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/keyboard/KeyboardFragment.java @@ -111,11 +111,7 @@ public class KeyboardFragment extends Fragment { public void onPause() { super.onPause(); if (mSensorManager != null) { - try { - mSensorManager.removeListener(mOnSensorChangedListener); - } catch (CarNotConnectedException e) { - Log.e(TAG, "Car not connected", e); - } + mSensorManager.removeListener(mOnSensorChangedListener); } } diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/radio/RadioTestFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/radio/RadioTestFragment.java index ed11998238..89efdf552d 100644 --- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/radio/RadioTestFragment.java +++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/radio/RadioTestFragment.java @@ -282,8 +282,12 @@ public class RadioTestFragment extends Fragment { if (DBG) { Log.i(TAG, "Get radio focus"); } - mCarAudioManager.requestAudioFocus(mRadioFocusListener, mRadioAudioAttrib, - AudioManager.AUDIOFOCUS_GAIN, 0); + try { + mCarAudioManager.requestAudioFocus(mRadioFocusListener, mRadioAudioAttrib, + AudioManager.AUDIOFOCUS_GAIN, 0); + } catch (CarNotConnectedException e) { + //ignore for now + } mHasRadioFocus = true; updateStates(); } diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/sensor/SensorsTestFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/sensor/SensorsTestFragment.java index d563a9a97f..7c757ee0eb 100644 --- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/sensor/SensorsTestFragment.java +++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/sensor/SensorsTestFragment.java @@ -114,11 +114,7 @@ public class SensorsTestFragment extends Fragment { public void onPause() { super.onPause(); if (mSensorManager != null) { - try { - mSensorManager.removeListener(mOnSensorChangedListener); - } catch (CarNotConnectedException e) { - Log.e(TAG, "Car not connected", e); - } + mSensorManager.removeListener(mOnSensorChangedListener); } } diff --git a/tests/android_car_api_test/src/android/car/apitest/CarApiUtilTest.java b/tests/android_car_api_test/src/android/car/apitest/CarApiUtilTest.java index f5b473c28f..9027ad4b25 100644 --- a/tests/android_car_api_test/src/android/car/apitest/CarApiUtilTest.java +++ b/tests/android_car_api_test/src/android/car/apitest/CarApiUtilTest.java @@ -18,7 +18,6 @@ package android.car.apitest; import android.car.Car; import android.car.CarApiUtil; import android.car.CarNotConnectedException; -import android.car.CarOperationNotSupportedException; import android.car.settings.CarSettings; import junit.framework.TestCase; @@ -78,34 +77,4 @@ public class CarApiUtilTest extends TestCase { } assertEquals(e, resultException); } - - public void testCheckAllIllegalStateExceptionsFromCarService() { - IllegalStateException e = new IllegalStateException( - CarApiUtil.CAR_NOT_CONNECTED_EXCEPTION_MSG); - Exception resultException = null; - try { - CarApiUtil.checkAllIllegalStateExceptionsFromCarService(e); - } catch (Exception exception) { - resultException = exception; - } - assertTrue(resultException instanceof CarNotConnectedException); - - e = new IllegalStateException(CarApiUtil.CAR_NOT_SUPPORTED_EXCEPTION_MSG); - resultException = null; - try { - CarApiUtil.checkAllIllegalStateExceptionsFromCarService(e); - } catch (Exception exception) { - resultException = exception; - } - assertTrue(resultException instanceof CarOperationNotSupportedException); - - e = new IllegalStateException("Hello"); - resultException = null; - try { - CarApiUtil.checkAllIllegalStateExceptionsFromCarService(e); - } catch (Exception exception) { - resultException = exception; - } - assertEquals(e, resultException); - } } diff --git a/tests/android_car_api_test/src/android/car/apitest/CarCabinManagerTest.java b/tests/android_car_api_test/src/android/car/apitest/CarCabinManagerTest.java index 509325103c..3a14624d03 100644 --- a/tests/android_car_api_test/src/android/car/apitest/CarCabinManagerTest.java +++ b/tests/android_car_api_test/src/android/car/apitest/CarCabinManagerTest.java @@ -17,7 +17,6 @@ package android.car.apitest; import android.car.Car; import android.car.hardware.cabin.CarCabinManager; -import android.car.hardware.cabin.CarCabinManager.CabinPropertyId; import android.car.hardware.CarPropertyConfig; import android.test.suitebuilder.annotation.MediumTest; import android.util.Log; @@ -58,52 +57,52 @@ public class CarCabinManagerTest extends CarApiTestBase { int propId = property.getPropertyId(); switch (propId) { // Zoned boolean properties - case CabinPropertyId.DOOR_LOCK: - case CabinPropertyId.MIRROR_LOCK: - case CabinPropertyId.MIRROR_FOLD: - case CabinPropertyId.SEAT_BELT_BUCKLED: - case CabinPropertyId.WINDOW_LOCK: + case CarCabinManager.ID_DOOR_LOCK: + case CarCabinManager.ID_MIRROR_LOCK: + case CarCabinManager.ID_MIRROR_FOLD: + case CarCabinManager.ID_SEAT_BELT_BUCKLED: + case CarCabinManager.ID_WINDOW_LOCK: assertEquals(Boolean.class, property.getPropertyType()); assertFalse(property.isGlobalProperty()); break; // Zoned integer properties - case CabinPropertyId.DOOR_POS: - case CabinPropertyId.DOOR_MOVE: - case CabinPropertyId.MIRROR_Z_POS: - case CabinPropertyId.MIRROR_Z_MOVE: - case CabinPropertyId.MIRROR_Y_POS: - case CabinPropertyId.MIRROR_Y_MOVE: - case CabinPropertyId.SEAT_MEMORY_SELECT: - case CabinPropertyId.SEAT_MEMORY_SET: - case CabinPropertyId.SEAT_BELT_HEIGHT_POS: - case CabinPropertyId.SEAT_BELT_HEIGHT_MOVE: - case CabinPropertyId.SEAT_FORE_AFT_POS: - case CabinPropertyId.SEAT_FORE_AFT_MOVE: - case CabinPropertyId.SEAT_BACKREST_ANGLE_1_POS: - case CabinPropertyId.SEAT_BACKREST_ANGLE_1_MOVE: - case CabinPropertyId.SEAT_BACKREST_ANGLE_2_POS: - case CabinPropertyId.SEAT_BACKREST_ANGLE_2_MOVE: - case CabinPropertyId.SEAT_HEIGHT_POS: - case CabinPropertyId.SEAT_HEIGHT_MOVE: - case CabinPropertyId.SEAT_DEPTH_POS: - case CabinPropertyId.SEAT_DEPTH_MOVE: - case CabinPropertyId.SEAT_TILT_POS: - case CabinPropertyId.SEAT_TILT_MOVE: - case CabinPropertyId.SEAT_LUMBAR_FORE_AFT_POS: - case CabinPropertyId.SEAT_LUMBAR_FORE_AFT_MOVE: - case CabinPropertyId.SEAT_LUMBAR_SIDE_SUPPORT_POS: - case CabinPropertyId.SEAT_LUMBAR_SIDE_SUPPORT_MOVE: - case CabinPropertyId.SEAT_HEADREST_HEIGHT_POS: - case CabinPropertyId.SEAT_HEADREST_HEIGHT_MOVE: - case CabinPropertyId.SEAT_HEADREST_ANGLE_POS: - case CabinPropertyId.SEAT_HEADREST_ANGLE_MOVE: - case CabinPropertyId.SEAT_HEADREST_FORE_AFT_POS: - case CabinPropertyId.SEAT_HEADREST_FORE_AFT_MOVE: - case CabinPropertyId.WINDOW_POS: - case CabinPropertyId.WINDOW_MOVE: - case CabinPropertyId.WINDOW_VENT_POS: - case CabinPropertyId.WINDOW_VENT_MOVE: + case CarCabinManager.ID_DOOR_POS: + case CarCabinManager.ID_DOOR_MOVE: + case CarCabinManager.ID_MIRROR_Z_POS: + case CarCabinManager.ID_MIRROR_Z_MOVE: + case CarCabinManager.ID_MIRROR_Y_POS: + case CarCabinManager.ID_MIRROR_Y_MOVE: + case CarCabinManager.ID_SEAT_MEMORY_SELECT: + case CarCabinManager.ID_SEAT_MEMORY_SET: + case CarCabinManager.ID_SEAT_BELT_HEIGHT_POS: + case CarCabinManager.ID_SEAT_BELT_HEIGHT_MOVE: + case CarCabinManager.ID_SEAT_FORE_AFT_POS: + case CarCabinManager.ID_SEAT_FORE_AFT_MOVE: + case CarCabinManager.ID_SEAT_BACKREST_ANGLE_1_POS: + case CarCabinManager.ID_SEAT_BACKREST_ANGLE_1_MOVE: + case CarCabinManager.ID_SEAT_BACKREST_ANGLE_2_POS: + case CarCabinManager.ID_SEAT_BACKREST_ANGLE_2_MOVE: + case CarCabinManager.ID_SEAT_HEIGHT_POS: + case CarCabinManager.ID_SEAT_HEIGHT_MOVE: + case CarCabinManager.ID_SEAT_DEPTH_POS: + case CarCabinManager.ID_SEAT_DEPTH_MOVE: + case CarCabinManager.ID_SEAT_TILT_POS: + case CarCabinManager.ID_SEAT_TILT_MOVE: + case CarCabinManager.ID_SEAT_LUMBAR_FORE_AFT_POS: + case CarCabinManager.ID_SEAT_LUMBAR_FORE_AFT_MOVE: + case CarCabinManager.ID_SEAT_LUMBAR_SIDE_SUPPORT_POS: + case CarCabinManager.ID_SEAT_LUMBAR_SIDE_SUPPORT_MOVE: + case CarCabinManager.ID_SEAT_HEADREST_HEIGHT_POS: + case CarCabinManager.ID_SEAT_HEADREST_HEIGHT_MOVE: + case CarCabinManager.ID_SEAT_HEADREST_ANGLE_POS: + case CarCabinManager.ID_SEAT_HEADREST_ANGLE_MOVE: + case CarCabinManager.ID_SEAT_HEADREST_FORE_AFT_POS: + case CarCabinManager.ID_SEAT_HEADREST_FORE_AFT_MOVE: + case CarCabinManager.ID_WINDOW_POS: + case CarCabinManager.ID_WINDOW_MOVE: + case CarCabinManager.ID_WINDOW_VENT_POS: + case CarCabinManager.ID_WINDOW_VENT_MOVE: assertEquals(Integer.class, property.getPropertyType()); assertFalse(property.isGlobalProperty()); checkIntMinMax(property); diff --git a/tests/android_car_api_test/src/android/car/apitest/CarHvacManagerTest.java b/tests/android_car_api_test/src/android/car/apitest/CarHvacManagerTest.java index f178df4a02..a377ea3231 100644 --- a/tests/android_car_api_test/src/android/car/apitest/CarHvacManagerTest.java +++ b/tests/android_car_api_test/src/android/car/apitest/CarHvacManagerTest.java @@ -17,7 +17,6 @@ package android.car.apitest; import android.car.Car; import android.car.hardware.hvac.CarHvacManager; -import android.car.hardware.hvac.CarHvacManager.HvacPropertyId; import android.car.hardware.CarPropertyConfig; import android.test.suitebuilder.annotation.MediumTest; import android.util.Log; @@ -56,44 +55,44 @@ public class CarHvacManagerTest extends CarApiTestBase { private void assertTypeAndZone(CarPropertyConfig property) { switch (property.getPropertyId()) { - case HvacPropertyId.MIRROR_DEFROSTER_ON: // non-zoned bool + case CarHvacManager.ID_MIRROR_DEFROSTER_ON: // non-zoned bool assertEquals(Boolean.class, property.getPropertyType()); assertTrue(property.isGlobalProperty()); break; - case HvacPropertyId.STEERING_WHEEL_TEMP: // non-zoned int - case HvacPropertyId.TEMPERATURE_UNITS: + case CarHvacManager.ID_STEERING_WHEEL_TEMP: // non-zoned int + case CarHvacManager.ID_TEMPERATURE_UNITS: assertEquals(Integer.class, property.getPropertyType()); assertTrue(property.isGlobalProperty()); checkIntMinMax(property); break; - case HvacPropertyId.OUTSIDE_AIR_TEMP: + case CarHvacManager.ID_OUTSIDE_AIR_TEMP: assertEquals(Float.class, property.getPropertyType()); assertTrue(property.isGlobalProperty()); checkFloatMinMax(property); break; - case HvacPropertyId.ZONED_TEMP_SETPOINT: // zoned float - case HvacPropertyId.ZONED_TEMP_ACTUAL: + case CarHvacManager.ID_ZONED_TEMP_SETPOINT: // zoned float + case CarHvacManager.ID_ZONED_TEMP_ACTUAL: assertEquals(Float.class, property.getPropertyType()); assertFalse(property.isGlobalProperty()); checkFloatMinMax(property); break; - case HvacPropertyId.ZONED_FAN_SPEED_SETPOINT: // zoned int - case HvacPropertyId.ZONED_FAN_SPEED_RPM: - case HvacPropertyId.ZONED_FAN_POSITION_AVAILABLE: - case HvacPropertyId.ZONED_FAN_POSITION: - case HvacPropertyId.ZONED_SEAT_TEMP: + case CarHvacManager.ID_ZONED_FAN_SPEED_SETPOINT: // zoned int + case CarHvacManager.ID_ZONED_FAN_SPEED_RPM: + case CarHvacManager.ID_ZONED_FAN_POSITION_AVAILABLE: + case CarHvacManager.ID_ZONED_FAN_POSITION: + case CarHvacManager.ID_ZONED_SEAT_TEMP: assertEquals(Integer.class, property.getPropertyType()); assertFalse(property.isGlobalProperty()); checkIntMinMax(property); break; - case HvacPropertyId.ZONED_AC_ON: // zoned boolean - case HvacPropertyId.ZONED_AUTOMATIC_MODE_ON: - case HvacPropertyId.ZONED_AIR_RECIRCULATION_ON: - case HvacPropertyId.ZONED_MAX_AC_ON: - case HvacPropertyId.ZONED_DUAL_ZONE_ON: - case HvacPropertyId.ZONED_MAX_DEFROST_ON: - case HvacPropertyId.ZONED_HVAC_POWER_ON: - case HvacPropertyId.WINDOW_DEFROSTER_ON: + case CarHvacManager.ID_ZONED_AC_ON: // zoned boolean + case CarHvacManager.ID_ZONED_AUTOMATIC_MODE_ON: + case CarHvacManager.ID_ZONED_AIR_RECIRCULATION_ON: + case CarHvacManager.ID_ZONED_MAX_AC_ON: + case CarHvacManager.ID_ZONED_DUAL_ZONE_ON: + case CarHvacManager.ID_ZONED_MAX_DEFROST_ON: + case CarHvacManager.ID_ZONED_HVAC_POWER_ON: + case CarHvacManager.ID_WINDOW_DEFROSTER_ON: assertEquals(Boolean.class, property.getPropertyType()); assertFalse(property.isGlobalProperty()); break; diff --git a/tests/android_car_api_test/src/android/car/apitest/VehicleSeatTest.java b/tests/android_car_api_test/src/android/car/apitest/VehicleSeatTest.java index 877755ecb8..bbd85e903a 100644 --- a/tests/android_car_api_test/src/android/car/apitest/VehicleSeatTest.java +++ b/tests/android_car_api_test/src/android/car/apitest/VehicleSeatTest.java @@ -25,27 +25,23 @@ import com.android.car.vehiclenetwork.VehicleNetworkConsts; public class VehicleSeatTest extends AndroidTestCase { public void testMatchWithVehicleHal() { - assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_DRIVER_LHD, - VehicleSeat.SEAT_DRIVER_LHD); - assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_DRIVER_RHD, - VehicleSeat.SEAT_DRIVER_RHD); - assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_1_PASSENGER_LEFT, - VehicleSeat.SEAT_ROW_1_PASSENGER_LEFT); - assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_1_PASSENGER_CENTER, - VehicleSeat.SEAT_ROW_1_PASSENGER_CENTER); - assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_1_PASSENGER_RIGHT, - VehicleSeat.SEAT_ROW_1_PASSENGER_RIGHT); - assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_2_PASSENGER_LEFT, - VehicleSeat.SEAT_ROW_2_PASSENGER_LEFT); - assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_2_PASSENGER_CENTER, - VehicleSeat.SEAT_ROW_2_PASSENGER_CENTER); - assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_2_PASSENGER_RIGHT, - VehicleSeat.SEAT_ROW_2_PASSENGER_RIGHT); - assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_3_PASSENGER_LEFT, - VehicleSeat.SEAT_ROW_3_PASSENGER_LEFT); - assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_3_PASSENGER_CENTER, - VehicleSeat.SEAT_ROW_3_PASSENGER_CENTER); - assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_3_PASSENGER_RIGHT, - VehicleSeat.SEAT_ROW_3_PASSENGER_RIGHT); + assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_1_LEFT, + VehicleSeat.SEAT_ROW_1_LEFT); + assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_1_CENTER, + VehicleSeat.SEAT_ROW_1_CENTER); + assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_1_RIGHT, + VehicleSeat.SEAT_ROW_1_RIGHT); + assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_2_LEFT, + VehicleSeat.SEAT_ROW_2_LEFT); + assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_2_CENTER, + VehicleSeat.SEAT_ROW_2_CENTER); + assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_2_RIGHT, + VehicleSeat.SEAT_ROW_2_RIGHT); + assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_3_LEFT, + VehicleSeat.SEAT_ROW_3_LEFT); + assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_3_CENTER, + VehicleSeat.SEAT_ROW_3_CENTER); + assertEquals(VehicleNetworkConsts.VehicleSeat.VEHICLE_SEAT_ROW_3_RIGHT, + VehicleSeat.SEAT_ROW_3_RIGHT); } } diff --git a/tests/android_support_car_api_test/src/com/android/support/car/apitest/CarNavigationStatusManagerTest.java b/tests/android_support_car_api_test/src/com/android/support/car/apitest/CarNavigationStatusManagerTest.java index 0d6bcb79ec..538407e41d 100644 --- a/tests/android_support_car_api_test/src/com/android/support/car/apitest/CarNavigationStatusManagerTest.java +++ b/tests/android_support_car_api_test/src/com/android/support/car/apitest/CarNavigationStatusManagerTest.java @@ -49,14 +49,14 @@ public class CarNavigationStatusManagerTest extends CarApiTestBase { public void testStart() throws Exception { final CountDownLatch onStartLatch = new CountDownLatch(1); - mCarNavigationStatusManager.addListener(new CarNavigationStatusManager.CarNavigationCallback() { + mCarNavigationStatusManager.addListener( + new CarNavigationStatusManager.CarNavigationCallback() { @Override public void onInstrumentClusterStarted(CarNavigationStatusManager manager, CarNavigationInstrumentCluster instrumentCluster) { - // TODO: we should use VehicleHalMock once we implement HAL support in - // CarNavigationStatusService. - assertFalse(instrumentCluster.supportsCustomImages()); - assertEquals(1000, instrumentCluster.getMinIntervalMillis()); + // return type cannot be asserted. + instrumentCluster.supportsCustomImages(); + instrumentCluster.getMinIntervalMillis(); onStartLatch.countDown(); } diff --git a/tests/carservice_test/src/com/android/car/test/CarCabinManagerTest.java b/tests/carservice_test/src/com/android/car/test/CarCabinManagerTest.java index c641933540..bf13bda270 100644 --- a/tests/carservice_test/src/com/android/car/test/CarCabinManagerTest.java +++ b/tests/carservice_test/src/com/android/car/test/CarCabinManagerTest.java @@ -18,8 +18,7 @@ package com.android.car.test; import android.car.Car; import android.car.hardware.cabin.CarCabinManager; -import android.car.hardware.cabin.CarCabinManager.CarCabinEventListener; -import android.car.hardware.cabin.CarCabinManager.CabinPropertyId; +import android.car.hardware.cabin.CarCabinManager.CarCabinEventCallback; import android.car.hardware.CarPropertyValue; import android.car.test.VehicleHalEmulator; import android.test.suitebuilder.annotation.MediumTest; @@ -80,37 +79,37 @@ public class CarCabinManagerTest extends MockedCarTestBase { // Test a boolean property public void testCabinDoorLockOn() throws Exception { - mCarCabinManager.setBooleanProperty(CabinPropertyId.DOOR_LOCK, + mCarCabinManager.setBooleanProperty(CarCabinManager.ID_DOOR_LOCK, VehicleDoor.VEHICLE_DOOR_ROW_1_LEFT, true); - boolean lock = mCarCabinManager.getBooleanProperty(CabinPropertyId.DOOR_LOCK, + boolean lock = mCarCabinManager.getBooleanProperty(CarCabinManager.ID_DOOR_LOCK, VehicleDoor.VEHICLE_DOOR_ROW_1_LEFT); assertTrue(lock); - mCarCabinManager.setBooleanProperty(CabinPropertyId.DOOR_LOCK, + mCarCabinManager.setBooleanProperty(CarCabinManager.ID_DOOR_LOCK, VehicleDoor.VEHICLE_DOOR_ROW_1_LEFT, false); - lock = mCarCabinManager.getBooleanProperty(CabinPropertyId.DOOR_LOCK, + lock = mCarCabinManager.getBooleanProperty(CarCabinManager.ID_DOOR_LOCK, VehicleDoor.VEHICLE_DOOR_ROW_1_LEFT); assertFalse(lock); } // Test an integer property public void testCabinWindowPos() throws Exception { - mCarCabinManager.setIntProperty(CabinPropertyId.WINDOW_POS, + mCarCabinManager.setIntProperty(CarCabinManager.ID_WINDOW_POS, VehicleWindow.VEHICLE_WINDOW_ROW_1_LEFT, 50); - int windowPos = mCarCabinManager.getIntProperty(CabinPropertyId.WINDOW_POS, + int windowPos = mCarCabinManager.getIntProperty(CarCabinManager.ID_WINDOW_POS, VehicleWindow.VEHICLE_WINDOW_ROW_1_LEFT); assertEquals(50, windowPos); - mCarCabinManager.setIntProperty(CabinPropertyId.WINDOW_POS, + mCarCabinManager.setIntProperty(CarCabinManager.ID_WINDOW_POS, VehicleWindow.VEHICLE_WINDOW_ROW_1_LEFT, 25); - windowPos = mCarCabinManager.getIntProperty(CabinPropertyId.WINDOW_POS, + windowPos = mCarCabinManager.getIntProperty(CarCabinManager.ID_WINDOW_POS, VehicleWindow.VEHICLE_WINDOW_ROW_1_LEFT); assertEquals(25, windowPos); } // Test an event public void testEvent() throws Exception { - mCarCabinManager.registerListener(new EventListener()); + mCarCabinManager.registerCallback(new EventListener()); // Inject a boolean event and wait for its callback in onPropertySet. VehiclePropValue v = VehiclePropValueUtil.createZonedBooleanValue( @@ -163,7 +162,7 @@ public class CarCabinManagerTest extends MockedCarTestBase { } } - private class EventListener implements CarCabinEventListener { + private class EventListener implements CarCabinEventCallback { public EventListener() { } @Override diff --git a/tests/carservice_test/src/com/android/car/test/CarHvacManagerTest.java b/tests/carservice_test/src/com/android/car/test/CarHvacManagerTest.java index 0b28e8b427..c4221734a1 100644 --- a/tests/carservice_test/src/com/android/car/test/CarHvacManagerTest.java +++ b/tests/carservice_test/src/com/android/car/test/CarHvacManagerTest.java @@ -18,8 +18,7 @@ package com.android.car.test; import android.car.Car; import android.car.hardware.hvac.CarHvacManager; -import android.car.hardware.hvac.CarHvacManager.CarHvacEventListener; -import android.car.hardware.hvac.CarHvacManager.HvacPropertyId; +import android.car.hardware.hvac.CarHvacManager.CarHvacEventCallback; import android.car.hardware.CarPropertyValue; import android.car.test.VehicleHalEmulator; import android.test.suitebuilder.annotation.MediumTest; @@ -96,52 +95,52 @@ public class CarHvacManagerTest extends MockedCarTestBase { // Test a boolean property public void testHvacRearDefrosterOn() throws Exception { - mCarHvacManager.setBooleanProperty(HvacPropertyId.WINDOW_DEFROSTER_ON, + mCarHvacManager.setBooleanProperty(CarHvacManager.ID_WINDOW_DEFROSTER_ON, VehicleWindow.VEHICLE_WINDOW_FRONT_WINDSHIELD, true); - boolean defrost = mCarHvacManager.getBooleanProperty(HvacPropertyId.WINDOW_DEFROSTER_ON, + boolean defrost = mCarHvacManager.getBooleanProperty(CarHvacManager.ID_WINDOW_DEFROSTER_ON, VehicleWindow.VEHICLE_WINDOW_FRONT_WINDSHIELD); assertTrue(defrost); - mCarHvacManager.setBooleanProperty(HvacPropertyId.WINDOW_DEFROSTER_ON, + mCarHvacManager.setBooleanProperty(CarHvacManager.ID_WINDOW_DEFROSTER_ON, VehicleWindow.VEHICLE_WINDOW_FRONT_WINDSHIELD, false); - defrost = mCarHvacManager.getBooleanProperty(HvacPropertyId.WINDOW_DEFROSTER_ON, + defrost = mCarHvacManager.getBooleanProperty(CarHvacManager.ID_WINDOW_DEFROSTER_ON, VehicleWindow.VEHICLE_WINDOW_FRONT_WINDSHIELD); assertFalse(defrost); } // Test an integer property public void testHvacFanSpeed() throws Exception { - mCarHvacManager.setIntProperty(HvacPropertyId.ZONED_FAN_SPEED_SETPOINT, + mCarHvacManager.setIntProperty(CarHvacManager.ID_ZONED_FAN_SPEED_SETPOINT, VehicleZone.VEHICLE_ZONE_ROW_1_LEFT, 15); - int speed = mCarHvacManager.getIntProperty(HvacPropertyId.ZONED_FAN_SPEED_SETPOINT, + int speed = mCarHvacManager.getIntProperty(CarHvacManager.ID_ZONED_FAN_SPEED_SETPOINT, VehicleZone.VEHICLE_ZONE_ROW_1_LEFT); assertEquals(15, speed); - mCarHvacManager.setIntProperty(HvacPropertyId.ZONED_FAN_SPEED_SETPOINT, + mCarHvacManager.setIntProperty(CarHvacManager.ID_ZONED_FAN_SPEED_SETPOINT, VehicleZone.VEHICLE_ZONE_ROW_1_LEFT, 23); - speed = mCarHvacManager.getIntProperty(HvacPropertyId.ZONED_FAN_SPEED_SETPOINT, + speed = mCarHvacManager.getIntProperty(CarHvacManager.ID_ZONED_FAN_SPEED_SETPOINT, VehicleZone.VEHICLE_ZONE_ROW_1_LEFT); assertEquals(23, speed); } // Test an float property public void testHvacTempSetpoint() throws Exception { - mCarHvacManager.setFloatProperty(HvacPropertyId.ZONED_TEMP_SETPOINT, + mCarHvacManager.setFloatProperty(CarHvacManager.ID_ZONED_TEMP_SETPOINT, VehicleZone.VEHICLE_ZONE_ROW_1_LEFT, 70); - float temp = mCarHvacManager.getFloatProperty(HvacPropertyId.ZONED_TEMP_SETPOINT, + float temp = mCarHvacManager.getFloatProperty(CarHvacManager.ID_ZONED_TEMP_SETPOINT, VehicleZone.VEHICLE_ZONE_ROW_1_LEFT); assertEquals(70.0, temp, 0); - mCarHvacManager.setFloatProperty(HvacPropertyId.ZONED_TEMP_SETPOINT, + mCarHvacManager.setFloatProperty(CarHvacManager.ID_ZONED_TEMP_SETPOINT, VehicleZone.VEHICLE_ZONE_ROW_1_LEFT, (float) 65.5); - temp = mCarHvacManager.getFloatProperty(HvacPropertyId.ZONED_TEMP_SETPOINT, + temp = mCarHvacManager.getFloatProperty(CarHvacManager.ID_ZONED_TEMP_SETPOINT, VehicleZone.VEHICLE_ZONE_ROW_1_LEFT); assertEquals(65.5, temp, 0); } // Test an event public void testEvent() throws Exception { - mCarHvacManager.registerListener(new EventListener()); + mCarHvacManager.registerCallback(new EventListener()); // Inject a boolean event and wait for its callback in onPropertySet. VehiclePropValue v = VehiclePropValueUtil.createZonedBooleanValue( @@ -205,7 +204,7 @@ public class CarHvacManagerTest extends MockedCarTestBase { } } - private class EventListener implements CarHvacEventListener { + private class EventListener implements CarHvacEventCallback { public EventListener() { } @Override |