Merge "Use InetAddress for LowPowerStandbyPortDescription" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
86fb6b2c3b
@@ -10719,15 +10719,15 @@ package android.os {
|
||||
|
||||
public static final class PowerManager.LowPowerStandbyPortDescription {
|
||||
ctor public PowerManager.LowPowerStandbyPortDescription(int, int, int);
|
||||
ctor public PowerManager.LowPowerStandbyPortDescription(int, int, int, @Nullable android.net.LinkAddress);
|
||||
method @Nullable public android.net.LinkAddress getBindAddress();
|
||||
ctor public PowerManager.LowPowerStandbyPortDescription(int, int, int, @Nullable java.net.InetAddress);
|
||||
method @Nullable public java.net.InetAddress getLocalAddress();
|
||||
method public int getPortMatcher();
|
||||
method public int getPortNumber();
|
||||
method public int getProtocol();
|
||||
field public static final int MATCH_PORT_LOCAL = 1; // 0x1
|
||||
field public static final int MATCH_PORT_REMOTE = 2; // 0x2
|
||||
field public static final int PROTOCOL_TCP = 1; // 0x1
|
||||
field public static final int PROTOCOL_UDP = 2; // 0x2
|
||||
field public static final int PROTOCOL_TCP = 6; // 0x6
|
||||
field public static final int PROTOCOL_UDP = 17; // 0x11
|
||||
}
|
||||
|
||||
public final class PowerManager.LowPowerStandbyPortsLock {
|
||||
|
||||
@@ -104,7 +104,7 @@ interface IPowerManager
|
||||
int protocol;
|
||||
int portMatcher;
|
||||
int portNumber;
|
||||
@nullable String bindAddress;
|
||||
@nullable byte[] localAddress;
|
||||
}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
|
||||
@@ -32,7 +32,6 @@ import android.annotation.TestApi;
|
||||
import android.app.PropertyInvalidatedCache;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.content.Context;
|
||||
import android.net.LinkAddress;
|
||||
import android.service.dreams.Sandman;
|
||||
import android.sysprop.InitProperties;
|
||||
import android.util.ArrayMap;
|
||||
@@ -45,6 +44,8 @@ import com.android.internal.util.Preconditions;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -3259,11 +3260,11 @@ public final class PowerManager {
|
||||
/**
|
||||
* Constant to indicate the {@link LowPowerStandbyPortDescription} refers to a TCP port.
|
||||
*/
|
||||
public static final int PROTOCOL_TCP = 1;
|
||||
public static final int PROTOCOL_TCP = 6;
|
||||
/**
|
||||
* Constant to indicate the {@link LowPowerStandbyPortDescription} refers to a UDP port.
|
||||
*/
|
||||
public static final int PROTOCOL_UDP = 2;
|
||||
public static final int PROTOCOL_UDP = 17;
|
||||
|
||||
/** @hide */
|
||||
@IntDef(prefix = { "MATCH_PORT_" }, value = {
|
||||
@@ -3292,7 +3293,7 @@ public final class PowerManager {
|
||||
private final int mPortMatcher;
|
||||
private final int mPortNumber;
|
||||
@Nullable
|
||||
private final LinkAddress mBindAddress;
|
||||
private final InetAddress mLocalAddress;
|
||||
|
||||
/**
|
||||
* Describes a port.
|
||||
@@ -3311,7 +3312,7 @@ public final class PowerManager {
|
||||
this.mProtocol = protocol;
|
||||
this.mPortMatcher = portMatcher;
|
||||
this.mPortNumber = portNumber;
|
||||
this.mBindAddress = null;
|
||||
this.mLocalAddress = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3323,16 +3324,16 @@ public final class PowerManager {
|
||||
* ({@link #MATCH_PORT_REMOTE}), or the destination port
|
||||
* ({@link #MATCH_PORT_LOCAL}).
|
||||
* @param portNumber The port number to match.
|
||||
* @param bindAddress The bind address to match.
|
||||
* @param localAddress The local address to match.
|
||||
*
|
||||
* @see #newLowPowerStandbyPortsLock(List)
|
||||
*/
|
||||
public LowPowerStandbyPortDescription(@Protocol int protocol, @PortMatcher int portMatcher,
|
||||
int portNumber, @Nullable LinkAddress bindAddress) {
|
||||
int portNumber, @Nullable InetAddress localAddress) {
|
||||
this.mProtocol = protocol;
|
||||
this.mPortMatcher = portMatcher;
|
||||
this.mPortNumber = portNumber;
|
||||
this.mBindAddress = bindAddress;
|
||||
this.mLocalAddress = localAddress;
|
||||
}
|
||||
|
||||
private String protocolToString(int protocol) {
|
||||
@@ -3398,8 +3399,8 @@ public final class PowerManager {
|
||||
* @see #getProtocol()
|
||||
*/
|
||||
@Nullable
|
||||
public LinkAddress getBindAddress() {
|
||||
return mBindAddress;
|
||||
public InetAddress getLocalAddress() {
|
||||
return mLocalAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3408,7 +3409,7 @@ public final class PowerManager {
|
||||
+ "mProtocol=" + protocolToString(mProtocol)
|
||||
+ ", mPortMatcher=" + portMatcherToString(mPortMatcher)
|
||||
+ ", mPortNumber=" + mPortNumber
|
||||
+ ", mBindAddress=" + mBindAddress
|
||||
+ ", mLocalAddress=" + mLocalAddress
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@@ -3418,13 +3419,13 @@ public final class PowerManager {
|
||||
if (!(o instanceof LowPowerStandbyPortDescription)) return false;
|
||||
LowPowerStandbyPortDescription that = (LowPowerStandbyPortDescription) o;
|
||||
return mProtocol == that.mProtocol && mPortMatcher == that.mPortMatcher
|
||||
&& mPortNumber == that.mPortNumber && Objects.equals(mBindAddress,
|
||||
that.mBindAddress);
|
||||
&& mPortNumber == that.mPortNumber && Objects.equals(mLocalAddress,
|
||||
that.mLocalAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mProtocol, mPortMatcher, mPortNumber, mBindAddress);
|
||||
return Objects.hash(mProtocol, mPortMatcher, mPortNumber, mLocalAddress);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@@ -3439,8 +3440,8 @@ public final class PowerManager {
|
||||
parcelablePortDescription.protocol = portDescription.mProtocol;
|
||||
parcelablePortDescription.portMatcher = portDescription.mPortMatcher;
|
||||
parcelablePortDescription.portNumber = portDescription.mPortNumber;
|
||||
if (portDescription.mBindAddress != null) {
|
||||
parcelablePortDescription.bindAddress = portDescription.mBindAddress.toString();
|
||||
if (portDescription.mLocalAddress != null) {
|
||||
parcelablePortDescription.localAddress = portDescription.mLocalAddress.getAddress();
|
||||
}
|
||||
return parcelablePortDescription;
|
||||
}
|
||||
@@ -3466,15 +3467,19 @@ public final class PowerManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
LinkAddress bindAddress = null;
|
||||
if (parcelablePortDescription.bindAddress != null) {
|
||||
bindAddress = new LinkAddress(parcelablePortDescription.bindAddress);
|
||||
InetAddress localAddress = null;
|
||||
if (parcelablePortDescription.localAddress != null) {
|
||||
try {
|
||||
localAddress = InetAddress.getByAddress(parcelablePortDescription.localAddress);
|
||||
} catch (UnknownHostException e) {
|
||||
Log.w(TAG, "Address has invalid length", e);
|
||||
}
|
||||
}
|
||||
return new LowPowerStandbyPortDescription(
|
||||
parcelablePortDescription.protocol,
|
||||
parcelablePortDescription.portMatcher,
|
||||
parcelablePortDescription.portNumber,
|
||||
bindAddress);
|
||||
localAddress);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
|
||||
Reference in New Issue
Block a user