Merge changes Ide9daebc,Id47ada57

* changes:
  Ensure all VPN runners clean up state when exiting
  Enforce restricted user, getConnectionOwnerUid checks
This commit is contained in:
Benedict Wong
2020-02-17 21:30:35 +00:00
committed by Gerrit Code Review
4 changed files with 186 additions and 18 deletions

View File

@@ -7528,6 +7528,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
*/
public int getConnectionOwnerUid(ConnectionInfo connectionInfo) {
final Vpn vpn = enforceActiveVpnOrNetworkStackPermission();
// Only VpnService based VPNs should be able to get this information.
if (vpn != null && vpn.getActiveAppVpnType() != VpnManager.TYPE_VPN_SERVICE) {
throw new SecurityException(
"getConnectionOwnerUid() not allowed for non-VpnService VPNs");
}
if (connectionInfo.protocol != IPPROTO_TCP && connectionInfo.protocol != IPPROTO_UDP) {
throw new IllegalArgumentException("Unsupported protocol " + connectionInfo.protocol);
}