/* * Copyright (C) 2016 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.annotation.SystemApi; import android.car.Car; import android.car.CarManagerBase; import android.car.hardware.property.CarPropertyManager; import android.car.hardware.property.CarPropertyManager.CarPropertyEventCallback; import android.car.hardware.property.ICarProperty; import android.os.IBinder; import android.util.ArraySet; import com.android.internal.annotations.GuardedBy; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collection; import java.util.List; /** * API to access custom vehicle properties defined by OEMs. *
* System permission {@link Car#PERMISSION_VENDOR_EXTENSION} is required to get this manager. *
* @hide * @deprecated consider using {@link CarPropertyManager} instead. */ @Deprecated @SystemApi public final class CarVendorExtensionManager extends CarManagerBase { private static final boolean DBG = false; private static final String TAG = CarVendorExtensionManager.class.getSimpleName(); private final CarPropertyManager mPropertyManager; @GuardedBy("mLock") private final ArraySetShould not be obtained directly by clients, use {@link Car#getCarManager(String)} instead.
* @hide
*/
public CarVendorExtensionManager(Car car, IBinder service) {
super(car);
ICarProperty mCarPropertyService = ICarProperty.Stub.asInterface(service);
mPropertyManager = new CarPropertyManager(car, mCarPropertyService);
}
/**
* Contains callback functions that will be called when some event happens with vehicle
* property.
*/
public interface CarVendorExtensionCallback {
/** Called when a property is updated */
void onChangeEvent(CarPropertyValue value);
/** Called when an error is detected with a property */
void onErrorEvent(int propertyId, int zone);
}
/**
* Registers listener. The methods of the listener will be called when new events arrived in
* the main thread.
*/
public void registerCallback(CarVendorExtensionCallback callback) {
synchronized (mLock) {
if (mCallbacks.isEmpty()) {
mListenerToBase = new CarPropertyEventListenerToBase(this);
}
List