car-samples icon indicating copy to clipboard operation
car-samples copied to clipboard

Can only get 4 properties?

Open nikagersonlohman opened this issue 4 years ago • 16 comments
trafficstars

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" />

nikagersonlohman avatar Apr 27 '21 23:04 nikagersonlohman

Maybe some other permissions are needed as well 🤔

frankkienl avatar Apr 28 '21 11:04 frankkienl

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

nikagersonlohman avatar Apr 28 '21 11:04 nikagersonlohman

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

asimwaleed avatar Apr 28 '21 13:04 asimwaleed

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

nikagersonlohman avatar Apr 28 '21 13:04 nikagersonlohman

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

frankkienl avatar Apr 28 '21 15:04 frankkienl

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

TIB28 avatar Jun 18 '21 07:06 TIB28

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 :(

nikagersonlohman avatar Jun 18 '21 07:06 nikagersonlohman

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?

andrewmbenton avatar Jun 25 '21 17:06 andrewmbenton

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.

nikagersonlohman avatar Jun 25 '21 18:06 nikagersonlohman

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?

andrewmbenton avatar Jun 25 '21 20:06 andrewmbenton

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

🤷‍♂️

nikagl avatar Jun 25 '21 21:06 nikagl

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

andrewmbenton avatar Jun 25 '21 22:06 andrewmbenton

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)
        }
    }

SergeyStepanov avatar Jun 27 '21 20:06 SergeyStepanov

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 avatar Jun 28 '21 07:06 nikagersonlohman

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 :( )

nikagersonlohman avatar Jun 28 '21 07:06 nikagersonlohman

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

narko avatar May 04 '22 09:05 narko