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

Commit afc750aa authored by Svet Ganov's avatar Svet Ganov Committed by Android (Google) Code Review
Browse files

Merge "Respect the record audio app op - media" into mnc-dev

parents 1e2a0e6a be71aa29
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#include <sys/stat.h>
#include <fcntl.h>

#include <utils/String16.h>

#include <binder/ProcessState.h>
#include <media/mediarecorder.h>
#include <media/stagefright/foundation/ADebug.h>
@@ -34,7 +36,7 @@ using namespace android;

static void usage(const char* name)
{
    fprintf(stderr, "Usage: %s [-d duration] [-m] [-w] [<output-file>]\n", name);
    fprintf(stderr, "Usage: %s [-d du.ration] [-m] [-w] [<output-file>]\n", name);
    fprintf(stderr, "Encodes either a sine wave or microphone input to AMR format\n");
    fprintf(stderr, "    -d    duration in seconds, default 5 seconds\n");
    fprintf(stderr, "    -m    use microphone for input, default sine source\n");
@@ -85,6 +87,7 @@ int main(int argc, char* argv[])
        // talk into the appropriate microphone for the duration
        source = new AudioSource(
                AUDIO_SOURCE_MIC,
                String16(),
                kSampleRate,
                channels);
    } else {
+11 −2
Original line number Diff line number Diff line
@@ -201,8 +201,12 @@ public:
     */

    /* Simple Constructor.
     *
     * Parameters:
     *
     * opPackageName:      The package name used for app op checks.
     */
    AudioEffect();
    AudioEffect(const String16& opPackageName);


    /* Constructor.
@@ -211,6 +215,7 @@ public:
     *
     * type:  type of effect created: can be null if uuid is specified. This corresponds to
     *        the OpenSL ES interface implemented by this effect.
     * opPackageName:  The package name used for app op checks.
     * uuid:  Uuid of effect created: can be null if type is specified. This uuid corresponds to
     *        a particular implementation of an effect type.
     * priority:    requested priority for effect control: the priority level corresponds to the
@@ -227,6 +232,7 @@ public:
     */

    AudioEffect(const effect_uuid_t *type,
                const String16& opPackageName,
                const effect_uuid_t *uuid = NULL,
                  int32_t priority = 0,
                  effect_callback_t cbf = NULL,
@@ -239,6 +245,7 @@ public:
     *      Same as above but with type and uuid specified by character strings
     */
    AudioEffect(const char *typeStr,
                    const String16& opPackageName,
                    const char *uuidStr = NULL,
                    int32_t priority = 0,
                    effect_callback_t cbf = NULL,
@@ -408,6 +415,8 @@ protected:
     int32_t                 mId;                // system wide unique effect engine instance ID
     Mutex                   mLock;              // Mutex for mEnabled access

     String16                mOpPackageName;     // The package name used for app op checks.

     // IEffectClient
     virtual void controlStatusChanged(bool controlGranted);
     virtual void enableStatusChanged(bool enabled);
+10 −2
Original line number Diff line number Diff line
@@ -129,8 +129,12 @@ public:

    /* Constructs an uninitialized AudioRecord. No connection with
     * AudioFlinger takes place.  Use set() after this.
     *
     * Parameters:
     *
     * opPackageName:      The package name used for app ops.
     */
                        AudioRecord();
                        AudioRecord(const String16& opPackageName);

    /* Creates an AudioRecord object and registers it with AudioFlinger.
     * Once created, the track needs to be started before it can be used.
@@ -143,6 +147,7 @@ public:
     * format:             Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed
     *                     16 bits per sample).
     * channelMask:        Channel mask, such that audio_is_input_channel(channelMask) is true.
     * opPackageName:      The package name used for app ops.
     * frameCount:         Minimum size of track PCM buffer in frames. This defines the
     *                     application's contribution to the
     *                     latency of the track.  The actual size selected by the AudioRecord could
@@ -165,6 +170,7 @@ public:
                                    uint32_t sampleRate,
                                    audio_format_t format,
                                    audio_channel_mask_t channelMask,
                                    const String16& opPackageName,
                                    size_t frameCount = 0,
                                    callback_t cbf = NULL,
                                    void* user = NULL,
@@ -483,7 +489,7 @@ private:

            // caller must hold lock on mLock for all _l methods

            status_t openRecord_l(size_t epoch);
            status_t openRecord_l(size_t epoch, const String16& opPackageName);

            // FIXME enum is faster than strcmp() for parameter 'from'
            status_t restoreRecord_l(const char *from);
@@ -520,6 +526,8 @@ private:

    status_t                mStatus;

    String16                mOpPackageName;         // The package name used for app ops.

    size_t                  mFrameCount;            // corresponds to current IAudioRecord, value is
                                                    // reported back by AudioFlinger to the client
    size_t                  mReqFrameCount;         // frame count to request the first or next time
+2 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ public:
                                uint32_t sampleRate,
                                audio_format_t format,
                                audio_channel_mask_t channelMask,
                                const String16& callingPackage,
                                size_t *pFrameCount,
                                track_flags_t *flags,
                                pid_t tid,  // -1 means unused, otherwise must be valid non-0
@@ -198,6 +199,7 @@ public:
                                    // AudioFlinger doesn't take over handle reference from client
                                    audio_io_handle_t output,
                                    int sessionId,
                                    const String16& callingPackage,
                                    status_t *status,
                                    int *id,
                                    int *enabled) = 0;
+3 −3
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ class IMediaPlayerService: public IInterface
public:
    DECLARE_META_INTERFACE(MediaPlayerService);

    virtual sp<IMediaRecorder> createMediaRecorder() = 0;
    virtual sp<IMediaRecorder> createMediaRecorder(const String16 &opPackageName) = 0;
    virtual sp<IMediaMetadataRetriever> createMetadataRetriever() = 0;
    virtual sp<IMediaPlayer> create(const sp<IMediaPlayerClient>& client, int audioSessionId = 0)
            = 0;
@@ -65,8 +65,8 @@ public:
    // display client when display connection, disconnection or errors occur.
    // The assumption is that at most one remote display will be connected to the
    // provided interface at a time.
    virtual sp<IRemoteDisplay> listenForRemoteDisplay(const sp<IRemoteDisplayClient>& client,
            const String8& iface) = 0;
    virtual sp<IRemoteDisplay> listenForRemoteDisplay(const String16 &opPackageName,
            const sp<IRemoteDisplayClient>& client, const String8& iface) = 0;

    // codecs and audio devices usage tracking for the battery app
    enum BatteryDataBits {
Loading