Add toString() for VpnProfileState am: 0eb8f090f6
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18115179 Change-Id: I09c2c64427c381ea19a28d7d66b69318847aa4a9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
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