summaryrefslogtreecommitdiffstats
path: root/service/java/com/android/server/wifi/WlanWakeReasonAndCounts.java
blob: 3311ec7d6cba06c8edbcba4d7deaf2f415087c24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.wifi;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * A class representing WLAN wake reason accounting.
 */

/** @hide */
public class WlanWakeReasonAndCounts implements Parcelable {
    private static final String TAG = "WlanWakeReasonAndCounts";
    /**
     * Wlan can wake host, only when it is cmd/event, local driver-fw
     * functions(non-data, non cmd/event) and rx data.The first packet
     * from wlan that woke up a sleep host is what is accounted here.
     * Total wlan wake to application processor would be:
     * [cmdEventWake + driverFwLocalWake + totalRxDataWake]
     * A further classification is provided for identifying the reasons
     * for wakeup.
     */
    public int totalCmdEventWake;
    public int totalDriverFwLocalWake;
    public int totalRxDataWake;

    public int rxUnicast;
    public int rxMulticast;
    public int rxBroadcast;

    public int icmp;
    public int icmp6;
    public int icmp6Ra;
    public int icmp6Na;
    public int icmp6Ns;

    public int ipv4RxMulticast;
    public int ipv6Multicast;
    public int otherRxMulticast;
    public int[] cmdEventWakeCntArray;
    public int[] driverFWLocalWakeCntArray;

    /* {@hide} */
    public WlanWakeReasonAndCounts() {
    }

    @Override
    /* {@hide} */
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append(" totalCmdEventWake ").append(totalCmdEventWake);
        sb.append(" totalDriverFwLocalWake ").append(totalDriverFwLocalWake);
        sb.append(" totalRxDataWake ").append(totalRxDataWake);

        sb.append(" rxUnicast ").append(rxUnicast);
        sb.append(" rxMulticast ").append(rxMulticast);
        sb.append(" rxBroadcast ").append(rxBroadcast);

        sb.append(" icmp ").append(icmp);
        sb.append(" icmp6 ").append(icmp6);
        sb.append(" icmp6Ra ").append(icmp6Ra);
        sb.append(" icmp6Na ").append(icmp6Na);
        sb.append(" icmp6Ns ").append(icmp6Ns);

        sb.append(" ipv4RxMulticast ").append(ipv4RxMulticast);
        sb.append(" ipv6Multicast ").append(ipv6Multicast);
        sb.append(" otherRxMulticast ").append(otherRxMulticast);
        for (int i = 0; i < cmdEventWakeCntArray.length; i++) {
            sb.append(" cmdEventWakeCntArray[" + i + "] " + cmdEventWakeCntArray[i]);
        }
        for (int i = 0; i < driverFWLocalWakeCntArray.length; i++) {
            sb.append(" driverFWLocalWakeCntArray[" + i + "] " + driverFWLocalWakeCntArray[i]);
        }

        return sb.toString();
    }

    /* Implement the Parcelable interface
     * {@hide}
     */
    @Override
    public int describeContents() {
        return 0;
    }

    /* Implement the Parcelable interface
     * {@hide}
     */
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(totalCmdEventWake);
        dest.writeInt(totalDriverFwLocalWake);
        dest.writeInt(totalRxDataWake);

        dest.writeInt(rxUnicast);
        dest.writeInt(rxMulticast);
        dest.writeInt(rxBroadcast);

        dest.writeInt(icmp);
        dest.writeInt(icmp6);
        dest.writeInt(icmp6Ra);
        dest.writeInt(icmp6Na);
        dest.writeInt(icmp6Ns);

        dest.writeInt(ipv4RxMulticast);
        dest.writeInt(ipv6Multicast);
        dest.writeInt(otherRxMulticast);
        dest.writeIntArray(cmdEventWakeCntArray);
        dest.writeIntArray(driverFWLocalWakeCntArray);
    }

    /* Implement the Parcelable interface
     * {@hide}
     */
    public static final Creator<WlanWakeReasonAndCounts> CREATOR =
            new Creator<WlanWakeReasonAndCounts>() {
                public WlanWakeReasonAndCounts createFromParcel(Parcel in) {
                    WlanWakeReasonAndCounts counts = new WlanWakeReasonAndCounts();
                    counts.totalCmdEventWake = in.readInt();
                    counts.totalDriverFwLocalWake = in.readInt();
                    counts.totalRxDataWake = in.readInt();

                    counts.rxUnicast = in.readInt();
                    counts.rxMulticast = in.readInt();
                    counts.rxBroadcast = in.readInt();

                    counts.icmp = in.readInt();
                    counts.icmp6 = in.readInt();
                    counts.icmp6Ra = in.readInt();
                    counts.icmp6Na = in.readInt();
                    counts.icmp6Ns = in.readInt();

                    counts.ipv4RxMulticast = in.readInt();
                    counts.ipv6Multicast = in.readInt();
                    counts.otherRxMulticast = in.readInt();
                    in.readIntArray(counts.cmdEventWakeCntArray);
                    in.readIntArray(counts.driverFWLocalWakeCntArray);
                    return counts;
                }

                /* Implement the Parcelable interface
                 * {@hide}
                 */
                @Override
                public WlanWakeReasonAndCounts[] newArray(int size) {
                    return new WlanWakeReasonAndCounts[size];
                }
            };
}