Merge changes from topic "defer-until-active"
* changes:
Add defer-until-active policy to CONNECTIVITY_ACTION.
Add defer-until-active policy to NETWORK_STATS_CHANGED.
diff --git a/service-t/src/com/android/server/net/NetworkStatsService.java b/service-t/src/com/android/server/net/NetworkStatsService.java
index 4eeaf6b..1606fd0 100644
--- a/service-t/src/com/android/server/net/NetworkStatsService.java
+++ b/service-t/src/com/android/server/net/NetworkStatsService.java
@@ -537,6 +537,7 @@
BroadcastOptions.makeBasic())
.setDeliveryGroupPolicy(
ConstantsShim.DELIVERY_GROUP_POLICY_MOST_RECENT)
+ .setDeferUntilActive(true)
.toBundle();
} catch (UnsupportedApiLevelException e) {
Log.wtf(TAG, "Using unsupported API" + e);
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index f5c6fb7..df29b8e 100755
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -3082,6 +3082,7 @@
optsShim.setDeliveryGroupPolicy(ConstantsShim.DELIVERY_GROUP_POLICY_MOST_RECENT);
optsShim.setDeliveryGroupMatchingKey(ConnectivityManager.CONNECTIVITY_ACTION,
createDeliveryGroupKeyForConnectivityAction(info));
+ optsShim.setDeferUntilActive(true);
} catch (UnsupportedApiLevelException e) {
Log.wtf(TAG, "Using unsupported API" + e);
}
diff --git a/tests/unit/java/com/android/server/ConnectivityServiceTest.java b/tests/unit/java/com/android/server/ConnectivityServiceTest.java
index c9783ba..febc23e 100755
--- a/tests/unit/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/unit/java/com/android/server/ConnectivityServiceTest.java
@@ -848,6 +848,7 @@
verify(mBroadcastOptionsShim).setDeliveryGroupMatchingKey(
eq(CONNECTIVITY_ACTION),
eq(createDeliveryGroupKeyForConnectivityAction(ni)));
+ verify(mBroadcastOptionsShim).setDeferUntilActive(eq(true));
} catch (UnsupportedApiLevelException e) {
throw new RuntimeException(e);
}