aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Granata <egranata@google.com>2017-05-08 18:09:58 -0700
committerEnrico Granata <egranata@google.com>2017-05-10 10:50:55 -0700
commitc2393683cf3c144461fe2ba28f4fa8cd817d8cb1 (patch)
tree26df681390d43c8178f4781d5ecea6139c7548f7
parentfb6472fcbb10800e9ec6cfdfa8780870fd625286 (diff)
downloadCar-c2393683cf3c144461fe2ba28f4fa8cd817d8cb1.tar.gz
Add APIs to CarDiagnosticManager to check whether specific features are enabled
DiagnosticHalService has a DiagnosticCapabilities object that keeps track of whether any/all the diagnostic HAL properties are supported by the underlying implementation. This change exposes the same information up to CarDiagnosticManager for applications to use, in order to quickly check whether or not they can expect support from a car. Change-Id: I0fd05b1e24346483ea94432e428d0b0e56b7d7e4 Fixes: 38138457 Test: runtest -x packages/services/Car/tests/carservice_test/src/com/android/car/test/CarDiagnosticManagerTest.java -c com.android.car.test.CarDiagnosticManagerTest -m testIsSupportedApiCalls
-rw-r--r--car-lib/src/android/car/hardware/CarDiagnosticManager.java66
-rw-r--r--car-lib/src/android/car/hardware/ICarDiagnostic.aidl22
-rw-r--r--service/src/com/android/car/CarDiagnosticService.java24
-rw-r--r--tests/carservice_test/src/com/android/car/test/CarDiagnosticManagerTest.java7
4 files changed, 118 insertions, 1 deletions
diff --git a/car-lib/src/android/car/hardware/CarDiagnosticManager.java b/car-lib/src/android/car/hardware/CarDiagnosticManager.java
index 851dd878d3..0444c14389 100644
--- a/car-lib/src/android/car/hardware/CarDiagnosticManager.java
+++ b/car-lib/src/android/car/hardware/CarDiagnosticManager.java
@@ -271,6 +271,72 @@ public final class CarDiagnosticManager implements CarManagerBase {
return false;
}
+ /**
+ * Returns true if this vehicle supports sending live frame information.
+ * @return
+ * @throws CarNotConnectedException
+ */
+ public boolean isLiveFrameSupported() throws CarNotConnectedException {
+ try {
+ return mService.isLiveFrameSupported();
+ } catch (IllegalStateException e) {
+ CarApiUtil.checkCarNotConnectedExceptionFromCarService(e);
+ } catch (RemoteException e) {
+ throw new CarNotConnectedException();
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if this vehicle supports sending freeze frame information.
+ * @return
+ * @throws CarNotConnectedException
+ */
+ public boolean isFreezeFrameSupported() throws CarNotConnectedException {
+ try {
+ return mService.isFreezeFrameSupported();
+ } catch (IllegalStateException e) {
+ CarApiUtil.checkCarNotConnectedExceptionFromCarService(e);
+ } catch (RemoteException e) {
+ throw new CarNotConnectedException();
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if this vehicle supports retrieving freeze frame timestamps.
+ * This is only meaningful if freeze frame data is also supported.
+ * @return
+ * @throws CarNotConnectedException
+ */
+ public boolean isFreezeFrameTimestampSupported() throws CarNotConnectedException {
+ try {
+ return mService.isFreezeFrameTimestampSupported();
+ } catch (IllegalStateException e) {
+ CarApiUtil.checkCarNotConnectedExceptionFromCarService(e);
+ } catch (RemoteException e) {
+ throw new CarNotConnectedException();
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if this vehicle supports clearing freeze frame timestamps.
+ * This is only meaningful if freeze frame data is also supported.
+ * @return
+ * @throws CarNotConnectedException
+ */
+ public boolean isFreezeFrameClearSupported() throws CarNotConnectedException {
+ try {
+ return mService.isFreezeFrameClearSupported();
+ } catch (IllegalStateException e) {
+ CarApiUtil.checkCarNotConnectedExceptionFromCarService(e);
+ } catch (RemoteException e) {
+ throw new CarNotConnectedException();
+ }
+ return false;
+ }
+
private static class CarDiagnosticEventListenerToService
extends ICarDiagnosticEventListener.Stub {
private final WeakReference<CarDiagnosticManager> mManager;
diff --git a/car-lib/src/android/car/hardware/ICarDiagnostic.aidl b/car-lib/src/android/car/hardware/ICarDiagnostic.aidl
index 098d2d4fcb..3afffc528b 100644
--- a/car-lib/src/android/car/hardware/ICarDiagnostic.aidl
+++ b/car-lib/src/android/car/hardware/ICarDiagnostic.aidl
@@ -52,4 +52,24 @@ interface ICarDiagnostic {
*/
void unregisterDiagnosticListener(int frameType,
in ICarDiagnosticEventListener callback) = 6;
-} \ No newline at end of file
+
+ /**
+ * Returns whether the underlying HAL supports live frames.
+ */
+ boolean isLiveFrameSupported() = 7;
+
+ /**
+ * Returns whether the underlying HAL supports freeze frames.
+ */
+ boolean isFreezeFrameSupported() = 8;
+
+ /**
+ * Returns whether the underlying HAL supports retrieving freeze frame timestamps.
+ */
+ boolean isFreezeFrameTimestampSupported() = 9;
+
+ /**
+ * Returns whether the underlying HAL supports clearing freeze frames.
+ */
+ boolean isFreezeFrameClearSupported() = 10;
+}
diff --git a/service/src/com/android/car/CarDiagnosticService.java b/service/src/com/android/car/CarDiagnosticService.java
index e752133f7c..88e7e349f1 100644
--- a/service/src/com/android/car/CarDiagnosticService.java
+++ b/service/src/com/android/car/CarDiagnosticService.java
@@ -29,6 +29,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.util.ArrayMap;
import android.util.Log;
+import com.android.car.hal.DiagnosticHalService.DiagnosticCapabilities;
import com.android.car.internal.CarPermission;
import com.android.car.Listeners.ClientWithRate;
import com.android.car.hal.DiagnosticHalService;
@@ -389,6 +390,29 @@ public class CarDiagnosticService extends ICarDiagnostic.Stub
return mDiagnosticHal;
}
+ // Expose DiagnosticCapabilities
+ public boolean isLiveFrameSupported() {
+ return getDiagnosticHal().getDiagnosticCapabilities().isLiveFrameSupported();
+ }
+
+ public boolean isFreezeFrameSupported() {
+ return getDiagnosticHal().getDiagnosticCapabilities().isFreezeFrameSupported();
+ }
+
+ public boolean isFreezeFrameTimestampSupported() {
+ DiagnosticCapabilities diagnosticCapabilities =
+ getDiagnosticHal().getDiagnosticCapabilities();
+ return diagnosticCapabilities.isFreezeFrameInfoSupported() &&
+ diagnosticCapabilities.isFreezeFrameSupported();
+ }
+
+ public boolean isFreezeFrameClearSupported() {
+ DiagnosticCapabilities diagnosticCapabilities =
+ getDiagnosticHal().getDiagnosticCapabilities();
+ return diagnosticCapabilities.isFreezeFrameClearSupported() &&
+ diagnosticCapabilities.isFreezeFrameSupported();
+ }
+
// ICarDiagnostic implementations
@Override
diff --git a/tests/carservice_test/src/com/android/car/test/CarDiagnosticManagerTest.java b/tests/carservice_test/src/com/android/car/test/CarDiagnosticManagerTest.java
index 8b307ab823..1bcc217674 100644
--- a/tests/carservice_test/src/com/android/car/test/CarDiagnosticManagerTest.java
+++ b/tests/carservice_test/src/com/android/car/test/CarDiagnosticManagerTest.java
@@ -801,6 +801,13 @@ public class CarDiagnosticManagerTest extends MockedCarTestBase {
assertTrue(listener2.waitForEvent(time));
}
+ public void testIsSupportedApiCalls() throws Exception {
+ assertTrue(mCarDiagnosticManager.isLiveFrameSupported());
+ assertTrue(mCarDiagnosticManager.isFreezeFrameSupported());
+ assertTrue(mCarDiagnosticManager.isFreezeFrameTimestampSupported());
+ assertTrue(mCarDiagnosticManager.isFreezeFrameClearSupported());
+ }
+
class Listener implements CarDiagnosticManager.OnDiagnosticEventListener {
private final Object mSync = new Object();