aboutsummaryrefslogtreecommitdiff
path: root/car-lib/src/android
diff options
context:
space:
mode:
authorAsaf Rosenfeld <asafro@google.com>2017-05-19 12:59:56 -0700
committerAsaf Rosenfeld <asafro@google.com>2017-05-25 09:08:41 -0700
commit602848940066abb3f0c36148cbe09c3d1855dffc (patch)
tree31e5cbae1dda585399b99ab7534dc5b77b1f0469 /car-lib/src/android
parent9a8bb73e9784e124dbb4f29cacb568be38b6cf78 (diff)
downloadCar-602848940066abb3f0c36148cbe09c3d1855dffc.tar.gz
Adding Publisher ID support to non-hal clients.
Publishers send a serialized proto message with their description and get ID integer. Everytime the same serialized message is sent they will get the same ID so it is persistent within client crashes. Other clients can ask for a map all the IDs with their serialized descriptions. Test: All of VMS tests pass + added unit tests and integration tests. Change-Id: I025dd9943427ee8631a6a00adb0f9a17334a821e Bugs: 38185290, 38185731, 38185927
Diffstat (limited to 'car-lib/src/android')
-rw-r--r--car-lib/src/android/car/vms/IVmsPublisherService.aidl7
-rw-r--r--car-lib/src/android/car/vms/IVmsSubscriberService.aidl8
-rw-r--r--car-lib/src/android/car/vms/VmsPublisherClientService.java17
-rw-r--r--car-lib/src/android/car/vms/VmsSubscriberManager.java18
4 files changed, 48 insertions, 2 deletions
diff --git a/car-lib/src/android/car/vms/IVmsPublisherService.aidl b/car-lib/src/android/car/vms/IVmsPublisherService.aidl
index 26b6e523ed..3312794e9a 100644
--- a/car-lib/src/android/car/vms/IVmsPublisherService.aidl
+++ b/car-lib/src/android/car/vms/IVmsPublisherService.aidl
@@ -40,4 +40,11 @@ interface IVmsPublisherService {
* Sets which layers the publisher can publish under which dependencties.
*/
oneway void setLayersOffering(in IBinder token, in VmsLayersOffering offering) = 2;
+
+ /**
+ * The first time a publisher calls this API it will store the publisher info and assigns the
+ * publisher a static ID. Between reboots, subsequent calls with the same publisher info will
+ * return the same ID so that a restarting process can obtain the same ID as it had before.
+ */
+ int getPublisherStaticId(in byte[] publisherInfo) = 3;
}
diff --git a/car-lib/src/android/car/vms/IVmsSubscriberService.aidl b/car-lib/src/android/car/vms/IVmsSubscriberService.aidl
index 236ae5a94c..923413478d 100644
--- a/car-lib/src/android/car/vms/IVmsSubscriberService.aidl
+++ b/car-lib/src/android/car/vms/IVmsSubscriberService.aidl
@@ -52,8 +52,12 @@ interface IVmsSubscriberService {
in IVmsSubscriberClient listener) = 3;
/**
- * Tells the VmsSubscriberService a client requests the list of available layers.
- * The service should call the client's onLayersAvailabilityChange in response.
+ * Returns a list of available layers from the closure of the publishers offerings.
*/
List<VmsLayer> getAvailableLayers() = 4;
+
+ /**
+ * Returns a the publisher information for a publisher ID.
+ */
+ byte[] getPublisherInfo(in int publisherId) = 5;
}
diff --git a/car-lib/src/android/car/vms/VmsPublisherClientService.java b/car-lib/src/android/car/vms/VmsPublisherClientService.java
index 85fd2c2b8d..ea265dfe5e 100644
--- a/car-lib/src/android/car/vms/VmsPublisherClientService.java
+++ b/car-lib/src/android/car/vms/VmsPublisherClientService.java
@@ -155,6 +155,23 @@ public abstract class VmsPublisherClientService extends Service {
return token;
}
+ public final int getPublisherStaticId(byte[] publisherInfo) {
+ if (mVmsPublisherService == null) {
+ throw new IllegalStateException("VmsPublisherService not set.");
+ }
+ Integer publisherStaticId = null;
+ try {
+ Log.i(TAG, "Getting publisher static ID");
+ publisherStaticId = mVmsPublisherService.getPublisherStaticId(publisherInfo);
+ } catch (RemoteException e) {
+ Log.e(TAG, "unable to invoke binder method.", e);
+ }
+ if (publisherStaticId == null) {
+ throw new IllegalStateException("VmsPublisherService cannot get a publisher static ID.");
+ }
+ return publisherStaticId;
+ }
+
/**
* Uses the VmsPublisherService binder to get the list of layer/version that have any
* subscribers.
diff --git a/car-lib/src/android/car/vms/VmsSubscriberManager.java b/car-lib/src/android/car/vms/VmsSubscriberManager.java
index 640948a056..84405f4a12 100644
--- a/car-lib/src/android/car/vms/VmsSubscriberManager.java
+++ b/car-lib/src/android/car/vms/VmsSubscriberManager.java
@@ -157,6 +157,24 @@ public final class VmsSubscriberManager implements CarManagerBase {
}
/**
+ * Returns a serialized publisher information for a publisher ID.
+ */
+ public byte[] getPublisherInfo(int publisherId) throws CarNotConnectedException, IllegalStateException {
+ if (DBG) {
+ Log.d(TAG, "Getting all publishers info.");
+ }
+ try {
+ return mVmsSubscriberService.getPublisherInfo(publisherId);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Could not connect: ", e);
+ throw new CarNotConnectedException(e);
+ } catch (IllegalStateException ex) {
+ Car.checkCarNotConnectedExceptionFromCarService(ex);
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ /**
* Subscribes to listen to the layer specified.
*
* @param layer the layer to subscribe to.