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

Commit ec25dad1 authored by Hui Peng's avatar Hui Peng Committed by Gerrit Code Review
Browse files

Merge "[redact_log] Redact addresses in logs of DatabaseManager"

parents 3804101b 789314f4
Loading
Loading
Loading
Loading
+20 −18
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ public class DatabaseManager {
                return true;
            }
            logManufacturerInfo(device, key, newValue);
            logMetadataChange(address, "setCustomMeta key=" + key);
            logMetadataChange(data, "setCustomMeta key=" + key);
            data.setCustomizedMeta(key, newValue);

            updateDatabase(data);
@@ -277,7 +277,7 @@ public class DatabaseManager {
            String address = device.getAddress();

            if (!mMetadataCache.containsKey(address)) {
                Log.d(TAG, "getCustomMeta: device " + address + " is not in cache");
                Log.d(TAG, "getCustomMeta: device " + device + " is not in cache");
                return null;
            }

@@ -327,7 +327,7 @@ public class DatabaseManager {
            String address = device.getAddress();

            if (!mMetadataCache.containsKey(address)) {
                Log.d(TAG, "getAudioPolicyMetadata: device " + address + " is not in cache");
                Log.d(TAG, "getAudioPolicyMetadata: device " + device + " is not in cache");
                return null;
            }

@@ -389,8 +389,8 @@ public class DatabaseManager {
                return true;
            }
            String profileStr = BluetoothProfile.getProfileName(profile);
            logMetadataChange(address, profileStr + " connection policy changed: "
                    + ": " + oldConnectionPolicy + " -> " + newConnectionPolicy);
            logMetadataChange(data, profileStr + " connection policy changed: "
                                    + oldConnectionPolicy + " -> " + newConnectionPolicy);

            data.setProfileConnectionPolicy(profile, newConnectionPolicy);
            updateDatabase(data);
@@ -475,7 +475,7 @@ public class DatabaseManager {
            if (oldValue == newValue) {
                return;
            }
            logMetadataChange(address, "Supports optional codec changed: "
            logMetadataChange(data, "Supports optional codec changed: "
                                    + oldValue + " -> " + newValue);

            data.a2dpSupportsOptionalCodecs = newValue;
@@ -504,7 +504,7 @@ public class DatabaseManager {
            String address = device.getAddress();

            if (!mMetadataCache.containsKey(address)) {
                Log.d(TAG, "getA2dpOptionalCodec: device " + address + " is not in cache");
                Log.d(TAG, "getA2dpOptionalCodec: device " + device + " is not in cache");
                return BluetoothA2dp.OPTIONAL_CODECS_SUPPORT_UNKNOWN;
            }

@@ -546,7 +546,7 @@ public class DatabaseManager {
            if (oldValue == newValue) {
                return;
            }
            logMetadataChange(address, "Enable optional codec changed: "
            logMetadataChange(data, "Enable optional codec changed: "
                                     + oldValue + " -> " + newValue);

            data.a2dpOptionalCodecsEnabled = newValue;
@@ -575,7 +575,7 @@ public class DatabaseManager {
            String address = device.getAddress();

            if (!mMetadataCache.containsKey(address)) {
                Log.d(TAG, "getA2dpOptionalCodecEnabled: device " + address + " is not in cache");
                Log.d(TAG, "getA2dpOptionalCodecEnabled: device " + device + " is not in cache");
                return BluetoothA2dp.OPTIONAL_CODECS_PREF_UNKNOWN;
            }

@@ -689,7 +689,7 @@ public class DatabaseManager {
                            .getRemoteDevice(metadata.getAddress()));
                } catch (IllegalArgumentException ex) {
                    Log.d(TAG, "getBondedDevicesOrdered: Invalid address for "
                            + "device " + metadata.getAddress());
                               + "device " + metadata.getAnonymizedAddress());
                }
            }
        }
@@ -743,7 +743,7 @@ public class DatabaseManager {
                                metadata.getAddress());
                    } catch (IllegalArgumentException ex) {
                        Log.d(TAG, "getMostRecentlyConnectedA2dpDevice: Invalid address for "
                                + "device " + metadata.getAddress());
                                   + "device " + metadata.getAnonymizedAddress());
                    }
                }
            }
@@ -939,7 +939,7 @@ public class DatabaseManager {
        data.is_active_a2dp_device = isActiveA2dpDevice;
        mMetadataCache.put(address, data);
        updateDatabase(data);
        logMetadataChange(address, "Metadata created");
        logMetadataChange(data, "Metadata created");
    }

    @VisibleForTesting
@@ -954,7 +954,8 @@ public class DatabaseManager {
                    for (int key : list) {
                        mAdapterService.metadataChanged(address, key, null);
                    }
                    Log.i(TAG, "remove unpaired device from database " + address);
                    Log.i(TAG, "remove unpaired device from database "
                               + metadata.getAnonymizedAddress());
                    deleteDatabase(mMetadataCache.get(address));
                }
            });
@@ -1195,7 +1196,7 @@ public class DatabaseManager {
            Log.e(TAG, "deleteDatabase: address is null");
            return;
        }
        logMetadataChange(address, "Metadata deleted");
        logMetadataChange(data, "Metadata deleted");
        Message message = mHandler.obtainMessage(MSG_DELETE_DATABASE);
        message.obj = data.getAddress();
        mHandler.sendMessage(message);
@@ -1237,10 +1238,11 @@ public class DatabaseManager {
                Integer.parseInt(macAddress[2], 16));
    }

    private void logMetadataChange(String address, String log) {
    private void logMetadataChange(Metadata data, String log) {
        String time = Utils.getLocalTimeString();
        String uidPid = Utils.getUidPidString();
        mMetadataChangedLog.add(time + " (" + uidPid + ") " + address + " " + log);
        mMetadataChangedLog.add(time + " (" + uidPid + ") " + data.getAnonymizedAddress()
                                + " " + log);
    }

    /**