blob: ae44f1d68c3cb7ce969d3f440da3b55771eb2aa1 [file] [log] [blame]
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -08001/*
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 */
16package android.hardware.location;
17
18import android.annotation.SystemApi;
19import android.os.Parcel;
20import android.os.Parcelable;
21
22import java.util.Arrays;
23
24/**
25 * @hide
Peng Xu9ff7d222016-02-11 13:02:05 -080026 */
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -080027@SystemApi
28public class ContextHubInfo {
29 private int mId;
30 private String mName;
31 private String mVendor;
32 private String mToolchain;
33 private int mPlatformVersion;
34 private int mStaticSwVersion;
35 private int mToolchainVersion;
36 private float mPeakMips;
37 private float mStoppedPowerDrawMw;
38 private float mSleepPowerDrawMw;
39 private float mPeakPowerDrawMw;
Ashutosh Joshib741e3b2016-03-29 09:19:56 -070040 private int mMaxPacketLengthBytes;
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -080041
42 private int[] mSupportedSensors;
43
44 private MemoryRegion[] mMemoryRegions;
45
46 public ContextHubInfo() {
47 }
48
49 /**
Ashutosh Joshib741e3b2016-03-29 09:19:56 -070050 * returns the maximum number of bytes that can be sent per message to the hub
51 *
52 * @return int - maximum bytes that can be transmitted in a
53 * single packet
54 */
55 public int getMaxPacketLengthBytes() {
56 return mMaxPacketLengthBytes;
57 }
58
59 /**
60 * set the context hub unique identifer
61 *
62 * @param bytes - Maximum number of bytes per message
63 *
64 * @hide
65 */
66 public void setMaxPacketLenBytes(int bytes) {
67 mMaxPacketLengthBytes = bytes;
68 }
69
70 /**
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -080071 * get the context hub unique identifer
72 *
73 * @return int - unique system wide identifier
74 */
75 public int getId() {
76 return mId;
77 }
78
79 /**
80 * set the context hub unique identifer
81 *
82 * @param id - unique system wide identifier for the hub
Peng Xu9ff7d222016-02-11 13:02:05 -080083 *
84 * @hide
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -080085 */
86 public void setId(int id) {
87 mId = id;
88 }
89
90 /**
91 * get a string as a hub name
92 *
93 * @return String - a name for the hub
94 */
95 public String getName() {
96 return mName;
97 }
98
99 /**
100 * set a string as the hub name
101 *
Peng Xu9ff7d222016-02-11 13:02:05 -0800102 * @param name - the name for the hub
103 *
104 * @hide
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -0800105 */
106 public void setName(String name) {
107 mName = name;
108 }
109
110 /**
111 * get a string as the vendor name
112 *
113 * @return String - a name for the vendor
114 */
115 public String getVendor() {
116 return mVendor;
117 }
118
119 /**
120 * set a string as the vendor name
121 *
Peng Xu9ff7d222016-02-11 13:02:05 -0800122 * @param vendor - a name for the vendor
123 *
124 * @hide
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -0800125 */
126 public void setVendor(String vendor) {
127 mVendor = vendor;
128 }
129
130 /**
131 * get tool chain string
132 *
133 * @return String - description of the tool chain
134 */
135 public String getToolchain() {
136 return mToolchain;
137 }
138
139 /**
140 * set tool chain string
141 *
Peng Xu9ff7d222016-02-11 13:02:05 -0800142 * @param toolchain - description of the tool chain
143 *
144 * @hide
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -0800145 */
146 public void setToolchain(String toolchain) {
147 mToolchain = toolchain;
148 }
149
150 /**
151 * get platform version
152 *
153 * @return int - platform version number
154 */
155 public int getPlatformVersion() {
156 return mPlatformVersion;
157 }
158
159 /**
160 * set platform version
161 *
162 * @param platformVersion - platform version number
Peng Xu9ff7d222016-02-11 13:02:05 -0800163 *
164 * @hide
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -0800165 */
166 public void setPlatformVersion(int platformVersion) {
167 mPlatformVersion = platformVersion;
168 }
169
170 /**
171 * get static platform version number
172 *
173 * @return int - platform version number
174 */
175 public int getStaticSwVersion() {
176 return mStaticSwVersion;
177 }
178
179 /**
180 * set platform software version
181 *
182 * @param staticSwVersion - platform static s/w version number
Peng Xu9ff7d222016-02-11 13:02:05 -0800183 *
184 * @hide
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -0800185 */
186 public void setStaticSwVersion(int staticSwVersion) {
187 mStaticSwVersion = staticSwVersion;
188 }
189
190 /**
191 * get the tool chain version
192 *
193 * @return int - the tool chain version
194 */
195 public int getToolchainVersion() {
196 return mToolchainVersion;
197 }
198
199 /**
200 * set the tool chain version number
201 *
202 * @param toolchainVersion - tool chain version number
Peng Xu9ff7d222016-02-11 13:02:05 -0800203 *
204 * @hide
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -0800205 */
206 public void setToolchainVersion(int toolchainVersion) {
207 mToolchainVersion = toolchainVersion;
208 }
209
210 /**
211 * get the peak processing mips the hub can support
212 *
213 * @return float - peak MIPS that this hub can deliver
214 */
215 public float getPeakMips() {
216 return mPeakMips;
217 }
218
219 /**
220 * set the peak mips that this hub can support
221 *
222 * @param peakMips - peak mips this hub can deliver
Peng Xu9ff7d222016-02-11 13:02:05 -0800223 *
224 * @hide
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -0800225 */
226 public void setPeakMips(float peakMips) {
227 mPeakMips = peakMips;
228 }
229
230 /**
231 * get the stopped power draw in milliwatts
232 * This assumes that the hub enter a stopped state - which is
233 * different from the sleep state. Latencies on exiting the
234 * sleep state are typically higher and expect to be in multiple
235 * milliseconds.
236 *
237 * @return float - power draw by the hub in stopped state
238 */
239 public float getStoppedPowerDrawMw() {
240 return mStoppedPowerDrawMw;
241 }
242
243 /**
244 * Set the power consumed by the hub in stopped state
245 *
246 * @param stoppedPowerDrawMw - stopped power in milli watts
Peng Xu9ff7d222016-02-11 13:02:05 -0800247 *
248 * @hide
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -0800249 */
250 public void setStoppedPowerDrawMw(float stoppedPowerDrawMw) {
251 mStoppedPowerDrawMw = stoppedPowerDrawMw;
252 }
253
254 /**
255 * get the power draw of the hub in sleep mode. This assumes
256 * that the hub supports a sleep mode in which the power draw is
257 * lower than the power consumed when the hub is actively
258 * processing. As a guideline, assume that the hub should be
259 * able to enter sleep mode if it knows reliably on completion
260 * of some task that the next interrupt/scheduled work item is
261 * at least 250 milliseconds later.
262 *
263 * @return float - sleep power draw in milli watts
264 */
265 public float getSleepPowerDrawMw() {
266 return mSleepPowerDrawMw;
267 }
268
269 /**
270 * Set the sleep power draw in milliwatts
271 *
272 * @param sleepPowerDrawMw - sleep power draw in milliwatts.
Peng Xu9ff7d222016-02-11 13:02:05 -0800273 *
274 * @hide
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -0800275 */
276 public void setSleepPowerDrawMw(float sleepPowerDrawMw) {
277 mSleepPowerDrawMw = sleepPowerDrawMw;
278 }
279
280 /**
281 * get the peak powe draw of the hub. This is the power consumed
282 * by the hub at maximum load.
283 *
284 * @return float - peak power draw
285 */
286 public float getPeakPowerDrawMw() {
287 return mPeakPowerDrawMw;
288 }
289
290 /**
291 * set the peak power draw of the hub
292 *
293 * @param peakPowerDrawMw - peak power draw of the hub in
294 * milliwatts.
Peng Xu9ff7d222016-02-11 13:02:05 -0800295 *
296 * @hide
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -0800297 */
298 public void setPeakPowerDrawMw(float peakPowerDrawMw) {
299 mPeakPowerDrawMw = peakPowerDrawMw;
300 }
301
302 /**
303 * get the sensors supported by this hub
304 *
305 * @return int[] - all the supported sensors on this hub
306 *
307 * @see ContextHubManager
308 */
309 public int[] getSupportedSensors() {
310 return Arrays.copyOf(mSupportedSensors, mSupportedSensors.length);
311 }
312
313 /**
314 * get the various memory regions on this hub
315 *
316 * @return MemoryRegion[] - all the memory regions on this hub
317 *
318 * @see MemoryRegion
319 */
320 public MemoryRegion[] getMemoryRegions() {
321 return Arrays.copyOf(mMemoryRegions, mMemoryRegions.length);
322 }
323
324 /**
325 * set the supported sensors on this hub
326 *
327 * @param supportedSensors - supported sensors on this hub
Peng Xu9ff7d222016-02-11 13:02:05 -0800328 *
329 * @hide
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -0800330 */
331 public void setSupportedSensors(int[] supportedSensors) {
332 mSupportedSensors = Arrays.copyOf(supportedSensors, supportedSensors.length);
333 }
334
335 /**
336 * set memory regions for this hub
337 *
338 * @param memoryRegions - memory regions information
339 *
340 * @see MemoryRegion
Peng Xu9ff7d222016-02-11 13:02:05 -0800341 *
342 * @hide
Ashutosh Joshi1d1ac542016-01-18 17:19:27 -0800343 */
344 public void setMemoryRegions(MemoryRegion[] memoryRegions) {
345 mMemoryRegions = Arrays.copyOf(memoryRegions, memoryRegions.length);
346 }
347
348 private ContextHubInfo(Parcel in) {
349 mId = in.readInt();
350 mName = in.readString();
351 mVendor = in.readString();
352 mToolchain = in.readString();
353 mPlatformVersion = in.readInt();
354 mToolchainVersion = in.readInt();
355 mStaticSwVersion = in.readInt();
356 mPeakMips = in.readFloat();
357 mStoppedPowerDrawMw = in.readFloat();
358 mSleepPowerDrawMw = in.readFloat();
359 mPeakPowerDrawMw = in.readFloat();
360
361 int numSupportedSensors = in.readInt();
362 mSupportedSensors = new int[numSupportedSensors];
363 in.readIntArray(mSupportedSensors);
364 mMemoryRegions = in.createTypedArray(MemoryRegion.CREATOR);
365 }
366
367 public int describeContents() {
368 return 0;
369 }
370
371 public void writeToParcel(Parcel out, int flags) {
372 out.writeInt(mId);
373 out.writeString(mName);
374 out.writeString(mVendor);
375 out.writeString(mToolchain);
376 out.writeInt(mPlatformVersion);
377 out.writeInt(mToolchainVersion);
378 out.writeInt(mStaticSwVersion);
379 out.writeFloat(mPeakMips);
380 out.writeFloat(mStoppedPowerDrawMw);
381 out.writeFloat(mSleepPowerDrawMw);
382 out.writeFloat(mPeakPowerDrawMw);
383
384 out.writeInt(mSupportedSensors.length);
385 out.writeIntArray(mSupportedSensors);
386 out.writeTypedArray(mMemoryRegions, flags);
387 }
388
389 public static final Parcelable.Creator<ContextHubInfo> CREATOR
390 = new Parcelable.Creator<ContextHubInfo>() {
391 public ContextHubInfo createFromParcel(Parcel in) {
392 return new ContextHubInfo(in);
393 }
394
395 public ContextHubInfo[] newArray(int size) {
396 return new ContextHubInfo[size];
397 }
398 };
Ashutosh Joshib741e3b2016-03-29 09:19:56 -0700399}