Home | History | Annotate | Download | only in location
      1 /*
      2  * Copyright 2017 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 /**
     23  * A class describing the nanoapp state information resulting from a query to a Context Hub.
     24  *
     25  * @hide
     26  */
     27 @SystemApi
     28 public final class NanoAppState implements Parcelable {
     29     private long mNanoAppId;
     30     private int mNanoAppVersion;
     31     private boolean mIsEnabled;
     32 
     33     public NanoAppState(long nanoAppId, int appVersion, boolean enabled) {
     34         mNanoAppId = nanoAppId;
     35         mNanoAppVersion = appVersion;
     36         mIsEnabled = enabled;
     37     }
     38 
     39     /**
     40      * @return the NanoAppInfo for this app
     41      */
     42     public long getNanoAppId() {
     43         return mNanoAppId;
     44     }
     45 
     46     /**
     47      * @return the app version
     48      */
     49     public long getNanoAppVersion() {
     50         return mNanoAppVersion;
     51     }
     52 
     53     /**
     54      * @return {@code true} if the app is enabled at the Context Hub, {@code false} otherwise
     55      */
     56     public boolean isEnabled() {
     57         return mIsEnabled;
     58     }
     59 
     60     private NanoAppState(Parcel in) {
     61         mNanoAppId = in.readLong();
     62         mNanoAppVersion = in.readInt();
     63         mIsEnabled = (in.readInt() == 1);
     64     }
     65 
     66     @Override
     67     public int describeContents() {
     68         return 0;
     69     }
     70 
     71     @Override
     72     public void writeToParcel(Parcel out, int flags) {
     73         out.writeLong(mNanoAppId);
     74         out.writeInt(mNanoAppVersion);
     75         out.writeInt(mIsEnabled ? 1 : 0);
     76     }
     77 
     78     public static final Creator<NanoAppState> CREATOR =
     79             new Creator<NanoAppState>() {
     80                 @Override
     81                 public NanoAppState createFromParcel(Parcel in) {
     82                     return new NanoAppState(in);
     83                 }
     84 
     85                 @Override
     86                 public NanoAppState[] newArray(int size) {
     87                     return new NanoAppState[size];
     88                 }
     89             };
     90 }
     91