Added audio service API to set active assistants.
Added API to manage the currently active assistants UIDs. When an
assistant can become active the API can be called to set voice
interaction service and corresponging trusted hotword service as active.
If there are no assistant UIDs in the active list the audio policy
service uses the default policy, which is to find the latest active
assistant and allow that to continue listening. This is to continue
support for legacy devices where the management of the active assistant
should be preserve.
Bug: 189312611
Test: m -j, and run assistant
Change-Id: I18984f3dcb8bf63dd16b3ae86d96dfbce39ced03
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index 3be3a1b..ae65a65 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -219,6 +219,7 @@
binder::Status setSurroundFormatEnabled(const AudioFormatDescription& audioFormat,
bool enabled) override;
binder::Status setAssistantServicesUids(const std::vector<int32_t>& uids) override;
+ binder::Status setActiveAssistantServicesUids(const std::vector<int32_t>& activeUids) override;
binder::Status setA11yServicesUids(const std::vector<int32_t>& uids) override;
binder::Status setCurrentImeUid(int32_t uid) override;
binder::Status isHapticPlaybackSupported(bool* _aidl_return) override;
@@ -432,6 +433,8 @@
int getUidState(uid_t uid);
void setAssistantUids(const std::vector<uid_t>& uids);
bool isAssistantUid(uid_t uid);
+ void setActiveAssistantUids(const std::vector<uid_t>& activeUids);
+ bool isActiveAssistantUid(uid_t uid);
void setA11yUids(const std::vector<uid_t>& uids) { mA11yUids.clear(); mA11yUids = uids; }
bool isA11yUid(uid_t uid);
bool isA11yOnTop();
@@ -469,6 +472,7 @@
std::unordered_map<uid_t, std::pair<bool, int>> mOverrideUids;
std::unordered_map<uid_t, std::pair<bool, int>> mCachedUids;
std::vector<uid_t> mAssistantUids;
+ std::vector<uid_t> mActiveAssistantUids;
std::vector<uid_t> mA11yUids;
uid_t mCurrentImeUid = -1;
bool mRttEnabled = false;