Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0eb8f090 authored by lucaslin's avatar lucaslin Committed by Lucas Lin
Browse files

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 6a75e5a3)
Merged-In: Ia36d794446114c0c2c27e725cba6a4dc1240ae38
parent e7dad46f
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -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();
    }
}