audioservice: add RTT mode observer
Enable audio capture by the Assistant when RTT is ON during a call
similarly to when an accessibility service is in the foreground.
Also remove log when permission checked for hotword
and audio output capture fail as those checks are now done
systematically.
Also do not check permission to bypass interruption policy if
bypass flags are not set.
Bug: 132976361
Test: use voice input during a call with RTT enabled.
Change-Id: Iff45b0816dac889262ec29ea115f74dea4dc6b6d
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index b0a8541..fa8da89 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -193,7 +193,8 @@
if (!mPackageManager.allowPlaybackCapture(uid)) {
attr->flags |= AUDIO_FLAG_NO_MEDIA_PROJECTION;
}
- if (!bypassInterruptionPolicyAllowed(pid, uid)) {
+ if (((attr->flags & (AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY|AUDIO_FLAG_BYPASS_MUTE)) != 0)
+ && !bypassInterruptionPolicyAllowed(pid, uid)) {
attr->flags &= ~(AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY|AUDIO_FLAG_BYPASS_MUTE);
}
audio_output_flags_t originalFlags = flags;
@@ -1316,4 +1317,12 @@
Mutex::Autolock _l(mLock);
return mAudioPolicyManager->getVolumeGroupFromAudioAttributes(aa, volumeGroup);
}
+
+status_t AudioPolicyService::setRttEnabled(bool enabled)
+{
+ Mutex::Autolock _l(mLock);
+ mUidPolicy->setRttEnabled(enabled);
+ return NO_ERROR;
+}
+
} // namespace android
diff --git a/services/audiopolicy/service/AudioPolicyService.cpp b/services/audiopolicy/service/AudioPolicyService.cpp
index e3c72ae..77f7997 100644
--- a/services/audiopolicy/service/AudioPolicyService.cpp
+++ b/services/audiopolicy/service/AudioPolicyService.cpp
@@ -409,7 +409,7 @@
// following cases:
// Another client in the same UID has already been allowed to capture
// OR The client is the assistant
-// AND an accessibility service is on TOP
+// AND an accessibility service is on TOP or a RTT call is active
// AND the source is VOICE_RECOGNITION or HOTWORD
// OR uses VOICE_RECOGNITION AND is on TOP
// OR uses HOTWORD
@@ -436,6 +436,9 @@
bool isAssistantOnTop = false;
bool isSensitiveActive = false;
bool isInCall = mPhoneState == AUDIO_MODE_IN_CALL;
+ bool rttCallActive =
+ (mPhoneState == AUDIO_MODE_IN_CALL || mPhoneState == AUDIO_MODE_IN_COMMUNICATION)
+ && mUidPolicy->isRttEnabled();
// if Sensor Privacy is enabled then all recordings should be silenced.
if (mSensorPrivacyPolicy->isSensorPrivacyEnabled()) {
@@ -518,13 +521,13 @@
allowCapture = true;
} else if (mUidPolicy->isAssistantUid(current->uid)) {
// For assistant allow capture if:
- // An accessibility service is on TOP
+ // An accessibility service is on TOP or a RTT call is active
// AND the source is VOICE_RECOGNITION or HOTWORD
// OR is on TOP AND uses VOICE_RECOGNITION
// OR uses HOTWORD
// AND there is no active privacy sensitive capture or call
// OR client has CAPTURE_AUDIO_OUTPUT privileged permission
- if (isA11yOnTop) {
+ if (isA11yOnTop || rttCallActive) {
if (source == AUDIO_SOURCE_HOTWORD || source == AUDIO_SOURCE_VOICE_RECOGNITION) {
allowCapture = true;
}
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index 8db63a5..e467f70 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -256,6 +256,8 @@
virtual status_t getVolumeGroupFromAudioAttributes(const AudioAttributes &aa,
volume_group_t &volumeGroup);
+ virtual status_t setRttEnabled(bool enabled);
+
status_t doStopOutput(audio_port_handle_t portId);
void doReleaseOutput(audio_port_handle_t portId);
@@ -345,7 +347,8 @@
class UidPolicy : public BnUidObserver, public virtual IBinder::DeathRecipient {
public:
explicit UidPolicy(wp<AudioPolicyService> service)
- : mService(service), mObserverRegistered(false), mAssistantUid(0) {}
+ : mService(service), mObserverRegistered(false),
+ mAssistantUid(0), mRttEnabled(false) {}
void registerSelf();
void unregisterSelf();
@@ -360,6 +363,8 @@
void setA11yUids(const std::vector<uid_t>& uids) { mA11yUids.clear(); mA11yUids = uids; }
bool isA11yUid(uid_t uid);
bool isA11yOnTop();
+ void setRttEnabled(bool enabled) { mRttEnabled = enabled; }
+ bool isRttEnabled() { return mRttEnabled; }
// BnUidObserver implementation
void onUidActive(uid_t uid) override;
@@ -387,6 +392,7 @@
std::unordered_map<uid_t, std::pair<bool, int>> mCachedUids;
uid_t mAssistantUid;
std::vector<uid_t> mA11yUids;
+ bool mRttEnabled;
};
// If sensor privacy is enabled then all apps, including those that are active, should be