Merge "AudioService: make PlaybackActivityMonitor less log-chatty" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9e55fcbdc2
@@ -46,12 +46,12 @@ import java.util.Set;
|
||||
public final class PlaybackActivityMonitor
|
||||
implements AudioPlaybackConfiguration.PlayerDeathMonitor, PlayerFocusEnforcer {
|
||||
|
||||
public final static String TAG = "AudioService.PlaybackActivityMonitor";
|
||||
public static final String TAG = "AudioService.PlaybackActivityMonitor";
|
||||
|
||||
private final static boolean DEBUG = false;
|
||||
private final static int VOLUME_SHAPER_SYSTEM_DUCK_ID = 1;
|
||||
private static final boolean DEBUG = false;
|
||||
private static final int VOLUME_SHAPER_SYSTEM_DUCK_ID = 1;
|
||||
|
||||
private final VolumeShaper.Configuration DUCK_VSHAPE =
|
||||
private static final VolumeShaper.Configuration DUCK_VSHAPE =
|
||||
new VolumeShaper.Configuration.Builder()
|
||||
.setId(VOLUME_SHAPER_SYSTEM_DUCK_ID)
|
||||
.setCurve(new float[] { 0.f, 1.f } /* times */,
|
||||
@@ -62,16 +62,12 @@ public final class PlaybackActivityMonitor
|
||||
new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION)
|
||||
.build()))
|
||||
.build();
|
||||
private final VolumeShaper.Configuration DUCK_ID =
|
||||
private static final VolumeShaper.Configuration DUCK_ID =
|
||||
new VolumeShaper.Configuration(VOLUME_SHAPER_SYSTEM_DUCK_ID);
|
||||
private final VolumeShaper.Operation PLAY_CREATE_IF_NEEDED =
|
||||
private static final VolumeShaper.Operation PLAY_CREATE_IF_NEEDED =
|
||||
new VolumeShaper.Operation.Builder(VolumeShaper.Operation.PLAY)
|
||||
.createIfNeeded()
|
||||
.build();
|
||||
private final VolumeShaper.Operation TERMINATE =
|
||||
new VolumeShaper.Operation.Builder()
|
||||
.terminate()
|
||||
.build();
|
||||
|
||||
private final ArrayList<PlayMonitorClient> mClients = new ArrayList<PlayMonitorClient>();
|
||||
// a public client is one that needs an anonymized version of the playback configurations, we
|
||||
@@ -166,14 +162,7 @@ public final class PlaybackActivityMonitor
|
||||
synchronized(mPlayerLock) {
|
||||
final AudioPlaybackConfiguration apc = mPlayers.get(new Integer(piid));
|
||||
if (checkConfigurationCaller(piid, apc, binderUid)) {
|
||||
try {
|
||||
apc.getPlayerProxy().applyVolumeShaper(
|
||||
DUCK_ID,
|
||||
TERMINATE);
|
||||
} catch (Exception e) { /* silent failure, happens with binder failure */ }
|
||||
mPlayers.remove(new Integer(piid));
|
||||
} else {
|
||||
Log.e(TAG, "Error releasing player " + piid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,16 +195,16 @@ public final class PlaybackActivityMonitor
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that piid and uid are valid for the given configuration.
|
||||
* Check that piid and uid are valid for the given valid configuration.
|
||||
* @param piid the piid of the player.
|
||||
* @param apc the configuration found for this piid.
|
||||
* @param binderUid actual uid of client trying to signal a player state/event/attributes.
|
||||
* @return true if the call is valid and the change should proceed, false otherwise.
|
||||
* @return true if the call is valid and the change should proceed, false otherwise. Always
|
||||
* returns false when apc is null.
|
||||
*/
|
||||
private static boolean checkConfigurationCaller(int piid,
|
||||
final AudioPlaybackConfiguration apc, int binderUid) {
|
||||
if (apc == null) {
|
||||
Log.e(TAG, "Invalid operation: unknown player " + piid);
|
||||
return false;
|
||||
} else if ((binderUid != 0) && (apc.getClientUid() != binderUid)) {
|
||||
Log.e(TAG, "Forbidden operation from uid " + binderUid + " for player " + piid);
|
||||
@@ -509,7 +498,7 @@ public final class PlaybackActivityMonitor
|
||||
/**
|
||||
* Inner class to track clients that want to be notified of playback updates
|
||||
*/
|
||||
private final static class PlayMonitorClient implements IBinder.DeathRecipient {
|
||||
private static final class PlayMonitorClient implements IBinder.DeathRecipient {
|
||||
|
||||
// can afford to be static because only one PlaybackActivityMonitor ever instantiated
|
||||
static PlaybackActivityMonitor sListenerDeathMonitor;
|
||||
|
||||
Reference in New Issue
Block a user