android / car-samples

Multiple samples showing best practices for car app development on both Android Auto and Android Automotive OS.
Apache License 2.0
358 stars 166 forks source link

Can only get 4 properties? #12

Open nikagersonlohman opened 3 years ago

nikagersonlohman commented 3 years ago

Any thoughts why I can only get 4 properties?

CarPropertyConfig{mPropertyId= 287310850 > PARKING_BRAKE_ON CarPropertyConfig{mPropertyId= 289408000 > GEAR_SELECTION CarPropertyConfig{mPropertyId= 289408001 > CURRENT_GEAR CarPropertyConfig{mPropertyId= 289408009 > IGNITION_STATE

When I list all properties, I only see the above 4:

        // Create a list of properties in debug window
        val carPropertyList = carPropertyManager.propertyList
        Log.d(TAG, "carPropertyList: " + carPropertyList.toString())
        for (i in 0 until carPropertyList.size) {
            val carProperty = carPropertyList[i]
            data.add(carProperty.toString())
        }

If I try to register any other property, I get an error: E/CarPropertyManager: registerListener: propId is not in config list: 291504647

Here's the code I try to use:

        // Subscribes to the car speed events.
        carPropertyManager.registerCallback(
            carPropertyCarSpeedListener,
            VehiclePropertyIds.PERF_VEHICLE_SPEED,
            CarPropertyManager.SENSOR_RATE_ONCHANGE
        )

I did add CAR_SPEED permission to my manifest:

    <uses-permission android:name="android.car.permission.CAR_SPEED" />
frankkienl commented 3 years ago

Maybe some other permissions are needed as well 🤔

nikagersonlohman commented 3 years ago

Yeah... but which... who knows... where to ask?

asimwaleed commented 3 years ago

i also got this error. Go through this link (code line 212-220), may be it's an issue of emulator

nikagersonlohman commented 3 years ago

I have the same issue in the car (Volvo XC40)...

frankkienl commented 3 years ago

You could try to file the issue here: https://issuetracker.google.com/issues?q=componentid:460472%20status:open# That may help.

TIB28 commented 3 years ago

Hi @nikagersonlohman , got the same problem, did you fix it ?

nikagersonlohman commented 3 years ago

No, sorry, I abandoned it because they denied testing the app further in my car as it's not a media app which is the only allowed currently :(

andrewmbenton commented 3 years ago

I know this is slightly off-topic but I saw that you did manage to install your testing app on an XC40 P8 via the Play Store and am wondering how you did that? I've set up testing channels for other apps and I think I did this one correctly (release type is Automotive OS). On the vehicle I'm signed in to the Google Account of one of my opted-in testers. But searching the Play Store on the vehicle turns up nothing. If you managed to do this successfully can you share the method?

nikagersonlohman commented 3 years ago

Hi Andrew,

I think it must have been a mistake. When I submitted the app a second time with hardly any changes, they denied it into the test phase...

This is what I got in February: image

And this is what I got last month: image

Regards,

Nika.

andrewmbenton commented 3 years ago

My app has been approved for testing but yes presumably they will reject it at some point.

During the brief period when your app was approved for testing did you manage to run it on the car?

nikagl commented 3 years ago

Yes, and it's still running in it...

🤷‍♂️

andrewmbenton commented 3 years ago

How did you manage to install? On the vehicle did you just search the Play Store from a tester's google account?

SergeyStepanov commented 3 years ago

Hi. I realize that my answer is already late, but I ran into this problem myself and I was able to solve it. So I am writing for those who will encounter it.

It is not enough to specify the permissions in the manifest. You need to request them in the GUI. I used the following example:

private val permissions = arrayOf(Car.PERMISSION_SPEED)

override fun onResume() {
        super.onResume()
        if(checkSelfPermission(permissions[0]) == PackageManager.PERMISSION_GRANTED) {
            //your code here
        } else {
            requestPermissions(permissions, 0)
        }
    }
nikagersonlohman commented 3 years ago

How did you manage to install? On the vehicle did you just search the Play Store from a tester's google account?

It's a bit too long ago, I do not remember exactly, but I do remember it didn't show up initially. I had to setup beta in Google Play too. If I remember correctly I clicked like 10 times on the play store version and it said I am a developer (like developer options in android, which doesn't work in the car; it did work here). Here's a screenshot of what I needed to enable (translated it says: internal share apps on google play, download and install test-versions of apps shared with you): image

After that, it didn't work initially. I could find the app but couldn't install it: image image

But after a while, it suddenly installed and is still running (even when driving): IMG_20210628_083618 (Large) IMG_20210628_083628 (Large) IMG_20210628_084434 (Large) IMG_20210628_084524 (Large) IMG_20210628_084531 (Large) IMG_20210628_084538 (Large) IMG_20210628_084551 (Large) IMG_20210628_084612 (Large)

nikagersonlohman commented 3 years ago

Hi. I realize that my answer is already late, but I ran into this problem myself and I was able to solve it. So I am writing for those who will encounter it.

It is not enough to specify the permissions in the manifest. You need to request them in the GUI. I used the following example:

private val permissions = arrayOf(Car.PERMISSION_SPEED)

override fun onResume() {
        super.onResume()
        if(checkSelfPermission(permissions[0]) == PackageManager.PERMISSION_GRANTED) {
            //your code here
        } else {
            requestPermissions(permissions, 0)
        }
    }

Superb! I'll try that soon on the emulator (as I can't get the app to publish to the car anymore :( )

narko commented 2 years ago

In case it helps, this file contains all the Car properties together with the required permissions: https://cs.android.com/android/platform/superproject/+/master:packages/services/Car/car-lib/src/android/car/VehiclePropertyIds.java;l=30?q=VehiclePropertyIds