Loading services/core/java/com/android/server/audio/PlaybackActivityMonitor.java +22 −70 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.server.audio; import static android.media.AudioPlaybackConfiguration.EXTRA_PLAYER_EVENT_MUTE; import static android.media.AudioPlaybackConfiguration.MUTED_BY_OP_PLAY_AUDIO; import static android.media.AudioPlaybackConfiguration.MUTED_BY_CLIENT_VOLUME; import static android.media.AudioPlaybackConfiguration.MUTED_BY_MASTER; Loading @@ -28,8 +27,6 @@ import static android.media.AudioPlaybackConfiguration.MUTED_BY_OP_CONTROL_AUDIO import static android.media.AudioPlaybackConfiguration.PLAYER_PIID_INVALID; import static android.media.AudioPlaybackConfiguration.PLAYER_UPDATE_MUTED; import static com.android.media.audio.Flags.portToPiidSimplification; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; Loading Loading @@ -158,8 +155,6 @@ public final class PlaybackActivityMonitor @GuardedBy("mPlayerLock") private final SparseIntArray mPiidToPortId = new SparseIntArray(); @GuardedBy("mPlayerLock") private final SparseIntArray mPortIdToPiid = new SparseIntArray(); private final Context mContext; private int mSavedAlarmVolume = -1; Loading Loading @@ -387,11 +382,7 @@ public final class PlaybackActivityMonitor sEventLogger.enqueue(new PlayerEvent(piid, event, eventValues)); if (event == AudioPlaybackConfiguration.PLAYER_UPDATE_PORT_ID) { if (portToPiidSimplification()) { mPiidToPortId.put(piid, eventValues[0]); } else { mPortIdToPiid.put(eventValues[0], piid); } return; } else if (event == AudioPlaybackConfiguration.PLAYER_STATE_STARTED) { for (Integer uidInteger: mBannedUids) { Loading Loading @@ -446,20 +437,12 @@ public final class PlaybackActivityMonitor synchronized (mPlayerLock) { int piid; if (portToPiidSimplification()) { int idxOfPiid = mPiidToPortId.indexOfValue(portId); if (idxOfPiid < 0) { Log.w(TAG, "No piid assigned for invalid/internal port id " + portId); return; } piid = mPiidToPortId.keyAt(idxOfPiid); } else { piid = mPortIdToPiid.get(portId, PLAYER_PIID_INVALID); if (piid == PLAYER_PIID_INVALID) { Log.w(TAG, "No piid assigned for invalid/internal port id " + portId); return; } } final AudioPlaybackConfiguration apc = mPlayers.get(piid); if (apc == null) { Log.w(TAG, "No AudioPlaybackConfiguration assigned for piid " + piid); Loading Loading @@ -496,20 +479,13 @@ public final class PlaybackActivityMonitor synchronized (mPlayerLock) { int piid; if (portToPiidSimplification()) { int idxOfPiid = mPiidToPortId.indexOfValue(portId); if (idxOfPiid < 0) { Log.w(TAG, "No piid assigned for invalid/internal port id " + portId); return; } piid = mPiidToPortId.keyAt(idxOfPiid); } else { piid = mPortIdToPiid.get(portId, PLAYER_PIID_INVALID); if (piid == PLAYER_PIID_INVALID) { Log.w(TAG, "No piid assigned for invalid/internal port id " + portId); return; } } final AudioPlaybackConfiguration apc = mPlayers.get(piid); if (apc == null) { Log.w(TAG, "No AudioPlaybackConfiguration assigned for piid " + piid); Loading Loading @@ -559,15 +535,7 @@ public final class PlaybackActivityMonitor change = apc.handleStateEvent(AudioPlaybackConfiguration.PLAYER_STATE_RELEASED, AudioPlaybackConfiguration.PLAYER_DEVICEIDS_INVALID); if (portToPiidSimplification()) { mPiidToPortId.delete(piid); } else { // remove all port ids mapped to the released player int portIdx; while ((portIdx = mPortIdToPiid.indexOfValue(piid)) >= 0) { mPortIdToPiid.removeAt(portIdx); } } if (change && mDoNotLogPiidList.contains(piid)) { // do not dispatch a change for a "do not log" player Loading @@ -585,17 +553,10 @@ public final class PlaybackActivityMonitor new EventLogger.StringEvent( "clear port id to piid map")); synchronized (mPlayerLock) { if (portToPiidSimplification()) { if (DEBUG) { Log.v(TAG, "clear piid to portId map:\n" + mPiidToPortId); } mPiidToPortId.clear(); } else { if (DEBUG) { Log.v(TAG, "clear port id to piid map:\n" + mPortIdToPiid); } mPortIdToPiid.clear(); } } } Loading Loading @@ -754,7 +715,6 @@ public final class PlaybackActivityMonitor pw.print(" " + piid); } pw.println("\n"); if (portToPiidSimplification()) { // portId to piid mappings: pw.println("\n current piid to portId map:"); for (int i = 0; i < mPiidToPortId.size(); ++i) { Loading @@ -762,14 +722,6 @@ public final class PlaybackActivityMonitor " piid: " + mPiidToPortId.keyAt(i) + " portId: " + mPiidToPortId.valueAt(i)); } } else { // portId to piid mappings: pw.println("\n current portId to piid map:"); for (int i = 0; i < mPortIdToPiid.size(); ++i) { pw.println(" portId: " + mPortIdToPiid.keyAt(i) + " piid: " + mPortIdToPiid.valueAt(i)); } } pw.println("\n"); // log sEventLogger.dump(pw); Loading Loading
services/core/java/com/android/server/audio/PlaybackActivityMonitor.java +22 −70 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.server.audio; import static android.media.AudioPlaybackConfiguration.EXTRA_PLAYER_EVENT_MUTE; import static android.media.AudioPlaybackConfiguration.MUTED_BY_OP_PLAY_AUDIO; import static android.media.AudioPlaybackConfiguration.MUTED_BY_CLIENT_VOLUME; import static android.media.AudioPlaybackConfiguration.MUTED_BY_MASTER; Loading @@ -28,8 +27,6 @@ import static android.media.AudioPlaybackConfiguration.MUTED_BY_OP_CONTROL_AUDIO import static android.media.AudioPlaybackConfiguration.PLAYER_PIID_INVALID; import static android.media.AudioPlaybackConfiguration.PLAYER_UPDATE_MUTED; import static com.android.media.audio.Flags.portToPiidSimplification; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; Loading Loading @@ -158,8 +155,6 @@ public final class PlaybackActivityMonitor @GuardedBy("mPlayerLock") private final SparseIntArray mPiidToPortId = new SparseIntArray(); @GuardedBy("mPlayerLock") private final SparseIntArray mPortIdToPiid = new SparseIntArray(); private final Context mContext; private int mSavedAlarmVolume = -1; Loading Loading @@ -387,11 +382,7 @@ public final class PlaybackActivityMonitor sEventLogger.enqueue(new PlayerEvent(piid, event, eventValues)); if (event == AudioPlaybackConfiguration.PLAYER_UPDATE_PORT_ID) { if (portToPiidSimplification()) { mPiidToPortId.put(piid, eventValues[0]); } else { mPortIdToPiid.put(eventValues[0], piid); } return; } else if (event == AudioPlaybackConfiguration.PLAYER_STATE_STARTED) { for (Integer uidInteger: mBannedUids) { Loading Loading @@ -446,20 +437,12 @@ public final class PlaybackActivityMonitor synchronized (mPlayerLock) { int piid; if (portToPiidSimplification()) { int idxOfPiid = mPiidToPortId.indexOfValue(portId); if (idxOfPiid < 0) { Log.w(TAG, "No piid assigned for invalid/internal port id " + portId); return; } piid = mPiidToPortId.keyAt(idxOfPiid); } else { piid = mPortIdToPiid.get(portId, PLAYER_PIID_INVALID); if (piid == PLAYER_PIID_INVALID) { Log.w(TAG, "No piid assigned for invalid/internal port id " + portId); return; } } final AudioPlaybackConfiguration apc = mPlayers.get(piid); if (apc == null) { Log.w(TAG, "No AudioPlaybackConfiguration assigned for piid " + piid); Loading Loading @@ -496,20 +479,13 @@ public final class PlaybackActivityMonitor synchronized (mPlayerLock) { int piid; if (portToPiidSimplification()) { int idxOfPiid = mPiidToPortId.indexOfValue(portId); if (idxOfPiid < 0) { Log.w(TAG, "No piid assigned for invalid/internal port id " + portId); return; } piid = mPiidToPortId.keyAt(idxOfPiid); } else { piid = mPortIdToPiid.get(portId, PLAYER_PIID_INVALID); if (piid == PLAYER_PIID_INVALID) { Log.w(TAG, "No piid assigned for invalid/internal port id " + portId); return; } } final AudioPlaybackConfiguration apc = mPlayers.get(piid); if (apc == null) { Log.w(TAG, "No AudioPlaybackConfiguration assigned for piid " + piid); Loading Loading @@ -559,15 +535,7 @@ public final class PlaybackActivityMonitor change = apc.handleStateEvent(AudioPlaybackConfiguration.PLAYER_STATE_RELEASED, AudioPlaybackConfiguration.PLAYER_DEVICEIDS_INVALID); if (portToPiidSimplification()) { mPiidToPortId.delete(piid); } else { // remove all port ids mapped to the released player int portIdx; while ((portIdx = mPortIdToPiid.indexOfValue(piid)) >= 0) { mPortIdToPiid.removeAt(portIdx); } } if (change && mDoNotLogPiidList.contains(piid)) { // do not dispatch a change for a "do not log" player Loading @@ -585,17 +553,10 @@ public final class PlaybackActivityMonitor new EventLogger.StringEvent( "clear port id to piid map")); synchronized (mPlayerLock) { if (portToPiidSimplification()) { if (DEBUG) { Log.v(TAG, "clear piid to portId map:\n" + mPiidToPortId); } mPiidToPortId.clear(); } else { if (DEBUG) { Log.v(TAG, "clear port id to piid map:\n" + mPortIdToPiid); } mPortIdToPiid.clear(); } } } Loading Loading @@ -754,7 +715,6 @@ public final class PlaybackActivityMonitor pw.print(" " + piid); } pw.println("\n"); if (portToPiidSimplification()) { // portId to piid mappings: pw.println("\n current piid to portId map:"); for (int i = 0; i < mPiidToPortId.size(); ++i) { Loading @@ -762,14 +722,6 @@ public final class PlaybackActivityMonitor " piid: " + mPiidToPortId.keyAt(i) + " portId: " + mPiidToPortId.valueAt(i)); } } else { // portId to piid mappings: pw.println("\n current portId to piid map:"); for (int i = 0; i < mPortIdToPiid.size(); ++i) { pw.println(" portId: " + mPortIdToPiid.keyAt(i) + " piid: " + mPortIdToPiid.valueAt(i)); } } pw.println("\n"); // log sEventLogger.dump(pw); Loading