Add toString() for VpnProfileState am: 0eb8f090f6 am: e77def5c8d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18115179

Change-Id: Ifd594e553bc87d681cec2cea515868772d254254
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
lucaslin
2022-05-12 12:49:10 +00:00
committed by Automerger Merge Worker

View File

@@ -24,6 +24,7 @@ import android.os.Parcelable;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.util.StringJoiner;
/** /**
* Describe the state of VPN. * Describe the state of VPN.
@@ -150,4 +151,29 @@ public final class VpnProfileState implements Parcelable {
mAlwaysOn = in.readBoolean(); mAlwaysOn = in.readBoolean();
mLockdown = 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();
}
} }