Condividi tramite


NetworkCapabilities.OwnerUid Property

Definition

Retrieves the UID of the app that owns this network.

public int OwnerUid { [Android.Runtime.Register("getOwnerUid", "()I", "", ApiSince=30)] get; }
[<get: Android.Runtime.Register("getOwnerUid", "()I", "", ApiSince=30)>]
member this.OwnerUid : int

Property Value

Attributes

Remarks

Retrieves the UID of the app that owns this network.

For user privacy reasons, this field will only be populated if the following conditions are met:

The caller is the network owner, AND one of the following sets of requirements is met:

<ol> <li>The described Network is a VPN </ol>

OR:

<ol> <li>The calling app is the network owner <li>The calling app has the ACCESS_FINE_LOCATION permission granted <li>The user's location toggle is on </ol>

Instances of NetworkCapabilities sent to apps without the appropriate permissions will have this field cleared out.

This field will only be populated for VPN and wifi network suggestor apps (i.e using android.net.wifi.WifiNetworkSuggestion WifiNetworkSuggestion), and only for the network they own. In the case of wifi network suggestors apps, this field is also location sensitive, so the app needs to hold android.Manifest.permission#ACCESS_FINE_LOCATION permission. If the app targets SDK version greater than or equal to Build.VERSION_CODES#S, then they also need to use NetworkCallback#FLAG_INCLUDE_LOCATION_INFO to get the info in their callback. If the apps targets SDK version equal to {Build.VERSION_CODES#R, this field will always be included. The app will be blamed for location access if this field is included.

Java documentation for android.net.NetworkCapabilities.getOwnerUid().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to