diff options
| author | 2022-10-19 16:30:28 +0000 | |
|---|---|---|
| committer | 2022-10-26 15:33:37 +0000 | |
| commit | 650e930950b262f43bb7872f453f6ebc070008a0 (patch) | |
| tree | 73b07540cf35a7491d159120e4f74024eeb0357e | |
| parent | dcf0fd4414214855631f4fbb3ca9d926bcdfe203 (diff) | |
Change log to enqueue inside EventLogger
Also did a few minor things:
1. renamed loglog to enqueueAndLog
2. removed logLogi as there were only a few usages of the method with
such severity
Bug: b/254234346
Test: atest EventLogger
Change-Id: Iec5d34027c999401a735f1eae07f7d31cf217521
13 files changed, 126 insertions, 132 deletions
diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java index c59ee83aa895..bbffc894ef3e 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java +++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java @@ -344,7 +344,7 @@ import java.util.concurrent.atomic.AtomicBoolean; if (AudioService.DEBUG_COMM_RTE) { Log.v(TAG, "setCommunicationRouteForClient: device: " + device); } - AudioService.sDeviceLogger.log((new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue((new EventLogger.StringEvent( "setCommunicationRouteForClient for pid: " + pid + " device: " + device + " from API: " + eventSource)).printLog(TAG)); @@ -1212,7 +1212,7 @@ import java.util.concurrent.atomic.AtomicBoolean; if (useCase == AudioSystem.FOR_MEDIA) { postReportNewRoutes(fromA2dp); } - AudioService.sForceUseLogger.log( + AudioService.sForceUseLogger.enqueue( new AudioServiceEvents.ForceUseEvent(useCase, config, eventSource)); new MediaMetrics.Item(MediaMetrics.Name.AUDIO_FORCE_USE + MediaMetrics.SEPARATOR + AudioSystem.forceUseUsageToString(useCase)) @@ -1230,7 +1230,7 @@ import java.util.concurrent.atomic.AtomicBoolean; } private void onSendBecomingNoisyIntent() { - AudioService.sDeviceLogger.log((new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue((new EventLogger.StringEvent( "broadcast ACTION_AUDIO_BECOMING_NOISY")).printLog(TAG)); mSystemServer.sendDeviceBecomingNoisyIntent(); } @@ -1468,7 +1468,7 @@ import java.util.concurrent.atomic.AtomicBoolean; case MSG_L_BT_ACTIVE_DEVICE_CHANGE_EXT: { final BtDeviceInfo info = (BtDeviceInfo) msg.obj; if (info.mDevice == null) break; - AudioService.sDeviceLogger.log((new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue((new EventLogger.StringEvent( "msg: onBluetoothActiveDeviceChange " + " state=" + info.mState // only querying address as this is the only readily available @@ -1858,7 +1858,7 @@ import java.util.concurrent.atomic.AtomicBoolean; Log.v(TAG, "onUpdateCommunicationRoute, preferredCommunicationDevice: " + preferredCommunicationDevice + " eventSource: " + eventSource); } - AudioService.sDeviceLogger.log((new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue((new EventLogger.StringEvent( "onUpdateCommunicationRoute, preferredCommunicationDevice: " + preferredCommunicationDevice + " eventSource: " + eventSource))); diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java index ce36ff829693..c8f282fd576e 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java +++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java @@ -309,7 +309,7 @@ public class AudioDeviceInventory { address = ""; } - AudioService.sDeviceLogger.log(new EventLogger.StringEvent("BT connected:" + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent("BT connected:" + " addr=" + address + " profile=" + btInfo.mProfile + " state=" + btInfo.mState @@ -412,13 +412,13 @@ public class AudioDeviceInventory { if (!BluetoothAdapter.checkBluetoothAddress(address)) { address = ""; } - AudioService.sDeviceLogger.log(new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( "onBluetoothA2dpDeviceConfigChange addr=" + address + " event=" + BtHelper.a2dpDeviceEventToString(event))); synchronized (mDevicesLock) { if (mDeviceBroker.hasScheduledA2dpConnection(btDevice)) { - AudioService.sDeviceLogger.log(new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( "A2dp config change ignored (scheduled connection change)") .printLog(TAG)); mmi.set(MediaMetrics.Property.EARLY_RETURN, "A2dp config change ignored") @@ -460,7 +460,7 @@ public class AudioDeviceInventory { BtHelper.getName(btDevice), a2dpCodec); if (res != AudioSystem.AUDIO_STATUS_OK) { - AudioService.sDeviceLogger.log(new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( "APM handleDeviceConfigChange failed for A2DP device addr=" + address + " codec=" + AudioSystem.audioFormatToString(a2dpCodec)) .printLog(TAG)); @@ -472,7 +472,7 @@ public class AudioDeviceInventory { BluetoothProfile.A2DP, BluetoothProfile.STATE_DISCONNECTED, musicDevice, AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP)); } else { - AudioService.sDeviceLogger.log(new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( "APM handleDeviceConfigChange success for A2DP device addr=" + address + " codec=" + AudioSystem.audioFormatToString(a2dpCodec)) .printLog(TAG)); @@ -522,7 +522,7 @@ public class AudioDeviceInventory { AudioDeviceInventory.WiredDeviceConnectionState wdcs) { int type = wdcs.mAttributes.getInternalType(); - AudioService.sDeviceLogger.log(new AudioServiceEvents.WiredDevConnectEvent(wdcs)); + AudioService.sDeviceLogger.enqueue(new AudioServiceEvents.WiredDevConnectEvent(wdcs)); MediaMetrics.Item mmi = new MediaMetrics.Item(mMetricsId + "onSetWiredDeviceConnectionState") @@ -619,7 +619,7 @@ public class AudioDeviceInventory { @NonNull List<AudioDeviceAttributes> devices) { final long identity = Binder.clearCallingIdentity(); - AudioService.sDeviceLogger.log((new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue((new EventLogger.StringEvent( "setPreferredDevicesForStrategySync, strategy: " + strategy + " devices: " + devices)).printLog(TAG)); final int status = mAudioSystem.setDevicesRoleForStrategy( @@ -635,7 +635,7 @@ public class AudioDeviceInventory { /*package*/ int removePreferredDevicesForStrategySync(int strategy) { final long identity = Binder.clearCallingIdentity(); - AudioService.sDeviceLogger.log((new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue((new EventLogger.StringEvent( "removePreferredDevicesForStrategySync, strategy: " + strategy)).printLog(TAG)); @@ -1000,13 +1000,13 @@ public class AudioDeviceInventory { // TODO: log in MediaMetrics once distinction between connection failure and // double connection is made. if (res != AudioSystem.AUDIO_STATUS_OK) { - AudioService.sDeviceLogger.log(new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( "APM failed to make available A2DP device addr=" + address + " error=" + res).printLog(TAG)); // TODO: connection failed, stop here // TODO: return; } else { - AudioService.sDeviceLogger.log(new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( "A2DP device addr=" + address + " now available").printLog(TAG)); } @@ -1047,7 +1047,7 @@ public class AudioDeviceInventory { if (!deviceToRemoveKey .equals(mApmConnectedDevices.get(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP))) { // removing A2DP device not currently used by AudioPolicy, log but don't act on it - AudioService.sDeviceLogger.log((new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue((new EventLogger.StringEvent( "A2DP device " + address + " made unavailable, was not used")).printLog(TAG)); mmi.set(MediaMetrics.Property.EARLY_RETURN, "A2DP device made unavailable, was not used") @@ -1062,13 +1062,13 @@ public class AudioDeviceInventory { AudioSystem.DEVICE_STATE_UNAVAILABLE, a2dpCodec); if (res != AudioSystem.AUDIO_STATUS_OK) { - AudioService.sDeviceLogger.log(new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( "APM failed to make unavailable A2DP device addr=" + address + " error=" + res).printLog(TAG)); // TODO: failed to disconnect, stop here // TODO: return; } else { - AudioService.sDeviceLogger.log((new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue((new EventLogger.StringEvent( "A2DP device addr=" + address + " made unavailable")).printLog(TAG)); } mApmConnectedDevices.remove(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP); @@ -1314,7 +1314,7 @@ public class AudioDeviceInventory { && !mDeviceBroker.hasAudioFocusUsers()) { // no media playback, not a "becoming noisy" situation, otherwise it could cause // the pausing of some apps that are playing remotely - AudioService.sDeviceLogger.log((new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue((new EventLogger.StringEvent( "dropping ACTION_AUDIO_BECOMING_NOISY")).printLog(TAG)); mmi.set(MediaMetrics.Property.DELAY_MS, 0).record(); // OK to return return 0; diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index f3a9a699b371..016bab08472a 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -990,7 +990,7 @@ public class AudioService extends IAudioService.Stub public AudioService(Context context, AudioSystemAdapter audioSystem, SystemServerAdapter systemServer, SettingsAdapter settings, @Nullable Looper looper, AppOpsManager appOps) { - sLifecycleLogger.log(new EventLogger.StringEvent("AudioService()")); + sLifecycleLogger.enqueue(new EventLogger.StringEvent("AudioService()")); mContext = context; mContentResolver = context.getContentResolver(); mAppOps = appOps; @@ -1539,14 +1539,14 @@ public class AudioService extends IAudioService.Stub if (!mSystemReady || (AudioSystem.checkAudioFlinger() != AudioSystem.AUDIO_STATUS_OK)) { Log.e(TAG, "Audioserver died."); - sLifecycleLogger.log(new EventLogger.StringEvent( + sLifecycleLogger.enqueue(new EventLogger.StringEvent( "onAudioServerDied() audioserver died")); sendMsg(mAudioHandler, MSG_AUDIO_SERVER_DIED, SENDMSG_NOOP, 0, 0, null, 500); return; } Log.i(TAG, "Audioserver started."); - sLifecycleLogger.log(new EventLogger.StringEvent( + sLifecycleLogger.enqueue(new EventLogger.StringEvent( "onAudioServerDied() audioserver started")); updateAudioHalPids(); @@ -1776,7 +1776,7 @@ public class AudioService extends IAudioService.Stub // did it work? check based on status if (status != AudioSystem.AUDIO_STATUS_OK) { - sLifecycleLogger.log(new EventLogger.StringEvent( + sLifecycleLogger.enqueue(new EventLogger.StringEvent( caller + ": initStreamVolume failed with " + status + " will retry") .printLog(ALOGE, TAG)); sendMsg(mAudioHandler, MSG_REINIT_VOLUMES, SENDMSG_NOOP, 0, 0, @@ -1790,7 +1790,7 @@ public class AudioService extends IAudioService.Stub } // success - sLifecycleLogger.log(new EventLogger.StringEvent( + sLifecycleLogger.enqueue(new EventLogger.StringEvent( caller + ": initStreamVolume succeeded").printLog(ALOGI, TAG)); } @@ -1813,7 +1813,7 @@ public class AudioService extends IAudioService.Stub } } if (!success) { - sLifecycleLogger.log(new EventLogger.StringEvent( + sLifecycleLogger.enqueue(new EventLogger.StringEvent( caller + ": initStreamVolume succeeded but invalid mix/max levels, will retry") .printLog(ALOGW, TAG)); sendMsg(mAudioHandler, MSG_REINIT_VOLUMES, SENDMSG_NOOP, 0, 0, @@ -2764,7 +2764,7 @@ public class AudioService extends IAudioService.Stub "setPreferredDeviceForStrategy u/pid:%d/%d strat:%d dev:%s", Binder.getCallingUid(), Binder.getCallingPid(), strategy, devices.stream().map(e -> e.toString()).collect(Collectors.joining(","))); - sDeviceLogger.log(new EventLogger.StringEvent(logString).printLog(TAG)); + sDeviceLogger.enqueue(new EventLogger.StringEvent(logString).printLog(TAG)); if (devices.stream().anyMatch(device -> device.getRole() == AudioDeviceAttributes.ROLE_INPUT)) { Log.e(TAG, "Unsupported input routing in " + logString); @@ -2784,7 +2784,7 @@ public class AudioService extends IAudioService.Stub public int removePreferredDevicesForStrategy(int strategy) { final String logString = String.format("removePreferredDeviceForStrategy strat:%d", strategy); - sDeviceLogger.log(new EventLogger.StringEvent(logString).printLog(TAG)); + sDeviceLogger.enqueue(new EventLogger.StringEvent(logString).printLog(TAG)); final int status = mDeviceBroker.removePreferredDevicesForStrategySync(strategy); if (status != AudioSystem.SUCCESS) { @@ -2850,7 +2850,7 @@ public class AudioService extends IAudioService.Stub "setPreferredDevicesForCapturePreset u/pid:%d/%d source:%d dev:%s", Binder.getCallingUid(), Binder.getCallingPid(), capturePreset, devices.stream().map(e -> e.toString()).collect(Collectors.joining(","))); - sDeviceLogger.log(new EventLogger.StringEvent(logString).printLog(TAG)); + sDeviceLogger.enqueue(new EventLogger.StringEvent(logString).printLog(TAG)); if (devices.stream().anyMatch(device -> device.getRole() == AudioDeviceAttributes.ROLE_OUTPUT)) { Log.e(TAG, "Unsupported output routing in " + logString); @@ -2871,7 +2871,7 @@ public class AudioService extends IAudioService.Stub public int clearPreferredDevicesForCapturePreset(int capturePreset) { final String logString = String.format( "removePreferredDeviceForCapturePreset source:%d", capturePreset); - sDeviceLogger.log(new EventLogger.StringEvent(logString).printLog(TAG)); + sDeviceLogger.enqueue(new EventLogger.StringEvent(logString).printLog(TAG)); final int status = mDeviceBroker.clearPreferredDevicesForCapturePresetSync(capturePreset); if (status != AudioSystem.SUCCESS) { @@ -3043,9 +3043,10 @@ public class AudioService extends IAudioService.Stub + ", volControlStream=" + mVolumeControlStream + ", userSelect=" + mUserSelectedVolumeControlStream); if (direction != AudioManager.ADJUST_SAME) { - sVolumeLogger.log(new VolumeEvent(VolumeEvent.VOL_ADJUST_SUGG_VOL, suggestedStreamType, - direction/*val1*/, flags/*val2*/, new StringBuilder(callingPackage) - .append("/").append(caller).append(" uid:").append(uid).toString())); + sVolumeLogger.enqueue( + new VolumeEvent(VolumeEvent.VOL_ADJUST_SUGG_VOL, suggestedStreamType, + direction/*val1*/, flags/*val2*/, new StringBuilder(callingPackage) + .append("/").append(caller).append(" uid:").append(uid).toString())); } boolean hasExternalVolumeController = notifyExternalVolumeController(direction); @@ -3144,7 +3145,7 @@ public class AudioService extends IAudioService.Stub return; } - sVolumeLogger.log(new VolumeEvent(VolumeEvent.VOL_ADJUST_STREAM_VOL, streamType, + sVolumeLogger.enqueue(new VolumeEvent(VolumeEvent.VOL_ADJUST_STREAM_VOL, streamType, direction/*val1*/, flags/*val2*/, callingPackage)); adjustStreamVolume(streamType, direction, flags, callingPackage, callingPackage, Binder.getCallingUid(), Binder.getCallingPid(), attributionTag, @@ -3625,7 +3626,7 @@ public class AudioService extends IAudioService.Stub } final VolumeGroupState vgs = sVolumeGroupStates.get(volumeGroup); - sVolumeLogger.log(new VolumeEvent(VolumeEvent.VOL_SET_GROUP_VOL, attr, vgs.name(), + sVolumeLogger.enqueue(new VolumeEvent(VolumeEvent.VOL_SET_GROUP_VOL, attr, vgs.name(), index/*val1*/, flags/*val2*/, callingPackage)); vgs.setVolumeIndex(index, flags); @@ -3776,7 +3777,7 @@ public class AudioService extends IAudioService.Stub ? new VolumeEvent(VolumeEvent.VOL_SET_STREAM_VOL, streamType, index/*val1*/, flags/*val2*/, callingPackage) : new DeviceVolumeEvent(streamType, index, device, callingPackage); - sVolumeLogger.log(event); + sVolumeLogger.enqueue(event); setStreamVolume(streamType, index, flags, device, callingPackage, callingPackage, attributionTag, Binder.getCallingUid(), callingOrSelfHasAudioSettingsPermission()); @@ -3977,7 +3978,7 @@ public class AudioService extends IAudioService.Stub private void updateHearingAidVolumeOnVoiceActivityUpdate() { final int streamType = getBluetoothContextualVolumeStream(); final int index = getStreamVolume(streamType); - sVolumeLogger.log(new VolumeEvent(VolumeEvent.VOL_VOICE_ACTIVITY_HEARING_AID, + sVolumeLogger.enqueue(new VolumeEvent(VolumeEvent.VOL_VOICE_ACTIVITY_HEARING_AID, mVoicePlaybackActive.get(), streamType, index)); mDeviceBroker.postSetHearingAidVolumeIndex(index * 10, streamType); @@ -4018,7 +4019,7 @@ public class AudioService extends IAudioService.Stub if (AudioSystem.isSingleAudioDeviceType( absVolumeMultiModeCaseDevices, AudioSystem.DEVICE_OUT_HEARING_AID)) { final int index = getStreamVolume(streamType); - sVolumeLogger.log(new VolumeEvent(VolumeEvent.VOL_MODE_CHANGE_HEARING_AID, + sVolumeLogger.enqueue(new VolumeEvent(VolumeEvent.VOL_MODE_CHANGE_HEARING_AID, newMode, streamType, index)); mDeviceBroker.postSetHearingAidVolumeIndex(index * 10, streamType); } @@ -5419,7 +5420,7 @@ public class AudioService extends IAudioService.Stub /*obj*/ null, /*delay*/ 0); int previousMode = mMode.getAndSet(mode); // Note: newModeOwnerPid is always 0 when actualMode is MODE_NORMAL - mModeLogger.log(new PhoneStateEvent(requesterPackage, requesterPid, + mModeLogger.enqueue(new PhoneStateEvent(requesterPackage, requesterPid, requestedMode, pid, mode)); int streamType = getActiveStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE); @@ -5562,7 +5563,7 @@ public class AudioService extends IAudioService.Stub } if (direction != AudioManager.ADJUST_SAME) { - sVolumeLogger.log(new VolumeEvent(VolumeEvent.VOL_ADJUST_VOL_UID, streamType, + sVolumeLogger.enqueue(new VolumeEvent(VolumeEvent.VOL_ADJUST_VOL_UID, streamType, direction/*val1*/, flags/*val2*/, new StringBuilder(packageName).append(" uid:").append(uid) .toString())); @@ -6892,7 +6893,7 @@ public class AudioService extends IAudioService.Stub // verify arguments Objects.requireNonNull(device); AudioManager.enforceValidVolumeBehavior(deviceVolumeBehavior); - sVolumeLogger.log(new EventLogger.StringEvent("setDeviceVolumeBehavior: dev:" + sVolumeLogger.enqueue(new EventLogger.StringEvent("setDeviceVolumeBehavior: dev:" + AudioSystem.getOutputDeviceName(device.getInternalType()) + " addr:" + device.getAddress() + " behavior:" + AudioDeviceVolumeManager.volumeBehaviorName(deviceVolumeBehavior) @@ -6948,7 +6949,7 @@ public class AudioService extends IAudioService.Stub } // log event and caller - sDeviceLogger.log(new EventLogger.StringEvent( + sDeviceLogger.enqueue(new EventLogger.StringEvent( "Volume behavior " + deviceVolumeBehavior + " for dev=0x" + Integer.toHexString(audioSystemDeviceOut) + " from:" + caller)); // make sure we have a volume entry for this device, and that volume is updated according @@ -7594,7 +7595,7 @@ public class AudioService extends IAudioService.Stub final int status = AudioSystem.initStreamVolume( streamType, mIndexMin / 10, mIndexMax / 10); if (status != AudioSystem.AUDIO_STATUS_OK) { - sLifecycleLogger.log(new EventLogger.StringEvent( + sLifecycleLogger.enqueue(new EventLogger.StringEvent( "VSS() stream:" + streamType + " initStreamVolume=" + status) .printLog(ALOGE, TAG)); sendMsg(mAudioHandler, MSG_REINIT_VOLUMES, SENDMSG_NOOP, 0, 0, @@ -8013,7 +8014,7 @@ public class AudioService extends IAudioService.Stub } } if (changed) { - sVolumeLogger.log(new VolumeEvent( + sVolumeLogger.enqueue(new VolumeEvent( VolumeEvent.VOL_MUTE_STREAM_INT, mStreamType, state)); } return changed; @@ -8183,10 +8184,10 @@ public class AudioService extends IAudioService.Stub streamState.setIndex(index, update.mDevice, update.mCaller, // trusted as index is always validated before message is posted true /*hasModifyAudioSettings*/); - sVolumeLogger.log(new EventLogger.StringEvent(update.mCaller + " dev:0x" + sVolumeLogger.enqueue(new EventLogger.StringEvent(update.mCaller + " dev:0x" + Integer.toHexString(update.mDevice) + " volIdx:" + index)); } else { - sVolumeLogger.log(new EventLogger.StringEvent(update.mCaller + sVolumeLogger.enqueue(new EventLogger.StringEvent(update.mCaller + " update vol on dev:0x" + Integer.toHexString(update.mDevice))); } setDeviceVolume(streamState, update.mDevice); @@ -8364,7 +8365,7 @@ public class AudioService extends IAudioService.Stub .set(MediaMetrics.Property.FORCE_USE_MODE, AudioSystem.forceUseConfigToString(config)) .record(); - sForceUseLogger.log( + sForceUseLogger.enqueue( new AudioServiceEvents.ForceUseEvent(useCase, config, eventSource)); mAudioSystem.setForceUse(useCase, config); } @@ -8633,7 +8634,7 @@ public class AudioService extends IAudioService.Stub private void avrcpSupportsAbsoluteVolume(String address, boolean support) { // address is not used for now, but may be used when multiple a2dp devices are supported - sVolumeLogger.log(new EventLogger.StringEvent("avrcpSupportsAbsoluteVolume addr=" + sVolumeLogger.enqueue(new EventLogger.StringEvent("avrcpSupportsAbsoluteVolume addr=" + address + " support=" + support).printLog(TAG)); mDeviceBroker.setAvrcpAbsoluteVolumeSupported(support); setAvrcpAbsoluteVolumeSupported(support); @@ -10668,7 +10669,7 @@ public class AudioService extends IAudioService.Stub pcb.asBinder().linkToDeath(app, 0/*flags*/); // logging after registration so we have the registration id - mDynPolicyLogger.log((new EventLogger.StringEvent("registerAudioPolicy for " + mDynPolicyLogger.enqueue((new EventLogger.StringEvent("registerAudioPolicy for " + pcb.asBinder() + " u/pid:" + Binder.getCallingUid() + "/" + Binder.getCallingPid() + " with config:" + app.toCompactLogString())) .printLog(TAG)); @@ -10866,7 +10867,7 @@ public class AudioService extends IAudioService.Stub private void unregisterAudioPolicyInt(@NonNull IAudioPolicyCallback pcb, String operationName) { - mDynPolicyLogger.log((new EventLogger.StringEvent(operationName + " for " + mDynPolicyLogger.enqueue((new EventLogger.StringEvent(operationName + " for " + pcb.asBinder()).printLog(TAG))); synchronized (mAudioPolicies) { AudioPolicyProxy app = mAudioPolicies.remove(pcb.asBinder()); @@ -11394,7 +11395,7 @@ public class AudioService extends IAudioService.Stub } public void binderDied() { - mDynPolicyLogger.log((new EventLogger.StringEvent("AudioPolicy " + mDynPolicyLogger.enqueue((new EventLogger.StringEvent("AudioPolicy " + mPolicyCallback.asBinder() + " died").printLog(TAG))); release(); } diff --git a/services/core/java/com/android/server/audio/BtHelper.java b/services/core/java/com/android/server/audio/BtHelper.java index 399829e32588..df65dbd53e06 100644 --- a/services/core/java/com/android/server/audio/BtHelper.java +++ b/services/core/java/com/android/server/audio/BtHelper.java @@ -263,20 +263,20 @@ public class BtHelper { /*package*/ synchronized void setAvrcpAbsoluteVolumeIndex(int index) { if (mA2dp == null) { if (AudioService.DEBUG_VOL) { - AudioService.sVolumeLogger.log(new EventLogger.StringEvent( + AudioService.sVolumeLogger.enqueue(new EventLogger.StringEvent( "setAvrcpAbsoluteVolumeIndex: bailing due to null mA2dp").printLog(TAG)); return; } } if (!mAvrcpAbsVolSupported) { - AudioService.sVolumeLogger.log(new EventLogger.StringEvent( + AudioService.sVolumeLogger.enqueue(new EventLogger.StringEvent( "setAvrcpAbsoluteVolumeIndex: abs vol not supported ").printLog(TAG)); return; } if (AudioService.DEBUG_VOL) { Log.i(TAG, "setAvrcpAbsoluteVolumeIndex index=" + index); } - AudioService.sVolumeLogger.log(new AudioServiceEvents.VolumeEvent( + AudioService.sVolumeLogger.enqueue(new AudioServiceEvents.VolumeEvent( AudioServiceEvents.VolumeEvent.VOL_SET_AVRCP_VOL, index)); mA2dp.setAvrcpAbsoluteVolume(index); } @@ -393,14 +393,14 @@ public class BtHelper { @GuardedBy("AudioDeviceBroker.mDeviceStateLock") /*package*/ synchronized boolean startBluetoothSco(int scoAudioMode, @NonNull String eventSource) { - AudioService.sDeviceLogger.log(new EventLogger.StringEvent(eventSource)); + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent(eventSource)); return requestScoState(BluetoothHeadset.STATE_AUDIO_CONNECTED, scoAudioMode); } // @GuardedBy("AudioDeviceBroker.mSetModeLock") @GuardedBy("AudioDeviceBroker.mDeviceStateLock") /*package*/ synchronized boolean stopBluetoothSco(@NonNull String eventSource) { - AudioService.sDeviceLogger.log(new EventLogger.StringEvent(eventSource)); + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent(eventSource)); return requestScoState(BluetoothHeadset.STATE_AUDIO_DISCONNECTED, SCO_MODE_VIRTUAL_CALL); } @@ -418,7 +418,7 @@ public class BtHelper { Log.i(TAG, "setLeAudioVolume: calling mLeAudio.setVolume idx=" + index + " volume=" + volume); } - AudioService.sVolumeLogger.log(new AudioServiceEvents.VolumeEvent( + AudioService.sVolumeLogger.enqueue(new AudioServiceEvents.VolumeEvent( AudioServiceEvents.VolumeEvent.VOL_SET_LE_AUDIO_VOL, index, maxIndex)); mLeAudio.setVolume(volume); } @@ -443,7 +443,7 @@ public class BtHelper { } // do not log when hearing aid is not connected to avoid confusion when reading dumpsys if (isHeadAidConnected) { - AudioService.sVolumeLogger.log(new AudioServiceEvents.VolumeEvent( + AudioService.sVolumeLogger.enqueue(new AudioServiceEvents.VolumeEvent( AudioServiceEvents.VolumeEvent.VOL_SET_HEARING_AID_VOL, index, gainDB)); } mHearingAid.setVolume(gainDB); @@ -675,7 +675,7 @@ public class BtHelper { case BluetoothProfile.HEADSET: case BluetoothProfile.HEARING_AID: case BluetoothProfile.LE_AUDIO: - AudioService.sDeviceLogger.log(new EventLogger.StringEvent( + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( "BT profile service: connecting " + BluetoothProfile.getProfileName(profile) + " profile")); mDeviceBroker.postBtProfileConnected(profile, proxy); diff --git a/services/core/java/com/android/server/audio/FadeOutManager.java b/services/core/java/com/android/server/audio/FadeOutManager.java index e54ee869fef2..5f6f4b125710 100644 --- a/services/core/java/com/android/server/audio/FadeOutManager.java +++ b/services/core/java/com/android/server/audio/FadeOutManager.java @@ -245,7 +245,7 @@ public final class FadeOutManager { return; } try { - PlaybackActivityMonitor.sEventLogger.log( + PlaybackActivityMonitor.sEventLogger.enqueue( (new PlaybackActivityMonitor.FadeOutEvent(apc, skipRamp)).printLog(TAG)); apc.getPlayerProxy().applyVolumeShaper( FADEOUT_VSHAPE, @@ -262,7 +262,7 @@ public final class FadeOutManager { final AudioPlaybackConfiguration apc = players.get(piid); if (apc != null) { try { - PlaybackActivityMonitor.sEventLogger.log( + PlaybackActivityMonitor.sEventLogger.enqueue( (new EventLogger.StringEvent("unfading out piid:" + piid)).printLog(TAG)); apc.getPlayerProxy().applyVolumeShaper( diff --git a/services/core/java/com/android/server/audio/MediaFocusControl.java b/services/core/java/com/android/server/audio/MediaFocusControl.java index 1ca27dd7112c..27687b2612e5 100644 --- a/services/core/java/com/android/server/audio/MediaFocusControl.java +++ b/services/core/java/com/android/server/audio/MediaFocusControl.java @@ -185,7 +185,7 @@ public class MediaFocusControl implements PlayerFocusEnforcer { final FocusRequester focusOwner = stackIterator.next(); if (focusOwner.hasSameUid(uid) && focusOwner.hasSamePackage(packageName)) { clientsToRemove.add(focusOwner.getClientId()); - mEventLogger.log((new EventLogger.StringEvent( + mEventLogger.enqueue((new EventLogger.StringEvent( "focus owner:" + focusOwner.getClientId() + " in uid:" + uid + " pack: " + packageName + " getting AUDIOFOCUS_LOSS due to app suspension")) @@ -433,7 +433,7 @@ public class MediaFocusControl implements PlayerFocusEnforcer { FocusRequester fr = stackIterator.next(); if(fr.hasSameBinder(cb)) { Log.i(TAG, "AudioFocus removeFocusStackEntryOnDeath(): removing entry for " + cb); - mEventLogger.log(new EventLogger.StringEvent( + mEventLogger.enqueue(new EventLogger.StringEvent( "focus requester:" + fr.getClientId() + " in uid:" + fr.getClientUid() + " pack:" + fr.getPackageName() @@ -470,7 +470,7 @@ public class MediaFocusControl implements PlayerFocusEnforcer { final FocusRequester fr = owner.getValue(); if (fr.hasSameBinder(cb)) { ownerIterator.remove(); - mEventLogger.log(new EventLogger.StringEvent( + mEventLogger.enqueue(new EventLogger.StringEvent( "focus requester:" + fr.getClientId() + " in uid:" + fr.getClientUid() + " pack:" + fr.getPackageName() @@ -968,7 +968,7 @@ public class MediaFocusControl implements PlayerFocusEnforcer { // supposed to be alone in bitfield final int uid = (flags == AudioManager.AUDIOFOCUS_FLAG_TEST) ? testUid : Binder.getCallingUid(); - mEventLogger.log((new EventLogger.StringEvent( + mEventLogger.enqueue((new EventLogger.StringEvent( "requestAudioFocus() from uid/pid " + uid + "/" + Binder.getCallingPid() + " AA=" + aa.usageToString() + "/" + aa.contentTypeToString() @@ -1143,7 +1143,7 @@ public class MediaFocusControl implements PlayerFocusEnforcer { .record(); // AudioAttributes are currently ignored, to be used for zones / a11y - mEventLogger.log((new EventLogger.StringEvent( + mEventLogger.enqueue((new EventLogger.StringEvent( "abandonAudioFocus() from uid/pid " + Binder.getCallingUid() + "/" + Binder.getCallingPid() + " clientId=" + clientId)) diff --git a/services/core/java/com/android/server/audio/PlaybackActivityMonitor.java b/services/core/java/com/android/server/audio/PlaybackActivityMonitor.java index 1af8c593f96b..74bfa80e4704 100644 --- a/services/core/java/com/android/server/audio/PlaybackActivityMonitor.java +++ b/services/core/java/com/android/server/audio/PlaybackActivityMonitor.java @@ -157,7 +157,7 @@ public final class PlaybackActivityMonitor if (index >= 0) { if (!disable) { if (DEBUG) { // hidden behind DEBUG, too noisy otherwise - sEventLogger.log(new EventLogger.StringEvent("unbanning uid:" + uid)); + sEventLogger.enqueue(new EventLogger.StringEvent("unbanning uid:" + uid)); } mBannedUids.remove(index); // nothing else to do, future playback requests from this uid are ok @@ -168,7 +168,7 @@ public final class PlaybackActivityMonitor checkBanPlayer(apc, uid); } if (DEBUG) { // hidden behind DEBUG, too noisy otherwise - sEventLogger.log(new EventLogger.StringEvent("banning uid:" + uid)); + sEventLogger.enqueue(new EventLogger.StringEvent("banning uid:" + uid)); } mBannedUids.add(new Integer(uid)); } // no else to handle, uid already not in list, so enabling again is no-op @@ -209,7 +209,7 @@ public final class PlaybackActivityMonitor updateAllowedCapturePolicy(apc, mAllowedCapturePolicies.get(uid)); } } - sEventLogger.log(new NewPlayerEvent(apc)); + sEventLogger.enqueue(new NewPlayerEvent(apc)); synchronized(mPlayerLock) { mPlayers.put(newPiid, apc); maybeMutePlayerAwaitingConnection(apc); @@ -229,7 +229,7 @@ public final class PlaybackActivityMonitor synchronized(mPlayerLock) { final AudioPlaybackConfiguration apc = mPlayers.get(new Integer(piid)); if (checkConfigurationCaller(piid, apc, binderUid)) { - sEventLogger.log(new AudioAttrEvent(piid, attr)); + sEventLogger.enqueue(new AudioAttrEvent(piid, attr)); change = apc.handleAudioAttributesEvent(attr); } else { Log.e(TAG, "Error updating audio attributes"); @@ -322,7 +322,7 @@ public final class PlaybackActivityMonitor return; } - sEventLogger.log(new PlayerEvent(piid, event, eventValue)); + sEventLogger.enqueue(new PlayerEvent(piid, event, eventValue)); if (event == AudioPlaybackConfiguration.PLAYER_UPDATE_PORT_ID) { mEventHandler.sendMessage( @@ -332,7 +332,7 @@ public final class PlaybackActivityMonitor for (Integer uidInteger: mBannedUids) { if (checkBanPlayer(apc, uidInteger.intValue())) { // player was banned, do not update its state - sEventLogger.log(new EventLogger.StringEvent( + sEventLogger.enqueue(new EventLogger.StringEvent( "not starting piid:" + piid + " ,is banned")); return; } @@ -412,7 +412,7 @@ public final class PlaybackActivityMonitor public void playerHasOpPlayAudio(int piid, boolean hasOpPlayAudio, int binderUid) { // no check on UID yet because this is only for logging at the moment - sEventLogger.log(new PlayerOpPlayAudioEvent(piid, hasOpPlayAudio, binderUid)); + sEventLogger.enqueue(new PlayerOpPlayAudioEvent(piid, hasOpPlayAudio, binderUid)); } public void releasePlayer(int piid, int binderUid) { @@ -421,7 +421,7 @@ public final class PlaybackActivityMonitor synchronized(mPlayerLock) { final AudioPlaybackConfiguration apc = mPlayers.get(new Integer(piid)); if (checkConfigurationCaller(piid, apc, binderUid)) { - sEventLogger.log(new EventLogger.StringEvent( + sEventLogger.enqueue(new EventLogger.StringEvent( "releasing player piid:" + piid)); mPlayers.remove(new Integer(piid)); mDuckingManager.removeReleased(apc); @@ -443,7 +443,7 @@ public final class PlaybackActivityMonitor } /*package*/ void onAudioServerDied() { - sEventLogger.log( + sEventLogger.enqueue( new EventLogger.StringEvent( "clear port id to piid map")); synchronized (mPlayerLock) { @@ -768,7 +768,7 @@ public final class PlaybackActivityMonitor } if (mute) { try { - sEventLogger.log((new EventLogger.StringEvent("call: muting piid:" + sEventLogger.enqueue((new EventLogger.StringEvent("call: muting piid:" + piid + " uid:" + apc.getClientUid())).printLog(TAG)); apc.getPlayerProxy().setVolume(0.0f); mMutedPlayers.add(new Integer(piid)); @@ -793,7 +793,7 @@ public final class PlaybackActivityMonitor final AudioPlaybackConfiguration apc = mPlayers.get(piid); if (apc != null) { try { - sEventLogger.log(new EventLogger.StringEvent("call: unmuting piid:" + sEventLogger.enqueue(new EventLogger.StringEvent("call: unmuting piid:" + piid).printLog(TAG)); apc.getPlayerProxy().setVolume(1.0f); } catch (Exception e) { @@ -1081,7 +1081,7 @@ public final class PlaybackActivityMonitor return; } try { - sEventLogger.log((new DuckEvent(apc, skipRamp)).printLog(TAG)); + sEventLogger.enqueue((new DuckEvent(apc, skipRamp)).printLog(TAG)); apc.getPlayerProxy().applyVolumeShaper( DUCK_VSHAPE, skipRamp ? PLAY_SKIP_RAMP : PLAY_CREATE_IF_NEEDED); @@ -1096,7 +1096,7 @@ public final class PlaybackActivityMonitor final AudioPlaybackConfiguration apc = players.get(piid); if (apc != null) { try { - sEventLogger.log((new EventLogger.StringEvent("unducking piid:" + sEventLogger.enqueue((new EventLogger.StringEvent("unducking piid:" + piid)).printLog(TAG)); apc.getPlayerProxy().applyVolumeShaper( DUCK_ID, @@ -1310,8 +1310,9 @@ public final class PlaybackActivityMonitor //========================================================================================== void muteAwaitConnection(@NonNull int[] usagesToMute, @NonNull AudioDeviceAttributes dev, long timeOutMs) { - sEventLogger.loglogi( - "muteAwaitConnection() dev:" + dev + " timeOutMs:" + timeOutMs, TAG); + sEventLogger.enqueueAndLog( + "muteAwaitConnection() dev:" + dev + " timeOutMs:" + timeOutMs, + EventLogger.Event.ALOGI, TAG); synchronized (mPlayerLock) { mutePlayersExpectingDevice(usagesToMute); // schedule timeout (remove previously scheduled first) @@ -1323,7 +1324,8 @@ public final class PlaybackActivityMonitor } void cancelMuteAwaitConnection(String source) { - sEventLogger.loglogi("cancelMuteAwaitConnection() from:" + source, TAG); + sEventLogger.enqueueAndLog("cancelMuteAwaitConnection() from:" + source, + EventLogger.Event.ALOGI, TAG); synchronized (mPlayerLock) { // cancel scheduled timeout, ignore device, only one expected device at a time mEventHandler.removeMessages(MSG_L_TIMEOUT_MUTE_AWAIT_CONNECTION); @@ -1346,7 +1348,7 @@ public final class PlaybackActivityMonitor @GuardedBy("mPlayerLock") private void mutePlayersExpectingDevice(@NonNull int[] usagesToMute) { - sEventLogger.log(new MuteAwaitConnectionEvent(usagesToMute)); + sEventLogger.enqueue(new MuteAwaitConnectionEvent(usagesToMute)); mMutedUsagesAwaitingConnection = usagesToMute; final Set<Integer> piidSet = mPlayers.keySet(); final Iterator<Integer> piidIterator = piidSet.iterator(); @@ -1369,7 +1371,7 @@ public final class PlaybackActivityMonitor for (int usage : mMutedUsagesAwaitingConnection) { if (usage == apc.getAudioAttributes().getUsage()) { try { - sEventLogger.log((new EventLogger.StringEvent( + sEventLogger.enqueue((new EventLogger.StringEvent( "awaiting connection: muting piid:" + apc.getPlayerInterfaceId() + " uid:" + apc.getClientUid())).printLog(TAG)); @@ -1394,7 +1396,7 @@ public final class PlaybackActivityMonitor continue; } try { - sEventLogger.log(new EventLogger.StringEvent( + sEventLogger.enqueue(new EventLogger.StringEvent( "unmuting piid:" + piid).printLog(TAG)); apc.getPlayerProxy().applyVolumeShaper(MUTE_AWAIT_CONNECTION_VSHAPE, VolumeShaper.Operation.REVERSE); @@ -1452,8 +1454,9 @@ public final class PlaybackActivityMonitor public void handleMessage(Message msg) { switch (msg.what) { case MSG_L_TIMEOUT_MUTE_AWAIT_CONNECTION: - sEventLogger.loglogi("Timeout for muting waiting for " - + (AudioDeviceAttributes) msg.obj + ", unmuting", TAG); + sEventLogger.enqueueAndLog("Timeout for muting waiting for " + + (AudioDeviceAttributes) msg.obj + ", unmuting", + EventLogger.Event.ALOGI, TAG); synchronized (mPlayerLock) { unmutePlayersExpectingDevice(); } @@ -1476,7 +1479,7 @@ public final class PlaybackActivityMonitor synchronized (mPlayerLock) { int piid = msg.arg1; - sEventLogger.log( + sEventLogger.enqueue( new PlayerEvent(piid, PLAYER_UPDATE_MUTED, eventValue)); final AudioPlaybackConfiguration apc = mPlayers.get(piid); diff --git a/services/core/java/com/android/server/audio/RecordingActivityMonitor.java b/services/core/java/com/android/server/audio/RecordingActivityMonitor.java index 2ba8882ae14f..652ea5228571 100644 --- a/services/core/java/com/android/server/audio/RecordingActivityMonitor.java +++ b/services/core/java/com/android/server/audio/RecordingActivityMonitor.java @@ -164,7 +164,7 @@ public final class RecordingActivityMonitor implements AudioSystem.AudioRecordin } if (MediaRecorder.isSystemOnlyAudioSource(source)) { // still want to log event, it just won't appear in recording configurations; - sEventLogger.log(new RecordingEvent(event, riid, config).printLog(TAG)); + sEventLogger.enqueue(new RecordingEvent(event, riid, config).printLog(TAG)); return; } dispatchCallbacks(updateSnapshot(event, riid, config)); @@ -204,7 +204,7 @@ public final class RecordingActivityMonitor implements AudioSystem.AudioRecordin ? AudioManager.RECORD_CONFIG_EVENT_STOP : AudioManager.RECORD_CONFIG_EVENT_NONE; if (riid == AudioManager.RECORD_RIID_INVALID || configEvent == AudioManager.RECORD_CONFIG_EVENT_NONE) { - sEventLogger.log(new RecordingEvent(event, riid, null).printLog(TAG)); + sEventLogger.enqueue(new RecordingEvent(event, riid, null).printLog(TAG)); return; } dispatchCallbacks(updateSnapshot(configEvent, riid, null)); @@ -301,7 +301,7 @@ public final class RecordingActivityMonitor implements AudioSystem.AudioRecordin if (!state.hasDeathHandler()) { if (state.isActiveConfiguration()) { configChanged = true; - sEventLogger.log(new RecordingEvent( + sEventLogger.enqueue(new RecordingEvent( AudioManager.RECORD_CONFIG_EVENT_RELEASE, state.getRiid(), state.getConfig())); } @@ -486,7 +486,7 @@ public final class RecordingActivityMonitor implements AudioSystem.AudioRecordin configChanged = false; } if (configChanged) { - sEventLogger.log(new RecordingEvent(event, riid, state.getConfig())); + sEventLogger.enqueue(new RecordingEvent(event, riid, state.getConfig())); configs = getActiveRecordingConfigurations(true /*isPrivileged*/); } } diff --git a/services/core/java/com/android/server/audio/SoundEffectsHelper.java b/services/core/java/com/android/server/audio/SoundEffectsHelper.java index 93eba50ac6dd..79b54ebfeb3c 100644 --- a/services/core/java/com/android/server/audio/SoundEffectsHelper.java +++ b/services/core/java/com/android/server/audio/SoundEffectsHelper.java @@ -164,7 +164,7 @@ class SoundEffectsHelper { } private void logEvent(String msg) { - mSfxLogger.log(new EventLogger.StringEvent(msg)); + mSfxLogger.enqueue(new EventLogger.StringEvent(msg)); } // All the methods below run on the worker thread diff --git a/services/core/java/com/android/server/audio/SpatializerHelper.java b/services/core/java/com/android/server/audio/SpatializerHelper.java index 1563d33d93f0..2b525f1fcf50 100644 --- a/services/core/java/com/android/server/audio/SpatializerHelper.java +++ b/services/core/java/com/android/server/audio/SpatializerHelper.java @@ -1708,11 +1708,11 @@ public class SpatializerHelper { private static void loglogi(String msg) { - AudioService.sSpatialLogger.loglogi(msg, TAG); + AudioService.sSpatialLogger.enqueueAndLog(msg, EventLogger.Event.ALOGI, TAG); } private static String logloge(String msg) { - AudioService.sSpatialLogger.loglog(msg, EventLogger.Event.ALOGE, TAG); + AudioService.sSpatialLogger.enqueueAndLog(msg, EventLogger.Event.ALOGE, TAG); return msg; } diff --git a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java index f653b9381721..439e9bd2624e 100644 --- a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java +++ b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java @@ -132,7 +132,7 @@ class MediaRouter2ServiceImpl { } } - mEventLogger.log(new EventLogger.StringEvent("mScreenOnOffReceiver", null)); + mEventLogger.enqueue(new EventLogger.StringEvent("mScreenOnOffReceiver", null)); } }; @@ -634,7 +634,7 @@ class MediaRouter2ServiceImpl { /* package */ void updateRunningUserAndProfiles(int newActiveUserId) { synchronized (mLock) { if (mCurrentActiveUserId != newActiveUserId) { - mEventLogger.log( + mEventLogger.enqueue( EventLogger.StringEvent.from("switchUser", "userId: %d", newActiveUserId)); @@ -705,7 +705,7 @@ class MediaRouter2ServiceImpl { obtainMessage(UserHandler::notifyRouterRegistered, userRecord.mHandler, routerRecord)); - mEventLogger.log(EventLogger.StringEvent.from("registerRouter2", + mEventLogger.enqueue(EventLogger.StringEvent.from("registerRouter2", "package: %s, uid: %d, pid: %d, router id: %d", packageName, uid, pid, routerRecord.mRouterId)); } @@ -718,7 +718,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log( + mEventLogger.enqueue( EventLogger.StringEvent.from( "unregisterRouter2", "package: %s, router id: %d", @@ -744,7 +744,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log(EventLogger.StringEvent.from( + mEventLogger.enqueue(EventLogger.StringEvent.from( "setDiscoveryRequestWithRouter2", "router id: %d, discovery request: %s", routerRecord.mRouterId, discoveryRequest.toString())); @@ -766,7 +766,7 @@ class MediaRouter2ServiceImpl { RouterRecord routerRecord = mAllRouterRecords.get(binder); if (routerRecord != null) { - mEventLogger.log(EventLogger.StringEvent.from( + mEventLogger.enqueue(EventLogger.StringEvent.from( "setRouteVolumeWithRouter2", "router id: %d, volume: %d", routerRecord.mRouterId, volume)); @@ -851,7 +851,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log(EventLogger.StringEvent.from( + mEventLogger.enqueue(EventLogger.StringEvent.from( "selectRouteWithRouter2", "router id: %d, route: %s", routerRecord.mRouterId, route.getId())); @@ -871,7 +871,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log(EventLogger.StringEvent.from( + mEventLogger.enqueue(EventLogger.StringEvent.from( "deselectRouteWithRouter2", "router id: %d, route: %s", routerRecord.mRouterId, route.getId())); @@ -891,7 +891,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log(EventLogger.StringEvent.from( + mEventLogger.enqueue(EventLogger.StringEvent.from( "transferToRouteWithRouter2", "router id: %d, route: %s", routerRecord.mRouterId, route.getId())); @@ -921,7 +921,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log(EventLogger.StringEvent.from( + mEventLogger.enqueue(EventLogger.StringEvent.from( "setSessionVolumeWithRouter2", "router id: %d, session: %s, volume: %d", routerRecord.mRouterId, uniqueSessionId, volume)); @@ -941,7 +941,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log(EventLogger.StringEvent.from( + mEventLogger.enqueue(EventLogger.StringEvent.from( "releaseSessionWithRouter2", "router id: %d, session: %s", routerRecord.mRouterId, uniqueSessionId)); @@ -983,7 +983,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log( + mEventLogger.enqueue( EventLogger.StringEvent.from("registerManager", "uid: %d, pid: %d, package: %s, userId: %d", uid, pid, packageName, userId)); @@ -1025,7 +1025,7 @@ class MediaRouter2ServiceImpl { } UserRecord userRecord = managerRecord.mUserRecord; - mEventLogger.log( + mEventLogger.enqueue( EventLogger.StringEvent.from( "unregisterManager", "package: %s, userId: %d, managerId: %d", @@ -1045,7 +1045,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log( + mEventLogger.enqueue( EventLogger.StringEvent.from("startScan", "manager: %d", managerRecord.mManagerId)); @@ -1059,7 +1059,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log( + mEventLogger.enqueue( EventLogger.StringEvent.from("stopScan", "manager: %d", managerRecord.mManagerId)); @@ -1076,7 +1076,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log( + mEventLogger.enqueue( EventLogger.StringEvent.from("setRouteVolumeWithManager", "managerId: %d, routeId: %s, volume: %d", managerRecord.mManagerId, route.getId(), volume)); @@ -1096,7 +1096,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log( + mEventLogger.enqueue( EventLogger.StringEvent.from("requestCreateSessionWithManager", "managerId: %d, routeId: %s", managerRecord.mManagerId, route.getId())); @@ -1146,7 +1146,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log( + mEventLogger.enqueue( EventLogger.StringEvent.from("selectRouteWithManager", "managerId: %d, session: %s, routeId: %s", managerRecord.mManagerId, uniqueSessionId, route.getId())); @@ -1172,7 +1172,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log( + mEventLogger.enqueue( EventLogger.StringEvent.from("deselectRouteWithManager", "managerId: %d, session: %s, routeId: %s", managerRecord.mManagerId, uniqueSessionId, route.getId())); @@ -1198,7 +1198,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log( + mEventLogger.enqueue( EventLogger.StringEvent.from("transferToRouteWithManager", "managerId: %d, session: %s, routeId: %s", managerRecord.mManagerId, uniqueSessionId, route.getId())); @@ -1224,7 +1224,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log( + mEventLogger.enqueue( EventLogger.StringEvent.from("setSessionVolumeWithManager", "managerId: %d, session: %s, volume: %d", managerRecord.mManagerId, uniqueSessionId, volume)); @@ -1245,7 +1245,7 @@ class MediaRouter2ServiceImpl { return; } - mEventLogger.log( + mEventLogger.enqueue( EventLogger.StringEvent.from("releaseSessionWithManager", "managerId: %d, session: %s", managerRecord.mManagerId, uniqueSessionId)); diff --git a/services/core/java/com/android/server/utils/EventLogger.java b/services/core/java/com/android/server/utils/EventLogger.java index 004312f06119..11766a3d70bd 100644 --- a/services/core/java/com/android/server/utils/EventLogger.java +++ b/services/core/java/com/android/server/utils/EventLogger.java @@ -43,7 +43,7 @@ public class EventLogger { /** * The maximum number of events to keep in {@code mEvents}. * - * <p>Calling {@link #log} when the size of {@link #mEvents} matches the threshold will + * <p>Calling {@link #enqueue} when the size of {@link #mEvents} matches the threshold will * cause the oldest event to be evicted. */ private final int mMemSize; @@ -60,7 +60,7 @@ public class EventLogger { } /** Enqueues {@code event} to be logged. */ - public synchronized void log(Event event) { + public synchronized void enqueue(Event event) { if (mEvents.size() >= mMemSize) { mEvents.removeLast(); } @@ -69,24 +69,14 @@ public class EventLogger { } /** - * Add a string-based event to the log, and print it to logcat as info. - * @param msg the message for the logs - * @param tag the logcat tag to use - */ - public synchronized void loglogi(String msg, String tag) { - final Event event = new StringEvent(msg); - log(event.printLog(tag)); - } - - /** - * Same as {@link #loglogi(String, String)} but specifying the logcat type + * Add a string-based event to the log, and print it to logcat with a specific severity. * @param msg the message for the logs * @param logType the type of logcat entry * @param tag the logcat tag to use */ - public synchronized void loglog(String msg, @Event.LogType int logType, String tag) { + public synchronized void enqueueAndLog(String msg, @Event.LogType int logType, String tag) { final Event event = new StringEvent(msg); - log(event.printLog(logType, tag)); + enqueue(event.printLog(logType, tag)); } /** Dumps events using {@link PrintWriter}. */ diff --git a/services/tests/servicestests/src/com/android/server/utils/EventLoggerTest.java b/services/tests/servicestests/src/com/android/server/utils/EventLoggerTest.java index 0b27f8734f23..4762696d7c61 100644 --- a/services/tests/servicestests/src/com/android/server/utils/EventLoggerTest.java +++ b/services/tests/servicestests/src/com/android/server/utils/EventLoggerTest.java @@ -125,7 +125,7 @@ public class EventLoggerTest { @Test public void testThatLoggingWorksAsExpected() { for (EventLogger.Event event: mEventsToInsert) { - mEventLogger.log(event); + mEventLogger.enqueue(event); } mEventLogger.dump(mTestPrintWriter); |