Merge "Address API review feedback"

This commit is contained in:
Chiachang Wang
2021-04-26 00:22:27 +00:00
committed by Gerrit Code Review
10 changed files with 51 additions and 36 deletions

View File

@@ -4418,7 +4418,7 @@ public class ConnectivityManager {
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
public void registerDefaultNetworkCallback(@NonNull NetworkCallback networkCallback,
@NonNull Handler handler) {
registerDefaultNetworkCallbackAsUid(Process.INVALID_UID, networkCallback, handler);
registerDefaultNetworkCallbackForUid(Process.INVALID_UID, networkCallback, handler);
}
/**
@@ -4448,7 +4448,7 @@ public class ConnectivityManager {
@RequiresPermission(anyOf = {
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
android.Manifest.permission.NETWORK_SETTINGS})
public void registerDefaultNetworkCallbackAsUid(int uid,
public void registerDefaultNetworkCallbackForUid(int uid,
@NonNull NetworkCallback networkCallback, @NonNull Handler handler) {
CallbackHandler cbHandler = new CallbackHandler(handler);
sendRequestForNetwork(uid, null /* need */, networkCallback, 0 /* timeoutMs */,

View File

@@ -879,11 +879,11 @@ public abstract class NetworkAgent {
* This method may be called at any time while the network is connected. It has no effect if
* the network is already disconnected and the teardown delay timer is running.
*
* @param teardownDelayMs the teardown delay to set, or 0 to disable teardown delay.
* @param teardownDelayMillis the teardown delay to set, or 0 to disable teardown delay.
*/
public void setTeardownDelayMs(
@IntRange(from = 0, to = MAX_TEARDOWN_DELAY_MS) int teardownDelayMs) {
queueOrSendMessage(reg -> reg.sendTeardownDelayMs(teardownDelayMs));
public void setTeardownDelayMillis(
@IntRange(from = 0, to = MAX_TEARDOWN_DELAY_MS) int teardownDelayMillis) {
queueOrSendMessage(reg -> reg.sendTeardownDelayMs(teardownDelayMillis));
}
/**

View File

@@ -40,10 +40,10 @@ import java.util.Objects;
@SystemApi(client = MODULE_LIBRARIES)
public final class VpnTransportInfo implements TransportInfo, Parcelable {
/** Type of this VPN. */
public final int type;
private final int mType;
@Nullable
public final String sessionId;
private final String mSessionId;
@Override
public @RedactionType long getApplicableRedactions() {
@@ -55,13 +55,28 @@ public final class VpnTransportInfo implements TransportInfo, Parcelable {
*/
@NonNull
public VpnTransportInfo makeCopy(@RedactionType long redactions) {
return new VpnTransportInfo(type,
((redactions & REDACT_FOR_NETWORK_SETTINGS) != 0) ? null : sessionId);
return new VpnTransportInfo(mType,
((redactions & REDACT_FOR_NETWORK_SETTINGS) != 0) ? null : mSessionId);
}
public VpnTransportInfo(int type, @Nullable String sessionId) {
this.type = type;
this.sessionId = sessionId;
this.mType = type;
this.mSessionId = sessionId;
}
/**
* Returns the session Id of this VpnTransportInfo.
*/
@Nullable
public String getSessionId() {
return mSessionId;
}
/**
* Returns the type of this VPN.
*/
public int getType() {
return mType;
}
@Override
@@ -69,17 +84,17 @@ public final class VpnTransportInfo implements TransportInfo, Parcelable {
if (!(o instanceof VpnTransportInfo)) return false;
VpnTransportInfo that = (VpnTransportInfo) o;
return (this.type == that.type) && TextUtils.equals(this.sessionId, that.sessionId);
return (this.mType == that.mType) && TextUtils.equals(this.mSessionId, that.mSessionId);
}
@Override
public int hashCode() {
return Objects.hash(type, sessionId);
return Objects.hash(mType, mSessionId);
}
@Override
public String toString() {
return String.format("VpnTransportInfo{type=%d, sessionId=%s}", type, sessionId);
return String.format("VpnTransportInfo{type=%d, sessionId=%s}", mType, mSessionId);
}
@Override
@@ -89,8 +104,8 @@ public final class VpnTransportInfo implements TransportInfo, Parcelable {
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(type);
dest.writeString(sessionId);
dest.writeInt(mType);
dest.writeString(mSessionId);
}
public static final @NonNull Creator<VpnTransportInfo> CREATOR =