Loading services/core/java/com/android/server/net/NetworkStatsService.java +21 −31 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import static android.net.NetworkStats.IFACE_ALL; import static android.net.NetworkStats.SET_ALL; import static android.net.NetworkStats.SET_DEFAULT; import static android.net.NetworkStats.SET_FOREGROUND; import static android.net.NetworkStats.TAG_ALL; import static android.net.NetworkStats.TAG_NONE; import static android.net.NetworkStats.UID_ALL; import static android.net.NetworkTemplate.buildTemplateMobileWildcard; Loading @@ -58,14 +57,13 @@ import static android.text.format.DateUtils.DAY_IN_MILLIS; import static android.text.format.DateUtils.HOUR_IN_MILLIS; import static android.text.format.DateUtils.MINUTE_IN_MILLIS; import static android.text.format.DateUtils.SECOND_IN_MILLIS; import static com.android.internal.util.Preconditions.checkArgument; import static com.android.internal.util.Preconditions.checkNotNull; import static com.android.server.NetworkManagementService.LIMIT_GLOBAL_ALERT; import static com.android.server.NetworkManagementSocketTagger.resetKernelUidStats; import static com.android.server.NetworkManagementSocketTagger.setKernelCounterSet; import android.app.AlarmManager; import android.app.IAlarmManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.ContentResolver; Loading Loading @@ -1031,7 +1029,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { // snapshot and record current counters; read UID stats first to // avoid over counting dev stats. final NetworkStats uidSnapshot = getNetworkStatsUidDetail(); final NetworkStats xtSnapshot = getNetworkStatsXtAndVt(); final NetworkStats xtSnapshot = getNetworkStatsXt(); final NetworkStats devSnapshot = mNetworkManager.getNetworkStatsSummaryDev(); Loading Loading @@ -1323,7 +1321,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub { /** * Return snapshot of current UID statistics, including any * {@link TrafficStats#UID_TETHERING} and {@link #mUidOperations} values. * {@link TrafficStats#UID_TETHERING}, video calling data usage, and {@link #mUidOperations} * values. */ private NetworkStats getNetworkStatsUidDetail() throws RemoteException { final NetworkStats uidSnapshot = mNetworkManager.getNetworkStatsUidDetail(UID_ALL); Loading @@ -1331,43 +1330,34 @@ public class NetworkStatsService extends INetworkStatsService.Stub { // fold tethering stats and operations into uid snapshot final NetworkStats tetherSnapshot = getNetworkStatsTethering(); uidSnapshot.combineAllValues(tetherSnapshot); final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService( Context.TELEPHONY_SERVICE); // fold video calling data usage stats into uid snapshot final NetworkStats vtStats = telephonyManager.getVtDataUsage(true); if (vtStats != null) { uidSnapshot.combineAllValues(vtStats); } uidSnapshot.combineAllValues(mUidOperations); return uidSnapshot; } /** * Return snapshot of current XT plus VT statistics. * Return snapshot of current XT statistics with video calling data usage statistics. */ private NetworkStats getNetworkStatsXtAndVt() throws RemoteException { private NetworkStats getNetworkStatsXt() throws RemoteException { final NetworkStats xtSnapshot = mNetworkManager.getNetworkStatsSummaryXt(); TelephonyManager tm = (TelephonyManager) mContext.getSystemService( final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService( Context.TELEPHONY_SERVICE); long usage = tm.getVtDataUsage(); if (LOGV) Slog.d(TAG, "VT call data usage = " + usage); final NetworkStats vtSnapshot = new NetworkStats(SystemClock.elapsedRealtime(), 1); final NetworkStats.Entry entry = new NetworkStats.Entry(); entry.iface = VT_INTERFACE; entry.uid = -1; entry.set = TAG_ALL; entry.tag = TAG_NONE; // Since modem only tell us the total usage instead of each usage for RX and TX, // we need to split it up (though it might not quite accurate). At // least we can make sure the data usage report to the user will still be accurate. entry.rxBytes = usage / 2; entry.rxPackets = 0; entry.txBytes = usage - entry.rxBytes; entry.txPackets = 0; vtSnapshot.combineValues(entry); // Merge VT int XT // Merge video calling data usage into XT final NetworkStats vtSnapshot = telephonyManager.getVtDataUsage(false); if (vtSnapshot != null) { xtSnapshot.combineAllValues(vtSnapshot); } return xtSnapshot; } Loading telephony/java/android/telephony/TelephonyManager.java +8 −11 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkStats; import android.net.Uri; import android.os.BatteryStats; import android.os.Binder; Loading @@ -39,11 +40,6 @@ import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.os.Message; import android.os.Messenger; import android.os.Parcelable; import android.os.PersistableBundle; import android.os.RemoteException; import android.os.ResultReceiver; Loading Loading @@ -6433,20 +6429,21 @@ public class TelephonyManager { /** * Get aggregated video call data usage since boot. * Permissions android.Manifest.permission.READ_NETWORK_USAGE_HISTORY is required. * @return total data usage in bytes * * @param perUidStats True if requesting data usage per uid, otherwise overall usage. * @return Snapshot of video call data usage * @hide */ public long getVtDataUsage() { public NetworkStats getVtDataUsage(boolean perUidStats) { try { ITelephony service = getITelephony(); if (service != null) { return service.getVtDataUsage(); return service.getVtDataUsage(getSubId(), perUidStats); } } catch (RemoteException e) { Log.e(TAG, "Error calling getVtDataUsage", e); Log.e(TAG, "Error calling ITelephony#getVtDataUsage", e); } return 0; return null; } /** Loading telephony/java/com/android/internal/telephony/ITelephony.aidl +5 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.Messenger; import android.os.ResultReceiver; import android.net.NetworkStats; import android.net.Uri; import android.service.carrier.CarrierIdentifier; import android.telecom.PhoneAccount; Loading Loading @@ -1268,10 +1269,12 @@ interface ITelephony { /** * Get aggregated video call data usage since boot. * Permissions android.Manifest.permission.READ_NETWORK_USAGE_HISTORY is required. * @return total data usage in bytes * * @param perUidStats True if requesting data usage per uid, otherwise overall usage. * @return Snapshot of video call data usage * @hide */ long getVtDataUsage(); NetworkStats getVtDataUsage(int subId, boolean perUidStats); /** * Policy control of data connection. Usually used when data limit is passed. Loading Loading
services/core/java/com/android/server/net/NetworkStatsService.java +21 −31 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import static android.net.NetworkStats.IFACE_ALL; import static android.net.NetworkStats.SET_ALL; import static android.net.NetworkStats.SET_DEFAULT; import static android.net.NetworkStats.SET_FOREGROUND; import static android.net.NetworkStats.TAG_ALL; import static android.net.NetworkStats.TAG_NONE; import static android.net.NetworkStats.UID_ALL; import static android.net.NetworkTemplate.buildTemplateMobileWildcard; Loading @@ -58,14 +57,13 @@ import static android.text.format.DateUtils.DAY_IN_MILLIS; import static android.text.format.DateUtils.HOUR_IN_MILLIS; import static android.text.format.DateUtils.MINUTE_IN_MILLIS; import static android.text.format.DateUtils.SECOND_IN_MILLIS; import static com.android.internal.util.Preconditions.checkArgument; import static com.android.internal.util.Preconditions.checkNotNull; import static com.android.server.NetworkManagementService.LIMIT_GLOBAL_ALERT; import static com.android.server.NetworkManagementSocketTagger.resetKernelUidStats; import static com.android.server.NetworkManagementSocketTagger.setKernelCounterSet; import android.app.AlarmManager; import android.app.IAlarmManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.ContentResolver; Loading Loading @@ -1031,7 +1029,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { // snapshot and record current counters; read UID stats first to // avoid over counting dev stats. final NetworkStats uidSnapshot = getNetworkStatsUidDetail(); final NetworkStats xtSnapshot = getNetworkStatsXtAndVt(); final NetworkStats xtSnapshot = getNetworkStatsXt(); final NetworkStats devSnapshot = mNetworkManager.getNetworkStatsSummaryDev(); Loading Loading @@ -1323,7 +1321,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub { /** * Return snapshot of current UID statistics, including any * {@link TrafficStats#UID_TETHERING} and {@link #mUidOperations} values. * {@link TrafficStats#UID_TETHERING}, video calling data usage, and {@link #mUidOperations} * values. */ private NetworkStats getNetworkStatsUidDetail() throws RemoteException { final NetworkStats uidSnapshot = mNetworkManager.getNetworkStatsUidDetail(UID_ALL); Loading @@ -1331,43 +1330,34 @@ public class NetworkStatsService extends INetworkStatsService.Stub { // fold tethering stats and operations into uid snapshot final NetworkStats tetherSnapshot = getNetworkStatsTethering(); uidSnapshot.combineAllValues(tetherSnapshot); final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService( Context.TELEPHONY_SERVICE); // fold video calling data usage stats into uid snapshot final NetworkStats vtStats = telephonyManager.getVtDataUsage(true); if (vtStats != null) { uidSnapshot.combineAllValues(vtStats); } uidSnapshot.combineAllValues(mUidOperations); return uidSnapshot; } /** * Return snapshot of current XT plus VT statistics. * Return snapshot of current XT statistics with video calling data usage statistics. */ private NetworkStats getNetworkStatsXtAndVt() throws RemoteException { private NetworkStats getNetworkStatsXt() throws RemoteException { final NetworkStats xtSnapshot = mNetworkManager.getNetworkStatsSummaryXt(); TelephonyManager tm = (TelephonyManager) mContext.getSystemService( final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService( Context.TELEPHONY_SERVICE); long usage = tm.getVtDataUsage(); if (LOGV) Slog.d(TAG, "VT call data usage = " + usage); final NetworkStats vtSnapshot = new NetworkStats(SystemClock.elapsedRealtime(), 1); final NetworkStats.Entry entry = new NetworkStats.Entry(); entry.iface = VT_INTERFACE; entry.uid = -1; entry.set = TAG_ALL; entry.tag = TAG_NONE; // Since modem only tell us the total usage instead of each usage for RX and TX, // we need to split it up (though it might not quite accurate). At // least we can make sure the data usage report to the user will still be accurate. entry.rxBytes = usage / 2; entry.rxPackets = 0; entry.txBytes = usage - entry.rxBytes; entry.txPackets = 0; vtSnapshot.combineValues(entry); // Merge VT int XT // Merge video calling data usage into XT final NetworkStats vtSnapshot = telephonyManager.getVtDataUsage(false); if (vtSnapshot != null) { xtSnapshot.combineAllValues(vtSnapshot); } return xtSnapshot; } Loading
telephony/java/android/telephony/TelephonyManager.java +8 −11 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkStats; import android.net.Uri; import android.os.BatteryStats; import android.os.Binder; Loading @@ -39,11 +40,6 @@ import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.os.Message; import android.os.Messenger; import android.os.Parcelable; import android.os.PersistableBundle; import android.os.RemoteException; import android.os.ResultReceiver; Loading Loading @@ -6433,20 +6429,21 @@ public class TelephonyManager { /** * Get aggregated video call data usage since boot. * Permissions android.Manifest.permission.READ_NETWORK_USAGE_HISTORY is required. * @return total data usage in bytes * * @param perUidStats True if requesting data usage per uid, otherwise overall usage. * @return Snapshot of video call data usage * @hide */ public long getVtDataUsage() { public NetworkStats getVtDataUsage(boolean perUidStats) { try { ITelephony service = getITelephony(); if (service != null) { return service.getVtDataUsage(); return service.getVtDataUsage(getSubId(), perUidStats); } } catch (RemoteException e) { Log.e(TAG, "Error calling getVtDataUsage", e); Log.e(TAG, "Error calling ITelephony#getVtDataUsage", e); } return 0; return null; } /** Loading
telephony/java/com/android/internal/telephony/ITelephony.aidl +5 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.Messenger; import android.os.ResultReceiver; import android.net.NetworkStats; import android.net.Uri; import android.service.carrier.CarrierIdentifier; import android.telecom.PhoneAccount; Loading Loading @@ -1268,10 +1269,12 @@ interface ITelephony { /** * Get aggregated video call data usage since boot. * Permissions android.Manifest.permission.READ_NETWORK_USAGE_HISTORY is required. * @return total data usage in bytes * * @param perUidStats True if requesting data usage per uid, otherwise overall usage. * @return Snapshot of video call data usage * @hide */ long getVtDataUsage(); NetworkStats getVtDataUsage(int subId, boolean perUidStats); /** * Policy control of data connection. Usually used when data limit is passed. Loading