OSDN Git Service

Add hostname aware isCleartextTrafficPermitted
authorChad Brubaker <cbrubaker@google.com>
Wed, 9 Dec 2015 22:58:01 +0000 (14:58 -0800)
committerChad Brubaker <cbrubaker@google.com>
Thu, 10 Dec 2015 18:30:33 +0000 (10:30 -0800)
Change-Id: I22b9ea277407846f9c333ce0cc37c25a2be1381e

core/java/android/security/FrameworkNetworkSecurityPolicy.java
core/java/android/security/NetworkSecurityPolicy.java

index e3dac5e..83f173e 100644 (file)
@@ -32,4 +32,9 @@ public class FrameworkNetworkSecurityPolicy extends libcore.net.NetworkSecurityP
     public boolean isCleartextTrafficPermitted() {
         return mCleartextTrafficPermitted;
     }
+
+    @Override
+    public boolean isCleartextTrafficPermitted(String hostname) {
+        return isCleartextTrafficPermitted();
+    }
 }
index 7991d37..46aa1af 100644 (file)
@@ -43,7 +43,7 @@ public class NetworkSecurityPolicy {
 
     /**
      * 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
      * FTP stacks, {@link android.app.DownloadManager}, {@link android.media.MediaPlayer}) will
@@ -64,6 +64,18 @@ public class NetworkSecurityPolicy {
     }
 
     /**
+     * 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.
      *
      * <p>This method is used by the platform early on in the application's initialization to set