Merge "MediaMetrics: Add LogSessionId" into sc-dev

This commit is contained in:
Andy Hung
2021-02-22 21:43:20 +00:00
committed by Android (Google) Code Review
2 changed files with 37 additions and 0 deletions

View File

@@ -1419,6 +1419,18 @@ static jint android_media_AudioTrack_getDualMonoMode(JNIEnv *env, jobject thiz,
return nativeToJavaStatus(status);
}
static void android_media_AudioTrack_setLogSessionId(JNIEnv *env, jobject thiz,
jstring jlogSessionId) {
sp<AudioTrack> track = getAudioTrack(env, thiz);
if (track == nullptr) {
jniThrowException(env, "java/lang/IllegalStateException",
"Unable to retrieve AudioTrack pointer for setLogSessionId()");
}
ScopedUtfChars logSessionId(env, jlogSessionId);
ALOGV("%s: logSessionId %s", __func__, logSessionId.c_str());
track->setLogSessionId(logSessionId.c_str());
}
static void android_media_AudioTrack_setPlayerIId(JNIEnv *env, jobject thiz, jint playerIId) {
sp<AudioTrack> track = getAudioTrack(env, thiz);
if (track == nullptr) {
@@ -1506,6 +1518,8 @@ static const JNINativeMethod gMethods[] = {
(void *)android_media_AudioTrack_getAudioDescriptionMixLeveldB},
{"native_set_dual_mono_mode", "(I)I", (void *)android_media_AudioTrack_setDualMonoMode},
{"native_get_dual_mono_mode", "([I)I", (void *)android_media_AudioTrack_getDualMonoMode},
{"native_setLogSessionId", "(Ljava/lang/String;)V",
(void *)android_media_AudioTrack_setLogSessionId},
{"native_setPlayerIId", "(I)V", (void *)android_media_AudioTrack_setPlayerIId},
};

View File

@@ -565,6 +565,11 @@ public class AudioTrack extends PlayerBase
*/
private int mOffloadPaddingFrames = 0;
/**
* The log session id used for metrics.
*/
private String mLogSessionId;
//--------------------------------
// Used exclusively by native code
//--------------------
@@ -3968,6 +3973,23 @@ public class AudioTrack extends PlayerBase
}
}
/**
* Sets a string handle to this AudioTrack for metrics collection.
*
* @param logSessionId a string which is used to identify this object
* to the metrics service.
* @throws IllegalStateException if AudioTrack not initialized.
*
* @hide
*/
public void setLogSessionId(@NonNull String logSessionId) {
if (mState == STATE_UNINITIALIZED) {
throw new IllegalStateException("track not initialized");
}
native_setLogSessionId(logSessionId);
mLogSessionId = logSessionId;
}
//---------------------------------------------------------
// Inner classes
//--------------------
@@ -4203,6 +4225,7 @@ public class AudioTrack extends PlayerBase
private native int native_get_audio_description_mix_level_db(float[] level);
private native int native_set_dual_mono_mode(int dualMonoMode);
private native int native_get_dual_mono_mode(int[] dualMonoMode);
private native void native_setLogSessionId(@NonNull String logSessionId);
/**
* Sets the audio service Player Interface Id.