summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSewook Seo <sewookseo@google.com>2023-02-28 16:08:46 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-02-28 16:08:46 +0000
commit89f1a681064644f60ac4ef404fe07c4703d13397 (patch)
tree81a0c20a87ca1c0341570609251380aca18e14f6
parent51089ab4b2497cc252269326a95870d279d1da17 (diff)
parent3518eece2811eeb75fc13a7fc28002587d4e5ff0 (diff)
downloadTelephony-89f1a681064644f60ac4ef404fe07c4703d13397.tar.gz
Merge "[QNS] use type 'long' for throttling time" into udc-dev
-rw-r--r--services/QualifiedNetworksService/src/com/android/telephony/qns/RestrictManager.java32
-rw-r--r--services/QualifiedNetworksService/tests/src/com/android/telephony/qns/RestrictManagerTest.java69
2 files changed, 93 insertions, 8 deletions
diff --git a/services/QualifiedNetworksService/src/com/android/telephony/qns/RestrictManager.java b/services/QualifiedNetworksService/src/com/android/telephony/qns/RestrictManager.java
index beb316b..9ae8a1d 100644
--- a/services/QualifiedNetworksService/src/com/android/telephony/qns/RestrictManager.java
+++ b/services/QualifiedNetworksService/src/com/android/telephony/qns/RestrictManager.java
@@ -325,12 +325,15 @@ class RestrictManager {
final ArrayList<Integer> mReleaseEventList;
long mReleaseTime;
- Restriction(int type, int[] releaseEvents, int restrictTime) {
+ Restriction(int type, int[] releaseEvents, long restrictTime) {
mRestrictType = type;
if (restrictTime == 0) {
mReleaseTime = 0;
} else {
mReleaseTime = restrictTime + SystemClock.elapsedRealtime();
+ if (restrictTime > 0 && mReleaseTime < 0) {
+ mReleaseTime = Long.MAX_VALUE;
+ }
}
if (releaseEvents != null && releaseEvents.length > 0) {
mReleaseEventList = new ArrayList<>();
@@ -354,8 +357,11 @@ class RestrictManager {
return false;
}
- void updateRestrictTime(int timeMillis) {
+ void updateRestrictTime(long timeMillis) {
mReleaseTime = SystemClock.elapsedRealtime() + timeMillis;
+ if (timeMillis > 0 && mReleaseTime < 0) {
+ mReleaseTime = Long.MAX_VALUE;
+ }
}
@Override
@@ -788,7 +794,7 @@ class RestrictManager {
mDeferredThrottlingEvent.first,
RESTRICT_TYPE_THROTTLING,
sReleaseEventMap.get(RESTRICT_TYPE_THROTTLING),
- (int) delayMillis);
+ delayMillis);
}
mDeferredThrottlingEvent = null;
}
@@ -1173,7 +1179,7 @@ class RestrictManager {
}
}
- void addRestriction(int transport, Restriction restrictObj, int timeMillis) {
+ void addRestriction(int transport, Restriction restrictObj, long timeMillis) {
boolean needNotify = false;
HashMap<Integer, Restriction> restrictionMap =
mRestrictInfos.get(transport).getRestrictionMap();
@@ -1185,7 +1191,8 @@ class RestrictManager {
+ "] "
+ restrictTypeToString(restrictObj.mRestrictType)
+ " was restrict:"
- + (restriction != null));
+ + (restriction != null)
+ + " timeMillis:" + timeMillis);
if (restriction == null) {
restriction = restrictObj;
restrictionMap.put(restrictObj.mRestrictType, restriction);
@@ -1216,7 +1223,7 @@ class RestrictManager {
}
}
- void addRestriction(int transport, int type, int[] releaseEvents, int timeMillis) {
+ void addRestriction(int transport, int type, int[] releaseEvents, long timeMillis) {
boolean needNotify = false;
HashMap<Integer, Restriction> restrictionMap =
mRestrictInfos.get(transport).getRestrictionMap();
@@ -1228,7 +1235,8 @@ class RestrictManager {
+ "] "
+ restrictTypeToString(type)
+ " was restrict:"
- + (restriction != null));
+ + (restriction != null)
+ + " timeMillis:" + timeMillis);
if (restriction == null) {
restriction = new Restriction(type, releaseEvents, timeMillis);
restrictionMap.put(type, restriction);
@@ -1579,6 +1587,10 @@ class RestrictManager {
+ " transportType:"
+ QnsConstants.transportTypeToString(transportType));
if (throttle) {
+ if (throttleTime < 0) {
+ //FWK send minus value of throttle expiration time, consider anomaly report at here.
+ return;
+ }
long delayMillis = throttleTime - SystemClock.elapsedRealtime();
if (delayMillis > 0) {
if (mDataConnectionStatusTracker.isActiveState()) {
@@ -1590,11 +1602,15 @@ class RestrictManager {
+ throttleTime);
mDeferredThrottlingEvent = new Pair<>(transportType, throttleTime);
} else {
+ if (throttleTime == Long.MAX_VALUE || throttleTime == Integer.MAX_VALUE) {
+ //Keep throttle status until receiving un-throttle event.
+ delayMillis = 0;
+ }
addRestriction(
transportType,
RESTRICT_TYPE_THROTTLING,
sReleaseEventMap.get(RESTRICT_TYPE_THROTTLING),
- (int) delayMillis);
+ delayMillis);
}
}
} else {
diff --git a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/RestrictManagerTest.java b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/RestrictManagerTest.java
index 68f0adf..466e687 100644
--- a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/RestrictManagerTest.java
+++ b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/RestrictManagerTest.java
@@ -932,6 +932,75 @@ public class RestrictManagerTest extends QnsTest {
}
@Test
+ public void testRestrictWithThrottlingWithThrottleTimeMax() {
+ long throttleTime = Long.MAX_VALUE;
+ mRestrictManager.notifyThrottling(
+ true, throttleTime, AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
+ assertTrue(
+ mRestrictManager.hasRestrictionType(
+ AccessNetworkConstants.TRANSPORT_TYPE_WLAN, RESTRICT_TYPE_THROTTLING));
+ long elapsed = SystemClock.elapsedRealtime();
+ mTestLooper.moveTimeForward(Long.MAX_VALUE - elapsed);
+ mTestLooper.dispatchAll();
+ mTestLooper.moveTimeForward(Long.MAX_VALUE - elapsed);
+ mTestLooper.dispatchAll();
+ assertTrue(
+ mRestrictManager.hasRestrictionType(
+ AccessNetworkConstants.TRANSPORT_TYPE_WLAN, RESTRICT_TYPE_THROTTLING));
+ mRestrictManager.releaseRestriction(
+ AccessNetworkConstants.TRANSPORT_TYPE_WLAN, RESTRICT_TYPE_THROTTLING);
+ assertFalse(
+ mRestrictManager.hasRestrictionType(
+ AccessNetworkConstants.TRANSPORT_TYPE_WLAN, RESTRICT_TYPE_THROTTLING));
+
+ throttleTime = Integer.MAX_VALUE;
+ mRestrictManager.notifyThrottling(
+ true, throttleTime, AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
+ assertTrue(
+ mRestrictManager.hasRestrictionType(
+ AccessNetworkConstants.TRANSPORT_TYPE_WLAN, RESTRICT_TYPE_THROTTLING));
+ elapsed = SystemClock.elapsedRealtime();
+ mTestLooper.moveTimeForward(Long.MAX_VALUE - elapsed);
+ mTestLooper.dispatchAll();
+ assertTrue(
+ mRestrictManager.hasRestrictionType(
+ AccessNetworkConstants.TRANSPORT_TYPE_WLAN, RESTRICT_TYPE_THROTTLING));
+ mRestrictManager.releaseRestriction(
+ AccessNetworkConstants.TRANSPORT_TYPE_WLAN, RESTRICT_TYPE_THROTTLING);
+ assertFalse(
+ mRestrictManager.hasRestrictionType(
+ AccessNetworkConstants.TRANSPORT_TYPE_WLAN, RESTRICT_TYPE_THROTTLING));
+ }
+
+ @Test
+ public void testRestrictWithThrottlingWithAbnormalThrottleTime() {
+ long throttleTime = -134243;
+ mRestrictManager.notifyThrottling(
+ true, throttleTime, AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
+ assertFalse(
+ mRestrictManager.hasRestrictionType(
+ AccessNetworkConstants.TRANSPORT_TYPE_WLAN, RESTRICT_TYPE_THROTTLING));
+
+ throttleTime = Long.MAX_VALUE - 100;
+ mRestrictManager.notifyThrottling(
+ true, throttleTime, AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
+ assertTrue(
+ mRestrictManager.hasRestrictionType(
+ AccessNetworkConstants.TRANSPORT_TYPE_WLAN, RESTRICT_TYPE_THROTTLING));
+ long elapsed = SystemClock.elapsedRealtime();
+ mTestLooper.moveTimeForward(Long.MAX_VALUE - elapsed * 2);
+ mTestLooper.dispatchAll();
+ assertTrue(
+ mRestrictManager.hasRestrictionType(
+ AccessNetworkConstants.TRANSPORT_TYPE_WLAN, RESTRICT_TYPE_THROTTLING));
+ mTestLooper.moveTimeForward(elapsed + 1000);
+ mTestLooper.dispatchAll();
+ assertFalse(
+ mRestrictManager.hasRestrictionType(
+ AccessNetworkConstants.TRANSPORT_TYPE_WLAN, RESTRICT_TYPE_THROTTLING));
+ }
+
+ @Test
public void testDeferThrottlingDuringActiveState() {
long throttleTime = SystemClock.elapsedRealtime() + 10000;
DataConnectionStatusTracker.DataConnectionChangedInfo dcInfo =