Home | History | Annotate | Download | only in wificond
      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 com.android.server.wifi.wificond;
     18 
     19 import android.os.Parcel;
     20 import android.os.Parcelable;
     21 
     22 import java.util.Objects;
     23 
     24 /**
     25  * RadioChainInfo for wificond
     26  *
     27  * @hide
     28  */
     29 public class RadioChainInfo implements Parcelable {
     30     private static final String TAG = "RadioChainInfo";
     31 
     32     public int chainId;
     33     public int level;
     34 
     35 
     36     /** public constructor */
     37     public RadioChainInfo() { }
     38 
     39     public RadioChainInfo(int chainId, int level) {
     40         this.chainId = chainId;
     41         this.level = level;
     42     }
     43 
     44     /** override comparator */
     45     @Override
     46     public boolean equals(Object rhs) {
     47         if (this == rhs) return true;
     48         if (!(rhs instanceof RadioChainInfo)) {
     49             return false;
     50         }
     51         RadioChainInfo chainInfo = (RadioChainInfo) rhs;
     52         if (chainInfo == null) {
     53             return false;
     54         }
     55         return chainId == chainInfo.chainId && level == chainInfo.level;
     56     }
     57 
     58     /** override hash code */
     59     @Override
     60     public int hashCode() {
     61         return Objects.hash(chainId, level);
     62     }
     63 
     64 
     65     /** implement Parcelable interface */
     66     @Override
     67     public int describeContents() {
     68         return 0;
     69     }
     70 
     71     /**
     72      * implement Parcelable interface
     73      * |flags| is ignored.
     74      */
     75     @Override
     76     public void writeToParcel(Parcel out, int flags) {
     77         out.writeInt(chainId);
     78         out.writeInt(level);
     79     }
     80 
     81     /** implement Parcelable interface */
     82     public static final Parcelable.Creator<RadioChainInfo> CREATOR =
     83             new Parcelable.Creator<RadioChainInfo>() {
     84         /**
     85          * Caller is responsible for providing a valid parcel.
     86          */
     87         @Override
     88         public RadioChainInfo createFromParcel(Parcel in) {
     89             RadioChainInfo result = new RadioChainInfo();
     90             result.chainId = in.readInt();
     91             result.level = in.readInt();
     92             return result;
     93         }
     94 
     95         @Override
     96         public RadioChainInfo[] newArray(int size) {
     97             return new RadioChainInfo[size];
     98         }
     99     };
    100 }
    101