Loading core/java/com/android/internal/os/BatteryStatsImpl.java +10 −6 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.content.IntentFilter; import android.database.ContentObserver; import android.hardware.usb.UsbManager; import android.net.ConnectivityManager; import android.net.INetworkStatsService; import android.net.NetworkStats; import android.net.Uri; import android.net.wifi.WifiActivityEnergyInfo; Loading Loading @@ -86,7 +87,6 @@ import android.view.Display; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.location.gnssmetrics.GnssMetrics; import com.android.internal.net.NetworkStatsFactory; import com.android.internal.util.ArrayUtils; import com.android.internal.util.FastPrintWriter; import com.android.internal.util.FastXmlSerializer; Loading Loading @@ -11012,7 +11012,6 @@ public class BatteryStatsImpl extends BatteryStats { } } private final NetworkStatsFactory mNetworkStatsFactory = new NetworkStatsFactory(); private final Pools.Pool<NetworkStats> mNetworkStatsPool = new Pools.SynchronizedPool<>(6); private final Object mWifiNetworkLock = new Object(); Loading @@ -11034,11 +11033,16 @@ public class BatteryStatsImpl extends BatteryStats { private NetworkStats readNetworkStatsLocked(String[] ifaces) { try { if (!ArrayUtils.isEmpty(ifaces)) { return mNetworkStatsFactory.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, mNetworkStatsPool.acquire()); INetworkStatsService statsService = INetworkStatsService.Stub.asInterface( ServiceManager.getService(Context.NETWORK_STATS_SERVICE)); if (statsService != null) { return statsService.getDetailedUidStats(ifaces); } else { Slog.e(TAG, "Failed to get networkStatsService "); } } catch (IOException e) { Slog.e(TAG, "failed to read network stats for ifaces: " + Arrays.toString(ifaces)); } } catch (RemoteException e) { Slog.e(TAG, "failed to read network stats for ifaces: " + Arrays.toString(ifaces) + e); } return null; } Loading services/core/java/com/android/server/stats/StatsCompanionService.java +28 −21 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.content.pm.PackageManager; import android.content.pm.UserInfo; import android.hardware.fingerprint.FingerprintManager; import android.net.ConnectivityManager; import android.net.INetworkStatsService; import android.net.Network; import android.net.NetworkRequest; import android.net.NetworkStats; Loading Loading @@ -90,7 +91,6 @@ import android.util.proto.ProtoOutputStream; import com.android.internal.annotations.GuardedBy; import com.android.internal.app.procstats.IProcessStats; import com.android.internal.app.procstats.ProcessStats; import com.android.internal.net.NetworkStatsFactory; import com.android.internal.os.BatterySipper; import com.android.internal.os.BatteryStatsHelper; import com.android.internal.os.BinderCallsStats.ExportedCallStat; Loading Loading @@ -210,6 +210,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { private final Context mContext; private final AlarmManager mAlarmManager; private final INetworkStatsService mNetworkStatsService; @GuardedBy("sStatsdLock") private static IStatsManager sStatsd; private static final Object sStatsdLock = new Object(); Loading Loading @@ -257,6 +258,8 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { super(); mContext = context; mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); mNetworkStatsService = INetworkStatsService.Stub.asInterface( ServiceManager.getService(Context.NETWORK_STATS_SERVICE)); mBaseDir.mkdirs(); mAppUpdateReceiver = new AppUpdateReceiver(); mUserUpdateReceiver = new BroadcastReceiver() { Loading Loading @@ -788,14 +791,14 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { if (ifaces.length == 0) { return; } NetworkStatsFactory nsf = new NetworkStatsFactory(); if (mNetworkStatsService == null) { Slog.e(TAG, "NetworkStats Service is not available!"); return; } // Combine all the metrics per Uid into one record. NetworkStats stats = nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null) .groupedByUid(); NetworkStats stats = mNetworkStatsService.getDetailedUidStats(ifaces).groupedByUid(); addNetworkStats(tagId, pulledData, stats, false); } catch (java.io.IOException e) { } catch (RemoteException e) { Slog.e(TAG, "Pulling netstats for wifi bytes has error", e); } finally { Binder.restoreCallingIdentity(token); Loading @@ -812,12 +815,14 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { if (ifaces.length == 0) { return; } NetworkStatsFactory nsf = new NetworkStatsFactory(); if (mNetworkStatsService == null) { Slog.e(TAG, "NetworkStats Service is not available!"); return; } NetworkStats stats = rollupNetworkStatsByFGBG( nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null)); mNetworkStatsService.getDetailedUidStats(ifaces)); addNetworkStats(tagId, pulledData, stats, true); } catch (java.io.IOException e) { } catch (RemoteException e) { Slog.e(TAG, "Pulling netstats for wifi bytes w/ fg/bg has error", e); } finally { Binder.restoreCallingIdentity(token); Loading @@ -834,14 +839,14 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { if (ifaces.length == 0) { return; } NetworkStatsFactory nsf = new NetworkStatsFactory(); if (mNetworkStatsService == null) { Slog.e(TAG, "NetworkStats Service is not available!"); return; } // Combine all the metrics per Uid into one record. NetworkStats stats = nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null) .groupedByUid(); NetworkStats stats = mNetworkStatsService.getDetailedUidStats(ifaces).groupedByUid(); addNetworkStats(tagId, pulledData, stats, false); } catch (java.io.IOException e) { } catch (RemoteException e) { Slog.e(TAG, "Pulling netstats for mobile bytes has error", e); } finally { Binder.restoreCallingIdentity(token); Loading Loading @@ -874,12 +879,14 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { if (ifaces.length == 0) { return; } NetworkStatsFactory nsf = new NetworkStatsFactory(); if (mNetworkStatsService == null) { Slog.e(TAG, "NetworkStats Service is not available!"); return; } NetworkStats stats = rollupNetworkStatsByFGBG( nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null)); mNetworkStatsService.getDetailedUidStats(ifaces)); addNetworkStats(tagId, pulledData, stats, true); } catch (java.io.IOException e) { } catch (RemoteException e) { Slog.e(TAG, "Pulling netstats for mobile bytes w/ fg/bg has error", e); } finally { Binder.restoreCallingIdentity(token); Loading Loading
core/java/com/android/internal/os/BatteryStatsImpl.java +10 −6 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.content.IntentFilter; import android.database.ContentObserver; import android.hardware.usb.UsbManager; import android.net.ConnectivityManager; import android.net.INetworkStatsService; import android.net.NetworkStats; import android.net.Uri; import android.net.wifi.WifiActivityEnergyInfo; Loading Loading @@ -86,7 +87,6 @@ import android.view.Display; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.location.gnssmetrics.GnssMetrics; import com.android.internal.net.NetworkStatsFactory; import com.android.internal.util.ArrayUtils; import com.android.internal.util.FastPrintWriter; import com.android.internal.util.FastXmlSerializer; Loading Loading @@ -11012,7 +11012,6 @@ public class BatteryStatsImpl extends BatteryStats { } } private final NetworkStatsFactory mNetworkStatsFactory = new NetworkStatsFactory(); private final Pools.Pool<NetworkStats> mNetworkStatsPool = new Pools.SynchronizedPool<>(6); private final Object mWifiNetworkLock = new Object(); Loading @@ -11034,11 +11033,16 @@ public class BatteryStatsImpl extends BatteryStats { private NetworkStats readNetworkStatsLocked(String[] ifaces) { try { if (!ArrayUtils.isEmpty(ifaces)) { return mNetworkStatsFactory.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, mNetworkStatsPool.acquire()); INetworkStatsService statsService = INetworkStatsService.Stub.asInterface( ServiceManager.getService(Context.NETWORK_STATS_SERVICE)); if (statsService != null) { return statsService.getDetailedUidStats(ifaces); } else { Slog.e(TAG, "Failed to get networkStatsService "); } } catch (IOException e) { Slog.e(TAG, "failed to read network stats for ifaces: " + Arrays.toString(ifaces)); } } catch (RemoteException e) { Slog.e(TAG, "failed to read network stats for ifaces: " + Arrays.toString(ifaces) + e); } return null; } Loading
services/core/java/com/android/server/stats/StatsCompanionService.java +28 −21 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.content.pm.PackageManager; import android.content.pm.UserInfo; import android.hardware.fingerprint.FingerprintManager; import android.net.ConnectivityManager; import android.net.INetworkStatsService; import android.net.Network; import android.net.NetworkRequest; import android.net.NetworkStats; Loading Loading @@ -90,7 +91,6 @@ import android.util.proto.ProtoOutputStream; import com.android.internal.annotations.GuardedBy; import com.android.internal.app.procstats.IProcessStats; import com.android.internal.app.procstats.ProcessStats; import com.android.internal.net.NetworkStatsFactory; import com.android.internal.os.BatterySipper; import com.android.internal.os.BatteryStatsHelper; import com.android.internal.os.BinderCallsStats.ExportedCallStat; Loading Loading @@ -210,6 +210,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { private final Context mContext; private final AlarmManager mAlarmManager; private final INetworkStatsService mNetworkStatsService; @GuardedBy("sStatsdLock") private static IStatsManager sStatsd; private static final Object sStatsdLock = new Object(); Loading Loading @@ -257,6 +258,8 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { super(); mContext = context; mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); mNetworkStatsService = INetworkStatsService.Stub.asInterface( ServiceManager.getService(Context.NETWORK_STATS_SERVICE)); mBaseDir.mkdirs(); mAppUpdateReceiver = new AppUpdateReceiver(); mUserUpdateReceiver = new BroadcastReceiver() { Loading Loading @@ -788,14 +791,14 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { if (ifaces.length == 0) { return; } NetworkStatsFactory nsf = new NetworkStatsFactory(); if (mNetworkStatsService == null) { Slog.e(TAG, "NetworkStats Service is not available!"); return; } // Combine all the metrics per Uid into one record. NetworkStats stats = nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null) .groupedByUid(); NetworkStats stats = mNetworkStatsService.getDetailedUidStats(ifaces).groupedByUid(); addNetworkStats(tagId, pulledData, stats, false); } catch (java.io.IOException e) { } catch (RemoteException e) { Slog.e(TAG, "Pulling netstats for wifi bytes has error", e); } finally { Binder.restoreCallingIdentity(token); Loading @@ -812,12 +815,14 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { if (ifaces.length == 0) { return; } NetworkStatsFactory nsf = new NetworkStatsFactory(); if (mNetworkStatsService == null) { Slog.e(TAG, "NetworkStats Service is not available!"); return; } NetworkStats stats = rollupNetworkStatsByFGBG( nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null)); mNetworkStatsService.getDetailedUidStats(ifaces)); addNetworkStats(tagId, pulledData, stats, true); } catch (java.io.IOException e) { } catch (RemoteException e) { Slog.e(TAG, "Pulling netstats for wifi bytes w/ fg/bg has error", e); } finally { Binder.restoreCallingIdentity(token); Loading @@ -834,14 +839,14 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { if (ifaces.length == 0) { return; } NetworkStatsFactory nsf = new NetworkStatsFactory(); if (mNetworkStatsService == null) { Slog.e(TAG, "NetworkStats Service is not available!"); return; } // Combine all the metrics per Uid into one record. NetworkStats stats = nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null) .groupedByUid(); NetworkStats stats = mNetworkStatsService.getDetailedUidStats(ifaces).groupedByUid(); addNetworkStats(tagId, pulledData, stats, false); } catch (java.io.IOException e) { } catch (RemoteException e) { Slog.e(TAG, "Pulling netstats for mobile bytes has error", e); } finally { Binder.restoreCallingIdentity(token); Loading Loading @@ -874,12 +879,14 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { if (ifaces.length == 0) { return; } NetworkStatsFactory nsf = new NetworkStatsFactory(); if (mNetworkStatsService == null) { Slog.e(TAG, "NetworkStats Service is not available!"); return; } NetworkStats stats = rollupNetworkStatsByFGBG( nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null)); mNetworkStatsService.getDetailedUidStats(ifaces)); addNetworkStats(tagId, pulledData, stats, true); } catch (java.io.IOException e) { } catch (RemoteException e) { Slog.e(TAG, "Pulling netstats for mobile bytes w/ fg/bg has error", e); } finally { Binder.restoreCallingIdentity(token); Loading