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

Commit 2091ab94 authored by Chad Brubaker's avatar Chad Brubaker
Browse files

Add hostname aware isCleartextTrafficPermitted

Change-Id: I22b9ea277407846f9c333ce0cc37c25a2be1381e
parent 224318aa
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -32,4 +32,9 @@ public class FrameworkNetworkSecurityPolicy extends libcore.net.NetworkSecurityP
    public boolean isCleartextTrafficPermitted() {
    public boolean isCleartextTrafficPermitted() {
        return mCleartextTrafficPermitted;
        return mCleartextTrafficPermitted;
    }
    }

    @Override
    public boolean isCleartextTrafficPermitted(String hostname) {
        return isCleartextTrafficPermitted();
    }
}
}
+13 −1
Original line number Original line Diff line number Diff line
@@ -43,7 +43,7 @@ public class NetworkSecurityPolicy {


    /**
    /**
     * Returns whether cleartext network traffic (e.g. HTTP, FTP, WebSockets, XMPP, IMAP, SMTP --
     * Returns whether cleartext network traffic (e.g. HTTP, FTP, WebSockets, XMPP, IMAP, SMTP --
     * without TLS or STARTTLS) is permitted for this process.
     * without TLS or STARTTLS) is permitted for all network communication from this process.
     *
     *
     * <p>When cleartext network traffic is not permitted, the platform's components (e.g. HTTP and
     * <p>When cleartext network traffic is not permitted, the platform's components (e.g. HTTP and
     * FTP stacks, {@link android.app.DownloadManager}, {@link android.media.MediaPlayer}) will
     * FTP stacks, {@link android.app.DownloadManager}, {@link android.media.MediaPlayer}) will
@@ -63,6 +63,18 @@ public class NetworkSecurityPolicy {
        return libcore.net.NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted();
        return libcore.net.NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted();
    }
    }


    /**
     * Returns whether cleartext network traffic (e.g. HTTP, FTP, XMPP, IMAP, SMTP -- without
     * TLS or STARTTLS) is permitted for communicating with {@code hostname} for this process.
     *
     * @see #isCleartextTrafficPermitted()
     * @hide
     */
    public boolean isCleartextTrafficPermitted(String hostname) {
        return libcore.net.NetworkSecurityPolicy.getInstance()
                .isCleartextTrafficPermitted(hostname);
    }

    /**
    /**
     * Sets whether cleartext network traffic is permitted for this process.
     * Sets whether cleartext network traffic is permitted for this process.
     *
     *