Add toString() for VpnProfileState
Sample log:
{State: DISCONNECTED, SessionId: null, Always-on: false,
Lockdown: false}
{State: CONNECTED, SessionId: d7913298-c07f-49de-b84e-304b5e26da89,
Always-on: true, Lockdown: false}
Bug: 225010642
Test: Add a log in Vpn.java and print it.
Change-Id: Ia36d794446114c0c2c27e725cba6a4dc1240ae38
(cherry picked from commit 6a75e5a3c5)
Merged-In: Ia36d794446114c0c2c27e725cba6a4dc1240ae38
This commit is contained in:
@@ -24,6 +24,7 @@ import android.os.Parcelable;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* Describe the state of VPN.
|
||||
@@ -150,4 +151,29 @@ public final class VpnProfileState implements Parcelable {
|
||||
mAlwaysOn = in.readBoolean();
|
||||
mLockdown = in.readBoolean();
|
||||
}
|
||||
|
||||
private String convertStateToString(@State int state) {
|
||||
switch (state) {
|
||||
case STATE_CONNECTED:
|
||||
return "CONNECTED";
|
||||
case STATE_CONNECTING:
|
||||
return "CONNECTING";
|
||||
case STATE_DISCONNECTED:
|
||||
return "DISCONNECTED";
|
||||
case STATE_FAILED:
|
||||
return "FAILED";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringJoiner resultJoiner = new StringJoiner(", ", "{", "}");
|
||||
resultJoiner.add("State: " + convertStateToString(getState()));
|
||||
resultJoiner.add("SessionId: " + getSessionId());
|
||||
resultJoiner.add("Always-on: " + isAlwaysOn());
|
||||
resultJoiner.add("Lockdown: " + isLockdownEnabled());
|
||||
return resultJoiner.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user