Merge "[DU11]Remove NetworkStats hiddden API dependencies"
This commit is contained in:
@@ -34,10 +34,6 @@ import static android.net.NetworkPolicyManager.FIREWALL_CHAIN_NAME_POWERSAVE;
|
|||||||
import static android.net.NetworkPolicyManager.FIREWALL_CHAIN_NAME_RESTRICTED;
|
import static android.net.NetworkPolicyManager.FIREWALL_CHAIN_NAME_RESTRICTED;
|
||||||
import static android.net.NetworkPolicyManager.FIREWALL_CHAIN_NAME_STANDBY;
|
import static android.net.NetworkPolicyManager.FIREWALL_CHAIN_NAME_STANDBY;
|
||||||
import static android.net.NetworkPolicyManager.FIREWALL_RULE_DEFAULT;
|
import static android.net.NetworkPolicyManager.FIREWALL_RULE_DEFAULT;
|
||||||
import static android.net.NetworkStats.SET_DEFAULT;
|
|
||||||
import static android.net.NetworkStats.STATS_PER_UID;
|
|
||||||
import static android.net.NetworkStats.TAG_NONE;
|
|
||||||
import static android.net.TrafficStats.UID_TETHERING;
|
|
||||||
|
|
||||||
import static com.android.net.module.util.NetworkStatsUtils.LIMIT_GLOBAL_ALERT;
|
import static com.android.net.module.util.NetworkStatsUtils.LIMIT_GLOBAL_ALERT;
|
||||||
|
|
||||||
@@ -58,7 +54,6 @@ import android.net.NetworkPolicyManager;
|
|||||||
import android.net.NetworkStack;
|
import android.net.NetworkStack;
|
||||||
import android.net.NetworkStats;
|
import android.net.NetworkStats;
|
||||||
import android.net.RouteInfo;
|
import android.net.RouteInfo;
|
||||||
import android.net.TetherStatsParcel;
|
|
||||||
import android.net.UidRangeParcel;
|
import android.net.UidRangeParcel;
|
||||||
import android.net.util.NetdService;
|
import android.net.util.NetdService;
|
||||||
import android.os.BatteryStats;
|
import android.os.BatteryStats;
|
||||||
@@ -1286,40 +1281,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
|
|||||||
private class NetdTetheringStatsProvider extends ITetheringStatsProvider.Stub {
|
private class NetdTetheringStatsProvider extends ITetheringStatsProvider.Stub {
|
||||||
@Override
|
@Override
|
||||||
public NetworkStats getTetherStats(int how) {
|
public NetworkStats getTetherStats(int how) {
|
||||||
// We only need to return per-UID stats. Per-device stats are already counted by
|
// Remove the implementation of NetdTetheringStatsProvider#getTetherStats
|
||||||
// interface counters.
|
// since all callers are migrated to use INetd#tetherGetStats directly.
|
||||||
if (how != STATS_PER_UID) {
|
throw new UnsupportedOperationException();
|
||||||
return new NetworkStats(SystemClock.elapsedRealtime(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
final TetherStatsParcel[] tetherStatsVec;
|
|
||||||
try {
|
|
||||||
tetherStatsVec = mNetdService.tetherGetStats();
|
|
||||||
} catch (RemoteException | ServiceSpecificException e) {
|
|
||||||
throw new IllegalStateException("problem parsing tethering stats: ", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(),
|
|
||||||
tetherStatsVec.length);
|
|
||||||
final NetworkStats.Entry entry = new NetworkStats.Entry();
|
|
||||||
|
|
||||||
for (TetherStatsParcel tetherStats : tetherStatsVec) {
|
|
||||||
try {
|
|
||||||
entry.iface = tetherStats.iface;
|
|
||||||
entry.uid = UID_TETHERING;
|
|
||||||
entry.set = SET_DEFAULT;
|
|
||||||
entry.tag = TAG_NONE;
|
|
||||||
entry.rxBytes = tetherStats.rxBytes;
|
|
||||||
entry.rxPackets = tetherStats.rxPackets;
|
|
||||||
entry.txBytes = tetherStats.txBytes;
|
|
||||||
entry.txPackets = tetherStats.txPackets;
|
|
||||||
stats.combineValues(entry);
|
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
|
||||||
throw new IllegalStateException("invalid tethering stats " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return stats;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1330,20 +1294,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NetworkStats getNetworkStatsTethering(int how) {
|
public NetworkStats getNetworkStatsTethering(int how) {
|
||||||
NetworkStack.checkNetworkStackPermission(mContext);
|
// Remove the implementation of getNetworkStatsTethering since all callers are migrated
|
||||||
|
// to use INetd#tetherGetStats directly.
|
||||||
final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 1);
|
throw new UnsupportedOperationException();
|
||||||
synchronized (mTetheringStatsProviders) {
|
|
||||||
for (ITetheringStatsProvider provider: mTetheringStatsProviders.keySet()) {
|
|
||||||
try {
|
|
||||||
stats.combineAllValues(provider.getTetherStats(how));
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log.e(TAG, "Problem reading tethering stats from " +
|
|
||||||
mTetheringStatsProviders.get(provider) + ": " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return stats;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user