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