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

Commit d5758340 authored by Victor Hsieh's avatar Victor Hsieh Committed by Android (Google) Code Review
Browse files

Merge "BinaryTransparencyService: Add CompatChange flag."

parents 64a22a86 00001111
Loading
Loading
Loading
Loading
+62 −47
Original line number Diff line number Diff line
@@ -21,10 +21,12 @@ import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.apex.ApexInfo;
import android.apex.IApexService;
import android.app.compat.CompatChanges;
import android.app.job.JobInfo;
import android.app.job.JobParameters;
import android.app.job.JobScheduler;
import android.app.job.JobService;
import android.compat.annotation.ChangeId;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
@@ -126,6 +128,14 @@ public class BinaryTransparencyService extends SystemService {
    // the system time (in ms) the last measurement was taken
    private long mMeasurementsLastRecordedMs;

    /**
     * Guards whether or not measurements of MBA to be performed. When this change is enabled,
     * measurements of MBAs are performed. But when it is disabled, only measurements of APEX
     * and modules are done.
     */
    @ChangeId
    public static final long LOG_MBA_INFO = 245692487L;

    final class BinaryTransparencyServiceImpl extends IBinaryTransparencyService.Stub {

        @Override
@@ -336,6 +346,7 @@ public class BinaryTransparencyService extends SystemService {
                        + " packages after considering preloads");
            }

            if (CompatChanges.isChangeEnabled(LOG_MBA_INFO)) {
                // lastly measure all newly installed MBAs
                for (PackageInfo packageInfo : getNewlyInstalledMbas()) {
                    if (packagesMeasured.contains(packageInfo.packageName)) {
@@ -353,7 +364,8 @@ public class BinaryTransparencyService extends SystemService {

                        // then extract package's InstallSourceInfo
                        if (DEBUG) {
                        Slog.d(TAG, "Extracting InstallSourceInfo for " + packageInfo.packageName);
                            Slog.d(TAG,
                                    "Extracting InstallSourceInfo for " + packageInfo.packageName);
                        }
                        InstallSourceInfo installSourceInfo = getInstallSourceInfo(
                                packageInfo.packageName);
@@ -365,7 +377,8 @@ public class BinaryTransparencyService extends SystemService {

                        if (installSourceInfo != null) {
                            initiator = installSourceInfo.getInitiatingPackageName();
                        initiatorSignerInfo = installSourceInfo.getInitiatingPackageSigningInfo();
                            initiatorSignerInfo =
                                    installSourceInfo.getInitiatingPackageSigningInfo();
                            if (initiatorSignerInfo != null) {
                                initiatorSignerInfoDigest = computePackageSignerSha256Digests(
                                        initiatorSignerInfo);
@@ -379,7 +392,8 @@ public class BinaryTransparencyService extends SystemService {
                        FrameworkStatsLog.write(FrameworkStatsLog.MOBILE_BUNDLED_APP_INFO_GATHERED,
                                packageInfo.packageName,
                                packageInfo.getLongVersionCode(),
                            (cDigest != null) ? HexEncoding.encodeToString(cDigest, false) : null,
                                (cDigest != null) ? HexEncoding.encodeToString(cDigest, false)
                                        : null,
                                packageMeasurement.getInt(BUNDLE_CONTENT_DIGEST_ALGORITHM),
                                signerDigestHexStrings,
                                MBA_STATUS_NEW_INSTALL,   // mba_status
@@ -390,6 +404,7 @@ public class BinaryTransparencyService extends SystemService {
                        );
                    }
                }
            }
            if (DEBUG) {
                long timeSpentMeasuring = System.currentTimeMillis() - currentTimeMs;
                Slog.d(TAG, "Measured " + packagesMeasured.size()