1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.support.car;
18 
19 import android.os.Bundle;
20 import android.os.RemoteException;
21 import android.support.car.annotation.ValueTypeDef;
22 
23 import java.lang.reflect.Field;
24 import java.util.HashMap;
25 
26 /**
27  * Utility to retrieve various static information from car. For given string keys, there can be
28  * different types of values and right query API like {@link #getFloat(String)} for float
29  * type, and {@link #getInt(String)} for int type, should be used. Passing a key string to wrong
30  * API will lead into {@link IllegalArgumentException}. All get* apis return null if requested
31  * property is not supported by the car. So caller should always check for null result.
32  */
33 public abstract class CarInfoManager implements CarManagerBase {
34 
35     /**
36      * Manufacturer of the car.
37      */
38     @ValueTypeDef(type = String.class)
39     public static final String KEY_MANUFACTURER = "manufacturer";
40     /**
41      * Model name of the car. This information may not necessarily allow distinguishing different
42      * car models as the same name may be used for different cars depending on manufacturers.
43      */
44     @ValueTypeDef(type = String.class)
45     public static final String KEY_MODEL = "model";
46     /**
47      * Model year of the car in AC.
48      */
49     @ValueTypeDef(type = Integer.class)
50     public static final String KEY_MODEL_YEAR = "model-year";
51     /**
52      * Unique identifier for the car. This is not VIN, and id is persistent until user resets it.
53      */
54     @ValueTypeDef(type = String.class)
55     public static final String KEY_VEHICLE_ID = "vehicle-id";
56 
57     /**
58      * Retrieve floating point information for car.
59      * @param key
60      * @return null if the key is not supported.
61      * @throws CarNotConnectedException
62      * @throws IllegalArgumentException
63      */
getFloat(String key)64     public abstract Float getFloat(String key)
65             throws CarNotConnectedException, IllegalArgumentException;
66 
getInt(String key)67     public abstract Integer getInt(String key)
68             throws CarNotConnectedException, IllegalArgumentException;
69 
getLong(String key)70     public abstract Long getLong(String key)
71             throws CarNotConnectedException, IllegalArgumentException;
72 
getString(String key)73     public abstract String getString(String key)
74             throws CarNotConnectedException, IllegalArgumentException;
75 
76     /**
77      * get Bundle for the given key. This is intended for passing vendor specific data for key
78      * defined only for the car vendor. Vendor extension can be used for other APIs like
79      * getInt / getString, but this is for passing more complex data.
80      * @param key
81      * @return
82      * @throws CarNotConnectedException
83      * @throws IllegalArgumentException
84      * @hide
85      */
getBundle(String key)86     public abstract Bundle getBundle(String key)
87             throws CarNotConnectedException, IllegalArgumentException;
88 }
89