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

Commit b5daf797 authored by jiabin's avatar jiabin
Browse files

Add package name when initializing ToneGenerator.

Bug: 175595599
Test: ToneGeneratorTest
Change-Id: Id2fd253f1fe12770060ed897bae05500a65fd452
parent b7e45499
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "ToneGenerator"

#include <utility>

#include <math.h>
#include <utils/Log.h>
#include <cutils/properties.h>
@@ -979,7 +981,9 @@ const unsigned char /*tone_type*/ ToneGenerator::sToneMappingTable[NUM_REGIONS-1
//        none
//
////////////////////////////////////////////////////////////////////////////////
ToneGenerator::ToneGenerator(audio_stream_type_t streamType, float volume, bool threadCanCallJava) {
ToneGenerator::ToneGenerator(audio_stream_type_t streamType, float volume, bool threadCanCallJava,
        std::string opPackageName)
        : mOpPackageName(std::move(opPackageName)) {

    ALOGV("ToneGenerator constructor: streamType=%d, volume=%f", streamType, volume);

@@ -1250,7 +1254,7 @@ void ToneGenerator::stopTone() {
////////////////////////////////////////////////////////////////////////////////
bool ToneGenerator::initAudioTrack() {
    // Open audio track in mono, PCM 16bit, default sampling rate.
    mpAudioTrack = new AudioTrack();
    mpAudioTrack = new AudioTrack(mOpPackageName);
    ALOGV("AudioTrack(%p) created", mpAudioTrack.get());

    audio_attributes_t attr;
+6 −1
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#ifndef ANDROID_TONEGENERATOR_H_
#define ANDROID_TONEGENERATOR_H_

#include <string>

#include <media/AudioSystem.h>
#include <media/AudioTrack.h>
#include <utils/Compat.h>
@@ -152,7 +154,8 @@ public:
        NUM_SUP_TONES = LAST_SUP_TONE-FIRST_SUP_TONE+1
    };

    ToneGenerator(audio_stream_type_t streamType, float volume, bool threadCanCallJava = false);
    ToneGenerator(audio_stream_type_t streamType, float volume, bool threadCanCallJava = false,
            std::string opPackageName = {});
    ~ToneGenerator();

    bool startTone(tone_type toneType, int durationMs = -1);
@@ -343,6 +346,8 @@ private:
    };

    KeyedVector<uint16_t, WaveGenerator *> mWaveGens;  // list of active wave generators.

    std::string mOpPackageName;
};

}