Merge "Update extra info before registering" am: 6f9c48b81e am: d5420bf1f9

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

Change-Id: I5e38601026c1f9d30fee58a40bfb1ad467f41e35
This commit is contained in:
Chiachang Wang
2020-06-05 00:41:42 +00:00
committed by Automerger Merge Worker
3 changed files with 41 additions and 3 deletions

View File

@@ -357,6 +357,7 @@ public abstract class NetworkAgent {
final NetworkInfo ni = new NetworkInfo(config.legacyType, config.legacyType, final NetworkInfo ni = new NetworkInfo(config.legacyType, config.legacyType,
config.legacyTypeName, ""); config.legacyTypeName, "");
ni.setIsAvailable(true); ni.setIsAvailable(true);
ni.setExtraInfo(config.getLegacyExtraInfo());
return ni; return ni;
} }

View File

@@ -185,6 +185,26 @@ public final class NetworkAgentConfig implements Parcelable {
return legacyTypeName; 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 */ /** @hide */
public NetworkAgentConfig() { public NetworkAgentConfig() {
} }
@@ -201,6 +221,7 @@ public final class NetworkAgentConfig implements Parcelable {
skip464xlat = nac.skip464xlat; skip464xlat = nac.skip464xlat;
legacyType = nac.legacyType; legacyType = nac.legacyType;
legacyTypeName = nac.legacyTypeName; legacyTypeName = nac.legacyTypeName;
mLegacyExtraInfo = nac.mLegacyExtraInfo;
} }
} }
@@ -308,6 +329,18 @@ public final class NetworkAgentConfig implements Parcelable {
return this; 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. * Returns the constructed {@link NetworkAgentConfig} object.
*/ */
@@ -330,14 +363,15 @@ public final class NetworkAgentConfig implements Parcelable {
&& skip464xlat == that.skip464xlat && skip464xlat == that.skip464xlat
&& legacyType == that.legacyType && legacyType == that.legacyType
&& Objects.equals(subscriberId, that.subscriberId) && Objects.equals(subscriberId, that.subscriberId)
&& Objects.equals(legacyTypeName, that.legacyTypeName); && Objects.equals(legacyTypeName, that.legacyTypeName)
&& Objects.equals(mLegacyExtraInfo, that.mLegacyExtraInfo);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(allowBypass, explicitlySelected, acceptUnvalidated, return Objects.hash(allowBypass, explicitlySelected, acceptUnvalidated,
acceptPartialConnectivity, provisioningNotificationDisabled, subscriberId, acceptPartialConnectivity, provisioningNotificationDisabled, subscriberId,
skip464xlat, legacyType, legacyTypeName); skip464xlat, legacyType, legacyTypeName, mLegacyExtraInfo);
} }
@Override @Override
@@ -353,6 +387,7 @@ public final class NetworkAgentConfig implements Parcelable {
+ ", legacyType = " + legacyType + ", legacyType = " + legacyType
+ ", hasShownBroken = " + hasShownBroken + ", hasShownBroken = " + hasShownBroken
+ ", legacyTypeName = '" + legacyTypeName + '\'' + ", legacyTypeName = '" + legacyTypeName + '\''
+ ", legacyExtraInfo = '" + mLegacyExtraInfo + '\''
+ "}"; + "}";
} }
@@ -372,6 +407,7 @@ public final class NetworkAgentConfig implements Parcelable {
out.writeInt(skip464xlat ? 1 : 0); out.writeInt(skip464xlat ? 1 : 0);
out.writeInt(legacyType); out.writeInt(legacyType);
out.writeString(legacyTypeName); out.writeString(legacyTypeName);
out.writeString(mLegacyExtraInfo);
} }
public static final @NonNull Creator<NetworkAgentConfig> CREATOR = public static final @NonNull Creator<NetworkAgentConfig> CREATOR =
@@ -388,6 +424,7 @@ public final class NetworkAgentConfig implements Parcelable {
networkAgentConfig.skip464xlat = in.readInt() != 0; networkAgentConfig.skip464xlat = in.readInt() != 0;
networkAgentConfig.legacyType = in.readInt(); networkAgentConfig.legacyType = in.readInt();
networkAgentConfig.legacyTypeName = in.readString(); networkAgentConfig.legacyTypeName = in.readString();
networkAgentConfig.mLegacyExtraInfo = in.readString();
return networkAgentConfig; return networkAgentConfig;
} }

View File

@@ -44,7 +44,7 @@ class NetworkAgentConfigTest {
setPartialConnectivityAcceptable(false) setPartialConnectivityAcceptable(false)
setUnvalidatedConnectivityAcceptable(true) setUnvalidatedConnectivityAcceptable(true)
}.build() }.build()
assertParcelSane(config, 9) assertParcelSane(config, 10)
} }
@Test @IgnoreUpTo(Build.VERSION_CODES.Q) @Test @IgnoreUpTo(Build.VERSION_CODES.Q)