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

Commit e7cf08b4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Change sampling ratio to 2% and add device config flag for sampling...

Merge "Change sampling ratio to 2% and add device config flag for sampling ratio adjustment." into rvc-dev am: 1bf019ce am: 6e7b141e

Change-Id: I0c6e7a79dd9f95ee1ef308ca85a876113c017351
parents 57182b05 6e7b141e
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -206,6 +206,8 @@ public class StatsPullAtomService extends SystemService {
    private static final int OP_FLAGS_PULLED = OP_FLAG_SELF | OP_FLAG_TRUSTED_PROXY;
    private static final String COMMON_PERMISSION_PREFIX = "android.permission.";
    private static final String APP_OPS_TARGET_COLLECTION_SIZE = "app_ops_target_collection_size";
    private static final String DANGEROUS_PERMISSION_STATE_SAMPLE_RATE =
            "dangerous_permission_state_sample_rate";

    private final Object mNetworkStatsLock = new Object();
    @GuardedBy("mNetworkStatsLock")
@@ -2583,6 +2585,8 @@ public class StatsPullAtomService extends SystemService {

    int pullDangerousPermissionState(int atomTag, List<StatsEvent> pulledData) {
        final long token = Binder.clearCallingIdentity();
        float samplingRate = DeviceConfig.getFloat(DeviceConfig.NAMESPACE_PERMISSIONS,
                DANGEROUS_PERMISSION_STATE_SAMPLE_RATE, 0.02f);
        Set<Integer> reportedUids = new HashSet<>();
        try {
            PackageManager pm = mContext.getPackageManager();
@@ -2611,7 +2615,7 @@ public class StatsPullAtomService extends SystemService {
                    reportedUids.add(pkg.applicationInfo.uid);

                    if (atomTag == FrameworkStatsLog.DANGEROUS_PERMISSION_STATE_SAMPLED
                            && ThreadLocalRandom.current().nextFloat() > 0.01f) {
                            && ThreadLocalRandom.current().nextFloat() > samplingRate) {
                        continue;
                    }