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

Commit f2a37d14 authored by Chen Chen's avatar Chen Chen Committed by Automerger Merge Worker
Browse files

Merge "BluetoothMetrics: Upload readable sha256, instead of bytes" am: 361c3b18 am: d53953ab

parents e6b4e6c3 d53953ab
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.internal.annotations.VisibleForTesting;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;
import com.google.common.hash.Hashing;

import java.io.ByteArrayInputStream;
import java.io.File;
@@ -304,16 +305,18 @@ public class MetricsLogger {
        if (matchedSha256 == null) {
            return false;
        }
        statslogBluetoothDeviceNames(metricId, matchedString, matchedSha256);
        statslogBluetoothDeviceNames(
                metricId,
                matchedString,
                Hashing.sha256().hashString(matchedString, StandardCharsets.UTF_8).toString());
        return true;
    }

    protected void statslogBluetoothDeviceNames(int metricId, String matchedString, byte[] sha256) {
        String sha256String = new String(sha256);
    protected void statslogBluetoothDeviceNames(int metricId, String matchedString, String sha256) {
        Log.d(TAG,
                "Uploading sha256 hash of matched bluetooth device name: " + sha256String);
                "Uploading sha256 hash of matched bluetooth device name: " + sha256);
        BluetoothStatsLog.write(
                BluetoothStatsLog.BLUETOOTH_HASHED_DEVICE_NAME_REPORTED, metricId, sha256String);
                BluetoothStatsLog.BLUETOOTH_HASHED_DEVICE_NAME_REPORTED, metricId, sha256);
    }

    protected static byte[] getSha256(String name) {
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ public class MetricsLoggerTest {

        @Override
        protected void statslogBluetoothDeviceNames(
                int metricId, String matchedString, byte[] sha256) {
                int metricId, String matchedString, String sha256) {
            mTestableDeviceNames.merge(matchedString, 1, Integer::sum);
        }
    }