Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | //#define LOG_NDEBUG 0 |
| 18 | #define LOG_TAG "IDrm" |
| 19 | #include <utils/Log.h> |
| 20 | |
| 21 | #include <binder/Parcel.h> |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 22 | #include <media/stagefright/MediaErrors.h> |
| 23 | #include <media/stagefright/foundation/ADebug.h> |
| 24 | #include <media/stagefright/foundation/AString.h> |
Jeff Tinker | 7d2c6e8 | 2018-02-16 16:14:59 -0800 | [diff] [blame] | 25 | #include <mediadrm/IDrm.h> |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | enum { |
| 30 | INIT_CHECK = IBinder::FIRST_CALL_TRANSACTION, |
| 31 | IS_CRYPTO_SUPPORTED, |
| 32 | CREATE_PLUGIN, |
| 33 | DESTROY_PLUGIN, |
| 34 | OPEN_SESSION, |
| 35 | CLOSE_SESSION, |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 36 | GET_KEY_REQUEST, |
| 37 | PROVIDE_KEY_RESPONSE, |
| 38 | REMOVE_KEYS, |
| 39 | RESTORE_KEYS, |
| 40 | QUERY_KEY_STATUS, |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 41 | GET_PROVISION_REQUEST, |
| 42 | PROVIDE_PROVISION_RESPONSE, |
| 43 | GET_SECURE_STOPS, |
| 44 | RELEASE_SECURE_STOPS, |
| 45 | GET_PROPERTY_STRING, |
| 46 | GET_PROPERTY_BYTE_ARRAY, |
| 47 | SET_PROPERTY_STRING, |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 48 | SET_PROPERTY_BYTE_ARRAY, |
Adam Stone | ab394d1 | 2017-12-22 12:34:20 -0800 | [diff] [blame] | 49 | GET_METRICS, |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 50 | SET_CIPHER_ALGORITHM, |
| 51 | SET_MAC_ALGORITHM, |
| 52 | ENCRYPT, |
| 53 | DECRYPT, |
| 54 | SIGN, |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 55 | SIGN_RSA, |
Jeff Tinker | c0d5f1f | 2013-04-02 13:08:05 -0700 | [diff] [blame] | 56 | VERIFY, |
Jeff Tinker | 68b1555 | 2014-04-30 10:19:03 -0700 | [diff] [blame] | 57 | SET_LISTENER, |
Jeff Tinker | 3c1285e | 2014-10-31 00:55:16 -0700 | [diff] [blame] | 58 | GET_SECURE_STOP, |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 59 | REMOVE_ALL_SECURE_STOPS, |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 60 | GET_HDCP_LEVELS, |
| 61 | GET_NUMBER_OF_SESSIONS, |
| 62 | GET_SECURITY_LEVEL, |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 63 | REMOVE_SECURE_STOP, |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 64 | GET_SECURE_STOP_IDS, |
| 65 | GET_OFFLINE_LICENSE_KEYSET_IDS, |
| 66 | REMOVE_OFFLINE_LICENSE, |
| 67 | GET_OFFLINE_LICENSE_STATE |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | struct BpDrm : public BpInterface<IDrm> { |
Chih-Hung Hsieh | 090ef60 | 2016-04-27 10:39:54 -0700 | [diff] [blame] | 71 | explicit BpDrm(const sp<IBinder> &impl) |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 72 | : BpInterface<IDrm>(impl) { |
| 73 | } |
| 74 | |
| 75 | virtual status_t initCheck() const { |
| 76 | Parcel data, reply; |
| 77 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 78 | status_t status = remote()->transact(INIT_CHECK, data, &reply); |
| 79 | if (status != OK) { |
| 80 | return status; |
| 81 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 82 | |
| 83 | return reply.readInt32(); |
| 84 | } |
| 85 | |
Jeff Tinker | 99dbfa8 | 2019-01-17 17:27:06 -0800 | [diff] [blame^] | 86 | virtual bool isCryptoSchemeSupported(const uint8_t uuid[16], const String8 &mimeType, |
| 87 | DrmPlugin::SecurityLevel level) { |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 88 | Parcel data, reply; |
| 89 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 90 | data.write(uuid, 16); |
Jeff Tinker | 9cf69e0 | 2013-08-21 11:59:23 -0700 | [diff] [blame] | 91 | data.writeString8(mimeType); |
Jeff Tinker | 99dbfa8 | 2019-01-17 17:27:06 -0800 | [diff] [blame^] | 92 | data.writeInt32(level); |
| 93 | |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 94 | status_t status = remote()->transact(IS_CRYPTO_SUPPORTED, data, &reply); |
| 95 | if (status != OK) { |
| 96 | ALOGE("isCryptoSchemeSupported: binder call failed: %d", status); |
| 97 | return false; |
| 98 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 99 | |
| 100 | return reply.readInt32() != 0; |
| 101 | } |
| 102 | |
Edwin Wong | 68b3d9f | 2017-01-06 19:07:54 -0800 | [diff] [blame] | 103 | virtual status_t createPlugin(const uint8_t uuid[16], |
| 104 | const String8& appPackageName) { |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 105 | Parcel data, reply; |
| 106 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 107 | data.write(uuid, 16); |
Edwin Wong | 68b3d9f | 2017-01-06 19:07:54 -0800 | [diff] [blame] | 108 | data.writeString8(appPackageName); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 109 | status_t status = remote()->transact(CREATE_PLUGIN, data, &reply); |
| 110 | if (status != OK) { |
Edwin Wong | 68b3d9f | 2017-01-06 19:07:54 -0800 | [diff] [blame] | 111 | ALOGE("createPlugin: binder call failed: %d", status); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 112 | return status; |
| 113 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 114 | |
| 115 | return reply.readInt32(); |
| 116 | } |
| 117 | |
| 118 | virtual status_t destroyPlugin() { |
| 119 | Parcel data, reply; |
| 120 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 121 | status_t status = remote()->transact(DESTROY_PLUGIN, data, &reply); |
| 122 | if (status != OK) { |
| 123 | return status; |
| 124 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 125 | |
| 126 | return reply.readInt32(); |
| 127 | } |
| 128 | |
Jeff Tinker | 99dbfa8 | 2019-01-17 17:27:06 -0800 | [diff] [blame^] | 129 | virtual status_t openSession(DrmPlugin::SecurityLevel level, |
Jeff Tinker | 41d279a | 2018-02-11 19:52:08 +0000 | [diff] [blame] | 130 | Vector<uint8_t> &sessionId) { |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 131 | Parcel data, reply; |
| 132 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
Jeff Tinker | 99dbfa8 | 2019-01-17 17:27:06 -0800 | [diff] [blame^] | 133 | data.writeInt32(level); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 134 | |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 135 | status_t status = remote()->transact(OPEN_SESSION, data, &reply); |
| 136 | if (status != OK) { |
| 137 | return status; |
| 138 | } |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 139 | readVector(reply, sessionId); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 140 | |
| 141 | return reply.readInt32(); |
| 142 | } |
| 143 | |
| 144 | virtual status_t closeSession(Vector<uint8_t> const &sessionId) { |
| 145 | Parcel data, reply; |
| 146 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 147 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 148 | writeVector(data, sessionId); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 149 | status_t status = remote()->transact(CLOSE_SESSION, data, &reply); |
| 150 | if (status != OK) { |
| 151 | return status; |
| 152 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 153 | |
| 154 | return reply.readInt32(); |
| 155 | } |
| 156 | |
| 157 | virtual status_t |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 158 | getKeyRequest(Vector<uint8_t> const &sessionId, |
| 159 | Vector<uint8_t> const &initData, |
| 160 | String8 const &mimeType, DrmPlugin::KeyType keyType, |
| 161 | KeyedVector<String8, String8> const &optionalParameters, |
Jeff Tinker | d072c90 | 2015-03-16 13:39:29 -0700 | [diff] [blame] | 162 | Vector<uint8_t> &request, String8 &defaultUrl, |
| 163 | DrmPlugin::KeyRequestType *keyRequestType) { |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 164 | Parcel data, reply; |
| 165 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 166 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 167 | writeVector(data, sessionId); |
| 168 | writeVector(data, initData); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 169 | data.writeString8(mimeType); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 170 | data.writeInt32((uint32_t)keyType); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 171 | |
| 172 | data.writeInt32(optionalParameters.size()); |
| 173 | for (size_t i = 0; i < optionalParameters.size(); ++i) { |
| 174 | data.writeString8(optionalParameters.keyAt(i)); |
| 175 | data.writeString8(optionalParameters.valueAt(i)); |
| 176 | } |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 177 | |
| 178 | status_t status = remote()->transact(GET_KEY_REQUEST, data, &reply); |
| 179 | if (status != OK) { |
| 180 | return status; |
| 181 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 182 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 183 | readVector(reply, request); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 184 | defaultUrl = reply.readString8(); |
Jeff Tinker | d072c90 | 2015-03-16 13:39:29 -0700 | [diff] [blame] | 185 | *keyRequestType = static_cast<DrmPlugin::KeyRequestType>(reply.readInt32()); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 186 | |
| 187 | return reply.readInt32(); |
| 188 | } |
| 189 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 190 | virtual status_t provideKeyResponse(Vector<uint8_t> const &sessionId, |
| 191 | Vector<uint8_t> const &response, |
| 192 | Vector<uint8_t> &keySetId) { |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 193 | Parcel data, reply; |
| 194 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 195 | writeVector(data, sessionId); |
| 196 | writeVector(data, response); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 197 | |
| 198 | status_t status = remote()->transact(PROVIDE_KEY_RESPONSE, data, &reply); |
| 199 | if (status != OK) { |
| 200 | return status; |
| 201 | } |
| 202 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 203 | readVector(reply, keySetId); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 204 | |
| 205 | return reply.readInt32(); |
| 206 | } |
| 207 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 208 | virtual status_t removeKeys(Vector<uint8_t> const &keySetId) { |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 209 | Parcel data, reply; |
| 210 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 211 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 212 | writeVector(data, keySetId); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 213 | status_t status = remote()->transact(REMOVE_KEYS, data, &reply); |
| 214 | if (status != OK) { |
| 215 | return status; |
| 216 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 217 | |
| 218 | return reply.readInt32(); |
| 219 | } |
| 220 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 221 | virtual status_t restoreKeys(Vector<uint8_t> const &sessionId, |
| 222 | Vector<uint8_t> const &keySetId) { |
| 223 | Parcel data, reply; |
| 224 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 225 | |
| 226 | writeVector(data, sessionId); |
| 227 | writeVector(data, keySetId); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 228 | status_t status = remote()->transact(RESTORE_KEYS, data, &reply); |
| 229 | if (status != OK) { |
| 230 | return status; |
| 231 | } |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 232 | |
| 233 | return reply.readInt32(); |
| 234 | } |
| 235 | |
| 236 | virtual status_t queryKeyStatus(Vector<uint8_t> const &sessionId, |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 237 | KeyedVector<String8, String8> &infoMap) const { |
| 238 | Parcel data, reply; |
| 239 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 240 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 241 | writeVector(data, sessionId); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 242 | status_t status = remote()->transact(QUERY_KEY_STATUS, data, &reply); |
| 243 | if (status != OK) { |
| 244 | return status; |
| 245 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 246 | |
| 247 | infoMap.clear(); |
| 248 | size_t count = reply.readInt32(); |
| 249 | for (size_t i = 0; i < count; i++) { |
| 250 | String8 key = reply.readString8(); |
| 251 | String8 value = reply.readString8(); |
| 252 | infoMap.add(key, value); |
| 253 | } |
| 254 | return reply.readInt32(); |
| 255 | } |
| 256 | |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 257 | virtual status_t getProvisionRequest(String8 const &certType, |
| 258 | String8 const &certAuthority, |
| 259 | Vector<uint8_t> &request, |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 260 | String8 &defaultUrl) { |
| 261 | Parcel data, reply; |
| 262 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 263 | |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 264 | data.writeString8(certType); |
| 265 | data.writeString8(certAuthority); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 266 | status_t status = remote()->transact(GET_PROVISION_REQUEST, data, &reply); |
| 267 | if (status != OK) { |
| 268 | return status; |
| 269 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 270 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 271 | readVector(reply, request); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 272 | defaultUrl = reply.readString8(); |
| 273 | |
| 274 | return reply.readInt32(); |
| 275 | } |
| 276 | |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 277 | virtual status_t provideProvisionResponse(Vector<uint8_t> const &response, |
| 278 | Vector<uint8_t> &certificate, |
| 279 | Vector<uint8_t> &wrappedKey) { |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 280 | Parcel data, reply; |
| 281 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 282 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 283 | writeVector(data, response); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 284 | status_t status = remote()->transact(PROVIDE_PROVISION_RESPONSE, data, &reply); |
| 285 | if (status != OK) { |
| 286 | return status; |
| 287 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 288 | |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 289 | readVector(reply, certificate); |
| 290 | readVector(reply, wrappedKey); |
| 291 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 292 | return reply.readInt32(); |
| 293 | } |
| 294 | |
| 295 | virtual status_t getSecureStops(List<Vector<uint8_t> > &secureStops) { |
| 296 | Parcel data, reply; |
| 297 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 298 | |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 299 | status_t status = remote()->transact(GET_SECURE_STOPS, data, &reply); |
| 300 | if (status != OK) { |
| 301 | return status; |
| 302 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 303 | |
| 304 | secureStops.clear(); |
| 305 | uint32_t count = reply.readInt32(); |
| 306 | for (size_t i = 0; i < count; i++) { |
| 307 | Vector<uint8_t> secureStop; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 308 | readVector(reply, secureStop); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 309 | secureStops.push_back(secureStop); |
| 310 | } |
| 311 | return reply.readInt32(); |
| 312 | } |
| 313 | |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 314 | virtual status_t getSecureStopIds(List<Vector<uint8_t> > &secureStopIds) { |
| 315 | Parcel data, reply; |
| 316 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 317 | |
| 318 | status_t status = remote()->transact(GET_SECURE_STOP_IDS, data, &reply); |
| 319 | if (status != OK) { |
| 320 | return status; |
| 321 | } |
| 322 | |
| 323 | secureStopIds.clear(); |
| 324 | uint32_t count = reply.readInt32(); |
| 325 | for (size_t i = 0; i < count; i++) { |
| 326 | Vector<uint8_t> secureStopId; |
| 327 | readVector(reply, secureStopId); |
| 328 | secureStopIds.push_back(secureStopId); |
| 329 | } |
| 330 | return reply.readInt32(); |
| 331 | } |
| 332 | |
Jeff Tinker | 3c1285e | 2014-10-31 00:55:16 -0700 | [diff] [blame] | 333 | virtual status_t getSecureStop(Vector<uint8_t> const &ssid, Vector<uint8_t> &secureStop) { |
| 334 | Parcel data, reply; |
| 335 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 336 | |
| 337 | writeVector(data, ssid); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 338 | status_t status = remote()->transact(GET_SECURE_STOP, data, &reply); |
| 339 | if (status != OK) { |
| 340 | return status; |
| 341 | } |
Jeff Tinker | 3c1285e | 2014-10-31 00:55:16 -0700 | [diff] [blame] | 342 | |
| 343 | readVector(reply, secureStop); |
| 344 | return reply.readInt32(); |
| 345 | } |
| 346 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 347 | virtual status_t releaseSecureStops(Vector<uint8_t> const &ssRelease) { |
| 348 | Parcel data, reply; |
| 349 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 350 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 351 | writeVector(data, ssRelease); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 352 | status_t status = remote()->transact(RELEASE_SECURE_STOPS, data, &reply); |
| 353 | if (status != OK) { |
| 354 | return status; |
| 355 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 356 | |
| 357 | return reply.readInt32(); |
| 358 | } |
| 359 | |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 360 | virtual status_t removeSecureStop(Vector<uint8_t> const &ssid) { |
Jeff Tinker | 3c1285e | 2014-10-31 00:55:16 -0700 | [diff] [blame] | 361 | Parcel data, reply; |
| 362 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 363 | |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 364 | writeVector(data, ssid); |
| 365 | status_t status = remote()->transact(REMOVE_SECURE_STOP, data, &reply); |
| 366 | if (status != OK) { |
| 367 | return status; |
| 368 | } |
| 369 | |
| 370 | return reply.readInt32(); |
| 371 | } |
| 372 | |
| 373 | virtual status_t removeAllSecureStops() { |
| 374 | Parcel data, reply; |
| 375 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 376 | |
| 377 | status_t status = remote()->transact(REMOVE_ALL_SECURE_STOPS, data, &reply); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 378 | if (status != OK) { |
| 379 | return status; |
| 380 | } |
Jeff Tinker | 3c1285e | 2014-10-31 00:55:16 -0700 | [diff] [blame] | 381 | |
| 382 | return reply.readInt32(); |
| 383 | } |
| 384 | |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 385 | virtual status_t getOfflineLicenseKeySetIds(List<Vector<uint8_t> > &keySetIds) const { |
| 386 | Parcel data, reply; |
| 387 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 388 | |
| 389 | status_t status = remote()->transact(GET_OFFLINE_LICENSE_KEYSET_IDS, data, &reply); |
| 390 | if (status != OK) { |
| 391 | return status; |
| 392 | } |
| 393 | |
| 394 | keySetIds.clear(); |
| 395 | uint32_t count = reply.readInt32(); |
| 396 | for (size_t i = 0; i < count; i++) { |
| 397 | Vector<uint8_t> keySetId; |
| 398 | readVector(reply, keySetId); |
| 399 | keySetIds.push_back(keySetId); |
| 400 | } |
| 401 | return reply.readInt32(); |
| 402 | } |
| 403 | |
| 404 | virtual status_t removeOfflineLicense(Vector<uint8_t> const &keySetId) { |
| 405 | Parcel data, reply; |
| 406 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 407 | |
| 408 | writeVector(data, keySetId); |
| 409 | status_t status = remote()->transact(REMOVE_OFFLINE_LICENSE, data, &reply); |
| 410 | if (status != OK) { |
| 411 | return status; |
| 412 | } |
| 413 | return reply.readInt32(); |
| 414 | } |
| 415 | |
| 416 | virtual status_t getOfflineLicenseState(Vector<uint8_t> const &keySetId, |
| 417 | DrmPlugin::OfflineLicenseState *licenseState) const { |
| 418 | Parcel data, reply; |
| 419 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 420 | |
| 421 | writeVector(data, keySetId); |
| 422 | status_t status = remote()->transact(GET_OFFLINE_LICENSE_STATE, data, &reply); |
| 423 | if (status != OK) { |
| 424 | *licenseState = DrmPlugin::OfflineLicenseState::kOfflineLicenseStateUnknown; |
| 425 | return status; |
| 426 | } |
| 427 | *licenseState = static_cast<DrmPlugin::OfflineLicenseState>(reply.readInt32()); |
| 428 | return reply.readInt32(); |
| 429 | } |
| 430 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 431 | virtual status_t getPropertyString(String8 const &name, String8 &value) const { |
| 432 | Parcel data, reply; |
| 433 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 434 | |
| 435 | data.writeString8(name); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 436 | status_t status = remote()->transact(GET_PROPERTY_STRING, data, &reply); |
| 437 | if (status != OK) { |
| 438 | return status; |
| 439 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 440 | |
| 441 | value = reply.readString8(); |
| 442 | return reply.readInt32(); |
| 443 | } |
| 444 | |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 445 | virtual status_t getHdcpLevels(DrmPlugin::HdcpLevel *connected, |
| 446 | DrmPlugin::HdcpLevel *max) const { |
| 447 | Parcel data, reply; |
| 448 | |
| 449 | if (connected == NULL || max == NULL) { |
| 450 | return BAD_VALUE; |
| 451 | } |
| 452 | |
| 453 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 454 | |
| 455 | status_t status = remote()->transact(GET_HDCP_LEVELS, data, &reply); |
| 456 | if (status != OK) { |
| 457 | return status; |
| 458 | } |
| 459 | |
| 460 | *connected = static_cast<DrmPlugin::HdcpLevel>(reply.readInt32()); |
| 461 | *max = static_cast<DrmPlugin::HdcpLevel>(reply.readInt32()); |
| 462 | return reply.readInt32(); |
| 463 | } |
| 464 | |
| 465 | virtual status_t getNumberOfSessions(uint32_t *open, uint32_t *max) const { |
| 466 | Parcel data, reply; |
| 467 | |
| 468 | if (open == NULL || max == NULL) { |
| 469 | return BAD_VALUE; |
| 470 | } |
| 471 | |
| 472 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 473 | |
| 474 | status_t status = remote()->transact(GET_NUMBER_OF_SESSIONS, data, &reply); |
| 475 | if (status != OK) { |
| 476 | return status; |
| 477 | } |
| 478 | |
| 479 | *open = reply.readInt32(); |
| 480 | *max = reply.readInt32(); |
| 481 | return reply.readInt32(); |
| 482 | } |
| 483 | |
| 484 | virtual status_t getSecurityLevel(Vector<uint8_t> const &sessionId, |
| 485 | DrmPlugin::SecurityLevel *level) const { |
| 486 | Parcel data, reply; |
| 487 | |
| 488 | if (level == NULL) { |
| 489 | return BAD_VALUE; |
| 490 | } |
| 491 | |
| 492 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 493 | |
| 494 | writeVector(data, sessionId); |
| 495 | status_t status = remote()->transact(GET_SECURITY_LEVEL, data, &reply); |
| 496 | if (status != OK) { |
| 497 | return status; |
| 498 | } |
| 499 | |
| 500 | *level = static_cast<DrmPlugin::SecurityLevel>(reply.readInt32()); |
| 501 | return reply.readInt32(); |
| 502 | } |
| 503 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 504 | virtual status_t getPropertyByteArray(String8 const &name, Vector<uint8_t> &value) const { |
| 505 | Parcel data, reply; |
| 506 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 507 | |
| 508 | data.writeString8(name); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 509 | status_t status = remote()->transact(GET_PROPERTY_BYTE_ARRAY, data, &reply); |
| 510 | if (status != OK) { |
| 511 | return status; |
| 512 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 513 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 514 | readVector(reply, value); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 515 | return reply.readInt32(); |
| 516 | } |
| 517 | |
| 518 | virtual status_t setPropertyString(String8 const &name, String8 const &value) const { |
| 519 | Parcel data, reply; |
| 520 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 521 | |
| 522 | data.writeString8(name); |
| 523 | data.writeString8(value); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 524 | status_t status = remote()->transact(SET_PROPERTY_STRING, data, &reply); |
| 525 | if (status != OK) { |
| 526 | return status; |
| 527 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 528 | |
| 529 | return reply.readInt32(); |
| 530 | } |
| 531 | |
| 532 | virtual status_t setPropertyByteArray(String8 const &name, |
| 533 | Vector<uint8_t> const &value) const { |
| 534 | Parcel data, reply; |
| 535 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 536 | |
| 537 | data.writeString8(name); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 538 | writeVector(data, value); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 539 | status_t status = remote()->transact(SET_PROPERTY_BYTE_ARRAY, data, &reply); |
| 540 | if (status != OK) { |
| 541 | return status; |
| 542 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 543 | |
| 544 | return reply.readInt32(); |
| 545 | } |
| 546 | |
Adam Stone | 637b785 | 2018-01-30 12:09:36 -0800 | [diff] [blame] | 547 | virtual status_t getMetrics(os::PersistableBundle *metrics) { |
Adam Stone | 568b3c4 | 2018-01-31 12:57:16 -0800 | [diff] [blame] | 548 | if (metrics == NULL) { |
| 549 | return BAD_VALUE; |
| 550 | } |
Adam Stone | ab394d1 | 2017-12-22 12:34:20 -0800 | [diff] [blame] | 551 | Parcel data, reply; |
| 552 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 553 | |
| 554 | status_t status = remote()->transact(GET_METRICS, data, &reply); |
| 555 | if (status != OK) { |
| 556 | return status; |
| 557 | } |
Adam Stone | 568b3c4 | 2018-01-31 12:57:16 -0800 | [diff] [blame] | 558 | // The reply data is ordered as |
| 559 | // 1) 32 bit integer reply followed by |
| 560 | // 2) Serialized PersistableBundle containing metrics. |
| 561 | status_t reply_status; |
| 562 | if (reply.readInt32(&reply_status) != OK |
| 563 | || reply_status != OK) { |
| 564 | ALOGE("Failed to read getMetrics response code from parcel. %d", |
| 565 | reply_status); |
| 566 | return reply_status; |
| 567 | } |
Adam Stone | ab394d1 | 2017-12-22 12:34:20 -0800 | [diff] [blame] | 568 | |
Adam Stone | 568b3c4 | 2018-01-31 12:57:16 -0800 | [diff] [blame] | 569 | status = metrics->readFromParcel(&reply); |
| 570 | if (status != OK) { |
| 571 | ALOGE("Failed to read metrics from parcel. %d", status); |
| 572 | return status; |
| 573 | } |
| 574 | return reply_status; |
Adam Stone | ab394d1 | 2017-12-22 12:34:20 -0800 | [diff] [blame] | 575 | } |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 576 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 577 | virtual status_t setCipherAlgorithm(Vector<uint8_t> const &sessionId, |
| 578 | String8 const &algorithm) { |
| 579 | Parcel data, reply; |
| 580 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 581 | |
| 582 | writeVector(data, sessionId); |
| 583 | data.writeString8(algorithm); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 584 | status_t status = remote()->transact(SET_CIPHER_ALGORITHM, data, &reply); |
| 585 | if (status != OK) { |
| 586 | return status; |
| 587 | } |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 588 | return reply.readInt32(); |
| 589 | } |
| 590 | |
| 591 | virtual status_t setMacAlgorithm(Vector<uint8_t> const &sessionId, |
| 592 | String8 const &algorithm) { |
| 593 | Parcel data, reply; |
| 594 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 595 | |
| 596 | writeVector(data, sessionId); |
| 597 | data.writeString8(algorithm); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 598 | status_t status = remote()->transact(SET_MAC_ALGORITHM, data, &reply); |
| 599 | if (status != OK) { |
| 600 | return status; |
| 601 | } |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 602 | return reply.readInt32(); |
| 603 | } |
| 604 | |
| 605 | virtual status_t encrypt(Vector<uint8_t> const &sessionId, |
| 606 | Vector<uint8_t> const &keyId, |
| 607 | Vector<uint8_t> const &input, |
| 608 | Vector<uint8_t> const &iv, |
| 609 | Vector<uint8_t> &output) { |
| 610 | Parcel data, reply; |
| 611 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 612 | |
| 613 | writeVector(data, sessionId); |
| 614 | writeVector(data, keyId); |
| 615 | writeVector(data, input); |
| 616 | writeVector(data, iv); |
| 617 | |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 618 | status_t status = remote()->transact(ENCRYPT, data, &reply); |
| 619 | if (status != OK) { |
| 620 | return status; |
| 621 | } |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 622 | readVector(reply, output); |
| 623 | |
| 624 | return reply.readInt32(); |
| 625 | } |
| 626 | |
| 627 | virtual status_t decrypt(Vector<uint8_t> const &sessionId, |
| 628 | Vector<uint8_t> const &keyId, |
| 629 | Vector<uint8_t> const &input, |
| 630 | Vector<uint8_t> const &iv, |
| 631 | Vector<uint8_t> &output) { |
| 632 | Parcel data, reply; |
| 633 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 634 | |
| 635 | writeVector(data, sessionId); |
| 636 | writeVector(data, keyId); |
| 637 | writeVector(data, input); |
| 638 | writeVector(data, iv); |
| 639 | |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 640 | status_t status = remote()->transact(DECRYPT, data, &reply); |
| 641 | if (status != OK) { |
| 642 | return status; |
| 643 | } |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 644 | readVector(reply, output); |
| 645 | |
| 646 | return reply.readInt32(); |
| 647 | } |
| 648 | |
| 649 | virtual status_t sign(Vector<uint8_t> const &sessionId, |
| 650 | Vector<uint8_t> const &keyId, |
| 651 | Vector<uint8_t> const &message, |
| 652 | Vector<uint8_t> &signature) { |
| 653 | Parcel data, reply; |
| 654 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 655 | |
| 656 | writeVector(data, sessionId); |
| 657 | writeVector(data, keyId); |
| 658 | writeVector(data, message); |
| 659 | |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 660 | status_t status = remote()->transact(SIGN, data, &reply); |
| 661 | if (status != OK) { |
| 662 | return status; |
| 663 | } |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 664 | readVector(reply, signature); |
| 665 | |
| 666 | return reply.readInt32(); |
| 667 | } |
| 668 | |
| 669 | virtual status_t verify(Vector<uint8_t> const &sessionId, |
| 670 | Vector<uint8_t> const &keyId, |
| 671 | Vector<uint8_t> const &message, |
| 672 | Vector<uint8_t> const &signature, |
| 673 | bool &match) { |
| 674 | Parcel data, reply; |
| 675 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 676 | |
| 677 | writeVector(data, sessionId); |
| 678 | writeVector(data, keyId); |
| 679 | writeVector(data, message); |
| 680 | writeVector(data, signature); |
| 681 | |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 682 | status_t status = remote()->transact(VERIFY, data, &reply); |
| 683 | if (status != OK) { |
| 684 | return status; |
| 685 | } |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 686 | match = (bool)reply.readInt32(); |
| 687 | return reply.readInt32(); |
| 688 | } |
| 689 | |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 690 | virtual status_t signRSA(Vector<uint8_t> const &sessionId, |
| 691 | String8 const &algorithm, |
| 692 | Vector<uint8_t> const &message, |
| 693 | Vector<uint8_t> const &wrappedKey, |
| 694 | Vector<uint8_t> &signature) { |
| 695 | Parcel data, reply; |
| 696 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 697 | |
| 698 | writeVector(data, sessionId); |
| 699 | data.writeString8(algorithm); |
| 700 | writeVector(data, message); |
| 701 | writeVector(data, wrappedKey); |
| 702 | |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 703 | status_t status = remote()->transact(SIGN_RSA, data, &reply); |
| 704 | if (status != OK) { |
| 705 | return status; |
| 706 | } |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 707 | readVector(reply, signature); |
| 708 | |
| 709 | return reply.readInt32(); |
| 710 | } |
| 711 | |
Jeff Tinker | c0d5f1f | 2013-04-02 13:08:05 -0700 | [diff] [blame] | 712 | virtual status_t setListener(const sp<IDrmClient>& listener) { |
| 713 | Parcel data, reply; |
| 714 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 715 | data.writeStrongBinder(IInterface::asBinder(listener)); |
Jeff Tinker | 3b5401a | 2015-06-15 17:42:10 -0700 | [diff] [blame] | 716 | status_t status = remote()->transact(SET_LISTENER, data, &reply); |
| 717 | if (status != OK) { |
| 718 | return status; |
| 719 | } |
Jeff Tinker | c0d5f1f | 2013-04-02 13:08:05 -0700 | [diff] [blame] | 720 | return reply.readInt32(); |
| 721 | } |
| 722 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 723 | private: |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 724 | void readVector(Parcel &reply, Vector<uint8_t> &vector) const { |
| 725 | uint32_t size = reply.readInt32(); |
| 726 | vector.insertAt((size_t)0, size); |
| 727 | reply.read(vector.editArray(), size); |
| 728 | } |
| 729 | |
| 730 | void writeVector(Parcel &data, Vector<uint8_t> const &vector) const { |
| 731 | data.writeInt32(vector.size()); |
| 732 | data.write(vector.array(), vector.size()); |
| 733 | } |
| 734 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 735 | DISALLOW_EVIL_CONSTRUCTORS(BpDrm); |
| 736 | }; |
| 737 | |
| 738 | IMPLEMENT_META_INTERFACE(Drm, "android.drm.IDrm"); |
| 739 | |
| 740 | //////////////////////////////////////////////////////////////////////////////// |
| 741 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 742 | void BnDrm::readVector(const Parcel &data, Vector<uint8_t> &vector) const { |
| 743 | uint32_t size = data.readInt32(); |
Jeff Tinker | 3cf728e | 2017-10-18 20:54:26 +0000 | [diff] [blame] | 744 | if (vector.insertAt((size_t)0, size) < 0) { |
| 745 | vector.clear(); |
| 746 | } |
| 747 | if (data.read(vector.editArray(), size) != NO_ERROR) { |
| 748 | vector.clear(); |
| 749 | android_errorWriteWithInfoLog(0x534e4554, "62872384", -1, NULL, 0); |
| 750 | } |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 751 | } |
| 752 | |
| 753 | void BnDrm::writeVector(Parcel *reply, Vector<uint8_t> const &vector) const { |
| 754 | reply->writeInt32(vector.size()); |
| 755 | reply->write(vector.array(), vector.size()); |
| 756 | } |
| 757 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 758 | status_t BnDrm::onTransact( |
| 759 | uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { |
| 760 | switch (code) { |
| 761 | case INIT_CHECK: |
| 762 | { |
| 763 | CHECK_INTERFACE(IDrm, data, reply); |
| 764 | reply->writeInt32(initCheck()); |
| 765 | return OK; |
| 766 | } |
| 767 | |
| 768 | case IS_CRYPTO_SUPPORTED: |
| 769 | { |
| 770 | CHECK_INTERFACE(IDrm, data, reply); |
| 771 | uint8_t uuid[16]; |
| 772 | data.read(uuid, sizeof(uuid)); |
Jeff Tinker | 9cf69e0 | 2013-08-21 11:59:23 -0700 | [diff] [blame] | 773 | String8 mimeType = data.readString8(); |
Jeff Tinker | 99dbfa8 | 2019-01-17 17:27:06 -0800 | [diff] [blame^] | 774 | DrmPlugin::SecurityLevel level = |
| 775 | static_cast<DrmPlugin::SecurityLevel>(data.readInt32()); |
| 776 | reply->writeInt32(isCryptoSchemeSupported(uuid, mimeType, level)); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 777 | return OK; |
| 778 | } |
| 779 | |
| 780 | case CREATE_PLUGIN: |
| 781 | { |
| 782 | CHECK_INTERFACE(IDrm, data, reply); |
| 783 | uint8_t uuid[16]; |
| 784 | data.read(uuid, sizeof(uuid)); |
Edwin Wong | 68b3d9f | 2017-01-06 19:07:54 -0800 | [diff] [blame] | 785 | String8 appPackageName = data.readString8(); |
| 786 | reply->writeInt32(createPlugin(uuid, appPackageName)); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 787 | return OK; |
| 788 | } |
| 789 | |
| 790 | case DESTROY_PLUGIN: |
| 791 | { |
| 792 | CHECK_INTERFACE(IDrm, data, reply); |
| 793 | reply->writeInt32(destroyPlugin()); |
| 794 | return OK; |
| 795 | } |
| 796 | |
| 797 | case OPEN_SESSION: |
| 798 | { |
| 799 | CHECK_INTERFACE(IDrm, data, reply); |
Jeff Tinker | 41d279a | 2018-02-11 19:52:08 +0000 | [diff] [blame] | 800 | DrmPlugin::SecurityLevel level = |
| 801 | static_cast<DrmPlugin::SecurityLevel>(data.readInt32()); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 802 | Vector<uint8_t> sessionId; |
Jeff Tinker | 41d279a | 2018-02-11 19:52:08 +0000 | [diff] [blame] | 803 | status_t result = openSession(level, sessionId); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 804 | writeVector(reply, sessionId); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 805 | reply->writeInt32(result); |
| 806 | return OK; |
| 807 | } |
| 808 | |
| 809 | case CLOSE_SESSION: |
| 810 | { |
| 811 | CHECK_INTERFACE(IDrm, data, reply); |
| 812 | Vector<uint8_t> sessionId; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 813 | readVector(data, sessionId); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 814 | reply->writeInt32(closeSession(sessionId)); |
| 815 | return OK; |
| 816 | } |
| 817 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 818 | case GET_KEY_REQUEST: |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 819 | { |
| 820 | CHECK_INTERFACE(IDrm, data, reply); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 821 | Vector<uint8_t> sessionId, initData; |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 822 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 823 | readVector(data, sessionId); |
| 824 | readVector(data, initData); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 825 | String8 mimeType = data.readString8(); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 826 | DrmPlugin::KeyType keyType = (DrmPlugin::KeyType)data.readInt32(); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 827 | |
| 828 | KeyedVector<String8, String8> optionalParameters; |
| 829 | uint32_t count = data.readInt32(); |
| 830 | for (size_t i = 0; i < count; ++i) { |
| 831 | String8 key, value; |
| 832 | key = data.readString8(); |
| 833 | value = data.readString8(); |
| 834 | optionalParameters.add(key, value); |
| 835 | } |
| 836 | |
| 837 | Vector<uint8_t> request; |
| 838 | String8 defaultUrl; |
Jeff Tinker | 8aff777 | 2016-02-08 17:52:25 -0800 | [diff] [blame] | 839 | DrmPlugin::KeyRequestType keyRequestType = DrmPlugin::kKeyRequestType_Unknown; |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 840 | |
Jeff Tinker | d072c90 | 2015-03-16 13:39:29 -0700 | [diff] [blame] | 841 | status_t result = getKeyRequest(sessionId, initData, mimeType, |
| 842 | keyType, optionalParameters, request, defaultUrl, |
| 843 | &keyRequestType); |
| 844 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 845 | writeVector(reply, request); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 846 | reply->writeString8(defaultUrl); |
Jeff Tinker | d072c90 | 2015-03-16 13:39:29 -0700 | [diff] [blame] | 847 | reply->writeInt32(static_cast<int32_t>(keyRequestType)); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 848 | reply->writeInt32(result); |
| 849 | return OK; |
| 850 | } |
| 851 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 852 | case PROVIDE_KEY_RESPONSE: |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 853 | { |
| 854 | CHECK_INTERFACE(IDrm, data, reply); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 855 | Vector<uint8_t> sessionId, response, keySetId; |
| 856 | readVector(data, sessionId); |
| 857 | readVector(data, response); |
| 858 | uint32_t result = provideKeyResponse(sessionId, response, keySetId); |
| 859 | writeVector(reply, keySetId); |
| 860 | reply->writeInt32(result); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 861 | return OK; |
| 862 | } |
| 863 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 864 | case REMOVE_KEYS: |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 865 | { |
| 866 | CHECK_INTERFACE(IDrm, data, reply); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 867 | Vector<uint8_t> keySetId; |
| 868 | readVector(data, keySetId); |
| 869 | reply->writeInt32(removeKeys(keySetId)); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 870 | return OK; |
| 871 | } |
| 872 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 873 | case RESTORE_KEYS: |
| 874 | { |
| 875 | CHECK_INTERFACE(IDrm, data, reply); |
| 876 | Vector<uint8_t> sessionId, keySetId; |
| 877 | readVector(data, sessionId); |
| 878 | readVector(data, keySetId); |
| 879 | reply->writeInt32(restoreKeys(sessionId, keySetId)); |
| 880 | return OK; |
| 881 | } |
| 882 | |
| 883 | case QUERY_KEY_STATUS: |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 884 | { |
| 885 | CHECK_INTERFACE(IDrm, data, reply); |
| 886 | Vector<uint8_t> sessionId; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 887 | readVector(data, sessionId); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 888 | KeyedVector<String8, String8> infoMap; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 889 | status_t result = queryKeyStatus(sessionId, infoMap); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 890 | size_t count = infoMap.size(); |
| 891 | reply->writeInt32(count); |
| 892 | for (size_t i = 0; i < count; ++i) { |
| 893 | reply->writeString8(infoMap.keyAt(i)); |
| 894 | reply->writeString8(infoMap.valueAt(i)); |
| 895 | } |
| 896 | reply->writeInt32(result); |
| 897 | return OK; |
| 898 | } |
| 899 | |
| 900 | case GET_PROVISION_REQUEST: |
| 901 | { |
| 902 | CHECK_INTERFACE(IDrm, data, reply); |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 903 | String8 certType = data.readString8(); |
| 904 | String8 certAuthority = data.readString8(); |
| 905 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 906 | Vector<uint8_t> request; |
| 907 | String8 defaultUrl; |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 908 | status_t result = getProvisionRequest(certType, certAuthority, |
| 909 | request, defaultUrl); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 910 | writeVector(reply, request); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 911 | reply->writeString8(defaultUrl); |
| 912 | reply->writeInt32(result); |
| 913 | return OK; |
| 914 | } |
| 915 | |
| 916 | case PROVIDE_PROVISION_RESPONSE: |
| 917 | { |
| 918 | CHECK_INTERFACE(IDrm, data, reply); |
| 919 | Vector<uint8_t> response; |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 920 | Vector<uint8_t> certificate; |
| 921 | Vector<uint8_t> wrappedKey; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 922 | readVector(data, response); |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 923 | status_t result = provideProvisionResponse(response, certificate, wrappedKey); |
| 924 | writeVector(reply, certificate); |
| 925 | writeVector(reply, wrappedKey); |
| 926 | reply->writeInt32(result); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 927 | return OK; |
| 928 | } |
| 929 | |
| 930 | case GET_SECURE_STOPS: |
| 931 | { |
| 932 | CHECK_INTERFACE(IDrm, data, reply); |
| 933 | List<Vector<uint8_t> > secureStops; |
| 934 | status_t result = getSecureStops(secureStops); |
| 935 | size_t count = secureStops.size(); |
| 936 | reply->writeInt32(count); |
| 937 | List<Vector<uint8_t> >::iterator iter = secureStops.begin(); |
| 938 | while(iter != secureStops.end()) { |
| 939 | size_t size = iter->size(); |
| 940 | reply->writeInt32(size); |
| 941 | reply->write(iter->array(), iter->size()); |
Jeff Tinker | 423e33c | 2013-04-08 15:23:17 -0700 | [diff] [blame] | 942 | iter++; |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 943 | } |
| 944 | reply->writeInt32(result); |
| 945 | return OK; |
| 946 | } |
| 947 | |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 948 | case GET_SECURE_STOP_IDS: |
| 949 | { |
| 950 | CHECK_INTERFACE(IDrm, data, reply); |
| 951 | List<Vector<uint8_t> > secureStopIds; |
| 952 | status_t result = getSecureStopIds(secureStopIds); |
| 953 | size_t count = secureStopIds.size(); |
| 954 | reply->writeInt32(count); |
| 955 | List<Vector<uint8_t> >::iterator iter = secureStopIds.begin(); |
| 956 | while(iter != secureStopIds.end()) { |
| 957 | size_t size = iter->size(); |
| 958 | reply->writeInt32(size); |
| 959 | reply->write(iter->array(), iter->size()); |
| 960 | iter++; |
| 961 | } |
| 962 | reply->writeInt32(result); |
| 963 | return OK; |
| 964 | } |
| 965 | |
Jeff Tinker | 3c1285e | 2014-10-31 00:55:16 -0700 | [diff] [blame] | 966 | case GET_SECURE_STOP: |
| 967 | { |
| 968 | CHECK_INTERFACE(IDrm, data, reply); |
| 969 | Vector<uint8_t> ssid, secureStop; |
| 970 | readVector(data, ssid); |
| 971 | status_t result = getSecureStop(ssid, secureStop); |
| 972 | writeVector(reply, secureStop); |
| 973 | reply->writeInt32(result); |
| 974 | return OK; |
| 975 | } |
| 976 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 977 | case RELEASE_SECURE_STOPS: |
| 978 | { |
| 979 | CHECK_INTERFACE(IDrm, data, reply); |
| 980 | Vector<uint8_t> ssRelease; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 981 | readVector(data, ssRelease); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 982 | reply->writeInt32(releaseSecureStops(ssRelease)); |
| 983 | return OK; |
| 984 | } |
| 985 | |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 986 | case REMOVE_SECURE_STOP: |
Jeff Tinker | 3c1285e | 2014-10-31 00:55:16 -0700 | [diff] [blame] | 987 | { |
| 988 | CHECK_INTERFACE(IDrm, data, reply); |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 989 | Vector<uint8_t> ssid; |
| 990 | readVector(data, ssid); |
| 991 | reply->writeInt32(removeSecureStop(ssid)); |
| 992 | return OK; |
| 993 | } |
| 994 | |
| 995 | case REMOVE_ALL_SECURE_STOPS: |
| 996 | { |
| 997 | CHECK_INTERFACE(IDrm, data, reply); |
| 998 | reply->writeInt32(removeAllSecureStops()); |
Jeff Tinker | 3c1285e | 2014-10-31 00:55:16 -0700 | [diff] [blame] | 999 | return OK; |
| 1000 | } |
| 1001 | |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1002 | case GET_HDCP_LEVELS: |
| 1003 | { |
| 1004 | CHECK_INTERFACE(IDrm, data, reply); |
| 1005 | DrmPlugin::HdcpLevel connected = DrmPlugin::kHdcpLevelUnknown; |
| 1006 | DrmPlugin::HdcpLevel max = DrmPlugin::kHdcpLevelUnknown; |
| 1007 | status_t result = getHdcpLevels(&connected, &max); |
| 1008 | reply->writeInt32(connected); |
| 1009 | reply->writeInt32(max); |
| 1010 | reply->writeInt32(result); |
| 1011 | return OK; |
| 1012 | } |
| 1013 | |
| 1014 | case GET_NUMBER_OF_SESSIONS: |
| 1015 | { |
| 1016 | CHECK_INTERFACE(IDrm, data, reply); |
| 1017 | uint32_t open = 0, max = 0; |
| 1018 | status_t result = getNumberOfSessions(&open, &max); |
| 1019 | reply->writeInt32(open); |
| 1020 | reply->writeInt32(max); |
| 1021 | reply->writeInt32(result); |
| 1022 | return OK; |
| 1023 | } |
| 1024 | |
| 1025 | case GET_SECURITY_LEVEL: |
| 1026 | { |
| 1027 | CHECK_INTERFACE(IDrm, data, reply); |
| 1028 | Vector<uint8_t> sessionId; |
| 1029 | readVector(data, sessionId); |
| 1030 | DrmPlugin::SecurityLevel level = DrmPlugin::kSecurityLevelUnknown; |
| 1031 | status_t result = getSecurityLevel(sessionId, &level); |
| 1032 | reply->writeInt32(level); |
| 1033 | reply->writeInt32(result); |
| 1034 | return OK; |
| 1035 | } |
| 1036 | |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 1037 | case GET_OFFLINE_LICENSE_KEYSET_IDS: |
| 1038 | { |
| 1039 | CHECK_INTERFACE(IDrm, data, reply); |
| 1040 | List<Vector<uint8_t> > keySetIds; |
| 1041 | status_t result = getOfflineLicenseKeySetIds(keySetIds); |
| 1042 | size_t count = keySetIds.size(); |
| 1043 | reply->writeInt32(count); |
| 1044 | List<Vector<uint8_t> >::iterator iter = keySetIds.begin(); |
| 1045 | while(iter != keySetIds.end()) { |
| 1046 | size_t size = iter->size(); |
| 1047 | reply->writeInt32(size); |
| 1048 | reply->write(iter->array(), iter->size()); |
| 1049 | iter++; |
| 1050 | } |
| 1051 | reply->writeInt32(result); |
| 1052 | return OK; |
| 1053 | } |
| 1054 | |
| 1055 | case REMOVE_OFFLINE_LICENSE: |
| 1056 | { |
| 1057 | CHECK_INTERFACE(IDrm, data, reply); |
| 1058 | Vector<uint8_t> keySetId; |
| 1059 | readVector(data, keySetId); |
| 1060 | reply->writeInt32(removeOfflineLicense(keySetId)); |
| 1061 | return OK; |
| 1062 | } |
| 1063 | |
| 1064 | case GET_OFFLINE_LICENSE_STATE: |
| 1065 | { |
| 1066 | CHECK_INTERFACE(IDrm, data, reply); |
| 1067 | Vector<uint8_t> keySetId; |
| 1068 | readVector(data, keySetId); |
| 1069 | DrmPlugin::OfflineLicenseState state; |
| 1070 | status_t result = getOfflineLicenseState(keySetId, &state); |
| 1071 | reply->writeInt32(static_cast<DrmPlugin::OfflineLicenseState>(state)); |
| 1072 | reply->writeInt32(result); |
| 1073 | return OK; |
| 1074 | } |
| 1075 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 1076 | case GET_PROPERTY_STRING: |
| 1077 | { |
| 1078 | CHECK_INTERFACE(IDrm, data, reply); |
| 1079 | String8 name = data.readString8(); |
| 1080 | String8 value; |
| 1081 | status_t result = getPropertyString(name, value); |
| 1082 | reply->writeString8(value); |
| 1083 | reply->writeInt32(result); |
| 1084 | return OK; |
| 1085 | } |
| 1086 | |
| 1087 | case GET_PROPERTY_BYTE_ARRAY: |
| 1088 | { |
| 1089 | CHECK_INTERFACE(IDrm, data, reply); |
| 1090 | String8 name = data.readString8(); |
| 1091 | Vector<uint8_t> value; |
| 1092 | status_t result = getPropertyByteArray(name, value); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 1093 | writeVector(reply, value); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 1094 | reply->writeInt32(result); |
| 1095 | return OK; |
| 1096 | } |
| 1097 | |
| 1098 | case SET_PROPERTY_STRING: |
| 1099 | { |
| 1100 | CHECK_INTERFACE(IDrm, data, reply); |
| 1101 | String8 name = data.readString8(); |
| 1102 | String8 value = data.readString8(); |
| 1103 | reply->writeInt32(setPropertyString(name, value)); |
| 1104 | return OK; |
| 1105 | } |
| 1106 | |
| 1107 | case SET_PROPERTY_BYTE_ARRAY: |
| 1108 | { |
| 1109 | CHECK_INTERFACE(IDrm, data, reply); |
| 1110 | String8 name = data.readString8(); |
| 1111 | Vector<uint8_t> value; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 1112 | readVector(data, value); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 1113 | reply->writeInt32(setPropertyByteArray(name, value)); |
| 1114 | return OK; |
| 1115 | } |
| 1116 | |
Adam Stone | ab394d1 | 2017-12-22 12:34:20 -0800 | [diff] [blame] | 1117 | case GET_METRICS: |
| 1118 | { |
| 1119 | CHECK_INTERFACE(IDrm, data, reply); |
| 1120 | |
Adam Stone | 637b785 | 2018-01-30 12:09:36 -0800 | [diff] [blame] | 1121 | os::PersistableBundle metrics; |
| 1122 | status_t result = getMetrics(&metrics); |
Adam Stone | 568b3c4 | 2018-01-31 12:57:16 -0800 | [diff] [blame] | 1123 | // The reply data is ordered as |
| 1124 | // 1) 32 bit integer reply followed by |
| 1125 | // 2) Serialized PersistableBundle containing metrics. |
| 1126 | // Only write the metrics if the getMetrics result was |
| 1127 | // OK and we successfully added the status to reply. |
| 1128 | status_t parcel_result = reply->writeInt32(result); |
| 1129 | if (result == OK && parcel_result == OK) { |
| 1130 | parcel_result = metrics.writeToParcel(reply); |
| 1131 | } |
| 1132 | return parcel_result; |
Adam Stone | ab394d1 | 2017-12-22 12:34:20 -0800 | [diff] [blame] | 1133 | } |
| 1134 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 1135 | case SET_CIPHER_ALGORITHM: |
| 1136 | { |
| 1137 | CHECK_INTERFACE(IDrm, data, reply); |
| 1138 | Vector<uint8_t> sessionId; |
| 1139 | readVector(data, sessionId); |
| 1140 | String8 algorithm = data.readString8(); |
| 1141 | reply->writeInt32(setCipherAlgorithm(sessionId, algorithm)); |
| 1142 | return OK; |
| 1143 | } |
| 1144 | |
| 1145 | case SET_MAC_ALGORITHM: |
| 1146 | { |
| 1147 | CHECK_INTERFACE(IDrm, data, reply); |
| 1148 | Vector<uint8_t> sessionId; |
| 1149 | readVector(data, sessionId); |
| 1150 | String8 algorithm = data.readString8(); |
| 1151 | reply->writeInt32(setMacAlgorithm(sessionId, algorithm)); |
| 1152 | return OK; |
| 1153 | } |
| 1154 | |
| 1155 | case ENCRYPT: |
| 1156 | { |
| 1157 | CHECK_INTERFACE(IDrm, data, reply); |
| 1158 | Vector<uint8_t> sessionId, keyId, input, iv, output; |
| 1159 | readVector(data, sessionId); |
| 1160 | readVector(data, keyId); |
| 1161 | readVector(data, input); |
| 1162 | readVector(data, iv); |
| 1163 | uint32_t result = encrypt(sessionId, keyId, input, iv, output); |
| 1164 | writeVector(reply, output); |
| 1165 | reply->writeInt32(result); |
| 1166 | return OK; |
| 1167 | } |
| 1168 | |
| 1169 | case DECRYPT: |
| 1170 | { |
| 1171 | CHECK_INTERFACE(IDrm, data, reply); |
| 1172 | Vector<uint8_t> sessionId, keyId, input, iv, output; |
| 1173 | readVector(data, sessionId); |
| 1174 | readVector(data, keyId); |
| 1175 | readVector(data, input); |
| 1176 | readVector(data, iv); |
| 1177 | uint32_t result = decrypt(sessionId, keyId, input, iv, output); |
| 1178 | writeVector(reply, output); |
| 1179 | reply->writeInt32(result); |
| 1180 | return OK; |
| 1181 | } |
| 1182 | |
| 1183 | case SIGN: |
| 1184 | { |
| 1185 | CHECK_INTERFACE(IDrm, data, reply); |
| 1186 | Vector<uint8_t> sessionId, keyId, message, signature; |
| 1187 | readVector(data, sessionId); |
| 1188 | readVector(data, keyId); |
| 1189 | readVector(data, message); |
| 1190 | uint32_t result = sign(sessionId, keyId, message, signature); |
| 1191 | writeVector(reply, signature); |
| 1192 | reply->writeInt32(result); |
| 1193 | return OK; |
| 1194 | } |
| 1195 | |
| 1196 | case VERIFY: |
| 1197 | { |
| 1198 | CHECK_INTERFACE(IDrm, data, reply); |
| 1199 | Vector<uint8_t> sessionId, keyId, message, signature; |
| 1200 | readVector(data, sessionId); |
| 1201 | readVector(data, keyId); |
| 1202 | readVector(data, message); |
| 1203 | readVector(data, signature); |
Jeff Tinker | 9a6861c | 2016-09-02 11:36:46 -0700 | [diff] [blame] | 1204 | bool match = false; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 1205 | uint32_t result = verify(sessionId, keyId, message, signature, match); |
| 1206 | reply->writeInt32(match); |
| 1207 | reply->writeInt32(result); |
| 1208 | return OK; |
| 1209 | } |
| 1210 | |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 1211 | case SIGN_RSA: |
| 1212 | { |
| 1213 | CHECK_INTERFACE(IDrm, data, reply); |
| 1214 | Vector<uint8_t> sessionId, message, wrappedKey, signature; |
| 1215 | readVector(data, sessionId); |
| 1216 | String8 algorithm = data.readString8(); |
| 1217 | readVector(data, message); |
| 1218 | readVector(data, wrappedKey); |
| 1219 | uint32_t result = signRSA(sessionId, algorithm, message, wrappedKey, signature); |
| 1220 | writeVector(reply, signature); |
| 1221 | reply->writeInt32(result); |
| 1222 | return OK; |
| 1223 | } |
| 1224 | |
Jeff Tinker | c0d5f1f | 2013-04-02 13:08:05 -0700 | [diff] [blame] | 1225 | case SET_LISTENER: { |
| 1226 | CHECK_INTERFACE(IDrm, data, reply); |
| 1227 | sp<IDrmClient> listener = |
| 1228 | interface_cast<IDrmClient>(data.readStrongBinder()); |
| 1229 | reply->writeInt32(setListener(listener)); |
| 1230 | return NO_ERROR; |
| 1231 | } break; |
| 1232 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 1233 | default: |
| 1234 | return BBinder::onTransact(code, data, reply, flags); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 1235 | } |
| 1236 | } |
| 1237 | |
| 1238 | } // namespace android |