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

CURRENT_GEAR should be GEAR_SELECTION #3

Closed
nikagl opened this issue Feb 8, 2021 · 8 comments
Closed

CURRENT_GEAR should be GEAR_SELECTION #3

nikagl opened this issue Feb 8, 2021 · 8 comments

Comments

@nikagl
Copy link

nikagl commented Feb 8, 2021

Correct me if I'm wrong, but CURRENT_GEAR should be GEAR_SELECTION here:

@Zhomart
Copy link
Contributor

Zhomart commented Apr 12, 2021

why do you think so?

@Zhomart
Copy link
Contributor

Zhomart commented Apr 12, 2021

According to VehiclePropertyIds.java, both represent the current gear. As this is just a sample code, it shouldn't matter which one. (Please let me know if you disagree)

    /**
     * Currently selected gear
     *
     * This is the gear selected by the user.
     * Requires permission: {@link Car#PERMISSION_POWERTRAIN}.
     */
    @RequiresPermission(Car.PERMISSION_POWERTRAIN)
    public static final int GEAR_SELECTION = 289408000;
    /**
     * Current gear. In non-manual case, selected gear may not
     * match the current gear. For example, if the selected gear is GEAR_DRIVE,
     * the current gear will be one of GEAR_1, GEAR_2 etc, which reflects
     * the actual gear the transmission is currently running in.
     * Requires permission: {@link Car#PERMISSION_POWERTRAIN}.
     */
    @RequiresPermission(Car.PERMISSION_POWERTRAIN)
    public static final int CURRENT_GEAR = 289408001;

@Zhomart Zhomart closed this as completed Apr 12, 2021
@nikagersonlohman
Copy link

Test it in the emulator. It's not ;)

@nikagersonlohman
Copy link

image

@nikagersonlohman
Copy link

And here's the code for the view (derived from your demo code :-) ):

    private var carPropertyCurrentGearListener = object : CarPropertyManager.CarPropertyEventCallback {
        override fun onChangeEvent(value: CarPropertyValue<Any>) {
            Log.d(TAG, "Received on changed car property event")
            // value.value type changes depending on the vehicle property.
            currentGearTextView.text = value.value.toString()
        }

        override fun onErrorEvent(propId: Int, zone: Int) {
            Log.w(TAG, "Received error car property event, propId=$propId, zone=$zone")
        }
    }

    private var carPropertyIgnitionStateListener = object : CarPropertyManager.CarPropertyEventCallback {
        override fun onChangeEvent(value: CarPropertyValue<Any>) {
            Log.d(TAG, "Received on changed car property event")
            // value.value type changes depending on the vehicle property.
            ignitionStateTextView.text = VEHICLE_IGNITION_STATES.getOrDefault(value.value as Int, "IGNITION_STATE_INVALID")
        }

        override fun onErrorEvent(propId: Int, zone: Int) {
            Log.w(TAG, "Received error car property event, propId=$propId, zone=$zone")
        }

@Zhomart
Copy link
Contributor

Zhomart commented Apr 13, 2021

you're right, it doesn't show GEAR_SELECTION. It shows CURRENT_GEAR, which can be changed in Vhal properties tab (next to the Car Sensor Data tab).

Search for gear and change the value of current gear, it will update the Gear Viewer app UI.

(looks like emulator should be updated, as CURRENT_GEAR should show the actual gear value)

@nikagersonlohman
Copy link

The emulator doesn't allow me driving anyway, as soon as I start "driving" the screen shows a message I am not allowed to use my app while driving :)

@Zhomart
Copy link
Contributor

Zhomart commented Apr 14, 2021

#11 this CL should fix your issue. Please read https://source.android.com/devices/automotive/driver_distraction/guidelines to learn more about UX Restrictions

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

No branches or pull requests

3 participants