• 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.hardware.location;
17 
18 import android.annotation.SystemApi;
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 
22 import java.util.Arrays;
23 
24 /**
25  * @hide
26  */
27 @SystemApi
28 public 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;
40     private int mMaxPacketLengthBytes;
41 
42     private int[] mSupportedSensors;
43 
44     private MemoryRegion[] mMemoryRegions;
45 
ContextHubInfo()46     public ContextHubInfo() {
47     }
48 
49     /**
50      * 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      */
getMaxPacketLengthBytes()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      */
setMaxPacketLenBytes(int bytes)66     public void setMaxPacketLenBytes(int bytes) {
67         mMaxPacketLengthBytes = bytes;
68     }
69 
70     /**
71      * get the context hub unique identifer
72      *
73      * @return int - unique system wide identifier
74      */
getId()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
83      *
84      * @hide
85      */
setId(int id)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      */
getName()95     public String getName() {
96         return mName;
97     }
98 
99     /**
100      * set a string as the hub name
101      *
102      * @param name - the name for the hub
103      *
104      * @hide
105      */
setName(String name)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      */
getVendor()115     public String getVendor() {
116         return mVendor;
117     }
118 
119     /**
120      * set a string as the vendor name
121      *
122      * @param vendor - a name for the vendor
123      *
124      * @hide
125      */
setVendor(String vendor)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      */
getToolchain()135     public String getToolchain() {
136         return mToolchain;
137     }
138 
139     /**
140      * set tool chain string
141      *
142      * @param toolchain - description of the tool chain
143      *
144      * @hide
145      */
setToolchain(String toolchain)146     public void setToolchain(String toolchain) {
147         mToolchain = toolchain;
148     }
149 
150     /**
151      * get platform version
152      *
153      * @return int - platform version number
154      */
getPlatformVersion()155     public int getPlatformVersion() {
156         return mPlatformVersion;
157     }
158 
159     /**
160      * set platform version
161      *
162      * @param platformVersion - platform version number
163      *
164      * @hide
165      */
setPlatformVersion(int platformVersion)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      */
getStaticSwVersion()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
183      *
184      * @hide
185      */
setStaticSwVersion(int staticSwVersion)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      */
getToolchainVersion()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
203      *
204      * @hide
205      */
setToolchainVersion(int toolchainVersion)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      */
getPeakMips()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
223      *
224      * @hide
225      */
setPeakMips(float peakMips)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      */
getStoppedPowerDrawMw()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
247      *
248      * @hide
249      */
setStoppedPowerDrawMw(float stoppedPowerDrawMw)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      */
getSleepPowerDrawMw()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.
273      *
274      * @hide
275      */
setSleepPowerDrawMw(float sleepPowerDrawMw)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      */
getPeakPowerDrawMw()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.
295      *
296      * @hide
297      */
setPeakPowerDrawMw(float peakPowerDrawMw)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      */
getSupportedSensors()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      */
getMemoryRegions()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
328      *
329      * @hide
330      */
setSupportedSensors(int[] supportedSensors)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
341      *
342      * @hide
343      */
setMemoryRegions(MemoryRegion[] memoryRegions)344     public void setMemoryRegions(MemoryRegion[] memoryRegions) {
345         mMemoryRegions = Arrays.copyOf(memoryRegions, memoryRegions.length);
346     }
347 
348     @Override
toString()349     public String toString() {
350       String retVal = "";
351       retVal += "Id : " + mId;
352       retVal += ", Name : " + mName;
353       retVal += "\n\tVendor : " + mVendor;
354       retVal += ", ToolChain : " + mToolchain;
355       retVal += "\n\tPlatformVersion : " + mPlatformVersion;
356       retVal += ", StaticSwVersion : " + mStaticSwVersion;
357       retVal += "\n\tPeakMips : " + mPeakMips;
358       retVal += ", StoppedPowerDraw : " + mStoppedPowerDrawMw + " mW";
359       retVal += ", PeakPowerDraw : " + mPeakPowerDrawMw + " mW";
360       retVal += ", MaxPacketLength : " + mMaxPacketLengthBytes + " Bytes";
361       retVal += "\n\tSupported sensors : " + Arrays.toString(mSupportedSensors);
362       retVal += "\n\tMemory Regions : " + Arrays.toString(mMemoryRegions);
363 
364       return retVal;
365     }
366 
ContextHubInfo(Parcel in)367     private ContextHubInfo(Parcel in) {
368         mId = in.readInt();
369         mName = in.readString();
370         mVendor = in.readString();
371         mToolchain = in.readString();
372         mPlatformVersion = in.readInt();
373         mToolchainVersion = in.readInt();
374         mStaticSwVersion = in.readInt();
375         mPeakMips = in.readFloat();
376         mStoppedPowerDrawMw = in.readFloat();
377         mSleepPowerDrawMw = in.readFloat();
378         mPeakPowerDrawMw = in.readFloat();
379         mMaxPacketLengthBytes = in.readInt();
380 
381         int numSupportedSensors = in.readInt();
382         mSupportedSensors = new int[numSupportedSensors];
383         in.readIntArray(mSupportedSensors);
384         mMemoryRegions = in.createTypedArray(MemoryRegion.CREATOR);
385     }
386 
describeContents()387     public int describeContents() {
388         return 0;
389     }
390 
writeToParcel(Parcel out, int flags)391     public void writeToParcel(Parcel out, int flags) {
392         out.writeInt(mId);
393         out.writeString(mName);
394         out.writeString(mVendor);
395         out.writeString(mToolchain);
396         out.writeInt(mPlatformVersion);
397         out.writeInt(mToolchainVersion);
398         out.writeInt(mStaticSwVersion);
399         out.writeFloat(mPeakMips);
400         out.writeFloat(mStoppedPowerDrawMw);
401         out.writeFloat(mSleepPowerDrawMw);
402         out.writeFloat(mPeakPowerDrawMw);
403         out.writeInt(mMaxPacketLengthBytes);
404 
405         out.writeInt(mSupportedSensors.length);
406         out.writeIntArray(mSupportedSensors);
407         out.writeTypedArray(mMemoryRegions, flags);
408     }
409 
410     public static final Parcelable.Creator<ContextHubInfo> CREATOR
411             = new Parcelable.Creator<ContextHubInfo>() {
412         public ContextHubInfo createFromParcel(Parcel in) {
413             return new ContextHubInfo(in);
414         }
415 
416         public ContextHubInfo[] newArray(int size) {
417             return new ContextHubInfo[size];
418         }
419     };
420 }
421