From 473ee1358deac95b094a40fd47397ab97b975751 Mon Sep 17 00:00:00 2001 From: Chad Brubaker Date: Mon, 20 Jun 2016 12:41:47 -0700 Subject: Use calling app's Network Security Config for HTTPS downloads Bug:29505888 Change-Id: Ifc33fd75e44d1dbc5a4ce5caa8e1ff938b94623e --- .../android/providers/downloads/FakeSystemFacade.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests') diff --git a/tests/src/com/android/providers/downloads/FakeSystemFacade.java b/tests/src/com/android/providers/downloads/FakeSystemFacade.java index 3b9a83bf..b6b800a2 100644 --- a/tests/src/com/android/providers/downloads/FakeSystemFacade.java +++ b/tests/src/com/android/providers/downloads/FakeSystemFacade.java @@ -4,6 +4,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager.NameNotFoundException; import android.net.ConnectivityManager; @@ -17,8 +18,10 @@ import org.mockito.stubbing.Answer; import java.io.IOException; import java.net.URL; import java.net.URLConnection; +import java.security.GeneralSecurityException; import java.util.ArrayList; import java.util.List; +import javax.net.ssl.SSLContext; public class FakeSystemFacade implements SystemFacade { long mTimeMillis = 0; @@ -30,6 +33,7 @@ public class FakeSystemFacade implements SystemFacade { List mBroadcastsSent = new ArrayList(); boolean mCleartextTrafficPermitted = true; private boolean mReturnActualTime = false; + private SSLContext mSSLContext = null; public void setUp() { mTimeMillis = 0; @@ -40,6 +44,11 @@ public class FakeSystemFacade implements SystemFacade { mRecommendedMaxBytesOverMobile = Long.MAX_VALUE; mBroadcastsSent.clear(); mReturnActualTime = false; + try { + mSSLContext = SSLContext.getDefault(); + } catch (GeneralSecurityException e) { + throw new RuntimeException(e); + } } void incrementTimeMillis(long delta) { @@ -112,6 +121,15 @@ public class FakeSystemFacade implements SystemFacade { return mCleartextTrafficPermitted; } + @Override + public SSLContext getSSLContextForPackage(Context context, String pckg) { + return mSSLContext; + } + + public void setSSLContext(SSLContext context) { + mSSLContext = context; + } + public void setReturnActualTime(boolean flag) { mReturnActualTime = flag; } -- cgit v1.2.3