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