aboutsummaryrefslogtreecommitdiff
path: root/car-lib/src/android/car/vms/VmsPublisherClientService.java
diff options
context:
space:
mode:
authorAsaf Rosenfeld <asafro@google.com>2017-08-31 23:51:12 -0700
committerAsaf Rosenfeld <asafro@google.com>2017-09-05 10:21:00 -0700
commit2e45d81aaa79fbca2620b20d04bfea3f2537e3e2 (patch)
tree86980a378c8fd0f66e4f019ca97870fdadda58d5 /car-lib/src/android/car/vms/VmsPublisherClientService.java
parenta0b665f7d31f54898bcd9169779081d0420ce447 (diff)
downloadCar-2e45d81aaa79fbca2620b20d04bfea3f2537e3e2.tar.gz
Fix VMS public API based on API review (ag/2593725).
Test: All tests were adjusted and pass. Bug: 65115457 Change-Id: Id271170d2d67706d243817c556e294faad672631
Diffstat (limited to 'car-lib/src/android/car/vms/VmsPublisherClientService.java')
-rw-r--r--car-lib/src/android/car/vms/VmsPublisherClientService.java33
1 files changed, 14 insertions, 19 deletions
diff --git a/car-lib/src/android/car/vms/VmsPublisherClientService.java b/car-lib/src/android/car/vms/VmsPublisherClientService.java
index 2b88487fbe..33ca1f3037 100644
--- a/car-lib/src/android/car/vms/VmsPublisherClientService.java
+++ b/car-lib/src/android/car/vms/VmsPublisherClientService.java
@@ -39,8 +39,8 @@ import java.lang.ref.WeakReference;
* of the target product.
*
* The {@link com.android.car.VmsPublisherService} will start this service. The callback
- * {@link #onVmsPublisherServiceReady()} notifies when VMS publisher services (i.e.
- * {@link #publish(int, int, byte[])} and {@link #getSubscribers()}) can be used.
+ * {@link #onVmsPublisherServiceReady()} notifies when VMS publisher services can be used, and the
+ * publisher can request a publisher ID in order to start publishing.
*
* SystemApi candidate.
*
@@ -76,7 +76,7 @@ public abstract class VmsPublisherClientService extends Service {
return super.onUnbind(intent);
}
- public void setToken(IBinder token) {
+ private void setToken(IBinder token) {
synchronized (mLock) {
mToken = token;
}
@@ -85,12 +85,12 @@ public abstract class VmsPublisherClientService extends Service {
/**
* Notifies that the publisher services are ready.
*/
- public abstract void onVmsPublisherServiceReady();
+ protected abstract void onVmsPublisherServiceReady();
/**
* Publishers need to implement this method to receive notifications of subscription changes.
*
- * @param subscriptionState layers with subscribers and a sequence number.
+ * @param subscriptionState the state of the subscriptions.
*/
public abstract void onVmsSubscriptionChange(VmsSubscriptionState subscriptionState);
@@ -103,7 +103,7 @@ public abstract class VmsPublisherClientService extends Service {
* VMS core.
* @return if the call to the method VmsPublisherService.publish was successful.
*/
- public final boolean publish(VmsLayer layer, int publisherId, byte[] payload) {
+ public final void publish(VmsLayer layer, int publisherId, byte[] payload) {
if (DBG) {
Log.d(TAG, "Publishing for layer : " + layer);
}
@@ -112,11 +112,9 @@ public abstract class VmsPublisherClientService extends Service {
try {
mVmsPublisherService.publish(token, layer, publisherId, payload);
- return true;
} catch (RemoteException e) {
Log.e(TAG, "unable to publish message: " + payload, e);
}
- return false;
}
/**
@@ -125,7 +123,7 @@ public abstract class VmsPublisherClientService extends Service {
* @param offering the layers that the publisher may publish.
* @return if the call to VmsPublisherService.setLayersOffering was successful.
*/
- public final boolean setLayersOffering(VmsLayersOffering offering) {
+ public final void setLayersOffering(VmsLayersOffering offering) {
if (DBG) {
Log.d(TAG, "Setting layers offering : " + offering);
}
@@ -135,11 +133,9 @@ public abstract class VmsPublisherClientService extends Service {
try {
mVmsPublisherService.setLayersOffering(token, offering);
VmsOperationRecorder.get().setLayersOffering(offering);
- return true;
} catch (RemoteException e) {
Log.e(TAG, "unable to set layers offering: " + offering, e);
}
- return false;
}
private IBinder getTokenForPublisherServiceThreadSafe() {
@@ -157,28 +153,27 @@ public abstract class VmsPublisherClientService extends Service {
return token;
}
- public final int getPublisherStaticId(byte[] publisherInfo) {
+ public final int getPublisherId(byte[] publisherInfo) {
if (mVmsPublisherService == null) {
throw new IllegalStateException("VmsPublisherService not set.");
}
- Integer publisherStaticId = null;
+ Integer publisherId = null;
try {
Log.i(TAG, "Getting publisher static ID");
- publisherStaticId = mVmsPublisherService.getPublisherStaticId(publisherInfo);
+ publisherId = mVmsPublisherService.getPublisherId(publisherInfo);
} catch (RemoteException e) {
Log.e(TAG, "unable to invoke binder method.", e);
}
- if (publisherStaticId == null) {
+ if (publisherId == null) {
throw new IllegalStateException("VmsPublisherService cannot get a publisher static ID.");
} else {
- VmsOperationRecorder.get().getPublisherStaticId(publisherStaticId);
+ VmsOperationRecorder.get().getPublisherId(publisherId);
}
- return publisherStaticId;
+ return publisherId;
}
/**
- * Uses the VmsPublisherService binder to get the list of layer/version that have any
- * subscribers.
+ * Uses the VmsPublisherService binder to get the state of the subscriptions.
*
* @return list of layer/version or null in case of error.
*/