Add more logs in TestableNetworkStatsProvider

Test: m gts && atest \
      GtsNetworkStackHostTestCases:NetworkStatsHostTest#testNetworkStatsProvider
Bug: 175742577
Change-Id: Ib8f45a20879517af08f9bf9cbb2b16314351d2da
This commit is contained in:
Junyu Lai
2021-09-22 09:26:32 +00:00
parent 47b2acb829
commit bb84528e38

View File

@@ -17,6 +17,7 @@
package com.android.testutils package com.android.testutils
import android.net.netstats.provider.NetworkStatsProvider import android.net.netstats.provider.NetworkStatsProvider
import android.util.Log
import com.android.net.module.util.ArrayTrackRecord import com.android.net.module.util.ArrayTrackRecord
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertTrue import kotlin.test.assertTrue
@@ -43,23 +44,28 @@ open class TestableNetworkStatsProvider(
data class OnSetAlert(val quotaBytes: Long) : CallbackType() data class OnSetAlert(val quotaBytes: Long) : CallbackType()
} }
private val TAG = this::class.simpleName
val history = ArrayTrackRecord<CallbackType>().newReadHead() val history = ArrayTrackRecord<CallbackType>().newReadHead()
// See ReadHead#mark // See ReadHead#mark
val mark get() = history.mark val mark get() = history.mark
override fun onRequestStatsUpdate(token: Int) { override fun onRequestStatsUpdate(token: Int) {
Log.d(TAG, "onRequestStatsUpdate $token")
history.add(CallbackType.OnRequestStatsUpdate(token)) history.add(CallbackType.OnRequestStatsUpdate(token))
} }
override fun onSetWarningAndLimit(iface: String, warningBytes: Long, limitBytes: Long) { override fun onSetWarningAndLimit(iface: String, warningBytes: Long, limitBytes: Long) {
Log.d(TAG, "onSetWarningAndLimit $iface $warningBytes $limitBytes")
history.add(CallbackType.OnSetWarningAndLimit(iface, warningBytes, limitBytes)) history.add(CallbackType.OnSetWarningAndLimit(iface, warningBytes, limitBytes))
} }
override fun onSetLimit(iface: String, quotaBytes: Long) { override fun onSetLimit(iface: String, quotaBytes: Long) {
Log.d(TAG, "onSetLimit $iface $quotaBytes")
history.add(CallbackType.OnSetLimit(iface, quotaBytes)) history.add(CallbackType.OnSetLimit(iface, quotaBytes))
} }
override fun onSetAlert(quotaBytes: Long) { override fun onSetAlert(quotaBytes: Long) {
Log.d(TAG, "onSetAlert $quotaBytes")
history.add(CallbackType.OnSetAlert(quotaBytes)) history.add(CallbackType.OnSetAlert(quotaBytes))
} }