CarrierConfigLoader: Always remove the timeout msg when receive result
Root cause:
Multiple config fetch sessions interleave with each other in different paths.
When one fetch session receives the result of default config and find the
ServiceConnection is stale (due to the new ServiceConnection created for
carrier config in other session), the original timeout msg is not removed.
The coming timeout msg assigns default config with stub config, although at
that time, both default and carrier config have been fetched in other session.
Solution:
Remove timeout msg when onReiveResult is called. At that time, we know
we have received result (whether success or not).
Alternative solutions:
While a full solution to throughly fix the interleaving problem
is prepared (aosp/1660529), the complexity make it more risky.
It will be landed on T release instead.
Bug: 181500325
Test: atest com.android.phone.CarrierConfigLoaderTest
Change-Id: Ied3c3ad96d654e6c5ab7160b12a25e64cf2f0d8c
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index 2c31dfd..d5b697a 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -321,13 +321,13 @@
@Override
public void onReceiveResult(int resultCode, Bundle resultData) {
unbindIfBound(mContext, conn, phoneId);
+ removeMessages(EVENT_FETCH_DEFAULT_TIMEOUT,
+ getMessageToken(phoneId));
// If new service connection has been created, this is stale.
if (mServiceConnection[phoneId] != conn) {
loge("Received response for stale request.");
return;
}
- removeMessages(EVENT_FETCH_DEFAULT_TIMEOUT,
- getMessageToken(phoneId));
if (resultCode == RESULT_ERROR || resultData == null) {
// On error, abort config fetching.
loge("Failed to get carrier config");
@@ -451,13 +451,13 @@
@Override
public void onReceiveResult(int resultCode, Bundle resultData) {
unbindIfBound(mContext, conn, phoneId);
+ removeMessages(EVENT_FETCH_CARRIER_TIMEOUT,
+ getMessageToken(phoneId));
// If new service connection has been created, this is stale.
if (mServiceConnection[phoneId] != conn) {
loge("Received response for stale request.");
return;
}
- removeMessages(EVENT_FETCH_CARRIER_TIMEOUT,
- getMessageToken(phoneId));
if (resultCode == RESULT_ERROR || resultData == null) {
// On error, abort config fetching.
loge("Failed to get carrier config from carrier app: "