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 <job-id>` where the
job-id can be found in logcat.

Change-Id: I148dc6a7f1c8362e87321ba5d4879b266f1f11c9
This commit is contained in:
Billy Lau
2022-11-30 23:59:04 -06:00
parent fa11a685e1
commit 0000111139

View File

@@ -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) {