Loading services/core/java/com/android/server/audio/SoundDoseHelper.java +24 −9 Original line number Diff line number Diff line Loading @@ -202,15 +202,7 @@ public class SoundDoseHelper { } } mCurrentCsd = currentCsd; mDoseRecords.addAll(Arrays.asList(records)); long totalDuration = 0; for (SoundDoseRecord record : records) { Log.i(TAG, " new record: csd=" + record.value + " averageMel=" + record.averageMel + " timestamp=" + record.timestamp + " duration=" + record.duration); totalDuration += record.duration; } mLogger.enqueue(SoundDoseEvent.getDoseUpdateEvent(currentCsd, totalDuration)); updateSoundDoseRecords(records, currentCsd); } }; Loading Loading @@ -626,6 +618,29 @@ public class SoundDoseHelper { return null; } private void updateSoundDoseRecords(SoundDoseRecord[] newRecords, float currentCsd) { long totalDuration = 0; for (SoundDoseRecord record : newRecords) { Log.i(TAG, " new record: " + record); totalDuration += record.duration; if (record.value < 0) { // Negative value means the record timestamp exceeded the CSD rolling window size // and needs to be removed if (!mDoseRecords.removeIf( r -> r.value == -record.value && r.timestamp == record.timestamp && r.averageMel == record.averageMel && r.duration == record.duration)) { Log.w(TAG, "Could not find cached record to remove: " + record); } } else { mDoseRecords.add(record); } } mLogger.enqueue(SoundDoseEvent.getDoseUpdateEvent(currentCsd, totalDuration)); } // StreamVolumeCommand contains the information needed to defer the process of // setStreamVolume() in case the user has to acknowledge the safe volume warning message. private static class StreamVolumeCommand { Loading Loading
services/core/java/com/android/server/audio/SoundDoseHelper.java +24 −9 Original line number Diff line number Diff line Loading @@ -202,15 +202,7 @@ public class SoundDoseHelper { } } mCurrentCsd = currentCsd; mDoseRecords.addAll(Arrays.asList(records)); long totalDuration = 0; for (SoundDoseRecord record : records) { Log.i(TAG, " new record: csd=" + record.value + " averageMel=" + record.averageMel + " timestamp=" + record.timestamp + " duration=" + record.duration); totalDuration += record.duration; } mLogger.enqueue(SoundDoseEvent.getDoseUpdateEvent(currentCsd, totalDuration)); updateSoundDoseRecords(records, currentCsd); } }; Loading Loading @@ -626,6 +618,29 @@ public class SoundDoseHelper { return null; } private void updateSoundDoseRecords(SoundDoseRecord[] newRecords, float currentCsd) { long totalDuration = 0; for (SoundDoseRecord record : newRecords) { Log.i(TAG, " new record: " + record); totalDuration += record.duration; if (record.value < 0) { // Negative value means the record timestamp exceeded the CSD rolling window size // and needs to be removed if (!mDoseRecords.removeIf( r -> r.value == -record.value && r.timestamp == record.timestamp && r.averageMel == record.averageMel && r.duration == record.duration)) { Log.w(TAG, "Could not find cached record to remove: " + record); } } else { mDoseRecords.add(record); } } mLogger.enqueue(SoundDoseEvent.getDoseUpdateEvent(currentCsd, totalDuration)); } // StreamVolumeCommand contains the information needed to defer the process of // setStreamVolume() in case the user has to acknowledge the safe volume warning message. private static class StreamVolumeCommand { Loading