Skip to content
Snippets Groups Projects
Commit c4374829 authored by Chalard Jean's avatar Chalard Jean
Browse files

Detect discrepancies in subIds

The subIds in network capabilities are stored both in
the network specifier (for telephony) or transportInfo (for
wifi), and in a separate field in NC, which are seeded
differently. These should in principle never diverge if there
is no bug in the network factories code, but since this code
is OEM-specific, it's very hard to know whether it's the case.

Historically CarrierPrivilegeAuthenticator has been using the
specifier / info to find out about the sub id, but reading
from NetworkCapabilities#getSubscriptionIds() would be both
nicer and more future-proof. Log a terrible failure in case
they differ, so we can confidently switch to the latter if
we don't see any such log.

Change-Id: Ifdf67318ceb881349e322591632c18a4dbf218e1
Test: NetworkAgentTest
parent a093b452
No related branches found
No related tags found
No related merge requests found
......@@ -224,6 +224,17 @@ public class CarrierPrivilegeAuthenticator {
} else {
subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
}
if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
&& !networkCapabilities.getSubscriptionIds().contains(subId)) {
// Ideally, the code above should just use networkCapabilities.getSubscriptionIds()
// for simplicity and future-proofing. However, this is not the historical behavior,
// and there is no enforcement that they do not differ, so log a terrible failure if
// they do not match to gain confidence this never happens.
// TODO : when there is confidence that this never happens, rewrite the code above
// with NetworkCapabilities#getSubscriptionIds.
Log.wtf(TAG, "NetworkCapabilities subIds are inconsistent between "
+ "specifier/transportInfo and mSubIds : " + networkCapabilities);
}
if (SubscriptionManager.INVALID_SUBSCRIPTION_ID == subId) return false;
return callingUid == getCarrierServiceUidForSubId(subId);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment