Report anomaly when config change with subId maps to invalid phoneId
There is an increasing reports of exception from Pixels and other
OEM devices when CarrierConfigLoader received the notifyConfigChanged
with a subId.
The subId can pass the permission check but fail the following subId to
phoneId mapping check, which is pretty confusing.
To identify which scenario can cause such failure, an anomaly will be
reported to collect more context.
Bug: 270757342
Test: atest FrameworksTelephonyTestCases
Change-Id: If47cf7b23237177ea0368932e3389e4730eb82f0
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index ef71016..9b71919 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -52,6 +52,7 @@
import android.service.carrier.CarrierIdentifier;
import android.service.carrier.CarrierService;
import android.service.carrier.ICarrierService;
+import android.telephony.AnomalyReporter;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyFrameworkInitializer;
@@ -94,6 +95,7 @@
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
+import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -218,6 +220,10 @@
CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL
};
+ // UUID to report anomaly when config changed reported with subId that map to invalid phone
+ private static final String UUID_NOTIFY_CONFIG_CHANGED_WITH_INVALID_PHONE =
+ "d81cef11-c2f1-4d76-955d-7f50e8590c48";
+
// Handler to process various events.
//
// For each phoneId, the event sequence should be:
@@ -1483,9 +1489,14 @@
int phoneId = SubscriptionManager.getPhoneId(subscriptionId);
if (!SubscriptionManager.isValidPhoneId(phoneId)) {
- logd("Ignore invalid phoneId: " + phoneId + " for subId: " + subscriptionId);
- throw new IllegalArgumentException(
- "Invalid phoneId " + phoneId + " for subId " + subscriptionId);
+ final String msg =
+ "Ignore invalid phoneId: " + phoneId + " for subId: " + subscriptionId;
+ if (mFeatureFlags.addAnomalyWhenNotifyConfigChangedWithInvalidPhone()) {
+ AnomalyReporter.reportAnomaly(
+ UUID.fromString(UUID_NOTIFY_CONFIG_CHANGED_WITH_INVALID_PHONE), msg);
+ }
+ logd(msg);
+ throw new IllegalArgumentException(msg);
}
enforceTelephonyFeatureWithException(getCurrentPackageName(),