How would I go about writing code that uses [email protected] Library?

1.2k Views Asked by At

I'm trying to learn to write Hardware Abstraction Layer (HAL). Here's the path I've taken so far, please correct me if I'm off in any step.

  1. Downloaded AOSP and built it successfully (86%)
  2. Located Vehicle Hal Support Library
  3. Located android.hardware.automotive.vehicle C++ code.

Things I've attempted after that the steps below without succeeding to get those above classes recognized.

  1. Import android.hardware.automotive.vehicle classes in Android Studio for a typical Android App that targets 29 Api Level.
  2. Adding meta tag of android.car app
  3. Copy/Pasting all source code under AOSP /packages/services/Car/
  4. Partially contemplated adding [email protected] Library and trying to access it through JNI (Not so sure about this one).

Please orient me, I see some repositories on github not doing anything special and somehow they're able to import the package in a java class like this.

import android.hardware.automotive.vehicle.V2_0.VehicleHwKeyInputAction;
import android.hardware.automotive.vehicle.V2_0.VehiclePropValue;
import android.hardware.automotive.vehicle.V2_0.VehicleProperty;
import android.hardware.automotive.vehicle.V2_0.VehiclePropertyAccess;

Here

how on earth do they get access to those classes?

Thanks

1

There are 1 best solutions below

0
On

Vehicle HAL is not meant to be accessed directly from apps. Car Service does that for you.

You have couple options depending on what you're actually trying to accomplish:

  1. Learn to write HAL services - it's like writing a driver for a given hardware (in this case, something that provides car data to Car Service).

  2. Learn to write HAL clients - try modifying EmbeddedKitchenSink app first. Please note you need to build it with AOSP and not in AmdroidStudio since this is a system app (and regular apps doesn't have access to the HAL)

  3. Learn Vehicle APIs - that's what you need car lib for. Details on how to use it: https://stackoverflow.com/a/63321234/14759774