public interface

CarInfo

 androidx.car.app.hardware.info.CarInfo

Subclasses:

ProjectedCarInfo, AutomotiveCarInfo

Gradle dependencies

compile group: 'androidx.car.app', name: 'app', version: '1.7.0-beta01'

  • groupId: androidx.car.app
  • artifactId: app
  • version: 1.7.0-beta01

Artifact androidx.car.app:app:1.7.0-beta01 it located at Google repository (https://maven.google.com/)

Overview

Manages access to car hardware specific info such as model, energy, and speed info.

Summary

Methods
public voidaddEnergyLevelListener(java.util.concurrent.Executor executor, OnCarDataAvailableListener<EnergyLevel> listener)

Setup an ongoing listener to receive EnergyLevel information from the car hardware.

public voidaddEvStatusListener(java.util.concurrent.Executor executor, OnCarDataAvailableListener<EvStatus> listener)

Setup an ongoing listener to receive EvStatus information from the car hardware.

public voidaddMileageListener(java.util.concurrent.Executor executor, OnCarDataAvailableListener<Mileage> listener)

Setup an ongoing listener to receive Mileage information from the car hardware.

public voidaddSpeedListener(java.util.concurrent.Executor executor, OnCarDataAvailableListener<Speed> listener)

Setup an ongoing listener to receive Speed information from the car hardware.

public voidaddTollListener(java.util.concurrent.Executor executor, OnCarDataAvailableListener<TollCard> listener)

Setup an ongoing listener to receive TollCard information from the car hardware.

public voidfetchEnergyProfile(java.util.concurrent.Executor executor, OnCarDataAvailableListener<EnergyProfile> listener)

Reguest the EnergyProfile information about the car hardware.

public voidfetchExteriorDimensions(java.util.concurrent.Executor executor, OnCarDataAvailableListener<ExteriorDimensions> listener)

Request the ExteriorDimensions information about the vehicle.

public voidfetchModel(java.util.concurrent.Executor executor, OnCarDataAvailableListener<Model> listener)

Fetch the Model information about the car hardware.

public voidremoveEnergyLevelListener(OnCarDataAvailableListener<EnergyLevel> listener)

Remove an ongoing listener for EnergyLevel information.

public voidremoveEvStatusListener(OnCarDataAvailableListener<EvStatus> listener)

Remove an ongoing listener for EvStatus information.

public voidremoveMileageListener(OnCarDataAvailableListener<Mileage> listener)

Remove an ongoing listener for Mileage information.

public voidremoveSpeedListener(OnCarDataAvailableListener<Speed> listener)

Remove an ongoing listener for Speed information.

public voidremoveTollListener(OnCarDataAvailableListener<TollCard> listener)

Remove an ongoing listener for TollCard information.

Methods

public void fetchModel(java.util.concurrent.Executor executor, OnCarDataAvailableListener<Model> listener)

Fetch the Model information about the car hardware.

Parameters:

executor: the executor which will be used for invoking the listener
listener: the listener that will be invoked when data is available

public void fetchEnergyProfile(java.util.concurrent.Executor executor, OnCarDataAvailableListener<EnergyProfile> listener)

Reguest the EnergyProfile information about the car hardware.

Parameters:

executor: the executor which will be used for invoking the listener
listener: the listener that will be invoked when data is available

public void fetchExteriorDimensions(java.util.concurrent.Executor executor, OnCarDataAvailableListener<ExteriorDimensions> listener)

Request the ExteriorDimensions information about the vehicle. This will only return meaningful data on select Automotive vehicles running SDK 30 and above.

This requires the android.car.permission.CAR_INFO permission.

See VehiclePropertyIds#INFO_EXTERIOR_DIMENSIONS

Parameters:

executor: the executor which will be used for invoking the listener
listener: the listener that will be invoked when data is available

public void addTollListener(java.util.concurrent.Executor executor, OnCarDataAvailableListener<TollCard> listener)

Setup an ongoing listener to receive TollCard information from the car hardware.

If the listener was added previously then it won't be added again.

Parameters:

executor: the executor which will be used for invoking the listener
listener: the listener that will be invoked when data is available

public void removeTollListener(OnCarDataAvailableListener<TollCard> listener)

Remove an ongoing listener for TollCard information.

If the listener is not currently added, then nothing will be removed.

Parameters:

listener: the listener to remove

public void addEnergyLevelListener(java.util.concurrent.Executor executor, OnCarDataAvailableListener<EnergyLevel> listener)

Setup an ongoing listener to receive EnergyLevel information from the car hardware.

If the listener was added previously then it won't be added.

Parameters:

executor: the executor which will be used for invoking the listener
listener: the listener that will be invoked when data is available

public void removeEnergyLevelListener(OnCarDataAvailableListener<EnergyLevel> listener)

Remove an ongoing listener for EnergyLevel information.

If the listener is not currently added, then nothing will be removed.

Parameters:

listener: the listener to remove

public void addSpeedListener(java.util.concurrent.Executor executor, OnCarDataAvailableListener<Speed> listener)

Setup an ongoing listener to receive Speed information from the car hardware.

If the listener was added previously then it won't be added.

Parameters:

executor: the executor which will be used for invoking the listener
listener: the listener that will be invoked when data is available

public void removeSpeedListener(OnCarDataAvailableListener<Speed> listener)

Remove an ongoing listener for Speed information.

If the listener is not currently added, then nothing will be removed.

Parameters:

listener: the listener to remove

public void addMileageListener(java.util.concurrent.Executor executor, OnCarDataAvailableListener<Mileage> listener)

Setup an ongoing listener to receive Mileage information from the car hardware.

If the listener was added previously then it won't be added.

Parameters:

executor: the executor which will be used for invoking the listener
listener: the listener that will be invoked when data is available

public void removeMileageListener(OnCarDataAvailableListener<Mileage> listener)

Remove an ongoing listener for Mileage information.

If the listener is not currently added, then nothing will be removed.

Parameters:

listener: the listener to remove

public void addEvStatusListener(java.util.concurrent.Executor executor, OnCarDataAvailableListener<EvStatus> listener)

Setup an ongoing listener to receive EvStatus information from the car hardware.

If the listener was added previously then it won't be added.

Parameters:

executor: the executor which will be used for invoking the listener
listener: the listener that will be invoked when data is available

public void removeEvStatusListener(OnCarDataAvailableListener<EvStatus> listener)

Remove an ongoing listener for EvStatus information.

If the listener is not currently added, then nothing will be removed.

Parameters:

listener: the listener to remove

Source

/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package androidx.car.app.hardware.info;

import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.car.app.annotations.ExperimentalCarApi;
import androidx.car.app.annotations.RequiresCarApi;
import androidx.car.app.hardware.common.OnCarDataAvailableListener;

import java.util.concurrent.Executor;

/**
 * Manages access to car hardware specific info such as model, energy, and speed info.
 */
@RequiresCarApi(3)
@MainThread
public interface CarInfo {
    /**
     * Fetch the {@link Model} information about the car hardware.
     *
     * @param executor the executor which will be used for invoking the listener
     * @param listener the listener that will be invoked when data is available
     */
    void fetchModel(@NonNull /* @CallbackExecutor */ Executor executor,
            @NonNull OnCarDataAvailableListener<Model> listener);

    /**
     * Reguest the {@link EnergyProfile} information about the car hardware.
     *
     * @param executor the executor which will be used for invoking the listener
     * @param listener the listener that will be invoked when data is available
     */
    void fetchEnergyProfile(@NonNull /* @CallbackExecutor */ Executor executor,
            @NonNull OnCarDataAvailableListener<EnergyProfile> listener);

    /**
     * Request the {@link ExteriorDimensions} information about the vehicle. This will only return
     * meaningful data on select Automotive vehicles running SDK 30 and above.
     *
     * <p>This requires the {@code android.car.permission.CAR_INFO} permission.
     *
     * <p>See
     * <a href="https://developer.android.com/reference/android/car/VehiclePropertyIds#INFO_EXTERIOR_DIMENSIONS">VehiclePropertyIds#INFO_EXTERIOR_DIMENSIONS</a>
     *
     * @param executor the executor which will be used for invoking the listener
     * @param listener the listener that will be invoked when data is available
     */
    @RequiresCarApi(7)
    default void fetchExteriorDimensions(@NonNull /* @CallbackExecutor */ Executor executor,
            @NonNull OnCarDataAvailableListener<ExteriorDimensions> listener) {
    }

    /**
     * Setup an ongoing listener to receive {@link TollCard} information from the car hardware.
     *
     * <p>If the listener was added previously then it won't be added again.
     *
     * @param executor the executor which will be used for invoking the listener
     * @param listener the listener that will be invoked when data is available
     */
    void addTollListener(@NonNull /* @CallbackExecutor */ Executor executor,
            @NonNull OnCarDataAvailableListener<TollCard> listener);

    /**
     * Remove an ongoing listener for {@link TollCard} information.
     *
     * <p>If the listener is not currently added, then nothing will be removed.
     *
     * @param listener the listener to remove
     */
    void removeTollListener(@NonNull OnCarDataAvailableListener<TollCard> listener);

    /**
     * Setup an ongoing listener to receive {@link EnergyLevel} information from the car hardware.
     *
     * <p>If the listener was added previously then it won't be added.
     *
     * @param executor the executor which will be used for invoking the listener
     * @param listener the listener that will be invoked when data is available
     */
    void addEnergyLevelListener(@NonNull /* @CallbackExecutor */ Executor executor,
            @NonNull OnCarDataAvailableListener<EnergyLevel> listener);

    /**
     * Remove an ongoing listener for {@link EnergyLevel} information.
     *
     * <p>If the listener is not currently added, then nothing will be removed.
     *
     * @param listener the listener to remove
     */
    void removeEnergyLevelListener(@NonNull OnCarDataAvailableListener<EnergyLevel> listener);

    /**
     * Setup an ongoing listener to receive {@link Speed} information from the car hardware.
     *
     * <p>If the listener was added previously then it won't be added.
     *
     * @param executor the executor which will be used for invoking the listener
     * @param listener the listener that will be invoked when data is available
     */
    void addSpeedListener(@NonNull /* @CallbackExecutor */ Executor executor,
            @NonNull OnCarDataAvailableListener<Speed> listener);

    /**
     * Remove an ongoing listener for {@link Speed} information.
     *
     * <p>If the listener is not currently added, then nothing will be removed.
     *
     * @param listener the listener to remove
     */
    void removeSpeedListener(@NonNull OnCarDataAvailableListener<Speed> listener);

    /**
     * Setup an ongoing listener to receive {@link Mileage} information from the car hardware.
     *
     * <p>If the listener was added previously then it won't be added.
     *
     * @param executor the executor which will be used for invoking the listener
     * @param listener the listener that will be invoked when data is available
     */
    void addMileageListener(@NonNull /* @CallbackExecutor */ Executor executor,
            @NonNull OnCarDataAvailableListener<Mileage> listener);

    /**
     * Remove an ongoing listener for {@link Mileage} information.
     *
     * <p>If the listener is not currently added, then nothing will be removed.
     *
     * @param listener the listener to remove
     */
    void removeMileageListener(@NonNull OnCarDataAvailableListener<Mileage> listener);

    /**
     * Setup an ongoing listener to receive {@link EvStatus} information from the car hardware.
     *
     * <p>If the listener was added previously then it won't be added.
     *
     * @param executor the executor which will be used for invoking the listener
     * @param listener the listener that will be invoked when data is available
     */
    @ExperimentalCarApi
    void addEvStatusListener(@NonNull /* @CallbackExecutor */ Executor executor,
            @NonNull OnCarDataAvailableListener<EvStatus> listener);

    /**
     * Remove an ongoing listener for {@link EvStatus} information.
     *
     * <p>If the listener is not currently added, then nothing will be removed.
     *
     * @param listener the listener to remove
     */
    @ExperimentalCarApi
    void removeEvStatusListener(@NonNull OnCarDataAvailableListener<EvStatus> listener);
}