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 | |
| 17 | package android.hardware.location; |
| 18 | |
| 19 | |
| 20 | import android.annotation.SystemApi; |
| 21 | import android.os.Parcel; |
| 22 | import android.os.Parcelable; |
| 23 | |
| 24 | /** |
| 25 | * @hide |
| 26 | */ |
| 27 | @SystemApi |
| 28 | public class NanoAppInstanceInfo { |
| 29 | private String mPublisher; |
| 30 | private String mName; |
| 31 | |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 32 | private long mAppId; |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 33 | private int mAppVersion; |
| 34 | |
| 35 | private int mNeededReadMemBytes; |
| 36 | private int mNeededWriteMemBytes; |
| 37 | private int mNeededExecMemBytes; |
| 38 | |
| 39 | private int[] mNeededSensors; |
| 40 | private int[] mOutputEvents; |
| 41 | |
| 42 | private int mContexthubId; |
| 43 | private int mHandle; |
| 44 | |
| 45 | public NanoAppInstanceInfo() { |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * get the publisher of this app |
| 50 | * |
| 51 | * @return String - name of the publisher |
| 52 | */ |
| 53 | public String getPublisher() { |
| 54 | return mPublisher; |
| 55 | } |
| 56 | |
| 57 | |
| 58 | /** |
| 59 | * set the publisher name for the app |
| 60 | * |
| 61 | * @param publisher - name of the publisher |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 62 | * |
| 63 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 64 | */ |
| 65 | public void setPublisher(String publisher) { |
| 66 | mPublisher = publisher; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * get the name of the app |
| 71 | * |
| 72 | * @return String - name of the app |
| 73 | */ |
| 74 | public String getName() { |
| 75 | return mName; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * set the name of the app |
| 80 | * |
| 81 | * @param name - name of the app |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 82 | * |
| 83 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 84 | */ |
| 85 | public void setName(String name) { |
| 86 | mName = name; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Get the application identifier |
| 91 | * |
| 92 | * @return int - application identifier |
| 93 | */ |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 94 | public long getAppId() { |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 95 | return mAppId; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Set the application identifier |
| 100 | * |
| 101 | * @param appId - application identifier |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 102 | * |
| 103 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 104 | */ |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 105 | public void setAppId(long appId) { |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 106 | mAppId = appId; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Set the application version |
| 111 | * |
| 112 | * @return int - version of the app |
| 113 | */ |
| 114 | public int getAppVersion() { |
| 115 | return mAppVersion; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Set the application version |
| 120 | * |
| 121 | * @param appVersion - version of the app |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 122 | * |
| 123 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 124 | */ |
| 125 | public void setAppVersion(int appVersion) { |
| 126 | mAppVersion = appVersion; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Get the read memory needed by the app |
| 131 | * |
| 132 | * @return int - readable memory needed in bytes |
| 133 | */ |
| 134 | public int getNeededReadMemBytes() { |
| 135 | return mNeededReadMemBytes; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Set the read memory needed by the app |
| 140 | * |
| 141 | * @param neededReadMemBytes - readable Memory needed in bytes |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 142 | * |
| 143 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 144 | */ |
| 145 | public void setNeededReadMemBytes(int neededReadMemBytes) { |
| 146 | mNeededReadMemBytes = neededReadMemBytes; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * get writable memory needed by the app |
| 151 | * |
| 152 | * @return int - writable memory needed by the app |
| 153 | */ |
| 154 | public int getNeededWriteMemBytes() { |
| 155 | return mNeededWriteMemBytes; |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * set writable memory needed by the app |
| 160 | * |
| 161 | * @param neededWriteMemBytes - writable memory needed by the |
| 162 | * app |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 163 | * |
| 164 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 165 | */ |
| 166 | public void setNeededWriteMemBytes(int neededWriteMemBytes) { |
| 167 | mNeededWriteMemBytes = neededWriteMemBytes; |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * get executable memory needed by the app |
| 172 | * |
| 173 | * @return int - executable memory needed by the app |
| 174 | */ |
| 175 | public int getNeededExecMemBytes() { |
| 176 | return mNeededExecMemBytes; |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * set executable memory needed by the app |
| 181 | * |
| 182 | * @param neededExecMemBytes - executable memory needed by the |
| 183 | * app |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 184 | * |
| 185 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 186 | */ |
| 187 | public void setNeededExecMemBytes(int neededExecMemBytes) { |
| 188 | mNeededExecMemBytes = neededExecMemBytes; |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Get the sensors needed by this app |
| 193 | * |
| 194 | * @return int[] all the required sensors needed by this app |
| 195 | */ |
| 196 | public int[] getNeededSensors() { |
| 197 | return mNeededSensors; |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * set the sensors needed by this app |
| 202 | * |
| 203 | * @param neededSensors - all the sensors needed by this app |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 204 | * |
| 205 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 206 | */ |
| 207 | public void setNeededSensors(int[] neededSensors) { |
| 208 | mNeededSensors = neededSensors; |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * get the events generated by this app |
| 213 | * |
| 214 | * @return all the events that can be generated by this app |
| 215 | */ |
| 216 | public int[] getOutputEvents() { |
| 217 | return mOutputEvents; |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * set the output events that can be generated by this app |
| 222 | * |
| 223 | * @param outputEvents - the events that may be generated by |
| 224 | * this app |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 225 | * |
| 226 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 227 | */ |
| 228 | public void setOutputEvents(int[] outputEvents) { |
| 229 | mOutputEvents = outputEvents; |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * get the context hub identifier |
| 234 | * |
| 235 | * @return int - system unique hub identifier |
| 236 | */ |
| 237 | public int getContexthubId() { |
| 238 | return mContexthubId; |
| 239 | } |
| 240 | |
| 241 | /** |
| 242 | * set the context hub identifier |
| 243 | * |
| 244 | * @param contexthubId - system wide unique identifier |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 245 | * |
| 246 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 247 | */ |
| 248 | public void setContexthubId(int contexthubId) { |
| 249 | mContexthubId = contexthubId; |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * get a handle to the nano app instance |
| 254 | * |
| 255 | * @return int - handle to this instance |
| 256 | */ |
| 257 | public int getHandle() { |
| 258 | return mHandle; |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * set the handle for an app instance |
| 263 | * |
| 264 | * @param handle - handle to this instance |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 265 | * |
| 266 | * @hide |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 267 | */ |
| 268 | public void setHandle(int handle) { |
| 269 | mHandle = handle; |
| 270 | } |
| 271 | |
| 272 | |
| 273 | private NanoAppInstanceInfo(Parcel in) { |
| 274 | mPublisher = in.readString(); |
| 275 | mName = in.readString(); |
| 276 | |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 277 | mAppId = in.readLong(); |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 278 | mAppVersion = in.readInt(); |
| 279 | mNeededReadMemBytes = in.readInt(); |
| 280 | mNeededWriteMemBytes = in.readInt(); |
| 281 | mNeededExecMemBytes = in.readInt(); |
| 282 | |
| 283 | int mNeededSensorsLength = in.readInt(); |
| 284 | mNeededSensors = new int[mNeededSensorsLength]; |
| 285 | in.readIntArray(mNeededSensors); |
| 286 | |
| 287 | int mOutputEventsLength = in.readInt(); |
| 288 | mOutputEvents = new int[mOutputEventsLength]; |
| 289 | in.readIntArray(mOutputEvents); |
| 290 | } |
| 291 | |
| 292 | public int describeContents() { |
| 293 | return 0; |
| 294 | } |
| 295 | |
| 296 | public void writeToParcel(Parcel out, int flags) { |
| 297 | out.writeString(mPublisher); |
| 298 | out.writeString(mName); |
Ashutosh Joshi | b741e3b | 2016-03-29 09:19:56 -0700 | [diff] [blame] | 299 | out.writeLong(mAppId); |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 300 | out.writeInt(mAppVersion); |
| 301 | out.writeInt(mContexthubId); |
| 302 | out.writeInt(mNeededReadMemBytes); |
| 303 | out.writeInt(mNeededWriteMemBytes); |
| 304 | out.writeInt(mNeededExecMemBytes); |
| 305 | |
| 306 | out.writeInt(mNeededSensors.length); |
| 307 | out.writeIntArray(mNeededSensors); |
| 308 | |
| 309 | out.writeInt(mOutputEvents.length); |
| 310 | out.writeIntArray(mOutputEvents); |
Ashutosh Joshi | 1d1ac54 | 2016-01-18 17:19:27 -0800 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | public static final Parcelable.Creator<NanoAppInstanceInfo> CREATOR |
| 314 | = new Parcelable.Creator<NanoAppInstanceInfo>() { |
| 315 | public NanoAppInstanceInfo createFromParcel(Parcel in) { |
| 316 | return new NanoAppInstanceInfo(in); |
| 317 | } |
| 318 | |
| 319 | public NanoAppInstanceInfo[] newArray(int size) { |
| 320 | return new NanoAppInstanceInfo[size]; |
| 321 | } |
| 322 | }; |
| 323 | } |