Expose access UIDs.

CTS already have basic tests for this since they run the common tests,
which were using these hidden methods already.

Test: CtsNetTestCases
Change-Id: Id5e5b911f5c63bdd3b05e5ac1d3dd89c1c525ab7
This commit is contained in:
Chalard Jean
2022-01-25 22:54:55 +09:00
parent e6c9527554
commit 41a602d2b8
2 changed files with 8 additions and 6 deletions

View File

@@ -132,6 +132,7 @@ package android.net {
}
public final class NetworkCapabilities implements android.os.Parcelable {
method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY) public java.util.Set<java.lang.Integer> getAccessUids();
method @Nullable public java.util.Set<android.util.Range<java.lang.Integer>> getUids();
method public boolean hasForbiddenCapability(int);
field public static final long REDACT_ALL = -1L; // 0xffffffffffffffffL
@@ -143,6 +144,7 @@ package android.net {
}
public static final class NetworkCapabilities.Builder {
method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY) public android.net.NetworkCapabilities.Builder setAccessUids(@NonNull java.util.Set<java.lang.Integer>);
method @NonNull public android.net.NetworkCapabilities.Builder setUids(@Nullable java.util.Set<android.util.Range<java.lang.Integer>>);
}

View File

@@ -1853,13 +1853,13 @@ public final class NetworkCapabilities implements Parcelable {
* the UID doesn't hold the USE_RESTRICTED_NETWORKS permission. This is defined by the
* network agent in charge of creating the network.
*
* Only network factories and the system server can see these UIDs, since the system
* The UIDs are only visible to network factories and the system server, since the system
* server makes sure to redact them before sending a NetworkCapabilities to a process
* that doesn't hold the permission.
*
* @hide
*/
// @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
@RequiresPermission(android.Manifest.permission.NETWORK_FACTORY)
public @NonNull Set<Integer> getAccessUids() {
return new ArraySet<>(mAccessUids);
@@ -3021,9 +3021,9 @@ public final class NetworkCapabilities implements Parcelable {
* the associated subscription. Failure to comply with these rules will see this member
* cleared.
* <p>
* Only network factories and the system server can see these UIDs, since the system server
* makes sure to redact them before sending a {@link NetworkCapabilities} instance to a
* process that doesn't hold the {@link android.Manifest.permission.NETWORK_FACTORY}
* These UIDs are only visible to network factories and the system server, since the system
* server makes sure to redact them before sending a {@link NetworkCapabilities} instance
* to a process that doesn't hold the {@link android.Manifest.permission.NETWORK_FACTORY}
* permission.
* <p>
* This list cannot be null, but it can be empty to mean that no UID without the
@@ -3035,7 +3035,7 @@ public final class NetworkCapabilities implements Parcelable {
* @hide
*/
@NonNull
// @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
@RequiresPermission(android.Manifest.permission.NETWORK_FACTORY)
public Builder setAccessUids(@NonNull Set<Integer> uids) {
Objects.requireNonNull(uids);