Merge "[MS75] Replace TrafficStats data units with DataUnit class" am: 03740ec6c2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1960399 Change-Id: I2a80c943e5f33e678fd479f3aa8f9fc8ed86901e
This commit is contained in:
@@ -100,7 +100,6 @@ import static android.net.NetworkTemplate.MATCH_MOBILE;
|
|||||||
import static android.net.NetworkTemplate.MATCH_WIFI;
|
import static android.net.NetworkTemplate.MATCH_WIFI;
|
||||||
import static android.net.NetworkTemplate.buildTemplateCarrierMetered;
|
import static android.net.NetworkTemplate.buildTemplateCarrierMetered;
|
||||||
import static android.net.NetworkTemplate.buildTemplateMobileAll;
|
import static android.net.NetworkTemplate.buildTemplateMobileAll;
|
||||||
import static android.net.TrafficStats.MB_IN_BYTES;
|
|
||||||
import static android.net.netstats.provider.NetworkStatsProvider.QUOTA_UNLIMITED;
|
import static android.net.netstats.provider.NetworkStatsProvider.QUOTA_UNLIMITED;
|
||||||
import static android.os.Trace.TRACE_TAG_NETWORK;
|
import static android.os.Trace.TRACE_TAG_NETWORK;
|
||||||
import static android.provider.Settings.Global.NETPOLICY_OVERRIDE_ENABLED;
|
import static android.provider.Settings.Global.NETPOLICY_OVERRIDE_ENABLED;
|
||||||
@@ -182,7 +181,6 @@ import android.net.NetworkStack;
|
|||||||
import android.net.NetworkStateSnapshot;
|
import android.net.NetworkStateSnapshot;
|
||||||
import android.net.NetworkTemplate;
|
import android.net.NetworkTemplate;
|
||||||
import android.net.TelephonyNetworkSpecifier;
|
import android.net.TelephonyNetworkSpecifier;
|
||||||
import android.net.TrafficStats;
|
|
||||||
import android.net.wifi.WifiConfiguration;
|
import android.net.wifi.WifiConfiguration;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.BestClock;
|
import android.os.BestClock;
|
||||||
@@ -2319,7 +2317,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
if (dataWarningConfig == WARNING_DISABLED) {
|
if (dataWarningConfig == WARNING_DISABLED) {
|
||||||
return WARNING_DISABLED;
|
return WARNING_DISABLED;
|
||||||
} else {
|
} else {
|
||||||
return dataWarningConfig * MB_IN_BYTES;
|
return DataUnit.MEBIBYTES.toBytes(dataWarningConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3488,9 +3486,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
plans.add(SubscriptionPlan.Builder
|
plans.add(SubscriptionPlan.Builder
|
||||||
.createRecurringMonthly(ZonedDateTime.parse("2007-03-14T00:00:00.000Z"))
|
.createRecurringMonthly(ZonedDateTime.parse("2007-03-14T00:00:00.000Z"))
|
||||||
.setTitle("G-Mobile")
|
.setTitle("G-Mobile")
|
||||||
.setDataLimit(5 * TrafficStats.GB_IN_BYTES,
|
.setDataLimit(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_BILLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_BILLED)
|
||||||
.setDataUsage(1 * TrafficStats.GB_IN_BYTES,
|
.setDataUsage(DataUnit.GIBIBYTES.toBytes(1),
|
||||||
ZonedDateTime.now().minusHours(36).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(36).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
plans.add(SubscriptionPlan.Builder
|
plans.add(SubscriptionPlan.Builder
|
||||||
@@ -3498,15 +3496,15 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
.setTitle("G-Mobile Happy")
|
.setTitle("G-Mobile Happy")
|
||||||
.setDataLimit(SubscriptionPlan.BYTES_UNLIMITED,
|
.setDataLimit(SubscriptionPlan.BYTES_UNLIMITED,
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_BILLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_BILLED)
|
||||||
.setDataUsage(5 * TrafficStats.GB_IN_BYTES,
|
.setDataUsage(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
ZonedDateTime.now().minusHours(36).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(36).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
plans.add(SubscriptionPlan.Builder
|
plans.add(SubscriptionPlan.Builder
|
||||||
.createRecurringMonthly(ZonedDateTime.parse("2017-03-14T00:00:00.000Z"))
|
.createRecurringMonthly(ZonedDateTime.parse("2017-03-14T00:00:00.000Z"))
|
||||||
.setTitle("G-Mobile, Charged after limit")
|
.setTitle("G-Mobile, Charged after limit")
|
||||||
.setDataLimit(5 * TrafficStats.GB_IN_BYTES,
|
.setDataLimit(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_BILLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_BILLED)
|
||||||
.setDataUsage(5 * TrafficStats.GB_IN_BYTES,
|
.setDataUsage(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
ZonedDateTime.now().minusHours(36).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(36).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
} else if ("month_soft".equals(fake)) {
|
} else if ("month_soft".equals(fake)) {
|
||||||
@@ -3515,25 +3513,25 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
.setTitle("G-Mobile is the carriers name who this plan belongs to")
|
.setTitle("G-Mobile is the carriers name who this plan belongs to")
|
||||||
.setSummary("Crazy unlimited bandwidth plan with incredibly long title "
|
.setSummary("Crazy unlimited bandwidth plan with incredibly long title "
|
||||||
+ "that should be cut off to prevent UI from looking terrible")
|
+ "that should be cut off to prevent UI from looking terrible")
|
||||||
.setDataLimit(5 * TrafficStats.GB_IN_BYTES,
|
.setDataLimit(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
||||||
.setDataUsage(1 * TrafficStats.GB_IN_BYTES,
|
.setDataUsage(DataUnit.GIBIBYTES.toBytes(1),
|
||||||
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
plans.add(SubscriptionPlan.Builder
|
plans.add(SubscriptionPlan.Builder
|
||||||
.createRecurringMonthly(ZonedDateTime.parse("2017-03-14T00:00:00.000Z"))
|
.createRecurringMonthly(ZonedDateTime.parse("2017-03-14T00:00:00.000Z"))
|
||||||
.setTitle("G-Mobile, Throttled after limit")
|
.setTitle("G-Mobile, Throttled after limit")
|
||||||
.setDataLimit(5 * TrafficStats.GB_IN_BYTES,
|
.setDataLimit(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
||||||
.setDataUsage(5 * TrafficStats.GB_IN_BYTES,
|
.setDataUsage(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
plans.add(SubscriptionPlan.Builder
|
plans.add(SubscriptionPlan.Builder
|
||||||
.createRecurringMonthly(ZonedDateTime.parse("2017-03-14T00:00:00.000Z"))
|
.createRecurringMonthly(ZonedDateTime.parse("2017-03-14T00:00:00.000Z"))
|
||||||
.setTitle("G-Mobile, No data connection after limit")
|
.setTitle("G-Mobile, No data connection after limit")
|
||||||
.setDataLimit(5 * TrafficStats.GB_IN_BYTES,
|
.setDataLimit(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_DISABLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_DISABLED)
|
||||||
.setDataUsage(5 * TrafficStats.GB_IN_BYTES,
|
.setDataUsage(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
@@ -3541,25 +3539,25 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
plans.add(SubscriptionPlan.Builder
|
plans.add(SubscriptionPlan.Builder
|
||||||
.createRecurringMonthly(ZonedDateTime.parse("2007-03-14T00:00:00.000Z"))
|
.createRecurringMonthly(ZonedDateTime.parse("2007-03-14T00:00:00.000Z"))
|
||||||
.setTitle("G-Mobile is the carriers name who this plan belongs to")
|
.setTitle("G-Mobile is the carriers name who this plan belongs to")
|
||||||
.setDataLimit(5 * TrafficStats.GB_IN_BYTES,
|
.setDataLimit(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
||||||
.setDataUsage(6 * TrafficStats.GB_IN_BYTES,
|
.setDataUsage(DataUnit.GIBIBYTES.toBytes(6),
|
||||||
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
plans.add(SubscriptionPlan.Builder
|
plans.add(SubscriptionPlan.Builder
|
||||||
.createRecurringMonthly(ZonedDateTime.parse("2017-03-14T00:00:00.000Z"))
|
.createRecurringMonthly(ZonedDateTime.parse("2017-03-14T00:00:00.000Z"))
|
||||||
.setTitle("G-Mobile, Throttled after limit")
|
.setTitle("G-Mobile, Throttled after limit")
|
||||||
.setDataLimit(5 * TrafficStats.GB_IN_BYTES,
|
.setDataLimit(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
||||||
.setDataUsage(5 * TrafficStats.GB_IN_BYTES,
|
.setDataUsage(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
plans.add(SubscriptionPlan.Builder
|
plans.add(SubscriptionPlan.Builder
|
||||||
.createRecurringMonthly(ZonedDateTime.parse("2017-03-14T00:00:00.000Z"))
|
.createRecurringMonthly(ZonedDateTime.parse("2017-03-14T00:00:00.000Z"))
|
||||||
.setTitle("G-Mobile, No data connection after limit")
|
.setTitle("G-Mobile, No data connection after limit")
|
||||||
.setDataLimit(5 * TrafficStats.GB_IN_BYTES,
|
.setDataLimit(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_DISABLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_DISABLED)
|
||||||
.setDataUsage(5 * TrafficStats.GB_IN_BYTES,
|
.setDataUsage(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
@@ -3573,9 +3571,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
.createNonrecurring(ZonedDateTime.now().minusDays(20),
|
.createNonrecurring(ZonedDateTime.now().minusDays(20),
|
||||||
ZonedDateTime.now().plusDays(10))
|
ZonedDateTime.now().plusDays(10))
|
||||||
.setTitle("G-Mobile")
|
.setTitle("G-Mobile")
|
||||||
.setDataLimit(512 * TrafficStats.MB_IN_BYTES,
|
.setDataLimit(DataUnit.MEBIBYTES.toBytes(512),
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_DISABLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_DISABLED)
|
||||||
.setDataUsage(100 * TrafficStats.MB_IN_BYTES,
|
.setDataUsage(DataUnit.MEBIBYTES.toBytes(100),
|
||||||
ZonedDateTime.now().minusHours(3).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(3).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
} else if ("prepaid_crazy".equals(fake)) {
|
} else if ("prepaid_crazy".equals(fake)) {
|
||||||
@@ -3583,9 +3581,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
.createNonrecurring(ZonedDateTime.now().minusDays(20),
|
.createNonrecurring(ZonedDateTime.now().minusDays(20),
|
||||||
ZonedDateTime.now().plusDays(10))
|
ZonedDateTime.now().plusDays(10))
|
||||||
.setTitle("G-Mobile Anytime")
|
.setTitle("G-Mobile Anytime")
|
||||||
.setDataLimit(512 * TrafficStats.MB_IN_BYTES,
|
.setDataLimit(DataUnit.MEBIBYTES.toBytes(512),
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_DISABLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_DISABLED)
|
||||||
.setDataUsage(100 * TrafficStats.MB_IN_BYTES,
|
.setDataUsage(DataUnit.MEBIBYTES.toBytes(100),
|
||||||
ZonedDateTime.now().minusHours(3).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(3).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
plans.add(SubscriptionPlan.Builder
|
plans.add(SubscriptionPlan.Builder
|
||||||
@@ -3593,9 +3591,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
ZonedDateTime.now().plusDays(20))
|
ZonedDateTime.now().plusDays(20))
|
||||||
.setTitle("G-Mobile Nickel Nights")
|
.setTitle("G-Mobile Nickel Nights")
|
||||||
.setSummary("5¢/GB between 1-5AM")
|
.setSummary("5¢/GB between 1-5AM")
|
||||||
.setDataLimit(5 * TrafficStats.GB_IN_BYTES,
|
.setDataLimit(DataUnit.GIBIBYTES.toBytes(5),
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
||||||
.setDataUsage(15 * TrafficStats.MB_IN_BYTES,
|
.setDataUsage(DataUnit.MEBIBYTES.toBytes(15),
|
||||||
ZonedDateTime.now().minusHours(30).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(30).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
plans.add(SubscriptionPlan.Builder
|
plans.add(SubscriptionPlan.Builder
|
||||||
@@ -3603,9 +3601,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
ZonedDateTime.now().plusDays(20))
|
ZonedDateTime.now().plusDays(20))
|
||||||
.setTitle("G-Mobile Bonus 3G")
|
.setTitle("G-Mobile Bonus 3G")
|
||||||
.setSummary("Unlimited 3G data")
|
.setSummary("Unlimited 3G data")
|
||||||
.setDataLimit(1 * TrafficStats.GB_IN_BYTES,
|
.setDataLimit(DataUnit.GIBIBYTES.toBytes(1),
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
||||||
.setDataUsage(300 * TrafficStats.MB_IN_BYTES,
|
.setDataUsage(DataUnit.MEBIBYTES.toBytes(300),
|
||||||
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
} else if ("unlimited".equals(fake)) {
|
} else if ("unlimited".equals(fake)) {
|
||||||
@@ -3615,7 +3613,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
.setTitle("G-Mobile Awesome")
|
.setTitle("G-Mobile Awesome")
|
||||||
.setDataLimit(SubscriptionPlan.BYTES_UNLIMITED,
|
.setDataLimit(SubscriptionPlan.BYTES_UNLIMITED,
|
||||||
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
|
||||||
.setDataUsage(50 * TrafficStats.MB_IN_BYTES,
|
.setDataUsage(DataUnit.MEBIBYTES.toBytes(50),
|
||||||
ZonedDateTime.now().minusHours(3).toInstant().toEpochMilli())
|
ZonedDateTime.now().minusHours(3).toInstant().toEpochMilli())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user