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

Commit f91c0ac7 authored by Atneya Nair's avatar Atneya Nair
Browse files

[audio] Add playback hardening override plumbing

Allows for AudioService to communicate that playback hardening has been
enabled via override by API, which results in skipping the flag checking
and exemption logic within audioserver.

Misc plumbing to get that bit of data available at the track level.

Bug: 376481063
Test: manual verification via adb shell set-hardening
Flag: EXEMPT test only
Change-Id: I75bd475d1fe0c415204ebda71c29043eb079ddf7
parent 4dba248e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -498,4 +498,9 @@ interface IAudioPolicyService {
    // When adding a new method, please review and update
    // AudioPolicyService.cpp AudioPolicyService::onTransact()
    // AudioPolicyService.cpp IAUDIOPOLICYSERVICE_BINDER_METHOD_MACRO_LIST

    /**
     * Enable hardening independent of flag or exemption state
     */
     void setEnableHardening(boolean shouldEnable);
}
+6 −0
Original line number Diff line number Diff line
@@ -2400,6 +2400,12 @@ const IPermissionProvider& AudioFlinger::getPermissionProvider() {
    return mAudioPolicyServiceLocal.load()->getPermissionProvider();
}

bool AudioFlinger::isHardeningOverrideEnabled() const {
    // This is inited as part of service construction, prior to binder registration,
    // so it should always be non-null.
    return mAudioPolicyServiceLocal.load()->isHardeningOverrideEnabled();
}

// removeClient_l() must be called with AudioFlinger::clientMutex() held
void AudioFlinger::removeClient_l(pid_t pid)
{
+2 −0
Original line number Diff line number Diff line
@@ -421,6 +421,8 @@ private:

    const ::com::android::media::permission::IPermissionProvider& getPermissionProvider() final;

    bool isHardeningOverrideEnabled() const final;

    // ---- end of IAfThreadCallback interface

    /* List available audio ports and their attributes */
+2 −0
Original line number Diff line number Diff line
@@ -133,6 +133,8 @@ public:

    virtual const ::com::android::media::permission::IPermissionProvider&
            getPermissionProvider() = 0;

    virtual bool isHardeningOverrideEnabled() const = 0;
};

class IAfThreadBase : public virtual RefBase {
+5 −3
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ class IAfPatchTrack;
class IAfPlaybackThread;
class IAfRecordThread;
class IAfThreadBase;
class IAfThreadCallback;

struct TeePatch {
    sp<IAfPatchRecord> patchRecord;
@@ -267,9 +268,10 @@ class AfPlaybackCommon : public virtual VolumePortInterface {
    using AppOpsSession = media::permission::AppOpsSession<media::permission::DefaultAppOpsFacade>;

  public:
    AfPlaybackCommon(
            IAfTrackBase & self, float volume, bool muted, const audio_attributes_t& attr,
            const AttributionSourceState& attributionSource, bool shouldPlaybackHarden = true);
    AfPlaybackCommon(IAfTrackBase& self, IAfThreadCallback& thread, float volume, bool muted,
                     const audio_attributes_t& attr,
                     const AttributionSourceState& attributionSource,
                     bool shouldPlaybackHarden = true);

    /**
     * Updates the mute state and notifies the audio service.
Loading