aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-08-15 07:30:04 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-08-15 07:30:04 +0000
commit24938cf65b47a5b6fa956ca18070247311a5f9f6 (patch)
tree991ce877a0892d931d54f5eee881a61511cf27c0
parent48674c6f3a1b2929f437c6a0ff29df49aca90984 (diff)
parent4d29f62d152fe176d57b35464b440845dfd3d769 (diff)
downloadCar-24938cf65b47a5b6fa956ca18070247311a5f9f6.tar.gz
release-request-e73a0a41-91c3-4249-808e-8d196d54a344-for-git_oc-mr1-release-4273744 snap-temp-L04700000093069831
Change-Id: I888696f7555504ccfcfe68cc8cfa0ed587dc24c2
-rw-r--r--car-cluster-logging-renderer/Android.mk3
-rw-r--r--car-lib/Android.mk2
-rw-r--r--car-lib/src/android/car/hardware/CarSensorConfig.aidl19
-rw-r--r--car-lib/src/android/car/hardware/CarSensorConfig.java125
-rw-r--r--car-lib/src/android/car/hardware/CarSensorManager.java25
-rw-r--r--car-lib/src/android/car/hardware/ICarSensor.aidl6
-rw-r--r--car-support-lib/src/android/support/car/hardware/CarSensorConfig.java98
-rw-r--r--car-support-lib/src/android/support/car/hardware/CarSensorManager.java11
-rw-r--r--car-support-lib/src/android/support/car/hardware/CarSensorManagerEmbedded.java17
-rw-r--r--service/Android.mk10
-rw-r--r--service/src/com/android/car/CarSensorService.java17
-rw-r--r--service/src/com/android/car/ICarImpl.java4
-rw-r--r--service/src/com/android/car/hal/SensorHalService.java137
-rw-r--r--tests/EmbeddedKitchenSinkApp/Android.mk3
-rw-r--r--tests/EmbeddedKitchenSinkApp/res/layout/bluetooth_headset.xml5
-rw-r--r--tests/EmbeddedKitchenSinkApp/res/values/strings.xml2
-rw-r--r--tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/audio/AudioPlayer.java3
-rw-r--r--tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/audio/AudioTestFragment.java4
-rw-r--r--tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/bluetooth/BluetoothHeadsetFragment.java31
-rw-r--r--tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/sensor/SensorsTestFragment.java14
-rw-r--r--tests/android_car_api_test/Android.mk3
-rw-r--r--tests/carservice_test/src/com/android/car/test/SystemActivityMonitoringServiceTest.java5
-rw-r--r--tests/vehiclehal_test/Android.mk5
-rw-r--r--vehicle-hal-support-lib/Android.mk5
-rw-r--r--vehicle-hal-support-lib/src/com/android/car/vehiclehal/test/MockedVehicleHal.java23
25 files changed, 515 insertions, 62 deletions
diff --git a/car-cluster-logging-renderer/Android.mk b/car-cluster-logging-renderer/Android.mk
index 8fb76748c9..dd1d0cab4e 100644
--- a/car-cluster-logging-renderer/Android.mk
+++ b/car-cluster-logging-renderer/Android.mk
@@ -13,7 +13,7 @@
# limitations under the License.
#
#
-
+ifneq ($(TARGET_BUILD_PDK),true)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
@@ -32,3 +32,4 @@ LOCAL_PROGUARD_ENABLED := disabled
LOCAL_JAVA_LIBRARIES += android.car
include $(BUILD_PACKAGE)
+endif
diff --git a/car-lib/Android.mk b/car-lib/Android.mk
index a07e940376..53be4a761b 100644
--- a/car-lib/Android.mk
+++ b/car-lib/Android.mk
@@ -37,6 +37,7 @@ else
car_lib_sources += $(call all-java-files-under, src_feature_current)
endif
car_lib_sources += $(call all-Iaidl-files-under, src)
+LOCAL_AIDL_INCLUDES += system/bt/binder
LOCAL_SRC_FILES := $(car_lib_sources)
@@ -65,6 +66,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := android.car7
LOCAL_SRC_FILES := $(car_lib_sources)
LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_AIDL_INCLUDES += system/bt/binder
ifeq ($(EMMA_INSTRUMENT_FRAMEWORK),true)
LOCAL_EMMA_INSTRUMENT := true
diff --git a/car-lib/src/android/car/hardware/CarSensorConfig.aidl b/car-lib/src/android/car/hardware/CarSensorConfig.aidl
new file mode 100644
index 0000000000..480f751c54
--- /dev/null
+++ b/car-lib/src/android/car/hardware/CarSensorConfig.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 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.hardware;
+
+parcelable CarSensorConfig;
diff --git a/car-lib/src/android/car/hardware/CarSensorConfig.java b/car-lib/src/android/car/hardware/CarSensorConfig.java
new file mode 100644
index 0000000000..8ba456b0cf
--- /dev/null
+++ b/car-lib/src/android/car/hardware/CarSensorConfig.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2017 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.hardware;
+
+import android.os.Bundle;
+import android.os.Parcel;
+import android.os.Parcelable;
+import java.util.ArrayList;
+
+/**
+ * A CarSensorConfig object corresponds to a single sensor type coming from the car.
+ * @hide
+ */
+public class CarSensorConfig implements Parcelable {
+ /** List of property specific mapped elements in bundle for WHEEL_TICK_DISTANCE sensor*/
+ /** @hide */
+ public final static String WHEEL_TICK_DISTANCE_SUPPORTED_WHEELS =
+ "android.car.wheelTickDistanceSupportedWhheels";
+ /** @hide */
+ public final static String WHEEL_TICK_DISTANCE_FRONT_LEFT_UM_PER_TICK =
+ "android.car.wheelTickDistanceFrontLeftUmPerTick";
+ /** @hide */
+ public final static String WHEEL_TICK_DISTANCE_FRONT_RIGHT_UM_PER_TICK =
+ "android.car.wheelTickDistanceFrontRightUmPerTick";
+ /** @hide */
+ public final static String WHEEL_TICK_DISTANCE_REAR_RIGHT_UM_PER_TICK =
+ "android.car.wheelTickDistanceRearRightUmPerTick";
+ /** @hide */
+ public final static String WHEEL_TICK_DISTANCE_REAR_LEFT_UM_PER_TICK =
+ "android.car.wheelTickDistanceRearLeftUmPerTick";
+
+ /** Config data stored in Bundle */
+ private final Bundle mConfig;
+ private final int mType;
+
+ /** @hide */
+ public CarSensorConfig(Parcel in) {
+ mType = in.readInt();
+ mConfig = in.readBundle();
+ }
+
+ /** @hide */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** @hide */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mType);
+ dest.writeBundle(mConfig);
+ }
+
+ /** @hide */
+ public static final Parcelable.Creator<CarSensorConfig> CREATOR
+ = new Parcelable.Creator<CarSensorConfig>() {
+ public CarSensorConfig createFromParcel(Parcel in) {
+ return new CarSensorConfig(in);
+ }
+
+ public CarSensorConfig[] newArray(int size) {
+ return new CarSensorConfig[size];
+ }
+ };
+
+ /** @hide */
+ public CarSensorConfig(int type, Bundle b) {
+ mType = type;
+ mConfig = b.deepCopy();
+ }
+
+ private void checkType(int type) {
+ if (mType == type) {
+ return;
+ }
+ throw new UnsupportedOperationException(String.format(
+ "Invalid sensor type: expected %d, got %d", type, mType));
+ }
+
+ /** @hide */
+ public Bundle getBundle() {
+ return mConfig;
+ }
+
+ /** @hide */
+ public int getInt(String key) {
+ if (mConfig.containsKey(key)) {
+ return mConfig.getInt(key);
+ } else {
+ throw new IllegalArgumentException("SensorType " + mType +
+ " does not contain key: " + key);
+ }
+ }
+
+ /** @hide */
+ public int getType() {
+ return mType;
+ }
+
+ /** @hide */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getClass().getName() + "[");
+ sb.append("mType: " + mType);
+ sb.append("mConfig: " + mConfig.toString());
+ sb.append("]");
+ return sb.toString();
+ }
+}
diff --git a/car-lib/src/android/car/hardware/CarSensorManager.java b/car-lib/src/android/car/hardware/CarSensorManager.java
index 796da7f978..e2bce11b78 100644
--- a/car-lib/src/android/car/hardware/CarSensorManager.java
+++ b/car-lib/src/android/car/hardware/CarSensorManager.java
@@ -25,6 +25,7 @@ import android.car.CarLibLog;
import android.car.CarManagerBase;
import android.car.CarNotConnectedException;
import android.content.Context;
+import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
@@ -513,4 +514,28 @@ public final class CarSensorManager implements CarManagerBase {
});
}
}
+
+ /**
+ * Get the config data for the given type.
+ *
+ * A CarSensorConfig object is returned for every sensor type. However, if there is no
+ * config, the data will be empty.
+ *
+ * @param sensor type to request
+ * @return CarSensorConfig object
+ * @throws CarNotConnectedException if the connection to the car service has been lost.
+ * @hide
+ */
+ public CarSensorConfig getSensorConfig(@SensorType int type)
+ throws CarNotConnectedException {
+ assertSensorType(type);
+ try {
+ return mService.getSensorConfig(type);
+ } catch (IllegalStateException e) {
+ CarApiUtil.checkCarNotConnectedExceptionFromCarService(e);
+ } catch(RemoteException e) {
+ handleCarServiceRemoteExceptionAndThrow(e);
+ }
+ return new CarSensorConfig(0, Bundle.EMPTY);
+ }
}
diff --git a/car-lib/src/android/car/hardware/ICarSensor.aidl b/car-lib/src/android/car/hardware/ICarSensor.aidl
index 6f9e3153fc..e943e0f296 100644
--- a/car-lib/src/android/car/hardware/ICarSensor.aidl
+++ b/car-lib/src/android/car/hardware/ICarSensor.aidl
@@ -16,6 +16,7 @@
package android.car.hardware;
+import android.car.hardware.CarSensorConfig;
import android.car.hardware.CarSensorEvent;
import android.car.hardware.ICarSensorEventListener;
@@ -44,4 +45,9 @@ interface ICarSensor {
* be affected.
*/
void unregisterSensorListener(int sensorType, in ICarSensorEventListener callback) = 3;
+
+ /**
+ * get config flags and config array for the sensor type
+ */
+ CarSensorConfig getSensorConfig(int sensorType) = 4;
}
diff --git a/car-support-lib/src/android/support/car/hardware/CarSensorConfig.java b/car-support-lib/src/android/support/car/hardware/CarSensorConfig.java
new file mode 100644
index 0000000000..3c71e04cc7
--- /dev/null
+++ b/car-support-lib/src/android/support/car/hardware/CarSensorConfig.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2017 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.support.car.hardware;
+
+import android.os.Bundle;
+import android.support.annotation.RestrictTo;
+import java.util.ArrayList;
+
+import static android.support.annotation.RestrictTo.Scope.GROUP_ID;
+
+/**
+ * A CarSensorConfig object corresponds to a single sensor type coming from the car.
+ * @hide
+ */
+public class CarSensorConfig {
+ /** List of property specific mapped elements in bundle for WHEEL_TICK_DISTANCE sensor*/
+ /** @hide */
+ public final static String WHEEL_TICK_DISTANCE_SUPPORTED_WHEELS =
+ "android.car.wheelTickDistanceSupportedWhheels";
+ /** @hide */
+ public final static String WHEEL_TICK_DISTANCE_FRONT_LEFT_UM_PER_TICK =
+ "android.car.wheelTickDistanceFrontLeftUmPerTick";
+ /** @hide */
+ public final static String WHEEL_TICK_DISTANCE_FRONT_RIGHT_UM_PER_TICK =
+ "android.car.wheelTickDistanceFrontRightUmPerTick";
+ /** @hide */
+ public final static String WHEEL_TICK_DISTANCE_REAR_RIGHT_UM_PER_TICK =
+ "android.car.wheelTickDistanceRearRightUmPerTick";
+ /** @hide */
+ public final static String WHEEL_TICK_DISTANCE_REAR_LEFT_UM_PER_TICK =
+ "android.car.wheelTickDistanceRearLeftUmPerTick";
+
+ /** Config data stored in Bundle */
+ private final Bundle mConfig;
+ private final int mType;
+
+ private final static int RAW_BUNDLE_SIZE = 4;
+ private final static int WHEEL_TICK_DISTANCE_BUNDLE_SIZE = 6;
+
+ /**
+ * Constructs a {@link CarSensorConfig}. Handled by CarSensorManager implementations.
+ * App developers need not worry about constructing these objects.
+ * @hide
+ */
+ @RestrictTo(GROUP_ID)
+ public CarSensorConfig(int type, Bundle in) {
+ mType = type;
+ mConfig = in.deepCopy();
+ }
+
+ private void checkType(int type) {
+ if (mType == type) {
+ return;
+ }
+ throw new UnsupportedOperationException(String.format(
+ "Invalid sensor type: expected %d, got %d", type, mType));
+ }
+
+ /** @hide */
+ public int getInt(String key) {
+ if (mConfig.containsKey(key)) {
+ return mConfig.getInt(key);
+ } else {
+ throw new IllegalArgumentException("SensorType " + mType +
+ " does not contain key: " + key);
+ }
+ }
+
+ /** @hide */
+ public int getType() {
+ return mType;
+ }
+
+ /** @hide */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getClass().getName() + "[");
+ sb.append("mConfig: " + mConfig.toString());
+ sb.append("mType: " + mType);
+ sb.append("]");
+ return sb.toString();
+ }
+}
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 f705a9f4e3..8bddce1d0a 100644
--- a/car-support-lib/src/android/support/car/hardware/CarSensorManager.java
+++ b/car-support-lib/src/android/support/car/hardware/CarSensorManager.java
@@ -280,4 +280,15 @@ public abstract class CarSensorManager implements CarManagerBase {
*/
public abstract CarSensorEvent getLatestSensorEvent(@SensorType int type)
throws CarNotConnectedException;
+
+ /**
+ * Get the config data for the given type.
+ * @param sensor type to request
+ * @return CarSensorConfig object
+ * @throws CarNotConnectedException if the connection to the car service has been lost.
+ * @hide
+ */
+ public abstract CarSensorConfig getSensorConfig(@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 5fa207cc9f..0fde10ff26 100644
--- a/car-support-lib/src/android/support/car/hardware/CarSensorManagerEmbedded.java
+++ b/car-support-lib/src/android/support/car/hardware/CarSensorManagerEmbedded.java
@@ -155,6 +155,16 @@ public class CarSensorManagerEmbedded extends CarSensorManager {
}
@Override
+ public CarSensorConfig getSensorConfig(@SensorType int type)
+ throws CarNotConnectedException {
+ try {
+ return convert(mManager.getSensorConfig(type));
+ } catch (android.car.CarNotConnectedException e) {
+ throw new CarNotConnectedException(e);
+ }
+ }
+
+ @Override
public void onCarDisconnected() {
//nothing to do
}
@@ -176,6 +186,13 @@ public class CarSensorManagerEmbedded extends CarSensorManager {
event.intValues, event.longValues);
}
+ private static CarSensorConfig convert(android.car.hardware.CarSensorConfig cfg) {
+ if (cfg == null) {
+ return null;
+ }
+ return new CarSensorConfig(cfg.getType(), cfg.getBundle());
+ }
+
private static class OnSensorChangedListenerProxy
implements android.car.hardware.CarSensorManager.OnSensorChangedListener {
diff --git a/service/Android.mk b/service/Android.mk
index 46bb9da1b5..9bd5e124a5 100644
--- a/service/Android.mk
+++ b/service/Android.mk
@@ -38,8 +38,9 @@ LOCAL_PROGUARD_ENABLED := disabled
LOCAL_JAVA_LIBRARIES += android.car
LOCAL_STATIC_JAVA_LIBRARIES += \
- android.hardware.automotive.vehicle-V2.0-java-static \
- android.hardware.automotive.vehicle-V2.1-java-static \
+ android.hidl.base-V1.0-java \
+ android.hardware.automotive.vehicle-V2.0-java \
+ android.hardware.automotive.vehicle-V2.1-java \
vehicle-hal-support-lib \
car-systemtest \
@@ -57,8 +58,9 @@ LOCAL_MODULE := car-service-lib-for-test
LOCAL_JAVA_LIBRARIES += android.car
LOCAL_STATIC_JAVA_LIBRARIES += \
- android.hardware.automotive.vehicle-V2.0-java-static \
- android.hardware.automotive.vehicle-V2.1-java-static \
+ android.hidl.base-V1.0-java \
+ android.hardware.automotive.vehicle-V2.0-java \
+ android.hardware.automotive.vehicle-V2.1-java \
vehicle-hal-support-lib \
car-systemtest \
diff --git a/service/src/com/android/car/CarSensorService.java b/service/src/com/android/car/CarSensorService.java
index 44a33b4bae..171a8c4bf4 100644
--- a/service/src/com/android/car/CarSensorService.java
+++ b/service/src/com/android/car/CarSensorService.java
@@ -17,6 +17,7 @@
package com.android.car;
import android.car.Car;
+import android.car.hardware.CarSensorConfig;
import android.car.hardware.CarSensorEvent;
import android.car.hardware.CarSensorManager;
import android.car.hardware.ICarSensor;
@@ -565,6 +566,22 @@ public class CarSensorService extends ICarSensor.Stub
}
}
+ @Override
+ public CarSensorConfig getSensorConfig(int sensorType) {
+ if (Binder.getCallingUid() != Process.myUid()) {
+ switch (getSensorPermission(sensorType)) {
+ case PackageManager.PERMISSION_DENIED:
+ throw new SecurityException("client does not have permission:"
+ + getPermissionName(sensorType)
+ + " pid:" + Binder.getCallingPid()
+ + " uid:" + Binder.getCallingUid());
+ case PackageManager.PERMISSION_GRANTED:
+ break;
+ }
+ }
+ return(mSensorHal.getSensorConfig(sensorType));
+ }
+
private void stopSensor(SensorRecord record, int sensorType) {
if (Log.isLoggable(CarLog.TAG_SENSOR, Log.DEBUG)) {
Log.d(CarLog.TAG_SENSOR, "stopSensor " + sensorType);
diff --git a/service/src/com/android/car/ICarImpl.java b/service/src/com/android/car/ICarImpl.java
index c412b97e14..5b01bcf089 100644
--- a/service/src/com/android/car/ICarImpl.java
+++ b/service/src/com/android/car/ICarImpl.java
@@ -28,9 +28,9 @@ import android.os.Binder;
import android.os.IBinder;
import android.os.Process;
import android.os.Trace;
-import android.util.BootTimingsTraceLog;
import android.util.Log;
import android.util.Slog;
+import android.util.TimingsTraceLog;
import com.android.car.cluster.InstrumentClusterService;
import com.android.car.hal.VehicleHal;
import com.android.car.internal.FeatureConfiguration;
@@ -81,7 +81,7 @@ public class ICarImpl extends ICar.Stub {
private static final String TAG = "ICarImpl";
private static final String VHAL_TIMING_TAG = "VehicleHalTiming";
- private static final BootTimingsTraceLog mBootTiming = new BootTimingsTraceLog(VHAL_TIMING_TAG,
+ private static final TimingsTraceLog mBootTiming = new TimingsTraceLog(VHAL_TIMING_TAG,
Trace.TRACE_TAG_HAL);
/** Test only service. Populate it only when necessary. */
diff --git a/service/src/com/android/car/hal/SensorHalService.java b/service/src/com/android/car/hal/SensorHalService.java
index 2b84fc4ecf..cf29f810cf 100644
--- a/service/src/com/android/car/hal/SensorHalService.java
+++ b/service/src/com/android/car/hal/SensorHalService.java
@@ -19,6 +19,7 @@ package com.android.car.hal;
import static java.lang.Integer.toHexString;
import android.annotation.Nullable;
+import android.car.hardware.CarSensorConfig;
import android.car.hardware.CarSensorEvent;
import android.car.hardware.CarSensorManager;
import android.hardware.automotive.vehicle.V2_0.VehicleGear;
@@ -29,11 +30,13 @@ import android.hardware.automotive.vehicle.V2_1.VehicleProperty;
import android.hardware.automotive.vehicle.V2_0.VehiclePropertyAccess;
import android.hardware.automotive.vehicle.V2_0.VehiclePropertyChangeMode;
import android.hardware.automotive.vehicle.V2_0.VehiclePropertyType;
+import android.os.Bundle;
import android.util.Log;
import android.util.SparseIntArray;
import com.android.car.CarLog;
import com.android.car.CarSensorEventFactory;
import java.io.PrintWriter;
+import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@@ -50,6 +53,7 @@ public class SensorHalService extends SensorHalServiceBase {
public interface SensorListener {
/**
* Sensor events are available.
+ *
* @param events
*/
void onSensorEvents(List<CarSensorEvent> events);
@@ -57,44 +61,44 @@ public class SensorHalService extends SensorHalServiceBase {
// Manager property Id to HAL property Id mapping.
private final static ManagerToHalPropIdMap mManagerToHalPropIdMap =
- ManagerToHalPropIdMap.create(
- CarSensorManager.SENSOR_TYPE_CAR_SPEED, VehicleProperty.PERF_VEHICLE_SPEED,
- CarSensorManager.SENSOR_TYPE_RPM, VehicleProperty.ENGINE_RPM,
- CarSensorManager.SENSOR_TYPE_ODOMETER, VehicleProperty.PERF_ODOMETER,
- CarSensorManager.SENSOR_TYPE_GEAR, VehicleProperty.GEAR_SELECTION,
- CarSensorManager.SENSOR_TYPE_NIGHT, VehicleProperty.NIGHT_MODE,
- CarSensorManager.SENSOR_TYPE_PARKING_BRAKE, VehicleProperty.PARKING_BRAKE_ON,
- CarSensorManager.SENSOR_TYPE_DRIVING_STATUS, VehicleProperty.DRIVING_STATUS,
- CarSensorManager.SENSOR_TYPE_FUEL_LEVEL, VehicleProperty.FUEL_LEVEL_LOW,
- CarSensorManager.SENSOR_TYPE_IGNITION_STATE, VehicleProperty.IGNITION_STATE,
- CarSensorManager.SENSOR_TYPE_WHEEL_TICK_DISTANCE, VehicleProperty.WHEEL_TICK,
- CarSensorManager.SENSOR_TYPE_ABS_ACTIVE, VehicleProperty.ABS_ACTIVE,
- CarSensorManager.SENSOR_TYPE_TRACTION_CONTROL_ACTIVE,
- VehicleProperty.TRACTION_CONTROL_ACTIVE
- );
+ ManagerToHalPropIdMap.create(
+ CarSensorManager.SENSOR_TYPE_CAR_SPEED, VehicleProperty.PERF_VEHICLE_SPEED,
+ CarSensorManager.SENSOR_TYPE_RPM, VehicleProperty.ENGINE_RPM,
+ CarSensorManager.SENSOR_TYPE_ODOMETER, VehicleProperty.PERF_ODOMETER,
+ CarSensorManager.SENSOR_TYPE_GEAR, VehicleProperty.GEAR_SELECTION,
+ CarSensorManager.SENSOR_TYPE_NIGHT, VehicleProperty.NIGHT_MODE,
+ CarSensorManager.SENSOR_TYPE_PARKING_BRAKE, VehicleProperty.PARKING_BRAKE_ON,
+ CarSensorManager.SENSOR_TYPE_DRIVING_STATUS, VehicleProperty.DRIVING_STATUS,
+ CarSensorManager.SENSOR_TYPE_FUEL_LEVEL, VehicleProperty.FUEL_LEVEL_LOW,
+ CarSensorManager.SENSOR_TYPE_IGNITION_STATE, VehicleProperty.IGNITION_STATE,
+ CarSensorManager.SENSOR_TYPE_WHEEL_TICK_DISTANCE, VehicleProperty.WHEEL_TICK,
+ CarSensorManager.SENSOR_TYPE_ABS_ACTIVE, VehicleProperty.ABS_ACTIVE,
+ CarSensorManager.SENSOR_TYPE_TRACTION_CONTROL_ACTIVE,
+ VehicleProperty.TRACTION_CONTROL_ACTIVE
+ );
private final static SparseIntArray mMgrGearToHalMap = initSparseIntArray(
- VehicleGear.GEAR_NEUTRAL, CarSensorEvent.GEAR_NEUTRAL,
- VehicleGear.GEAR_REVERSE, CarSensorEvent.GEAR_REVERSE,
- VehicleGear.GEAR_PARK, CarSensorEvent.GEAR_PARK,
- VehicleGear.GEAR_DRIVE, CarSensorEvent.GEAR_DRIVE,
- VehicleGear.GEAR_LOW, CarSensorEvent.GEAR_FIRST, // Also GEAR_1 - the value is the same.
- VehicleGear.GEAR_2, CarSensorEvent.GEAR_SECOND,
- VehicleGear.GEAR_3, CarSensorEvent.GEAR_THIRD,
- VehicleGear.GEAR_4, CarSensorEvent.GEAR_FOURTH,
- VehicleGear.GEAR_5, CarSensorEvent.GEAR_FIFTH,
- VehicleGear.GEAR_6, CarSensorEvent.GEAR_SIXTH,
- VehicleGear.GEAR_7, CarSensorEvent.GEAR_SEVENTH,
- VehicleGear.GEAR_8, CarSensorEvent.GEAR_EIGHTH,
- VehicleGear.GEAR_9, CarSensorEvent.GEAR_NINTH);
+ VehicleGear.GEAR_NEUTRAL, CarSensorEvent.GEAR_NEUTRAL,
+ VehicleGear.GEAR_REVERSE, CarSensorEvent.GEAR_REVERSE,
+ VehicleGear.GEAR_PARK, CarSensorEvent.GEAR_PARK,
+ VehicleGear.GEAR_DRIVE, CarSensorEvent.GEAR_DRIVE,
+ VehicleGear.GEAR_LOW, CarSensorEvent.GEAR_FIRST, // Also GEAR_1 - the value is the same.
+ VehicleGear.GEAR_2, CarSensorEvent.GEAR_SECOND,
+ VehicleGear.GEAR_3, CarSensorEvent.GEAR_THIRD,
+ VehicleGear.GEAR_4, CarSensorEvent.GEAR_FOURTH,
+ VehicleGear.GEAR_5, CarSensorEvent.GEAR_FIFTH,
+ VehicleGear.GEAR_6, CarSensorEvent.GEAR_SIXTH,
+ VehicleGear.GEAR_7, CarSensorEvent.GEAR_SEVENTH,
+ VehicleGear.GEAR_8, CarSensorEvent.GEAR_EIGHTH,
+ VehicleGear.GEAR_9, CarSensorEvent.GEAR_NINTH);
private final static SparseIntArray mMgrIgnitionStateToHalMap = initSparseIntArray(
- VehicleIgnitionState.UNDEFINED, CarSensorEvent.IGNITION_STATE_UNDEFINED,
- VehicleIgnitionState.LOCK, CarSensorEvent.IGNITION_STATE_LOCK,
- VehicleIgnitionState.OFF, CarSensorEvent.IGNITION_STATE_OFF,
- VehicleIgnitionState.ACC, CarSensorEvent.IGNITION_STATE_ACC,
- VehicleIgnitionState.ON, CarSensorEvent.IGNITION_STATE_ON,
- VehicleIgnitionState.START, CarSensorEvent.IGNITION_STATE_START);
+ VehicleIgnitionState.UNDEFINED, CarSensorEvent.IGNITION_STATE_UNDEFINED,
+ VehicleIgnitionState.LOCK, CarSensorEvent.IGNITION_STATE_LOCK,
+ VehicleIgnitionState.OFF, CarSensorEvent.IGNITION_STATE_OFF,
+ VehicleIgnitionState.ACC, CarSensorEvent.IGNITION_STATE_ACC,
+ VehicleIgnitionState.ON, CarSensorEvent.IGNITION_STATE_ON,
+ VehicleIgnitionState.START, CarSensorEvent.IGNITION_STATE_START);
private SensorListener mSensorListener;
@@ -102,15 +106,17 @@ public class SensorHalService extends SensorHalServiceBase {
@Override
public void init() {
+ VehiclePropConfig config;
// Populate internal values if available
- VehiclePropConfig config = mSensorToPropConfig.get(
- CarSensorManager.SENSOR_TYPE_WHEEL_TICK_DISTANCE);
+ synchronized (this) {
+ config = mSensorToPropConfig.get(CarSensorManager.SENSOR_TYPE_WHEEL_TICK_DISTANCE);
+ }
if (config == null) {
Log.e(TAG, "init: unable to get property config for SENSOR_TYPE_WHEEL_TICK_DISTANCE");
} else {
- for (int i=0; i<4; i++) {
- // ConfigArray starts with Wheels enum at idx 0
- mMicrometersPerWheelTick[i] = config.configArray.get(i+1);
+ for (int i = 0; i < 4; i++) {
+ mMicrometersPerWheelTick[i] = config.configArray.get(i +
+ INDEX_WHEEL_DISTANCE_FRONT_LEFT);
}
}
super.init();
@@ -137,6 +143,7 @@ public class SensorHalService extends SensorHalServiceBase {
// Should be used only inside handleHalEvents method.
private final LinkedList<CarSensorEvent> mEventsToDispatch = new LinkedList<>();
+
@Override
public void handleHalEvents(List<VehiclePropValue> values) {
for (VehiclePropValue v : values) {
@@ -165,7 +172,7 @@ public class SensorHalService extends SensorHalServiceBase {
mgrValue = mMgrGearToHalMap.get(halValue, -1);
break;
case VehicleProperty.IGNITION_STATE:
- mgrValue = mMgrIgnitionStateToHalMap.get(halValue, -1);
+ mgrValue = mMgrIgnitionStateToHalMap.get(halValue, -1);
default:
break; // Do nothing
}
@@ -192,7 +199,7 @@ public class SensorHalService extends SensorHalServiceBase {
break;
case VehiclePropertyType.INT32:
Integer mgrVal = mapHalEnumValueToMgr(property, v.value.int32Values.get(0));
- event = mgrVal == null ? null
+ event = mgrVal == null ? null
: CarSensorEventFactory.createIntEvent(sensorType, v.timestamp, mgrVal);
break;
case VehiclePropertyType.FLOAT:
@@ -283,4 +290,50 @@ public class SensorHalService extends SensorHalServiceBase {
}
return map;
}
-}
+
+ private static final int INDEX_WHEEL_DISTANCE_ENABLE_FLAG = 0;
+ private static final int INDEX_WHEEL_DISTANCE_FRONT_LEFT = 1;
+ private static final int INDEX_WHEEL_DISTANCE_FRONT_RIGHT = 2;
+ private static final int INDEX_WHEEL_DISTANCE_REAR_RIGHT = 3;
+ private static final int INDEX_WHEEL_DISTANCE_REAR_LEFT = 4;
+ private static final int WHEEL_TICK_DISTANCE_BUNDLE_SIZE = 6;
+
+ private Bundle createWheelDistanceTickBundle(ArrayList<Integer> configArray) {
+ Bundle b = new Bundle(WHEEL_TICK_DISTANCE_BUNDLE_SIZE);
+ b.putInt(CarSensorConfig.WHEEL_TICK_DISTANCE_SUPPORTED_WHEELS,
+ configArray.get(INDEX_WHEEL_DISTANCE_ENABLE_FLAG));
+ b.putInt(CarSensorConfig.WHEEL_TICK_DISTANCE_FRONT_LEFT_UM_PER_TICK,
+ configArray.get(INDEX_WHEEL_DISTANCE_FRONT_LEFT));
+ b.putInt(CarSensorConfig.WHEEL_TICK_DISTANCE_FRONT_RIGHT_UM_PER_TICK,
+ configArray.get(INDEX_WHEEL_DISTANCE_FRONT_RIGHT));
+ b.putInt(CarSensorConfig.WHEEL_TICK_DISTANCE_REAR_RIGHT_UM_PER_TICK,
+ configArray.get(INDEX_WHEEL_DISTANCE_REAR_RIGHT));
+ b.putInt(CarSensorConfig.WHEEL_TICK_DISTANCE_REAR_LEFT_UM_PER_TICK,
+ configArray.get(INDEX_WHEEL_DISTANCE_REAR_LEFT));
+ return b;
+ }
+
+
+ public CarSensorConfig getSensorConfig(int sensorType) {
+ VehiclePropConfig cfg;
+ synchronized (this) {
+ cfg = mSensorToPropConfig.get(sensorType);
+ }
+ if (cfg == null) {
+ /* Invalid sensor type. */
+ throw new IllegalArgumentException("Unknown sensorType = " + sensorType);
+ } else {
+ Bundle b;
+ switch(sensorType) {
+ case CarSensorManager.SENSOR_TYPE_WHEEL_TICK_DISTANCE:
+ b = createWheelDistanceTickBundle(cfg.configArray);
+ break;
+ default:
+ /* Unhandled config. Create empty bundle */
+ b = Bundle.EMPTY;
+ break;
+ }
+ return new CarSensorConfig(sensorType, b);
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/EmbeddedKitchenSinkApp/Android.mk b/tests/EmbeddedKitchenSinkApp/Android.mk
index d6619022ed..37c79f75a3 100644
--- a/tests/EmbeddedKitchenSinkApp/Android.mk
+++ b/tests/EmbeddedKitchenSinkApp/Android.mk
@@ -40,7 +40,8 @@ LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
LOCAL_STATIC_JAVA_LIBRARIES += \
- android.hardware.automotive.vehicle-V2.0-java-static \
+ android.hidl.base-V1.0-java \
+ android.hardware.automotive.vehicle-V2.0-java \
vehicle-hal-support-lib \
car-service-lib-for-test \
diff --git a/tests/EmbeddedKitchenSinkApp/res/layout/bluetooth_headset.xml b/tests/EmbeddedKitchenSinkApp/res/layout/bluetooth_headset.xml
index 0547a8f4f1..5dbefc10e3 100644
--- a/tests/EmbeddedKitchenSinkApp/res/layout/bluetooth_headset.xml
+++ b/tests/EmbeddedKitchenSinkApp/res/layout/bluetooth_headset.xml
@@ -57,4 +57,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bluetooth_quiet_mode_enable"/>
+ <Button
+ android:id="@+id/bluetooth_hold_call"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/bluetooth_hold_call"/>
</LinearLayout>
diff --git a/tests/EmbeddedKitchenSinkApp/res/values/strings.xml b/tests/EmbeddedKitchenSinkApp/res/values/strings.xml
index 75fbceb158..fbba2a0d0d 100644
--- a/tests/EmbeddedKitchenSinkApp/res/values/strings.xml
+++ b/tests/EmbeddedKitchenSinkApp/res/values/strings.xml
@@ -182,6 +182,7 @@
<string name="sensor_gps">GPS Satellites[%1$s]: inView: %2$s, inUse: %3$s. %4$s</string>
<string name="sensor_single_gps_satellite">(%1$s): usedInFix: %2$s, prn: %3$s, snr: %4$s, azimuth: %5$s, elevation: %6$s</string>
<string name="sensor_wheel_ticks">Wheel Distance[%1$s]: reset=%2$s, FL=%3$s, FR=%4$s, RL=%5$s, RR=%6$s</string>
+ <string name="sensor_wheel_ticks_cfg">Wheel Distance Config: Wheels=%1$s, FL=%2$s, FR=%3$s, RL=%4$s, RR=%5$s</string>
<string name="sensor_abs_is_active">ABS[%1$s]: isActive=%2$s</string>
<string name="sensor_traction_control_is_active">Traction Control[%1$s]: isActive=%2$s</string>
@@ -211,6 +212,7 @@
<string name="bluetooth_sco_disconnect">SCO disconnect</string>
<string name="bluetooth_pick_device">Pick Device</string>
<string name="bluetooth_quiet_mode_enable">Quiet Mode</string>
+ <string name="bluetooth_hold_call">Hold call</string>
<!--Car Service Settings-->
<string name="garage_title">Garage Mode</string>
diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/audio/AudioPlayer.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/audio/AudioPlayer.java
index 618367dccf..74345aa823 100644
--- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/audio/AudioPlayer.java
+++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/audio/AudioPlayer.java
@@ -61,7 +61,8 @@ public class AudioPlayer {
}
} else if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) {
if (isPlaying()) {
- mPlayer.setVolume(0.5f, 0.5f);
+ // Duck to 20% volume (which matches system ducking as of this date)
+ mPlayer.setVolume(0.2f, 0.2f);
}
} else if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT && mRepeat) {
if (isPlaying()) {
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 dec0dc6397..81e8737c4f 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
@@ -219,7 +219,9 @@ public class AudioTestFragment extends Fragment {
mMediaPlay.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- mMusicPlayer.start(false, true, AudioManager.AUDIOFOCUS_GAIN);
+ boolean requestFocus = true;
+ boolean repeat = true;
+ mMusicPlayer.start(requestFocus, repeat, AudioManager.AUDIOFOCUS_GAIN);
}
});
mMediaPlayOnce = (Button) view.findViewById(R.id.button_media_play_once);
diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/bluetooth/BluetoothHeadsetFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/bluetooth/BluetoothHeadsetFragment.java
index 30804feb08..cb668c49b6 100644
--- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/bluetooth/BluetoothHeadsetFragment.java
+++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/bluetooth/BluetoothHeadsetFragment.java
@@ -57,15 +57,17 @@ public class BluetoothHeadsetFragment extends Fragment {
Button mScoConnect;
Button mScoDisconnect;
Button mEnableQuietMode;
+ Button mHoldCall;
BluetoothHeadsetClient mHfpClientProfile;
// Intent for picking a Bluetooth device
- public static final String DEVICE_PICKER_ACTION = "android.bluetooth.devicepicker.action.LAUNCH";
+ public static final String DEVICE_PICKER_ACTION =
+ "android.bluetooth.devicepicker.action.LAUNCH";
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
+ @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.bluetooth_headset, container, false);
mPickedDeviceText = (TextView) v.findViewById(R.id.bluetooth_device);
@@ -73,8 +75,9 @@ public class BluetoothHeadsetFragment extends Fragment {
mConnect = (Button) v.findViewById(R.id.bluetooth_headset_connect);
mDisconnect = (Button) v.findViewById(R.id.bluetooth_headset_disconnect);
mScoConnect = (Button) v.findViewById(R.id.bluetooth_sco_connect);
- mScoDisconnect= (Button) v.findViewById(R.id.bluetooth_sco_disconnect);
+ mScoDisconnect = (Button) v.findViewById(R.id.bluetooth_sco_disconnect);
mEnableQuietMode = (Button) v.findViewById(R.id.bluetooth_quiet_mode_enable);
+ mHoldCall = (Button) v.findViewById(R.id.bluetooth_hold_call);
// Pick a bluetooth device
mDevicePicker.setOnClickListener(new View.OnClickListener() {
@@ -123,6 +126,14 @@ public class BluetoothHeadsetFragment extends Fragment {
mBluetoothAdapter.enableNoAutoConnect();
}
});
+
+ // Place the current call on hold
+ mHoldCall.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ holdCall();
+ }
+ });
return v;
}
@@ -192,6 +203,20 @@ public class BluetoothHeadsetFragment extends Fragment {
mHfpClientProfile.disconnectAudio(mPickedDevice);
}
+ void holdCall() {
+ if (mPickedDevice == null) {
+ Log.w(TAG, "Device null when trying to put the call on hold!");
+ return;
+ }
+
+ if (mHfpClientProfile == null) {
+ Log.w(TAG, "HFP Profile proxy not available, cannot put the call on hold " +
+ mPickedDevice);
+ return;
+ }
+ mHfpClientProfile.holdCall(mPickedDevice);
+ }
+
private final BroadcastReceiver mPickerReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
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 082a3f0a6b..d502c75901 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
@@ -24,6 +24,7 @@ import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.support.car.CarNotConnectedException;
+import android.support.car.hardware.CarSensorConfig;
import android.support.car.hardware.CarSensorEvent;
import android.support.car.hardware.CarSensorManager;
import android.support.v4.app.Fragment;
@@ -285,6 +286,19 @@ public class SensorsTestFragment extends Fragment {
getTimestamp(event), mNaString, mNaString, mNaString, mNaString,
mNaString));
}
+ // Get the config data
+ try {
+ CarSensorConfig c = mSensorManager.getSensorConfig(
+ CarSensorManager.SENSOR_TYPE_WHEEL_TICK_DISTANCE);
+ summary.add(getContext().getString(R.string.sensor_wheel_ticks_cfg,
+ c.getInt(CarSensorConfig.WHEEL_TICK_DISTANCE_SUPPORTED_WHEELS),
+ c.getInt(CarSensorConfig.WHEEL_TICK_DISTANCE_FRONT_LEFT_UM_PER_TICK),
+ c.getInt(CarSensorConfig.WHEEL_TICK_DISTANCE_FRONT_RIGHT_UM_PER_TICK),
+ c.getInt(CarSensorConfig.WHEEL_TICK_DISTANCE_REAR_LEFT_UM_PER_TICK),
+ c.getInt(CarSensorConfig.WHEEL_TICK_DISTANCE_REAR_RIGHT_UM_PER_TICK)));
+ } catch (CarNotConnectedException e) {
+ Log.e(TAG, "Car not connected or not supported", e);
+ }
break;
case CarSensorManager.SENSOR_TYPE_ABS_ACTIVE:
summary.add(getContext().getString(R.string.sensor_abs_is_active,
diff --git a/tests/android_car_api_test/Android.mk b/tests/android_car_api_test/Android.mk
index 306a240f51..58a12885c8 100644
--- a/tests/android_car_api_test/Android.mk
+++ b/tests/android_car_api_test/Android.mk
@@ -35,7 +35,8 @@ LOCAL_PROGUARD_ENABLED := disabled
LOCAL_STATIC_JAVA_LIBRARIES := junit legacy-android-test
LOCAL_STATIC_JAVA_LIBRARIES += \
android-support-test \
- android.hardware.automotive.vehicle-V2.0-java-static \
+ android.hidl.base-V1.0-java \
+ android.hardware.automotive.vehicle-V2.0-java \
LOCAL_JAVA_LIBRARIES := android.car android.test.runner
diff --git a/tests/carservice_test/src/com/android/car/test/SystemActivityMonitoringServiceTest.java b/tests/carservice_test/src/com/android/car/test/SystemActivityMonitoringServiceTest.java
index 0b1e7189eb..3345605e9e 100644
--- a/tests/carservice_test/src/com/android/car/test/SystemActivityMonitoringServiceTest.java
+++ b/tests/carservice_test/src/com/android/car/test/SystemActivityMonitoringServiceTest.java
@@ -54,6 +54,11 @@ public class SystemActivityMonitoringServiceTest extends MockedCarTestBase {
// blocking activity.
mDrivingStatusHandler.setDrivingStatusRestricted(drivingStatusRestricted);
+ // Due to asynchronous nature of Car Service initialization, if we won't wait we may inject
+ // an event while SensorHalService is not subscribed yet.
+ assertTrue(getMockedVehicleHal()
+ .waitForSubscriber(VehicleProperty.DRIVING_STATUS, TIMEOUT_MS));
+
VehiclePropValue injectValue =
VehiclePropValueBuilder.newBuilder(VehicleProperty.DRIVING_STATUS)
.setTimestamp(SystemClock.elapsedRealtimeNanos())
diff --git a/tests/vehiclehal_test/Android.mk b/tests/vehiclehal_test/Android.mk
index 43aa41f484..a22ee1b301 100644
--- a/tests/vehiclehal_test/Android.mk
+++ b/tests/vehiclehal_test/Android.mk
@@ -33,8 +33,9 @@ LOCAL_PROGUARD_ENABLED := disabled
LOCAL_STATIC_JAVA_LIBRARIES += vehicle-hal-support-lib \
android-support-test \
- android.hardware.automotive.vehicle-V2.0-java-static \
- android.hardware.automotive.vehicle-V2.1-java-static
+ android.hidl.base-V1.0-java \
+ android.hardware.automotive.vehicle-V2.0-java \
+ android.hardware.automotive.vehicle-V2.1-java
LOCAL_JAVA_LIBRARIES := android.car android.test.runner
diff --git a/vehicle-hal-support-lib/Android.mk b/vehicle-hal-support-lib/Android.mk
index 638e5cf26e..9ff39c60b8 100644
--- a/vehicle-hal-support-lib/Android.mk
+++ b/vehicle-hal-support-lib/Android.mk
@@ -24,8 +24,9 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hardware.automotive.vehicle-V2.0-java-static \
- android.hardware.automotive.vehicle-V2.1-java-static \
+ android.hidl.base-V1.0-java \
+ android.hardware.automotive.vehicle-V2.0-java \
+ android.hardware.automotive.vehicle-V2.1-java \
junit \
legacy-android-test
diff --git a/vehicle-hal-support-lib/src/com/android/car/vehiclehal/test/MockedVehicleHal.java b/vehicle-hal-support-lib/src/com/android/car/vehiclehal/test/MockedVehicleHal.java
index 1a5b8c6dcc..0da3565fdf 100644
--- a/vehicle-hal-support-lib/src/com/android/car/vehiclehal/test/MockedVehicleHal.java
+++ b/vehicle-hal-support-lib/src/com/android/car/vehiclehal/test/MockedVehicleHal.java
@@ -21,8 +21,6 @@ import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.fail;
-import com.google.android.collect.Lists;
-
import android.hardware.automotive.vehicle.V2_0.IVehicle;
import android.hardware.automotive.vehicle.V2_0.IVehicleCallback;
import android.hardware.automotive.vehicle.V2_0.StatusCode;
@@ -31,6 +29,9 @@ import android.hardware.automotive.vehicle.V2_0.VehiclePropConfig;
import android.hardware.automotive.vehicle.V2_0.VehiclePropValue;
import android.hardware.automotive.vehicle.V2_0.VehiclePropertyAccess;
import android.os.RemoteException;
+import android.os.SystemClock;
+
+import com.google.android.collect.Lists;
import java.util.ArrayList;
import java.util.HashMap;
@@ -74,6 +75,23 @@ public class MockedVehicleHal extends IVehicle.Stub {
addProperty(config, new StaticPropertyHandler(value));
}
+ public boolean waitForSubscriber(int propId, long timeoutMillis) {
+ long startTime = SystemClock.elapsedRealtime();
+ try {
+ synchronized (this) {
+ while (mSubscribers.get(propId) == null) {
+ long waitMillis = startTime - SystemClock.elapsedRealtime() + timeoutMillis;
+ if (waitMillis < 0) break;
+ wait(waitMillis);
+ }
+
+ return mSubscribers.get(propId) != null;
+ }
+ } catch (InterruptedException e) {
+ return false;
+ }
+ }
+
public synchronized void injectEvent(VehiclePropValue value) {
List<IVehicleCallback> callbacks = mSubscribers.get(value.prop);
assertNotNull("Injecting event failed for property: " + value.prop
@@ -156,6 +174,7 @@ public class MockedVehicleHal extends IVehicle.Stub {
if (subscribers == null) {
subscribers = new ArrayList<>();
mSubscribers.put(opt.propId, subscribers);
+ notifyAll();
}
subscribers.add(callback);
}