Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 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 |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 26 | */ |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 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 | |
| 41 | private int[] mSupportedSensors; |
| 42 | |
| 43 | private MemoryRegion[] mMemoryRegions; |
| 44 | |
| 45 | public ContextHubInfo() { |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * get the context hub unique identifer |
| 50 | * |
| 51 | * @return int - unique system wide identifier |
| 52 | */ |
| 53 | public int getId() { |
| 54 | return mId; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * set the context hub unique identifer |
| 59 | * |
| 60 | * @param id - unique system wide identifier for the hub |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 61 | * |
| 62 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 63 | */ |
| 64 | public void setId(int id) { |
| 65 | mId = id; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * get a string as a hub name |
| 70 | * |
| 71 | * @return String - a name for the hub |
| 72 | */ |
| 73 | public String getName() { |
| 74 | return mName; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * set a string as the hub name |
| 79 | * |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 80 | * @param name - the name for the hub |
| 81 | * |
| 82 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 83 | */ |
| 84 | public void setName(String name) { |
| 85 | mName = name; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * get a string as the vendor name |
| 90 | * |
| 91 | * @return String - a name for the vendor |
| 92 | */ |
| 93 | public String getVendor() { |
| 94 | return mVendor; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * set a string as the vendor name |
| 99 | * |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 100 | * @param vendor - a name for the vendor |
| 101 | * |
| 102 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 103 | */ |
| 104 | public void setVendor(String vendor) { |
| 105 | mVendor = vendor; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * get tool chain string |
| 110 | * |
| 111 | * @return String - description of the tool chain |
| 112 | */ |
| 113 | public String getToolchain() { |
| 114 | return mToolchain; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * set tool chain string |
| 119 | * |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 120 | * @param toolchain - description of the tool chain |
| 121 | * |
| 122 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 123 | */ |
| 124 | public void setToolchain(String toolchain) { |
| 125 | mToolchain = toolchain; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * get platform version |
| 130 | * |
| 131 | * @return int - platform version number |
| 132 | */ |
| 133 | public int getPlatformVersion() { |
| 134 | return mPlatformVersion; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * set platform version |
| 139 | * |
| 140 | * @param platformVersion - platform version number |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 141 | * |
| 142 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 143 | */ |
| 144 | public void setPlatformVersion(int platformVersion) { |
| 145 | mPlatformVersion = platformVersion; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * get static platform version number |
| 150 | * |
| 151 | * @return int - platform version number |
| 152 | */ |
| 153 | public int getStaticSwVersion() { |
| 154 | return mStaticSwVersion; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * set platform software version |
| 159 | * |
| 160 | * @param staticSwVersion - platform static s/w version number |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 161 | * |
| 162 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 163 | */ |
| 164 | public void setStaticSwVersion(int staticSwVersion) { |
| 165 | mStaticSwVersion = staticSwVersion; |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * get the tool chain version |
| 170 | * |
| 171 | * @return int - the tool chain version |
| 172 | */ |
| 173 | public int getToolchainVersion() { |
| 174 | return mToolchainVersion; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * set the tool chain version number |
| 179 | * |
| 180 | * @param toolchainVersion - tool chain version number |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 181 | * |
| 182 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 183 | */ |
| 184 | public void setToolchainVersion(int toolchainVersion) { |
| 185 | mToolchainVersion = toolchainVersion; |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * get the peak processing mips the hub can support |
| 190 | * |
| 191 | * @return float - peak MIPS that this hub can deliver |
| 192 | */ |
| 193 | public float getPeakMips() { |
| 194 | return mPeakMips; |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * set the peak mips that this hub can support |
| 199 | * |
| 200 | * @param peakMips - peak mips this hub can deliver |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 201 | * |
| 202 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 203 | */ |
| 204 | public void setPeakMips(float peakMips) { |
| 205 | mPeakMips = peakMips; |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * get the stopped power draw in milliwatts |
| 210 | * This assumes that the hub enter a stopped state - which is |
| 211 | * different from the sleep state. Latencies on exiting the |
| 212 | * sleep state are typically higher and expect to be in multiple |
| 213 | * milliseconds. |
| 214 | * |
| 215 | * @return float - power draw by the hub in stopped state |
| 216 | */ |
| 217 | public float getStoppedPowerDrawMw() { |
| 218 | return mStoppedPowerDrawMw; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Set the power consumed by the hub in stopped state |
| 223 | * |
| 224 | * @param stoppedPowerDrawMw - stopped power in milli watts |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 225 | * |
| 226 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 227 | */ |
| 228 | public void setStoppedPowerDrawMw(float stoppedPowerDrawMw) { |
| 229 | mStoppedPowerDrawMw = stoppedPowerDrawMw; |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * get the power draw of the hub in sleep mode. This assumes |
| 234 | * that the hub supports a sleep mode in which the power draw is |
| 235 | * lower than the power consumed when the hub is actively |
| 236 | * processing. As a guideline, assume that the hub should be |
| 237 | * able to enter sleep mode if it knows reliably on completion |
| 238 | * of some task that the next interrupt/scheduled work item is |
| 239 | * at least 250 milliseconds later. |
| 240 | * |
| 241 | * @return float - sleep power draw in milli watts |
| 242 | */ |
| 243 | public float getSleepPowerDrawMw() { |
| 244 | return mSleepPowerDrawMw; |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * Set the sleep power draw in milliwatts |
| 249 | * |
| 250 | * @param sleepPowerDrawMw - sleep power draw in milliwatts. |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 251 | * |
| 252 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 253 | */ |
| 254 | public void setSleepPowerDrawMw(float sleepPowerDrawMw) { |
| 255 | mSleepPowerDrawMw = sleepPowerDrawMw; |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * get the peak powe draw of the hub. This is the power consumed |
| 260 | * by the hub at maximum load. |
| 261 | * |
| 262 | * @return float - peak power draw |
| 263 | */ |
| 264 | public float getPeakPowerDrawMw() { |
| 265 | return mPeakPowerDrawMw; |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * set the peak power draw of the hub |
| 270 | * |
| 271 | * @param peakPowerDrawMw - peak power draw of the hub in |
| 272 | * milliwatts. |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 273 | * |
| 274 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 275 | */ |
| 276 | public void setPeakPowerDrawMw(float peakPowerDrawMw) { |
| 277 | mPeakPowerDrawMw = peakPowerDrawMw; |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * get the sensors supported by this hub |
| 282 | * |
| 283 | * @return int[] - all the supported sensors on this hub |
| 284 | * |
| 285 | * @see ContextHubManager |
| 286 | */ |
| 287 | public int[] getSupportedSensors() { |
| 288 | return Arrays.copyOf(mSupportedSensors, mSupportedSensors.length); |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * get the various memory regions on this hub |
| 293 | * |
| 294 | * @return MemoryRegion[] - all the memory regions on this hub |
| 295 | * |
| 296 | * @see MemoryRegion |
| 297 | */ |
| 298 | public MemoryRegion[] getMemoryRegions() { |
| 299 | return Arrays.copyOf(mMemoryRegions, mMemoryRegions.length); |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * set the supported sensors on this hub |
| 304 | * |
| 305 | * @param supportedSensors - supported sensors on this hub |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 306 | * |
| 307 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 308 | */ |
| 309 | public void setSupportedSensors(int[] supportedSensors) { |
| 310 | mSupportedSensors = Arrays.copyOf(supportedSensors, supportedSensors.length); |
| 311 | } |
| 312 | |
| 313 | /** |
| 314 | * set memory regions for this hub |
| 315 | * |
| 316 | * @param memoryRegions - memory regions information |
| 317 | * |
| 318 | * @see MemoryRegion |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 319 | * |
| 320 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 321 | */ |
| 322 | public void setMemoryRegions(MemoryRegion[] memoryRegions) { |
| 323 | mMemoryRegions = Arrays.copyOf(memoryRegions, memoryRegions.length); |
| 324 | } |
| 325 | |
| 326 | private ContextHubInfo(Parcel in) { |
| 327 | mId = in.readInt(); |
| 328 | mName = in.readString(); |
| 329 | mVendor = in.readString(); |
| 330 | mToolchain = in.readString(); |
| 331 | mPlatformVersion = in.readInt(); |
| 332 | mToolchainVersion = in.readInt(); |
| 333 | mStaticSwVersion = in.readInt(); |
| 334 | mPeakMips = in.readFloat(); |
| 335 | mStoppedPowerDrawMw = in.readFloat(); |
| 336 | mSleepPowerDrawMw = in.readFloat(); |
| 337 | mPeakPowerDrawMw = in.readFloat(); |
| 338 | |
| 339 | int numSupportedSensors = in.readInt(); |
| 340 | mSupportedSensors = new int[numSupportedSensors]; |
| 341 | in.readIntArray(mSupportedSensors); |
| 342 | mMemoryRegions = in.createTypedArray(MemoryRegion.CREATOR); |
| 343 | } |
| 344 | |
| 345 | public int describeContents() { |
| 346 | return 0; |
| 347 | } |
| 348 | |
| 349 | public void writeToParcel(Parcel out, int flags) { |
| 350 | out.writeInt(mId); |
| 351 | out.writeString(mName); |
| 352 | out.writeString(mVendor); |
| 353 | out.writeString(mToolchain); |
| 354 | out.writeInt(mPlatformVersion); |
| 355 | out.writeInt(mToolchainVersion); |
| 356 | out.writeInt(mStaticSwVersion); |
| 357 | out.writeFloat(mPeakMips); |
| 358 | out.writeFloat(mStoppedPowerDrawMw); |
| 359 | out.writeFloat(mSleepPowerDrawMw); |
| 360 | out.writeFloat(mPeakPowerDrawMw); |
| 361 | |
| 362 | out.writeInt(mSupportedSensors.length); |
| 363 | out.writeIntArray(mSupportedSensors); |
| 364 | out.writeTypedArray(mMemoryRegions, flags); |
| 365 | } |
| 366 | |
| 367 | public static final Parcelable.Creator<ContextHubInfo> CREATOR |
| 368 | = new Parcelable.Creator<ContextHubInfo>() { |
| 369 | public ContextHubInfo createFromParcel(Parcel in) { |
| 370 | return new ContextHubInfo(in); |
| 371 | } |
| 372 | |
| 373 | public ContextHubInfo[] newArray(int size) { |
| 374 | return new ContextHubInfo[size]; |
| 375 | } |
| 376 | }; |
| 377 | } |