Andreas Huber | 1aec397 | 2016-08-26 09:26:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 17 | #include "Interface.h" |
| 18 | |
Zhuoyao Zhang | ba7e6e9 | 2016-08-10 12:19:02 -0700 | [diff] [blame] | 19 | #include "Annotation.h" |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 20 | #include "DeathRecipientType.h" |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 21 | #include "Method.h" |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 22 | #include "ScalarType.h" |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 23 | #include "StringType.h" |
| 24 | #include "VectorType.h" |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 25 | |
Steven Moreland | 14ee674 | 2016-10-18 12:58:28 -0700 | [diff] [blame] | 26 | #include <android-base/logging.h> |
Iliyan Malchev | a72e0d2 | 2016-09-09 11:03:08 -0700 | [diff] [blame] | 27 | #include <hidl-util/Formatter.h> |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 28 | #include <hidl-util/StringHelper.h> |
Zhuoyao Zhang | 864c771 | 2016-08-16 15:35:28 -0700 | [diff] [blame] | 29 | #include <iostream> |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 30 | #include <sstream> |
Zhuoyao Zhang | 864c771 | 2016-08-16 15:35:28 -0700 | [diff] [blame] | 31 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 32 | namespace android { |
| 33 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 34 | /* It is very important that these values NEVER change. These values |
| 35 | * must remain unchanged over the lifetime of android. This is |
| 36 | * because the framework on a device will be updated independently of |
| 37 | * the hals on a device. If the hals are compiled with one set of |
| 38 | * transaction values, and the framework with another, then the |
| 39 | * interface between them will be destroyed, and the device will not |
| 40 | * work. |
| 41 | */ |
| 42 | enum { |
| 43 | // These values are defined in hardware::IBinder. |
| 44 | /////////////////// User defined transactions |
| 45 | FIRST_CALL_TRANSACTION = 0x00000001, |
| 46 | LAST_CALL_TRANSACTION = 0x00efffff, |
| 47 | /////////////////// HIDL reserved |
| 48 | FIRST_HIDL_TRANSACTION = 0x00f00000, |
| 49 | HIDL_DESCRIPTOR_CHAIN_TRANSACTION = FIRST_HIDL_TRANSACTION, |
Yifan Hong | c75fd47 | 2017-01-11 12:37:31 -0800 | [diff] [blame^] | 50 | HIDL_GET_DESCRIPTOR_TRANSACTION, |
Martijn Coenen | af712c0 | 2016-11-16 15:26:27 +0100 | [diff] [blame] | 51 | HIDL_SYSPROPS_CHANGED_TRANSACTION, |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 52 | HIDL_LINK_TO_DEATH_TRANSACTION, |
| 53 | HIDL_UNLINK_TO_DEATH_TRANSACTION, |
Zhuoyao Zhang | dd85c5c | 2017-01-03 17:30:24 -0800 | [diff] [blame] | 54 | HIDL_SET_HAL_INSTRUMENTATION_TRANSACTION, |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 55 | LAST_HIDL_TRANSACTION = 0x00ffffff, |
| 56 | }; |
| 57 | |
Yifan Hong | a4b53d0 | 2016-10-31 17:29:10 -0700 | [diff] [blame] | 58 | Interface::Interface(const char *localName, const Location &location, Interface *super) |
| 59 | : Scope(localName, location), |
Andreas Huber | 9ed827c | 2016-08-22 12:31:13 -0700 | [diff] [blame] | 60 | mSuperType(super), |
Andreas Huber | ea081b3 | 2016-08-17 15:57:47 -0700 | [diff] [blame] | 61 | mIsJavaCompatibleInProgress(false) { |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 62 | mReservedMethods.push_back(createDescriptorChainMethod()); |
Yifan Hong | c75fd47 | 2017-01-11 12:37:31 -0800 | [diff] [blame^] | 63 | mReservedMethods.push_back(createGetDescriptorMethod()); |
Martijn Coenen | af712c0 | 2016-11-16 15:26:27 +0100 | [diff] [blame] | 64 | mReservedMethods.push_back(createSyspropsChangedMethod()); |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 65 | mReservedMethods.push_back(createLinkToDeathMethod()); |
| 66 | mReservedMethods.push_back(createUnlinkToDeathMethod()); |
Zhuoyao Zhang | dd85c5c | 2017-01-03 17:30:24 -0800 | [diff] [blame] | 67 | mReservedMethods.push_back(createSetHALInstrumentationMethod()); |
Martijn Coenen | af712c0 | 2016-11-16 15:26:27 +0100 | [diff] [blame] | 68 | } |
| 69 | |
Steven Moreland | 30bb6a8 | 2016-11-30 09:18:34 -0800 | [diff] [blame] | 70 | std::string Interface::typeName() const { |
| 71 | return "interface " + localName(); |
| 72 | } |
| 73 | |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 74 | Method *Interface::createLinkToDeathMethod() const { |
| 75 | auto *results = new std::vector<TypedVar *> { |
| 76 | new TypedVar("success", new ScalarType(ScalarType::KIND_BOOL)) }; |
| 77 | auto *args = new std::vector<TypedVar *> { |
| 78 | new TypedVar("recipient", new DeathRecipientType()), |
| 79 | new TypedVar("cookie", new ScalarType(ScalarType::KIND_UINT64)) }; |
| 80 | |
| 81 | return new Method("linkToDeath", |
| 82 | args, |
| 83 | results, |
| 84 | false /*oneway */, |
| 85 | new std::vector<Annotation *>(), |
| 86 | HIDL_LINK_TO_DEATH_TRANSACTION, |
| 87 | { |
| 88 | {IMPL_HEADER, |
| 89 | [](auto &out) { |
| 90 | out << "(void)cookie;\n" |
| 91 | << "return (recipient != nullptr);\n"; |
| 92 | } |
| 93 | }, |
| 94 | {IMPL_PROXY, |
| 95 | [](auto &out) { |
Martijn Coenen | fa55d6e | 2016-12-20 06:08:31 +0100 | [diff] [blame] | 96 | out << "::android::hardware::ProcessState::self()->startThreadPool();\n"; |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 97 | out << "::android::hardware::hidl_binder_death_recipient *binder_recipient" |
| 98 | << " = new ::android::hardware::hidl_binder_death_recipient(recipient, cookie, this);\n" |
| 99 | << "std::unique_lock<std::mutex> lock(_hidl_mMutex);\n" |
| 100 | << "_hidl_mDeathRecipients.push_back(binder_recipient);\n" |
| 101 | << "return (remote()->linkToDeath(binder_recipient)" |
| 102 | << " == ::android::OK);\n"; |
| 103 | } |
| 104 | }, |
Martijn Coenen | 8d12b50 | 2016-12-27 14:30:27 +0100 | [diff] [blame] | 105 | {IMPL_STUB, nullptr} |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 106 | }, /*cppImpl*/ |
| 107 | { |
| 108 | {IMPL_HEADER, |
| 109 | [this](auto &out) { |
| 110 | out << "return true;"; |
| 111 | } |
| 112 | }, |
| 113 | {IMPL_PROXY, |
| 114 | [this](auto &out) { |
Martijn Coenen | 8d12b50 | 2016-12-27 14:30:27 +0100 | [diff] [blame] | 115 | out << "return mRemote.linkToDeath(recipient, cookie);\n"; |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 116 | } |
| 117 | }, |
Martijn Coenen | 8d12b50 | 2016-12-27 14:30:27 +0100 | [diff] [blame] | 118 | {IMPL_STUB, nullptr} |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 119 | } /*javaImpl*/ |
| 120 | ); |
| 121 | } |
| 122 | |
| 123 | Method *Interface::createUnlinkToDeathMethod() const { |
| 124 | auto *results = new std::vector<TypedVar *> { |
| 125 | new TypedVar("success", new ScalarType(ScalarType::KIND_BOOL)) }; |
| 126 | auto *args = new std::vector<TypedVar *> { |
| 127 | new TypedVar("recipient", new DeathRecipientType()) }; |
| 128 | |
| 129 | return new Method("unlinkToDeath", |
| 130 | args, |
| 131 | results, |
| 132 | false /*oneway */, |
| 133 | new std::vector<Annotation *>(), |
| 134 | HIDL_UNLINK_TO_DEATH_TRANSACTION, |
| 135 | { |
| 136 | {IMPL_HEADER, |
| 137 | [](auto &out) { |
| 138 | out << "return (recipient != nullptr);\n"; |
| 139 | } |
| 140 | }, |
| 141 | {IMPL_PROXY, |
| 142 | [](auto &out) { |
| 143 | out << "std::unique_lock<std::mutex> lock(_hidl_mMutex);\n" |
| 144 | << "for (auto it = _hidl_mDeathRecipients.begin();" |
| 145 | << "it != _hidl_mDeathRecipients.end();" |
| 146 | << "++it) {\n"; |
| 147 | out.indent([&] { |
| 148 | out.sIf("(*it)->getRecipient() == recipient", [&] { |
| 149 | out << "::android::status_t status = remote()->unlinkToDeath(*it);\n" |
| 150 | << "_hidl_mDeathRecipients.erase(it);\n" |
| 151 | << "return status == ::android::OK;\n"; |
| 152 | }); |
| 153 | }); |
| 154 | out << "}\n"; |
| 155 | out << "return false;\n"; |
| 156 | } |
| 157 | }, |
Martijn Coenen | 8d12b50 | 2016-12-27 14:30:27 +0100 | [diff] [blame] | 158 | {IMPL_STUB, nullptr /* don't generate code */} |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 159 | }, /*cppImpl*/ |
| 160 | { |
| 161 | {IMPL_HEADER, |
| 162 | [this](auto &out) { |
Martijn Coenen | 8d12b50 | 2016-12-27 14:30:27 +0100 | [diff] [blame] | 163 | out << "return true;\n"; |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 164 | } |
| 165 | }, |
| 166 | {IMPL_PROXY, |
| 167 | [this](auto &out) { |
Martijn Coenen | 8d12b50 | 2016-12-27 14:30:27 +0100 | [diff] [blame] | 168 | out << "return mRemote.unlinkToDeath(recipient);\n"; |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 169 | } |
| 170 | }, |
Martijn Coenen | 8d12b50 | 2016-12-27 14:30:27 +0100 | [diff] [blame] | 171 | {IMPL_STUB, nullptr /* don't generate code */} |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 172 | } /*javaImpl*/ |
| 173 | ); |
| 174 | } |
Martijn Coenen | af712c0 | 2016-11-16 15:26:27 +0100 | [diff] [blame] | 175 | Method *Interface::createSyspropsChangedMethod() const { |
| 176 | return new Method("notifySyspropsChanged", |
| 177 | new std::vector<TypedVar *>() /*args */, |
| 178 | new std::vector<TypedVar *>() /*results */, |
| 179 | true /*oneway */, |
| 180 | new std::vector<Annotation *>(), |
| 181 | HIDL_SYSPROPS_CHANGED_TRANSACTION, |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 182 | { { IMPL_HEADER, [this](auto &out) { |
Martijn Coenen | af712c0 | 2016-11-16 15:26:27 +0100 | [diff] [blame] | 183 | out << "::android::report_sysprop_change();\n"; |
| 184 | out << "return ::android::hardware::Void();"; |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 185 | } } }, /*cppImpl */ |
| 186 | { { IMPL_HEADER, [](auto &out) { /* javaImpl */ |
Martijn Coenen | af712c0 | 2016-11-16 15:26:27 +0100 | [diff] [blame] | 187 | out << "android.os.SystemProperties.reportSyspropChanged();"; |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 188 | } } } /*javaImpl */ |
Martijn Coenen | af712c0 | 2016-11-16 15:26:27 +0100 | [diff] [blame] | 189 | ); |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 190 | } |
| 191 | |
Zhuoyao Zhang | dd85c5c | 2017-01-03 17:30:24 -0800 | [diff] [blame] | 192 | Method *Interface::createSetHALInstrumentationMethod() const { |
| 193 | return new Method("setHALInstrumentation", |
| 194 | new std::vector<TypedVar *>() /*args */, |
| 195 | new std::vector<TypedVar *>() /*results */, |
| 196 | true /*oneway */, |
| 197 | new std::vector<Annotation *>(), |
| 198 | HIDL_SET_HAL_INSTRUMENTATION_TRANSACTION, |
| 199 | { |
| 200 | {IMPL_HEADER, |
| 201 | [this](auto &out) { |
| 202 | // do nothing for base class. |
| 203 | out << "return ::android::hardware::Void();\n"; |
| 204 | } |
| 205 | }, |
Zhuoyao Zhang | dd85c5c | 2017-01-03 17:30:24 -0800 | [diff] [blame] | 206 | {IMPL_STUB, |
| 207 | [](auto &out) { |
| 208 | out << "configureInstrumentation();\n"; |
| 209 | } |
| 210 | }, |
| 211 | {IMPL_PASSTHROUGH, |
| 212 | [](auto &out) { |
| 213 | out << "configureInstrumentation();\n"; |
| 214 | out << "return ::android::hardware::Void();\n"; |
| 215 | } |
| 216 | }, |
| 217 | }, /*cppImpl */ |
| 218 | { { IMPL_HEADER, [](auto & /*out*/) { /* javaImpl */ |
| 219 | // Not support for Java Impl for now. |
| 220 | } } } /*javaImpl */ |
| 221 | ); |
| 222 | } |
| 223 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 224 | Method *Interface::createDescriptorChainMethod() const { |
| 225 | VectorType *vecType = new VectorType(); |
| 226 | vecType->setElementType(new StringType()); |
| 227 | std::vector<TypedVar *> *results = new std::vector<TypedVar *>(); |
Yifan Hong | c75fd47 | 2017-01-11 12:37:31 -0800 | [diff] [blame^] | 228 | results->push_back(new TypedVar("descriptors", vecType)); |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 229 | |
| 230 | return new Method("interfaceChain", |
| 231 | new std::vector<TypedVar *>() /* args */, |
| 232 | results, |
| 233 | false /* oneway */, |
| 234 | new std::vector<Annotation *>(), |
| 235 | HIDL_DESCRIPTOR_CHAIN_TRANSACTION, |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 236 | { { IMPL_HEADER, [this](auto &out) { |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 237 | std::vector<const Interface *> chain = typeChain(); |
Yifan Hong | 0393512 | 2016-12-19 11:10:40 -0800 | [diff] [blame] | 238 | out << "_hidl_cb("; |
| 239 | out.block([&] { |
| 240 | for (const Interface *iface : chain) { |
| 241 | out << iface->fullName() << "::descriptor,\n"; |
| 242 | } |
| 243 | }); |
| 244 | out << ");\n"; |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 245 | out << "return ::android::hardware::Void();"; |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 246 | } } }, /* cppImpl */ |
| 247 | { { IMPL_HEADER, [this](auto &out) { |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 248 | std::vector<const Interface *> chain = typeChain(); |
Yifan Hong | 1af7353 | 2016-11-09 14:32:58 -0800 | [diff] [blame] | 249 | out << "return new java.util.ArrayList<String>(java.util.Arrays.asList(\n"; |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 250 | out.indent(); out.indent(); |
| 251 | for (size_t i = 0; i < chain.size(); ++i) { |
| 252 | if (i != 0) |
| 253 | out << ",\n"; |
Steven Moreland | d39133b | 2016-11-11 12:30:08 -0800 | [diff] [blame] | 254 | out << chain[i]->fullJavaName() << ".kInterfaceName"; |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 255 | } |
| 256 | out << "));"; |
| 257 | out.unindent(); out.unindent(); |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 258 | } } } /* javaImpl */ |
| 259 | ); |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 260 | } |
| 261 | |
Yifan Hong | c75fd47 | 2017-01-11 12:37:31 -0800 | [diff] [blame^] | 262 | Method *Interface::createGetDescriptorMethod() const { |
| 263 | std::vector<TypedVar *> *results = new std::vector<TypedVar *>(); |
| 264 | results->push_back(new TypedVar("descriptor", new StringType())); |
| 265 | |
| 266 | return new Method("interfaceDescriptor", |
| 267 | new std::vector<TypedVar *>() /* args */, |
| 268 | results, |
| 269 | false /* oneway */, |
| 270 | new std::vector<Annotation *>(), |
| 271 | HIDL_GET_DESCRIPTOR_TRANSACTION, |
| 272 | { { IMPL_HEADER, [this](auto &out) { |
| 273 | out << "_hidl_cb(" |
| 274 | << fullName() |
| 275 | << "::descriptor);\n" |
| 276 | << "return ::android::hardware::Void();"; |
| 277 | } } }, /* cppImpl */ |
| 278 | { { IMPL_HEADER, [this](auto &out) { |
| 279 | out << "return " |
| 280 | << fullJavaName() |
| 281 | << ".kInterfaceName;\n"; |
| 282 | } } } /* javaImpl */ |
| 283 | ); |
| 284 | } |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 285 | |
Steven Moreland | 14ee674 | 2016-10-18 12:58:28 -0700 | [diff] [blame] | 286 | bool Interface::addMethod(Method *method) { |
Yifan Hong | c893404 | 2016-11-17 17:10:52 -0800 | [diff] [blame] | 287 | if (isIBase()) { |
| 288 | // ignore addMethod requests for IBase; they are all HIDL reserved methods. |
| 289 | return true; |
| 290 | } |
| 291 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 292 | CHECK(!method->isHidlReserved()); |
Steven Moreland | 14ee674 | 2016-10-18 12:58:28 -0700 | [diff] [blame] | 293 | if (lookupMethod(method->name()) != nullptr) { |
| 294 | LOG(ERROR) << "Redefinition of method " << method->name(); |
| 295 | return false; |
| 296 | } |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 297 | size_t serial = FIRST_CALL_TRANSACTION; |
Steven Moreland | 14ee674 | 2016-10-18 12:58:28 -0700 | [diff] [blame] | 298 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 299 | serial += userDefinedMethods().size(); |
Steven Moreland | ef1a9fe | 2016-10-06 17:19:09 -0700 | [diff] [blame] | 300 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 301 | const Interface *ancestor = mSuperType; |
Steven Moreland | ef1a9fe | 2016-10-06 17:19:09 -0700 | [diff] [blame] | 302 | while (ancestor != nullptr) { |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 303 | serial += ancestor->userDefinedMethods().size(); |
Steven Moreland | ef1a9fe | 2016-10-06 17:19:09 -0700 | [diff] [blame] | 304 | ancestor = ancestor->superType(); |
| 305 | } |
| 306 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 307 | CHECK(serial <= LAST_CALL_TRANSACTION) << "More than " |
| 308 | << LAST_CALL_TRANSACTION << " methods are not allowed."; |
Steven Moreland | ef1a9fe | 2016-10-06 17:19:09 -0700 | [diff] [blame] | 309 | method->setSerialId(serial); |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 310 | mUserMethods.push_back(method); |
Steven Moreland | 14ee674 | 2016-10-18 12:58:28 -0700 | [diff] [blame] | 311 | |
| 312 | return true; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 313 | } |
| 314 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 315 | |
Andreas Huber | 6cb08cf | 2016-08-03 15:44:51 -0700 | [diff] [blame] | 316 | const Interface *Interface::superType() const { |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 317 | return mSuperType; |
| 318 | } |
| 319 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 320 | std::vector<const Interface *> Interface::typeChain() const { |
| 321 | std::vector<const Interface *> v; |
| 322 | const Interface *iface = this; |
| 323 | while (iface != nullptr) { |
| 324 | v.push_back(iface); |
| 325 | iface = iface->mSuperType; |
| 326 | } |
| 327 | return v; |
| 328 | } |
| 329 | |
Yifan Hong | fe95aa2 | 2016-10-19 17:26:45 -0700 | [diff] [blame] | 330 | std::vector<const Interface *> Interface::superTypeChain() const { |
| 331 | return superType()->typeChain(); // should work even if superType is nullptr |
| 332 | } |
| 333 | |
Martijn Coenen | b40ef02 | 2017-01-02 15:21:46 +0100 | [diff] [blame] | 334 | bool Interface::isElidableType() const { |
| 335 | return true; |
| 336 | } |
| 337 | |
Andreas Huber | a2723d2 | 2016-07-29 15:36:07 -0700 | [diff] [blame] | 338 | bool Interface::isInterface() const { |
| 339 | return true; |
| 340 | } |
| 341 | |
Andreas Huber | 295ad30 | 2016-08-16 11:35:00 -0700 | [diff] [blame] | 342 | bool Interface::isBinder() const { |
| 343 | return true; |
| 344 | } |
| 345 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 346 | const std::vector<Method *> &Interface::userDefinedMethods() const { |
| 347 | return mUserMethods; |
| 348 | } |
| 349 | |
| 350 | const std::vector<Method *> &Interface::hidlReservedMethods() const { |
| 351 | return mReservedMethods; |
| 352 | } |
| 353 | |
| 354 | std::vector<Method *> Interface::methods() const { |
| 355 | std::vector<Method *> v(mUserMethods); |
| 356 | v.insert(v.end(), mReservedMethods.begin(), mReservedMethods.end()); |
| 357 | return v; |
| 358 | } |
| 359 | |
| 360 | std::vector<InterfaceAndMethod> Interface::allMethodsFromRoot() const { |
| 361 | std::vector<InterfaceAndMethod> v; |
| 362 | std::vector<const Interface *> chain = typeChain(); |
| 363 | for (auto it = chain.rbegin(); it != chain.rend(); ++it) { |
| 364 | const Interface *iface = *it; |
| 365 | for (Method *userMethod : iface->userDefinedMethods()) { |
| 366 | v.push_back(InterfaceAndMethod(iface, userMethod)); |
| 367 | } |
| 368 | } |
| 369 | for (Method *reservedMethod : hidlReservedMethods()) { |
Yifan Hong | c893404 | 2016-11-17 17:10:52 -0800 | [diff] [blame] | 370 | v.push_back(InterfaceAndMethod( |
| 371 | *chain.rbegin(), // IBase |
| 372 | reservedMethod)); |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 373 | } |
| 374 | return v; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 375 | } |
| 376 | |
Steven Moreland | 14ee674 | 2016-10-18 12:58:28 -0700 | [diff] [blame] | 377 | Method *Interface::lookupMethod(std::string name) const { |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 378 | for (const auto &tuple : allMethodsFromRoot()) { |
| 379 | Method *method = tuple.method(); |
| 380 | if (method->name() == name) { |
| 381 | return method; |
Steven Moreland | 14ee674 | 2016-10-18 12:58:28 -0700 | [diff] [blame] | 382 | } |
Steven Moreland | 14ee674 | 2016-10-18 12:58:28 -0700 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | return nullptr; |
| 386 | } |
| 387 | |
Steven Moreland | 4078631 | 2016-08-16 10:29:40 -0700 | [diff] [blame] | 388 | std::string Interface::getBaseName() const { |
Jayant Chowdhary | 3f32c1f | 2016-09-15 16:53:56 -0700 | [diff] [blame] | 389 | return fqName().getInterfaceBaseName(); |
Steven Moreland | 4078631 | 2016-08-16 10:29:40 -0700 | [diff] [blame] | 390 | } |
| 391 | |
Yifan Hong | eefe4f2 | 2017-01-04 15:32:42 -0800 | [diff] [blame] | 392 | std::string Interface::getProxyName() const { |
| 393 | return fqName().getInterfaceProxyName(); |
| 394 | } |
| 395 | |
| 396 | std::string Interface::getStubName() const { |
| 397 | return fqName().getInterfaceStubName(); |
| 398 | } |
| 399 | |
| 400 | std::string Interface::getHwName() const { |
| 401 | return fqName().getInterfaceHwName(); |
| 402 | } |
| 403 | |
| 404 | std::string Interface::getPassthroughName() const { |
| 405 | return fqName().getInterfacePassthroughName(); |
| 406 | } |
| 407 | |
Yifan Hong | 51a6509 | 2017-01-04 15:41:44 -0800 | [diff] [blame] | 408 | FQName Interface::getProxyFqName() const { |
Yifan Hong | eefe4f2 | 2017-01-04 15:32:42 -0800 | [diff] [blame] | 409 | return fqName().getInterfaceProxyFqName(); |
Yifan Hong | 158655a | 2016-11-08 12:34:07 -0800 | [diff] [blame] | 410 | } |
| 411 | |
Yifan Hong | 51a6509 | 2017-01-04 15:41:44 -0800 | [diff] [blame] | 412 | FQName Interface::getStubFqName() const { |
Yifan Hong | eefe4f2 | 2017-01-04 15:32:42 -0800 | [diff] [blame] | 413 | return fqName().getInterfaceStubFqName(); |
Yifan Hong | 158655a | 2016-11-08 12:34:07 -0800 | [diff] [blame] | 414 | } |
| 415 | |
Yifan Hong | 51a6509 | 2017-01-04 15:41:44 -0800 | [diff] [blame] | 416 | FQName Interface::getPassthroughFqName() const { |
Yifan Hong | eefe4f2 | 2017-01-04 15:32:42 -0800 | [diff] [blame] | 417 | return fqName().getInterfacePassthroughFqName(); |
Yifan Hong | 158655a | 2016-11-08 12:34:07 -0800 | [diff] [blame] | 418 | } |
| 419 | |
Steven Moreland | 979e099 | 2016-09-07 09:18:08 -0700 | [diff] [blame] | 420 | std::string Interface::getCppType(StorageMode mode, |
Steven Moreland | 979e099 | 2016-09-07 09:18:08 -0700 | [diff] [blame] | 421 | bool specifyNamespaces) const { |
Steven Moreland | 979e099 | 2016-09-07 09:18:08 -0700 | [diff] [blame] | 422 | const std::string base = |
| 423 | std::string(specifyNamespaces ? "::android::" : "") |
| 424 | + "sp<" |
| 425 | + (specifyNamespaces ? fullName() : partialCppName()) |
| 426 | + ">"; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 427 | |
| 428 | switch (mode) { |
| 429 | case StorageMode_Stack: |
| 430 | case StorageMode_Result: |
| 431 | return base; |
| 432 | |
| 433 | case StorageMode_Argument: |
| 434 | return "const " + base + "&"; |
| 435 | } |
| 436 | } |
| 437 | |
Yifan Hong | 4ed1347 | 2016-11-02 10:44:11 -0700 | [diff] [blame] | 438 | std::string Interface::getJavaType(bool /* forInitializer */) const { |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 439 | return fullJavaName(); |
| 440 | } |
| 441 | |
Zhuoyao Zhang | a588b23 | 2016-11-10 14:37:35 -0800 | [diff] [blame] | 442 | std::string Interface::getVtsType() const { |
| 443 | if (StringHelper::EndsWith(localName(), "Callback")) { |
| 444 | return "TYPE_HIDL_CALLBACK"; |
| 445 | } else { |
| 446 | return "TYPE_HIDL_INTERFACE"; |
| 447 | } |
| 448 | } |
| 449 | |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 450 | void Interface::emitReaderWriter( |
| 451 | Formatter &out, |
| 452 | const std::string &name, |
| 453 | const std::string &parcelObj, |
| 454 | bool parcelObjIsPointer, |
| 455 | bool isReader, |
| 456 | ErrorMode mode) const { |
| 457 | const std::string parcelObjDeref = |
| 458 | parcelObj + (parcelObjIsPointer ? "->" : "."); |
| 459 | |
| 460 | if (isReader) { |
Andreas Huber | e7ff228 | 2016-08-16 13:50:03 -0700 | [diff] [blame] | 461 | out << "{\n"; |
| 462 | out.indent(); |
| 463 | |
Iliyan Malchev | 549e259 | 2016-08-10 08:59:12 -0700 | [diff] [blame] | 464 | const std::string binderName = "_hidl_" + name + "_binder"; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 465 | |
Andreas Huber | 8a82ff7 | 2016-08-04 10:29:39 -0700 | [diff] [blame] | 466 | out << "::android::sp<::android::hardware::IBinder> " |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 467 | << binderName << ";\n"; |
| 468 | |
Iliyan Malchev | 549e259 | 2016-08-10 08:59:12 -0700 | [diff] [blame] | 469 | out << "_hidl_err = "; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 470 | out << parcelObjDeref |
| 471 | << "readNullableStrongBinder(&" |
| 472 | << binderName |
| 473 | << ");\n"; |
| 474 | |
| 475 | handleError(out, mode); |
| 476 | |
| 477 | out << name |
| 478 | << " = " |
Martijn Coenen | a63e0ad | 2016-12-07 17:29:00 +0100 | [diff] [blame] | 479 | << "::android::hardware::fromBinder<" |
| 480 | << fqName().cppName() |
| 481 | << "," |
Yifan Hong | 51a6509 | 2017-01-04 15:41:44 -0800 | [diff] [blame] | 482 | << getProxyFqName().cppName() |
Martijn Coenen | a63e0ad | 2016-12-07 17:29:00 +0100 | [diff] [blame] | 483 | << "," |
Yifan Hong | 51a6509 | 2017-01-04 15:41:44 -0800 | [diff] [blame] | 484 | << getStubFqName().cppName() |
Martijn Coenen | a63e0ad | 2016-12-07 17:29:00 +0100 | [diff] [blame] | 485 | << ">(" |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 486 | << binderName |
| 487 | << ");\n"; |
Andreas Huber | e7ff228 | 2016-08-16 13:50:03 -0700 | [diff] [blame] | 488 | |
| 489 | out.unindent(); |
| 490 | out << "}\n\n"; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 491 | } else { |
Martijn Coenen | e163823 | 2016-10-26 12:51:34 +0200 | [diff] [blame] | 492 | out << "if (" << name << " == nullptr) {\n"; |
| 493 | out.indent(); |
| 494 | out << "_hidl_err = "; |
| 495 | out << parcelObjDeref |
| 496 | << "writeStrongBinder(nullptr);\n"; |
| 497 | out.unindent(); |
| 498 | out << "} else {\n"; |
| 499 | out.indent(); |
Yifan Hong | 158655a | 2016-11-08 12:34:07 -0800 | [diff] [blame] | 500 | out << "::android::sp<::android::hardware::IBinder> _hidl_binder = " |
| 501 | << "::android::hardware::toBinder<\n"; |
Yifan Hong | 33223ca | 2016-12-13 15:07:35 -0800 | [diff] [blame] | 502 | out.indent(2, [&] { |
Martijn Coenen | a63e0ad | 2016-12-07 17:29:00 +0100 | [diff] [blame] | 503 | out << fqName().cppName() |
Yifan Hong | 158655a | 2016-11-08 12:34:07 -0800 | [diff] [blame] | 504 | << ", " |
Yifan Hong | 51a6509 | 2017-01-04 15:41:44 -0800 | [diff] [blame] | 505 | << getProxyFqName().cppName() |
Yifan Hong | 158655a | 2016-11-08 12:34:07 -0800 | [diff] [blame] | 506 | << ">(" |
| 507 | << name |
| 508 | << ");\n"; |
| 509 | }); |
| 510 | out << "if (_hidl_binder.get() != nullptr) {\n"; |
Yifan Hong | 33223ca | 2016-12-13 15:07:35 -0800 | [diff] [blame] | 511 | out.indent([&] { |
Yifan Hong | 158655a | 2016-11-08 12:34:07 -0800 | [diff] [blame] | 512 | out << "_hidl_err = " |
| 513 | << parcelObjDeref |
| 514 | << "writeStrongBinder(_hidl_binder);\n"; |
| 515 | }); |
| 516 | out << "} else {\n"; |
Yifan Hong | 33223ca | 2016-12-13 15:07:35 -0800 | [diff] [blame] | 517 | out.indent([&] { |
Yifan Hong | 158655a | 2016-11-08 12:34:07 -0800 | [diff] [blame] | 518 | out << "_hidl_err = ::android::UNKNOWN_ERROR;\n"; |
| 519 | }); |
| 520 | out << "}\n"; |
Martijn Coenen | e163823 | 2016-10-26 12:51:34 +0200 | [diff] [blame] | 521 | out.unindent(); |
| 522 | out << "}\n"; |
Steven Moreland | 4078631 | 2016-08-16 10:29:40 -0700 | [diff] [blame] | 523 | |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 524 | handleError(out, mode); |
| 525 | } |
| 526 | } |
| 527 | |
Yifan Hong | f5cc2f7 | 2017-01-04 18:02:34 -0800 | [diff] [blame] | 528 | status_t Interface::emitGlobalTypeDeclarations(Formatter &out) const { |
| 529 | status_t status = Scope::emitGlobalTypeDeclarations(out); |
| 530 | if (status != OK) { |
| 531 | return status; |
| 532 | } |
| 533 | out << "std::string toString(" |
| 534 | << getCppArgumentType() |
| 535 | << ");\n"; |
| 536 | return OK; |
| 537 | } |
| 538 | |
| 539 | |
| 540 | status_t Interface::emitTypeDefinitions( |
| 541 | Formatter &out, const std::string prefix) const { |
| 542 | std::string space = prefix.empty() ? "" : (prefix + "::"); |
| 543 | status_t err = Scope::emitTypeDefinitions(out, space + localName()); |
| 544 | if (err != OK) { |
| 545 | return err; |
| 546 | } |
| 547 | |
| 548 | out << "std::string toString(" |
| 549 | << getCppArgumentType() |
| 550 | << " o) "; |
| 551 | |
| 552 | out.block([&] { |
| 553 | out << "std::string os;\nbool ok = false;\n"; |
| 554 | // TODO b/34136228 use interfaceDescriptor instead |
| 555 | out << "auto ret = o->interfaceChain([&os, &ok] (const auto &chain) "; |
| 556 | out.block([&] { |
| 557 | out.sIf("chain.size() >= 1", [&] { |
| 558 | out << "os += chain[0].c_str();\n" |
| 559 | << "ok = true;\n"; |
| 560 | }).endl(); |
| 561 | }); |
| 562 | out << ");\n"; |
| 563 | out.sIf("!ret.isOk() || !ok", [&] { |
| 564 | out << "os += \"[class or subclass of \";\n" |
| 565 | << "os += " << fullName() << "::descriptor;\n" |
| 566 | << "os += \"]\";\n"; |
| 567 | }).endl(); |
| 568 | out << "os += o->isRemote() ? \"@remote\" : \"@local\";\n" |
| 569 | << "return os;\n"; |
| 570 | }).endl().endl(); |
| 571 | |
| 572 | return OK; |
| 573 | } |
| 574 | |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 575 | void Interface::emitJavaReaderWriter( |
| 576 | Formatter &out, |
| 577 | const std::string &parcelObj, |
| 578 | const std::string &argName, |
| 579 | bool isReader) const { |
| 580 | if (isReader) { |
| 581 | out << fullJavaName() |
| 582 | << ".asInterface(" |
| 583 | << parcelObj |
| 584 | << ".readStrongBinder());\n"; |
| 585 | } else { |
| 586 | out << parcelObj |
| 587 | << ".writeStrongBinder(" |
| 588 | << argName |
| 589 | << " == null ? null : " |
| 590 | << argName |
| 591 | << ".asBinder());\n"; |
| 592 | } |
| 593 | } |
| 594 | |
Zhuoyao Zhang | 864c771 | 2016-08-16 15:35:28 -0700 | [diff] [blame] | 595 | status_t Interface::emitVtsAttributeDeclaration(Formatter &out) const { |
| 596 | for (const auto &type : getSubTypes()) { |
Zhuoyao Zhang | c5ea9f5 | 2016-10-06 15:05:39 -0700 | [diff] [blame] | 597 | // Skip for TypeDef as it is just an alias of a defined type. |
| 598 | if (type->isTypeDef()) { |
| 599 | continue; |
| 600 | } |
Zhuoyao Zhang | 864c771 | 2016-08-16 15:35:28 -0700 | [diff] [blame] | 601 | out << "attribute: {\n"; |
| 602 | out.indent(); |
| 603 | status_t status = type->emitVtsTypeDeclarations(out); |
| 604 | if (status != OK) { |
| 605 | return status; |
| 606 | } |
| 607 | out.unindent(); |
| 608 | out << "}\n\n"; |
| 609 | } |
| 610 | return OK; |
| 611 | } |
| 612 | |
| 613 | status_t Interface::emitVtsMethodDeclaration(Formatter &out) const { |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 614 | for (const auto &method : methods()) { |
Steven Moreland | cea2478 | 2016-11-07 11:40:48 -0800 | [diff] [blame] | 615 | if (method->isHidlReserved()) { |
| 616 | continue; |
| 617 | } |
| 618 | |
Zhuoyao Zhang | 864c771 | 2016-08-16 15:35:28 -0700 | [diff] [blame] | 619 | out << "api: {\n"; |
| 620 | out.indent(); |
| 621 | out << "name: \"" << method->name() << "\"\n"; |
| 622 | // Generate declaration for each return value. |
| 623 | for (const auto &result : method->results()) { |
| 624 | out << "return_type_hidl: {\n"; |
| 625 | out.indent(); |
| 626 | status_t status = result->type().emitVtsAttributeType(out); |
| 627 | if (status != OK) { |
| 628 | return status; |
| 629 | } |
| 630 | out.unindent(); |
| 631 | out << "}\n"; |
| 632 | } |
| 633 | // Generate declaration for each input argument |
| 634 | for (const auto &arg : method->args()) { |
| 635 | out << "arg: {\n"; |
| 636 | out.indent(); |
| 637 | status_t status = arg->type().emitVtsAttributeType(out); |
| 638 | if (status != OK) { |
| 639 | return status; |
| 640 | } |
| 641 | out.unindent(); |
| 642 | out << "}\n"; |
| 643 | } |
| 644 | // Generate declaration for each annotation. |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame] | 645 | for (const auto &annotation : method->annotations()) { |
Zhuoyao Zhang | 864c771 | 2016-08-16 15:35:28 -0700 | [diff] [blame] | 646 | out << "callflow: {\n"; |
| 647 | out.indent(); |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame] | 648 | std::string name = annotation->name(); |
Zhuoyao Zhang | 864c771 | 2016-08-16 15:35:28 -0700 | [diff] [blame] | 649 | if (name == "entry") { |
| 650 | out << "entry: true\n"; |
| 651 | } else if (name == "exit") { |
| 652 | out << "exit: true\n"; |
| 653 | } else if (name == "callflow") { |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame] | 654 | const AnnotationParam *param = |
| 655 | annotation->getParam("next"); |
| 656 | if (param != nullptr) { |
| 657 | for (auto value : *param->getValues()) { |
| 658 | out << "next: " << value << "\n"; |
| 659 | } |
Zhuoyao Zhang | 864c771 | 2016-08-16 15:35:28 -0700 | [diff] [blame] | 660 | } |
| 661 | } else { |
| 662 | std::cerr << "Invalid annotation '" |
| 663 | << name << "' for method: " << method->name() |
| 664 | << ". Should be one of: entry, exit, callflow. \n"; |
| 665 | return UNKNOWN_ERROR; |
| 666 | } |
| 667 | out.unindent(); |
| 668 | out << "}\n"; |
| 669 | } |
| 670 | out.unindent(); |
| 671 | out << "}\n\n"; |
| 672 | } |
| 673 | return OK; |
| 674 | } |
| 675 | |
| 676 | status_t Interface::emitVtsAttributeType(Formatter &out) const { |
Zhuoyao Zhang | a588b23 | 2016-11-10 14:37:35 -0800 | [diff] [blame] | 677 | out << "type: " << getVtsType() << "\n" |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame] | 678 | << "predefined_type: \"" |
| 679 | << localName() |
Zhuoyao Zhang | 1993352 | 2016-08-29 15:06:38 -0700 | [diff] [blame] | 680 | << "\"\n" |
Zhuoyao Zhang | a588b23 | 2016-11-10 14:37:35 -0800 | [diff] [blame] | 681 | << "is_callback: " |
| 682 | << (StringHelper::EndsWith(localName(), "Callback") ? "true" : "false") |
| 683 | << "\n"; |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame] | 684 | return OK; |
| 685 | } |
| 686 | |
Steven Moreland | 69e7c70 | 2016-09-09 11:16:32 -0700 | [diff] [blame] | 687 | bool Interface::hasOnewayMethods() const { |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 688 | for (auto const &method : methods()) { |
Steven Moreland | 69e7c70 | 2016-09-09 11:16:32 -0700 | [diff] [blame] | 689 | if (method->isOneway()) { |
| 690 | return true; |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | const Interface* superClass = superType(); |
| 695 | |
| 696 | if (superClass != nullptr) { |
| 697 | return superClass->hasOnewayMethods(); |
| 698 | } |
| 699 | |
| 700 | return false; |
| 701 | } |
| 702 | |
Andreas Huber | 70a59e1 | 2016-08-16 12:57:01 -0700 | [diff] [blame] | 703 | bool Interface::isJavaCompatible() const { |
Andreas Huber | ea081b3 | 2016-08-17 15:57:47 -0700 | [diff] [blame] | 704 | if (mIsJavaCompatibleInProgress) { |
| 705 | // We're currently trying to determine if this Interface is |
| 706 | // java-compatible and something is referencing this interface through |
| 707 | // one of its methods. Assume we'll ultimately succeed, if we were wrong |
| 708 | // the original invocation of Interface::isJavaCompatible() will then |
| 709 | // return the correct "false" result. |
| 710 | return true; |
| 711 | } |
| 712 | |
Andreas Huber | 0fa9e39 | 2016-08-31 09:05:44 -0700 | [diff] [blame] | 713 | if (mSuperType != nullptr && !mSuperType->isJavaCompatible()) { |
| 714 | mIsJavaCompatibleInProgress = false; |
| 715 | return false; |
| 716 | } |
| 717 | |
Andreas Huber | ea081b3 | 2016-08-17 15:57:47 -0700 | [diff] [blame] | 718 | mIsJavaCompatibleInProgress = true; |
| 719 | |
Andreas Huber | 70a59e1 | 2016-08-16 12:57:01 -0700 | [diff] [blame] | 720 | if (!Scope::isJavaCompatible()) { |
Andreas Huber | ea081b3 | 2016-08-17 15:57:47 -0700 | [diff] [blame] | 721 | mIsJavaCompatibleInProgress = false; |
Andreas Huber | 70a59e1 | 2016-08-16 12:57:01 -0700 | [diff] [blame] | 722 | return false; |
| 723 | } |
| 724 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 725 | for (const auto &method : methods()) { |
Andreas Huber | 70a59e1 | 2016-08-16 12:57:01 -0700 | [diff] [blame] | 726 | if (!method->isJavaCompatible()) { |
Andreas Huber | ea081b3 | 2016-08-17 15:57:47 -0700 | [diff] [blame] | 727 | mIsJavaCompatibleInProgress = false; |
Andreas Huber | 70a59e1 | 2016-08-16 12:57:01 -0700 | [diff] [blame] | 728 | return false; |
| 729 | } |
| 730 | } |
| 731 | |
Andreas Huber | ea081b3 | 2016-08-17 15:57:47 -0700 | [diff] [blame] | 732 | mIsJavaCompatibleInProgress = false; |
| 733 | |
Andreas Huber | 70a59e1 | 2016-08-16 12:57:01 -0700 | [diff] [blame] | 734 | return true; |
| 735 | } |
| 736 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 737 | } // namespace android |
| 738 | |