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

Commit 49d2af36 authored by Chiachang Wang's avatar Chiachang Wang Committed by Gerrit Code Review
Browse files

Merge "Update extra info before registering"

parents f7c1dc5a 55882575
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -357,6 +357,7 @@ public abstract class NetworkAgent {
        final NetworkInfo ni = new NetworkInfo(config.legacyType, config.legacyType,
                config.legacyTypeName, "");
        ni.setIsAvailable(true);
        ni.setExtraInfo(config.getLegacyExtraInfo());
        return ni;
    }

+39 −2
Original line number Diff line number Diff line
@@ -185,6 +185,26 @@ public final class NetworkAgentConfig implements Parcelable {
        return legacyTypeName;
    }

    /**
     * The legacy extra info of the agent. The extra info should only be :
     * <ul>
     *   <li>For cellular agents, the APN name.</li>
     *   <li>For ethernet agents, the interface name.</li>
     * </ul>
     * @hide
     */
    @NonNull
    private String mLegacyExtraInfo = "";

    /**
     * The legacy extra info of the agent.
     * @hide
     */
    @NonNull
    public String getLegacyExtraInfo() {
        return mLegacyExtraInfo;
    }

    /** @hide */
    public NetworkAgentConfig() {
    }
@@ -201,6 +221,7 @@ public final class NetworkAgentConfig implements Parcelable {
            skip464xlat = nac.skip464xlat;
            legacyType = nac.legacyType;
            legacyTypeName = nac.legacyTypeName;
            mLegacyExtraInfo = nac.mLegacyExtraInfo;
        }
    }

@@ -308,6 +329,18 @@ public final class NetworkAgentConfig implements Parcelable {
            return this;
        }

        /**
         * Sets the legacy extra info of the agent.
         * @param legacyExtraInfo the legacy extra info.
         * @return this builder, to facilitate chaining.
         * @hide
         */
        @NonNull
        public Builder setLegacyExtraInfo(@NonNull String legacyExtraInfo) {
            mConfig.mLegacyExtraInfo = legacyExtraInfo;
            return this;
        }

        /**
         * Returns the constructed {@link NetworkAgentConfig} object.
         */
@@ -330,14 +363,15 @@ public final class NetworkAgentConfig implements Parcelable {
                && skip464xlat == that.skip464xlat
                && legacyType == that.legacyType
                && Objects.equals(subscriberId, that.subscriberId)
                && Objects.equals(legacyTypeName, that.legacyTypeName);
                && Objects.equals(legacyTypeName, that.legacyTypeName)
                && Objects.equals(mLegacyExtraInfo, that.mLegacyExtraInfo);
    }

    @Override
    public int hashCode() {
        return Objects.hash(allowBypass, explicitlySelected, acceptUnvalidated,
                acceptPartialConnectivity, provisioningNotificationDisabled, subscriberId,
                skip464xlat, legacyType, legacyTypeName);
                skip464xlat, legacyType, legacyTypeName, mLegacyExtraInfo);
    }

    @Override
@@ -353,6 +387,7 @@ public final class NetworkAgentConfig implements Parcelable {
                + ", legacyType = " + legacyType
                + ", hasShownBroken = " + hasShownBroken
                + ", legacyTypeName = '" + legacyTypeName + '\''
                + ", legacyExtraInfo = '" + mLegacyExtraInfo + '\''
                + "}";
    }

@@ -372,6 +407,7 @@ public final class NetworkAgentConfig implements Parcelable {
        out.writeInt(skip464xlat ? 1 : 0);
        out.writeInt(legacyType);
        out.writeString(legacyTypeName);
        out.writeString(mLegacyExtraInfo);
    }

    public static final @NonNull Creator<NetworkAgentConfig> CREATOR =
@@ -388,6 +424,7 @@ public final class NetworkAgentConfig implements Parcelable {
            networkAgentConfig.skip464xlat = in.readInt() != 0;
            networkAgentConfig.legacyType = in.readInt();
            networkAgentConfig.legacyTypeName = in.readString();
            networkAgentConfig.mLegacyExtraInfo = in.readString();
            return networkAgentConfig;
        }

+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ class NetworkAgentConfigTest {
            setPartialConnectivityAcceptable(false)
            setUnvalidatedConnectivityAcceptable(true)
        }.build()
        assertParcelSane(config, 9)
        assertParcelSane(config, 10)
    }

    @Test @IgnoreUpTo(Build.VERSION_CODES.Q)