Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2009, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #define LOG_TAG "IAudioPolicyService" |
| 19 | #include <utils/Log.h> |
| 20 | |
| 21 | #include <stdint.h> |
Eric Laurent | ac9cef5 | 2017-06-09 15:46:26 -0700 | [diff] [blame] | 22 | #include <math.h> |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 23 | #include <sys/types.h> |
| 24 | |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 25 | #include <binder/IPCThreadState.h> |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 26 | #include <binder/Parcel.h> |
Eric Laurent | 74adca9 | 2014-11-05 12:15:36 -0800 | [diff] [blame] | 27 | #include <media/AudioEffect.h> |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 28 | #include <media/IAudioPolicyService.h> |
Andy Hung | 4ef19fa | 2018-05-15 19:35:29 -0700 | [diff] [blame] | 29 | #include <mediautils/ServiceUtilities.h> |
Marco Nelissen | cf90b49 | 2019-09-26 11:20:54 -0700 | [diff] [blame] | 30 | #include <mediautils/TimeCheck.h> |
Dima Zavin | 6476024 | 2011-05-11 14:15:23 -0700 | [diff] [blame] | 31 | #include <system/audio.h> |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 32 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 33 | namespace android { |
| 34 | |
| 35 | enum { |
| 36 | SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION, |
| 37 | GET_DEVICE_CONNECTION_STATE, |
Pavlin Radoslavov | f862bc6 | 2016-12-26 18:57:22 -0800 | [diff] [blame] | 38 | HANDLE_DEVICE_CONFIG_CHANGE, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 39 | SET_PHONE_STATE, |
Glenn Kasten | 0b07b80 | 2012-01-18 14:56:06 -0800 | [diff] [blame] | 40 | SET_RINGER_MODE, // reserved, no longer used |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 41 | SET_FORCE_USE, |
| 42 | GET_FORCE_USE, |
| 43 | GET_OUTPUT, |
| 44 | START_OUTPUT, |
| 45 | STOP_OUTPUT, |
| 46 | RELEASE_OUTPUT, |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 47 | GET_INPUT_FOR_ATTR, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 48 | START_INPUT, |
| 49 | STOP_INPUT, |
| 50 | RELEASE_INPUT, |
| 51 | INIT_STREAM_VOLUME, |
| 52 | SET_STREAM_VOLUME, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 53 | GET_STREAM_VOLUME, |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 54 | SET_VOLUME_ATTRIBUTES, |
| 55 | GET_VOLUME_ATTRIBUTES, |
| 56 | GET_MIN_VOLUME_FOR_ATTRIBUTES, |
| 57 | GET_MAX_VOLUME_FOR_ATTRIBUTES, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 58 | GET_STRATEGY_FOR_STREAM, |
| 59 | GET_OUTPUT_FOR_EFFECT, |
| 60 | REGISTER_EFFECT, |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 61 | UNREGISTER_EFFECT, |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 62 | IS_STREAM_ACTIVE, |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 63 | IS_SOURCE_ACTIVE, |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 64 | GET_DEVICES_FOR_STREAM, |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 65 | QUERY_DEFAULT_PRE_PROCESSING, |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 66 | SET_EFFECT_ENABLED, |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 67 | IS_STREAM_ACTIVE_REMOTELY, |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 68 | IS_OFFLOAD_SUPPORTED, |
Michael Chan | a94fbb2 | 2018-04-24 14:31:19 +1000 | [diff] [blame] | 69 | IS_DIRECT_OUTPUT_SUPPORTED, |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 70 | LIST_AUDIO_PORTS, |
| 71 | GET_AUDIO_PORT, |
| 72 | CREATE_AUDIO_PATCH, |
| 73 | RELEASE_AUDIO_PATCH, |
| 74 | LIST_AUDIO_PATCHES, |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 75 | SET_AUDIO_PORT_CONFIG, |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 76 | REGISTER_CLIENT, |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 77 | GET_OUTPUT_FOR_ATTR, |
| 78 | ACQUIRE_SOUNDTRIGGER_SESSION, |
Eric Laurent | bb6c9a0 | 2014-09-25 14:11:47 -0700 | [diff] [blame] | 79 | RELEASE_SOUNDTRIGGER_SESSION, |
Eric Laurent | baac183 | 2014-12-01 17:52:59 -0800 | [diff] [blame] | 80 | GET_PHONE_STATE, |
| 81 | REGISTER_POLICY_MIXES, |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 82 | START_AUDIO_SOURCE, |
Eric Laurent | e8726fe | 2015-06-26 09:39:24 -0700 | [diff] [blame] | 83 | STOP_AUDIO_SOURCE, |
| 84 | SET_AUDIO_PORT_CALLBACK_ENABLED, |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 85 | SET_AUDIO_VOLUME_GROUP_CALLBACK_ENABLED, |
Andy Hung | 2ddee19 | 2015-12-18 17:34:44 -0800 | [diff] [blame] | 86 | SET_MASTER_MONO, |
| 87 | GET_MASTER_MONO, |
jiabin | 8177290 | 2018-04-02 17:52:27 -0700 | [diff] [blame] | 88 | GET_STREAM_VOLUME_DB, |
| 89 | GET_SURROUND_FORMATS, |
Ari Hausman-Cohen | 433722e | 2018-04-24 14:25:22 -0700 | [diff] [blame] | 90 | SET_SURROUND_FORMAT_ENABLED, |
| 91 | ADD_STREAM_DEFAULT_EFFECT, |
Ari Hausman-Cohen | 2462831 | 2018-08-13 15:01:09 -0700 | [diff] [blame] | 92 | REMOVE_STREAM_DEFAULT_EFFECT, |
| 93 | ADD_SOURCE_DEFAULT_EFFECT, |
Eric Laurent | b78763e | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 94 | REMOVE_SOURCE_DEFAULT_EFFECT, |
| 95 | SET_ASSISTANT_UID, |
| 96 | SET_A11Y_SERVICES_UIDS, |
jiabin | 6012f91 | 2018-11-02 17:06:30 -0700 | [diff] [blame] | 97 | IS_HAPTIC_PLAYBACK_SUPPORTED, |
Jean-Michel Trivi | bda70da | 2018-12-19 07:30:15 -0800 | [diff] [blame] | 98 | SET_UID_DEVICE_AFFINITY, |
| 99 | REMOVE_UID_DEVICE_AFFINITY, |
Oscar Azucena | 90e7763 | 2019-11-27 17:12:28 -0800 | [diff] [blame] | 100 | SET_USERID_DEVICE_AFFINITY, |
| 101 | REMOVE_USERID_DEVICE_AFFINITY, |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 102 | GET_OFFLOAD_FORMATS_A2DP, |
| 103 | LIST_AUDIO_PRODUCT_STRATEGIES, |
| 104 | GET_STRATEGY_FOR_ATTRIBUTES, |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 105 | LIST_AUDIO_VOLUME_GROUPS, |
Kevin Rocard | b99cc75 | 2019-03-21 20:52:24 -0700 | [diff] [blame] | 106 | GET_VOLUME_GROUP_FOR_ATTRIBUTES, |
Hayden Gomes | 524159d | 2019-12-23 14:41:47 -0800 | [diff] [blame] | 107 | SET_SUPPORTED_SYSTEM_USAGES, |
Kevin Rocard | b99cc75 | 2019-03-21 20:52:24 -0700 | [diff] [blame] | 108 | SET_ALLOWED_CAPTURE_POLICY, |
Eric Laurent | 6c79632 | 2019-04-09 14:13:17 -0700 | [diff] [blame] | 109 | MOVE_EFFECTS_TO_IO, |
Eric Laurent | 8340e67 | 2019-11-06 11:01:08 -0800 | [diff] [blame] | 110 | SET_RTT_ENABLED, |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 111 | IS_CALL_SCREEN_MODE_SUPPORTED, |
| 112 | SET_PREFERRED_DEVICE_FOR_PRODUCT_STRATEGY, |
| 113 | REMOVE_PREFERRED_DEVICE_FOR_PRODUCT_STRATEGY, |
| 114 | GET_PREFERRED_DEVICE_FOR_PRODUCT_STRATEGY, |
Jean-Michel Trivi | f41599b | 2020-01-07 14:22:08 -0800 | [diff] [blame] | 115 | GET_DEVICES_FOR_ATTRIBUTES, |
Mikhail Naganov | 88b30d2 | 2020-03-09 19:43:13 +0000 | [diff] [blame] | 116 | AUDIO_MODULES_UPDATED, // oneway |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 117 | }; |
| 118 | |
Eric Laurent | 1d670b1 | 2015-02-06 10:44:24 -0800 | [diff] [blame] | 119 | #define MAX_ITEMS_PER_LIST 1024 |
| 120 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 121 | class BpAudioPolicyService : public BpInterface<IAudioPolicyService> |
| 122 | { |
| 123 | public: |
Chih-Hung Hsieh | 090ef60 | 2016-04-27 10:39:54 -0700 | [diff] [blame] | 124 | explicit BpAudioPolicyService(const sp<IBinder>& impl) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 125 | : BpInterface<IAudioPolicyService>(impl) |
| 126 | { |
| 127 | } |
| 128 | |
| 129 | virtual status_t setDeviceConnectionState( |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 130 | audio_devices_t device, |
| 131 | audio_policy_dev_state_t state, |
Paul McLean | e743a47 | 2015-01-28 11:07:31 -0800 | [diff] [blame] | 132 | const char *device_address, |
Aniket Kumar Lata | 4e46470 | 2019-01-10 23:38:46 -0800 | [diff] [blame] | 133 | const char *device_name, |
| 134 | audio_format_t encodedFormat) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 135 | { |
| 136 | Parcel data, reply; |
| 137 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 138 | data.writeInt32(static_cast <uint32_t>(device)); |
| 139 | data.writeInt32(static_cast <uint32_t>(state)); |
| 140 | data.writeCString(device_address); |
Paul McLean | e743a47 | 2015-01-28 11:07:31 -0800 | [diff] [blame] | 141 | data.writeCString(device_name); |
Aniket Kumar Lata | 4e46470 | 2019-01-10 23:38:46 -0800 | [diff] [blame] | 142 | data.writeInt32(static_cast <uint32_t>(encodedFormat)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 143 | remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); |
| 144 | return static_cast <status_t> (reply.readInt32()); |
| 145 | } |
| 146 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 147 | virtual audio_policy_dev_state_t getDeviceConnectionState( |
| 148 | audio_devices_t device, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 149 | const char *device_address) |
| 150 | { |
| 151 | Parcel data, reply; |
| 152 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 153 | data.writeInt32(static_cast <uint32_t>(device)); |
| 154 | data.writeCString(device_address); |
| 155 | remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 156 | return static_cast <audio_policy_dev_state_t>(reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 157 | } |
| 158 | |
Pavlin Radoslavov | f862bc6 | 2016-12-26 18:57:22 -0800 | [diff] [blame] | 159 | virtual status_t handleDeviceConfigChange(audio_devices_t device, |
| 160 | const char *device_address, |
Aniket Kumar Lata | 4e46470 | 2019-01-10 23:38:46 -0800 | [diff] [blame] | 161 | const char *device_name, |
| 162 | audio_format_t encodedFormat) |
Pavlin Radoslavov | f862bc6 | 2016-12-26 18:57:22 -0800 | [diff] [blame] | 163 | { |
| 164 | Parcel data, reply; |
| 165 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 166 | data.writeInt32(static_cast <uint32_t>(device)); |
| 167 | data.writeCString(device_address); |
| 168 | data.writeCString(device_name); |
Aniket Kumar Lata | 4e46470 | 2019-01-10 23:38:46 -0800 | [diff] [blame] | 169 | data.writeInt32(static_cast <uint32_t>(encodedFormat)); |
Pavlin Radoslavov | f862bc6 | 2016-12-26 18:57:22 -0800 | [diff] [blame] | 170 | remote()->transact(HANDLE_DEVICE_CONFIG_CHANGE, data, &reply); |
| 171 | return static_cast <status_t> (reply.readInt32()); |
| 172 | } |
| 173 | |
Eric Laurent | 00dba06 | 2020-02-11 15:52:09 -0800 | [diff] [blame] | 174 | virtual status_t setPhoneState(audio_mode_t state, uid_t uid) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 175 | { |
| 176 | Parcel data, reply; |
| 177 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 178 | data.writeInt32(state); |
Eric Laurent | 00dba06 | 2020-02-11 15:52:09 -0800 | [diff] [blame] | 179 | data.writeInt32(uid); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 180 | remote()->transact(SET_PHONE_STATE, data, &reply); |
| 181 | return static_cast <status_t> (reply.readInt32()); |
| 182 | } |
| 183 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 184 | virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 185 | { |
| 186 | Parcel data, reply; |
| 187 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 188 | data.writeInt32(static_cast <uint32_t>(usage)); |
| 189 | data.writeInt32(static_cast <uint32_t>(config)); |
| 190 | remote()->transact(SET_FORCE_USE, data, &reply); |
| 191 | return static_cast <status_t> (reply.readInt32()); |
| 192 | } |
| 193 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 194 | virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 195 | { |
| 196 | Parcel data, reply; |
| 197 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 198 | data.writeInt32(static_cast <uint32_t>(usage)); |
| 199 | remote()->transact(GET_FORCE_USE, data, &reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 200 | return static_cast <audio_policy_forced_cfg_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Eric Laurent | f4e6345 | 2017-11-06 19:31:46 +0000 | [diff] [blame] | 203 | virtual audio_io_handle_t getOutput(audio_stream_type_t stream) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 204 | { |
| 205 | Parcel data, reply; |
| 206 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 207 | data.writeInt32(static_cast <uint32_t>(stream)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 208 | remote()->transact(GET_OUTPUT, data, &reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 209 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Eric Laurent | 4298441 | 2019-05-09 17:57:03 -0700 | [diff] [blame] | 212 | status_t getOutputForAttr(audio_attributes_t *attr, |
Kevin Rocard | 153f92d | 2018-12-18 18:33:28 -0800 | [diff] [blame] | 213 | audio_io_handle_t *output, |
| 214 | audio_session_t session, |
| 215 | audio_stream_type_t *stream, |
| 216 | pid_t pid, |
| 217 | uid_t uid, |
| 218 | const audio_config_t *config, |
| 219 | audio_output_flags_t flags, |
| 220 | audio_port_handle_t *selectedDeviceId, |
| 221 | audio_port_handle_t *portId, |
| 222 | std::vector<audio_io_handle_t> *secondaryOutputs) override |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 223 | { |
| 224 | Parcel data, reply; |
| 225 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | 4298441 | 2019-05-09 17:57:03 -0700 | [diff] [blame] | 226 | if (attr == nullptr) { |
| 227 | ALOGE("%s NULL audio attributes", __func__); |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 228 | return BAD_VALUE; |
| 229 | } |
Eric Laurent | 4298441 | 2019-05-09 17:57:03 -0700 | [diff] [blame] | 230 | if (output == nullptr) { |
| 231 | ALOGE("%s NULL output - shouldn't happen", __func__); |
Eric Laurent | 9ae8c59 | 2017-06-22 17:17:09 -0700 | [diff] [blame] | 232 | return BAD_VALUE; |
| 233 | } |
Eric Laurent | 4298441 | 2019-05-09 17:57:03 -0700 | [diff] [blame] | 234 | if (selectedDeviceId == nullptr) { |
| 235 | ALOGE("%s NULL selectedDeviceId - shouldn't happen", __func__); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 236 | return BAD_VALUE; |
| 237 | } |
Eric Laurent | 4298441 | 2019-05-09 17:57:03 -0700 | [diff] [blame] | 238 | if (portId == nullptr) { |
| 239 | ALOGE("%s NULL portId - shouldn't happen", __func__); |
Kevin Rocard | 153f92d | 2018-12-18 18:33:28 -0800 | [diff] [blame] | 240 | return BAD_VALUE; |
| 241 | } |
Eric Laurent | 4298441 | 2019-05-09 17:57:03 -0700 | [diff] [blame] | 242 | if (secondaryOutputs == nullptr) { |
| 243 | ALOGE("%s NULL secondaryOutputs - shouldn't happen", __func__); |
| 244 | return BAD_VALUE; |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 245 | } |
Eric Laurent | 4298441 | 2019-05-09 17:57:03 -0700 | [diff] [blame] | 246 | data.write(attr, sizeof(audio_attributes_t)); |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 247 | data.writeInt32(session); |
| 248 | if (stream == NULL) { |
| 249 | data.writeInt32(0); |
| 250 | } else { |
| 251 | data.writeInt32(1); |
| 252 | data.writeInt32(*stream); |
| 253 | } |
Nadav Bar | 766fb02 | 2018-01-07 12:18:03 +0200 | [diff] [blame] | 254 | data.writeInt32(pid); |
Eric Laurent | 8c7e6da | 2015-04-21 17:37:00 -0700 | [diff] [blame] | 255 | data.writeInt32(uid); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 256 | data.write(config, sizeof(audio_config_t)); |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 257 | data.writeInt32(static_cast <uint32_t>(flags)); |
Eric Laurent | 9ae8c59 | 2017-06-22 17:17:09 -0700 | [diff] [blame] | 258 | data.writeInt32(*selectedDeviceId); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 259 | data.writeInt32(*portId); |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 260 | status_t status = remote()->transact(GET_OUTPUT_FOR_ATTR, data, &reply); |
| 261 | if (status != NO_ERROR) { |
| 262 | return status; |
| 263 | } |
| 264 | status = (status_t)reply.readInt32(); |
| 265 | if (status != NO_ERROR) { |
| 266 | return status; |
| 267 | } |
Eric Laurent | 4298441 | 2019-05-09 17:57:03 -0700 | [diff] [blame] | 268 | status = (status_t)reply.read(&attr, sizeof(audio_attributes_t)); |
| 269 | if (status != NO_ERROR) { |
| 270 | return status; |
| 271 | } |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 272 | *output = (audio_io_handle_t)reply.readInt32(); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 273 | audio_stream_type_t lStream = (audio_stream_type_t)reply.readInt32(); |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 274 | if (stream != NULL) { |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 275 | *stream = lStream; |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 276 | } |
Eric Laurent | 9ae8c59 | 2017-06-22 17:17:09 -0700 | [diff] [blame] | 277 | *selectedDeviceId = (audio_port_handle_t)reply.readInt32(); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 278 | *portId = (audio_port_handle_t)reply.readInt32(); |
Kevin Rocard | 153f92d | 2018-12-18 18:33:28 -0800 | [diff] [blame] | 279 | secondaryOutputs->resize(reply.readInt32()); |
| 280 | return reply.read(secondaryOutputs->data(), |
| 281 | secondaryOutputs->size() * sizeof(audio_io_handle_t)); |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 282 | } |
| 283 | |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 284 | virtual status_t startOutput(audio_port_handle_t portId) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 285 | { |
| 286 | Parcel data, reply; |
| 287 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 288 | data.writeInt32((int32_t)portId); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 289 | remote()->transact(START_OUTPUT, data, &reply); |
| 290 | return static_cast <status_t> (reply.readInt32()); |
| 291 | } |
| 292 | |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 293 | virtual status_t stopOutput(audio_port_handle_t portId) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 294 | { |
| 295 | Parcel data, reply; |
| 296 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 297 | data.writeInt32((int32_t)portId); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 298 | remote()->transact(STOP_OUTPUT, data, &reply); |
| 299 | return static_cast <status_t> (reply.readInt32()); |
| 300 | } |
| 301 | |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 302 | virtual void releaseOutput(audio_port_handle_t portId) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 303 | { |
| 304 | Parcel data, reply; |
| 305 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 306 | data.writeInt32((int32_t)portId); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 307 | remote()->transact(RELEASE_OUTPUT, data, &reply); |
| 308 | } |
| 309 | |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 310 | virtual status_t getInputForAttr(const audio_attributes_t *attr, |
| 311 | audio_io_handle_t *input, |
Mikhail Naganov | 2996f67 | 2019-04-18 12:29:59 -0700 | [diff] [blame] | 312 | audio_unique_id_t riid, |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 313 | audio_session_t session, |
Eric Laurent | b2379ba | 2016-05-23 17:42:12 -0700 | [diff] [blame] | 314 | pid_t pid, |
Eric Laurent | 8c7e6da | 2015-04-21 17:37:00 -0700 | [diff] [blame] | 315 | uid_t uid, |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 316 | const String16& opPackageName, |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 317 | const audio_config_base_t *config, |
Paul McLean | 466dc8e | 2015-04-17 13:15:36 -0600 | [diff] [blame] | 318 | audio_input_flags_t flags, |
Eric Laurent | 9ae8c59 | 2017-06-22 17:17:09 -0700 | [diff] [blame] | 319 | audio_port_handle_t *selectedDeviceId, |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 320 | audio_port_handle_t *portId) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 321 | { |
| 322 | Parcel data, reply; |
| 323 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 324 | if (attr == NULL) { |
| 325 | ALOGE("getInputForAttr NULL attr - shouldn't happen"); |
| 326 | return BAD_VALUE; |
| 327 | } |
| 328 | if (input == NULL) { |
| 329 | ALOGE("getInputForAttr NULL input - shouldn't happen"); |
| 330 | return BAD_VALUE; |
| 331 | } |
Eric Laurent | 9ae8c59 | 2017-06-22 17:17:09 -0700 | [diff] [blame] | 332 | if (selectedDeviceId == NULL) { |
| 333 | ALOGE("getInputForAttr NULL selectedDeviceId - shouldn't happen"); |
| 334 | return BAD_VALUE; |
| 335 | } |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 336 | if (portId == NULL) { |
| 337 | ALOGE("getInputForAttr NULL portId - shouldn't happen"); |
| 338 | return BAD_VALUE; |
| 339 | } |
Hayden Gomes | 524159d | 2019-12-23 14:41:47 -0800 | [diff] [blame] | 340 | |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 341 | data.write(attr, sizeof(audio_attributes_t)); |
Eric Laurent | a54f128 | 2017-07-01 19:39:32 -0700 | [diff] [blame] | 342 | data.writeInt32(*input); |
Mikhail Naganov | 2996f67 | 2019-04-18 12:29:59 -0700 | [diff] [blame] | 343 | data.writeInt32(riid); |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 344 | data.writeInt32(session); |
Eric Laurent | b2379ba | 2016-05-23 17:42:12 -0700 | [diff] [blame] | 345 | data.writeInt32(pid); |
Eric Laurent | 8c7e6da | 2015-04-21 17:37:00 -0700 | [diff] [blame] | 346 | data.writeInt32(uid); |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 347 | data.writeString16(opPackageName); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 348 | data.write(config, sizeof(audio_config_base_t)); |
Glenn Kasten | b3b1660 | 2014-07-16 08:36:31 -0700 | [diff] [blame] | 349 | data.writeInt32(flags); |
Eric Laurent | 9ae8c59 | 2017-06-22 17:17:09 -0700 | [diff] [blame] | 350 | data.writeInt32(*selectedDeviceId); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 351 | data.writeInt32(*portId); |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 352 | status_t status = remote()->transact(GET_INPUT_FOR_ATTR, data, &reply); |
| 353 | if (status != NO_ERROR) { |
| 354 | return status; |
| 355 | } |
| 356 | status = reply.readInt32(); |
| 357 | if (status != NO_ERROR) { |
| 358 | return status; |
| 359 | } |
| 360 | *input = (audio_io_handle_t)reply.readInt32(); |
Eric Laurent | 9ae8c59 | 2017-06-22 17:17:09 -0700 | [diff] [blame] | 361 | *selectedDeviceId = (audio_port_handle_t)reply.readInt32(); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 362 | *portId = (audio_port_handle_t)reply.readInt32(); |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 363 | return NO_ERROR; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 364 | } |
| 365 | |
Eric Laurent | 4eb58f1 | 2018-12-07 16:41:02 -0800 | [diff] [blame] | 366 | virtual status_t startInput(audio_port_handle_t portId) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 367 | { |
| 368 | Parcel data, reply; |
| 369 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 370 | data.writeInt32(portId); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 371 | remote()->transact(START_INPUT, data, &reply); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 372 | status_t status = static_cast <status_t> (reply.readInt32()); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 373 | return status; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 374 | } |
| 375 | |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 376 | virtual status_t stopInput(audio_port_handle_t portId) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 377 | { |
| 378 | Parcel data, reply; |
| 379 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 380 | data.writeInt32(portId); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 381 | remote()->transact(STOP_INPUT, data, &reply); |
| 382 | return static_cast <status_t> (reply.readInt32()); |
| 383 | } |
| 384 | |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 385 | virtual void releaseInput(audio_port_handle_t portId) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 386 | { |
| 387 | Parcel data, reply; |
| 388 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 389 | data.writeInt32(portId); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 390 | remote()->transact(RELEASE_INPUT, data, &reply); |
| 391 | } |
| 392 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 393 | virtual status_t initStreamVolume(audio_stream_type_t stream, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 394 | int indexMin, |
| 395 | int indexMax) |
| 396 | { |
| 397 | Parcel data, reply; |
| 398 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 399 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 400 | data.writeInt32(indexMin); |
| 401 | data.writeInt32(indexMax); |
| 402 | remote()->transact(INIT_STREAM_VOLUME, data, &reply); |
| 403 | return static_cast <status_t> (reply.readInt32()); |
| 404 | } |
| 405 | |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 406 | virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, |
| 407 | int index, |
| 408 | audio_devices_t device) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 409 | { |
| 410 | Parcel data, reply; |
| 411 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 412 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 413 | data.writeInt32(index); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 414 | data.writeInt32(static_cast <uint32_t>(device)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 415 | remote()->transact(SET_STREAM_VOLUME, data, &reply); |
| 416 | return static_cast <status_t> (reply.readInt32()); |
| 417 | } |
| 418 | |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 419 | virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, |
| 420 | int *index, |
| 421 | audio_devices_t device) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 422 | { |
| 423 | Parcel data, reply; |
| 424 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 425 | data.writeInt32(static_cast <uint32_t>(stream)); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 426 | data.writeInt32(static_cast <uint32_t>(device)); |
| 427 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 428 | remote()->transact(GET_STREAM_VOLUME, data, &reply); |
| 429 | int lIndex = reply.readInt32(); |
| 430 | if (index) *index = lIndex; |
| 431 | return static_cast <status_t> (reply.readInt32()); |
| 432 | } |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 433 | |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 434 | virtual status_t setVolumeIndexForAttributes(const audio_attributes_t &attr, int index, |
| 435 | audio_devices_t device) |
| 436 | { |
| 437 | Parcel data, reply; |
| 438 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 439 | data.write(&attr, sizeof(audio_attributes_t)); |
| 440 | data.writeInt32(index); |
| 441 | data.writeInt32(static_cast <uint32_t>(device)); |
| 442 | status_t status = remote()->transact(SET_VOLUME_ATTRIBUTES, data, &reply); |
| 443 | if (status != NO_ERROR) { |
| 444 | return status; |
| 445 | } |
| 446 | return static_cast <status_t> (reply.readInt32()); |
| 447 | } |
| 448 | virtual status_t getVolumeIndexForAttributes(const audio_attributes_t &attr, int &index, |
| 449 | audio_devices_t device) |
| 450 | { |
| 451 | Parcel data, reply; |
| 452 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 453 | data.write(&attr, sizeof(audio_attributes_t)); |
| 454 | data.writeInt32(static_cast <uint32_t>(device)); |
| 455 | status_t status = remote()->transact(GET_VOLUME_ATTRIBUTES, data, &reply); |
| 456 | if (status != NO_ERROR) { |
| 457 | return status; |
| 458 | } |
| 459 | status = static_cast <status_t> (reply.readInt32()); |
| 460 | if (status != NO_ERROR) { |
| 461 | return status; |
| 462 | } |
| 463 | index = reply.readInt32(); |
| 464 | return NO_ERROR; |
| 465 | } |
| 466 | virtual status_t getMinVolumeIndexForAttributes(const audio_attributes_t &attr, int &index) |
| 467 | { |
| 468 | Parcel data, reply; |
| 469 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 470 | data.write(&attr, sizeof(audio_attributes_t)); |
| 471 | status_t status = remote()->transact(GET_MIN_VOLUME_FOR_ATTRIBUTES, data, &reply); |
| 472 | if (status != NO_ERROR) { |
| 473 | return status; |
| 474 | } |
| 475 | status = static_cast <status_t> (reply.readInt32()); |
| 476 | if (status != NO_ERROR) { |
| 477 | return status; |
| 478 | } |
| 479 | index = reply.readInt32(); |
| 480 | return NO_ERROR; |
| 481 | } |
| 482 | virtual status_t getMaxVolumeIndexForAttributes(const audio_attributes_t &attr, int &index) |
| 483 | { |
| 484 | Parcel data, reply; |
| 485 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 486 | data.write(&attr, sizeof(audio_attributes_t)); |
| 487 | status_t status = remote()->transact(GET_MAX_VOLUME_FOR_ATTRIBUTES, data, &reply); |
| 488 | if (status != NO_ERROR) { |
| 489 | return status; |
| 490 | } |
| 491 | status = static_cast <status_t> (reply.readInt32()); |
| 492 | if (status != NO_ERROR) { |
| 493 | return status; |
| 494 | } |
| 495 | index = reply.readInt32(); |
| 496 | return NO_ERROR; |
| 497 | } |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 498 | virtual uint32_t getStrategyForStream(audio_stream_type_t stream) |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 499 | { |
| 500 | Parcel data, reply; |
| 501 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 502 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 503 | remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); |
François Gaffie | c005e56 | 2018-11-06 15:04:49 +0100 | [diff] [blame] | 504 | return reply.readUint32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 505 | } |
| 506 | |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 507 | virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 508 | { |
| 509 | Parcel data, reply; |
| 510 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 511 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 512 | remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 513 | return (audio_devices_t) reply.readInt32(); |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 514 | } |
| 515 | |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame] | 516 | virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 517 | { |
| 518 | Parcel data, reply; |
| 519 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 520 | data.write(desc, sizeof(effect_descriptor_t)); |
| 521 | remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); |
| 522 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
| 523 | } |
| 524 | |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame] | 525 | virtual status_t registerEffect(const effect_descriptor_t *desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 526 | audio_io_handle_t io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 527 | uint32_t strategy, |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 528 | audio_session_t session, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 529 | int id) |
| 530 | { |
| 531 | Parcel data, reply; |
| 532 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 533 | data.write(desc, sizeof(effect_descriptor_t)); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 534 | data.writeInt32(io); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 535 | data.writeInt32(strategy); |
| 536 | data.writeInt32(session); |
| 537 | data.writeInt32(id); |
| 538 | remote()->transact(REGISTER_EFFECT, data, &reply); |
| 539 | return static_cast <status_t> (reply.readInt32()); |
| 540 | } |
| 541 | |
| 542 | virtual status_t unregisterEffect(int id) |
| 543 | { |
| 544 | Parcel data, reply; |
| 545 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 546 | data.writeInt32(id); |
| 547 | remote()->transact(UNREGISTER_EFFECT, data, &reply); |
| 548 | return static_cast <status_t> (reply.readInt32()); |
| 549 | } |
| 550 | |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 551 | virtual status_t setEffectEnabled(int id, bool enabled) |
| 552 | { |
| 553 | Parcel data, reply; |
| 554 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 555 | data.writeInt32(id); |
| 556 | data.writeInt32(enabled); |
| 557 | remote()->transact(SET_EFFECT_ENABLED, data, &reply); |
| 558 | return static_cast <status_t> (reply.readInt32()); |
| 559 | } |
| 560 | |
Eric Laurent | 6c79632 | 2019-04-09 14:13:17 -0700 | [diff] [blame] | 561 | status_t moveEffectsToIo(const std::vector<int>& ids, audio_io_handle_t io) override |
| 562 | { |
| 563 | Parcel data, reply; |
| 564 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 565 | data.writeInt32(ids.size()); |
| 566 | for (auto id : ids) { |
| 567 | data.writeInt32(id); |
| 568 | } |
| 569 | data.writeInt32(io); |
| 570 | status_t status = remote()->transact(MOVE_EFFECTS_TO_IO, data, &reply); |
| 571 | if (status != NO_ERROR) { |
| 572 | return status; |
| 573 | } |
| 574 | return static_cast <status_t> (reply.readInt32()); |
| 575 | } |
| 576 | |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 577 | virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 578 | { |
| 579 | Parcel data, reply; |
| 580 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 581 | data.writeInt32((int32_t) stream); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 582 | data.writeInt32(inPastMs); |
| 583 | remote()->transact(IS_STREAM_ACTIVE, data, &reply); |
| 584 | return reply.readInt32(); |
| 585 | } |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 586 | |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 587 | virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const |
| 588 | { |
| 589 | Parcel data, reply; |
| 590 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 591 | data.writeInt32((int32_t) stream); |
| 592 | data.writeInt32(inPastMs); |
| 593 | remote()->transact(IS_STREAM_ACTIVE_REMOTELY, data, &reply); |
| 594 | return reply.readInt32(); |
| 595 | } |
| 596 | |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 597 | virtual bool isSourceActive(audio_source_t source) const |
| 598 | { |
| 599 | Parcel data, reply; |
| 600 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 601 | data.writeInt32((int32_t) source); |
| 602 | remote()->transact(IS_SOURCE_ACTIVE, data, &reply); |
| 603 | return reply.readInt32(); |
| 604 | } |
| 605 | |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 606 | virtual status_t queryDefaultPreProcessing(audio_session_t audioSession, |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 607 | effect_descriptor_t *descriptors, |
| 608 | uint32_t *count) |
| 609 | { |
| 610 | if (descriptors == NULL || count == NULL) { |
| 611 | return BAD_VALUE; |
| 612 | } |
| 613 | Parcel data, reply; |
| 614 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 615 | data.writeInt32(audioSession); |
| 616 | data.writeInt32(*count); |
| 617 | status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply); |
| 618 | if (status != NO_ERROR) { |
| 619 | return status; |
| 620 | } |
| 621 | status = static_cast <status_t> (reply.readInt32()); |
| 622 | uint32_t retCount = reply.readInt32(); |
| 623 | if (retCount != 0) { |
| 624 | uint32_t numDesc = (retCount < *count) ? retCount : *count; |
| 625 | reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc); |
| 626 | } |
| 627 | *count = retCount; |
| 628 | return status; |
| 629 | } |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 630 | |
Hayden Gomes | 524159d | 2019-12-23 14:41:47 -0800 | [diff] [blame] | 631 | status_t setSupportedSystemUsages(const std::vector<audio_usage_t>& systemUsages) { |
| 632 | Parcel data, reply; |
| 633 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 634 | data.writeInt32(systemUsages.size()); |
| 635 | for (auto systemUsage : systemUsages) { |
| 636 | data.writeInt32(systemUsage); |
| 637 | } |
| 638 | status_t status = remote()->transact(SET_SUPPORTED_SYSTEM_USAGES, data, &reply); |
| 639 | if (status != NO_ERROR) { |
| 640 | return status; |
| 641 | } |
| 642 | return static_cast <status_t> (reply.readInt32()); |
| 643 | } |
| 644 | |
Kevin Rocard | b99cc75 | 2019-03-21 20:52:24 -0700 | [diff] [blame] | 645 | status_t setAllowedCapturePolicy(uid_t uid, audio_flags_mask_t flags) override { |
| 646 | Parcel data, reply; |
| 647 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 648 | data.writeInt32(uid); |
| 649 | data.writeInt32(flags); |
| 650 | remote()->transact(SET_ALLOWED_CAPTURE_POLICY, data, &reply); |
| 651 | return reply.readInt32(); |
| 652 | } |
| 653 | |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 654 | virtual bool isOffloadSupported(const audio_offload_info_t& info) |
| 655 | { |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 656 | Parcel data, reply; |
| 657 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 658 | data.write(&info, sizeof(audio_offload_info_t)); |
| 659 | remote()->transact(IS_OFFLOAD_SUPPORTED, data, &reply); |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 660 | return reply.readInt32(); |
| 661 | } |
| 662 | |
Michael Chan | a94fbb2 | 2018-04-24 14:31:19 +1000 | [diff] [blame] | 663 | virtual bool isDirectOutputSupported(const audio_config_base_t& config, |
| 664 | const audio_attributes_t& attributes) { |
| 665 | Parcel data, reply; |
| 666 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 667 | data.write(&config, sizeof(audio_config_base_t)); |
| 668 | data.write(&attributes, sizeof(audio_attributes_t)); |
| 669 | status_t status = remote()->transact(IS_DIRECT_OUTPUT_SUPPORTED, data, &reply); |
| 670 | return status == NO_ERROR ? static_cast<bool>(reply.readInt32()) : false; |
| 671 | } |
| 672 | |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 673 | virtual status_t listAudioPorts(audio_port_role_t role, |
| 674 | audio_port_type_t type, |
| 675 | unsigned int *num_ports, |
| 676 | struct audio_port *ports, |
| 677 | unsigned int *generation) |
| 678 | { |
| 679 | if (num_ports == NULL || (*num_ports != 0 && ports == NULL) || |
| 680 | generation == NULL) { |
| 681 | return BAD_VALUE; |
| 682 | } |
| 683 | Parcel data, reply; |
| 684 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 685 | unsigned int numPortsReq = (ports == NULL) ? 0 : *num_ports; |
| 686 | data.writeInt32(role); |
| 687 | data.writeInt32(type); |
| 688 | data.writeInt32(numPortsReq); |
| 689 | status_t status = remote()->transact(LIST_AUDIO_PORTS, data, &reply); |
| 690 | if (status == NO_ERROR) { |
| 691 | status = (status_t)reply.readInt32(); |
| 692 | *num_ports = (unsigned int)reply.readInt32(); |
| 693 | } |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 694 | if (status == NO_ERROR) { |
| 695 | if (numPortsReq > *num_ports) { |
| 696 | numPortsReq = *num_ports; |
| 697 | } |
| 698 | if (numPortsReq > 0) { |
| 699 | reply.read(ports, numPortsReq * sizeof(struct audio_port)); |
| 700 | } |
| 701 | *generation = reply.readInt32(); |
| 702 | } |
| 703 | return status; |
| 704 | } |
| 705 | |
| 706 | virtual status_t getAudioPort(struct audio_port *port) |
| 707 | { |
| 708 | if (port == NULL) { |
| 709 | return BAD_VALUE; |
| 710 | } |
| 711 | Parcel data, reply; |
| 712 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 713 | data.write(port, sizeof(struct audio_port)); |
| 714 | status_t status = remote()->transact(GET_AUDIO_PORT, data, &reply); |
| 715 | if (status != NO_ERROR || |
| 716 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 717 | return status; |
| 718 | } |
| 719 | reply.read(port, sizeof(struct audio_port)); |
| 720 | return status; |
| 721 | } |
| 722 | |
| 723 | virtual status_t createAudioPatch(const struct audio_patch *patch, |
| 724 | audio_patch_handle_t *handle) |
| 725 | { |
| 726 | if (patch == NULL || handle == NULL) { |
| 727 | return BAD_VALUE; |
| 728 | } |
| 729 | Parcel data, reply; |
| 730 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 731 | data.write(patch, sizeof(struct audio_patch)); |
| 732 | data.write(handle, sizeof(audio_patch_handle_t)); |
| 733 | status_t status = remote()->transact(CREATE_AUDIO_PATCH, data, &reply); |
| 734 | if (status != NO_ERROR || |
| 735 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 736 | return status; |
| 737 | } |
| 738 | reply.read(handle, sizeof(audio_patch_handle_t)); |
| 739 | return status; |
| 740 | } |
| 741 | |
| 742 | virtual status_t releaseAudioPatch(audio_patch_handle_t handle) |
| 743 | { |
| 744 | Parcel data, reply; |
| 745 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 746 | data.write(&handle, sizeof(audio_patch_handle_t)); |
| 747 | status_t status = remote()->transact(RELEASE_AUDIO_PATCH, data, &reply); |
| 748 | if (status != NO_ERROR) { |
| 749 | status = (status_t)reply.readInt32(); |
| 750 | } |
| 751 | return status; |
| 752 | } |
| 753 | |
| 754 | virtual status_t listAudioPatches(unsigned int *num_patches, |
| 755 | struct audio_patch *patches, |
| 756 | unsigned int *generation) |
| 757 | { |
| 758 | if (num_patches == NULL || (*num_patches != 0 && patches == NULL) || |
| 759 | generation == NULL) { |
| 760 | return BAD_VALUE; |
| 761 | } |
| 762 | Parcel data, reply; |
| 763 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 764 | unsigned int numPatchesReq = (patches == NULL) ? 0 : *num_patches; |
| 765 | data.writeInt32(numPatchesReq); |
| 766 | status_t status = remote()->transact(LIST_AUDIO_PATCHES, data, &reply); |
| 767 | if (status == NO_ERROR) { |
| 768 | status = (status_t)reply.readInt32(); |
| 769 | *num_patches = (unsigned int)reply.readInt32(); |
| 770 | } |
| 771 | if (status == NO_ERROR) { |
| 772 | if (numPatchesReq > *num_patches) { |
| 773 | numPatchesReq = *num_patches; |
| 774 | } |
| 775 | if (numPatchesReq > 0) { |
| 776 | reply.read(patches, numPatchesReq * sizeof(struct audio_patch)); |
| 777 | } |
| 778 | *generation = reply.readInt32(); |
| 779 | } |
| 780 | return status; |
| 781 | } |
| 782 | |
| 783 | virtual status_t setAudioPortConfig(const struct audio_port_config *config) |
| 784 | { |
| 785 | if (config == NULL) { |
| 786 | return BAD_VALUE; |
| 787 | } |
| 788 | Parcel data, reply; |
| 789 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 790 | data.write(config, sizeof(struct audio_port_config)); |
| 791 | status_t status = remote()->transact(SET_AUDIO_PORT_CONFIG, data, &reply); |
| 792 | if (status != NO_ERROR) { |
| 793 | status = (status_t)reply.readInt32(); |
| 794 | } |
| 795 | return status; |
| 796 | } |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 797 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 798 | virtual void registerClient(const sp<IAudioPolicyServiceClient>& client) |
| 799 | { |
| 800 | Parcel data, reply; |
| 801 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Marco Nelissen | f888020 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 802 | data.writeStrongBinder(IInterface::asBinder(client)); |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 803 | remote()->transact(REGISTER_CLIENT, data, &reply); |
| 804 | } |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 805 | |
Eric Laurent | e8726fe | 2015-06-26 09:39:24 -0700 | [diff] [blame] | 806 | virtual void setAudioPortCallbacksEnabled(bool enabled) |
| 807 | { |
| 808 | Parcel data, reply; |
| 809 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 810 | data.writeInt32(enabled ? 1 : 0); |
| 811 | remote()->transact(SET_AUDIO_PORT_CALLBACK_ENABLED, data, &reply); |
| 812 | } |
| 813 | |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 814 | virtual void setAudioVolumeGroupCallbacksEnabled(bool enabled) |
| 815 | { |
| 816 | Parcel data, reply; |
| 817 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 818 | data.writeInt32(enabled ? 1 : 0); |
| 819 | remote()->transact(SET_AUDIO_VOLUME_GROUP_CALLBACK_ENABLED, data, &reply); |
| 820 | } |
| 821 | |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 822 | virtual status_t acquireSoundTriggerSession(audio_session_t *session, |
| 823 | audio_io_handle_t *ioHandle, |
| 824 | audio_devices_t *device) |
| 825 | { |
| 826 | if (session == NULL || ioHandle == NULL || device == NULL) { |
| 827 | return BAD_VALUE; |
| 828 | } |
| 829 | Parcel data, reply; |
| 830 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 831 | status_t status = remote()->transact(ACQUIRE_SOUNDTRIGGER_SESSION, data, &reply); |
| 832 | if (status != NO_ERROR) { |
| 833 | return status; |
| 834 | } |
| 835 | status = (status_t)reply.readInt32(); |
| 836 | if (status == NO_ERROR) { |
| 837 | *session = (audio_session_t)reply.readInt32(); |
| 838 | *ioHandle = (audio_io_handle_t)reply.readInt32(); |
| 839 | *device = (audio_devices_t)reply.readInt32(); |
| 840 | } |
| 841 | return status; |
| 842 | } |
| 843 | |
| 844 | virtual status_t releaseSoundTriggerSession(audio_session_t session) |
| 845 | { |
| 846 | Parcel data, reply; |
| 847 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 848 | data.writeInt32(session); |
| 849 | status_t status = remote()->transact(RELEASE_SOUNDTRIGGER_SESSION, data, &reply); |
| 850 | if (status != NO_ERROR) { |
| 851 | return status; |
| 852 | } |
| 853 | return (status_t)reply.readInt32(); |
| 854 | } |
Eric Laurent | bb6c9a0 | 2014-09-25 14:11:47 -0700 | [diff] [blame] | 855 | |
| 856 | virtual audio_mode_t getPhoneState() |
| 857 | { |
| 858 | Parcel data, reply; |
| 859 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 860 | status_t status = remote()->transact(GET_PHONE_STATE, data, &reply); |
| 861 | if (status != NO_ERROR) { |
| 862 | return AUDIO_MODE_INVALID; |
| 863 | } |
| 864 | return (audio_mode_t)reply.readInt32(); |
| 865 | } |
Eric Laurent | baac183 | 2014-12-01 17:52:59 -0800 | [diff] [blame] | 866 | |
Chih-Hung Hsieh | e964d4e | 2016-08-09 14:31:32 -0700 | [diff] [blame] | 867 | virtual status_t registerPolicyMixes(const Vector<AudioMix>& mixes, bool registration) |
Eric Laurent | baac183 | 2014-12-01 17:52:59 -0800 | [diff] [blame] | 868 | { |
| 869 | Parcel data, reply; |
| 870 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 871 | data.writeInt32(registration ? 1 : 0); |
| 872 | size_t size = mixes.size(); |
| 873 | if (size > MAX_MIXES_PER_POLICY) { |
| 874 | size = MAX_MIXES_PER_POLICY; |
| 875 | } |
| 876 | size_t sizePosition = data.dataPosition(); |
| 877 | data.writeInt32(size); |
| 878 | size_t finalSize = size; |
| 879 | for (size_t i = 0; i < size; i++) { |
| 880 | size_t position = data.dataPosition(); |
| 881 | if (mixes[i].writeToParcel(&data) != NO_ERROR) { |
| 882 | data.setDataPosition(position); |
| 883 | finalSize--; |
| 884 | } |
| 885 | } |
| 886 | if (size != finalSize) { |
| 887 | size_t position = data.dataPosition(); |
| 888 | data.setDataPosition(sizePosition); |
| 889 | data.writeInt32(finalSize); |
| 890 | data.setDataPosition(position); |
| 891 | } |
| 892 | status_t status = remote()->transact(REGISTER_POLICY_MIXES, data, &reply); |
| 893 | if (status == NO_ERROR) { |
| 894 | status = (status_t)reply.readInt32(); |
| 895 | } |
| 896 | return status; |
| 897 | } |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 898 | |
| 899 | virtual status_t startAudioSource(const struct audio_port_config *source, |
| 900 | const audio_attributes_t *attributes, |
Eric Laurent | 3e6c7e1 | 2018-07-27 17:09:23 -0700 | [diff] [blame] | 901 | audio_port_handle_t *portId) |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 902 | { |
| 903 | Parcel data, reply; |
| 904 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | 3e6c7e1 | 2018-07-27 17:09:23 -0700 | [diff] [blame] | 905 | if (source == NULL || attributes == NULL || portId == NULL) { |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 906 | return BAD_VALUE; |
| 907 | } |
| 908 | data.write(source, sizeof(struct audio_port_config)); |
| 909 | data.write(attributes, sizeof(audio_attributes_t)); |
| 910 | status_t status = remote()->transact(START_AUDIO_SOURCE, data, &reply); |
| 911 | if (status != NO_ERROR) { |
| 912 | return status; |
| 913 | } |
| 914 | status = (status_t)reply.readInt32(); |
| 915 | if (status != NO_ERROR) { |
| 916 | return status; |
| 917 | } |
Eric Laurent | 3e6c7e1 | 2018-07-27 17:09:23 -0700 | [diff] [blame] | 918 | *portId = (audio_port_handle_t)reply.readInt32(); |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 919 | return status; |
| 920 | } |
| 921 | |
Eric Laurent | 3e6c7e1 | 2018-07-27 17:09:23 -0700 | [diff] [blame] | 922 | virtual status_t stopAudioSource(audio_port_handle_t portId) |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 923 | { |
| 924 | Parcel data, reply; |
| 925 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | 3e6c7e1 | 2018-07-27 17:09:23 -0700 | [diff] [blame] | 926 | data.writeInt32(portId); |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 927 | status_t status = remote()->transact(STOP_AUDIO_SOURCE, data, &reply); |
| 928 | if (status != NO_ERROR) { |
| 929 | return status; |
| 930 | } |
| 931 | status = (status_t)reply.readInt32(); |
| 932 | return status; |
| 933 | } |
Andy Hung | 2ddee19 | 2015-12-18 17:34:44 -0800 | [diff] [blame] | 934 | |
| 935 | virtual status_t setMasterMono(bool mono) |
| 936 | { |
| 937 | Parcel data, reply; |
| 938 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 939 | data.writeInt32(static_cast<int32_t>(mono)); |
| 940 | status_t status = remote()->transact(SET_MASTER_MONO, data, &reply); |
| 941 | if (status != NO_ERROR) { |
| 942 | return status; |
| 943 | } |
| 944 | return static_cast<status_t>(reply.readInt32()); |
| 945 | } |
| 946 | |
| 947 | virtual status_t getMasterMono(bool *mono) |
| 948 | { |
| 949 | if (mono == nullptr) { |
| 950 | return BAD_VALUE; |
| 951 | } |
| 952 | Parcel data, reply; |
| 953 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 954 | |
| 955 | status_t status = remote()->transact(GET_MASTER_MONO, data, &reply); |
| 956 | if (status != NO_ERROR) { |
| 957 | return status; |
| 958 | } |
| 959 | status = static_cast<status_t>(reply.readInt32()); |
| 960 | if (status == NO_ERROR) { |
| 961 | *mono = static_cast<bool>(reply.readInt32()); |
| 962 | } |
| 963 | return status; |
| 964 | } |
Eric Laurent | ac9cef5 | 2017-06-09 15:46:26 -0700 | [diff] [blame] | 965 | |
| 966 | virtual float getStreamVolumeDB(audio_stream_type_t stream, int index, audio_devices_t device) |
| 967 | { |
| 968 | Parcel data, reply; |
| 969 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 970 | data.writeInt32(static_cast <int32_t>(stream)); |
| 971 | data.writeInt32(static_cast <int32_t>(index)); |
| 972 | data.writeUint32(static_cast <uint32_t>(device)); |
| 973 | status_t status = remote()->transact(GET_STREAM_VOLUME_DB, data, &reply); |
| 974 | if (status != NO_ERROR) { |
| 975 | return NAN; |
| 976 | } |
| 977 | return reply.readFloat(); |
| 978 | } |
jiabin | 8177290 | 2018-04-02 17:52:27 -0700 | [diff] [blame] | 979 | |
| 980 | virtual status_t getSurroundFormats(unsigned int *numSurroundFormats, |
| 981 | audio_format_t *surroundFormats, |
| 982 | bool *surroundFormatsEnabled, |
| 983 | bool reported) |
| 984 | { |
| 985 | if (numSurroundFormats == NULL || (*numSurroundFormats != 0 && |
| 986 | (surroundFormats == NULL || surroundFormatsEnabled == NULL))) { |
| 987 | return BAD_VALUE; |
| 988 | } |
| 989 | Parcel data, reply; |
| 990 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 991 | unsigned int numSurroundFormatsReq = *numSurroundFormats; |
| 992 | data.writeUint32(numSurroundFormatsReq); |
| 993 | data.writeBool(reported); |
| 994 | status_t status = remote()->transact(GET_SURROUND_FORMATS, data, &reply); |
| 995 | if (status == NO_ERROR && (status = (status_t)reply.readInt32()) == NO_ERROR) { |
| 996 | *numSurroundFormats = reply.readUint32(); |
| 997 | } |
| 998 | if (status == NO_ERROR) { |
| 999 | if (numSurroundFormatsReq > *numSurroundFormats) { |
| 1000 | numSurroundFormatsReq = *numSurroundFormats; |
| 1001 | } |
| 1002 | if (numSurroundFormatsReq > 0) { |
| 1003 | status = reply.read(surroundFormats, |
| 1004 | numSurroundFormatsReq * sizeof(audio_format_t)); |
| 1005 | if (status != NO_ERROR) { |
| 1006 | return status; |
| 1007 | } |
| 1008 | status = reply.read(surroundFormatsEnabled, |
| 1009 | numSurroundFormatsReq * sizeof(bool)); |
| 1010 | } |
| 1011 | } |
| 1012 | return status; |
| 1013 | } |
| 1014 | |
| 1015 | virtual status_t setSurroundFormatEnabled(audio_format_t audioFormat, bool enabled) |
| 1016 | { |
| 1017 | Parcel data, reply; |
| 1018 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1019 | data.writeInt32(audioFormat); |
| 1020 | data.writeBool(enabled); |
| 1021 | status_t status = remote()->transact(SET_SURROUND_FORMAT_ENABLED, data, &reply); |
| 1022 | if (status != NO_ERROR) { |
| 1023 | return status; |
| 1024 | } |
| 1025 | return reply.readInt32(); |
| 1026 | } |
Ari Hausman-Cohen | 433722e | 2018-04-24 14:25:22 -0700 | [diff] [blame] | 1027 | |
Arun Mirpuri | 11029ad | 2018-12-19 20:45:19 -0800 | [diff] [blame] | 1028 | virtual status_t getHwOffloadEncodingFormatsSupportedForA2DP( |
| 1029 | std::vector<audio_format_t> *formats) |
| 1030 | { |
| 1031 | if (formats == NULL) { |
| 1032 | return BAD_VALUE; |
| 1033 | } |
| 1034 | |
| 1035 | Parcel data, reply; |
| 1036 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1037 | status_t status = remote()->transact(GET_OFFLOAD_FORMATS_A2DP, data, &reply); |
| 1038 | if (status != NO_ERROR || (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 1039 | return status; |
| 1040 | } |
| 1041 | |
| 1042 | size_t list_size = reply.readUint32(); |
| 1043 | |
| 1044 | for (size_t i = 0; i < list_size; i++) { |
| 1045 | formats->push_back(static_cast<audio_format_t>(reply.readInt32())); |
| 1046 | } |
| 1047 | return NO_ERROR; |
| 1048 | } |
| 1049 | |
| 1050 | |
| 1051 | virtual status_t addStreamDefaultEffect(const effect_uuid_t *type, |
Ari Hausman-Cohen | 433722e | 2018-04-24 14:25:22 -0700 | [diff] [blame] | 1052 | const String16& opPackageName, |
| 1053 | const effect_uuid_t *uuid, |
| 1054 | int32_t priority, |
| 1055 | audio_usage_t usage, |
| 1056 | audio_unique_id_t* id) |
| 1057 | { |
| 1058 | Parcel data, reply; |
| 1059 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1060 | data.write(type, sizeof(effect_uuid_t)); |
| 1061 | data.writeString16(opPackageName); |
| 1062 | data.write(uuid, sizeof(effect_uuid_t)); |
| 1063 | data.writeInt32(priority); |
| 1064 | data.writeInt32((int32_t) usage); |
| 1065 | status_t status = remote()->transact(ADD_STREAM_DEFAULT_EFFECT, data, &reply); |
| 1066 | if (status != NO_ERROR) { |
| 1067 | return status; |
| 1068 | } |
| 1069 | status = static_cast <status_t> (reply.readInt32()); |
| 1070 | *id = reply.readInt32(); |
| 1071 | return status; |
| 1072 | } |
| 1073 | |
| 1074 | virtual status_t removeStreamDefaultEffect(audio_unique_id_t id) |
| 1075 | { |
| 1076 | Parcel data, reply; |
| 1077 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1078 | data.writeInt32(id); |
| 1079 | status_t status = remote()->transact(REMOVE_STREAM_DEFAULT_EFFECT, data, &reply); |
| 1080 | if (status != NO_ERROR) { |
| 1081 | return status; |
| 1082 | } |
| 1083 | return static_cast <status_t> (reply.readInt32()); |
| 1084 | } |
| 1085 | |
Ari Hausman-Cohen | 2462831 | 2018-08-13 15:01:09 -0700 | [diff] [blame] | 1086 | virtual status_t addSourceDefaultEffect(const effect_uuid_t *type, |
| 1087 | const String16& opPackageName, |
| 1088 | const effect_uuid_t *uuid, |
| 1089 | int32_t priority, |
| 1090 | audio_source_t source, |
| 1091 | audio_unique_id_t* id) |
| 1092 | { |
| 1093 | Parcel data, reply; |
| 1094 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1095 | data.write(type, sizeof(effect_uuid_t)); |
| 1096 | data.writeString16(opPackageName); |
| 1097 | data.write(uuid, sizeof(effect_uuid_t)); |
| 1098 | data.writeInt32(priority); |
| 1099 | data.writeInt32((int32_t) source); |
| 1100 | status_t status = remote()->transact(ADD_SOURCE_DEFAULT_EFFECT, data, &reply); |
| 1101 | if (status != NO_ERROR) { |
| 1102 | return status; |
| 1103 | } |
| 1104 | status = static_cast <status_t> (reply.readInt32()); |
| 1105 | *id = reply.readInt32(); |
| 1106 | return status; |
| 1107 | } |
| 1108 | |
| 1109 | virtual status_t removeSourceDefaultEffect(audio_unique_id_t id) |
| 1110 | { |
| 1111 | Parcel data, reply; |
| 1112 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1113 | data.writeInt32(id); |
| 1114 | status_t status = remote()->transact(REMOVE_SOURCE_DEFAULT_EFFECT, data, &reply); |
| 1115 | if (status != NO_ERROR) { |
| 1116 | return status; |
| 1117 | } |
| 1118 | return static_cast <status_t> (reply.readInt32()); |
| 1119 | } |
| 1120 | |
Eric Laurent | b78763e | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 1121 | virtual status_t setAssistantUid(uid_t uid) |
| 1122 | { |
| 1123 | Parcel data, reply; |
| 1124 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1125 | data.writeInt32(uid); |
| 1126 | status_t status = remote()->transact(SET_ASSISTANT_UID, data, &reply); |
| 1127 | if (status != NO_ERROR) { |
| 1128 | return status; |
| 1129 | } |
| 1130 | return static_cast <status_t> (reply.readInt32()); |
| 1131 | } |
| 1132 | |
| 1133 | virtual status_t setA11yServicesUids(const std::vector<uid_t>& uids) |
| 1134 | { |
| 1135 | Parcel data, reply; |
| 1136 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1137 | data.writeInt32(uids.size()); |
| 1138 | for (auto uid : uids) { |
| 1139 | data.writeInt32(uid); |
| 1140 | } |
| 1141 | status_t status = remote()->transact(SET_A11Y_SERVICES_UIDS, data, &reply); |
| 1142 | if (status != NO_ERROR) { |
| 1143 | return status; |
| 1144 | } |
| 1145 | return static_cast <status_t> (reply.readInt32()); |
| 1146 | } |
| 1147 | |
jiabin | 6012f91 | 2018-11-02 17:06:30 -0700 | [diff] [blame] | 1148 | virtual bool isHapticPlaybackSupported() |
| 1149 | { |
| 1150 | Parcel data, reply; |
| 1151 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1152 | status_t status = remote()->transact(IS_HAPTIC_PLAYBACK_SUPPORTED, data, &reply); |
| 1153 | if (status != NO_ERROR) { |
| 1154 | return false; |
| 1155 | } |
| 1156 | return reply.readBool(); |
| 1157 | } |
| 1158 | |
Jean-Michel Trivi | bda70da | 2018-12-19 07:30:15 -0800 | [diff] [blame] | 1159 | virtual status_t setUidDeviceAffinities(uid_t uid, const Vector<AudioDeviceTypeAddr>& devices) |
| 1160 | { |
| 1161 | Parcel data, reply; |
| 1162 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1163 | |
| 1164 | data.writeInt32((int32_t) uid); |
| 1165 | size_t size = devices.size(); |
| 1166 | size_t sizePosition = data.dataPosition(); |
| 1167 | data.writeInt32((int32_t) size); |
| 1168 | size_t finalSize = size; |
| 1169 | for (size_t i = 0; i < size; i++) { |
| 1170 | size_t position = data.dataPosition(); |
| 1171 | if (devices[i].writeToParcel(&data) != NO_ERROR) { |
| 1172 | data.setDataPosition(position); |
| 1173 | finalSize--; |
| 1174 | } |
| 1175 | } |
| 1176 | if (size != finalSize) { |
| 1177 | size_t position = data.dataPosition(); |
| 1178 | data.setDataPosition(sizePosition); |
| 1179 | data.writeInt32(finalSize); |
| 1180 | data.setDataPosition(position); |
| 1181 | } |
| 1182 | |
| 1183 | status_t status = remote()->transact(SET_UID_DEVICE_AFFINITY, data, &reply); |
| 1184 | if (status == NO_ERROR) { |
| 1185 | status = (status_t)reply.readInt32(); |
| 1186 | } |
| 1187 | return status; |
| 1188 | } |
| 1189 | |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 1190 | virtual status_t removeUidDeviceAffinities(uid_t uid) { |
Jean-Michel Trivi | bda70da | 2018-12-19 07:30:15 -0800 | [diff] [blame] | 1191 | Parcel data, reply; |
| 1192 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1193 | |
| 1194 | data.writeInt32((int32_t) uid); |
| 1195 | |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 1196 | status_t status = |
| 1197 | remote()->transact(REMOVE_UID_DEVICE_AFFINITY, data, &reply); |
Jean-Michel Trivi | bda70da | 2018-12-19 07:30:15 -0800 | [diff] [blame] | 1198 | if (status == NO_ERROR) { |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 1199 | status = (status_t) reply.readInt32(); |
Jean-Michel Trivi | bda70da | 2018-12-19 07:30:15 -0800 | [diff] [blame] | 1200 | } |
| 1201 | return status; |
| 1202 | } |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 1203 | |
Oscar Azucena | 90e7763 | 2019-11-27 17:12:28 -0800 | [diff] [blame] | 1204 | virtual status_t setUserIdDeviceAffinities(int userId, |
| 1205 | const Vector<AudioDeviceTypeAddr>& devices) |
| 1206 | { |
| 1207 | Parcel data, reply; |
| 1208 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1209 | |
| 1210 | data.writeInt32((int32_t) userId); |
| 1211 | size_t size = devices.size(); |
| 1212 | size_t sizePosition = data.dataPosition(); |
| 1213 | data.writeInt32((int32_t) size); |
| 1214 | size_t finalSize = size; |
| 1215 | for (size_t i = 0; i < size; i++) { |
| 1216 | size_t position = data.dataPosition(); |
| 1217 | if (devices[i].writeToParcel(&data) != NO_ERROR) { |
| 1218 | data.setDataPosition(position); |
| 1219 | finalSize--; |
| 1220 | } |
| 1221 | } |
| 1222 | if (size != finalSize) { |
| 1223 | size_t position = data.dataPosition(); |
| 1224 | data.setDataPosition(sizePosition); |
| 1225 | data.writeInt32(finalSize); |
| 1226 | data.setDataPosition(position); |
| 1227 | } |
| 1228 | |
| 1229 | status_t status = remote()->transact(SET_USERID_DEVICE_AFFINITY, data, &reply); |
| 1230 | if (status == NO_ERROR) { |
| 1231 | status = (status_t)reply.readInt32(); |
| 1232 | } |
| 1233 | return status; |
| 1234 | } |
| 1235 | |
| 1236 | virtual status_t removeUserIdDeviceAffinities(int userId) { |
| 1237 | Parcel data, reply; |
| 1238 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1239 | |
| 1240 | data.writeInt32((int32_t) userId); |
| 1241 | |
| 1242 | status_t status = |
| 1243 | remote()->transact(REMOVE_USERID_DEVICE_AFFINITY, data, &reply); |
| 1244 | if (status == NO_ERROR) { |
| 1245 | status = (status_t) reply.readInt32(); |
| 1246 | } |
| 1247 | return status; |
| 1248 | } |
| 1249 | |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 1250 | virtual status_t listAudioProductStrategies(AudioProductStrategyVector &strategies) |
| 1251 | { |
| 1252 | Parcel data, reply; |
| 1253 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1254 | |
| 1255 | status_t status = remote()->transact(LIST_AUDIO_PRODUCT_STRATEGIES, data, &reply); |
| 1256 | if (status != NO_ERROR) { |
| 1257 | ALOGE("%s: permission denied", __func__); |
| 1258 | return status; |
| 1259 | } |
| 1260 | status = static_cast<status_t>(reply.readInt32()); |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 1261 | if (status != NO_ERROR) { |
| 1262 | return status; |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 1263 | } |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 1264 | uint32_t numStrategies = static_cast<uint32_t>(reply.readInt32()); |
| 1265 | for (size_t i = 0; i < numStrategies; i++) { |
| 1266 | AudioProductStrategy strategy; |
| 1267 | status = strategy.readFromParcel(&reply); |
| 1268 | if (status != NO_ERROR) { |
| 1269 | ALOGE("%s: failed to read strategies", __FUNCTION__); |
| 1270 | strategies.clear(); |
| 1271 | return status; |
| 1272 | } |
| 1273 | strategies.push_back(strategy); |
| 1274 | } |
| 1275 | return NO_ERROR; |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 1276 | } |
| 1277 | |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 1278 | virtual status_t getProductStrategyFromAudioAttributes(const AudioAttributes &aa, |
| 1279 | product_strategy_t &productStrategy) |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 1280 | { |
| 1281 | Parcel data, reply; |
| 1282 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1283 | status_t status = aa.writeToParcel(&data); |
| 1284 | if (status != NO_ERROR) { |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 1285 | return status; |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 1286 | } |
| 1287 | status = remote()->transact(GET_STRATEGY_FOR_ATTRIBUTES, data, &reply); |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 1288 | if (status != NO_ERROR) { |
| 1289 | return status; |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 1290 | } |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 1291 | status = static_cast<status_t>(reply.readInt32()); |
| 1292 | if (status != NO_ERROR) { |
| 1293 | return status; |
| 1294 | } |
| 1295 | productStrategy = static_cast<product_strategy_t>(reply.readInt32()); |
| 1296 | return NO_ERROR; |
| 1297 | } |
| 1298 | |
| 1299 | virtual status_t listAudioVolumeGroups(AudioVolumeGroupVector &groups) |
| 1300 | { |
| 1301 | Parcel data, reply; |
| 1302 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1303 | |
| 1304 | status_t status = remote()->transact(LIST_AUDIO_VOLUME_GROUPS, data, &reply); |
| 1305 | if (status != NO_ERROR) { |
| 1306 | return status; |
| 1307 | } |
| 1308 | status = static_cast<status_t>(reply.readInt32()); |
| 1309 | if (status != NO_ERROR) { |
| 1310 | return status; |
| 1311 | } |
| 1312 | uint32_t numGroups = static_cast<uint32_t>(reply.readInt32()); |
| 1313 | for (size_t i = 0; i < numGroups; i++) { |
| 1314 | AudioVolumeGroup group; |
| 1315 | status = group.readFromParcel(&reply); |
| 1316 | if (status != NO_ERROR) { |
| 1317 | ALOGE("%s: failed to read volume groups", __FUNCTION__); |
| 1318 | groups.clear(); |
| 1319 | return status; |
| 1320 | } |
| 1321 | groups.push_back(group); |
| 1322 | } |
| 1323 | return NO_ERROR; |
| 1324 | } |
| 1325 | |
| 1326 | virtual status_t getVolumeGroupFromAudioAttributes(const AudioAttributes &aa, |
| 1327 | volume_group_t &volumeGroup) |
| 1328 | { |
| 1329 | Parcel data, reply; |
| 1330 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1331 | status_t status = aa.writeToParcel(&data); |
| 1332 | if (status != NO_ERROR) { |
| 1333 | return status; |
| 1334 | } |
| 1335 | status = remote()->transact(GET_VOLUME_GROUP_FOR_ATTRIBUTES, data, &reply); |
| 1336 | if (status != NO_ERROR) { |
| 1337 | return status; |
| 1338 | } |
| 1339 | status = static_cast<status_t>(reply.readInt32()); |
| 1340 | if (status != NO_ERROR) { |
| 1341 | return status; |
| 1342 | } |
| 1343 | volumeGroup = static_cast<volume_group_t>(reply.readInt32()); |
| 1344 | return NO_ERROR; |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 1345 | } |
Eric Laurent | 6ede98f | 2019-06-11 14:50:30 -0700 | [diff] [blame] | 1346 | |
| 1347 | virtual status_t setRttEnabled(bool enabled) |
| 1348 | { |
| 1349 | Parcel data, reply; |
| 1350 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1351 | data.writeInt32(static_cast<int32_t>(enabled)); |
| 1352 | status_t status = remote()->transact(SET_RTT_ENABLED, data, &reply); |
| 1353 | if (status != NO_ERROR) { |
| 1354 | return status; |
| 1355 | } |
| 1356 | return static_cast<status_t>(reply.readInt32()); |
| 1357 | } |
Eric Laurent | 8340e67 | 2019-11-06 11:01:08 -0800 | [diff] [blame] | 1358 | |
| 1359 | virtual bool isCallScreenModeSupported() |
| 1360 | { |
| 1361 | Parcel data, reply; |
| 1362 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1363 | status_t status = remote()->transact(IS_CALL_SCREEN_MODE_SUPPORTED, data, &reply); |
| 1364 | if (status != NO_ERROR) { |
| 1365 | return false; |
| 1366 | } |
| 1367 | return reply.readBool(); |
| 1368 | } |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 1369 | |
| 1370 | virtual status_t setPreferredDeviceForStrategy(product_strategy_t strategy, |
| 1371 | const AudioDeviceTypeAddr &device) |
| 1372 | { |
| 1373 | Parcel data, reply; |
| 1374 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1375 | data.writeUint32(static_cast<uint32_t>(strategy)); |
| 1376 | status_t status = device.writeToParcel(&data); |
| 1377 | if (status != NO_ERROR) { |
| 1378 | return BAD_VALUE; |
| 1379 | } |
| 1380 | status = remote()->transact(SET_PREFERRED_DEVICE_FOR_PRODUCT_STRATEGY, |
| 1381 | data, &reply); |
| 1382 | if (status != NO_ERROR) { |
| 1383 | return status; |
| 1384 | } |
| 1385 | return static_cast<status_t>(reply.readInt32()); |
| 1386 | } |
| 1387 | |
| 1388 | virtual status_t removePreferredDeviceForStrategy(product_strategy_t strategy) |
| 1389 | { |
| 1390 | Parcel data, reply; |
| 1391 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1392 | data.writeUint32(static_cast<uint32_t>(strategy)); |
| 1393 | status_t status = remote()->transact(REMOVE_PREFERRED_DEVICE_FOR_PRODUCT_STRATEGY, |
| 1394 | data, &reply); |
| 1395 | if (status != NO_ERROR) { |
| 1396 | return status; |
| 1397 | } |
| 1398 | return static_cast<status_t>(reply.readInt32()); |
| 1399 | } |
| 1400 | |
| 1401 | virtual status_t getPreferredDeviceForStrategy(product_strategy_t strategy, |
| 1402 | AudioDeviceTypeAddr &device) |
| 1403 | { |
| 1404 | Parcel data, reply; |
| 1405 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1406 | data.writeUint32(static_cast<uint32_t>(strategy)); |
| 1407 | status_t status = remote()->transact(GET_PREFERRED_DEVICE_FOR_PRODUCT_STRATEGY, |
| 1408 | data, &reply); |
| 1409 | if (status != NO_ERROR) { |
| 1410 | return status; |
| 1411 | } |
| 1412 | status = device.readFromParcel(&reply); |
| 1413 | if (status != NO_ERROR) { |
| 1414 | return status; |
| 1415 | } |
| 1416 | return static_cast<status_t>(reply.readInt32()); |
| 1417 | } |
Jean-Michel Trivi | f41599b | 2020-01-07 14:22:08 -0800 | [diff] [blame] | 1418 | |
| 1419 | virtual status_t getDevicesForAttributes(const AudioAttributes &aa, |
| 1420 | AudioDeviceTypeAddrVector *devices) const |
| 1421 | { |
| 1422 | if (devices == nullptr) { |
| 1423 | return BAD_VALUE; |
| 1424 | } |
| 1425 | Parcel data, reply; |
| 1426 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1427 | status_t status = aa.writeToParcel(&data); |
| 1428 | if (status != NO_ERROR) { |
| 1429 | return status; |
| 1430 | } |
| 1431 | status = remote()->transact(GET_DEVICES_FOR_ATTRIBUTES, data, &reply); |
| 1432 | if (status != NO_ERROR) { |
| 1433 | // transaction failed, return error |
| 1434 | return status; |
| 1435 | } |
| 1436 | status = static_cast<status_t>(reply.readInt32()); |
| 1437 | if (status != NO_ERROR) { |
| 1438 | // APM method call failed, return error |
| 1439 | return status; |
| 1440 | } |
| 1441 | |
| 1442 | const size_t numberOfDevices = (size_t)reply.readInt32(); |
| 1443 | for (size_t i = 0; i < numberOfDevices; i++) { |
| 1444 | AudioDeviceTypeAddr device; |
| 1445 | if (device.readFromParcel((Parcel*)&reply) == NO_ERROR) { |
| 1446 | devices->push_back(device); |
| 1447 | } else { |
| 1448 | return FAILED_TRANSACTION; |
| 1449 | } |
| 1450 | } |
| 1451 | return NO_ERROR; |
| 1452 | } |
Mikhail Naganov | 88b30d2 | 2020-03-09 19:43:13 +0000 | [diff] [blame] | 1453 | |
| 1454 | virtual void onNewAudioModulesAvailable() |
| 1455 | { |
| 1456 | Parcel data, reply; |
| 1457 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 1458 | remote()->transact(AUDIO_MODULES_UPDATED, data, &reply, IBinder::FLAG_ONEWAY); |
| 1459 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1460 | }; |
| 1461 | |
| 1462 | IMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); |
| 1463 | |
| 1464 | // ---------------------------------------------------------------------- |
| 1465 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1466 | status_t BnAudioPolicyService::onTransact( |
| 1467 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 1468 | { |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 1469 | // make sure transactions reserved to AudioFlinger do not come from other processes |
| 1470 | switch (code) { |
| 1471 | case START_OUTPUT: |
| 1472 | case STOP_OUTPUT: |
| 1473 | case RELEASE_OUTPUT: |
| 1474 | case GET_INPUT_FOR_ATTR: |
| 1475 | case START_INPUT: |
| 1476 | case STOP_INPUT: |
| 1477 | case RELEASE_INPUT: |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 1478 | case GET_OUTPUT_FOR_EFFECT: |
| 1479 | case REGISTER_EFFECT: |
| 1480 | case UNREGISTER_EFFECT: |
| 1481 | case SET_EFFECT_ENABLED: |
| 1482 | case GET_OUTPUT_FOR_ATTR: |
Eric Laurent | 6c79632 | 2019-04-09 14:13:17 -0700 | [diff] [blame] | 1483 | case MOVE_EFFECTS_TO_IO: |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 1484 | ALOGW("%s: transaction %d received from PID %d", |
| 1485 | __func__, code, IPCThreadState::self()->getCallingPid()); |
Eric Laurent | ef92bff | 2018-04-26 10:44:50 -0700 | [diff] [blame] | 1486 | // return status only for non void methods |
| 1487 | switch (code) { |
| 1488 | case RELEASE_OUTPUT: |
| 1489 | case RELEASE_INPUT: |
| 1490 | break; |
| 1491 | default: |
| 1492 | reply->writeInt32(static_cast<int32_t> (INVALID_OPERATION)); |
| 1493 | break; |
| 1494 | } |
| 1495 | return OK; |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 1496 | default: |
| 1497 | break; |
| 1498 | } |
| 1499 | |
Eric Laurent | 4980df2 | 2018-01-26 18:04:09 -0800 | [diff] [blame] | 1500 | // make sure the following transactions come from system components |
| 1501 | switch (code) { |
| 1502 | case SET_DEVICE_CONNECTION_STATE: |
| 1503 | case HANDLE_DEVICE_CONFIG_CHANGE: |
| 1504 | case SET_PHONE_STATE: |
Eric Laurent | e17378d | 2018-05-09 14:43:01 -0700 | [diff] [blame] | 1505 | //FIXME: Allow SET_FORCE_USE calls from system apps until a better use case routing API is available |
| 1506 | // case SET_FORCE_USE: |
Eric Laurent | 4980df2 | 2018-01-26 18:04:09 -0800 | [diff] [blame] | 1507 | case INIT_STREAM_VOLUME: |
| 1508 | case SET_STREAM_VOLUME: |
| 1509 | case REGISTER_POLICY_MIXES: |
Eric Laurent | 10b7123 | 2018-04-13 18:14:44 -0700 | [diff] [blame] | 1510 | case SET_MASTER_MONO: |
jiabin | 8177290 | 2018-04-02 17:52:27 -0700 | [diff] [blame] | 1511 | case GET_SURROUND_FORMATS: |
Eric Laurent | b78763e | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 1512 | case SET_SURROUND_FORMAT_ENABLED: |
| 1513 | case SET_ASSISTANT_UID: |
Jean-Michel Trivi | bda70da | 2018-12-19 07:30:15 -0800 | [diff] [blame] | 1514 | case SET_A11Y_SERVICES_UIDS: |
| 1515 | case SET_UID_DEVICE_AFFINITY: |
Arun Mirpuri | 11029ad | 2018-12-19 20:45:19 -0800 | [diff] [blame] | 1516 | case REMOVE_UID_DEVICE_AFFINITY: |
Oscar Azucena | 90e7763 | 2019-11-27 17:12:28 -0800 | [diff] [blame] | 1517 | case SET_USERID_DEVICE_AFFINITY: |
| 1518 | case REMOVE_USERID_DEVICE_AFFINITY: |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 1519 | case GET_OFFLOAD_FORMATS_A2DP: |
| 1520 | case LIST_AUDIO_VOLUME_GROUPS: |
Eric Laurent | 6ede98f | 2019-06-11 14:50:30 -0700 | [diff] [blame] | 1521 | case GET_VOLUME_GROUP_FOR_ATTRIBUTES: |
Ytai Ben-Tsvi | a32e601 | 2019-10-28 15:39:16 -0700 | [diff] [blame] | 1522 | case ACQUIRE_SOUNDTRIGGER_SESSION: |
| 1523 | case RELEASE_SOUNDTRIGGER_SESSION: |
Eric Laurent | 8340e67 | 2019-11-06 11:01:08 -0800 | [diff] [blame] | 1524 | case SET_RTT_ENABLED: |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 1525 | case IS_CALL_SCREEN_MODE_SUPPORTED: |
| 1526 | case SET_PREFERRED_DEVICE_FOR_PRODUCT_STRATEGY: |
Hayden Gomes | 524159d | 2019-12-23 14:41:47 -0800 | [diff] [blame] | 1527 | case SET_SUPPORTED_SYSTEM_USAGES: |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 1528 | case REMOVE_PREFERRED_DEVICE_FOR_PRODUCT_STRATEGY: |
Jean-Michel Trivi | f41599b | 2020-01-07 14:22:08 -0800 | [diff] [blame] | 1529 | case GET_PREFERRED_DEVICE_FOR_PRODUCT_STRATEGY: |
jiabin | 140a34f | 2019-12-23 11:17:25 -0800 | [diff] [blame] | 1530 | case GET_DEVICES_FOR_ATTRIBUTES: |
Mikhail Naganov | 88b30d2 | 2020-03-09 19:43:13 +0000 | [diff] [blame] | 1531 | case SET_ALLOWED_CAPTURE_POLICY: |
| 1532 | case AUDIO_MODULES_UPDATED: { |
Andy Hung | 4ef19fa | 2018-05-15 19:35:29 -0700 | [diff] [blame] | 1533 | if (!isServiceUid(IPCThreadState::self()->getCallingUid())) { |
Eric Laurent | 4980df2 | 2018-01-26 18:04:09 -0800 | [diff] [blame] | 1534 | ALOGW("%s: transaction %d received from PID %d unauthorized UID %d", |
| 1535 | __func__, code, IPCThreadState::self()->getCallingPid(), |
| 1536 | IPCThreadState::self()->getCallingUid()); |
Eric Laurent | ef92bff | 2018-04-26 10:44:50 -0700 | [diff] [blame] | 1537 | reply->writeInt32(static_cast<int32_t> (INVALID_OPERATION)); |
| 1538 | return OK; |
Eric Laurent | 4980df2 | 2018-01-26 18:04:09 -0800 | [diff] [blame] | 1539 | } |
Eric Laurent | 96c7eed | 2018-03-26 17:57:01 -0700 | [diff] [blame] | 1540 | } break; |
Eric Laurent | 4980df2 | 2018-01-26 18:04:09 -0800 | [diff] [blame] | 1541 | default: |
| 1542 | break; |
| 1543 | } |
| 1544 | |
Eric Laurent | 39b09b5 | 2018-06-29 12:24:40 -0700 | [diff] [blame] | 1545 | std::string tag("IAudioPolicyService command " + std::to_string(code)); |
| 1546 | TimeCheck check(tag.c_str()); |
Eric Laurent | 3528c93 | 2018-02-23 17:17:22 -0800 | [diff] [blame] | 1547 | |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 1548 | switch (code) { |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1549 | case SET_DEVICE_CONNECTION_STATE: { |
| 1550 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 1551 | audio_devices_t device = |
| 1552 | static_cast <audio_devices_t>(data.readInt32()); |
| 1553 | audio_policy_dev_state_t state = |
| 1554 | static_cast <audio_policy_dev_state_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1555 | const char *device_address = data.readCString(); |
Paul McLean | e743a47 | 2015-01-28 11:07:31 -0800 | [diff] [blame] | 1556 | const char *device_name = data.readCString(); |
Aniket Kumar Lata | 4e46470 | 2019-01-10 23:38:46 -0800 | [diff] [blame] | 1557 | audio_format_t codecFormat = static_cast <audio_format_t>(data.readInt32()); |
Pavlin Radoslavov | c694ff4 | 2017-01-09 23:27:29 -0800 | [diff] [blame] | 1558 | if (device_address == nullptr || device_name == nullptr) { |
| 1559 | ALOGE("Bad Binder transaction: SET_DEVICE_CONNECTION_STATE for device %u", device); |
| 1560 | reply->writeInt32(static_cast<int32_t> (BAD_VALUE)); |
| 1561 | } else { |
| 1562 | reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, |
| 1563 | state, |
| 1564 | device_address, |
Aniket Kumar Lata | 4e46470 | 2019-01-10 23:38:46 -0800 | [diff] [blame] | 1565 | device_name, |
| 1566 | codecFormat))); |
Pavlin Radoslavov | c694ff4 | 2017-01-09 23:27:29 -0800 | [diff] [blame] | 1567 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1568 | return NO_ERROR; |
| 1569 | } break; |
| 1570 | |
| 1571 | case GET_DEVICE_CONNECTION_STATE: { |
| 1572 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 1573 | audio_devices_t device = |
| 1574 | static_cast<audio_devices_t> (data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1575 | const char *device_address = data.readCString(); |
Pavlin Radoslavov | c694ff4 | 2017-01-09 23:27:29 -0800 | [diff] [blame] | 1576 | if (device_address == nullptr) { |
| 1577 | ALOGE("Bad Binder transaction: GET_DEVICE_CONNECTION_STATE for device %u", device); |
| 1578 | reply->writeInt32(static_cast<int32_t> (AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE)); |
| 1579 | } else { |
| 1580 | reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, |
| 1581 | device_address))); |
| 1582 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1583 | return NO_ERROR; |
| 1584 | } break; |
| 1585 | |
Pavlin Radoslavov | f862bc6 | 2016-12-26 18:57:22 -0800 | [diff] [blame] | 1586 | case HANDLE_DEVICE_CONFIG_CHANGE: { |
| 1587 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1588 | audio_devices_t device = |
| 1589 | static_cast <audio_devices_t>(data.readInt32()); |
| 1590 | const char *device_address = data.readCString(); |
| 1591 | const char *device_name = data.readCString(); |
Aniket Kumar Lata | 4e46470 | 2019-01-10 23:38:46 -0800 | [diff] [blame] | 1592 | audio_format_t codecFormat = |
| 1593 | static_cast <audio_format_t>(data.readInt32()); |
Pavlin Radoslavov | c694ff4 | 2017-01-09 23:27:29 -0800 | [diff] [blame] | 1594 | if (device_address == nullptr || device_name == nullptr) { |
| 1595 | ALOGE("Bad Binder transaction: HANDLE_DEVICE_CONFIG_CHANGE for device %u", device); |
| 1596 | reply->writeInt32(static_cast<int32_t> (BAD_VALUE)); |
| 1597 | } else { |
| 1598 | reply->writeInt32(static_cast<uint32_t> (handleDeviceConfigChange(device, |
| 1599 | device_address, |
Aniket Kumar Lata | 4e46470 | 2019-01-10 23:38:46 -0800 | [diff] [blame] | 1600 | device_name, |
| 1601 | codecFormat))); |
Pavlin Radoslavov | c694ff4 | 2017-01-09 23:27:29 -0800 | [diff] [blame] | 1602 | } |
Pavlin Radoslavov | f862bc6 | 2016-12-26 18:57:22 -0800 | [diff] [blame] | 1603 | return NO_ERROR; |
| 1604 | } break; |
| 1605 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1606 | case SET_PHONE_STATE: { |
| 1607 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 1608 | reply->writeInt32(static_cast <uint32_t>(setPhoneState( |
Eric Laurent | 00dba06 | 2020-02-11 15:52:09 -0800 | [diff] [blame] | 1609 | (audio_mode_t) data.readInt32(), |
| 1610 | (uid_t) data.readInt32()))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1611 | return NO_ERROR; |
| 1612 | } break; |
| 1613 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1614 | case SET_FORCE_USE: { |
| 1615 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 1616 | audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( |
| 1617 | data.readInt32()); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 1618 | audio_policy_forced_cfg_t config = |
| 1619 | static_cast <audio_policy_forced_cfg_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1620 | reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); |
| 1621 | return NO_ERROR; |
| 1622 | } break; |
| 1623 | |
| 1624 | case GET_FORCE_USE: { |
| 1625 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 1626 | audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( |
| 1627 | data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1628 | reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); |
| 1629 | return NO_ERROR; |
| 1630 | } break; |
| 1631 | |
| 1632 | case GET_OUTPUT: { |
| 1633 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 1634 | audio_stream_type_t stream = |
| 1635 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | f4e6345 | 2017-11-06 19:31:46 +0000 | [diff] [blame] | 1636 | audio_io_handle_t output = getOutput(stream); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 1637 | reply->writeInt32(static_cast <int>(output)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1638 | return NO_ERROR; |
| 1639 | } break; |
| 1640 | |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 1641 | case GET_OUTPUT_FOR_ATTR: { |
| 1642 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | 4298441 | 2019-05-09 17:57:03 -0700 | [diff] [blame] | 1643 | audio_attributes_t attr = AUDIO_ATTRIBUTES_INITIALIZER; |
| 1644 | status_t status = data.read(&attr, sizeof(audio_attributes_t)); |
| 1645 | if (status != NO_ERROR) { |
| 1646 | return status; |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 1647 | } |
Eric Laurent | 4298441 | 2019-05-09 17:57:03 -0700 | [diff] [blame] | 1648 | sanetizeAudioAttributes(&attr); |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 1649 | audio_session_t session = (audio_session_t)data.readInt32(); |
| 1650 | audio_stream_type_t stream = AUDIO_STREAM_DEFAULT; |
| 1651 | bool hasStream = data.readInt32() != 0; |
| 1652 | if (hasStream) { |
| 1653 | stream = (audio_stream_type_t)data.readInt32(); |
| 1654 | } |
Nadav Bar | 766fb02 | 2018-01-07 12:18:03 +0200 | [diff] [blame] | 1655 | pid_t pid = (pid_t)data.readInt32(); |
Eric Laurent | 8c7e6da | 2015-04-21 17:37:00 -0700 | [diff] [blame] | 1656 | uid_t uid = (uid_t)data.readInt32(); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 1657 | audio_config_t config; |
| 1658 | memset(&config, 0, sizeof(audio_config_t)); |
| 1659 | data.read(&config, sizeof(audio_config_t)); |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 1660 | audio_output_flags_t flags = |
| 1661 | static_cast <audio_output_flags_t>(data.readInt32()); |
Paul McLean | aa98119 | 2015-03-21 09:55:15 -0700 | [diff] [blame] | 1662 | audio_port_handle_t selectedDeviceId = data.readInt32(); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 1663 | audio_port_handle_t portId = (audio_port_handle_t)data.readInt32(); |
Robert Shih | a946d84 | 2015-09-02 16:46:59 -0700 | [diff] [blame] | 1664 | audio_io_handle_t output = 0; |
Kevin Rocard | 153f92d | 2018-12-18 18:33:28 -0800 | [diff] [blame] | 1665 | std::vector<audio_io_handle_t> secondaryOutputs; |
Eric Laurent | 4298441 | 2019-05-09 17:57:03 -0700 | [diff] [blame] | 1666 | status = getOutputForAttr(&attr, |
Nadav Bar | 766fb02 | 2018-01-07 12:18:03 +0200 | [diff] [blame] | 1667 | &output, session, &stream, pid, uid, |
Ricardo Correa | 57a3769 | 2020-03-23 17:27:25 -0700 | [diff] [blame^] | 1668 | &config, |
Kevin Rocard | 153f92d | 2018-12-18 18:33:28 -0800 | [diff] [blame] | 1669 | flags, &selectedDeviceId, &portId, &secondaryOutputs); |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 1670 | reply->writeInt32(status); |
Eric Laurent | 4298441 | 2019-05-09 17:57:03 -0700 | [diff] [blame] | 1671 | status = reply->write(&attr, sizeof(audio_attributes_t)); |
| 1672 | if (status != NO_ERROR) { |
| 1673 | return status; |
| 1674 | } |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 1675 | reply->writeInt32(output); |
| 1676 | reply->writeInt32(stream); |
Eric Laurent | 9ae8c59 | 2017-06-22 17:17:09 -0700 | [diff] [blame] | 1677 | reply->writeInt32(selectedDeviceId); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 1678 | reply->writeInt32(portId); |
Kevin Rocard | 153f92d | 2018-12-18 18:33:28 -0800 | [diff] [blame] | 1679 | reply->writeInt32(secondaryOutputs.size()); |
| 1680 | return reply->write(secondaryOutputs.data(), |
| 1681 | secondaryOutputs.size() * sizeof(audio_io_handle_t)); |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 1682 | } break; |
| 1683 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1684 | case START_OUTPUT: { |
| 1685 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 1686 | const audio_port_handle_t portId = static_cast <audio_port_handle_t>(data.readInt32()); |
| 1687 | reply->writeInt32(static_cast <uint32_t>(startOutput(portId))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1688 | return NO_ERROR; |
| 1689 | } break; |
| 1690 | |
| 1691 | case STOP_OUTPUT: { |
| 1692 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 1693 | const audio_port_handle_t portId = static_cast <audio_port_handle_t>(data.readInt32()); |
| 1694 | reply->writeInt32(static_cast <uint32_t>(stopOutput(portId))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1695 | return NO_ERROR; |
| 1696 | } break; |
| 1697 | |
| 1698 | case RELEASE_OUTPUT: { |
| 1699 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | d7fe086 | 2018-07-14 16:48:01 -0700 | [diff] [blame] | 1700 | const audio_port_handle_t portId = static_cast <audio_port_handle_t>(data.readInt32()); |
| 1701 | releaseOutput(portId); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1702 | return NO_ERROR; |
| 1703 | } break; |
| 1704 | |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 1705 | case GET_INPUT_FOR_ATTR: { |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1706 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Andy Hung | b027209 | 2018-04-12 11:06:56 -0700 | [diff] [blame] | 1707 | audio_attributes_t attr = {}; |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 1708 | data.read(&attr, sizeof(audio_attributes_t)); |
Kevin Rocard | 39fdbd0 | 2017-11-13 11:15:27 -0800 | [diff] [blame] | 1709 | sanetizeAudioAttributes(&attr); |
Eric Laurent | a54f128 | 2017-07-01 19:39:32 -0700 | [diff] [blame] | 1710 | audio_io_handle_t input = (audio_io_handle_t)data.readInt32(); |
Mikhail Naganov | 2996f67 | 2019-04-18 12:29:59 -0700 | [diff] [blame] | 1711 | audio_unique_id_t riid = (audio_unique_id_t)data.readInt32(); |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 1712 | audio_session_t session = (audio_session_t)data.readInt32(); |
Eric Laurent | b2379ba | 2016-05-23 17:42:12 -0700 | [diff] [blame] | 1713 | pid_t pid = (pid_t)data.readInt32(); |
Eric Laurent | 8c7e6da | 2015-04-21 17:37:00 -0700 | [diff] [blame] | 1714 | uid_t uid = (uid_t)data.readInt32(); |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 1715 | const String16 opPackageName = data.readString16(); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 1716 | audio_config_base_t config; |
| 1717 | memset(&config, 0, sizeof(audio_config_base_t)); |
| 1718 | data.read(&config, sizeof(audio_config_base_t)); |
Glenn Kasten | b3b1660 | 2014-07-16 08:36:31 -0700 | [diff] [blame] | 1719 | audio_input_flags_t flags = (audio_input_flags_t) data.readInt32(); |
Paul McLean | 466dc8e | 2015-04-17 13:15:36 -0600 | [diff] [blame] | 1720 | audio_port_handle_t selectedDeviceId = (audio_port_handle_t) data.readInt32(); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 1721 | audio_port_handle_t portId = (audio_port_handle_t)data.readInt32(); |
Mikhail Naganov | 2996f67 | 2019-04-18 12:29:59 -0700 | [diff] [blame] | 1722 | status_t status = getInputForAttr(&attr, &input, riid, session, pid, uid, |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 1723 | opPackageName, &config, |
Eric Laurent | 9ae8c59 | 2017-06-22 17:17:09 -0700 | [diff] [blame] | 1724 | flags, &selectedDeviceId, &portId); |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 1725 | reply->writeInt32(status); |
| 1726 | if (status == NO_ERROR) { |
| 1727 | reply->writeInt32(input); |
Eric Laurent | 9ae8c59 | 2017-06-22 17:17:09 -0700 | [diff] [blame] | 1728 | reply->writeInt32(selectedDeviceId); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 1729 | reply->writeInt32(portId); |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 1730 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1731 | return NO_ERROR; |
| 1732 | } break; |
| 1733 | |
| 1734 | case START_INPUT: { |
| 1735 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 1736 | audio_port_handle_t portId = static_cast <audio_port_handle_t>(data.readInt32()); |
Eric Laurent | 4eb58f1 | 2018-12-07 16:41:02 -0800 | [diff] [blame] | 1737 | status_t status = startInput(portId); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 1738 | reply->writeInt32(static_cast <uint32_t>(status)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1739 | return NO_ERROR; |
| 1740 | } break; |
| 1741 | |
| 1742 | case STOP_INPUT: { |
| 1743 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 1744 | audio_port_handle_t portId = static_cast <audio_port_handle_t>(data.readInt32()); |
| 1745 | reply->writeInt32(static_cast <uint32_t>(stopInput(portId))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1746 | return NO_ERROR; |
| 1747 | } break; |
| 1748 | |
| 1749 | case RELEASE_INPUT: { |
| 1750 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fee1976 | 2018-01-29 18:44:13 -0800 | [diff] [blame] | 1751 | audio_port_handle_t portId = static_cast <audio_port_handle_t>(data.readInt32()); |
| 1752 | releaseInput(portId); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1753 | return NO_ERROR; |
| 1754 | } break; |
| 1755 | |
| 1756 | case INIT_STREAM_VOLUME: { |
| 1757 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 1758 | audio_stream_type_t stream = |
| 1759 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1760 | int indexMin = data.readInt32(); |
| 1761 | int indexMax = data.readInt32(); |
| 1762 | reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); |
| 1763 | return NO_ERROR; |
| 1764 | } break; |
| 1765 | |
| 1766 | case SET_STREAM_VOLUME: { |
| 1767 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 1768 | audio_stream_type_t stream = |
| 1769 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1770 | int index = data.readInt32(); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 1771 | audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); |
| 1772 | reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, |
| 1773 | index, |
| 1774 | device))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1775 | return NO_ERROR; |
| 1776 | } break; |
| 1777 | |
| 1778 | case GET_STREAM_VOLUME: { |
| 1779 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 1780 | audio_stream_type_t stream = |
| 1781 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 1782 | audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); |
Robert Shih | 8923543 | 2015-09-02 16:46:59 -0700 | [diff] [blame] | 1783 | int index = 0; |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 1784 | status_t status = getStreamVolumeIndex(stream, &index, device); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1785 | reply->writeInt32(index); |
| 1786 | reply->writeInt32(static_cast <uint32_t>(status)); |
| 1787 | return NO_ERROR; |
| 1788 | } break; |
| 1789 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1790 | case GET_STRATEGY_FOR_STREAM: { |
| 1791 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 1792 | audio_stream_type_t stream = |
| 1793 | static_cast <audio_stream_type_t>(data.readInt32()); |
François Gaffie | c005e56 | 2018-11-06 15:04:49 +0100 | [diff] [blame] | 1794 | reply->writeUint32(getStrategyForStream(stream)); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1795 | return NO_ERROR; |
| 1796 | } break; |
| 1797 | |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 1798 | case SET_VOLUME_ATTRIBUTES: { |
| 1799 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1800 | audio_attributes_t attributes = {}; |
| 1801 | status_t status = data.read(&attributes, sizeof(audio_attributes_t)); |
| 1802 | if (status != NO_ERROR) { |
| 1803 | return status; |
| 1804 | } |
| 1805 | int index = data.readInt32(); |
| 1806 | audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); |
| 1807 | |
| 1808 | reply->writeInt32(static_cast <uint32_t>(setVolumeIndexForAttributes(attributes, |
| 1809 | index, device))); |
| 1810 | return NO_ERROR; |
| 1811 | } break; |
| 1812 | |
| 1813 | case GET_VOLUME_ATTRIBUTES: { |
| 1814 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1815 | audio_attributes_t attributes = {}; |
| 1816 | status_t status = data.read(&attributes, sizeof(audio_attributes_t)); |
| 1817 | if (status != NO_ERROR) { |
| 1818 | return status; |
| 1819 | } |
| 1820 | audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); |
| 1821 | |
| 1822 | int index = 0; |
| 1823 | status = getVolumeIndexForAttributes(attributes, index, device); |
| 1824 | reply->writeInt32(static_cast <uint32_t>(status)); |
| 1825 | if (status == NO_ERROR) { |
| 1826 | reply->writeInt32(index); |
| 1827 | } |
| 1828 | return NO_ERROR; |
| 1829 | } break; |
| 1830 | |
| 1831 | case GET_MIN_VOLUME_FOR_ATTRIBUTES: { |
| 1832 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1833 | audio_attributes_t attributes = {}; |
| 1834 | status_t status = data.read(&attributes, sizeof(audio_attributes_t)); |
| 1835 | if (status != NO_ERROR) { |
| 1836 | return status; |
| 1837 | } |
| 1838 | |
| 1839 | int index = 0; |
| 1840 | status = getMinVolumeIndexForAttributes(attributes, index); |
| 1841 | reply->writeInt32(static_cast <uint32_t>(status)); |
| 1842 | if (status == NO_ERROR) { |
| 1843 | reply->writeInt32(index); |
| 1844 | } |
| 1845 | return NO_ERROR; |
| 1846 | } break; |
| 1847 | |
| 1848 | case GET_MAX_VOLUME_FOR_ATTRIBUTES: { |
| 1849 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1850 | audio_attributes_t attributes = {}; |
| 1851 | status_t status = data.read(&attributes, sizeof(audio_attributes_t)); |
| 1852 | if (status != NO_ERROR) { |
| 1853 | return status; |
| 1854 | } |
| 1855 | |
| 1856 | int index = 0; |
| 1857 | status = getMaxVolumeIndexForAttributes(attributes, index); |
| 1858 | reply->writeInt32(static_cast <uint32_t>(status)); |
| 1859 | if (status == NO_ERROR) { |
| 1860 | reply->writeInt32(index); |
| 1861 | } |
| 1862 | return NO_ERROR; |
| 1863 | } break; |
| 1864 | |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 1865 | case GET_DEVICES_FOR_STREAM: { |
| 1866 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 1867 | audio_stream_type_t stream = |
| 1868 | static_cast <audio_stream_type_t>(data.readInt32()); |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 1869 | reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); |
| 1870 | return NO_ERROR; |
| 1871 | } break; |
| 1872 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1873 | case GET_OUTPUT_FOR_EFFECT: { |
| 1874 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Andy Hung | b027209 | 2018-04-12 11:06:56 -0700 | [diff] [blame] | 1875 | effect_descriptor_t desc = {}; |
| 1876 | if (data.read(&desc, sizeof(desc)) != NO_ERROR) { |
| 1877 | android_errorWriteLog(0x534e4554, "73126106"); |
| 1878 | } |
| 1879 | (void)sanitizeEffectDescriptor(&desc); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1880 | audio_io_handle_t output = getOutputForEffect(&desc); |
| 1881 | reply->writeInt32(static_cast <int>(output)); |
| 1882 | return NO_ERROR; |
| 1883 | } break; |
| 1884 | |
| 1885 | case REGISTER_EFFECT: { |
| 1886 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Andy Hung | b027209 | 2018-04-12 11:06:56 -0700 | [diff] [blame] | 1887 | effect_descriptor_t desc = {}; |
| 1888 | if (data.read(&desc, sizeof(desc)) != NO_ERROR) { |
| 1889 | android_errorWriteLog(0x534e4554, "73126106"); |
| 1890 | } |
| 1891 | (void)sanitizeEffectDescriptor(&desc); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 1892 | audio_io_handle_t io = data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1893 | uint32_t strategy = data.readInt32(); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1894 | audio_session_t session = (audio_session_t) data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1895 | int id = data.readInt32(); |
| 1896 | reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 1897 | io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1898 | strategy, |
| 1899 | session, |
| 1900 | id))); |
| 1901 | return NO_ERROR; |
| 1902 | } break; |
| 1903 | |
| 1904 | case UNREGISTER_EFFECT: { |
| 1905 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1906 | int id = data.readInt32(); |
| 1907 | reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); |
| 1908 | return NO_ERROR; |
| 1909 | } break; |
| 1910 | |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 1911 | case SET_EFFECT_ENABLED: { |
| 1912 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1913 | int id = data.readInt32(); |
| 1914 | bool enabled = static_cast <bool>(data.readInt32()); |
| 1915 | reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled))); |
| 1916 | return NO_ERROR; |
| 1917 | } break; |
| 1918 | |
Eric Laurent | 6c79632 | 2019-04-09 14:13:17 -0700 | [diff] [blame] | 1919 | case MOVE_EFFECTS_TO_IO: { |
| 1920 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1921 | std::vector<int> ids; |
| 1922 | int32_t size; |
| 1923 | status_t status = data.readInt32(&size); |
| 1924 | if (status != NO_ERROR) { |
| 1925 | return status; |
| 1926 | } |
| 1927 | if (size > MAX_ITEMS_PER_LIST) { |
| 1928 | return BAD_VALUE; |
| 1929 | } |
| 1930 | for (int32_t i = 0; i < size; i++) { |
| 1931 | int id; |
| 1932 | status = data.readInt32(&id); |
| 1933 | if (status != NO_ERROR) { |
| 1934 | return status; |
| 1935 | } |
| 1936 | ids.push_back(id); |
| 1937 | } |
| 1938 | |
| 1939 | audio_io_handle_t io = data.readInt32(); |
| 1940 | reply->writeInt32(static_cast <int32_t>(moveEffectsToIo(ids, io))); |
| 1941 | return NO_ERROR; |
| 1942 | } break; |
| 1943 | |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 1944 | case IS_STREAM_ACTIVE: { |
| 1945 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 1946 | audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 1947 | uint32_t inPastMs = (uint32_t)data.readInt32(); |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 1948 | reply->writeInt32( isStreamActive(stream, inPastMs) ); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 1949 | return NO_ERROR; |
| 1950 | } break; |
| 1951 | |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 1952 | case IS_STREAM_ACTIVE_REMOTELY: { |
| 1953 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1954 | audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); |
| 1955 | uint32_t inPastMs = (uint32_t)data.readInt32(); |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 1956 | reply->writeInt32( isStreamActiveRemotely(stream, inPastMs) ); |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 1957 | return NO_ERROR; |
| 1958 | } break; |
| 1959 | |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 1960 | case IS_SOURCE_ACTIVE: { |
| 1961 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1962 | audio_source_t source = (audio_source_t) data.readInt32(); |
| 1963 | reply->writeInt32( isSourceActive(source)); |
| 1964 | return NO_ERROR; |
| 1965 | } |
| 1966 | |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 1967 | case QUERY_DEFAULT_PRE_PROCESSING: { |
| 1968 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1969 | audio_session_t audioSession = (audio_session_t) data.readInt32(); |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 1970 | uint32_t count = data.readInt32(); |
Eric Laurent | 74adca9 | 2014-11-05 12:15:36 -0800 | [diff] [blame] | 1971 | if (count > AudioEffect::kMaxPreProcessing) { |
| 1972 | count = AudioEffect::kMaxPreProcessing; |
| 1973 | } |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 1974 | uint32_t retCount = count; |
Andy Hung | b027209 | 2018-04-12 11:06:56 -0700 | [diff] [blame] | 1975 | effect_descriptor_t *descriptors = new effect_descriptor_t[count]{}; |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 1976 | status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount); |
| 1977 | reply->writeInt32(status); |
| 1978 | if (status != NO_ERROR && status != NO_MEMORY) { |
| 1979 | retCount = 0; |
| 1980 | } |
| 1981 | reply->writeInt32(retCount); |
Eric Laurent | 74adca9 | 2014-11-05 12:15:36 -0800 | [diff] [blame] | 1982 | if (retCount != 0) { |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 1983 | if (retCount < count) { |
| 1984 | count = retCount; |
| 1985 | } |
| 1986 | reply->write(descriptors, sizeof(effect_descriptor_t) * count); |
| 1987 | } |
| 1988 | delete[] descriptors; |
| 1989 | return status; |
| 1990 | } |
| 1991 | |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 1992 | case IS_OFFLOAD_SUPPORTED: { |
| 1993 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Andy Hung | b027209 | 2018-04-12 11:06:56 -0700 | [diff] [blame] | 1994 | audio_offload_info_t info = {}; |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 1995 | data.read(&info, sizeof(audio_offload_info_t)); |
| 1996 | bool isSupported = isOffloadSupported(info); |
| 1997 | reply->writeInt32(isSupported); |
| 1998 | return NO_ERROR; |
| 1999 | } |
| 2000 | |
Michael Chan | a94fbb2 | 2018-04-24 14:31:19 +1000 | [diff] [blame] | 2001 | case IS_DIRECT_OUTPUT_SUPPORTED: { |
| 2002 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2003 | audio_config_base_t config = {}; |
| 2004 | audio_attributes_t attributes = {}; |
| 2005 | status_t status = data.read(&config, sizeof(audio_config_base_t)); |
| 2006 | if (status != NO_ERROR) return status; |
| 2007 | status = data.read(&attributes, sizeof(audio_attributes_t)); |
| 2008 | if (status != NO_ERROR) return status; |
| 2009 | reply->writeInt32(isDirectOutputSupported(config, attributes)); |
| 2010 | return NO_ERROR; |
| 2011 | } |
| 2012 | |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2013 | case LIST_AUDIO_PORTS: { |
| 2014 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2015 | audio_port_role_t role = (audio_port_role_t)data.readInt32(); |
| 2016 | audio_port_type_t type = (audio_port_type_t)data.readInt32(); |
| 2017 | unsigned int numPortsReq = data.readInt32(); |
Eric Laurent | 1d670b1 | 2015-02-06 10:44:24 -0800 | [diff] [blame] | 2018 | if (numPortsReq > MAX_ITEMS_PER_LIST) { |
| 2019 | numPortsReq = MAX_ITEMS_PER_LIST; |
| 2020 | } |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2021 | unsigned int numPorts = numPortsReq; |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2022 | struct audio_port *ports = |
| 2023 | (struct audio_port *)calloc(numPortsReq, sizeof(struct audio_port)); |
Eric Laurent | 1d670b1 | 2015-02-06 10:44:24 -0800 | [diff] [blame] | 2024 | if (ports == NULL) { |
| 2025 | reply->writeInt32(NO_MEMORY); |
| 2026 | reply->writeInt32(0); |
| 2027 | return NO_ERROR; |
| 2028 | } |
| 2029 | unsigned int generation; |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2030 | status_t status = listAudioPorts(role, type, &numPorts, ports, &generation); |
| 2031 | reply->writeInt32(status); |
| 2032 | reply->writeInt32(numPorts); |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2033 | |
| 2034 | if (status == NO_ERROR) { |
| 2035 | if (numPortsReq > numPorts) { |
| 2036 | numPortsReq = numPorts; |
| 2037 | } |
| 2038 | reply->write(ports, numPortsReq * sizeof(struct audio_port)); |
| 2039 | reply->writeInt32(generation); |
| 2040 | } |
| 2041 | free(ports); |
| 2042 | return NO_ERROR; |
| 2043 | } |
| 2044 | |
| 2045 | case GET_AUDIO_PORT: { |
| 2046 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 2047 | struct audio_port port = {}; |
| 2048 | if (data.read(&port, sizeof(struct audio_port)) != NO_ERROR) { |
| 2049 | ALOGE("b/23912202"); |
| 2050 | } |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2051 | status_t status = getAudioPort(&port); |
| 2052 | reply->writeInt32(status); |
| 2053 | if (status == NO_ERROR) { |
| 2054 | reply->write(&port, sizeof(struct audio_port)); |
| 2055 | } |
| 2056 | return NO_ERROR; |
| 2057 | } |
| 2058 | |
| 2059 | case CREATE_AUDIO_PATCH: { |
| 2060 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Andy Hung | b027209 | 2018-04-12 11:06:56 -0700 | [diff] [blame] | 2061 | struct audio_patch patch = {}; |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2062 | data.read(&patch, sizeof(struct audio_patch)); |
Glenn Kasten | a13cde9 | 2016-03-28 15:26:02 -0700 | [diff] [blame] | 2063 | audio_patch_handle_t handle = AUDIO_PATCH_HANDLE_NONE; |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 2064 | if (data.read(&handle, sizeof(audio_patch_handle_t)) != NO_ERROR) { |
| 2065 | ALOGE("b/23912202"); |
| 2066 | } |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2067 | status_t status = createAudioPatch(&patch, &handle); |
| 2068 | reply->writeInt32(status); |
| 2069 | if (status == NO_ERROR) { |
| 2070 | reply->write(&handle, sizeof(audio_patch_handle_t)); |
| 2071 | } |
| 2072 | return NO_ERROR; |
| 2073 | } |
| 2074 | |
| 2075 | case RELEASE_AUDIO_PATCH: { |
| 2076 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Andy Hung | b027209 | 2018-04-12 11:06:56 -0700 | [diff] [blame] | 2077 | audio_patch_handle_t handle = AUDIO_PATCH_HANDLE_NONE; |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2078 | data.read(&handle, sizeof(audio_patch_handle_t)); |
| 2079 | status_t status = releaseAudioPatch(handle); |
| 2080 | reply->writeInt32(status); |
| 2081 | return NO_ERROR; |
| 2082 | } |
| 2083 | |
| 2084 | case LIST_AUDIO_PATCHES: { |
| 2085 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2086 | unsigned int numPatchesReq = data.readInt32(); |
Eric Laurent | 1d670b1 | 2015-02-06 10:44:24 -0800 | [diff] [blame] | 2087 | if (numPatchesReq > MAX_ITEMS_PER_LIST) { |
| 2088 | numPatchesReq = MAX_ITEMS_PER_LIST; |
| 2089 | } |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2090 | unsigned int numPatches = numPatchesReq; |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2091 | struct audio_patch *patches = |
| 2092 | (struct audio_patch *)calloc(numPatchesReq, |
| 2093 | sizeof(struct audio_patch)); |
Eric Laurent | 1d670b1 | 2015-02-06 10:44:24 -0800 | [diff] [blame] | 2094 | if (patches == NULL) { |
| 2095 | reply->writeInt32(NO_MEMORY); |
| 2096 | reply->writeInt32(0); |
| 2097 | return NO_ERROR; |
| 2098 | } |
| 2099 | unsigned int generation; |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2100 | status_t status = listAudioPatches(&numPatches, patches, &generation); |
| 2101 | reply->writeInt32(status); |
| 2102 | reply->writeInt32(numPatches); |
| 2103 | if (status == NO_ERROR) { |
| 2104 | if (numPatchesReq > numPatches) { |
| 2105 | numPatchesReq = numPatches; |
| 2106 | } |
| 2107 | reply->write(patches, numPatchesReq * sizeof(struct audio_patch)); |
| 2108 | reply->writeInt32(generation); |
| 2109 | } |
| 2110 | free(patches); |
| 2111 | return NO_ERROR; |
| 2112 | } |
| 2113 | |
| 2114 | case SET_AUDIO_PORT_CONFIG: { |
| 2115 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Andy Hung | b027209 | 2018-04-12 11:06:56 -0700 | [diff] [blame] | 2116 | struct audio_port_config config = {}; |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2117 | data.read(&config, sizeof(struct audio_port_config)); |
Andy Hung | b027209 | 2018-04-12 11:06:56 -0700 | [diff] [blame] | 2118 | (void)sanitizeAudioPortConfig(&config); |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2119 | status_t status = setAudioPortConfig(&config); |
| 2120 | reply->writeInt32(status); |
| 2121 | return NO_ERROR; |
| 2122 | } |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 2123 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 2124 | case REGISTER_CLIENT: { |
| 2125 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2126 | sp<IAudioPolicyServiceClient> client = interface_cast<IAudioPolicyServiceClient>( |
| 2127 | data.readStrongBinder()); |
| 2128 | registerClient(client); |
| 2129 | return NO_ERROR; |
| 2130 | } break; |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 2131 | |
Eric Laurent | e8726fe | 2015-06-26 09:39:24 -0700 | [diff] [blame] | 2132 | case SET_AUDIO_PORT_CALLBACK_ENABLED: { |
| 2133 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2134 | setAudioPortCallbacksEnabled(data.readInt32() == 1); |
| 2135 | return NO_ERROR; |
| 2136 | } break; |
| 2137 | |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 2138 | case SET_AUDIO_VOLUME_GROUP_CALLBACK_ENABLED: { |
| 2139 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2140 | setAudioVolumeGroupCallbacksEnabled(data.readInt32() == 1); |
| 2141 | return NO_ERROR; |
| 2142 | } break; |
| 2143 | |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 2144 | case ACQUIRE_SOUNDTRIGGER_SESSION: { |
| 2145 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | a13cde9 | 2016-03-28 15:26:02 -0700 | [diff] [blame] | 2146 | audio_session_t session = AUDIO_SESSION_NONE; |
| 2147 | audio_io_handle_t ioHandle = AUDIO_IO_HANDLE_NONE; |
| 2148 | audio_devices_t device = AUDIO_DEVICE_NONE; |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 2149 | status_t status = acquireSoundTriggerSession(&session, &ioHandle, &device); |
| 2150 | reply->writeInt32(status); |
| 2151 | if (status == NO_ERROR) { |
| 2152 | reply->writeInt32(session); |
| 2153 | reply->writeInt32(ioHandle); |
| 2154 | reply->writeInt32(device); |
| 2155 | } |
| 2156 | return NO_ERROR; |
| 2157 | } break; |
| 2158 | |
| 2159 | case RELEASE_SOUNDTRIGGER_SESSION: { |
| 2160 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 2161 | audio_session_t session = (audio_session_t)data.readInt32(); |
| 2162 | status_t status = releaseSoundTriggerSession(session); |
| 2163 | reply->writeInt32(status); |
| 2164 | return NO_ERROR; |
| 2165 | } break; |
| 2166 | |
Eric Laurent | bb6c9a0 | 2014-09-25 14:11:47 -0700 | [diff] [blame] | 2167 | case GET_PHONE_STATE: { |
| 2168 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2169 | reply->writeInt32((int32_t)getPhoneState()); |
| 2170 | return NO_ERROR; |
| 2171 | } break; |
| 2172 | |
Eric Laurent | baac183 | 2014-12-01 17:52:59 -0800 | [diff] [blame] | 2173 | case REGISTER_POLICY_MIXES: { |
| 2174 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2175 | bool registration = data.readInt32() == 1; |
| 2176 | Vector<AudioMix> mixes; |
| 2177 | size_t size = (size_t)data.readInt32(); |
| 2178 | if (size > MAX_MIXES_PER_POLICY) { |
| 2179 | size = MAX_MIXES_PER_POLICY; |
| 2180 | } |
| 2181 | for (size_t i = 0; i < size; i++) { |
| 2182 | AudioMix mix; |
| 2183 | if (mix.readFromParcel((Parcel*)&data) == NO_ERROR) { |
| 2184 | mixes.add(mix); |
| 2185 | } |
| 2186 | } |
| 2187 | status_t status = registerPolicyMixes(mixes, registration); |
| 2188 | reply->writeInt32(status); |
| 2189 | return NO_ERROR; |
| 2190 | } break; |
| 2191 | |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 2192 | case START_AUDIO_SOURCE: { |
| 2193 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Andy Hung | b027209 | 2018-04-12 11:06:56 -0700 | [diff] [blame] | 2194 | struct audio_port_config source = {}; |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 2195 | data.read(&source, sizeof(struct audio_port_config)); |
Andy Hung | b027209 | 2018-04-12 11:06:56 -0700 | [diff] [blame] | 2196 | (void)sanitizeAudioPortConfig(&source); |
| 2197 | audio_attributes_t attributes = {}; |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 2198 | data.read(&attributes, sizeof(audio_attributes_t)); |
Kevin Rocard | 39fdbd0 | 2017-11-13 11:15:27 -0800 | [diff] [blame] | 2199 | sanetizeAudioAttributes(&attributes); |
Eric Laurent | 3e6c7e1 | 2018-07-27 17:09:23 -0700 | [diff] [blame] | 2200 | audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE; |
| 2201 | status_t status = startAudioSource(&source, &attributes, &portId); |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 2202 | reply->writeInt32(status); |
Eric Laurent | 3e6c7e1 | 2018-07-27 17:09:23 -0700 | [diff] [blame] | 2203 | reply->writeInt32(portId); |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 2204 | return NO_ERROR; |
| 2205 | } break; |
| 2206 | |
| 2207 | case STOP_AUDIO_SOURCE: { |
| 2208 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | 3e6c7e1 | 2018-07-27 17:09:23 -0700 | [diff] [blame] | 2209 | audio_port_handle_t portId = (audio_port_handle_t) data.readInt32(); |
| 2210 | status_t status = stopAudioSource(portId); |
Eric Laurent | 554a277 | 2015-04-10 11:29:24 -0700 | [diff] [blame] | 2211 | reply->writeInt32(status); |
| 2212 | return NO_ERROR; |
| 2213 | } break; |
| 2214 | |
Andy Hung | 2ddee19 | 2015-12-18 17:34:44 -0800 | [diff] [blame] | 2215 | case SET_MASTER_MONO: { |
| 2216 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2217 | bool mono = static_cast<bool>(data.readInt32()); |
| 2218 | status_t status = setMasterMono(mono); |
| 2219 | reply->writeInt32(status); |
| 2220 | return NO_ERROR; |
| 2221 | } break; |
| 2222 | |
| 2223 | case GET_MASTER_MONO: { |
| 2224 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2225 | bool mono; |
| 2226 | status_t status = getMasterMono(&mono); |
| 2227 | reply->writeInt32(status); |
| 2228 | if (status == NO_ERROR) { |
| 2229 | reply->writeInt32(static_cast<int32_t>(mono)); |
| 2230 | } |
| 2231 | return NO_ERROR; |
| 2232 | } break; |
| 2233 | |
Eric Laurent | ac9cef5 | 2017-06-09 15:46:26 -0700 | [diff] [blame] | 2234 | case GET_STREAM_VOLUME_DB: { |
| 2235 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2236 | audio_stream_type_t stream = |
| 2237 | static_cast <audio_stream_type_t>(data.readInt32()); |
| 2238 | int index = static_cast <int>(data.readInt32()); |
| 2239 | audio_devices_t device = |
| 2240 | static_cast <audio_devices_t>(data.readUint32()); |
| 2241 | reply->writeFloat(getStreamVolumeDB(stream, index, device)); |
| 2242 | return NO_ERROR; |
| 2243 | } |
| 2244 | |
jiabin | 8177290 | 2018-04-02 17:52:27 -0700 | [diff] [blame] | 2245 | case GET_SURROUND_FORMATS: { |
| 2246 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2247 | unsigned int numSurroundFormatsReq = data.readUint32(); |
| 2248 | if (numSurroundFormatsReq > MAX_ITEMS_PER_LIST) { |
| 2249 | numSurroundFormatsReq = MAX_ITEMS_PER_LIST; |
| 2250 | } |
| 2251 | bool reported = data.readBool(); |
| 2252 | unsigned int numSurroundFormats = numSurroundFormatsReq; |
| 2253 | audio_format_t *surroundFormats = (audio_format_t *)calloc( |
| 2254 | numSurroundFormats, sizeof(audio_format_t)); |
| 2255 | bool *surroundFormatsEnabled = (bool *)calloc(numSurroundFormats, sizeof(bool)); |
| 2256 | if (numSurroundFormatsReq > 0 && |
| 2257 | (surroundFormats == NULL || surroundFormatsEnabled == NULL)) { |
| 2258 | free(surroundFormats); |
| 2259 | free(surroundFormatsEnabled); |
| 2260 | reply->writeInt32(NO_MEMORY); |
| 2261 | return NO_ERROR; |
| 2262 | } |
| 2263 | status_t status = getSurroundFormats( |
| 2264 | &numSurroundFormats, surroundFormats, surroundFormatsEnabled, reported); |
| 2265 | reply->writeInt32(status); |
| 2266 | |
| 2267 | if (status == NO_ERROR) { |
| 2268 | reply->writeUint32(numSurroundFormats); |
| 2269 | if (numSurroundFormatsReq > numSurroundFormats) { |
| 2270 | numSurroundFormatsReq = numSurroundFormats; |
| 2271 | } |
| 2272 | reply->write(surroundFormats, numSurroundFormatsReq * sizeof(audio_format_t)); |
| 2273 | reply->write(surroundFormatsEnabled, numSurroundFormatsReq * sizeof(bool)); |
| 2274 | } |
| 2275 | free(surroundFormats); |
| 2276 | free(surroundFormatsEnabled); |
| 2277 | return NO_ERROR; |
| 2278 | } |
| 2279 | |
| 2280 | case SET_SURROUND_FORMAT_ENABLED: { |
| 2281 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2282 | audio_format_t audioFormat = (audio_format_t) data.readInt32(); |
| 2283 | bool enabled = data.readBool(); |
| 2284 | status_t status = setSurroundFormatEnabled(audioFormat, enabled); |
| 2285 | reply->writeInt32(status); |
| 2286 | return NO_ERROR; |
| 2287 | } |
| 2288 | |
Arun Mirpuri | 11029ad | 2018-12-19 20:45:19 -0800 | [diff] [blame] | 2289 | case GET_OFFLOAD_FORMATS_A2DP: { |
| 2290 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2291 | std::vector<audio_format_t> encodingFormats; |
| 2292 | status_t status = getHwOffloadEncodingFormatsSupportedForA2DP(&encodingFormats); |
| 2293 | reply->writeInt32(status); |
| 2294 | if (status != NO_ERROR) { |
| 2295 | return NO_ERROR; |
| 2296 | } |
| 2297 | reply->writeUint32(static_cast<uint32_t>(encodingFormats.size())); |
| 2298 | for (size_t i = 0; i < encodingFormats.size(); i++) |
| 2299 | reply->writeInt32(static_cast<int32_t>(encodingFormats[i])); |
| 2300 | return NO_ERROR; |
| 2301 | } |
| 2302 | |
| 2303 | |
Ari Hausman-Cohen | 433722e | 2018-04-24 14:25:22 -0700 | [diff] [blame] | 2304 | case ADD_STREAM_DEFAULT_EFFECT: { |
| 2305 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2306 | effect_uuid_t type; |
| 2307 | status_t status = data.read(&type, sizeof(effect_uuid_t)); |
| 2308 | if (status != NO_ERROR) { |
| 2309 | return status; |
| 2310 | } |
| 2311 | String16 opPackageName; |
| 2312 | status = data.readString16(&opPackageName); |
| 2313 | if (status != NO_ERROR) { |
| 2314 | return status; |
| 2315 | } |
| 2316 | effect_uuid_t uuid; |
| 2317 | status = data.read(&uuid, sizeof(effect_uuid_t)); |
| 2318 | if (status != NO_ERROR) { |
| 2319 | return status; |
| 2320 | } |
| 2321 | int32_t priority = data.readInt32(); |
| 2322 | audio_usage_t usage = (audio_usage_t) data.readInt32(); |
| 2323 | audio_unique_id_t id = 0; |
| 2324 | reply->writeInt32(static_cast <int32_t>(addStreamDefaultEffect(&type, |
| 2325 | opPackageName, |
| 2326 | &uuid, |
| 2327 | priority, |
| 2328 | usage, |
| 2329 | &id))); |
| 2330 | reply->writeInt32(id); |
| 2331 | return NO_ERROR; |
| 2332 | } |
| 2333 | |
| 2334 | case REMOVE_STREAM_DEFAULT_EFFECT: { |
| 2335 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2336 | audio_unique_id_t id = static_cast<audio_unique_id_t>(data.readInt32()); |
| 2337 | reply->writeInt32(static_cast <int32_t>(removeStreamDefaultEffect(id))); |
| 2338 | return NO_ERROR; |
| 2339 | } |
| 2340 | |
Ari Hausman-Cohen | 2462831 | 2018-08-13 15:01:09 -0700 | [diff] [blame] | 2341 | case ADD_SOURCE_DEFAULT_EFFECT: { |
| 2342 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2343 | effect_uuid_t type; |
| 2344 | status_t status = data.read(&type, sizeof(effect_uuid_t)); |
| 2345 | if (status != NO_ERROR) { |
| 2346 | return status; |
| 2347 | } |
| 2348 | String16 opPackageName; |
| 2349 | status = data.readString16(&opPackageName); |
| 2350 | if (status != NO_ERROR) { |
| 2351 | return status; |
| 2352 | } |
| 2353 | effect_uuid_t uuid; |
| 2354 | status = data.read(&uuid, sizeof(effect_uuid_t)); |
| 2355 | if (status != NO_ERROR) { |
| 2356 | return status; |
| 2357 | } |
| 2358 | int32_t priority = data.readInt32(); |
| 2359 | audio_source_t source = (audio_source_t) data.readInt32(); |
| 2360 | audio_unique_id_t id = 0; |
| 2361 | reply->writeInt32(static_cast <int32_t>(addSourceDefaultEffect(&type, |
| 2362 | opPackageName, |
| 2363 | &uuid, |
| 2364 | priority, |
| 2365 | source, |
| 2366 | &id))); |
| 2367 | reply->writeInt32(id); |
| 2368 | return NO_ERROR; |
| 2369 | } |
| 2370 | |
| 2371 | case REMOVE_SOURCE_DEFAULT_EFFECT: { |
| 2372 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2373 | audio_unique_id_t id = static_cast<audio_unique_id_t>(data.readInt32()); |
| 2374 | reply->writeInt32(static_cast <int32_t>(removeSourceDefaultEffect(id))); |
| 2375 | return NO_ERROR; |
| 2376 | } |
| 2377 | |
Eric Laurent | b78763e | 2018-10-17 10:08:02 -0700 | [diff] [blame] | 2378 | case SET_ASSISTANT_UID: { |
| 2379 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2380 | int32_t uid; |
| 2381 | status_t status = data.readInt32(&uid); |
| 2382 | if (status != NO_ERROR) { |
| 2383 | return status; |
| 2384 | } |
| 2385 | status = setAssistantUid(uid); |
| 2386 | reply->writeInt32(static_cast <int32_t>(status)); |
| 2387 | return NO_ERROR; |
| 2388 | } |
| 2389 | |
| 2390 | case SET_A11Y_SERVICES_UIDS: { |
| 2391 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2392 | std::vector<uid_t> uids; |
| 2393 | int32_t size; |
| 2394 | status_t status = data.readInt32(&size); |
| 2395 | if (status != NO_ERROR) { |
| 2396 | return status; |
| 2397 | } |
| 2398 | if (size > MAX_ITEMS_PER_LIST) { |
| 2399 | size = MAX_ITEMS_PER_LIST; |
| 2400 | } |
| 2401 | for (int32_t i = 0; i < size; i++) { |
| 2402 | int32_t uid; |
| 2403 | status = data.readInt32(&uid); |
| 2404 | if (status != NO_ERROR) { |
| 2405 | return status; |
| 2406 | } |
| 2407 | uids.push_back(uid); |
| 2408 | } |
| 2409 | status = setA11yServicesUids(uids); |
| 2410 | reply->writeInt32(static_cast <int32_t>(status)); |
| 2411 | return NO_ERROR; |
| 2412 | } |
| 2413 | |
jiabin | 6012f91 | 2018-11-02 17:06:30 -0700 | [diff] [blame] | 2414 | case IS_HAPTIC_PLAYBACK_SUPPORTED: { |
| 2415 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2416 | bool isSupported = isHapticPlaybackSupported(); |
| 2417 | reply->writeBool(isSupported); |
Kevin Rocard | b99cc75 | 2019-03-21 20:52:24 -0700 | [diff] [blame] | 2418 | return NO_ERROR; |
Jean-Michel Trivi | bda70da | 2018-12-19 07:30:15 -0800 | [diff] [blame] | 2419 | } |
Jean-Michel Trivi | bda70da | 2018-12-19 07:30:15 -0800 | [diff] [blame] | 2420 | case SET_UID_DEVICE_AFFINITY: { |
| 2421 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2422 | const uid_t uid = (uid_t) data.readInt32(); |
| 2423 | Vector<AudioDeviceTypeAddr> devices; |
| 2424 | size_t size = (size_t)data.readInt32(); |
| 2425 | for (size_t i = 0; i < size; i++) { |
| 2426 | AudioDeviceTypeAddr device; |
| 2427 | if (device.readFromParcel((Parcel*)&data) == NO_ERROR) { |
| 2428 | devices.add(device); |
| 2429 | } |
| 2430 | } |
| 2431 | status_t status = setUidDeviceAffinities(uid, devices); |
| 2432 | reply->writeInt32(status); |
| 2433 | return NO_ERROR; |
| 2434 | } |
| 2435 | |
| 2436 | case REMOVE_UID_DEVICE_AFFINITY: { |
| 2437 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2438 | const uid_t uid = (uid_t) data.readInt32(); |
| 2439 | status_t status = removeUidDeviceAffinities(uid); |
| 2440 | reply->writeInt32(status); |
jiabin | 6012f91 | 2018-11-02 17:06:30 -0700 | [diff] [blame] | 2441 | return NO_ERROR; |
| 2442 | } |
| 2443 | |
Oscar Azucena | 90e7763 | 2019-11-27 17:12:28 -0800 | [diff] [blame] | 2444 | case SET_USERID_DEVICE_AFFINITY: { |
| 2445 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2446 | const int userId = (int) data.readInt32(); |
| 2447 | Vector<AudioDeviceTypeAddr> devices; |
| 2448 | size_t size = (size_t)data.readInt32(); |
| 2449 | for (size_t i = 0; i < size; i++) { |
| 2450 | AudioDeviceTypeAddr device; |
| 2451 | if (device.readFromParcel((Parcel*)&data) == NO_ERROR) { |
| 2452 | devices.add(device); |
| 2453 | } |
| 2454 | } |
| 2455 | status_t status = setUserIdDeviceAffinities(userId, devices); |
| 2456 | reply->writeInt32(status); |
| 2457 | return NO_ERROR; |
| 2458 | } |
| 2459 | |
| 2460 | case REMOVE_USERID_DEVICE_AFFINITY: { |
| 2461 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2462 | const int userId = (int) data.readInt32(); |
| 2463 | status_t status = removeUserIdDeviceAffinities(userId); |
| 2464 | reply->writeInt32(status); |
| 2465 | return NO_ERROR; |
| 2466 | } |
| 2467 | |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 2468 | case LIST_AUDIO_PRODUCT_STRATEGIES: { |
| 2469 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2470 | AudioProductStrategyVector strategies; |
| 2471 | status_t status = listAudioProductStrategies(strategies); |
| 2472 | reply->writeInt32(status); |
| 2473 | if (status != NO_ERROR) { |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 2474 | return NO_ERROR; |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 2475 | } |
| 2476 | size_t size = strategies.size(); |
| 2477 | size_t sizePosition = reply->dataPosition(); |
| 2478 | reply->writeInt32(size); |
| 2479 | size_t finalSize = size; |
| 2480 | for (size_t i = 0; i < size; i++) { |
| 2481 | size_t position = reply->dataPosition(); |
| 2482 | if (strategies[i].writeToParcel(reply) != NO_ERROR) { |
| 2483 | reply->setDataPosition(position); |
| 2484 | finalSize--; |
| 2485 | } |
| 2486 | } |
| 2487 | if (size != finalSize) { |
| 2488 | size_t position = reply->dataPosition(); |
| 2489 | reply->setDataPosition(sizePosition); |
| 2490 | reply->writeInt32(finalSize); |
| 2491 | reply->setDataPosition(position); |
| 2492 | } |
| 2493 | return NO_ERROR; |
| 2494 | } |
| 2495 | |
| 2496 | case GET_STRATEGY_FOR_ATTRIBUTES: { |
| 2497 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2498 | AudioAttributes attributes; |
| 2499 | status_t status = attributes.readFromParcel(&data); |
| 2500 | if (status != NO_ERROR) { |
| 2501 | return status; |
| 2502 | } |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 2503 | product_strategy_t strategy; |
| 2504 | status = getProductStrategyFromAudioAttributes(attributes, strategy); |
| 2505 | reply->writeInt32(status); |
| 2506 | if (status != NO_ERROR) { |
| 2507 | return NO_ERROR; |
| 2508 | } |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 2509 | reply->writeUint32(static_cast<int>(strategy)); |
| 2510 | return NO_ERROR; |
| 2511 | } |
| 2512 | |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 2513 | case LIST_AUDIO_VOLUME_GROUPS: { |
| 2514 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2515 | AudioVolumeGroupVector groups; |
| 2516 | status_t status = listAudioVolumeGroups(groups); |
| 2517 | reply->writeInt32(status); |
| 2518 | if (status != NO_ERROR) { |
| 2519 | return NO_ERROR; |
| 2520 | } |
| 2521 | size_t size = groups.size(); |
| 2522 | size_t sizePosition = reply->dataPosition(); |
| 2523 | reply->writeInt32(size); |
| 2524 | size_t finalSize = size; |
| 2525 | for (size_t i = 0; i < size; i++) { |
| 2526 | size_t position = reply->dataPosition(); |
| 2527 | if (groups[i].writeToParcel(reply) != NO_ERROR) { |
| 2528 | reply->setDataPosition(position); |
| 2529 | finalSize--; |
| 2530 | } |
| 2531 | } |
| 2532 | if (size != finalSize) { |
| 2533 | size_t position = reply->dataPosition(); |
| 2534 | reply->setDataPosition(sizePosition); |
| 2535 | reply->writeInt32(finalSize); |
| 2536 | reply->setDataPosition(position); |
| 2537 | } |
| 2538 | return NO_ERROR; |
| 2539 | } |
| 2540 | |
| 2541 | case GET_VOLUME_GROUP_FOR_ATTRIBUTES: { |
| 2542 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2543 | AudioAttributes attributes; |
| 2544 | status_t status = attributes.readFromParcel(&data); |
| 2545 | if (status != NO_ERROR) { |
| 2546 | return status; |
| 2547 | } |
Hayden Gomes | 524159d | 2019-12-23 14:41:47 -0800 | [diff] [blame] | 2548 | |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 2549 | volume_group_t group; |
| 2550 | status = getVolumeGroupFromAudioAttributes(attributes, group); |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 2551 | if (status != NO_ERROR) { |
| 2552 | return NO_ERROR; |
| 2553 | } |
Hayden Gomes | 524159d | 2019-12-23 14:41:47 -0800 | [diff] [blame] | 2554 | |
| 2555 | reply->writeInt32(status); |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 2556 | reply->writeUint32(static_cast<int>(group)); |
| 2557 | return NO_ERROR; |
| 2558 | } |
| 2559 | |
Hayden Gomes | 524159d | 2019-12-23 14:41:47 -0800 | [diff] [blame] | 2560 | case SET_SUPPORTED_SYSTEM_USAGES: { |
| 2561 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2562 | std::vector<audio_usage_t> systemUsages; |
| 2563 | |
| 2564 | int32_t size; |
| 2565 | status_t status = data.readInt32(&size); |
| 2566 | if (status != NO_ERROR) { |
| 2567 | return status; |
| 2568 | } |
| 2569 | if (size > MAX_ITEMS_PER_LIST) { |
| 2570 | size = MAX_ITEMS_PER_LIST; |
| 2571 | } |
| 2572 | |
| 2573 | for (int32_t i = 0; i < size; i++) { |
| 2574 | int32_t systemUsageInt; |
| 2575 | status = data.readInt32(&systemUsageInt); |
| 2576 | if (status != NO_ERROR) { |
| 2577 | return status; |
| 2578 | } |
| 2579 | |
| 2580 | audio_usage_t systemUsage = static_cast<audio_usage_t>(systemUsageInt); |
| 2581 | systemUsages.push_back(systemUsage); |
| 2582 | } |
| 2583 | status = setSupportedSystemUsages(systemUsages); |
| 2584 | reply->writeInt32(static_cast <int32_t>(status)); |
| 2585 | return NO_ERROR; |
| 2586 | } |
| 2587 | |
Kevin Rocard | b99cc75 | 2019-03-21 20:52:24 -0700 | [diff] [blame] | 2588 | case SET_ALLOWED_CAPTURE_POLICY: { |
| 2589 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2590 | uid_t uid = data.readInt32(); |
| 2591 | audio_flags_mask_t flags = data.readInt32(); |
| 2592 | status_t status = setAllowedCapturePolicy(uid, flags); |
| 2593 | reply->writeInt32(status); |
| 2594 | return NO_ERROR; |
| 2595 | } |
| 2596 | |
Eric Laurent | 6ede98f | 2019-06-11 14:50:30 -0700 | [diff] [blame] | 2597 | case SET_RTT_ENABLED: { |
| 2598 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2599 | bool enabled = static_cast<bool>(data.readInt32()); |
| 2600 | status_t status = setRttEnabled(enabled); |
| 2601 | reply->writeInt32(status); |
| 2602 | return NO_ERROR; |
| 2603 | } |
| 2604 | |
Eric Laurent | 8340e67 | 2019-11-06 11:01:08 -0800 | [diff] [blame] | 2605 | case IS_CALL_SCREEN_MODE_SUPPORTED: { |
| 2606 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2607 | bool isAvailable = isCallScreenModeSupported(); |
| 2608 | reply->writeBool(isAvailable); |
| 2609 | return NO_ERROR; |
| 2610 | } |
| 2611 | |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 2612 | case SET_PREFERRED_DEVICE_FOR_PRODUCT_STRATEGY: { |
| 2613 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2614 | product_strategy_t strategy = (product_strategy_t) data.readUint32(); |
| 2615 | AudioDeviceTypeAddr device; |
| 2616 | status_t status = device.readFromParcel((Parcel*)&data); |
| 2617 | if (status != NO_ERROR) { |
| 2618 | return status; |
| 2619 | } |
| 2620 | status = setPreferredDeviceForStrategy(strategy, device); |
| 2621 | reply->writeInt32(status); |
| 2622 | return NO_ERROR; |
| 2623 | } |
| 2624 | |
| 2625 | case REMOVE_PREFERRED_DEVICE_FOR_PRODUCT_STRATEGY: { |
| 2626 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2627 | product_strategy_t strategy = (product_strategy_t) data.readUint32(); |
| 2628 | status_t status = removePreferredDeviceForStrategy(strategy); |
| 2629 | reply->writeInt32(status); |
| 2630 | return NO_ERROR; |
| 2631 | } |
| 2632 | |
| 2633 | case GET_PREFERRED_DEVICE_FOR_PRODUCT_STRATEGY: { |
| 2634 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2635 | product_strategy_t strategy = (product_strategy_t) data.readUint32(); |
| 2636 | AudioDeviceTypeAddr device; |
| 2637 | status_t status = getPreferredDeviceForStrategy(strategy, device); |
| 2638 | status_t marshall_status = device.writeToParcel(reply); |
| 2639 | if (marshall_status != NO_ERROR) { |
| 2640 | return marshall_status; |
| 2641 | } |
| 2642 | reply->writeInt32(status); |
| 2643 | return NO_ERROR; |
| 2644 | } |
| 2645 | |
Jean-Michel Trivi | f41599b | 2020-01-07 14:22:08 -0800 | [diff] [blame] | 2646 | case GET_DEVICES_FOR_ATTRIBUTES: { |
| 2647 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2648 | AudioAttributes attributes; |
| 2649 | status_t status = attributes.readFromParcel(&data); |
| 2650 | if (status != NO_ERROR) { |
| 2651 | return status; |
| 2652 | } |
| 2653 | AudioDeviceTypeAddrVector devices; |
| 2654 | status = getDevicesForAttributes(attributes.getAttributes(), &devices); |
| 2655 | // reply data formatted as: |
| 2656 | // - (int32) method call result from APM |
| 2657 | // - (int32) number of devices (n) if method call returned NO_ERROR |
| 2658 | // - n AudioDeviceTypeAddr if method call returned NO_ERROR |
| 2659 | reply->writeInt32(status); |
| 2660 | if (status != NO_ERROR) { |
| 2661 | return NO_ERROR; |
| 2662 | } |
| 2663 | status = reply->writeInt32(devices.size()); |
| 2664 | if (status != NO_ERROR) { |
| 2665 | return status; |
| 2666 | } |
| 2667 | for (const auto& device : devices) { |
| 2668 | status = device.writeToParcel(reply); |
| 2669 | if (status != NO_ERROR) { |
| 2670 | return status; |
| 2671 | } |
| 2672 | } |
| 2673 | |
| 2674 | return NO_ERROR; |
| 2675 | } |
| 2676 | |
Mikhail Naganov | 88b30d2 | 2020-03-09 19:43:13 +0000 | [diff] [blame] | 2677 | case AUDIO_MODULES_UPDATED: { |
| 2678 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 2679 | onNewAudioModulesAvailable(); |
| 2680 | return NO_ERROR; |
| 2681 | } break; |
| 2682 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 2683 | default: |
| 2684 | return BBinder::onTransact(code, data, reply, flags); |
| 2685 | } |
| 2686 | } |
| 2687 | |
Andy Hung | b027209 | 2018-04-12 11:06:56 -0700 | [diff] [blame] | 2688 | /** returns true if string overflow was prevented by zero termination */ |
| 2689 | template <size_t size> |
| 2690 | static bool preventStringOverflow(char (&s)[size]) { |
| 2691 | if (strnlen(s, size) < size) return false; |
| 2692 | s[size - 1] = '\0'; |
| 2693 | return true; |
| 2694 | } |
| 2695 | |
Kevin Rocard | 39fdbd0 | 2017-11-13 11:15:27 -0800 | [diff] [blame] | 2696 | void BnAudioPolicyService::sanetizeAudioAttributes(audio_attributes_t* attr) |
| 2697 | { |
| 2698 | const size_t tagsMaxSize = AUDIO_ATTRIBUTES_TAGS_MAX_SIZE; |
| 2699 | if (strnlen(attr->tags, tagsMaxSize) >= tagsMaxSize) { |
| 2700 | android_errorWriteLog(0x534e4554, "68953950"); // SafetyNet logging |
| 2701 | } |
| 2702 | attr->tags[tagsMaxSize - 1] = '\0'; |
| 2703 | } |
| 2704 | |
Andy Hung | b027209 | 2018-04-12 11:06:56 -0700 | [diff] [blame] | 2705 | /** returns BAD_VALUE if sanitization was required. */ |
| 2706 | status_t BnAudioPolicyService::sanitizeEffectDescriptor(effect_descriptor_t* desc) |
| 2707 | { |
| 2708 | if (preventStringOverflow(desc->name) |
| 2709 | | /* always */ preventStringOverflow(desc->implementor)) { |
| 2710 | android_errorWriteLog(0x534e4554, "73126106"); // SafetyNet logging |
| 2711 | return BAD_VALUE; |
| 2712 | } |
| 2713 | return NO_ERROR; |
| 2714 | } |
| 2715 | |
| 2716 | /** returns BAD_VALUE if sanitization was required. */ |
| 2717 | status_t BnAudioPolicyService::sanitizeAudioPortConfig(struct audio_port_config* config) |
| 2718 | { |
| 2719 | if (config->type == AUDIO_PORT_TYPE_DEVICE && |
| 2720 | preventStringOverflow(config->ext.device.address)) { |
| 2721 | return BAD_VALUE; |
| 2722 | } |
| 2723 | return NO_ERROR; |
| 2724 | } |
| 2725 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 2726 | // ---------------------------------------------------------------------------- |
| 2727 | |
Glenn Kasten | 40bc906 | 2015-03-20 09:09:33 -0700 | [diff] [blame] | 2728 | } // namespace android |