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

Commit 8340e671 authored by Eric Laurent's avatar Eric Laurent
Browse files

audio policy: Add call screen audio mode.

Add new audio mode AUDIO_MODE_CALL_SCREEN allowing call screening
to take place while other audio use cases are still active.

Also add API and audio policy configuration attribute to
indicate if the platform supports this audio mode.

Bug: 140384450
Test: make
Change-Id: If2fc56dbbd10aae2cf1498480471b35de0940228
parent cd606f3f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1519,6 +1519,13 @@ status_t AudioSystem::setRttEnabled(bool enabled)
    return aps->setRttEnabled(enabled);
}

bool AudioSystem::isCallScreenModeSupported()
{
    const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
    if (aps == 0) return false;
    return aps->isCallScreenModeSupported();
}

// ---------------------------------------------------------------------------

int AudioSystem::AudioPolicyServiceClient::addAudioPortCallback(
+22 −3
Original line number Diff line number Diff line
@@ -104,7 +104,8 @@ enum {
    GET_VOLUME_GROUP_FOR_ATTRIBUTES,
    SET_ALLOWED_CAPTURE_POLICY,
    MOVE_EFFECTS_TO_IO,
    SET_RTT_ENABLED
    SET_RTT_ENABLED,
    IS_CALL_SCREEN_MODE_SUPPORTED
};

#define MAX_ITEMS_PER_LIST 1024
@@ -1284,6 +1285,17 @@ public:
        }
        return static_cast<status_t>(reply.readInt32());
    }

    virtual bool isCallScreenModeSupported()
    {
        Parcel data, reply;
        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
        status_t status = remote()->transact(IS_CALL_SCREEN_MODE_SUPPORTED, data, &reply);
        if (status != NO_ERROR) {
            return false;
        }
        return reply.readBool();
    }
};

IMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService");
@@ -1346,7 +1358,8 @@ status_t BnAudioPolicyService::onTransact(
        case GET_OFFLOAD_FORMATS_A2DP:
        case LIST_AUDIO_VOLUME_GROUPS:
        case GET_VOLUME_GROUP_FOR_ATTRIBUTES:
        case SET_RTT_ENABLED: {
        case SET_RTT_ENABLED:
        case IS_CALL_SCREEN_MODE_SUPPORTED: {
            if (!isServiceUid(IPCThreadState::self()->getCallingUid())) {
                ALOGW("%s: transaction %d received from PID %d unauthorized UID %d",
                      __func__, code, IPCThreadState::self()->getCallingPid(),
@@ -2237,7 +2250,6 @@ status_t BnAudioPolicyService::onTransact(
            reply->writeBool(isSupported);
            return NO_ERROR;
        }

        case SET_UID_DEVICE_AFFINITY: {
            CHECK_INTERFACE(IAudioPolicyService, data, reply);
            const uid_t uid = (uid_t) data.readInt32();
@@ -2369,6 +2381,13 @@ status_t BnAudioPolicyService::onTransact(
            return NO_ERROR;
        }

        case IS_CALL_SCREEN_MODE_SUPPORTED: {
            CHECK_INTERFACE(IAudioPolicyService, data, reply);
            bool isAvailable = isCallScreenModeSupported();
            reply->writeBool(isAvailable);
            return NO_ERROR;
        }

        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
+2 −0
Original line number Diff line number Diff line
@@ -396,6 +396,8 @@ public:

    static status_t setRttEnabled(bool enabled);

    static bool     isCallScreenModeSupported();

    // ----------------------------------------------------------------------------

    class AudioVolumeGroupCallback : public RefBase
+2 −0
Original line number Diff line number Diff line
@@ -222,6 +222,8 @@ public:
                                                       volume_group_t &volumeGroup) = 0;

    virtual status_t setRttEnabled(bool enabled) = 0;

    virtual bool     isCallScreenModeSupported() = 0;
};


+1 −0
Original line number Diff line number Diff line
@@ -325,6 +325,7 @@ const AudioModeConverter::Table AudioModeConverter::mTable[] = {
    MAKE_STRING_FROM_ENUM(AUDIO_MODE_RINGTONE),
    MAKE_STRING_FROM_ENUM(AUDIO_MODE_IN_CALL),
    MAKE_STRING_FROM_ENUM(AUDIO_MODE_IN_COMMUNICATION),
    MAKE_STRING_FROM_ENUM(AUDIO_MODE_CALL_SCREEN),
    TERMINATOR
};

Loading