Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dummy hal #13

Open
wants to merge 4 commits into
base: hal_example
Choose a base branch
from
Open

Feature/dummy hal #13

wants to merge 4 commits into from

Conversation

MaironLucas
Copy link
Contributor

@MaironLucas MaironLucas commented Jan 8, 2025

Description

This PR introduces a simple HAL implementation to the project, which provides some dummy data about a car. The goal is to understand and document the steps required to develop such a feature, as it is quite important and common in Android development. The idea is to eventually add a PR that improves or creates a new HAL using the SOME/IP and CommonAPI libraries to address a more typical demand in AOSP projects.

Visual reference

running_app_hal

@MaironLucas MaironLucas force-pushed the feature/dummy-hal branch 9 times, most recently from 1a30088 to aa1085b Compare January 16, 2025 11:55
@MaironLucas MaironLucas force-pushed the feature/dummy-hal branch 3 times, most recently from 6c5dc4d to 42d7557 Compare January 16, 2025 17:17
@MaironLucas MaironLucas marked this pull request as ready for review January 16, 2025 17:18
Comment on lines 1 to 10
cc_defaults{
name: "profusion.hardware.dummy_car_info_hal-defaults",
shared_libs: [
"profusion.hardware.dummy_car_info_hal-V1-ndk",
"libbase",
"liblog",
"libbinder_ndk",
],
vendor: true,
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would honestly avoid using defaults 😅. Take a look at my message here: https://profusion-mobi.slack.com/archives/C0714A7UT0D/p1736878171974269

Comment on lines 11 to 12
class DummyCarInfoHAL : public BnDummyCarInfoHAL {
virtual ndk::ScopedAStatus getCarInfo(CarInfo* carInfo) override;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is private, is that on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I didn't understand. What is private here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method is private. When you don't specify a visibility in class fields in C++, they're private by default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that makes sense. In that case, it's okay to stay private. This method will only be invoked through the HAL interface.

Comment on lines 21 to 22
LOG(INFO) << "DummyHAL: Main HAL initialization failed";
return EXIT_FAILURE;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed? Won't this always return a failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand about this type of service binding, ABinderProcess_joinThreadPool should never be completed, so the expected behavior is that it does not reach this return.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like eventually it would exit (even if at the end of the process), but I'm not very familiar with Android so you may be right

Comment on lines 1 to 10
java_defaults {
name: "dummyCarInfo_defaults",
static_libs: [
"profusion.hardware.dummy_car_info_hal-V1-java",
],
}

android_app {
name: "dummyCarInfoService",
defaults: ["dummyCarInfo_defaults"],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto about defaults

Comment on lines +16 to +10
dex_preopt: {
enabled: false,
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Contributor Author

@MaironLucas MaironLucas Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property supposedly reduces AOSP build time but also reduces app performance at the emulator. As our app is very simple and just a sample, I think it's a fair trade

srcs: [
"src/com/profusion/dummyCarInfo/DummyCarInfoManager.java",
],
unsafe_ignore_missing_latest_api: true,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I brought this from hello-world-service. When I was migrating from android 9 to android 14 I faced some problems with apis, and I found a topic at the java_sdk_library documentation about this one. But maybe isn't necessary anymore, since I figured out the problem with m update-api. I will try it here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, stills the same. If I remove this property, I get this error:

error: packages/services/profusion/dummy-car-info-service/Android.bp:33:1: "DummyCarInfoManager" depends on undefined module "DummyCarInfoManager.api.public.latest".
Or did you mean ["CarFrameworkResVisualThemePinkRROBase" "CarServiceMultiDisplayOverlayEmulator" "CarServiceOverlayEmulatorMediaGoogle" "CarSystemUISystemBarPersistcyImmersive" "mediaresourcemanager_fuzzer_defaults"]?
error: packages/services/profusion/dummy-car-info-service/Android.bp:33:1: "DummyCarInfoManager" depends on undefined module "DummyCarInfoManager-removed.api.public.latest".
Or did you mean ["CarEmulationAutomotiveUltrawideCutoutOverlay" "CarSystemUISystemBarPersistcyImmersiveWithNav"]?
error: packages/services/profusion/dummy-car-info-service/Android.bp:33:1: "DummyCarInfoManager" depends on undefined module "DummyCarInfoManager.api.system.latest".
Or did you mean ["CarFrameworkResVisualThemePinkRROBase" "CarServiceMultiDisplayOverlayEmulator" "CarServiceOverlayEmulatorMediaGoogle" "CarSystemUISystemBarPersistcyImmersive" "mediaresourcemanager_fuzzer_defaults"]?
error: packages/services/profusion/dummy-car-info-service/Android.bp:33:1: "DummyCarInfoManager" depends on undefined module "DummyCarInfoManager-removed.api.system.latest".
Or did you mean ["CarEmulationAutomotiveUltrawideCutoutOverlay" "CarSystemUISystemBarPersistcyImmersiveWithNav"]?
fatal errors encountered

I think it is related to the fact that I am defining a new SDK and not extending from a module that already exists at AOSP.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because for java_sdk_libraries, you need to define filegroups for your api, create an api directory and create .txt files that represent your api. I learned this while going through the BMW codebase. I'll share an example on Slack

- Create a new service to interact with HAL service to get car info
- Create a Manager to handle the service binding and communication
- Add Manager to sdk-addon
- Instead of using the Service directly, the example app will use the
Manager to get the car info.
@MaironLucas MaironLucas self-assigned this Jan 29, 2025
@MaironLucas MaironLucas changed the base branch from main to hal_example January 29, 2025 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants