Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95868547 authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "MediaMetrics: Add LogSessionId" into sc-dev

parents d2191dba 88205a34
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -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},
};

+23 −0
Original line number Diff line number Diff line
@@ -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.