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

Commit f597da7b authored by Jordan Liu's avatar Jordan Liu Committed by Automerger Merge Worker
Browse files

Fallback to non-gzip am: 661e9f7a

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1516047

Change-Id: I32d01a88f86fe5994ba6b160bec531aff6b9cf29
parents eaf8506c 661e9f7a
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import java.security.cert.X509Certificate;
import java.util.Date;
import java.util.Random;
import java.util.zip.GZIPInputStream;
import java.util.zip.ZipException;

/**
 * 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) {
        try {
            // The current implementation at certain Carriers has the data gzipped, which requires
            // us to unzip the contents. Longer term, we want to add a flag in carrier config which
            // determines if the data needs to be zipped or not.
            GZIPInputStream gunzip = new GZIPInputStream(is);
            BufferedReader reader = new BufferedReader(new InputStreamReader(gunzip, UTF_8));
            // If the carrier does not have the data gzipped, fallback to assuming it is not zipped.
            // parseJsonAndPersistKey may still fail if the data is malformed, so we won't be
            // persisting random bogus strings thinking it's the cert
            try {
                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();

            String line;