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

Commit 76373c26 authored by Eric Laurent's avatar Eric Laurent Committed by Phil Burk
Browse files

aaudio: add missing symbols and tests for capture privacy API

Add missing symbols for new APIs added to control if an input stream
is privacy sensitive or not.
Also add tests for these new APIs.

Bug: 137850106
Test: test_attributes
Change-Id: Iab6e37a312dd295f705a3dfb69acddd131dc9142
parent d1ce689a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ LIBAAUDIO {
    AAudioStreamBuilder_setInputPreset; # introduced=28
    AAudioStreamBuilder_setAllowedCapturePolicy; # introduced=29
    AAudioStreamBuilder_setSessionId;   # introduced=28
    AAudioStreamBuilder_setPrivacySensitive;   # introduced=30
    AAudioStreamBuilder_openStream;
    AAudioStreamBuilder_delete;
    AAudioStream_close;
@@ -56,6 +57,7 @@ LIBAAUDIO {
    AAudioStream_getSessionId;   # introduced=28
    AAudioStream_getTimestamp;
    AAudioStream_isMMapUsed;
    AAudioStream_isPrivacySensitive;   # introduced=30
  local:
    *;
};
+34 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ static void checkAttributes(aaudio_performance_mode_t perfMode,
                            aaudio_content_type_t contentType,
                            aaudio_input_preset_t preset = DONT_SET,
                            aaudio_allowed_capture_policy_t capturePolicy = DONT_SET,
                            int privacyMode = DONT_SET,
                            aaudio_direction_t direction = AAUDIO_DIRECTION_OUTPUT) {

    float *buffer = new float[kNumFrames * kChannelCount];
@@ -60,6 +61,9 @@ static void checkAttributes(aaudio_performance_mode_t perfMode,
    if (capturePolicy != DONT_SET) {
        AAudioStreamBuilder_setAllowedCapturePolicy(aaudioBuilder, capturePolicy);
    }
    if (privacyMode != DONT_SET) {
        AAudioStreamBuilder_setPrivacySensitive(aaudioBuilder, (bool)privacyMode);
    }

    // Create an AAudioStream using the Builder.
    ASSERT_EQ(AAUDIO_OK, AAudioStreamBuilder_openStream(aaudioBuilder, &aaudioStream));
@@ -90,6 +94,13 @@ static void checkAttributes(aaudio_performance_mode_t perfMode,
            : preset;
    EXPECT_EQ(expectedCapturePolicy, AAudioStream_getAllowedCapturePolicy(aaudioStream));

    bool expectedPrivacyMode =
            (privacyMode == DONT_SET) ?
                ((preset == AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION
                    || preset == AAUDIO_INPUT_PRESET_CAMCORDER) ? true : false) :
                privacyMode;
    EXPECT_EQ(expectedPrivacyMode, AAudioStream_isPrivacySensitive(aaudioStream));

    EXPECT_EQ(AAUDIO_OK, AAudioStream_requestStart(aaudioStream));

    if (direction == AAUDIO_DIRECTION_INPUT) {
@@ -151,6 +162,12 @@ static const aaudio_input_preset_t sAllowCapturePolicies[] = {
    AAUDIO_ALLOW_CAPTURE_BY_NONE,
};

static const int sPrivacyModes[] = {
    DONT_SET,
    false,
    true,
};

static void checkAttributesUsage(aaudio_performance_mode_t perfMode) {
    for (aaudio_usage_t usage : sUsages) {
        checkAttributes(perfMode, usage, DONT_SET);
@@ -170,6 +187,7 @@ static void checkAttributesInputPreset(aaudio_performance_mode_t perfMode) {
                        DONT_SET,
                        inputPreset,
                        DONT_SET,
                        DONT_SET,
                        AAUDIO_DIRECTION_INPUT);
    }
}
@@ -185,6 +203,18 @@ static void checkAttributesAllowedCapturePolicy(aaudio_performance_mode_t perfMo
    }
}

static void checkAttributesPrivacySensitive(aaudio_performance_mode_t perfMode) {
    for (int privacyMode : sPrivacyModes) {
        checkAttributes(perfMode,
                        DONT_SET,
                        DONT_SET,
                        DONT_SET,
                        DONT_SET,
                        privacyMode,
                        AAUDIO_DIRECTION_INPUT);
    }
}

TEST(test_attributes, aaudio_usage_perfnone) {
    checkAttributesUsage(AAUDIO_PERFORMANCE_MODE_NONE);
}
@@ -216,3 +246,7 @@ TEST(test_attributes, aaudio_input_preset_lowlat) {
TEST(test_attributes, aaudio_allowed_capture_policy_lowlat) {
    checkAttributesAllowedCapturePolicy(AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
}

TEST(test_attributes, aaudio_allowed_privacy_sensitive_lowlat) {
    checkAttributesPrivacySensitive(AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
}