Home | History | Annotate | Download | only in wifi
      1 /*
      2  * Copyright (C) 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 
     17 package com.android.settingslib.wifi;
     18 
     19 import android.net.ScoredNetwork;
     20 import android.os.Parcel;
     21 import android.os.Parcelable;
     22 
     23 /**
     24  * Data encapsulation object to associate a time with a {@link ScoredNetwork}
     25  */
     26 class TimestampedScoredNetwork implements Parcelable {
     27     private ScoredNetwork mScore;
     28     private long mUpdatedTimestampMillis;
     29 
     30     TimestampedScoredNetwork(ScoredNetwork score, long updatedTimestampMillis) {
     31         mScore = score;
     32         mUpdatedTimestampMillis = updatedTimestampMillis;
     33     }
     34 
     35     protected TimestampedScoredNetwork(Parcel in) {
     36         mScore = in.readParcelable(ScoredNetwork.class.getClassLoader());
     37         mUpdatedTimestampMillis = in.readLong();
     38     }
     39 
     40     public void update(ScoredNetwork score, long updatedTimestampMillis) {
     41         mScore = score;
     42         mUpdatedTimestampMillis = updatedTimestampMillis;
     43     }
     44 
     45     public ScoredNetwork getScore() {
     46         return mScore;
     47     }
     48 
     49     public long getUpdatedTimestampMillis() {
     50         return mUpdatedTimestampMillis;
     51     }
     52 
     53     @Override
     54     public int describeContents() {
     55         return 0;
     56     }
     57 
     58     @Override
     59     public void writeToParcel(Parcel dest, int flags) {
     60         dest.writeParcelable(mScore, flags);
     61         dest.writeLong(mUpdatedTimestampMillis);
     62     }
     63 
     64     public static final Creator<TimestampedScoredNetwork> CREATOR =
     65             new Creator<TimestampedScoredNetwork>() {
     66                 @Override
     67                 public TimestampedScoredNetwork createFromParcel(Parcel in) {
     68                     return new TimestampedScoredNetwork(in);
     69                 }
     70 
     71                 @Override
     72                 public TimestampedScoredNetwork[] newArray(int size) {
     73                     return new TimestampedScoredNetwork[size];
     74                 }
     75             };
     76 }
     77