Loading services/core/java/com/android/server/audio/AudioService.java +1 −0 Original line number Diff line number Diff line Loading @@ -10003,6 +10003,7 @@ public class AudioService extends IAudioService.Stub static final int LOG_NB_EVENTS_VOLUME = 40; static final int LOG_NB_EVENTS_DYN_POLICY = 10; static final int LOG_NB_EVENTS_SPATIAL = 30; static final int LOG_NB_EVENTS_SOUND_DOSE = 30; static final EventLogger sLifecycleLogger = new EventLogger(LOG_NB_EVENTS_LIFECYCLE, Loading services/core/java/com/android/server/audio/AudioServiceEvents.java +49 −0 Original line number Diff line number Diff line Loading @@ -476,4 +476,53 @@ public class AudioServiceEvents { } } } static final class SoundDoseEvent extends EventLogger.Event { static final int MOMENTARY_EXPOSURE = 0; static final int DOSE_UPDATE = 1; static final int DOSE_REPEAT_5X = 2; static final int DOSE_ACCUMULATION_START = 3; final int mEventType; final float mFloatValue; final long mLongValue; private SoundDoseEvent(int event, float f, long l) { mEventType = event; mFloatValue = f; mLongValue = l; } static SoundDoseEvent getMomentaryExposureEvent(float mel) { return new SoundDoseEvent(MOMENTARY_EXPOSURE, mel, 0 /*ignored*/); } static SoundDoseEvent getDoseUpdateEvent(float csd, long totalDuration) { return new SoundDoseEvent(DOSE_UPDATE, csd, totalDuration); } static SoundDoseEvent getDoseRepeat5xEvent() { return new SoundDoseEvent(DOSE_REPEAT_5X, 0 /*ignored*/, 0 /*ignored*/); } static SoundDoseEvent getDoseAccumulationStartEvent() { return new SoundDoseEvent(DOSE_ACCUMULATION_START, 0 /*ignored*/, 0 /*ignored*/); } @Override public String eventToString() { switch (mEventType) { case MOMENTARY_EXPOSURE: return String.format("momentary exposure MEL=%.2f", mFloatValue); case DOSE_UPDATE: return String.format(java.util.Locale.US, "dose update CSD=%.1f%% total duration=%d", mFloatValue * 100.0f, mLongValue); case DOSE_REPEAT_5X: return "CSD reached 500%"; case DOSE_ACCUMULATION_START: return "CSD accumulating: RS2 entered"; } return new StringBuilder("FIXME invalid event type:").append(mEventType).toString(); } } } services/core/java/com/android/server/audio/SoundDoseHelper.java +12 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ import android.util.MathUtils; import com.android.internal.annotations.GuardedBy; import com.android.server.audio.AudioService.AudioHandler; import com.android.server.audio.AudioService.ISafeHearingVolumeController; import com.android.server.audio.AudioServiceEvents.SoundDoseEvent; import com.android.server.utils.EventLogger; import java.io.PrintWriter; import java.util.ArrayList; Loading Loading @@ -94,6 +96,9 @@ public class SoundDoseHelper { private static final float CUSTOM_RS2_VALUE = 90; private final EventLogger mLogger = new EventLogger(AudioService.LOG_NB_EVENTS_SOUND_DOSE, "CSD updates"); private int mMcc = 0; final Object mSafeMediaVolumeStateLock = new Object(); Loading Loading @@ -147,17 +152,21 @@ public class SoundDoseHelper { public void onMomentaryExposure(float currentMel, int deviceId) { Log.w(TAG, "DeviceId " + deviceId + " triggered momentary exposure with value: " + currentMel); mLogger.enqueue(SoundDoseEvent.getMomentaryExposureEvent(currentMel)); } public void onNewCsdValue(float currentCsd, SoundDoseRecord[] records) { Log.i(TAG, "onNewCsdValue: " + currentCsd); 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)); } }; Loading Loading @@ -400,6 +409,9 @@ public class SoundDoseHelper { pw.print(" mMusicActiveMs="); pw.println(mMusicActiveMs); pw.print(" mMcc="); pw.println(mMcc); pw.print(" mPendingVolumeCommand="); pw.println(mPendingVolumeCommand); pw.println(); mLogger.dump(pw); pw.println(); } /*package*/void reset() { Loading Loading
services/core/java/com/android/server/audio/AudioService.java +1 −0 Original line number Diff line number Diff line Loading @@ -10003,6 +10003,7 @@ public class AudioService extends IAudioService.Stub static final int LOG_NB_EVENTS_VOLUME = 40; static final int LOG_NB_EVENTS_DYN_POLICY = 10; static final int LOG_NB_EVENTS_SPATIAL = 30; static final int LOG_NB_EVENTS_SOUND_DOSE = 30; static final EventLogger sLifecycleLogger = new EventLogger(LOG_NB_EVENTS_LIFECYCLE, Loading
services/core/java/com/android/server/audio/AudioServiceEvents.java +49 −0 Original line number Diff line number Diff line Loading @@ -476,4 +476,53 @@ public class AudioServiceEvents { } } } static final class SoundDoseEvent extends EventLogger.Event { static final int MOMENTARY_EXPOSURE = 0; static final int DOSE_UPDATE = 1; static final int DOSE_REPEAT_5X = 2; static final int DOSE_ACCUMULATION_START = 3; final int mEventType; final float mFloatValue; final long mLongValue; private SoundDoseEvent(int event, float f, long l) { mEventType = event; mFloatValue = f; mLongValue = l; } static SoundDoseEvent getMomentaryExposureEvent(float mel) { return new SoundDoseEvent(MOMENTARY_EXPOSURE, mel, 0 /*ignored*/); } static SoundDoseEvent getDoseUpdateEvent(float csd, long totalDuration) { return new SoundDoseEvent(DOSE_UPDATE, csd, totalDuration); } static SoundDoseEvent getDoseRepeat5xEvent() { return new SoundDoseEvent(DOSE_REPEAT_5X, 0 /*ignored*/, 0 /*ignored*/); } static SoundDoseEvent getDoseAccumulationStartEvent() { return new SoundDoseEvent(DOSE_ACCUMULATION_START, 0 /*ignored*/, 0 /*ignored*/); } @Override public String eventToString() { switch (mEventType) { case MOMENTARY_EXPOSURE: return String.format("momentary exposure MEL=%.2f", mFloatValue); case DOSE_UPDATE: return String.format(java.util.Locale.US, "dose update CSD=%.1f%% total duration=%d", mFloatValue * 100.0f, mLongValue); case DOSE_REPEAT_5X: return "CSD reached 500%"; case DOSE_ACCUMULATION_START: return "CSD accumulating: RS2 entered"; } return new StringBuilder("FIXME invalid event type:").append(mEventType).toString(); } } }
services/core/java/com/android/server/audio/SoundDoseHelper.java +12 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ import android.util.MathUtils; import com.android.internal.annotations.GuardedBy; import com.android.server.audio.AudioService.AudioHandler; import com.android.server.audio.AudioService.ISafeHearingVolumeController; import com.android.server.audio.AudioServiceEvents.SoundDoseEvent; import com.android.server.utils.EventLogger; import java.io.PrintWriter; import java.util.ArrayList; Loading Loading @@ -94,6 +96,9 @@ public class SoundDoseHelper { private static final float CUSTOM_RS2_VALUE = 90; private final EventLogger mLogger = new EventLogger(AudioService.LOG_NB_EVENTS_SOUND_DOSE, "CSD updates"); private int mMcc = 0; final Object mSafeMediaVolumeStateLock = new Object(); Loading Loading @@ -147,17 +152,21 @@ public class SoundDoseHelper { public void onMomentaryExposure(float currentMel, int deviceId) { Log.w(TAG, "DeviceId " + deviceId + " triggered momentary exposure with value: " + currentMel); mLogger.enqueue(SoundDoseEvent.getMomentaryExposureEvent(currentMel)); } public void onNewCsdValue(float currentCsd, SoundDoseRecord[] records) { Log.i(TAG, "onNewCsdValue: " + currentCsd); 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)); } }; Loading Loading @@ -400,6 +409,9 @@ public class SoundDoseHelper { pw.print(" mMusicActiveMs="); pw.println(mMusicActiveMs); pw.print(" mMcc="); pw.println(mMcc); pw.print(" mPendingVolumeCommand="); pw.println(mPendingVolumeCommand); pw.println(); mLogger.dump(pw); pw.println(); } /*package*/void reset() { Loading