From 0000111139a3104d75a7ca977ffae5fb42942871 Mon Sep 17 00:00:00 2001 From: Billy Lau Date: Wed, 30 Nov 2022 23:59:04 -0600 Subject: [PATCH] BinaryTransparencyService: Log new atom to Westworld. Per the introduction of a new atom (MobileBundledAppInfoGathered), we are logging new pertinent data to Westworld. These includes: - preloaded apps that are updated - new MBAs that are installed in the background Note that we are *not* recording the full set of preloaded apps on a device due to being cautious about data footprint. Instead, we rely on those being implicitly covered under the vbmeta digest measurement. Bug: 245944158 Test: Manual. Set up the device by going through the SuW. Connect to the Internet and allow for updates and also let the system install several MBAs. Then, invoke `statsd_testdrive 566` from a terminal (as 566 is the atom number). Within 60 seconds of that invocation, trigger the package measuring job via the following command from another terminal: `adb shell cmd jobscheduler run android ` where the job-id can be found in logcat. Change-Id: I148dc6a7f1c8362e87321ba5d4879b266f1f11c9 --- .../server/BinaryTransparencyService.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/services/core/java/com/android/server/BinaryTransparencyService.java b/services/core/java/com/android/server/BinaryTransparencyService.java index 68880bd09a408..277ee918ecd99 100644 --- a/services/core/java/com/android/server/BinaryTransparencyService.java +++ b/services/core/java/com/android/server/BinaryTransparencyService.java @@ -310,27 +310,27 @@ public class BinaryTransparencyService extends SystemService { Bundle packageMeasurement = measurePackage(packageInfo); results.add(packageMeasurement); - if (record) { + if (record && (mba_status == MBA_STATUS_UPDATED_PRELOAD)) { // compute digests of signing info String[] signerDigestHexStrings = computePackageSignerSha256Digests( packageInfo.signingInfo); // now we should have all the bits for the atom - /* TODO: Uncomment and test after merging new atom definition. + byte[] cDigest = packageMeasurement.getByteArray(BUNDLE_CONTENT_DIGEST); FrameworkStatsLog.write(FrameworkStatsLog.MOBILE_BUNDLED_APP_INFO_GATHERED, packageInfo.packageName, packageInfo.getLongVersionCode(), - HexEncoding.encodeToString(packageMeasurement.getByteArray( - BUNDLE_CONTENT_DIGEST), false), + (cDigest != null) ? HexEncoding.encodeToString( + packageMeasurement.getByteArray(BUNDLE_CONTENT_DIGEST), + false) : null, packageMeasurement.getInt(BUNDLE_CONTENT_DIGEST_ALGORITHM), signerDigestHexStrings, // signer_cert_digest - mba_status, // mba_status + mba_status, // mba_status null, // initiator null, // initiator_signer_digest null, // installer null // originator ); - */ } } if (DEBUG) { @@ -377,12 +377,13 @@ public class BinaryTransparencyService extends SystemService { } // we should now have all the info needed for the atom - /* TODO: Uncomment and test after merging new atom definition. + byte[] cDigest = packageMeasurement.getByteArray(BUNDLE_CONTENT_DIGEST); FrameworkStatsLog.write(FrameworkStatsLog.MOBILE_BUNDLED_APP_INFO_GATHERED, packageInfo.packageName, packageInfo.getLongVersionCode(), - HexEncoding.encodeToString(packageMeasurement.getByteArray( - BUNDLE_CONTENT_DIGEST), false), + (cDigest != null) ? HexEncoding.encodeToString( + packageMeasurement.getByteArray(BUNDLE_CONTENT_DIGEST), + false) : null, packageMeasurement.getInt(BUNDLE_CONTENT_DIGEST_ALGORITHM), signerDigestHexStrings, MBA_STATUS_NEW_INSTALL, // mba_status @@ -391,7 +392,6 @@ public class BinaryTransparencyService extends SystemService { installer, originator ); - */ } } if (DEBUG) {