Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_AUDIOPOLICYSERVICE_H |
| 18 | #define ANDROID_AUDIOPOLICYSERVICE_H |
| 19 | |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 20 | #include <cutils/misc.h> |
| 21 | #include <cutils/config_utils.h> |
Mathias Agopian | e762be9 | 2013-05-09 16:26:45 -0700 | [diff] [blame] | 22 | #include <cutils/compiler.h> |
Glenn Kasten | d1d8f23 | 2011-07-08 09:34:50 -0700 | [diff] [blame] | 23 | #include <utils/String8.h> |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 24 | #include <utils/Vector.h> |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 25 | #include <utils/SortedVector.h> |
Glenn Kasten | d2dcb08 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 26 | #include <binder/BinderService.h> |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 27 | #include <binder/IUidObserver.h> |
Dima Zavin | 6476024 | 2011-05-11 14:15:23 -0700 | [diff] [blame] | 28 | #include <system/audio.h> |
Dima Zavin | 7394a4f | 2011-06-13 18:16:26 -0700 | [diff] [blame] | 29 | #include <system/audio_policy.h> |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 30 | #include <media/IAudioPolicyService.h> |
| 31 | #include <media/ToneGenerator.h> |
| 32 | #include <media/AudioEffect.h> |
Eric Laurent | baac183 | 2014-12-01 17:52:59 -0800 | [diff] [blame] | 33 | #include <media/AudioPolicy.h> |
Kevin Rocard | 8be9497 | 2019-02-22 13:26:25 -0800 | [diff] [blame] | 34 | #include <mediautils/ServiceUtilities.h> |
bryant_liu | ba2b439 | 2014-06-11 16:49:30 +0800 | [diff] [blame] | 35 | #include "AudioPolicyEffects.h" |
François Gaffie | 962ba21 | 2019-04-03 16:21:39 +0200 | [diff] [blame] | 36 | #include <AudioPolicyInterface.h> |
Michael Groover | cfd2830 | 2018-12-11 19:16:46 -0800 | [diff] [blame] | 37 | #include <android/hardware/BnSensorPrivacyListener.h> |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 38 | |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 39 | #include <unordered_map> |
bryant_liu | ba2b439 | 2014-06-11 16:49:30 +0800 | [diff] [blame] | 40 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 41 | namespace android { |
| 42 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 43 | // ---------------------------------------------------------------------------- |
| 44 | |
Glenn Kasten | d2dcb08 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 45 | class AudioPolicyService : |
| 46 | public BinderService<AudioPolicyService>, |
| 47 | public BnAudioPolicyService, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 48 | public IBinder::DeathRecipient |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 49 | { |
Glenn Kasten | d2dcb08 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 50 | friend class BinderService<AudioPolicyService>; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 51 | |
| 52 | public: |
Glenn Kasten | d2dcb08 | 2011-02-03 16:55:26 -0800 | [diff] [blame] | 53 | // for BinderService |
Mathias Agopian | e762be9 | 2013-05-09 16:26:45 -0700 | [diff] [blame] | 54 | static const char *getServiceName() ANDROID_API { return "media.audio_policy"; } |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 55 | |
| 56 | virtual status_t dump(int fd, const Vector<String16>& args); |
| 57 | |
| 58 | // |
| 59 | // BnAudioPolicyService (see AudioPolicyInterface for method descriptions) |
| 60 | // |
| 61 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 62 | virtual status_t setDeviceConnectionState(audio_devices_t device, |
| 63 | audio_policy_dev_state_t state, |
Paul McLean | e743a47 | 2015-01-28 11:07:31 -0800 | [diff] [blame] | 64 | const char *device_address, |
Aniket Kumar Lata | 4e46470 | 2019-01-10 23:38:46 -0800 | [diff] [blame] | 65 | const char *device_name, |
| 66 | audio_format_t encodedFormat); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 67 | virtual audio_policy_dev_state_t getDeviceConnectionState( |
| 68 | audio_devices_t device, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 69 | const char *device_address); |
Pavlin Radoslavov | f862bc6 | 2016-12-26 18:57:22 -0800 | [diff] [blame] | 70 | virtual status_t handleDeviceConfigChange(audio_devices_t device, |
| 71 | const char *device_address, |
Aniket Kumar Lata | 4e46470 | 2019-01-10 23:38:46 -0800 | [diff] [blame] | 72 | const char *device_name, |
| 73 | audio_format_t encodedFormat); |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 74 | virtual status_t setPhoneState(audio_mode_t state); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 75 | virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config); |
| 76 | virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage); |
Eric Laurent | f4e6345 | 2017-11-06 19:31:46 +0000 | [diff] [blame] | 77 | virtual audio_io_handle_t getOutput(audio_stream_type_t stream); |
Eric Laurent | 4298441 | 2019-05-09 17:57:03 -0700 | [diff] [blame^] | 78 | status_t getOutputForAttr(audio_attributes_t *attr, |
Kevin Rocard | 153f92d | 2018-12-18 18:33:28 -0800 | [diff] [blame] | 79 | audio_io_handle_t *output, |
| 80 | audio_session_t session, |
| 81 | audio_stream_type_t *stream, |
| 82 | pid_t pid, |
| 83 | uid_t uid, |
| 84 | const audio_config_t *config, |
| 85 | audio_output_flags_t flags, |
| 86 | audio_port_handle_t *selectedDeviceId, |
| 87 | audio_port_handle_t *portId, |
| 88 | std::vector<audio_io_handle_t> *secondaryOutputs) override; |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 89 | virtual status_t startOutput(audio_port_handle_t portId); |
| 90 | virtual status_t stopOutput(audio_port_handle_t portId); |
| 91 | virtual void releaseOutput(audio_port_handle_t portId); |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 92 | virtual status_t getInputForAttr(const audio_attributes_t *attr, |
| 93 | audio_io_handle_t *input, |
Mikhail Naganov | 2996f67 | 2019-04-18 12:29:59 -0700 | [diff] [blame] | 94 | audio_unique_id_t riid, |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 95 | audio_session_t session, |
Eric Laurent | b2379ba | 2016-05-23 17:42:12 -0700 | [diff] [blame] | 96 | pid_t pid, |
Eric Laurent | 8c7e6da | 2015-04-21 17:37:00 -0700 | [diff] [blame] | 97 | uid_t uid, |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 98 | const String16& opPackageName, |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 99 | const audio_config_base_t *config, |
Paul McLean | 466dc8e | 2015-04-17 13:15:36 -0600 | [diff] [blame] | 100 | audio_input_flags_t flags, |
Eric Laurent | 9ae8c59 | 2017-06-22 17:17:09 -0700 | [diff] [blame] | 101 | audio_port_handle_t *selectedDeviceId = NULL, |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 102 | audio_port_handle_t *portId = NULL); |
Eric Laurent | 4eb58f1 | 2018-12-07 16:41:02 -0800 | [diff] [blame] | 103 | virtual status_t startInput(audio_port_handle_t portId); |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 104 | virtual status_t stopInput(audio_port_handle_t portId); |
| 105 | virtual void releaseInput(audio_port_handle_t portId); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 106 | virtual status_t initStreamVolume(audio_stream_type_t stream, |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 107 | int indexMin, |
| 108 | int indexMax); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 109 | virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, |
| 110 | int index, |
| 111 | audio_devices_t device); |
| 112 | virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, |
| 113 | int *index, |
| 114 | audio_devices_t device); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 115 | |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 116 | virtual status_t setVolumeIndexForAttributes(const audio_attributes_t &attr, |
| 117 | int index, |
| 118 | audio_devices_t device); |
| 119 | virtual status_t getVolumeIndexForAttributes(const audio_attributes_t &attr, |
| 120 | int &index, |
| 121 | audio_devices_t device); |
| 122 | virtual status_t getMinVolumeIndexForAttributes(const audio_attributes_t &attr, |
| 123 | int &index); |
| 124 | virtual status_t getMaxVolumeIndexForAttributes(const audio_attributes_t &attr, |
| 125 | int &index); |
| 126 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 127 | virtual uint32_t getStrategyForStream(audio_stream_type_t stream); |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 128 | virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 129 | |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame] | 130 | virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc); |
| 131 | virtual status_t registerEffect(const effect_descriptor_t *desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 132 | audio_io_handle_t io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 133 | uint32_t strategy, |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 134 | audio_session_t session, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 135 | int id); |
| 136 | virtual status_t unregisterEffect(int id); |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 137 | virtual status_t setEffectEnabled(int id, bool enabled); |
Eric Laurent | 6c79632 | 2019-04-09 14:13:17 -0700 | [diff] [blame] | 138 | status_t moveEffectsToIo(const std::vector<int>& ids, audio_io_handle_t io) override; |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 139 | virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const; |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 140 | virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0) const; |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 141 | virtual bool isSourceActive(audio_source_t source) const; |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 142 | |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 143 | virtual status_t queryDefaultPreProcessing(audio_session_t audioSession, |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 144 | effect_descriptor_t *descriptors, |
| 145 | uint32_t *count); |
Ari Hausman-Cohen | 2462831 | 2018-08-13 15:01:09 -0700 | [diff] [blame] | 146 | virtual status_t addSourceDefaultEffect(const effect_uuid_t *type, |
| 147 | const String16& opPackageName, |
| 148 | const effect_uuid_t *uuid, |
| 149 | int32_t priority, |
| 150 | audio_source_t source, |
| 151 | audio_unique_id_t* id); |
Ari Hausman-Cohen | 433722e | 2018-04-24 14:25:22 -0700 | [diff] [blame] | 152 | virtual status_t addStreamDefaultEffect(const effect_uuid_t *type, |
| 153 | const String16& opPackageName, |
| 154 | const effect_uuid_t *uuid, |
| 155 | int32_t priority, |
| 156 | audio_usage_t usage, |
| 157 | audio_unique_id_t* id); |
Ari Hausman-Cohen | 2462831 | 2018-08-13 15:01:09 -0700 | [diff] [blame] | 158 | virtual status_t removeSourceDefaultEffect(audio_unique_id_t id); |
Ari Hausman-Cohen | 433722e | 2018-04-24 14:25:22 -0700 | [diff] [blame] | 159 | virtual status_t removeStreamDefaultEffect(audio_unique_id_t id); |
| 160 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 161 | virtual status_t onTransact( |
| 162 | uint32_t code, |
| 163 | const Parcel& data, |
| 164 | Parcel* reply, |
| 165 | uint32_t flags); |
| 166 | |
| 167 | // IBinder::DeathRecipient |
| 168 | virtual void binderDied(const wp<IBinder>& who); |
| 169 | |
Eric Laurent | f5ada6e | 2014-10-09 17:49:00 -0700 | [diff] [blame] | 170 | // RefBase |
| 171 | virtual void onFirstRef(); |
| 172 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 173 | // |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 174 | // Helpers for the struct audio_policy_service_ops implementation. |
| 175 | // This is used by the audio policy manager for certain operations that |
| 176 | // are implemented by the policy service. |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 177 | // |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 178 | virtual void setParameters(audio_io_handle_t ioHandle, |
| 179 | const char *keyValuePairs, |
| 180 | int delayMs); |
| 181 | |
| 182 | virtual status_t setStreamVolume(audio_stream_type_t stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 183 | float volume, |
| 184 | audio_io_handle_t output, |
| 185 | int delayMs = 0); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 186 | virtual status_t setVoiceVolume(float volume, int delayMs = 0); |
Kevin Rocard | b99cc75 | 2019-03-21 20:52:24 -0700 | [diff] [blame] | 187 | status_t setAllowedCapturePolicy(uint_t uid, audio_flags_mask_t capturePolicy) override; |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 188 | virtual bool isOffloadSupported(const audio_offload_info_t &config); |
Michael Chan | a94fbb2 | 2018-04-24 14:31:19 +1000 | [diff] [blame] | 189 | virtual bool isDirectOutputSupported(const audio_config_base_t& config, |
| 190 | const audio_attributes_t& attributes); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 191 | |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 192 | virtual status_t listAudioPorts(audio_port_role_t role, |
| 193 | audio_port_type_t type, |
| 194 | unsigned int *num_ports, |
| 195 | struct audio_port *ports, |
| 196 | unsigned int *generation); |
| 197 | virtual status_t getAudioPort(struct audio_port *port); |
| 198 | virtual status_t createAudioPatch(const struct audio_patch *patch, |
| 199 | audio_patch_handle_t *handle); |
| 200 | virtual status_t releaseAudioPatch(audio_patch_handle_t handle); |
| 201 | virtual status_t listAudioPatches(unsigned int *num_patches, |
| 202 | struct audio_patch *patches, |
| 203 | unsigned int *generation); |
| 204 | virtual status_t setAudioPortConfig(const struct audio_port_config *config); |
| 205 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 206 | virtual void registerClient(const sp<IAudioPolicyServiceClient>& client); |
| 207 | |
Eric Laurent | e8726fe | 2015-06-26 09:39:24 -0700 | [diff] [blame] | 208 | virtual void setAudioPortCallbacksEnabled(bool enabled); |
| 209 | |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 210 | virtual void setAudioVolumeGroupCallbacksEnabled(bool enabled); |
| 211 | |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 212 | virtual status_t acquireSoundTriggerSession(audio_session_t *session, |
| 213 | audio_io_handle_t *ioHandle, |
| 214 | audio_devices_t *device); |
| 215 | |
| 216 | virtual status_t releaseSoundTriggerSession(audio_session_t session); |
| 217 | |
Eric Laurent | bb6c9a0 | 2014-09-25 14:11:47 -0700 | [diff] [blame] | 218 | virtual audio_mode_t getPhoneState(); |
| 219 | |
Chih-Hung Hsieh | e964d4e | 2016-08-09 14:31:32 -0700 | [diff] [blame] | 220 | virtual status_t registerPolicyMixes(const Vector<AudioMix>& mixes, bool registration); |
Eric Laurent | baac183 | 2014-12-01 17:52:59 -0800 | [diff] [blame] | 221 | |
Jean-Michel Trivi | bda70da | 2018-12-19 07:30:15 -0800 | [diff] [blame] | 222 | virtual status_t setUidDeviceAffinities(uid_t uid, const Vector<AudioDeviceTypeAddr>& devices); |
| 223 | |
| 224 | virtual status_t removeUidDeviceAffinities(uid_t uid); |
| 225 | |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 226 | virtual status_t startAudioSource(const struct audio_port_config *source, |
| 227 | const audio_attributes_t *attributes, |
Eric Laurent | 3e6c7e1 | 2018-07-27 17:09:23 -0700 | [diff] [blame] | 228 | audio_port_handle_t *portId); |
| 229 | virtual status_t stopAudioSource(audio_port_handle_t portId); |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 230 | |
Andy Hung | 2ddee19 | 2015-12-18 17:34:44 -0800 | [diff] [blame] | 231 | virtual status_t setMasterMono(bool mono); |
| 232 | virtual status_t getMasterMono(bool *mono); |
| 233 | |
Eric Laurent | ac9cef5 | 2017-06-09 15:46:26 -0700 | [diff] [blame] | 234 | virtual float getStreamVolumeDB( |
| 235 | audio_stream_type_t stream, int index, audio_devices_t device); |
| 236 | |
jiabin | 8177290 | 2018-04-02 17:52:27 -0700 | [diff] [blame] | 237 | virtual status_t getSurroundFormats(unsigned int *numSurroundFormats, |
| 238 | audio_format_t *surroundFormats, |
| 239 | bool *surroundFormatsEnabled, |
| 240 | bool reported); |
Arun Mirpuri | 11029ad | 2018-12-19 20:45:19 -0800 | [diff] [blame] | 241 | virtual status_t getHwOffloadEncodingFormatsSupportedForA2DP( |
| 242 | std::vector<audio_format_t> *formats); |
jiabin | 8177290 | 2018-04-02 17:52:27 -0700 | [diff] [blame] | 243 | virtual status_t setSurroundFormatEnabled(audio_format_t audioFormat, bool enabled); |
| 244 | |
Eric Laurent | b78763e | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 245 | virtual status_t setAssistantUid(uid_t uid); |
| 246 | virtual status_t setA11yServicesUids(const std::vector<uid_t>& uids); |
| 247 | |
jiabin | 6012f91 | 2018-11-02 17:06:30 -0700 | [diff] [blame] | 248 | virtual bool isHapticPlaybackSupported(); |
| 249 | |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 250 | virtual status_t listAudioProductStrategies(AudioProductStrategyVector &strategies); |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 251 | virtual status_t getProductStrategyFromAudioAttributes(const AudioAttributes &aa, |
| 252 | product_strategy_t &productStrategy); |
| 253 | |
| 254 | virtual status_t listAudioVolumeGroups(AudioVolumeGroupVector &groups); |
| 255 | |
| 256 | virtual status_t getVolumeGroupFromAudioAttributes(const AudioAttributes &aa, |
| 257 | volume_group_t &volumeGroup); |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 258 | |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 259 | status_t doStopOutput(audio_port_handle_t portId); |
| 260 | void doReleaseOutput(audio_port_handle_t portId); |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 261 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 262 | status_t clientCreateAudioPatch(const struct audio_patch *patch, |
| 263 | audio_patch_handle_t *handle, |
| 264 | int delayMs); |
| 265 | status_t clientReleaseAudioPatch(audio_patch_handle_t handle, |
| 266 | int delayMs); |
Eric Laurent | e1715a4 | 2014-05-20 11:30:42 -0700 | [diff] [blame] | 267 | virtual status_t clientSetAudioPortConfig(const struct audio_port_config *config, |
| 268 | int delayMs); |
| 269 | |
luochaojiang | 908c7d7 | 2018-06-21 14:58:04 +0800 | [diff] [blame] | 270 | void removeNotificationClient(uid_t uid, pid_t pid); |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 271 | void onAudioPortListUpdate(); |
| 272 | void doOnAudioPortListUpdate(); |
| 273 | void onAudioPatchListUpdate(); |
| 274 | void doOnAudioPatchListUpdate(); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 275 | |
Chih-Hung Hsieh | e964d4e | 2016-08-09 14:31:32 -0700 | [diff] [blame] | 276 | void onDynamicPolicyMixStateUpdate(const String8& regId, int32_t state); |
| 277 | void doOnDynamicPolicyMixStateUpdate(const String8& regId, int32_t state); |
Eric Laurent | a9f8665 | 2018-11-28 17:23:11 -0800 | [diff] [blame] | 278 | void onRecordingConfigurationUpdate(int event, |
| 279 | const record_client_info_t *clientInfo, |
| 280 | const audio_config_base_t *clientConfig, |
| 281 | std::vector<effect_descriptor_t> clientEffects, |
| 282 | const audio_config_base_t *deviceConfig, |
| 283 | std::vector<effect_descriptor_t> effects, |
| 284 | audio_patch_handle_t patchHandle, |
| 285 | audio_source_t source); |
| 286 | void doOnRecordingConfigurationUpdate(int event, |
| 287 | const record_client_info_t *clientInfo, |
| 288 | const audio_config_base_t *clientConfig, |
| 289 | std::vector<effect_descriptor_t> clientEffects, |
| 290 | const audio_config_base_t *deviceConfig, |
| 291 | std::vector<effect_descriptor_t> effects, |
| 292 | audio_patch_handle_t patchHandle, |
| 293 | audio_source_t source); |
Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 294 | |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 295 | void onAudioVolumeGroupChanged(volume_group_t group, int flags); |
| 296 | void doOnAudioVolumeGroupChanged(volume_group_t group, int flags); |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 297 | void setEffectSuspended(int effectId, |
| 298 | audio_session_t sessionId, |
| 299 | bool suspended); |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 300 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 301 | private: |
Mathias Agopian | e762be9 | 2013-05-09 16:26:45 -0700 | [diff] [blame] | 302 | AudioPolicyService() ANDROID_API; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 303 | virtual ~AudioPolicyService(); |
| 304 | |
| 305 | status_t dumpInternals(int fd); |
| 306 | |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 307 | // Handles binder shell commands |
| 308 | virtual status_t shellCommand(int in, int out, int err, Vector<String16>& args); |
| 309 | |
| 310 | // Sets whether the given UID records only silence |
Eric Laurent | e8c8b43 | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 311 | virtual void setAppState_l(uid_t uid, app_state_t state); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 312 | |
| 313 | // Overrides the UID state as if it is idle |
| 314 | status_t handleSetUidState(Vector<String16>& args, int err); |
| 315 | |
| 316 | // Clears the override for the UID state |
| 317 | status_t handleResetUidState(Vector<String16>& args, int err); |
| 318 | |
| 319 | // Gets the UID state |
| 320 | status_t handleGetUidState(Vector<String16>& args, int out, int err); |
| 321 | |
| 322 | // Prints the shell command help |
| 323 | status_t printHelp(int out); |
| 324 | |
Eric Laurent | 99fcae4 | 2018-05-17 16:59:18 -0700 | [diff] [blame] | 325 | std::string getDeviceTypeStrForPortId(audio_port_handle_t portId); |
| 326 | |
Ari Hausman-Cohen | 2462831 | 2018-08-13 15:01:09 -0700 | [diff] [blame] | 327 | status_t getAudioPolicyEffects(sp<AudioPolicyEffects>& audioPolicyEffects); |
| 328 | |
Eric Laurent | e8c8b43 | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 329 | app_state_t apmStatFromAmState(int amState); |
| 330 | |
| 331 | void updateUidStates(); |
| 332 | void updateUidStates_l(); |
| 333 | |
Michael Groover | cfd2830 | 2018-12-11 19:16:46 -0800 | [diff] [blame] | 334 | void silenceAllRecordings_l(); |
| 335 | |
Eric Laurent | 2dc962b | 2019-03-01 08:25:25 -0800 | [diff] [blame] | 336 | static bool isPrivacySensitiveSource(audio_source_t source); |
| 337 | static bool isVirtualSource(audio_source_t source); |
Eric Laurent | 4eb58f1 | 2018-12-07 16:41:02 -0800 | [diff] [blame] | 338 | |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 339 | // If recording we need to make sure the UID is allowed to do that. If the UID is idle |
| 340 | // then it cannot record and gets buffers with zeros - silence. As soon as the UID |
| 341 | // transitions to an active state we will start reporting buffers with data. This approach |
| 342 | // transparently handles recording while the UID transitions between idle/active state |
| 343 | // avoiding to get stuck in a state receiving non-empty buffers while idle or in a state |
| 344 | // receiving empty buffers while active. |
Mikhail Naganov | eae73eb | 2018-04-03 16:57:36 -0700 | [diff] [blame] | 345 | class UidPolicy : public BnUidObserver, public virtual IBinder::DeathRecipient { |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 346 | public: |
| 347 | explicit UidPolicy(wp<AudioPolicyService> service) |
Eric Laurent | b78763e | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 348 | : mService(service), mObserverRegistered(false), mAssistantUid(0) {} |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 349 | |
| 350 | void registerSelf(); |
| 351 | void unregisterSelf(); |
| 352 | |
Mikhail Naganov | eae73eb | 2018-04-03 16:57:36 -0700 | [diff] [blame] | 353 | // IBinder::DeathRecipient implementation |
| 354 | void binderDied(const wp<IBinder> &who) override; |
| 355 | |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 356 | bool isUidActive(uid_t uid); |
Eric Laurent | e8c8b43 | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 357 | int getUidState(uid_t uid); |
Eric Laurent | b78763e | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 358 | void setAssistantUid(uid_t uid) { mAssistantUid = uid; } |
| 359 | bool isAssistantUid(uid_t uid) { return uid == mAssistantUid; } |
| 360 | void setA11yUids(const std::vector<uid_t>& uids) { mA11yUids.clear(); mA11yUids = uids; } |
| 361 | bool isA11yUid(uid_t uid); |
Eric Laurent | 4eb58f1 | 2018-12-07 16:41:02 -0800 | [diff] [blame] | 362 | bool isA11yOnTop(); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 363 | |
Mikhail Naganov | eae73eb | 2018-04-03 16:57:36 -0700 | [diff] [blame] | 364 | // BnUidObserver implementation |
| 365 | void onUidActive(uid_t uid) override; |
| 366 | void onUidGone(uid_t uid, bool disabled) override; |
| 367 | void onUidIdle(uid_t uid, bool disabled) override; |
Eric Laurent | e8c8b43 | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 368 | void onUidStateChanged(uid_t uid, int32_t procState, int64_t procStateSeq); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 369 | |
Mikhail Naganov | eae73eb | 2018-04-03 16:57:36 -0700 | [diff] [blame] | 370 | void addOverrideUid(uid_t uid, bool active) { updateOverrideUid(uid, active, true); } |
| 371 | void removeOverrideUid(uid_t uid) { updateOverrideUid(uid, false, false); } |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 372 | |
Eric Laurent | e8c8b43 | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 373 | void updateUid(std::unordered_map<uid_t, std::pair<bool, int>> *uids, |
| 374 | uid_t uid, bool active, int state, bool insert); |
| 375 | |
| 376 | private: |
| 377 | void notifyService(); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 378 | void updateOverrideUid(uid_t uid, bool active, bool insert); |
Eric Laurent | e8c8b43 | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 379 | void updateUidLocked(std::unordered_map<uid_t, std::pair<bool, int>> *uids, |
| 380 | uid_t uid, bool active, int state, bool insert); |
| 381 | void checkRegistered(); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 382 | |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 383 | wp<AudioPolicyService> mService; |
Mikhail Naganov | eae73eb | 2018-04-03 16:57:36 -0700 | [diff] [blame] | 384 | Mutex mLock; |
| 385 | bool mObserverRegistered; |
Eric Laurent | e8c8b43 | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 386 | std::unordered_map<uid_t, std::pair<bool, int>> mOverrideUids; |
| 387 | std::unordered_map<uid_t, std::pair<bool, int>> mCachedUids; |
Eric Laurent | b78763e | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 388 | uid_t mAssistantUid; |
| 389 | std::vector<uid_t> mA11yUids; |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 390 | }; |
| 391 | |
Michael Groover | cfd2830 | 2018-12-11 19:16:46 -0800 | [diff] [blame] | 392 | // If sensor privacy is enabled then all apps, including those that are active, should be |
| 393 | // prevented from recording. This is handled similar to idle UIDs, any app that attempts |
| 394 | // to record while sensor privacy is enabled will receive buffers with zeros. As soon as |
| 395 | // sensor privacy is disabled active apps will receive the expected data when recording. |
| 396 | class SensorPrivacyPolicy : public hardware::BnSensorPrivacyListener { |
| 397 | public: |
| 398 | explicit SensorPrivacyPolicy(wp<AudioPolicyService> service) |
| 399 | : mService(service) {} |
| 400 | |
| 401 | void registerSelf(); |
| 402 | void unregisterSelf(); |
| 403 | |
| 404 | bool isSensorPrivacyEnabled(); |
| 405 | |
| 406 | binder::Status onSensorPrivacyChanged(bool enabled); |
| 407 | |
| 408 | private: |
| 409 | wp<AudioPolicyService> mService; |
| 410 | std::atomic_bool mSensorPrivacyEnabled; |
| 411 | }; |
| 412 | |
Eric Laurent | dcd4ab1 | 2018-06-29 17:45:13 -0700 | [diff] [blame] | 413 | // Thread used to send audio config commands to audio flinger |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 414 | // For audio config commands, it is necessary because audio flinger requires that the calling |
| 415 | // process (user) has permission to modify audio settings. |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 416 | class AudioCommandThread : public Thread { |
| 417 | class AudioCommand; |
| 418 | public: |
| 419 | |
| 420 | // commands for tone AudioCommand |
| 421 | enum { |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 422 | SET_VOLUME, |
| 423 | SET_PARAMETERS, |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 424 | SET_VOICE_VOLUME, |
| 425 | STOP_OUTPUT, |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 426 | RELEASE_OUTPUT, |
| 427 | CREATE_AUDIO_PATCH, |
| 428 | RELEASE_AUDIO_PATCH, |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 429 | UPDATE_AUDIOPORT_LIST, |
Eric Laurent | e1715a4 | 2014-05-20 11:30:42 -0700 | [diff] [blame] | 430 | UPDATE_AUDIOPATCH_LIST, |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 431 | CHANGED_AUDIOVOLUMEGROUP, |
Eric Laurent | e1715a4 | 2014-05-20 11:30:42 -0700 | [diff] [blame] | 432 | SET_AUDIOPORT_CONFIG, |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 433 | DYN_POLICY_MIX_STATE_UPDATE, |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 434 | RECORDING_CONFIGURATION_UPDATE, |
| 435 | SET_EFFECT_SUSPENDED, |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 436 | }; |
| 437 | |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 438 | AudioCommandThread (String8 name, const wp<AudioPolicyService>& service); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 439 | virtual ~AudioCommandThread(); |
| 440 | |
| 441 | status_t dump(int fd); |
| 442 | |
| 443 | // Thread virtuals |
| 444 | virtual void onFirstRef(); |
| 445 | virtual bool threadLoop(); |
| 446 | |
| 447 | void exit(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 448 | status_t volumeCommand(audio_stream_type_t stream, float volume, |
| 449 | audio_io_handle_t output, int delayMs = 0); |
| 450 | status_t parametersCommand(audio_io_handle_t ioHandle, |
| 451 | const char *keyValuePairs, int delayMs = 0); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 452 | status_t voiceVolumeCommand(float volume, int delayMs = 0); |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 453 | void stopOutputCommand(audio_port_handle_t portId); |
| 454 | void releaseOutputCommand(audio_port_handle_t portId); |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 455 | status_t sendCommand(sp<AudioCommand>& command, int delayMs = 0); |
| 456 | void insertCommand_l(sp<AudioCommand>& command, int delayMs = 0); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 457 | status_t createAudioPatchCommand(const struct audio_patch *patch, |
| 458 | audio_patch_handle_t *handle, |
| 459 | int delayMs); |
| 460 | status_t releaseAudioPatchCommand(audio_patch_handle_t handle, |
| 461 | int delayMs); |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 462 | void updateAudioPortListCommand(); |
| 463 | void updateAudioPatchListCommand(); |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 464 | void changeAudioVolumeGroupCommand(volume_group_t group, int flags); |
Eric Laurent | e1715a4 | 2014-05-20 11:30:42 -0700 | [diff] [blame] | 465 | status_t setAudioPortConfigCommand(const struct audio_port_config *config, |
| 466 | int delayMs); |
Eric Laurent | a9f8665 | 2018-11-28 17:23:11 -0800 | [diff] [blame] | 467 | void dynamicPolicyMixStateUpdateCommand(const String8& regId, |
| 468 | int32_t state); |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 469 | void recordingConfigurationUpdateCommand( |
Eric Laurent | a9f8665 | 2018-11-28 17:23:11 -0800 | [diff] [blame] | 470 | int event, |
| 471 | const record_client_info_t *clientInfo, |
| 472 | const audio_config_base_t *clientConfig, |
| 473 | std::vector<effect_descriptor_t> clientEffects, |
| 474 | const audio_config_base_t *deviceConfig, |
| 475 | std::vector<effect_descriptor_t> effects, |
| 476 | audio_patch_handle_t patchHandle, |
| 477 | audio_source_t source); |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 478 | void setEffectSuspendedCommand(int effectId, |
| 479 | audio_session_t sessionId, |
| 480 | bool suspended); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 481 | void insertCommand_l(AudioCommand *command, int delayMs = 0); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 482 | private: |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 483 | class AudioCommandData; |
| 484 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 485 | // descriptor for requested tone playback event |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 486 | class AudioCommand: public RefBase { |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 487 | |
| 488 | public: |
| 489 | AudioCommand() |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 490 | : mCommand(-1), mStatus(NO_ERROR), mWaitStatus(false) {} |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 491 | |
| 492 | void dump(char* buffer, size_t size); |
| 493 | |
Eric Laurent | dcd4ab1 | 2018-06-29 17:45:13 -0700 | [diff] [blame] | 494 | int mCommand; // SET_VOLUME, SET_PARAMETERS... |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 495 | nsecs_t mTime; // time stamp |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 496 | Mutex mLock; // mutex associated to mCond |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 497 | Condition mCond; // condition for status return |
| 498 | status_t mStatus; // command status |
| 499 | bool mWaitStatus; // true if caller is waiting for status |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 500 | sp<AudioCommandData> mParam; // command specific parameter data |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 501 | }; |
| 502 | |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 503 | class AudioCommandData: public RefBase { |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 504 | public: |
| 505 | virtual ~AudioCommandData() {} |
| 506 | protected: |
| 507 | AudioCommandData() {} |
| 508 | }; |
| 509 | |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 510 | class VolumeData : public AudioCommandData { |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 511 | public: |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 512 | audio_stream_type_t mStream; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 513 | float mVolume; |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 514 | audio_io_handle_t mIO; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 515 | }; |
| 516 | |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 517 | class ParametersData : public AudioCommandData { |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 518 | public: |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 519 | audio_io_handle_t mIO; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 520 | String8 mKeyValuePairs; |
| 521 | }; |
| 522 | |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 523 | class VoiceVolumeData : public AudioCommandData { |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 524 | public: |
| 525 | float mVolume; |
| 526 | }; |
| 527 | |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 528 | class StopOutputData : public AudioCommandData { |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 529 | public: |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 530 | audio_port_handle_t mPortId; |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 531 | }; |
| 532 | |
Jesper Tragardh | 48412dc | 2014-03-24 14:12:43 +0100 | [diff] [blame] | 533 | class ReleaseOutputData : public AudioCommandData { |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 534 | public: |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 535 | audio_port_handle_t mPortId; |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 536 | }; |
| 537 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 538 | class CreateAudioPatchData : public AudioCommandData { |
| 539 | public: |
| 540 | struct audio_patch mPatch; |
| 541 | audio_patch_handle_t mHandle; |
| 542 | }; |
| 543 | |
| 544 | class ReleaseAudioPatchData : public AudioCommandData { |
| 545 | public: |
| 546 | audio_patch_handle_t mHandle; |
| 547 | }; |
| 548 | |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 549 | class AudioVolumeGroupData : public AudioCommandData { |
| 550 | public: |
| 551 | volume_group_t mGroup; |
| 552 | int mFlags; |
| 553 | }; |
| 554 | |
Eric Laurent | e1715a4 | 2014-05-20 11:30:42 -0700 | [diff] [blame] | 555 | class SetAudioPortConfigData : public AudioCommandData { |
| 556 | public: |
| 557 | struct audio_port_config mConfig; |
| 558 | }; |
| 559 | |
Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 560 | class DynPolicyMixStateUpdateData : public AudioCommandData { |
| 561 | public: |
| 562 | String8 mRegId; |
| 563 | int32_t mState; |
| 564 | }; |
| 565 | |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 566 | class RecordingConfigurationUpdateData : public AudioCommandData { |
| 567 | public: |
| 568 | int mEvent; |
Jean-Michel Trivi | ac4e429 | 2016-12-22 11:39:31 -0800 | [diff] [blame] | 569 | record_client_info_t mClientInfo; |
Jean-Michel Trivi | 7281aa9 | 2016-02-17 15:33:40 -0800 | [diff] [blame] | 570 | struct audio_config_base mClientConfig; |
Eric Laurent | a9f8665 | 2018-11-28 17:23:11 -0800 | [diff] [blame] | 571 | std::vector<effect_descriptor_t> mClientEffects; |
Jean-Michel Trivi | 7281aa9 | 2016-02-17 15:33:40 -0800 | [diff] [blame] | 572 | struct audio_config_base mDeviceConfig; |
Eric Laurent | a9f8665 | 2018-11-28 17:23:11 -0800 | [diff] [blame] | 573 | std::vector<effect_descriptor_t> mEffects; |
Jean-Michel Trivi | 8c7cf3b | 2016-02-25 17:08:24 -0800 | [diff] [blame] | 574 | audio_patch_handle_t mPatchHandle; |
Eric Laurent | a9f8665 | 2018-11-28 17:23:11 -0800 | [diff] [blame] | 575 | audio_source_t mSource; |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 576 | }; |
| 577 | |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 578 | class SetEffectSuspendedData : public AudioCommandData { |
| 579 | public: |
| 580 | int mEffectId; |
| 581 | audio_session_t mSessionId; |
| 582 | bool mSuspended; |
| 583 | }; |
| 584 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 585 | Mutex mLock; |
| 586 | Condition mWaitWorkCV; |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 587 | Vector < sp<AudioCommand> > mAudioCommands; // list of pending commands |
Eric Laurent | 0ede892 | 2014-05-09 18:04:42 -0700 | [diff] [blame] | 588 | sp<AudioCommand> mLastCommand; // last processed command (used by dump) |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 589 | String8 mName; // string used by wake lock fo delayed commands |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 590 | wp<AudioPolicyService> mService; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 591 | }; |
| 592 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 593 | class AudioPolicyClient : public AudioPolicyClientInterface |
| 594 | { |
| 595 | public: |
Chih-Hung Hsieh | e964d4e | 2016-08-09 14:31:32 -0700 | [diff] [blame] | 596 | explicit AudioPolicyClient(AudioPolicyService *service) : mAudioPolicyService(service) {} |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 597 | virtual ~AudioPolicyClient() {} |
| 598 | |
| 599 | // |
| 600 | // Audio HW module functions |
| 601 | // |
| 602 | |
| 603 | // loads a HW module. |
| 604 | virtual audio_module_handle_t loadHwModule(const char *name); |
| 605 | |
| 606 | // |
| 607 | // Audio output Control functions |
| 608 | // |
| 609 | |
| 610 | // opens an audio output with the requested parameters. The parameter values can indicate to use the default values |
| 611 | // in case the audio policy manager has no specific requirements for the output being opened. |
| 612 | // When the function returns, the parameter values reflect the actual values used by the audio hardware output stream. |
| 613 | // The audio policy manager can check if the proposed parameters are suitable or not and act accordingly. |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 614 | virtual status_t openOutput(audio_module_handle_t module, |
| 615 | audio_io_handle_t *output, |
| 616 | audio_config_t *config, |
| 617 | audio_devices_t *devices, |
| 618 | const String8& address, |
| 619 | uint32_t *latencyMs, |
| 620 | audio_output_flags_t flags); |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 621 | // creates a special output that is duplicated to the two outputs passed as arguments. The duplication is performed by |
| 622 | // a special mixer thread in the AudioFlinger. |
| 623 | virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1, audio_io_handle_t output2); |
| 624 | // closes the output stream |
| 625 | virtual status_t closeOutput(audio_io_handle_t output); |
| 626 | // suspends the output. When an output is suspended, the corresponding audio hardware output stream is placed in |
| 627 | // standby and the AudioTracks attached to the mixer thread are still processed but the output mix is discarded. |
| 628 | virtual status_t suspendOutput(audio_io_handle_t output); |
| 629 | // restores a suspended output. |
| 630 | virtual status_t restoreOutput(audio_io_handle_t output); |
| 631 | |
| 632 | // |
| 633 | // Audio input Control functions |
| 634 | // |
| 635 | |
| 636 | // opens an audio input |
| 637 | virtual audio_io_handle_t openInput(audio_module_handle_t module, |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 638 | audio_io_handle_t *input, |
| 639 | audio_config_t *config, |
| 640 | audio_devices_t *devices, |
| 641 | const String8& address, |
| 642 | audio_source_t source, |
Glenn Kasten | ec40d28 | 2014-07-15 15:31:26 -0700 | [diff] [blame] | 643 | audio_input_flags_t flags); |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 644 | // closes an audio input |
| 645 | virtual status_t closeInput(audio_io_handle_t input); |
| 646 | // |
| 647 | // misc control functions |
| 648 | // |
| 649 | |
| 650 | // set a stream volume for a particular output. For the same user setting, a given stream type can have different volumes |
| 651 | // for each output (destination device) it is attached to. |
| 652 | virtual status_t setStreamVolume(audio_stream_type_t stream, float volume, audio_io_handle_t output, int delayMs = 0); |
| 653 | |
| 654 | // invalidate a stream type, causing a reroute to an unspecified new output |
| 655 | virtual status_t invalidateStream(audio_stream_type_t stream); |
| 656 | |
| 657 | // function enabling to send proprietary informations directly from audio policy manager to audio hardware interface. |
| 658 | virtual void setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs, int delayMs = 0); |
| 659 | // function enabling to receive proprietary informations directly from audio hardware interface to audio policy manager. |
| 660 | virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys); |
| 661 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 662 | // set down link audio volume. |
| 663 | virtual status_t setVoiceVolume(float volume, int delayMs = 0); |
| 664 | |
| 665 | // move effect to the specified output |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 666 | virtual status_t moveEffects(audio_session_t session, |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 667 | audio_io_handle_t srcOutput, |
| 668 | audio_io_handle_t dstOutput); |
| 669 | |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 670 | void setEffectSuspended(int effectId, |
| 671 | audio_session_t sessionId, |
| 672 | bool suspended) override; |
| 673 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 674 | /* Create a patch between several source and sink ports */ |
| 675 | virtual status_t createAudioPatch(const struct audio_patch *patch, |
| 676 | audio_patch_handle_t *handle, |
| 677 | int delayMs); |
| 678 | |
| 679 | /* Release a patch */ |
| 680 | virtual status_t releaseAudioPatch(audio_patch_handle_t handle, |
| 681 | int delayMs); |
| 682 | |
Eric Laurent | e1715a4 | 2014-05-20 11:30:42 -0700 | [diff] [blame] | 683 | /* Set audio port configuration */ |
| 684 | virtual status_t setAudioPortConfig(const struct audio_port_config *config, int delayMs); |
| 685 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 686 | virtual void onAudioPortListUpdate(); |
| 687 | virtual void onAudioPatchListUpdate(); |
Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 688 | virtual void onDynamicPolicyMixStateUpdate(String8 regId, int32_t state); |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 689 | virtual void onRecordingConfigurationUpdate(int event, |
Eric Laurent | a9f8665 | 2018-11-28 17:23:11 -0800 | [diff] [blame] | 690 | const record_client_info_t *clientInfo, |
| 691 | const audio_config_base_t *clientConfig, |
| 692 | std::vector<effect_descriptor_t> clientEffects, |
| 693 | const audio_config_base_t *deviceConfig, |
| 694 | std::vector<effect_descriptor_t> effects, |
| 695 | audio_patch_handle_t patchHandle, |
| 696 | audio_source_t source); |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 697 | |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 698 | virtual void onAudioVolumeGroupChanged(volume_group_t group, int flags); |
| 699 | |
Glenn Kasten | eeecb98 | 2016-02-26 10:44:04 -0800 | [diff] [blame] | 700 | virtual audio_unique_id_t newAudioUniqueId(audio_unique_id_use_t use); |
Eric Laurent | de3f839 | 2014-07-27 18:38:22 -0700 | [diff] [blame] | 701 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 702 | private: |
| 703 | AudioPolicyService *mAudioPolicyService; |
| 704 | }; |
| 705 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 706 | // --- Notification Client --- |
| 707 | class NotificationClient : public IBinder::DeathRecipient { |
| 708 | public: |
| 709 | NotificationClient(const sp<AudioPolicyService>& service, |
| 710 | const sp<IAudioPolicyServiceClient>& client, |
luochaojiang | 908c7d7 | 2018-06-21 14:58:04 +0800 | [diff] [blame] | 711 | uid_t uid, pid_t pid); |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 712 | virtual ~NotificationClient(); |
| 713 | |
Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 714 | void onAudioPortListUpdate(); |
| 715 | void onAudioPatchListUpdate(); |
Eric Laurent | a9f8665 | 2018-11-28 17:23:11 -0800 | [diff] [blame] | 716 | void onDynamicPolicyMixStateUpdate(const String8& regId, |
| 717 | int32_t state); |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 718 | void onAudioVolumeGroupChanged(volume_group_t group, int flags); |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 719 | void onRecordingConfigurationUpdate( |
Eric Laurent | a9f8665 | 2018-11-28 17:23:11 -0800 | [diff] [blame] | 720 | int event, |
| 721 | const record_client_info_t *clientInfo, |
| 722 | const audio_config_base_t *clientConfig, |
| 723 | std::vector<effect_descriptor_t> clientEffects, |
| 724 | const audio_config_base_t *deviceConfig, |
| 725 | std::vector<effect_descriptor_t> effects, |
| 726 | audio_patch_handle_t patchHandle, |
| 727 | audio_source_t source); |
Eric Laurent | e8726fe | 2015-06-26 09:39:24 -0700 | [diff] [blame] | 728 | void setAudioPortCallbacksEnabled(bool enabled); |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 729 | void setAudioVolumeGroupCallbacksEnabled(bool enabled); |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 730 | |
luochaojiang | 908c7d7 | 2018-06-21 14:58:04 +0800 | [diff] [blame] | 731 | uid_t uid() { |
| 732 | return mUid; |
| 733 | } |
| 734 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 735 | // IBinder::DeathRecipient |
| 736 | virtual void binderDied(const wp<IBinder>& who); |
| 737 | |
| 738 | private: |
| 739 | NotificationClient(const NotificationClient&); |
| 740 | NotificationClient& operator = (const NotificationClient&); |
| 741 | |
| 742 | const wp<AudioPolicyService> mService; |
| 743 | const uid_t mUid; |
luochaojiang | 908c7d7 | 2018-06-21 14:58:04 +0800 | [diff] [blame] | 744 | const pid_t mPid; |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 745 | const sp<IAudioPolicyServiceClient> mAudioPolicyServiceClient; |
Eric Laurent | e8726fe | 2015-06-26 09:39:24 -0700 | [diff] [blame] | 746 | bool mAudioPortCallbacksEnabled; |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 747 | bool mAudioVolumeGroupCallbacksEnabled; |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 748 | }; |
| 749 | |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 750 | class AudioClient : public virtual RefBase { |
| 751 | public: |
| 752 | AudioClient(const audio_attributes_t attributes, |
| 753 | const audio_io_handle_t io, uid_t uid, pid_t pid, |
| 754 | const audio_session_t session, const audio_port_handle_t deviceId) : |
| 755 | attributes(attributes), io(io), uid(uid), pid(pid), |
| 756 | session(session), deviceId(deviceId), active(false) {} |
| 757 | ~AudioClient() override = default; |
| 758 | |
| 759 | |
| 760 | const audio_attributes_t attributes; // source, flags ... |
| 761 | const audio_io_handle_t io; // audio HAL stream IO handle |
| 762 | const uid_t uid; // client UID |
| 763 | const pid_t pid; // client PID |
| 764 | const audio_session_t session; // audio session ID |
| 765 | const audio_port_handle_t deviceId; // selected input device port ID |
| 766 | bool active; // Playback/Capture is active or inactive |
| 767 | }; |
| 768 | |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 769 | // --- AudioRecordClient --- |
| 770 | // Information about each registered AudioRecord client |
| 771 | // (between calls to getInputForAttr() and releaseInput()) |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 772 | class AudioRecordClient : public AudioClient { |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 773 | public: |
| 774 | AudioRecordClient(const audio_attributes_t attributes, |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 775 | const audio_io_handle_t io, uid_t uid, pid_t pid, |
| 776 | const audio_session_t session, const audio_port_handle_t deviceId, |
Eric Laurent | 1ff16a7 | 2019-03-14 18:35:04 -0700 | [diff] [blame] | 777 | const String16& opPackageName, |
| 778 | bool canCaptureOutput, bool canCaptureHotword) : |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 779 | AudioClient(attributes, io, uid, pid, session, deviceId), |
Eric Laurent | 1ff16a7 | 2019-03-14 18:35:04 -0700 | [diff] [blame] | 780 | opPackageName(opPackageName), startTimeNs(0), |
| 781 | canCaptureOutput(canCaptureOutput), canCaptureHotword(canCaptureHotword) {} |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 782 | ~AudioRecordClient() override = default; |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 783 | |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 784 | const String16 opPackageName; // client package name |
Eric Laurent | 4eb58f1 | 2018-12-07 16:41:02 -0800 | [diff] [blame] | 785 | nsecs_t startTimeNs; |
Eric Laurent | 1ff16a7 | 2019-03-14 18:35:04 -0700 | [diff] [blame] | 786 | const bool canCaptureOutput; |
| 787 | const bool canCaptureHotword; |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 788 | }; |
| 789 | |
| 790 | // --- AudioPlaybackClient --- |
| 791 | // Information about each registered AudioTrack client |
| 792 | // (between calls to getOutputForAttr() and releaseOutput()) |
| 793 | class AudioPlaybackClient : public AudioClient { |
| 794 | public: |
| 795 | AudioPlaybackClient(const audio_attributes_t attributes, |
| 796 | const audio_io_handle_t io, uid_t uid, pid_t pid, |
| 797 | const audio_session_t session, audio_port_handle_t deviceId, |
| 798 | audio_stream_type_t stream) : |
| 799 | AudioClient(attributes, io, uid, pid, session, deviceId), stream(stream) {} |
| 800 | ~AudioPlaybackClient() override = default; |
| 801 | |
| 802 | const audio_stream_type_t stream; |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 803 | }; |
| 804 | |
Eric Laurent | bcfe5be | 2019-04-09 19:56:39 -0700 | [diff] [blame] | 805 | void getPlaybackClientAndEffects(audio_port_handle_t portId, |
| 806 | sp<AudioPlaybackClient>& client, |
| 807 | sp<AudioPolicyEffects>& effects, |
| 808 | const char *context); |
| 809 | |
| 810 | |
Eric Laurent | 10b7123 | 2018-04-13 18:14:44 -0700 | [diff] [blame] | 811 | // A class automatically clearing and restoring binder caller identity inside |
| 812 | // a code block (scoped variable) |
| 813 | // Declare one systematically before calling AudioPolicyManager methods so that they are |
| 814 | // executed with the same level of privilege as audioserver process. |
| 815 | class AutoCallerClear { |
| 816 | public: |
| 817 | AutoCallerClear() : |
| 818 | mToken(IPCThreadState::self()->clearCallingIdentity()) {} |
| 819 | ~AutoCallerClear() { |
| 820 | IPCThreadState::self()->restoreCallingIdentity(mToken); |
| 821 | } |
| 822 | |
| 823 | private: |
| 824 | const int64_t mToken; |
| 825 | }; |
| 826 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 827 | // Internal dump utilities. |
| 828 | status_t dumpPermissionDenial(int fd); |
| 829 | |
| 830 | |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 831 | mutable Mutex mLock; // prevents concurrent access to AudioPolicy manager functions changing |
| 832 | // device connection state or routing |
Haynes Mathew George | bab7bf4 | 2015-10-30 18:02:23 -0700 | [diff] [blame] | 833 | // Note: lock acquisition order is always mLock > mEffectsLock: |
| 834 | // mLock protects AudioPolicyManager methods that can call into audio flinger |
| 835 | // and possibly back in to audio policy service and acquire mEffectsLock. |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 836 | sp<AudioCommandThread> mAudioCommandThread; // audio commands thread |
Eric Laurent | bfb1b83 | 2013-01-07 09:53:42 -0800 | [diff] [blame] | 837 | sp<AudioCommandThread> mOutputCommandThread; // process stop and release output |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 838 | struct audio_policy_device *mpAudioPolicyDev; |
| 839 | struct audio_policy *mpAudioPolicy; |
Eric Laurent | f269b8e | 2014-06-09 20:01:29 -0700 | [diff] [blame] | 840 | AudioPolicyInterface *mAudioPolicyManager; |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 841 | AudioPolicyClient *mAudioPolicyClient; |
| 842 | |
luochaojiang | 908c7d7 | 2018-06-21 14:58:04 +0800 | [diff] [blame] | 843 | DefaultKeyedVector< int64_t, sp<NotificationClient> > mNotificationClients; |
Eric Laurent | 0ebd5f9 | 2014-11-19 19:04:52 -0800 | [diff] [blame] | 844 | Mutex mNotificationClientsLock; // protects mNotificationClients |
bryant_liu | ba2b439 | 2014-06-11 16:49:30 +0800 | [diff] [blame] | 845 | // Manage all effects configured in audio_effects.conf |
Eric Laurent | 6c79632 | 2019-04-09 14:13:17 -0700 | [diff] [blame] | 846 | // never hold AudioPolicyService::mLock when calling AudioPolicyEffects methods as |
| 847 | // those can call back into AudioPolicyService methods and try to acquire the mutex |
bryant_liu | ba2b439 | 2014-06-11 16:49:30 +0800 | [diff] [blame] | 848 | sp<AudioPolicyEffects> mAudioPolicyEffects; |
Eric Laurent | bb6c9a0 | 2014-09-25 14:11:47 -0700 | [diff] [blame] | 849 | audio_mode_t mPhoneState; |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 850 | |
| 851 | sp<UidPolicy> mUidPolicy; |
Michael Groover | cfd2830 | 2018-12-11 19:16:46 -0800 | [diff] [blame] | 852 | sp<SensorPrivacyPolicy> mSensorPrivacyPolicy; |
| 853 | |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 854 | DefaultKeyedVector< audio_port_handle_t, sp<AudioRecordClient> > mAudioRecordClients; |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 855 | DefaultKeyedVector< audio_port_handle_t, sp<AudioPlaybackClient> > mAudioPlaybackClients; |
Kevin Rocard | 8be9497 | 2019-02-22 13:26:25 -0800 | [diff] [blame] | 856 | |
| 857 | MediaPackageManager mPackageManager; // To check allowPlaybackCapture |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 858 | }; |
| 859 | |
Mikhail Naganov | 1b2a794 | 2017-12-08 10:18:09 -0800 | [diff] [blame] | 860 | } // namespace android |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 861 | |
| 862 | #endif // ANDROID_AUDIOPOLICYSERVICE_H |