From 026a987e1e33b5e41eb88aefc0f92842b1c7a5b7 Mon Sep 17 00:00:00 2001 From: lucaslin Date: Tue, 23 Mar 2021 16:17:37 +0800 Subject: [PATCH 1/2] Expose NetworkScore to external caller NetworkScore will be a part of mainline module, so the external callers cannot call its hidden APIs. Expose needed APIs to the external callers. CTS-Coverage-Bug: 182963397 Bug: 182963397 Test: m Change-Id: Iddf8c71a5f51a40bc6ff78626b3e8ee530d1b7eb Merged-In: Iddf8c71a5f51a40bc6ff78626b3e8ee530d1b7eb (cherry-picked from ag/13947595) --- framework/api/system-current.txt | 13 +++++++++++++ framework/src/android/net/NetworkScore.java | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/framework/api/system-current.txt b/framework/api/system-current.txt index 703fca408f..8c1fae91eb 100644 --- a/framework/api/system-current.txt +++ b/framework/api/system-current.txt @@ -316,6 +316,19 @@ package android.net { method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_SIGNAL_STRENGTH_WAKEUP) public android.net.NetworkRequest.Builder setSignalStrength(int); } + public final class NetworkScore implements android.os.Parcelable { + method public int describeContents(); + method public int getLegacyInt(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator CREATOR; + } + + public static final class NetworkScore.Builder { + ctor public NetworkScore.Builder(); + method @NonNull public android.net.NetworkScore build(); + method @NonNull public android.net.NetworkScore.Builder setLegacyInt(int); + } + public final class OemNetworkPreferences implements android.os.Parcelable { method public int describeContents(); method @NonNull public java.util.Map getNetworkPreferences(); diff --git a/framework/src/android/net/NetworkScore.java b/framework/src/android/net/NetworkScore.java index eadcb2d0a7..65849930fa 100644 --- a/framework/src/android/net/NetworkScore.java +++ b/framework/src/android/net/NetworkScore.java @@ -17,6 +17,7 @@ package android.net; import android.annotation.NonNull; +import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; @@ -29,7 +30,7 @@ import com.android.internal.annotations.VisibleForTesting; * network is considered for a particular use. * @hide */ -// TODO : @SystemApi when the implementation is complete +@SystemApi public final class NetworkScore implements Parcelable { // This will be removed soon. Do *NOT* depend on it for any new code that is not part of // a migration. @@ -62,6 +63,8 @@ public final class NetworkScore implements Parcelable { /** * @return whether this score has a particular policy. + * + * @hide */ @VisibleForTesting public boolean hasPolicy(final int policy) { From 823542095f348ec38d762bd282511c915787a459 Mon Sep 17 00:00:00 2001 From: Chiachang Wang Date: Tue, 23 Mar 2021 16:12:44 +0800 Subject: [PATCH 2/2] Expose NetworkAgent constructor taking a NetworkScore parameter Vpn constructs NetworkAgent with this exposed NetworkAgent constructor. Given NetworkAgent is moving into the incoming connectivity module, Vpn which is outside the module will not be able to access it if it's not in the API surface. Thus, expose it to allow Vpn to use it. Bug: 182963397 Test: make update-api Change-Id: Ic2357dcfff3233e0dd17b48b0e376a5095ef60fa Merged-In: Ic2357dcfff3233e0dd17b48b0e376a5095ef60fa CTS-Coverage-Bug: 172183305 (cherry-picked from ag/13966707) --- framework/api/system-current.txt | 1 + framework/src/android/net/NetworkAgent.java | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/api/system-current.txt b/framework/api/system-current.txt index 8c1fae91eb..11aa7063da 100644 --- a/framework/api/system-current.txt +++ b/framework/api/system-current.txt @@ -212,6 +212,7 @@ package android.net { public abstract class NetworkAgent { ctor public NetworkAgent(@NonNull android.content.Context, @NonNull android.os.Looper, @NonNull String, @NonNull android.net.NetworkCapabilities, @NonNull android.net.LinkProperties, int, @NonNull android.net.NetworkAgentConfig, @Nullable android.net.NetworkProvider); + ctor public NetworkAgent(@NonNull android.content.Context, @NonNull android.os.Looper, @NonNull String, @NonNull android.net.NetworkCapabilities, @NonNull android.net.LinkProperties, @NonNull android.net.NetworkScore, @NonNull android.net.NetworkAgentConfig, @Nullable android.net.NetworkProvider); method @Nullable public android.net.Network getNetwork(); method public void markConnected(); method public void onAddKeepalivePacketFilter(int, @NonNull android.net.KeepalivePacketData); diff --git a/framework/src/android/net/NetworkAgent.java b/framework/src/android/net/NetworkAgent.java index 3863ed1113..05f8460770 100644 --- a/framework/src/android/net/NetworkAgent.java +++ b/framework/src/android/net/NetworkAgent.java @@ -390,7 +390,6 @@ public abstract class NetworkAgent { * @param score the initial score of this network. Update with sendNetworkScore. * @param config an immutable {@link NetworkAgentConfig} for this agent. * @param provider the {@link NetworkProvider} managing this agent. - * @hide TODO : unhide when impl is complete */ public NetworkAgent(@NonNull Context context, @NonNull Looper looper, @NonNull String logTag, @NonNull NetworkCapabilities nc, @NonNull LinkProperties lp,