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