mirror of
https://github.com/M66B/NetGuard.git
synced 2025-02-23 23:00:56 +00:00
parent
013adfc738
commit
cb52caa8b1
2 changed files with 8 additions and 1 deletions
|
@ -454,7 +454,10 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
||||||
holder.tvDisabled.setVisibility(rule.enabled ? View.GONE : View.VISIBLE);
|
holder.tvDisabled.setVisibility(rule.enabled ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
// Show traffic statistics
|
// Show traffic statistics
|
||||||
holder.tvStatistics.setVisibility(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? View.GONE : View.VISIBLE);
|
holder.tvStatistics.setVisibility(
|
||||||
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ||
|
||||||
|
(rule.upspeed == 0 && rule.downspeed == 0)
|
||||||
|
? View.GONE : View.VISIBLE);
|
||||||
holder.tvStatistics.setText(context.getString(R.string.msg_mbday, rule.upspeed, rule.downspeed));
|
holder.tvStatistics.setText(context.getString(R.string.msg_mbday, rule.upspeed, rule.downspeed));
|
||||||
|
|
||||||
// Show related
|
// Show related
|
||||||
|
|
|
@ -410,6 +410,10 @@ public class Rule {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||||
long up = TrafficStats.getUidTxBytes(rule.info.applicationInfo.uid);
|
long up = TrafficStats.getUidTxBytes(rule.info.applicationInfo.uid);
|
||||||
long down = TrafficStats.getUidRxBytes(rule.info.applicationInfo.uid);
|
long down = TrafficStats.getUidRxBytes(rule.info.applicationInfo.uid);
|
||||||
|
if (up == TrafficStats.UNSUPPORTED)
|
||||||
|
up = 0;
|
||||||
|
if (down == TrafficStats.UNSUPPORTED)
|
||||||
|
down = 0;
|
||||||
rule.totalbytes = up + down;
|
rule.totalbytes = up + down;
|
||||||
rule.upspeed = (float) up * 24 * 3600 * 1000 / 1024f / 1024f / now;
|
rule.upspeed = (float) up * 24 * 3600 * 1000 / 1024f / 1024f / now;
|
||||||
rule.downspeed = (float) down * 24 * 3600 * 1000 / 1024f / 1024f / now;
|
rule.downspeed = (float) down * 24 * 3600 * 1000 / 1024f / 1024f / now;
|
||||||
|
|
Loading…
Reference in a new issue