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

Commit 6ecc570b authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Update puller method to support other modalities

Bug: 120161047
Bug: 117060268

Test: Builds
Change-Id: Ieaeadbb32b2b3a7aa2436ca2328a8f9c56e79d62
parent 367f0686
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -174,9 +174,12 @@ const std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
        // Size of specific categories of files. Eg. Music.
        {android::util::CATEGORY_SIZE,
         {.puller = new StatsCompanionServicePuller(android::util::CATEGORY_SIZE)}},
        // Number of fingerprints registered to each user.
        // Number of fingerprints enrolled for each user.
        {android::util::NUM_FINGERPRINTS_ENROLLED,
         {.puller = new StatsCompanionServicePuller(android::util::NUM_FINGERPRINTS_ENROLLED)}},
        // Number of faces enrolled for each user.
        {android::util::NUM_FACES_ENROLLED,
         {.puller = new StatsCompanionServicePuller(android::util::NUM_FACES_ENROLLED)}},
        // ProcStats.
        {android::util::PROC_STATS,
         {.puller = new StatsCompanionServicePuller(android::util::PROC_STATS)}},
+26 −6
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ import android.content.IntentSender;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.hardware.biometrics.BiometricsProtoEnums;
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import android.net.ConnectivityManager;
import android.net.INetworkStatsService;
@@ -1411,23 +1413,35 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
        }
    }

    private void pullNumFingerprints(int tagId, long elapsedNanos, long wallClockNanos,
            List<StatsLogEventWrapper> pulledData) {
    private void pullNumBiometricsEnrolled(int modality, int tagId, long elapsedNanos,
            long wallClockNanos, List<StatsLogEventWrapper> pulledData) {
        FingerprintManager fingerprintManager = mContext.getSystemService(FingerprintManager.class);
        if (fingerprintManager == null) {
        FaceManager faceManager = mContext.getSystemService(FaceManager.class);
        if (modality == BiometricsProtoEnums.MODALITY_FINGERPRINT && fingerprintManager == null) {
            return;
        }
        if (modality == BiometricsProtoEnums.MODALITY_FACE && faceManager == null) {
            return;
        }
        UserManager userManager = mContext.getSystemService(UserManager.class);
        if (userManager == null) {
            return;
        }

        final long token = Binder.clearCallingIdentity();
        for (UserInfo user : userManager.getUsers()) {
            final int userId = user.getUserHandle().getIdentifier();
            final int numFingerprints = fingerprintManager.getEnrolledFingerprints(userId).size();
            int numEnrolled = 0;
            if (modality == BiometricsProtoEnums.MODALITY_FINGERPRINT) {
                numEnrolled = fingerprintManager.getEnrolledFingerprints(userId).size();
            } else if (modality == BiometricsProtoEnums.MODALITY_FACE) {
                numEnrolled = faceManager.getEnrolledFaces(userId).size();
            } else {
                return;
            }
            StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
            e.writeInt(userId);
            e.writeInt(numFingerprints);
            e.writeInt(numEnrolled);
            pulledData.add(e);
        }
        Binder.restoreCallingIdentity(token);
@@ -1898,7 +1912,13 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
                break;
            }
            case StatsLog.NUM_FINGERPRINTS_ENROLLED: {
                pullNumFingerprints(tagId, elapsedNanos, wallClockNanos, ret);
                pullNumBiometricsEnrolled(BiometricsProtoEnums.MODALITY_FINGERPRINT, tagId,
                        elapsedNanos, wallClockNanos, ret);
                break;
            }
            case StatsLog.NUM_FACES_ENROLLED: {
                pullNumBiometricsEnrolled(BiometricsProtoEnums.MODALITY_FACE, tagId, elapsedNanos,
                        wallClockNanos, ret);
                break;
            }
            case StatsLog.PROC_STATS: {