Home | History | Annotate | Download | only in wifi
      1 /*
      2  * Copyright (C) 2015 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.net.wifi;
     18 
     19 import android.os.Parcel;
     20 import android.os.Parcelable;
     21 
     22 /**
     23  * A class representing wifi wake reason accounting.
     24  */
     25 
     26 /** @hide */
     27 public class WifiWakeReasonAndCounts implements Parcelable {
     28     private static final String TAG = "WifiWakeReasonAndCounts";
     29     /**
     30      * Wlan can wake host, only when it is cmd/event, local driver-fw
     31      * functions(non-data, non cmd/event) and rx data.The first packet
     32      * from wlan that woke up a sleep host is what is accounted here.
     33      * Total wlan wake to application processor would be:
     34      * [cmdEventWake + driverFwLocalWake + totalRxDataWake]
     35      * A further classification is provided for identifying the reasons
     36      * for wakeup.
     37      */
     38     public int totalCmdEventWake;
     39     public int totalDriverFwLocalWake;
     40     public int totalRxDataWake;
     41 
     42     public int rxUnicast;
     43     public int rxMulticast;
     44     public int rxBroadcast;
     45 
     46     public int icmp;
     47     public int icmp6;
     48     public int icmp6Ra;
     49     public int icmp6Na;
     50     public int icmp6Ns;
     51 
     52     public int ipv4RxMulticast;
     53     public int ipv6Multicast;
     54     public int otherRxMulticast;
     55     public int[] cmdEventWakeCntArray;
     56     public int[] driverFWLocalWakeCntArray;
     57 
     58     /* {@hide} */
     59     public WifiWakeReasonAndCounts () {
     60     }
     61 
     62     @Override
     63     /* {@hide} */
     64     public String toString() {
     65         StringBuffer sb = new StringBuffer();
     66         sb.append(" totalCmdEventWake ").append(totalCmdEventWake);
     67         sb.append(" totalDriverFwLocalWake ").append(totalDriverFwLocalWake);
     68         sb.append(" totalRxDataWake ").append(totalRxDataWake);
     69 
     70         sb.append(" rxUnicast ").append(rxUnicast);
     71         sb.append(" rxMulticast ").append(rxMulticast);
     72         sb.append(" rxBroadcast ").append(rxBroadcast);
     73 
     74         sb.append(" icmp ").append(icmp);
     75         sb.append(" icmp6 ").append(icmp6);
     76         sb.append(" icmp6Ra ").append(icmp6Ra);
     77         sb.append(" icmp6Na ").append(icmp6Na);
     78         sb.append(" icmp6Ns ").append(icmp6Ns);
     79 
     80         sb.append(" ipv4RxMulticast ").append(ipv4RxMulticast);
     81         sb.append(" ipv6Multicast ").append(ipv6Multicast);
     82         sb.append(" otherRxMulticast ").append(otherRxMulticast);
     83         for (int i = 0; i < cmdEventWakeCntArray.length; i++) {
     84             sb.append(" cmdEventWakeCntArray[" + i + "] " + cmdEventWakeCntArray[i]);
     85         }
     86         for (int i = 0; i < driverFWLocalWakeCntArray.length; i++) {
     87             sb.append(" driverFWLocalWakeCntArray[" + i + "] " + driverFWLocalWakeCntArray[i]);
     88         }
     89 
     90         return sb.toString();
     91     }
     92 
     93     /* Implement the Parcelable interface
     94      * {@hide}
     95      */
     96     @Override
     97     public int describeContents() {
     98         return 0;
     99     }
    100 
    101     /* Implement the Parcelable interface
    102      * {@hide}
    103      */
    104     @Override
    105     public void writeToParcel(Parcel dest, int flags) {
    106         dest.writeInt(totalCmdEventWake);
    107         dest.writeInt(totalDriverFwLocalWake);
    108         dest.writeInt(totalRxDataWake);
    109 
    110         dest.writeInt(rxUnicast);
    111         dest.writeInt(rxMulticast);
    112         dest.writeInt(rxBroadcast);
    113 
    114         dest.writeInt(icmp);
    115         dest.writeInt(icmp6);
    116         dest.writeInt(icmp6Ra);
    117         dest.writeInt(icmp6Na);
    118         dest.writeInt(icmp6Ns);
    119 
    120         dest.writeInt(ipv4RxMulticast);
    121         dest.writeInt(ipv6Multicast);
    122         dest.writeInt(otherRxMulticast);
    123         dest.writeIntArray(cmdEventWakeCntArray);
    124         dest.writeIntArray(driverFWLocalWakeCntArray);
    125     }
    126 
    127     /* Implement the Parcelable interface
    128      * {@hide}
    129      */
    130     public static final Creator<WifiWakeReasonAndCounts> CREATOR =
    131         new Creator<WifiWakeReasonAndCounts>() {
    132             public WifiWakeReasonAndCounts createFromParcel(Parcel in) {
    133                 WifiWakeReasonAndCounts counts = new WifiWakeReasonAndCounts();
    134                 counts.totalCmdEventWake = in.readInt();
    135                 counts.totalDriverFwLocalWake = in.readInt();
    136                 counts.totalRxDataWake = in.readInt();
    137 
    138                 counts.rxUnicast = in.readInt();
    139                 counts.rxMulticast = in.readInt();
    140                 counts.rxBroadcast = in.readInt();
    141 
    142                 counts.icmp = in.readInt();
    143                 counts.icmp6 = in.readInt();
    144                 counts.icmp6Ra = in.readInt();
    145                 counts.icmp6Na = in.readInt();
    146                 counts.icmp6Ns = in.readInt();
    147 
    148                 counts.ipv4RxMulticast = in.readInt();
    149                 counts.ipv6Multicast = in.readInt();
    150                 counts.otherRxMulticast = in.readInt();
    151                 in.readIntArray(counts.cmdEventWakeCntArray);
    152                 in.readIntArray(counts.driverFWLocalWakeCntArray);
    153                 return counts;
    154             }
    155             /* Implement the Parcelable interface
    156              * {@hide}
    157              */
    158             @Override
    159             public WifiWakeReasonAndCounts[] newArray(int size) {
    160                 return new WifiWakeReasonAndCounts[size];
    161             }
    162         };
    163 }
    164