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

Commit f7a2e7c5 authored by Jordan Liu's avatar Jordan Liu
Browse files

Fallback to non-gzip

Bug: 142906839
Test: manual and CarrierKeyDownloadMgrTest
Change-Id: I7ae2ddd701f3929c32922a495a08247645ce5c8d
parent a4c31c9f
Loading
Loading
Loading
Loading
+10 −5
Original line number Original line Diff line number Diff line
@@ -60,6 +60,7 @@ import java.security.cert.X509Certificate;
import java.util.Date;
import java.util.Date;
import java.util.Random;
import java.util.Random;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.ZipException;


/**
/**
 * This class contains logic to get Certificates and keep them current.
 * This class contains logic to get Certificates and keep them current.
@@ -403,11 +404,15 @@ public class CarrierKeyDownloadManager extends Handler {


    private static String convertToString(InputStream is) {
    private static String convertToString(InputStream is) {
        try {
        try {
            // The current implementation at certain Carriers has the data gzipped, which requires
            // If the carrier does not have the data gzipped, fallback to assuming it is not zipped.
            // us to unzip the contents. Longer term, we want to add a flag in carrier config which
            // parseJsonAndPersistKey may still fail if the data is malformed, so we won't be
            // determines if the data needs to be zipped or not.
            // persisting random bogus strings thinking it's the cert
            GZIPInputStream gunzip = new GZIPInputStream(is);
            try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(gunzip, UTF_8));
                is = new GZIPInputStream(is);
            } catch (ZipException e) {
                Log.d(LOG_TAG, "fallback to no gzip");
            }
            BufferedReader reader = new BufferedReader(new InputStreamReader(is, UTF_8));
            StringBuilder sb = new StringBuilder();
            StringBuilder sb = new StringBuilder();


            String line;
            String line;