11d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi/*
21d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * Copyright (C) 2016 The Android Open Source Project
31d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi *
41d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * Licensed under the Apache License, Version 2.0 (the "License");
51d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * you may not use this file except in compliance with the License.
61d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * You may obtain a copy of the License at
71d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi *
81d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi *      http://www.apache.org/licenses/LICENSE-2.0
91d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi *
101d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * Unless required by applicable law or agreed to in writing, software
111d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * distributed under the License is distributed on an "AS IS" BASIS,
121d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * See the License for the specific language governing permissions and
141d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * limitations under the License.
151d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi */
161d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshipackage android.hardware.location;
171d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
181d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshiimport android.annotation.SystemApi;
191d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshiimport android.os.Parcel;
201d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshiimport android.os.Parcelable;
21cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiserimport android.util.Log;
221d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
239ff7d2235427b211344fa58b608424805a21aa24Peng Xu/** A class describing nano apps.
241d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * A nano app is a piece of executable code that can be
251d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * downloaded onto a specific architecture. These are targtted
261d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * for low power compute domains on a device.
271d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi *
281d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * Nano apps are expected to be used only by bundled apps only
291d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * at this time.
301d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi *
31581950cd76e008344a131d9670e0868ac185fbc3Arthur Ishiguro * @deprecated Use {@link android.hardware.location.NanoAppBinary} instead to load a nanoapp with
32581950cd76e008344a131d9670e0868ac185fbc3Arthur Ishiguro *             {@link android.hardware.location.ContextHubManager#loadNanoApp(
33581950cd76e008344a131d9670e0868ac185fbc3Arthur Ishiguro *             ContextHubInfo, NanoAppBinary)}.
34581950cd76e008344a131d9670e0868ac185fbc3Arthur Ishiguro *
351d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * @hide
361d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi */
371d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi@SystemApi
38581950cd76e008344a131d9670e0868ac185fbc3Arthur Ishiguro@Deprecated
39f3ab9cdc413fd921ec4f386a4ae55f01ae5510f7Arthur Ishiguropublic class NanoApp implements Parcelable {
40cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser    private final String TAG = "NanoApp";
41cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser
42cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser    private final String UNKNOWN = "Unknown";
43cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser
441d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    private String mPublisher;
451d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    private String mName;
461d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
476f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi    private long mAppId;
48cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser    private boolean mAppIdSet;
491d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    private int mAppVersion;
501d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
511d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    private int mNeededReadMemBytes;
521d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    private int mNeededWriteMemBytes;
531d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    private int mNeededExecMemBytes;
541d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
551d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    private int[] mNeededSensors;
561d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    private int[] mOutputEvents;
571d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    private byte[] mAppBinary;
581d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
59cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser    /**
60cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     * If this version of the constructor is used, the methods
616f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * {@link #setAppBinary(byte[])} and {@link #setAppId(long)} must be called
62cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     * prior to passing this object to any managers.
63cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     *
64afaddaaffbe5fadeafdeb6368e95ffdbbb1451beArthur Ishiguro     * @see #NanoApp(long, byte[])
65cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     */
661d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public NanoApp() {
67afaddaaffbe5fadeafdeb6368e95ffdbbb1451beArthur Ishiguro        this(0L, null);
68cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        mAppIdSet = false;
69cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser    }
70cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser
71cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser    /**
72cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     * Initialize a NanoApp with the given id and binary.
73cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     *
74cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     * While this sets defaults for other fields, users will want to provide
75cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     * other values for those fields in most cases.
76cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     *
77cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     * @see #setPublisher(String)
78cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     * @see #setName(String)
79cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     * @see #setAppVersion(int)
80cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     * @see #setNeededReadMemBytes(int)
81cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     * @see #setNeededWriteMemBytes(int)
82cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     * @see #setNeededExecMemBytes(int)
83cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     * @see #setNeededSensors(int[])
84cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     * @see #setOutputEvents(int[])
856f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     *
866f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * @deprecated Use NanoApp(long, byte[]) instead
876f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     */
886f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi    @Deprecated public NanoApp(int appId, byte[] appBinary) {
896f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi        Log.w(TAG, "NanoApp(int, byte[]) is deprecated, please use NanoApp(long, byte[]) instead.");
906f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi    }
916f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi
926f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi    /**
936f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * Initialize a NanoApp with the given id and binary.
946f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     *
956f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * While this sets defaults for other fields, users will want to provide
966f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * other values for those fields in most cases.
976f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     *
986f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * @see #setPublisher(String)
996f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * @see #setName(String)
1006f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * @see #setAppVersion(int)
1016f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * @see #setNeededReadMemBytes(int)
1026f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * @see #setNeededWriteMemBytes(int)
1036f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * @see #setNeededExecMemBytes(int)
1046f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * @see #setNeededSensors(int[])
1056f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * @see #setOutputEvents(int[])
106cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser     */
1076f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi    public NanoApp(long appId, byte[] appBinary) {
108cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        mPublisher = UNKNOWN;
109cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        mName = UNKNOWN;
110cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser
111cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        mAppId = appId;
112cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        mAppIdSet = true;
113cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        mAppVersion = 0;
114cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser
115cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        mNeededReadMemBytes = 0;
116cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        mNeededWriteMemBytes = 0;
117cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        mNeededExecMemBytes = 0;
118cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser
119cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        mNeededSensors = new int[0];
120cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        mOutputEvents = new int[0];
121cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        mAppBinary = appBinary;
1221d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
1231d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
1241d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
1251d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * Set the publisher name
1261d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
1271d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @param publisher name of the publisher of this nano app
1281d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
1291d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public void setPublisher(String publisher) {
1301d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mPublisher = publisher;
1311d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
1321d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
1331d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
1341d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * set the name of the app
1351d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
1361d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @param name   name of the app
1371d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
1381d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public void setName(String name) {
1391d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mName = name;
1401d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
1411d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
1421d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
1431d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * set the app identifier
1441d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
1456f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi     * @param appId  app identifier
1461d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
1476f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi    public void setAppId(long appId) {
1481d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mAppId = appId;
149cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        mAppIdSet = true;
1501d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
1511d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
1521d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
1531d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * Set the app version
1541d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
1551d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @param appVersion app version
1561d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
1571d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public void setAppVersion(int appVersion) {
1581d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mAppVersion = appVersion;
1591d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
1601d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
1611d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
1621d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * set memory needed as read only
1631d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
1641d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @param neededReadMemBytes
1651d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *               read only memory needed in bytes
1661d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
1671d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public void setNeededReadMemBytes(int neededReadMemBytes) {
1681d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mNeededReadMemBytes = neededReadMemBytes;
1691d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
1701d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
1711d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
1721d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * set writable memory needed in bytes
1731d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
1741d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @param neededWriteMemBytes
1751d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *               writable memory needed in bytes
1761d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
1771d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public void setNeededWriteMemBytes(int neededWriteMemBytes) {
1781d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mNeededWriteMemBytes = neededWriteMemBytes;
1791d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
1801d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
1811d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
1821d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * set executable memory needed
1831d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
1841d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @param neededExecMemBytes
1851d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *               executable memory needed in bytes
1861d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
1871d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public void setNeededExecMemBytes(int neededExecMemBytes) {
1881d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mNeededExecMemBytes = neededExecMemBytes;
1891d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
1901d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
1911d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
1921d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * set the sensors needed for this app
1931d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
1941d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @param neededSensors
1951d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *               needed Sensors
1961d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
1971d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public void setNeededSensors(int[] neededSensors) {
1981d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mNeededSensors = neededSensors;
1991d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
2001d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
2011d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public void setOutputEvents(int[] outputEvents) {
2021d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mOutputEvents = outputEvents;
2031d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
2041d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
2051d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
2061d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * set output events returned by the nano app
2071d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
2081d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @param appBinary generated events
2091d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
2101d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public void setAppBinary(byte[] appBinary) {
2111d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mAppBinary = appBinary;
2121d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
2131d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
2141d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
2151d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
2161d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * get the publisher name
2171d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
2181d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @return publisher name
2191d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
2201d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public String getPublisher() {
2211f3560e75ea4101f5d80262147e6860e43f1a907Greg Kaiser        return mPublisher;
2221d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
2231d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
2241d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
2251d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * get the name of the app
2261d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
2271d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @return app name
2281d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
2291d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public String getName() {
2301f3560e75ea4101f5d80262147e6860e43f1a907Greg Kaiser        return mName;
2311d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
2321d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
2331d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
2341d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * get the identifier of the app
2351d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
2361d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @return identifier for this app
2371d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
2386f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi    public long getAppId() {
2391f3560e75ea4101f5d80262147e6860e43f1a907Greg Kaiser        return mAppId;
2401d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
2411d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
2421d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
2431d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * get the app version
2441d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
2451d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @return app version
2461d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
2471d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public int getAppVersion() {
2481f3560e75ea4101f5d80262147e6860e43f1a907Greg Kaiser        return mAppVersion;
2491d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
2501d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
2511d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
2521d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * get the ammount of readable memory needed by this app
2531d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
2541d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @return readable memory needed in bytes
2551d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
2561d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public int getNeededReadMemBytes() {
2571f3560e75ea4101f5d80262147e6860e43f1a907Greg Kaiser        return mNeededReadMemBytes;
2581d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
2591d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
2601d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
2611d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * get the ammount og writable memory needed in bytes
2621d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
2631d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @return writable memory needed in bytes
2641d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
2651d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public int getNeededWriteMemBytes() {
2661f3560e75ea4101f5d80262147e6860e43f1a907Greg Kaiser        return mNeededWriteMemBytes;
2671d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
2681d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
2691d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
2701d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * executable memory needed in bytes
2711d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
2721d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @return executable memory needed in bytes
2731d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
2741d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public int getNeededExecMemBytes() {
2751f3560e75ea4101f5d80262147e6860e43f1a907Greg Kaiser        return mNeededExecMemBytes;
2761d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
2771d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
2781d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
2791d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * get the sensors needed by this app
2801d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
2811d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @return sensors needed
2821d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
2831d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public int[] getNeededSensors() {
2841f3560e75ea4101f5d80262147e6860e43f1a907Greg Kaiser        return mNeededSensors;
2851d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
2861d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
2871d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
2881d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * get the events generated by this app
2891d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
2901d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @return generated events
2911d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
2921d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public int[] getOutputEvents() {
2931f3560e75ea4101f5d80262147e6860e43f1a907Greg Kaiser        return mOutputEvents;
2941d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
2951d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
2961d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    /**
2971d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * get the binary for this app
2981d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     *
2991d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     * @return app binary
3001d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi     */
3011d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public byte[] getAppBinary() {
3021f3560e75ea4101f5d80262147e6860e43f1a907Greg Kaiser        return mAppBinary;
3031d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
3041d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
3051d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    private NanoApp(Parcel in) {
3061d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mPublisher = in.readString();
3071d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mName = in.readString();
3081d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
3096f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi        mAppId = in.readLong();
3101d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mAppVersion = in.readInt();
3111d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mNeededReadMemBytes = in.readInt();
3121d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mNeededWriteMemBytes = in.readInt();
3131d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mNeededExecMemBytes = in.readInt();
3141d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
3151d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        int mNeededSensorsLength = in.readInt();
3161d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mNeededSensors = new int[mNeededSensorsLength];
3171d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        in.readIntArray(mNeededSensors);
3181d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
3191d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        int mOutputEventsLength = in.readInt();
3201d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mOutputEvents = new int[mOutputEventsLength];
3211d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        in.readIntArray(mOutputEvents);
3221d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
3231d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        int binaryLength = in.readInt();
3241d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        mAppBinary = new byte[binaryLength];
3251d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        in.readByteArray(mAppBinary);
3261d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
3271d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
3281d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public int describeContents() {
3291d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        return 0;
3301d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
3311d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
3321d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public void writeToParcel(Parcel out, int flags) {
333cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        if (mAppBinary == null) {
334cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser            throw new IllegalStateException("Must set non-null AppBinary for nanoapp " + mName);
335cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        }
336cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        if (!mAppIdSet) {
337cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser            throw new IllegalStateException("Must set AppId for nanoapp " + mName);
338cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser        }
339cb83bd04b7dac57be7f382be7343bfe9f1a598abGreg Kaiser
3401d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        out.writeString(mPublisher);
3411d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        out.writeString(mName);
3426f64bf059030ba53f7869f8639e6082b0f1f8824Ashutosh Joshi        out.writeLong(mAppId);
3431d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        out.writeInt(mAppVersion);
3441d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        out.writeInt(mNeededReadMemBytes);
3451d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        out.writeInt(mNeededWriteMemBytes);
3461d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        out.writeInt(mNeededExecMemBytes);
3471d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
3481d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        out.writeInt(mNeededSensors.length);
3491d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        out.writeIntArray(mNeededSensors);
3501d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
3511d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        out.writeInt(mOutputEvents.length);
3521d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        out.writeIntArray(mOutputEvents);
3531d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
3541d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        out.writeInt(mAppBinary.length);
3551d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        out.writeByteArray(mAppBinary);
3561d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    }
3571d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
3581d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    public static final Parcelable.Creator<NanoApp> CREATOR
3591d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi            = new Parcelable.Creator<NanoApp>() {
3601d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        public NanoApp createFromParcel(Parcel in) {
3611d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi            return new NanoApp(in);
3621d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        }
3631d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
3641d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        public NanoApp[] newArray(int size) {
3651d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi            return new NanoApp[size];
3661d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi        }
3671d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    };
3686239cc6fe1d18ce4365c56346a09c7963dfa8f10Ashutosh Joshi
3696239cc6fe1d18ce4365c56346a09c7963dfa8f10Ashutosh Joshi    @Override
3706239cc6fe1d18ce4365c56346a09c7963dfa8f10Ashutosh Joshi    public String toString() {
3716239cc6fe1d18ce4365c56346a09c7963dfa8f10Ashutosh Joshi        String retVal = "Id : " + mAppId;
3726239cc6fe1d18ce4365c56346a09c7963dfa8f10Ashutosh Joshi        retVal += ", Version : " + mAppVersion;
3736239cc6fe1d18ce4365c56346a09c7963dfa8f10Ashutosh Joshi        retVal += ", Name : " + mName;
3746239cc6fe1d18ce4365c56346a09c7963dfa8f10Ashutosh Joshi        retVal += ", Publisher : " + mPublisher;
3756239cc6fe1d18ce4365c56346a09c7963dfa8f10Ashutosh Joshi
3766239cc6fe1d18ce4365c56346a09c7963dfa8f10Ashutosh Joshi        return retVal;
3776239cc6fe1d18ce4365c56346a09c7963dfa8f10Ashutosh Joshi    }
3781d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi}
379