Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 233c7f58 authored by Benedict Wong's avatar Benedict Wong Committed by Automerger Merge Worker
Browse files

Merge "Downgrade list of subIds in NetworkCapabilities to @SystemApi" am: c7c4b132 am: 385ce8ed

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1652974

Change-Id: Ib714d9a03e5b5152a576330711a8894178db4a95
parents d6727c25 385ce8ed
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -298,7 +298,6 @@ package android.net {
    method @Nullable public android.net.NetworkSpecifier getNetworkSpecifier();
    method public int getOwnerUid();
    method public int getSignalStrength();
    method @NonNull public java.util.Set<java.lang.Integer> getSubIds();
    method @Nullable public android.net.TransportInfo getTransportInfo();
    method public boolean hasCapability(int);
    method public boolean hasTransport(int);
@@ -408,7 +407,6 @@ package android.net {
    method public android.net.NetworkRequest.Builder removeTransportType(int);
    method @Deprecated public android.net.NetworkRequest.Builder setNetworkSpecifier(String);
    method public android.net.NetworkRequest.Builder setNetworkSpecifier(android.net.NetworkSpecifier);
    method @NonNull public android.net.NetworkRequest.Builder setSubIds(@NonNull java.util.Set<java.lang.Integer>);
  }

  public class ParseException extends java.lang.RuntimeException {
+2 −0
Original line number Diff line number Diff line
@@ -275,6 +275,7 @@ package android.net {
    method @NonNull public int[] getAdministratorUids();
    method @Nullable public static String getCapabilityCarrierName(int);
    method @Nullable public String getSsid();
    method @NonNull public java.util.Set<java.lang.Integer> getSubIds();
    method @NonNull public int[] getTransportTypes();
    method public boolean isPrivateDnsBroken();
    method public boolean satisfiedByNetworkCapabilities(@Nullable android.net.NetworkCapabilities);
@@ -328,6 +329,7 @@ package android.net {

  public static class NetworkRequest.Builder {
    method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_SIGNAL_STRENGTH_WAKEUP) public android.net.NetworkRequest.Builder setSignalStrength(int);
    method @NonNull public android.net.NetworkRequest.Builder setSubIds(@NonNull java.util.Set<java.lang.Integer>);
  }

  public final class NetworkScore implements android.os.Parcelable {
+13 −0
Original line number Diff line number Diff line
@@ -2363,9 +2363,15 @@ public final class NetworkCapabilities implements Parcelable {

    /**
     * Gets the subscription ID set that associated to this network or request.
     *
     * <p>Instances of NetworkCapabilities will only have this field populated by the system if the
     * receiver holds the NETWORK_FACTORY permission. In all other cases, it will be the empty set.
     *
     * @return
     * @hide
     */
    @NonNull
    @SystemApi
    public Set<Integer> getSubIds() {
        return new ArraySet<>(mSubIds);
    }
@@ -2730,10 +2736,17 @@ public final class NetworkCapabilities implements Parcelable {
        /**
         * Set the subscription ID set.
         *
         * <p>SubIds are populated in NetworkCapability instances from the system only for callers
         * that hold the NETWORK_FACTORY permission. Similarly, the system will reject any
         * NetworkRequests filed with a non-empty set of subIds unless the caller holds the
         * NETWORK_FACTORY permission.
         *
         * @param subIds a set that represent the subscription IDs. Empty if clean up.
         * @return this builder.
         * @hide
         */
        @NonNull
        @SystemApi
        public Builder setSubIds(@NonNull final Set<Integer> subIds) {
            mCaps.setSubIds(subIds);
            return this;
+5 −0
Original line number Diff line number Diff line
@@ -501,9 +501,14 @@ public class NetworkRequest implements Parcelable {
         * A network will satisfy this request only if it matches one of the subIds in this set.
         * An empty set matches all networks, including those without a subId.
         *
         * <p>Registering a NetworkRequest with a non-empty set of subIds requires the
         * NETWORK_FACTORY permission.
         *
         * @param subIds A {@code Set} that represents subscription IDs.
         * @hide
         */
        @NonNull
        @SystemApi
        public Builder setSubIds(@NonNull Set<Integer> subIds) {
            mNetworkCapabilities.setSubIds(subIds);
            return this;
+8 −0
Original line number Diff line number Diff line
@@ -1895,6 +1895,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
            newNc.setNetworkSpecifier(newNc.getNetworkSpecifier().redact());
        }
        newNc.setAdministratorUids(new int[0]);
        if (!checkAnyPermissionOf(
                callerPid, callerUid, android.Manifest.permission.NETWORK_FACTORY)) {
            newNc.setSubIds(Collections.emptySet());
        }

        return newNc;
    }
@@ -5666,6 +5670,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
                    "Insufficient permissions to request a specific signal strength");
        }
        mAppOpsManager.checkPackage(callerUid, callerPackageName);

        if (!nc.getSubIds().isEmpty()) {
            enforceNetworkFactoryPermission();
        }
    }

    private int[] getSignalStrengthThresholds(@NonNull final NetworkAgentInfo nai) {
Loading