diff options
author | Asaf Rosenfeld <asafro@google.com> | 2017-03-17 16:21:40 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-03-17 16:21:41 +0000 |
commit | 883252c75a00af217bd1714648493c93aeb7918b (patch) | |
tree | 530857e47c112abf02e7c07f0cf9e2fca2e0b025 /car-lib/src/android | |
parent | e2b3b6ce284eee66acd56b6cad2a19736b118a85 (diff) | |
parent | 7bd684ec25febcbd65e32ff59e64f8b1d411aced (diff) | |
download | Car-883252c75a00af217bd1714648493c93aeb7918b.tar.gz |
Merge "Adding a class to describe a single VMS dependency. Adding a class to describe a publisher layers offering. Adding a way to publishers to declare their offering. Adding a token to publishers so that the service can track offering and potentially have more access control on publishing"
Diffstat (limited to 'car-lib/src/android')
7 files changed, 233 insertions, 8 deletions
diff --git a/car-lib/src/android/car/vms/IVmsPublisherClient.aidl b/car-lib/src/android/car/vms/IVmsPublisherClient.aidl index 761e6e731e..f454a33576 100644 --- a/car-lib/src/android/car/vms/IVmsPublisherClient.aidl +++ b/car-lib/src/android/car/vms/IVmsPublisherClient.aidl @@ -25,9 +25,10 @@ import android.car.vms.VmsLayer; interface IVmsPublisherClient { /** * Once the VmsPublisherService is bound to the client, this callback is used to set the - * binder that the client can use to invoke publisher services. + * binder that the client can use to invoke publisher services. This also gives the client + * the token it should use when calling the service. */ - oneway void setVmsPublisherService(IVmsPublisherService service) = 0; + oneway void setVmsPublisherService(in IBinder token, IVmsPublisherService service) = 0; /** * The VmsPublisherService uses this callback to notify about subscription changes. diff --git a/car-lib/src/android/car/vms/IVmsPublisherService.aidl b/car-lib/src/android/car/vms/IVmsPublisherService.aidl index 6e2f729c45..5e210fe703 100644 --- a/car-lib/src/android/car/vms/IVmsPublisherService.aidl +++ b/car-lib/src/android/car/vms/IVmsPublisherService.aidl @@ -17,6 +17,7 @@ package android.car.vms; import android.car.vms.VmsLayer; +import android.car.vms.VmsLayersOffering; /** * Exposes publisher services to VMS clients. @@ -27,10 +28,15 @@ interface IVmsPublisherService { /** * Client call to publish a message. */ - oneway void publish(int layer, int version, in byte[] message) = 0; + oneway void publish(in IBinder token, int layer, int version, in byte[] message) = 0; /** * Returns whether the layer/version has any clients subscribed to it. */ - List<VmsLayer> getSubscribers() = 1; + List<VmsLayer> getSubscriptions() = 1; + + /** + * Sets which layers the publisher can publish under which dependencties. + */ + oneway void setLayersOffering(in IBinder token, in VmsLayersOffering offering) = 2; } diff --git a/car-lib/src/android/car/vms/VmsLayerDependency.aidl b/car-lib/src/android/car/vms/VmsLayerDependency.aidl new file mode 100644 index 0000000000..3e64001b8b --- /dev/null +++ b/car-lib/src/android/car/vms/VmsLayerDependency.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.vms; + +parcelable VmsLayerDependency;
\ No newline at end of file diff --git a/car-lib/src/android/car/vms/VmsLayerDependency.java b/car-lib/src/android/car/vms/VmsLayerDependency.java new file mode 100644 index 0000000000..254330e3a3 --- /dev/null +++ b/car-lib/src/android/car/vms/VmsLayerDependency.java @@ -0,0 +1,94 @@ +/* + * 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.vms; + +import android.car.annotation.FutureFeature; +import android.os.Parcel; +import android.os.Parcelable; +import java.util.ArrayList; +import java.util.List; + +/** + * A dependency for a VMS layer on other VMS layers. + * + * @hide + */ +@FutureFeature +public final class VmsLayerDependency implements Parcelable { + private final VmsLayer mLayer; + private final List<VmsLayer> mDependency = new ArrayList<>(); + + /** + * Construct a dependency for layer on other layers. + */ + public VmsLayerDependency(VmsLayer layer, List<VmsLayer> dependencies) { + mLayer = layer; + mDependency.addAll(dependencies); + } + + /** + * Constructs a layer without a dependency. + */ + public VmsLayerDependency(VmsLayer layer) { + mLayer = layer; + } + + /** + * Checks if a layer has a dependency. + */ + public boolean hasDependencies() { + return (!mDependency.isEmpty()); + } + + public VmsLayer getLayer() { + return mLayer; + } + + /** + * Returns the dependencies. + */ + public List<VmsLayer> getDependencies() { + return new ArrayList<VmsLayer>(mDependency); + } + + public static final Parcelable.Creator<VmsLayerDependency> CREATOR = new + Parcelable.Creator<VmsLayerDependency>() { + public VmsLayerDependency createFromParcel(Parcel in) { + return new VmsLayerDependency(in); + } + public VmsLayerDependency[] newArray(int size) { + return new VmsLayerDependency[size]; + } + }; + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(mLayer, flags); + out.writeParcelableList(mDependency, flags); + } + + @Override + public int describeContents() { + return 0; + } + + private VmsLayerDependency(Parcel in) { + mLayer = in.readParcelable(VmsLayer.class.getClassLoader()); + in.readParcelableList(mDependency, VmsLayer.class.getClassLoader()); + + } +}
\ No newline at end of file diff --git a/car-lib/src/android/car/vms/VmsLayersOffering.aidl b/car-lib/src/android/car/vms/VmsLayersOffering.aidl new file mode 100644 index 0000000000..4231f2daf5 --- /dev/null +++ b/car-lib/src/android/car/vms/VmsLayersOffering.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.vms; + +parcelable VmsLayersOffering;
\ No newline at end of file diff --git a/car-lib/src/android/car/vms/VmsLayersOffering.java b/car-lib/src/android/car/vms/VmsLayersOffering.java new file mode 100644 index 0000000000..e3691bcc06 --- /dev/null +++ b/car-lib/src/android/car/vms/VmsLayersOffering.java @@ -0,0 +1,65 @@ +/* + * 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.vms; + +import android.car.annotation.FutureFeature; +import android.os.Parcel; +import android.os.Parcelable; +import java.util.ArrayList; +import java.util.List; + +/** + * The state of dependencies for a single publisher. + * + * @hide + */ +@FutureFeature +public final class VmsLayersOffering implements Parcelable { + + private final List<VmsLayerDependency> mDependencies = new ArrayList<>(); + + /** + * Returns the dependencies. + */ + public List<VmsLayerDependency> getDependencies() { + return new ArrayList<VmsLayerDependency>(mDependencies); + } + + public static final Parcelable.Creator<VmsLayersOffering> CREATOR = new + Parcelable.Creator<VmsLayersOffering>() { + public VmsLayersOffering createFromParcel(Parcel in) { + return new VmsLayersOffering(in); + } + public VmsLayersOffering[] newArray(int size) { + return new VmsLayersOffering[size]; + } + }; + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeParcelableList(mDependencies, flags); + } + + @Override + public int describeContents() { + return 0; + } + + private VmsLayersOffering(Parcel in) { + in.readParcelableList(mDependencies, VmsLayerDependency.class.getClassLoader()); + } +}
\ No newline at end of file diff --git a/car-lib/src/android/car/vms/VmsPublisherClientService.java b/car-lib/src/android/car/vms/VmsPublisherClientService.java index a3ac1ab686..7cda632e8a 100644 --- a/car-lib/src/android/car/vms/VmsPublisherClientService.java +++ b/car-lib/src/android/car/vms/VmsPublisherClientService.java @@ -52,9 +52,13 @@ public abstract class VmsPublisherClientService extends Service { private static final boolean DBG = true; private static final String TAG = "VmsPublisherClient"; + private final Object mLock = new Object(); + private Handler mHandler = new VmsEventHandler(this); private final VmsPublisherClientBinder mVmsPublisherClient = new VmsPublisherClientBinder(this); private volatile IVmsPublisherService mVmsPublisherService = null; + @GuardedBy("mLock") + private volatile IBinder mToken = null; @Override public final IBinder onBind(Intent intent) { @@ -73,6 +77,12 @@ public abstract class VmsPublisherClientService extends Service { return super.onUnbind(intent); } + public void setToken(IBinder token) { + synchronized (mLock) { + mToken = token; + } + } + /** * Notifies that the publisher services are ready. */ @@ -103,8 +113,17 @@ public abstract class VmsPublisherClientService extends Service { if (mVmsPublisherService == null) { throw new IllegalStateException("VmsPublisherService not set."); } + + IBinder token; + synchronized (mLock) { + token = mToken; + } + if (token == null) { + throw new IllegalStateException("VmsPublisherService does not have a valid token."); + } try { - mVmsPublisherService.publish(layerId, layerVersion, payload); + mVmsPublisherService + .publish(token, layerId, layerVersion, payload); return true; } catch (RemoteException e) { Log.e(TAG, "unable to publish message: " + payload, e); @@ -118,12 +137,12 @@ public abstract class VmsPublisherClientService extends Service { * * @return list of layer/version or null in case of error. */ - public final @Nullable List<VmsLayer> getSubscribers() { + public final @Nullable List<VmsLayer> getSubscriptions() { if (mVmsPublisherService == null) { throw new IllegalStateException("VmsPublisherService not set."); } try { - return mVmsPublisherService.getSubscribers(); + return mVmsPublisherService.getSubscriptions(); } catch (RemoteException e) { Log.e(TAG, "unable to invoke binder method.", e); } @@ -149,7 +168,8 @@ public abstract class VmsPublisherClientService extends Service { } @Override - public void setVmsPublisherService(IVmsPublisherService service) throws RemoteException { + public void setVmsPublisherService(IBinder token, IVmsPublisherService service) + throws RemoteException { VmsPublisherClientService vmsPublisherClientService = mVmsPublisherClientService.get(); if (vmsPublisherClientService == null) return; if (DBG) { @@ -158,6 +178,7 @@ public abstract class VmsPublisherClientService extends Service { Handler handler = vmsPublisherClientService.mHandler; handler.sendMessage( handler.obtainMessage(VmsEventHandler.SET_SERVICE_CALLBACK, service)); + vmsPublisherClientService.setToken(token); } @Override |