diff options
4 files changed, 171 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 29b38aed7..ab5b7f08f 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -25,7 +25,6 @@ import android.net.apf.ApfCapabilities; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiScanner; -import android.net.wifi.WifiWakeReasonAndCounts; import android.os.INetworkManagementService; import android.os.RemoteException; import android.os.SystemClock; @@ -2793,9 +2792,9 @@ public class WifiNative { /** * Fetch the host wakeup reasons stats from wlan driver. * - * @return the |WifiWakeReasonAndCounts| object retrieved from the wlan driver. + * @return the |WlanWakeReasonAndCounts| object retrieved from the wlan driver. */ - public WifiWakeReasonAndCounts getWlanWakeReasonCount() { + public WlanWakeReasonAndCounts getWlanWakeReasonCount() { return mWifiVendorHal.getWlanWakeReasonCount(); } diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java index 77da7667f..25b6fc4ea 100644 --- a/service/java/com/android/server/wifi/WifiVendorHal.java +++ b/service/java/com/android/server/wifi/WifiVendorHal.java @@ -52,7 +52,6 @@ import android.net.wifi.ScanResult; import android.net.wifi.WifiManager; import android.net.wifi.WifiScanner; import android.net.wifi.WifiSsid; -import android.net.wifi.WifiWakeReasonAndCounts; import android.os.Handler; import android.os.Looper; import android.os.RemoteException; @@ -1963,10 +1962,10 @@ public class WifiVendorHal { * @param h - Hal version of wake reason stats * @return framework version of same */ - private static WifiWakeReasonAndCounts halToFrameworkWakeReasons( + private static WlanWakeReasonAndCounts halToFrameworkWakeReasons( WifiDebugHostWakeReasonStats h) { if (h == null) return null; - WifiWakeReasonAndCounts ans = new WifiWakeReasonAndCounts(); + WlanWakeReasonAndCounts ans = new WlanWakeReasonAndCounts(); ans.totalCmdEventWake = h.totalCmdEventWakeCnt; ans.totalDriverFwLocalWake = h.totalDriverFwLocalWakeCnt; ans.totalRxDataWake = h.totalRxPacketWakeCnt; @@ -1989,9 +1988,9 @@ public class WifiVendorHal { /** * Fetch the host wakeup reasons stats from wlan driver. * - * @return the |WifiWakeReasonAndCounts| from the wlan driver, or null on failure. + * @return the |WlanWakeReasonAndCounts| from the wlan driver, or null on failure. */ - public WifiWakeReasonAndCounts getWlanWakeReasonCount() { + public WlanWakeReasonAndCounts getWlanWakeReasonCount() { class AnswerBox { public WifiDebugHostWakeReasonStats value = null; } diff --git a/service/java/com/android/server/wifi/WlanWakeReasonAndCounts.java b/service/java/com/android/server/wifi/WlanWakeReasonAndCounts.java new file mode 100644 index 000000000..3311ec7d6 --- /dev/null +++ b/service/java/com/android/server/wifi/WlanWakeReasonAndCounts.java @@ -0,0 +1,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]; + } + }; +} diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java index 9ca722164..65ff7d2c9 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java @@ -84,7 +84,6 @@ import android.net.wifi.ScanResult; import android.net.wifi.WifiManager; import android.net.wifi.WifiScanner; import android.net.wifi.WifiSsid; -import android.net.wifi.WifiWakeReasonAndCounts; import android.os.Looper; import android.os.RemoteException; import android.os.test.TestLooper; @@ -1893,7 +1892,7 @@ public class WifiVendorHalTest { assertTrue(mWifiVendorHal.startVendorHalSta()); - WifiWakeReasonAndCounts retrievedStats = mWifiVendorHal.getWlanWakeReasonCount(); + WlanWakeReasonAndCounts retrievedStats = mWifiVendorHal.getWlanWakeReasonCount(); verify(mIWifiChip).getDebugHostWakeReasonStats( any(IWifiChip.getDebugHostWakeReasonStatsCallback.class)); assertNotNull(retrievedStats); |