Add SDK level check to adding sandbox UIDs.

ConnectivityServiceTest builds against the latest Vpn framework code,
but when run on an older base image (eg 'S'), said framework code might
run into runtime errors calling new APIs. Until the test is decoupled,
do the SDK level check here.

Bug: 230548427
Bug: 232420362
Test: Build
Change-Id: If453e16e680f46cf2b9eb769e5607fb5513b32ac
(cherry picked from commit ab678b983b)
Merged-In: If453e16e680f46cf2b9eb769e5607fb5513b32ac
This commit is contained in:
Martijn Coenen
2022-05-13 04:44:56 +00:00
committed by Cherrypicker Worker
parent 41bcf6803e
commit 512a4fe715

View File

@@ -1646,7 +1646,9 @@ public class Vpn {
for (String app : packageNames) {
int uid = getAppUid(app, userId);
if (uid != -1) uids.add(uid);
if (Process.isApplicationUid(uid)) {
// TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from
// ConnectivityServiceTest.
if (Process.isApplicationUid(uid) && SdkLevel.isAtLeastT()) {
uids.add(Process.toSdkSandboxUid(uid));
}
}