• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 package android.car.navigation;
17 
18 import android.annotation.IntDef;
19 import android.annotation.SystemApi;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 
23 import java.lang.annotation.Retention;
24 import java.lang.annotation.RetentionPolicy;
25 
26 /**
27  * Holds options related to navigation for the car's instrument cluster.
28  * @hide
29  */
30 @SystemApi
31 public class CarNavigationInstrumentCluster implements Parcelable {
32 
33     /** Navigation Next Turn messages contain an image, as well as an enum. */
34     public static final int CLUSTER_TYPE_CUSTOM_IMAGES_SUPPORTED = 1;
35     /** Navigation Next Turn messages contain only an enum. */
36     public static final int CLUSTER_TYPE_IMAGE_CODES_ONLY = 2;
37 
38     /** @hide */
39     @Retention(RetentionPolicy.SOURCE)
40     @IntDef({
41         CLUSTER_TYPE_CUSTOM_IMAGES_SUPPORTED,
42         CLUSTER_TYPE_IMAGE_CODES_ONLY
43     })
44     public @interface ClusterType {}
45 
46     private int mMinIntervalMillis;
47 
48     @ClusterType
49     private int mType;
50 
51     private int mImageWidth;
52 
53     private int mImageHeight;
54 
55     private int mImageColorDepthBits;
56 
57     public static final Parcelable.Creator<CarNavigationInstrumentCluster> CREATOR
58             = new Parcelable.Creator<CarNavigationInstrumentCluster>() {
59         public CarNavigationInstrumentCluster createFromParcel(Parcel in) {
60             return new CarNavigationInstrumentCluster(in);
61         }
62 
63         public CarNavigationInstrumentCluster[] newArray(int size) {
64             return new CarNavigationInstrumentCluster[size];
65         }
66     };
67 
createCluster(int minIntervalMillis)68     public static CarNavigationInstrumentCluster createCluster(int minIntervalMillis) {
69         return new CarNavigationInstrumentCluster(minIntervalMillis, CLUSTER_TYPE_IMAGE_CODES_ONLY,
70                 0, 0, 0);
71     }
72 
createCustomImageCluster(int minIntervalMs, int imageWidth, int imageHeight, int imageColorDepthBits)73     public static CarNavigationInstrumentCluster createCustomImageCluster(int minIntervalMs,
74             int imageWidth, int imageHeight, int imageColorDepthBits) {
75         return new CarNavigationInstrumentCluster(minIntervalMs,
76                 CLUSTER_TYPE_CUSTOM_IMAGES_SUPPORTED,
77                 imageWidth, imageHeight, imageColorDepthBits);
78     }
79 
80     /** Minimum time between instrument cluster updates in milliseconds.*/
getMinIntervalMillis()81     public int getMinIntervalMillis() {
82         return mMinIntervalMillis;
83     }
84 
85     /**
86      * Type of instrument cluster, can be {@link #CLUSTER_TYPE_CUSTOM_IMAGES_SUPPORTED} or
87      * {@link #CLUSTER_TYPE_IMAGE_CODES_ONLY}.
88      */
89     @ClusterType
getType()90     public int getType() {
91         return mType;
92     }
93 
94     /** If instrument cluster is image, width of instrument cluster in pixels. */
getImageWidth()95     public int getImageWidth() {
96         return mImageWidth;
97     }
98 
99     /** If instrument cluster is image, height of instrument cluster in pixels. */
getImageHeight()100     public int getImageHeight() {
101         return mImageHeight;
102     }
103 
104     /**
105      * If instrument cluster is image, number of bits of colour depth it supports (8, 16, or 32).
106      */
getImageColorDepthBits()107     public int getImageColorDepthBits() {
108         return mImageColorDepthBits;
109     }
110 
CarNavigationInstrumentCluster(CarNavigationInstrumentCluster that)111     public CarNavigationInstrumentCluster(CarNavigationInstrumentCluster that) {
112       this(that.mMinIntervalMillis,
113           that.mType,
114           that.mImageWidth,
115           that.mImageHeight,
116           that.mImageColorDepthBits);
117     }
118 
119     /**
120      * Whether cluster support custom image or not.
121      * @return
122      */
supportsCustomImages()123     public boolean supportsCustomImages() {
124       return mType == CLUSTER_TYPE_CUSTOM_IMAGES_SUPPORTED;
125     }
126 
CarNavigationInstrumentCluster( int minIntervalMillis, @ClusterType int type, int imageWidth, int imageHeight, int imageColorDepthBits)127     private CarNavigationInstrumentCluster(
128             int minIntervalMillis,
129             @ClusterType int type,
130             int imageWidth,
131             int imageHeight,
132             int imageColorDepthBits) {
133         this.mMinIntervalMillis = minIntervalMillis;
134         this.mType = type;
135         this.mImageWidth = imageWidth;
136         this.mImageHeight = imageHeight;
137         this.mImageColorDepthBits = imageColorDepthBits;
138     }
139 
140     @Override
describeContents()141     public int describeContents() {
142         return 0;
143     }
144 
145     @Override
writeToParcel(Parcel dest, int flags)146     public void writeToParcel(Parcel dest, int flags) {
147         dest.writeInt(mMinIntervalMillis);
148         dest.writeInt(mType);
149         dest.writeInt(mImageWidth);
150         dest.writeInt(mImageHeight);
151         dest.writeInt(mImageColorDepthBits);
152     }
153 
CarNavigationInstrumentCluster(Parcel in)154     private CarNavigationInstrumentCluster(Parcel in) {
155         mMinIntervalMillis = in.readInt();
156         mType = in.readInt();
157         mImageWidth = in.readInt();
158         mImageHeight = in.readInt();
159         mImageColorDepthBits = in.readInt();
160     }
161 
162     /** Converts to string for debug purpose */
163     @Override
toString()164     public String toString() {
165         return CarNavigationInstrumentCluster.class.getSimpleName() + "{ " +
166                 "minIntervalMillis: " + mMinIntervalMillis + ", " +
167                 "type: " + mType + ", " +
168                 "imageWidth: " + mImageWidth + ", " +
169                 "imageHeight: " + mImageHeight + ", " +
170                 "imageColourDepthBits: " + mImageColorDepthBits + " }";
171     }
172 }
173