diff --git a/android-core/src/main/java/com/mparticle/networking/NetworkConnection.java b/android-core/src/main/java/com/mparticle/networking/NetworkConnection.java index e1e1b1d97..5102dbf94 100644 --- a/android-core/src/main/java/com/mparticle/networking/NetworkConnection.java +++ b/android-core/src/main/java/com/mparticle/networking/NetworkConnection.java @@ -129,7 +129,7 @@ private static Certificate generateCertificate(CertificateFactory certificateFac private boolean shouldDisablePinning() { NetworkOptions networkOptions = mConfigManager.getNetworkOptions(); - return ConfigManager.getEnvironment() == MParticle.Environment.Development && networkOptions.pinningDisabledInDevelopment; + return networkOptions.pinningDisabled || (ConfigManager.getEnvironment() == MParticle.Environment.Development && networkOptions.pinningDisabledInDevelopment); } diff --git a/android-core/src/main/java/com/mparticle/networking/NetworkOptions.java b/android-core/src/main/java/com/mparticle/networking/NetworkOptions.java index a2320dc38..b0ff76b8f 100644 --- a/android-core/src/main/java/com/mparticle/networking/NetworkOptions.java +++ b/android-core/src/main/java/com/mparticle/networking/NetworkOptions.java @@ -25,6 +25,7 @@ public class NetworkOptions { Map domainMappings = new HashMap(); boolean pinningDisabledInDevelopment = false; + boolean pinningDisabled = false; private NetworkOptions() { } @@ -36,6 +37,10 @@ private NetworkOptions(Builder builder) { if (builder.pinningDisabledInDevelopment != null) { pinningDisabledInDevelopment = builder.pinningDisabledInDevelopment; } + + if (builder.pinningDisabled != null) { + pinningDisabled = builder.pinningDisabled; + } } @NonNull @@ -52,6 +57,7 @@ public static NetworkOptions withNetworkOptions(@Nullable String jsonString) { try { JSONObject jsonObject = new JSONObject(jsonString); builder.setPinningDisabledInDevelopment(jsonObject.optBoolean("disableDevPinning", false)); + builder.setPinningDisabled(jsonObject.optBoolean("disablePinning", false)); JSONArray domainMappingsJson = jsonObject.getJSONArray("domainMappings"); for (int i = 0; i < domainMappingsJson.length(); i++) { builder.addDomainMapping(DomainMapping @@ -93,6 +99,10 @@ public boolean isPinningDisabledInDevelopment() { return pinningDisabledInDevelopment; } + public boolean isPinningDisabled() { + return pinningDisabled; + } + DomainMapping getDomain(Endpoint endpoint) { return domainMappings.get(endpoint); } @@ -109,6 +119,7 @@ private JSONObject toJson() { try { JSONArray domainMappingsJson = new JSONArray(); networkOptions.put("disableDevPinning", pinningDisabledInDevelopment); + networkOptions.put("disablePinning", pinningDisabled); networkOptions.put("domainMappings", domainMappingsJson); for (DomainMapping domainMapping : domainMappings.values()) { domainMappingsJson.put(domainMapping.toString()); @@ -122,6 +133,7 @@ private JSONObject toJson() { public static class Builder { private Map domainMappings = new HashMap(); private Boolean pinningDisabledInDevelopment; + private Boolean pinningDisabled; private Builder() { } @@ -163,6 +175,12 @@ public Builder setPinningDisabledInDevelopment(boolean disabledInDevelopment) { return this; } + @NonNull + public Builder setPinningDisabled(boolean disabled) { + this.pinningDisabled = disabled; + return this; + } + @NonNull public NetworkOptions build() { return new NetworkOptions(this);