Merge "AudioService: log changes in OP_PLAY_AUDIO" into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
8da5c64628
@@ -842,8 +842,8 @@ public final class AudioAttributes implements Parcelable {
|
||||
@Override
|
||||
public String toString () {
|
||||
return new String("AudioAttributes:"
|
||||
+ " usage=" + mUsage
|
||||
+ " content=" + mContentType
|
||||
+ " usage=" + usageToString()
|
||||
+ " content=" + contentTypeToString()
|
||||
+ " flags=0x" + Integer.toHexString(mFlags).toUpperCase()
|
||||
+ " tags=" + mFormattedTags
|
||||
+ " bundle=" + (mBundle == null ? "null" : mBundle.toString()));
|
||||
@@ -894,6 +894,19 @@ public final class AudioAttributes implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public String contentTypeToString() {
|
||||
switch(mContentType) {
|
||||
case CONTENT_TYPE_UNKNOWN:
|
||||
return new String("CONTENT_TYPE_UNKNOWN");
|
||||
case CONTENT_TYPE_SPEECH: return new String("CONTENT_TYPE_SPEECH");
|
||||
case CONTENT_TYPE_MUSIC: return new String("CONTENT_TYPE_MUSIC");
|
||||
case CONTENT_TYPE_MOVIE: return new String("CONTENT_TYPE_MOVIE");
|
||||
case CONTENT_TYPE_SONIFICATION: return new String("CONTENT_TYPE_SONIFICATION");
|
||||
default: return new String("unknown content type " + mContentType);
|
||||
}
|
||||
}
|
||||
|
||||
private static int usageForStreamType(int streamType) {
|
||||
switch(streamType) {
|
||||
case AudioSystem.STREAM_VOICE_CALL:
|
||||
|
||||
@@ -201,5 +201,7 @@ interface IAudioService {
|
||||
int dispatchFocusChange(in AudioFocusInfo afi, in int focusChange,
|
||||
in IAudioPolicyCallback pcb);
|
||||
|
||||
oneway void playerHasOpPlayAudio(in int piid, in boolean hasOpPlayAudio);
|
||||
|
||||
// WARNING: read warning at top of file, it is recommended to add new methods at the end
|
||||
}
|
||||
|
||||
@@ -276,6 +276,7 @@ public abstract class PlayerBase {
|
||||
// volume used by the player
|
||||
try {
|
||||
if (oldHasAppOpsPlayAudio != mHasAppOpsPlayAudio) {
|
||||
getService().playerHasOpPlayAudio(mPlayerIId, mHasAppOpsPlayAudio);
|
||||
if (mHasAppOpsPlayAudio) {
|
||||
if (DEBUG_APP_OPS) {
|
||||
Log.v(TAG, "updateAppOpsPlayAudio: unmuting player, vol=" + mLeftVolume
|
||||
|
||||
@@ -6973,6 +6973,10 @@ public class AudioService extends IAudioService.Stub
|
||||
mPlaybackMonitor.playerEvent(piid, event, Binder.getCallingUid());
|
||||
}
|
||||
|
||||
public void playerHasOpPlayAudio(int piid, boolean hasOpPlayAudio) {
|
||||
mPlaybackMonitor.playerHasOpPlayAudio(piid, hasOpPlayAudio, Binder.getCallingUid());
|
||||
}
|
||||
|
||||
public void releasePlayer(int piid) {
|
||||
mPlaybackMonitor.releasePlayer(piid, Binder.getCallingUid());
|
||||
}
|
||||
|
||||
@@ -214,6 +214,11 @@ 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
|
||||
mEventLogger.log(new PlayerOpPlayAudioEvent(piid, hasOpPlayAudio, binderUid));
|
||||
}
|
||||
|
||||
public void releasePlayer(int piid, int binderUid) {
|
||||
if (DEBUG) { Log.v(TAG, "releasePlayer() for piid=" + piid); }
|
||||
synchronized(mPlayerLock) {
|
||||
@@ -702,8 +707,28 @@ public final class PlaybackActivityMonitor
|
||||
|
||||
@Override
|
||||
public String eventToString() {
|
||||
return new String("player piid:" + mPlayerIId + " state:"
|
||||
+ AudioPlaybackConfiguration.toLogFriendlyPlayerState(mState));
|
||||
return new StringBuilder("player piid:").append(mPlayerIId).append(" state:")
|
||||
.append(AudioPlaybackConfiguration.toLogFriendlyPlayerState(mState)).toString();
|
||||
}
|
||||
}
|
||||
|
||||
private final static class PlayerOpPlayAudioEvent extends AudioEventLogger.Event {
|
||||
// only keeping the player interface ID as it uniquely identifies the player in the event
|
||||
final int mPlayerIId;
|
||||
final boolean mHasOp;
|
||||
final int mUid;
|
||||
|
||||
PlayerOpPlayAudioEvent(int piid, boolean hasOp, int uid) {
|
||||
mPlayerIId = piid;
|
||||
mHasOp = hasOp;
|
||||
mUid = uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String eventToString() {
|
||||
return new StringBuilder("player piid:").append(mPlayerIId)
|
||||
.append(" has OP_PLAY_AUDIO:").append(mHasOp)
|
||||
.append(" in uid:").append(mUid).toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user