Revert "Update the UIDs only after the native network is created"

This reverts commit a7d4766d0d.

Reason for revert: DroidMonitor: Potential culprit for Bug 218308105 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: Ia9953d023c1eb84846834f92d4f38a72fa14bd30
This commit is contained in:
Jordan Demeulenaere
2022-02-08 10:42:11 +00:00
parent a7d4766d0d
commit 13b96bc651

View File

@@ -7043,7 +7043,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
nai.notifyRegistered(); nai.notifyRegistered();
NetworkInfo networkInfo = nai.networkInfo; NetworkInfo networkInfo = nai.networkInfo;
updateNetworkInfo(nai, networkInfo); updateNetworkInfo(nai, networkInfo);
updateVpnUids(nai, null, nai.networkCapabilities); updateUids(nai, null, nai.networkCapabilities);
} }
private class NetworkOfferInfo implements IBinder.DeathRecipient { private class NetworkOfferInfo implements IBinder.DeathRecipient {
@@ -7679,8 +7679,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
updateNetworkPermissions(nai, newNc); updateNetworkPermissions(nai, newNc);
final NetworkCapabilities prevNc = nai.getAndSetNetworkCapabilities(newNc); final NetworkCapabilities prevNc = nai.getAndSetNetworkCapabilities(newNc);
updateVpnUids(nai, prevNc, newNc); updateUids(nai, prevNc, newNc);
updateAccessUids(nai, prevNc, newNc);
nai.updateScoreForNetworkAgentUpdate(); nai.updateScoreForNetworkAgentUpdate();
if (nai.getCurrentScore() == oldScore && newNc.equalRequestableCapabilities(prevNc)) { if (nai.getCurrentScore() == oldScore && newNc.equalRequestableCapabilities(prevNc)) {
@@ -7850,6 +7849,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
} }
private void updateUids(@NonNull NetworkAgentInfo nai, @Nullable NetworkCapabilities prevNc,
@Nullable NetworkCapabilities newNc) {
updateVpnUids(nai, prevNc, newNc);
updateAccessUids(nai, prevNc, newNc);
}
private void updateVpnUids(@NonNull NetworkAgentInfo nai, @Nullable NetworkCapabilities prevNc, private void updateVpnUids(@NonNull NetworkAgentInfo nai, @Nullable NetworkCapabilities prevNc,
@Nullable NetworkCapabilities newNc) { @Nullable NetworkCapabilities newNc) {
Set<UidRange> prevRanges = null == prevNc ? null : prevNc.getUidRanges(); Set<UidRange> prevRanges = null == prevNc ? null : prevNc.getUidRanges();
@@ -7906,7 +7911,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
} catch (Exception e) { } catch (Exception e) {
// Never crash! // Never crash!
loge("Exception in updateVpnUids: ", e); loge("Exception in updateUids: ", e);
} }
} }
@@ -7945,9 +7950,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
intsToUidRangeStableParcels(toRemove), intsToUidRangeStableParcels(toRemove),
PREFERENCE_ORDER_IRRELEVANT_BECAUSE_NOT_DEFAULT)); PREFERENCE_ORDER_IRRELEVANT_BECAUSE_NOT_DEFAULT));
} }
} catch (ServiceSpecificException e) {
// Has the interface disappeared since the network was built ?
Log.i(TAG, "Can't set access UIDs for network " + nai.network, e);
} catch (RemoteException e) { } catch (RemoteException e) {
// Netd died. This usually causes a runtime restart anyway. // Netd died. This usually causes a runtime restart anyway.
} }
@@ -8862,7 +8864,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
networkAgent.created = true; networkAgent.created = true;
networkAgent.onNetworkCreated(); networkAgent.onNetworkCreated();
updateAccessUids(networkAgent, null, networkAgent.networkCapabilities);
} }
if (!networkAgent.everConnected && state == NetworkInfo.State.CONNECTED) { if (!networkAgent.everConnected && state == NetworkInfo.State.CONNECTED) {
@@ -8916,7 +8917,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} else if (state == NetworkInfo.State.DISCONNECTED) { } else if (state == NetworkInfo.State.DISCONNECTED) {
networkAgent.disconnect(); networkAgent.disconnect();
if (networkAgent.isVPN()) { if (networkAgent.isVPN()) {
updateVpnUids(networkAgent, networkAgent.networkCapabilities, null); updateUids(networkAgent, networkAgent.networkCapabilities, null);
} }
disconnectAndDestroyNetwork(networkAgent); disconnectAndDestroyNetwork(networkAgent);
if (networkAgent.isVPN()) { if (networkAgent.isVPN()) {