2 * Copyright (C) 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.hardware.location;
19 import android.annotation.NonNull;
20 import android.annotation.SystemApi;
21 import android.os.Parcel;
22 import android.os.Parcelable;
24 import libcore.util.EmptyArray;
27 * Describes an instance of a nanoapp, used by the internal state manged by ContextHubService.
29 * TODO(b/69270990) Remove this class once the old API is deprecated.
31 * @deprecated Use {@link android.hardware.location.NanoAppState} instead.
37 public class NanoAppInstanceInfo {
38 private String mPublisher = "Unknown";
39 private String mName = "Unknown";
43 private int mAppVersion;
44 private int mContexthubId;
46 private int mNeededReadMemBytes = 0;
47 private int mNeededWriteMemBytes = 0;
48 private int mNeededExecMemBytes = 0;
50 private int[] mNeededSensors = EmptyArray.INT;
51 private int[] mOutputEvents = EmptyArray.INT;
53 public NanoAppInstanceInfo() {
59 public NanoAppInstanceInfo(int handle, long appId, int appVersion, int contextHubId) {
62 mAppVersion = appVersion;
63 mContexthubId = contextHubId;
67 * get the publisher of this app
69 * @return String - name of the publisher
71 public String getPublisher() {
76 * get the name of the app
78 * @return String - name of the app
80 public String getName() {
85 * Get the application identifier
87 * @return int - application identifier
89 public long getAppId() {
94 * Get the application version
96 * @return int - version of the app
98 public int getAppVersion() {
103 * Get the read memory needed by the app
105 * @return int - readable memory needed in bytes
107 public int getNeededReadMemBytes() {
108 return mNeededReadMemBytes;
112 * get writable memory needed by the app
114 * @return int - writable memory needed by the app
116 public int getNeededWriteMemBytes() {
117 return mNeededWriteMemBytes;
121 * get executable memory needed by the app
123 * @return int - executable memory needed by the app
125 public int getNeededExecMemBytes() {
126 return mNeededExecMemBytes;
130 * Get the sensors needed by this app
132 * @return int[] all the required sensors needed by this app
135 public int[] getNeededSensors() {
136 return mNeededSensors;
140 * get the events generated by this app
142 * @return all the events that can be generated by this app
145 public int[] getOutputEvents() {
146 return mOutputEvents;
150 * get the context hub identifier
152 * @return int - system unique hub identifier
154 public int getContexthubId() {
155 return mContexthubId;
159 * get a handle to the nano app instance
161 * @return int - handle to this instance
163 public int getHandle() {
167 private NanoAppInstanceInfo(Parcel in) {
168 mPublisher = in.readString();
169 mName = in.readString();
171 mHandle = in.readInt();
172 mAppId = in.readLong();
173 mAppVersion = in.readInt();
174 mContexthubId = in.readInt();
175 mNeededReadMemBytes = in.readInt();
176 mNeededWriteMemBytes = in.readInt();
177 mNeededExecMemBytes = in.readInt();
179 int neededSensorsLength = in.readInt();
180 mNeededSensors = new int[neededSensorsLength];
181 in.readIntArray(mNeededSensors);
183 int outputEventsLength = in.readInt();
184 mOutputEvents = new int[outputEventsLength];
185 in.readIntArray(mOutputEvents);
188 public int describeContents() {
192 public void writeToParcel(Parcel out, int flags) {
193 out.writeString(mPublisher);
194 out.writeString(mName);
196 out.writeInt(mHandle);
197 out.writeLong(mAppId);
198 out.writeInt(mAppVersion);
199 out.writeInt(mContexthubId);
200 out.writeInt(mNeededReadMemBytes);
201 out.writeInt(mNeededWriteMemBytes);
202 out.writeInt(mNeededExecMemBytes);
204 // arrays are never null
205 out.writeInt(mNeededSensors.length);
206 out.writeIntArray(mNeededSensors);
207 out.writeInt(mOutputEvents.length);
208 out.writeIntArray(mOutputEvents);
211 public static final Parcelable.Creator<NanoAppInstanceInfo> CREATOR
212 = new Parcelable.Creator<NanoAppInstanceInfo>() {
213 public NanoAppInstanceInfo createFromParcel(Parcel in) {
214 return new NanoAppInstanceInfo(in);
217 public NanoAppInstanceInfo[] newArray(int size) {
218 return new NanoAppInstanceInfo[size];
223 public String toString() {
224 String retVal = "handle : " + mHandle;
225 retVal += ", Id : 0x" + Long.toHexString(mAppId);
226 retVal += ", Version : 0x" + Integer.toHexString(mAppVersion);