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

Commit 00001111 authored by Billy Lau's avatar Billy Lau
Browse files

BinaryTransparencyService: Fix printPackageInstallationInfo

It seems that APEX_PRELOAD_LOCATION_ERROR is consistently returned
as the value of original APEX location when calling
`getOriginalApexPreinstalledLocation` when preloaded APEXs are
compressed.

While this change does not address the root issue of why that is
the case, it prevents the error value to be used as a legitimate
path to compute digests for by guarding the control flow based on
sane values of apex install location.

Bug: 264925790
Test: Manual.
	adb shell cmd transparency get apex_info -v
Change-Id: I924ba889cb6d11a874cf06ca8692f8320b86b588
parent 565b61b9
Loading
Loading
Loading
Loading
+23 −20
Original line number Diff line number Diff line
@@ -531,6 +531,7 @@ public class BinaryTransparencyService extends SystemService {
                        pw.println("|--> Pre-installed package install location: "
                                + origPackageFilepath);

                        if (!origPackageFilepath.equals(APEX_PRELOAD_LOCATION_ERROR)) {
                            if (useSha256) {
                                String sha256Digest = PackageUtils.computeSha256DigestForLargeFile(
                                        origPackageFilepath, PackageUtils.createLargeFileBuffer());
@@ -538,20 +539,22 @@ public class BinaryTransparencyService extends SystemService {
                                        + sha256Digest);
                            }


                            Map<Integer, byte[]> contentDigests = computeApkContentDigest(
                                    origPackageFilepath);
                            if (contentDigests == null) {
                            pw.println("ERROR: Failed to compute package content digest for "
                                    + origPackageFilepath);
                                pw.println("|--> ERROR: Failed to compute package content digest "
                                        + "for " + origPackageFilepath);
                            } else {
                                for (Map.Entry<Integer, byte[]> entry : contentDigests.entrySet()) {
                                    Integer algorithmId = entry.getKey();
                                    byte[] contentDigest = entry.getValue();
                                    pw.println("|--> Pre-installed package content digest: "
                                            + HexEncoding.encodeToString(contentDigest, false));
                                pw.println("|--> Pre-installed package content digest algorithm: "
                                        + translateContentDigestAlgorithmIdToString(algorithmId));
                                    pw.println("|--> Pre-installed package content digest "
                                            + "algorithm: "
                                            + translateContentDigestAlgorithmIdToString(
                                                    algorithmId));
                                }
                            }
                        }
                    }