blob: 805d81c583334c4f8971b7938d26f38b228a64b9 [file] [log] [blame]
Andreas Huber1aec3972016-08-26 09:26:32 -07001/*
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 Huberc9410c72016-07-28 12:18:40 -070017#include "Interface.h"
18
Zhuoyao Zhangba7e6e92016-08-10 12:19:02 -070019#include "Annotation.h"
Yifan Hong30b5d1f2017-04-03 12:19:25 -070020#include "ArrayType.h"
21#include "ConstantExpression.h"
Martijn Coenen115d4282016-12-19 05:14:04 +010022#include "DeathRecipientType.h"
Andreas Huberc9410c72016-07-28 12:18:40 -070023#include "Method.h"
Martijn Coenen115d4282016-12-19 05:14:04 +010024#include "ScalarType.h"
Yifan Hong10fe0b52016-10-19 14:20:17 -070025#include "StringType.h"
26#include "VectorType.h"
Andreas Huberc9410c72016-07-28 12:18:40 -070027
Yifan Hong30b5d1f2017-04-03 12:19:25 -070028#include <unistd.h>
29
Yifan Hong30b5d1f2017-04-03 12:19:25 -070030#include <iostream>
31#include <sstream>
32
Steven Moreland14ee6742016-10-18 12:58:28 -070033#include <android-base/logging.h>
Steven Moreland5bdfa702017-04-18 23:20:39 -070034#include <hidl-hash/Hash.h>
Iliyan Malcheva72e0d22016-09-09 11:03:08 -070035#include <hidl-util/Formatter.h>
Yifan Hong10fe0b52016-10-19 14:20:17 -070036#include <hidl-util/StringHelper.h>
Zhuoyao Zhang864c7712016-08-16 15:35:28 -070037
Andreas Huberc9410c72016-07-28 12:18:40 -070038namespace android {
39
Steven Morelandb8e15a52017-02-13 19:35:40 -080040#define B_PACK_CHARS(c1, c2, c3, c4) \
41 ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4))
42
Yifan Hong10fe0b52016-10-19 14:20:17 -070043/* It is very important that these values NEVER change. These values
44 * must remain unchanged over the lifetime of android. This is
45 * because the framework on a device will be updated independently of
46 * the hals on a device. If the hals are compiled with one set of
47 * transaction values, and the framework with another, then the
48 * interface between them will be destroyed, and the device will not
49 * work.
50 */
51enum {
Yifan Hong10fe0b52016-10-19 14:20:17 -070052 /////////////////// User defined transactions
53 FIRST_CALL_TRANSACTION = 0x00000001,
Steven Morelandb8e15a52017-02-13 19:35:40 -080054 LAST_CALL_TRANSACTION = 0x0effffff,
Yifan Hong10fe0b52016-10-19 14:20:17 -070055 /////////////////// HIDL reserved
Steven Morelandb8e15a52017-02-13 19:35:40 -080056 FIRST_HIDL_TRANSACTION = 0x0f000000,
57 HIDL_PING_TRANSACTION = B_PACK_CHARS(0x0f, 'P', 'N', 'G'),
58 HIDL_DESCRIPTOR_CHAIN_TRANSACTION = B_PACK_CHARS(0x0f, 'C', 'H', 'N'),
59 HIDL_GET_DESCRIPTOR_TRANSACTION = B_PACK_CHARS(0x0f, 'D', 'S', 'C'),
60 HIDL_SYSPROPS_CHANGED_TRANSACTION = B_PACK_CHARS(0x0f, 'S', 'Y', 'S'),
61 HIDL_LINK_TO_DEATH_TRANSACTION = B_PACK_CHARS(0x0f, 'L', 'T', 'D'),
62 HIDL_UNLINK_TO_DEATH_TRANSACTION = B_PACK_CHARS(0x0f, 'U', 'T', 'D'),
63 HIDL_SET_HAL_INSTRUMENTATION_TRANSACTION = B_PACK_CHARS(0x0f, 'I', 'N', 'T'),
64 HIDL_GET_REF_INFO_TRANSACTION = B_PACK_CHARS(0x0f, 'R', 'E', 'F'),
65 HIDL_DEBUG_TRANSACTION = B_PACK_CHARS(0x0f, 'D', 'B', 'G'),
Yifan Hong30b5d1f2017-04-03 12:19:25 -070066 HIDL_HASH_CHAIN_TRANSACTION = B_PACK_CHARS(0x0f, 'H', 'S', 'H'),
Steven Morelandb8e15a52017-02-13 19:35:40 -080067 LAST_HIDL_TRANSACTION = 0x0fffffff,
Yifan Hong10fe0b52016-10-19 14:20:17 -070068};
69
Timur Iskhakovcb0ba522017-07-17 20:01:37 -070070Interface::Interface(const char* localName, const Location& location, Scope* parent,
Timur Iskhakov505316c2017-08-05 03:38:59 +000071 const Reference<Interface>& superType)
72 : Scope(localName, location, parent),
73 mSuperType(superType),
74 mIsJavaCompatibleInProgress(false) {}
Martijn Coenenaf712c02016-11-16 15:26:27 +010075
Steven Moreland30bb6a82016-11-30 09:18:34 -080076std::string Interface::typeName() const {
77 return "interface " + localName();
78}
79
Steven Moreland424a9482017-02-13 19:20:40 -080080bool Interface::fillPingMethod(Method *method) const {
81 if (method->name() != "ping") {
82 return false;
83 }
84
85 method->fillImplementation(
86 HIDL_PING_TRANSACTION,
87 {
Steven Moreland937408a2017-03-20 09:54:18 -070088 {IMPL_INTERFACE,
Steven Moreland424a9482017-02-13 19:20:40 -080089 [](auto &out) {
90 out << "return ::android::hardware::Void();\n";
91 }
92 },
93 {IMPL_STUB_IMPL,
94 [](auto &out) {
95 out << "return ::android::hardware::Void();\n";
96 }
97 }
98 }, /*cppImpl*/
99 {
Steven Moreland937408a2017-03-20 09:54:18 -0700100 {IMPL_INTERFACE,
Yi Kongc8ff4672017-04-30 23:46:56 -0700101 [](auto &out) {
Steven Moreland424a9482017-02-13 19:20:40 -0800102 out << "return;\n";
103 }
104 },
105 {IMPL_STUB, nullptr /* don't generate code */}
106 } /*javaImpl*/
107 );
108
109 return true;
110}
111
Yifan Hongffa91392017-01-31 13:41:23 -0800112bool Interface::fillLinkToDeathMethod(Method *method) const {
113 if (method->name() != "linkToDeath") {
114 return false;
115 }
Martijn Coenen115d4282016-12-19 05:14:04 +0100116
Yifan Hongffa91392017-01-31 13:41:23 -0800117 method->fillImplementation(
Martijn Coenen115d4282016-12-19 05:14:04 +0100118 HIDL_LINK_TO_DEATH_TRANSACTION,
119 {
Steven Moreland937408a2017-03-20 09:54:18 -0700120 {IMPL_INTERFACE,
Martijn Coenen115d4282016-12-19 05:14:04 +0100121 [](auto &out) {
122 out << "(void)cookie;\n"
123 << "return (recipient != nullptr);\n";
124 }
125 },
126 {IMPL_PROXY,
127 [](auto &out) {
Martijn Coenenfa55d6e2016-12-20 06:08:31 +0100128 out << "::android::hardware::ProcessState::self()->startThreadPool();\n";
Martijn Coenen115d4282016-12-19 05:14:04 +0100129 out << "::android::hardware::hidl_binder_death_recipient *binder_recipient"
130 << " = new ::android::hardware::hidl_binder_death_recipient(recipient, cookie, this);\n"
131 << "std::unique_lock<std::mutex> lock(_hidl_mMutex);\n"
132 << "_hidl_mDeathRecipients.push_back(binder_recipient);\n"
133 << "return (remote()->linkToDeath(binder_recipient)"
134 << " == ::android::OK);\n";
135 }
136 },
Martijn Coenen8d12b502016-12-27 14:30:27 +0100137 {IMPL_STUB, nullptr}
Martijn Coenen115d4282016-12-19 05:14:04 +0100138 }, /*cppImpl*/
139 {
Steven Moreland937408a2017-03-20 09:54:18 -0700140 {IMPL_INTERFACE,
Yi Kongc8ff4672017-04-30 23:46:56 -0700141 [](auto &out) {
Martijn Coenen115d4282016-12-19 05:14:04 +0100142 out << "return true;";
143 }
144 },
145 {IMPL_PROXY,
Yi Kongc8ff4672017-04-30 23:46:56 -0700146 [](auto &out) {
Martijn Coenen8d12b502016-12-27 14:30:27 +0100147 out << "return mRemote.linkToDeath(recipient, cookie);\n";
Martijn Coenen115d4282016-12-19 05:14:04 +0100148 }
149 },
Martijn Coenen8d12b502016-12-27 14:30:27 +0100150 {IMPL_STUB, nullptr}
Martijn Coenen115d4282016-12-19 05:14:04 +0100151 } /*javaImpl*/
152 );
Yifan Hongffa91392017-01-31 13:41:23 -0800153 return true;
Martijn Coenen115d4282016-12-19 05:14:04 +0100154}
155
Yifan Hongffa91392017-01-31 13:41:23 -0800156bool Interface::fillUnlinkToDeathMethod(Method *method) const {
157 if (method->name() != "unlinkToDeath") {
158 return false;
159 }
Martijn Coenen115d4282016-12-19 05:14:04 +0100160
Yifan Hongffa91392017-01-31 13:41:23 -0800161 method->fillImplementation(
Martijn Coenen115d4282016-12-19 05:14:04 +0100162 HIDL_UNLINK_TO_DEATH_TRANSACTION,
163 {
Steven Moreland937408a2017-03-20 09:54:18 -0700164 {IMPL_INTERFACE,
Martijn Coenen115d4282016-12-19 05:14:04 +0100165 [](auto &out) {
166 out << "return (recipient != nullptr);\n";
167 }
168 },
169 {IMPL_PROXY,
170 [](auto &out) {
171 out << "std::unique_lock<std::mutex> lock(_hidl_mMutex);\n"
172 << "for (auto it = _hidl_mDeathRecipients.begin();"
173 << "it != _hidl_mDeathRecipients.end();"
174 << "++it) {\n";
175 out.indent([&] {
176 out.sIf("(*it)->getRecipient() == recipient", [&] {
177 out << "::android::status_t status = remote()->unlinkToDeath(*it);\n"
178 << "_hidl_mDeathRecipients.erase(it);\n"
179 << "return status == ::android::OK;\n";
180 });
181 });
182 out << "}\n";
183 out << "return false;\n";
184 }
185 },
Martijn Coenen8d12b502016-12-27 14:30:27 +0100186 {IMPL_STUB, nullptr /* don't generate code */}
Martijn Coenen115d4282016-12-19 05:14:04 +0100187 }, /*cppImpl*/
188 {
Steven Moreland937408a2017-03-20 09:54:18 -0700189 {IMPL_INTERFACE,
Yi Kongc8ff4672017-04-30 23:46:56 -0700190 [](auto &out) {
Martijn Coenen8d12b502016-12-27 14:30:27 +0100191 out << "return true;\n";
Martijn Coenen115d4282016-12-19 05:14:04 +0100192 }
193 },
194 {IMPL_PROXY,
Yi Kongc8ff4672017-04-30 23:46:56 -0700195 [](auto &out) {
Martijn Coenen8d12b502016-12-27 14:30:27 +0100196 out << "return mRemote.unlinkToDeath(recipient);\n";
Martijn Coenen115d4282016-12-19 05:14:04 +0100197 }
198 },
Martijn Coenen8d12b502016-12-27 14:30:27 +0100199 {IMPL_STUB, nullptr /* don't generate code */}
Martijn Coenen115d4282016-12-19 05:14:04 +0100200 } /*javaImpl*/
201 );
Yifan Hongffa91392017-01-31 13:41:23 -0800202 return true;
Martijn Coenen115d4282016-12-19 05:14:04 +0100203}
Yifan Hongffa91392017-01-31 13:41:23 -0800204bool Interface::fillSyspropsChangedMethod(Method *method) const {
205 if (method->name() != "notifySyspropsChanged") {
206 return false;
207 }
208
209 method->fillImplementation(
Martijn Coenenaf712c02016-11-16 15:26:27 +0100210 HIDL_SYSPROPS_CHANGED_TRANSACTION,
Yi Kongc8ff4672017-04-30 23:46:56 -0700211 { { IMPL_INTERFACE, [](auto &out) {
Martijn Coenenaf712c02016-11-16 15:26:27 +0100212 out << "::android::report_sysprop_change();\n";
213 out << "return ::android::hardware::Void();";
Martijn Coenen115d4282016-12-19 05:14:04 +0100214 } } }, /*cppImpl */
Steven Moreland937408a2017-03-20 09:54:18 -0700215 { { IMPL_INTERFACE, [](auto &out) { /* javaImpl */
Sundong Ahnc1432c92017-07-13 23:58:27 +0900216 out << "android.os.HwBinder.reportSyspropChanged();";
Martijn Coenen115d4282016-12-19 05:14:04 +0100217 } } } /*javaImpl */
Martijn Coenenaf712c02016-11-16 15:26:27 +0100218 );
Yifan Hongffa91392017-01-31 13:41:23 -0800219 return true;
Andreas Huberc9410c72016-07-28 12:18:40 -0700220}
221
Yifan Hongffa91392017-01-31 13:41:23 -0800222bool Interface::fillSetHALInstrumentationMethod(Method *method) const {
223 if (method->name() != "setHALInstrumentation") {
224 return false;
225 }
226
227 method->fillImplementation(
Zhuoyao Zhangdd85c5c2017-01-03 17:30:24 -0800228 HIDL_SET_HAL_INSTRUMENTATION_TRANSACTION,
229 {
Steven Moreland937408a2017-03-20 09:54:18 -0700230 {IMPL_INTERFACE,
Yi Kongc8ff4672017-04-30 23:46:56 -0700231 [](auto &out) {
Zhuoyao Zhangdd85c5c2017-01-03 17:30:24 -0800232 // do nothing for base class.
233 out << "return ::android::hardware::Void();\n";
234 }
235 },
Zhuoyao Zhangdd85c5c2017-01-03 17:30:24 -0800236 {IMPL_STUB,
237 [](auto &out) {
238 out << "configureInstrumentation();\n";
239 }
240 },
241 {IMPL_PASSTHROUGH,
242 [](auto &out) {
243 out << "configureInstrumentation();\n";
244 out << "return ::android::hardware::Void();\n";
245 }
246 },
247 }, /*cppImpl */
Steven Moreland937408a2017-03-20 09:54:18 -0700248 { { IMPL_INTERFACE, [](auto & /*out*/) { /* javaImpl */
Zhuoyao Zhangdd85c5c2017-01-03 17:30:24 -0800249 // Not support for Java Impl for now.
250 } } } /*javaImpl */
251 );
Yifan Hongffa91392017-01-31 13:41:23 -0800252 return true;
Zhuoyao Zhangdd85c5c2017-01-03 17:30:24 -0800253}
254
Yifan Hongffa91392017-01-31 13:41:23 -0800255bool Interface::fillDescriptorChainMethod(Method *method) const {
256 if (method->name() != "interfaceChain") {
257 return false;
258 }
Yifan Hong10fe0b52016-10-19 14:20:17 -0700259
Yifan Hongffa91392017-01-31 13:41:23 -0800260 method->fillImplementation(
Yifan Hong10fe0b52016-10-19 14:20:17 -0700261 HIDL_DESCRIPTOR_CHAIN_TRANSACTION,
Steven Moreland937408a2017-03-20 09:54:18 -0700262 { { IMPL_INTERFACE, [this](auto &out) {
Yifan Hong10fe0b52016-10-19 14:20:17 -0700263 std::vector<const Interface *> chain = typeChain();
Yifan Hong03935122016-12-19 11:10:40 -0800264 out << "_hidl_cb(";
265 out.block([&] {
266 for (const Interface *iface : chain) {
267 out << iface->fullName() << "::descriptor,\n";
268 }
269 });
270 out << ");\n";
Yifan Hong10fe0b52016-10-19 14:20:17 -0700271 out << "return ::android::hardware::Void();";
Martijn Coenen115d4282016-12-19 05:14:04 +0100272 } } }, /* cppImpl */
Steven Moreland937408a2017-03-20 09:54:18 -0700273 { { IMPL_INTERFACE, [this](auto &out) {
Yifan Hong10fe0b52016-10-19 14:20:17 -0700274 std::vector<const Interface *> chain = typeChain();
Yifan Hong1af73532016-11-09 14:32:58 -0800275 out << "return new java.util.ArrayList<String>(java.util.Arrays.asList(\n";
Yifan Hong10fe0b52016-10-19 14:20:17 -0700276 out.indent(); out.indent();
277 for (size_t i = 0; i < chain.size(); ++i) {
278 if (i != 0)
279 out << ",\n";
Steven Morelandd39133b2016-11-11 12:30:08 -0800280 out << chain[i]->fullJavaName() << ".kInterfaceName";
Yifan Hong10fe0b52016-10-19 14:20:17 -0700281 }
282 out << "));";
283 out.unindent(); out.unindent();
Yifan Hongffa91392017-01-31 13:41:23 -0800284 } } } /* javaImpl */
Martijn Coenen115d4282016-12-19 05:14:04 +0100285 );
Yifan Hongffa91392017-01-31 13:41:23 -0800286 return true;
Yifan Hong10fe0b52016-10-19 14:20:17 -0700287}
288
Yifan Hong30b5d1f2017-04-03 12:19:25 -0700289static void emitDigestChain(
290 Formatter &out,
291 const std::string &prefix,
292 const std::vector<const Interface *> &chain,
293 std::function<std::string(const ConstantExpression &)> byteToString) {
294 out.join(chain.begin(), chain.end(), ",\n", [&] (const auto &iface) {
Steven Moreland0e4be1e2017-04-18 19:50:29 -0700295 const Hash &hash = Hash::getHash(iface->location().begin().filename());
Yifan Hong30b5d1f2017-04-03 12:19:25 -0700296 out << prefix;
297 out << "{";
Steven Moreland0e4be1e2017-04-18 19:50:29 -0700298 out.join(hash.raw().begin(), hash.raw().end(), ",", [&](const auto &e) {
Yifan Hong30b5d1f2017-04-03 12:19:25 -0700299 // Use ConstantExpression::cppValue / javaValue
300 // because Java used signed byte for uint8_t.
301 out << byteToString(ConstantExpression::ValueOf(ScalarType::Kind::KIND_UINT8, e));
302 });
303 out << "} /* ";
Steven Moreland0e4be1e2017-04-18 19:50:29 -0700304 out << hash.hexString();
Yifan Hong30b5d1f2017-04-03 12:19:25 -0700305 out << " */";
306 });
307}
308
309bool Interface::fillHashChainMethod(Method *method) const {
310 if (method->name() != "getHashChain") {
311 return false;
312 }
313 const VectorType *chainType = static_cast<const VectorType *>(&method->results()[0]->type());
314 const ArrayType *digestType = static_cast<const ArrayType *>(chainType->getElementType());
315
316 method->fillImplementation(
317 HIDL_HASH_CHAIN_TRANSACTION,
318 { { IMPL_INTERFACE, [this, digestType](auto &out) {
319 std::vector<const Interface *> chain = typeChain();
320 out << "_hidl_cb(";
321 out.block([&] {
322 emitDigestChain(out, "(" + digestType->getInternalDataCppType() + ")",
323 chain, [](const auto &e){return e.cppValue();});
324 });
325 out << ");\n";
326 out << "return ::android::hardware::Void();\n";
327 } } }, /* cppImpl */
328 { { IMPL_INTERFACE, [this, digestType, chainType](auto &out) {
329 std::vector<const Interface *> chain = typeChain();
330 out << "return new "
331 << chainType->getJavaType(false /* forInitializer */)
332 << "(java.util.Arrays.asList(\n";
333 out.indent(2, [&] {
334 // No need for dimensions when elements are explicitly provided.
335 emitDigestChain(out, "new " + digestType->getJavaType(false /* forInitializer */),
336 chain, [](const auto &e){return e.javaValue();});
337 });
338 out << "));\n";
339 } } } /* javaImpl */
340 );
341 return true;
342}
343
Yifan Hongffa91392017-01-31 13:41:23 -0800344bool Interface::fillGetDescriptorMethod(Method *method) const {
345 if (method->name() != "interfaceDescriptor") {
346 return false;
347 }
Yifan Hongc75fd472017-01-11 12:37:31 -0800348
Yifan Hongffa91392017-01-31 13:41:23 -0800349 method->fillImplementation(
Yifan Hongc75fd472017-01-11 12:37:31 -0800350 HIDL_GET_DESCRIPTOR_TRANSACTION,
Steven Moreland937408a2017-03-20 09:54:18 -0700351 { { IMPL_INTERFACE, [this](auto &out) {
Yifan Hongc75fd472017-01-11 12:37:31 -0800352 out << "_hidl_cb("
353 << fullName()
354 << "::descriptor);\n"
355 << "return ::android::hardware::Void();";
356 } } }, /* cppImpl */
Steven Moreland937408a2017-03-20 09:54:18 -0700357 { { IMPL_INTERFACE, [this](auto &out) {
Yifan Hongc75fd472017-01-11 12:37:31 -0800358 out << "return "
359 << fullJavaName()
360 << ".kInterfaceName;\n";
Yifan Hongffa91392017-01-31 13:41:23 -0800361 } } } /* javaImpl */
Yifan Hongc75fd472017-01-11 12:37:31 -0800362 );
Yifan Hongffa91392017-01-31 13:41:23 -0800363 return true;
Yifan Hongc75fd472017-01-11 12:37:31 -0800364}
Yifan Hong10fe0b52016-10-19 14:20:17 -0700365
Yifan Hongbcffce22017-02-01 15:52:06 -0800366bool Interface::fillGetDebugInfoMethod(Method *method) const {
367 if (method->name() != "getDebugInfo") {
Yifan Hongcd2ae452017-01-31 14:33:40 -0800368 return false;
369 }
370
Yifan Hongdf1ea3f2017-03-02 17:02:10 -0800371 static const std::string sArch =
372 "#if defined(__LP64__)\n"
373 "::android::hidl::base::V1_0::DebugInfo::Architecture::IS_64BIT\n"
374 "#else\n"
375 "::android::hidl::base::V1_0::DebugInfo::Architecture::IS_32BIT\n"
376 "#endif\n";
377
Yifan Hongcd2ae452017-01-31 14:33:40 -0800378 method->fillImplementation(
379 HIDL_GET_REF_INFO_TRANSACTION,
380 {
Steven Moreland937408a2017-03-20 09:54:18 -0700381 {IMPL_INTERFACE,
Yi Kongc8ff4672017-04-30 23:46:56 -0700382 [](auto &out) {
Yifan Hongbcffce22017-02-01 15:52:06 -0800383 // getDebugInfo returns N/A for local objects.
Yifan Hongdf1ea3f2017-03-02 17:02:10 -0800384 out << "_hidl_cb({ -1 /* pid */, 0 /* ptr */, \n"
385 << sArch
386 << "});\n"
Yifan Hongcd2ae452017-01-31 14:33:40 -0800387 << "return ::android::hardware::Void();";
388 }
389 },
390 {IMPL_STUB_IMPL,
Yi Kongc8ff4672017-04-30 23:46:56 -0700391 [](auto &out) {
Yifan Hong2e036c92017-03-07 13:18:12 -0800392 out << "_hidl_cb(";
393 out.block([&] {
394 out << "::android::hardware::details::debuggable()"
395 << "? getpid() : -1 /* pid */,\n"
396 << "::android::hardware::details::debuggable()"
397 << "? reinterpret_cast<uint64_t>(this) : 0 /* ptr */,\n"
398 << sArch << "\n";
399 });
400 out << ");\n"
Yifan Hongcd2ae452017-01-31 14:33:40 -0800401 << "return ::android::hardware::Void();";
402 }
403 }
404 }, /* cppImpl */
Yi Kongc8ff4672017-04-30 23:46:56 -0700405 { { IMPL_INTERFACE, [method](auto &out) {
Yifan Hongcd2ae452017-01-31 14:33:40 -0800406 const Type &refInfo = method->results().front()->type();
407 out << refInfo.getJavaType(false /* forInitializer */) << " info = new "
408 << refInfo.getJavaType(true /* forInitializer */) << "();\n"
Yifan Hongbcffce22017-02-01 15:52:06 -0800409 // TODO(b/34777099): PID for java.
410 << "info.pid = -1;\n"
411 << "info.ptr = 0;\n"
Yifan Hongdf1ea3f2017-03-02 17:02:10 -0800412 << "info.arch = android.hidl.base.V1_0.DebugInfo.Architecture.UNKNOWN;"
Yifan Hongcd2ae452017-01-31 14:33:40 -0800413 << "return info;";
414 } } } /* javaImpl */
415 );
416
417 return true;
418}
419
Andreas Huber37065d62017-02-07 14:36:54 -0800420bool Interface::fillDebugMethod(Method *method) const {
421 if (method->name() != "debug") {
422 return false;
423 }
424
425 method->fillImplementation(
426 HIDL_DEBUG_TRANSACTION,
427 {
Steven Moreland937408a2017-03-20 09:54:18 -0700428 {IMPL_INTERFACE,
Yi Kongc8ff4672017-04-30 23:46:56 -0700429 [](auto &out) {
Andreas Huber37065d62017-02-07 14:36:54 -0800430 out << "(void)fd;\n"
431 << "(void)options;\n"
432 << "return ::android::hardware::Void();";
433 }
434 },
435 }, /* cppImpl */
436 {
437 /* unused, as the debug method is hidden from Java */
438 } /* javaImpl */
439 );
440
441 return true;
442}
443
Yifan Hongffa91392017-01-31 13:41:23 -0800444static std::map<std::string, Method *> gAllReservedMethods;
445
Steven Moreland14ee6742016-10-18 12:58:28 -0700446bool Interface::addMethod(Method *method) {
Yifan Hongc8934042016-11-17 17:10:52 -0800447 if (isIBase()) {
Yifan Hongffa91392017-01-31 13:41:23 -0800448 if (!gAllReservedMethods.emplace(method->name(), method).second) {
449 LOG(ERROR) << "ERROR: hidl-gen encountered duplicated reserved method "
450 << method->name();
451 return false;
452 }
453 // will add it in addAllReservedMethods
Yifan Hongc8934042016-11-17 17:10:52 -0800454 return true;
455 }
456
Yifan Hong10fe0b52016-10-19 14:20:17 -0700457 CHECK(!method->isHidlReserved());
Steven Moreland14ee6742016-10-18 12:58:28 -0700458 if (lookupMethod(method->name()) != nullptr) {
459 LOG(ERROR) << "Redefinition of method " << method->name();
460 return false;
461 }
Yifan Hong10fe0b52016-10-19 14:20:17 -0700462 size_t serial = FIRST_CALL_TRANSACTION;
Steven Moreland14ee6742016-10-18 12:58:28 -0700463
Yifan Hong10fe0b52016-10-19 14:20:17 -0700464 serial += userDefinedMethods().size();
Steven Morelandef1a9fe2016-10-06 17:19:09 -0700465
Timur Iskhakov505316c2017-08-05 03:38:59 +0000466 const Interface* ancestor = superType();
Steven Morelandef1a9fe2016-10-06 17:19:09 -0700467 while (ancestor != nullptr) {
Yifan Hong10fe0b52016-10-19 14:20:17 -0700468 serial += ancestor->userDefinedMethods().size();
Steven Morelandef1a9fe2016-10-06 17:19:09 -0700469 ancestor = ancestor->superType();
470 }
471
Yifan Hong10fe0b52016-10-19 14:20:17 -0700472 CHECK(serial <= LAST_CALL_TRANSACTION) << "More than "
473 << LAST_CALL_TRANSACTION << " methods are not allowed.";
Steven Morelandef1a9fe2016-10-06 17:19:09 -0700474 method->setSerialId(serial);
Yifan Hong10fe0b52016-10-19 14:20:17 -0700475 mUserMethods.push_back(method);
Steven Moreland14ee6742016-10-18 12:58:28 -0700476
477 return true;
Andreas Huberc9410c72016-07-28 12:18:40 -0700478}
479
Yifan Hongffa91392017-01-31 13:41:23 -0800480bool Interface::addAllReservedMethods() {
481 // use a sorted map to insert them in serial ID order.
482 std::map<int32_t, Method *> reservedMethodsById;
483 for (const auto &pair : gAllReservedMethods) {
484 Method *method = pair.second->copySignature();
Steven Moreland424a9482017-02-13 19:20:40 -0800485 bool fillSuccess = fillPingMethod(method)
486 || fillDescriptorChainMethod(method)
Yifan Hongffa91392017-01-31 13:41:23 -0800487 || fillGetDescriptorMethod(method)
Yifan Hong30b5d1f2017-04-03 12:19:25 -0700488 || fillHashChainMethod(method)
Yifan Hongffa91392017-01-31 13:41:23 -0800489 || fillSyspropsChangedMethod(method)
490 || fillLinkToDeathMethod(method)
491 || fillUnlinkToDeathMethod(method)
Yifan Hongcd2ae452017-01-31 14:33:40 -0800492 || fillSetHALInstrumentationMethod(method)
Andreas Huber37065d62017-02-07 14:36:54 -0800493 || fillGetDebugInfoMethod(method)
494 || fillDebugMethod(method);
495
Yifan Hongffa91392017-01-31 13:41:23 -0800496 if (!fillSuccess) {
497 LOG(ERROR) << "ERROR: hidl-gen does not recognize a reserved method "
498 << method->name();
499 return false;
500 }
501 if (!reservedMethodsById.emplace(method->getSerialId(), method).second) {
502 LOG(ERROR) << "ERROR: hidl-gen uses duplicated serial id for "
503 << method->name() << " and "
504 << reservedMethodsById[method->getSerialId()]->name()
505 << ", serialId = " << method->getSerialId();
506 return false;
507 }
508 }
509 for (const auto &pair : reservedMethodsById) {
510 this->mReservedMethods.push_back(pair.second);
511 }
512 return true;
513}
Yifan Hong10fe0b52016-10-19 14:20:17 -0700514
Timur Iskhakov505316c2017-08-05 03:38:59 +0000515const Interface* Interface::superType() const {
516 return isIBase() ? nullptr : mSuperType;
Andreas Huberc9410c72016-07-28 12:18:40 -0700517}
518
Yifan Hong10fe0b52016-10-19 14:20:17 -0700519std::vector<const Interface *> Interface::typeChain() const {
520 std::vector<const Interface *> v;
521 const Interface *iface = this;
522 while (iface != nullptr) {
523 v.push_back(iface);
Timur Iskhakov505316c2017-08-05 03:38:59 +0000524 iface = iface->superType();
Yifan Hong10fe0b52016-10-19 14:20:17 -0700525 }
526 return v;
527}
528
Yifan Hongfe95aa22016-10-19 17:26:45 -0700529std::vector<const Interface *> Interface::superTypeChain() const {
Timur Iskhakov505316c2017-08-05 03:38:59 +0000530 return isIBase() ? std::vector<const Interface*>() : superType()->typeChain();
Yifan Hongfe95aa22016-10-19 17:26:45 -0700531}
532
Martijn Coenenb40ef022017-01-02 15:21:46 +0100533bool Interface::isElidableType() const {
534 return true;
535}
536
Andreas Hubera2723d22016-07-29 15:36:07 -0700537bool Interface::isInterface() const {
538 return true;
539}
540
Andreas Huber295ad302016-08-16 11:35:00 -0700541bool Interface::isBinder() const {
542 return true;
543}
544
Yifan Hong10fe0b52016-10-19 14:20:17 -0700545const std::vector<Method *> &Interface::userDefinedMethods() const {
546 return mUserMethods;
547}
548
549const std::vector<Method *> &Interface::hidlReservedMethods() const {
550 return mReservedMethods;
551}
552
553std::vector<Method *> Interface::methods() const {
554 std::vector<Method *> v(mUserMethods);
555 v.insert(v.end(), mReservedMethods.begin(), mReservedMethods.end());
556 return v;
557}
558
559std::vector<InterfaceAndMethod> Interface::allMethodsFromRoot() const {
560 std::vector<InterfaceAndMethod> v;
561 std::vector<const Interface *> chain = typeChain();
562 for (auto it = chain.rbegin(); it != chain.rend(); ++it) {
563 const Interface *iface = *it;
564 for (Method *userMethod : iface->userDefinedMethods()) {
565 v.push_back(InterfaceAndMethod(iface, userMethod));
566 }
567 }
568 for (Method *reservedMethod : hidlReservedMethods()) {
Yifan Hongc8934042016-11-17 17:10:52 -0800569 v.push_back(InterfaceAndMethod(
570 *chain.rbegin(), // IBase
571 reservedMethod));
Yifan Hong10fe0b52016-10-19 14:20:17 -0700572 }
573 return v;
Andreas Huber881227d2016-08-02 14:20:21 -0700574}
575
Steven Moreland14ee6742016-10-18 12:58:28 -0700576Method *Interface::lookupMethod(std::string name) const {
Yifan Hong10fe0b52016-10-19 14:20:17 -0700577 for (const auto &tuple : allMethodsFromRoot()) {
578 Method *method = tuple.method();
579 if (method->name() == name) {
580 return method;
Steven Moreland14ee6742016-10-18 12:58:28 -0700581 }
Steven Moreland14ee6742016-10-18 12:58:28 -0700582 }
583
584 return nullptr;
585}
586
Steven Moreland40786312016-08-16 10:29:40 -0700587std::string Interface::getBaseName() const {
Jayant Chowdhary3f32c1f2016-09-15 16:53:56 -0700588 return fqName().getInterfaceBaseName();
Steven Moreland40786312016-08-16 10:29:40 -0700589}
590
Yifan Hongeefe4f22017-01-04 15:32:42 -0800591std::string Interface::getProxyName() const {
592 return fqName().getInterfaceProxyName();
593}
594
595std::string Interface::getStubName() const {
596 return fqName().getInterfaceStubName();
597}
598
599std::string Interface::getHwName() const {
600 return fqName().getInterfaceHwName();
601}
602
603std::string Interface::getPassthroughName() const {
604 return fqName().getInterfacePassthroughName();
605}
606
Yifan Hong51a65092017-01-04 15:41:44 -0800607FQName Interface::getProxyFqName() const {
Yifan Hongeefe4f22017-01-04 15:32:42 -0800608 return fqName().getInterfaceProxyFqName();
Yifan Hong158655a2016-11-08 12:34:07 -0800609}
610
Yifan Hong51a65092017-01-04 15:41:44 -0800611FQName Interface::getStubFqName() const {
Yifan Hongeefe4f22017-01-04 15:32:42 -0800612 return fqName().getInterfaceStubFqName();
Yifan Hong158655a2016-11-08 12:34:07 -0800613}
614
Yifan Hong51a65092017-01-04 15:41:44 -0800615FQName Interface::getPassthroughFqName() const {
Yifan Hongeefe4f22017-01-04 15:32:42 -0800616 return fqName().getInterfacePassthroughFqName();
Yifan Hong158655a2016-11-08 12:34:07 -0800617}
618
Steven Moreland979e0992016-09-07 09:18:08 -0700619std::string Interface::getCppType(StorageMode mode,
Steven Moreland979e0992016-09-07 09:18:08 -0700620 bool specifyNamespaces) const {
Steven Moreland979e0992016-09-07 09:18:08 -0700621 const std::string base =
622 std::string(specifyNamespaces ? "::android::" : "")
623 + "sp<"
Steven Morelande30ee9b2017-05-09 13:31:01 -0700624 + fullName()
Steven Moreland979e0992016-09-07 09:18:08 -0700625 + ">";
Andreas Huber881227d2016-08-02 14:20:21 -0700626
627 switch (mode) {
628 case StorageMode_Stack:
629 case StorageMode_Result:
630 return base;
631
632 case StorageMode_Argument:
633 return "const " + base + "&";
634 }
635}
636
Yifan Hong4ed13472016-11-02 10:44:11 -0700637std::string Interface::getJavaType(bool /* forInitializer */) const {
Andreas Huber2831d512016-08-15 09:33:47 -0700638 return fullJavaName();
639}
640
Zhuoyao Zhanga588b232016-11-10 14:37:35 -0800641std::string Interface::getVtsType() const {
642 if (StringHelper::EndsWith(localName(), "Callback")) {
643 return "TYPE_HIDL_CALLBACK";
644 } else {
645 return "TYPE_HIDL_INTERFACE";
646 }
647}
648
Andreas Huber881227d2016-08-02 14:20:21 -0700649void Interface::emitReaderWriter(
650 Formatter &out,
651 const std::string &name,
652 const std::string &parcelObj,
653 bool parcelObjIsPointer,
654 bool isReader,
655 ErrorMode mode) const {
656 const std::string parcelObjDeref =
657 parcelObj + (parcelObjIsPointer ? "->" : ".");
658
659 if (isReader) {
Andreas Hubere7ff2282016-08-16 13:50:03 -0700660 out << "{\n";
661 out.indent();
662
Iliyan Malchev549e2592016-08-10 08:59:12 -0700663 const std::string binderName = "_hidl_" + name + "_binder";
Andreas Huber881227d2016-08-02 14:20:21 -0700664
Andreas Huber8a82ff72016-08-04 10:29:39 -0700665 out << "::android::sp<::android::hardware::IBinder> "
Andreas Huber881227d2016-08-02 14:20:21 -0700666 << binderName << ";\n";
667
Iliyan Malchev549e2592016-08-10 08:59:12 -0700668 out << "_hidl_err = ";
Andreas Huber881227d2016-08-02 14:20:21 -0700669 out << parcelObjDeref
670 << "readNullableStrongBinder(&"
671 << binderName
672 << ");\n";
673
674 handleError(out, mode);
675
676 out << name
677 << " = "
Martijn Coenena63e0ad2016-12-07 17:29:00 +0100678 << "::android::hardware::fromBinder<"
679 << fqName().cppName()
680 << ","
Yifan Hong51a65092017-01-04 15:41:44 -0800681 << getProxyFqName().cppName()
Martijn Coenena63e0ad2016-12-07 17:29:00 +0100682 << ","
Yifan Hong51a65092017-01-04 15:41:44 -0800683 << getStubFqName().cppName()
Martijn Coenena63e0ad2016-12-07 17:29:00 +0100684 << ">("
Andreas Huber881227d2016-08-02 14:20:21 -0700685 << binderName
686 << ");\n";
Andreas Hubere7ff2282016-08-16 13:50:03 -0700687
688 out.unindent();
689 out << "}\n\n";
Andreas Huber881227d2016-08-02 14:20:21 -0700690 } else {
Martijn Coenene1638232016-10-26 12:51:34 +0200691 out << "if (" << name << " == nullptr) {\n";
692 out.indent();
693 out << "_hidl_err = ";
694 out << parcelObjDeref
695 << "writeStrongBinder(nullptr);\n";
696 out.unindent();
697 out << "} else {\n";
698 out.indent();
Yifan Hong158655a2016-11-08 12:34:07 -0800699 out << "::android::sp<::android::hardware::IBinder> _hidl_binder = "
700 << "::android::hardware::toBinder<\n";
Yifan Hong33223ca2016-12-13 15:07:35 -0800701 out.indent(2, [&] {
Martijn Coenena63e0ad2016-12-07 17:29:00 +0100702 out << fqName().cppName()
Yifan Hong158655a2016-11-08 12:34:07 -0800703 << ">("
704 << name
705 << ");\n";
706 });
707 out << "if (_hidl_binder.get() != nullptr) {\n";
Yifan Hong33223ca2016-12-13 15:07:35 -0800708 out.indent([&] {
Yifan Hong158655a2016-11-08 12:34:07 -0800709 out << "_hidl_err = "
710 << parcelObjDeref
711 << "writeStrongBinder(_hidl_binder);\n";
712 });
713 out << "} else {\n";
Yifan Hong33223ca2016-12-13 15:07:35 -0800714 out.indent([&] {
Yifan Hong158655a2016-11-08 12:34:07 -0800715 out << "_hidl_err = ::android::UNKNOWN_ERROR;\n";
716 });
717 out << "}\n";
Martijn Coenene1638232016-10-26 12:51:34 +0200718 out.unindent();
719 out << "}\n";
Steven Moreland40786312016-08-16 10:29:40 -0700720
Andreas Huber881227d2016-08-02 14:20:21 -0700721 handleError(out, mode);
722 }
723}
724
Yifan Hongf5cc2f72017-01-04 18:02:34 -0800725status_t Interface::emitGlobalTypeDeclarations(Formatter &out) const {
726 status_t status = Scope::emitGlobalTypeDeclarations(out);
727 if (status != OK) {
728 return status;
729 }
Steven Moreland3d98bc42017-06-23 21:36:41 +0000730 out << "std::string toString("
Yifan Hongf5cc2f72017-01-04 18:02:34 -0800731 << getCppArgumentType()
Steven Moreland3d98bc42017-06-23 21:36:41 +0000732 << ");\n";
Yifan Hongf5cc2f72017-01-04 18:02:34 -0800733 return OK;
734}
735
736
737status_t Interface::emitTypeDefinitions(
738 Formatter &out, const std::string prefix) const {
739 std::string space = prefix.empty() ? "" : (prefix + "::");
740 status_t err = Scope::emitTypeDefinitions(out, space + localName());
741 if (err != OK) {
742 return err;
743 }
744
Steven Moreland3d98bc42017-06-23 21:36:41 +0000745 out << "std::string toString("
746 << getCppArgumentType()
747 << " o) ";
748
749 out.block([&] {
750 out << "std::string os = \"[class or subclass of \";\n"
751 << "os += " << fullName() << "::descriptor;\n"
752 << "os += \"]\";\n"
753 << "os += o->isRemote() ? \"@remote\" : \"@local\";\n"
754 << "return os;\n";
755 }).endl().endl();
756
Yifan Hongf5cc2f72017-01-04 18:02:34 -0800757 return OK;
758}
759
Andreas Huber2831d512016-08-15 09:33:47 -0700760void Interface::emitJavaReaderWriter(
761 Formatter &out,
762 const std::string &parcelObj,
763 const std::string &argName,
764 bool isReader) const {
765 if (isReader) {
766 out << fullJavaName()
767 << ".asInterface("
768 << parcelObj
769 << ".readStrongBinder());\n";
770 } else {
771 out << parcelObj
772 << ".writeStrongBinder("
773 << argName
774 << " == null ? null : "
775 << argName
776 << ".asBinder());\n";
777 }
778}
779
Zhuoyao Zhang864c7712016-08-16 15:35:28 -0700780status_t Interface::emitVtsAttributeDeclaration(Formatter &out) const {
781 for (const auto &type : getSubTypes()) {
Zhuoyao Zhangc5ea9f52016-10-06 15:05:39 -0700782 // Skip for TypeDef as it is just an alias of a defined type.
783 if (type->isTypeDef()) {
784 continue;
785 }
Zhuoyao Zhang864c7712016-08-16 15:35:28 -0700786 out << "attribute: {\n";
787 out.indent();
788 status_t status = type->emitVtsTypeDeclarations(out);
789 if (status != OK) {
790 return status;
791 }
792 out.unindent();
793 out << "}\n\n";
794 }
795 return OK;
796}
797
798status_t Interface::emitVtsMethodDeclaration(Formatter &out) const {
Yifan Hong10fe0b52016-10-19 14:20:17 -0700799 for (const auto &method : methods()) {
Steven Morelandcea24782016-11-07 11:40:48 -0800800 if (method->isHidlReserved()) {
801 continue;
802 }
803
Zhuoyao Zhang864c7712016-08-16 15:35:28 -0700804 out << "api: {\n";
805 out.indent();
806 out << "name: \"" << method->name() << "\"\n";
807 // Generate declaration for each return value.
808 for (const auto &result : method->results()) {
809 out << "return_type_hidl: {\n";
810 out.indent();
811 status_t status = result->type().emitVtsAttributeType(out);
812 if (status != OK) {
813 return status;
814 }
815 out.unindent();
816 out << "}\n";
817 }
818 // Generate declaration for each input argument
819 for (const auto &arg : method->args()) {
820 out << "arg: {\n";
821 out.indent();
822 status_t status = arg->type().emitVtsAttributeType(out);
823 if (status != OK) {
824 return status;
825 }
826 out.unindent();
827 out << "}\n";
828 }
829 // Generate declaration for each annotation.
Steven Morelandd537ab02016-09-12 10:32:01 -0700830 for (const auto &annotation : method->annotations()) {
Zhuoyao Zhang864c7712016-08-16 15:35:28 -0700831 out << "callflow: {\n";
832 out.indent();
Steven Morelandd537ab02016-09-12 10:32:01 -0700833 std::string name = annotation->name();
Zhuoyao Zhang864c7712016-08-16 15:35:28 -0700834 if (name == "entry") {
835 out << "entry: true\n";
836 } else if (name == "exit") {
837 out << "exit: true\n";
838 } else if (name == "callflow") {
Steven Morelandd537ab02016-09-12 10:32:01 -0700839 const AnnotationParam *param =
840 annotation->getParam("next");
841 if (param != nullptr) {
842 for (auto value : *param->getValues()) {
843 out << "next: " << value << "\n";
844 }
Zhuoyao Zhang864c7712016-08-16 15:35:28 -0700845 }
846 } else {
Keun Soo Yima5a57e92017-02-04 11:32:06 -0800847 std::cerr << "Unrecognized annotation '"
Zhuoyao Zhang864c7712016-08-16 15:35:28 -0700848 << name << "' for method: " << method->name()
Keun Soo Yima5a57e92017-02-04 11:32:06 -0800849 << ". A VTS annotation should be one of: "
850 << "entry, exit, callflow. \n";
Zhuoyao Zhang864c7712016-08-16 15:35:28 -0700851 }
852 out.unindent();
853 out << "}\n";
854 }
855 out.unindent();
856 out << "}\n\n";
857 }
858 return OK;
859}
860
861status_t Interface::emitVtsAttributeType(Formatter &out) const {
Zhuoyao Zhanga588b232016-11-10 14:37:35 -0800862 out << "type: " << getVtsType() << "\n"
Zhuoyao Zhang5158db42016-08-10 10:25:20 -0700863 << "predefined_type: \""
Zhuoyao Zhangc4e10602017-01-27 16:48:05 -0800864 << fullName()
865 << "\"\n";
Zhuoyao Zhang5158db42016-08-10 10:25:20 -0700866 return OK;
867}
868
Steven Moreland69e7c702016-09-09 11:16:32 -0700869bool Interface::hasOnewayMethods() const {
Yifan Hong10fe0b52016-10-19 14:20:17 -0700870 for (auto const &method : methods()) {
Steven Moreland69e7c702016-09-09 11:16:32 -0700871 if (method->isOneway()) {
872 return true;
873 }
874 }
875
876 const Interface* superClass = superType();
877
878 if (superClass != nullptr) {
879 return superClass->hasOnewayMethods();
880 }
881
882 return false;
883}
884
Andreas Huber70a59e12016-08-16 12:57:01 -0700885bool Interface::isJavaCompatible() const {
Andreas Huberea081b32016-08-17 15:57:47 -0700886 if (mIsJavaCompatibleInProgress) {
887 // We're currently trying to determine if this Interface is
888 // java-compatible and something is referencing this interface through
889 // one of its methods. Assume we'll ultimately succeed, if we were wrong
890 // the original invocation of Interface::isJavaCompatible() will then
891 // return the correct "false" result.
892 return true;
893 }
894
Timur Iskhakov505316c2017-08-05 03:38:59 +0000895 if (superType() != nullptr && !superType()->isJavaCompatible()) {
Andreas Huber0fa9e392016-08-31 09:05:44 -0700896 mIsJavaCompatibleInProgress = false;
897 return false;
898 }
899
Andreas Huberea081b32016-08-17 15:57:47 -0700900 mIsJavaCompatibleInProgress = true;
901
Andreas Huber70a59e12016-08-16 12:57:01 -0700902 if (!Scope::isJavaCompatible()) {
Andreas Huberea081b32016-08-17 15:57:47 -0700903 mIsJavaCompatibleInProgress = false;
Andreas Huber70a59e12016-08-16 12:57:01 -0700904 return false;
905 }
906
Yifan Hong10fe0b52016-10-19 14:20:17 -0700907 for (const auto &method : methods()) {
Andreas Huber70a59e12016-08-16 12:57:01 -0700908 if (!method->isJavaCompatible()) {
Andreas Huberea081b32016-08-17 15:57:47 -0700909 mIsJavaCompatibleInProgress = false;
Andreas Huber70a59e12016-08-16 12:57:01 -0700910 return false;
911 }
912 }
913
Andreas Huberea081b32016-08-17 15:57:47 -0700914 mIsJavaCompatibleInProgress = false;
915
Andreas Huber70a59e12016-08-16 12:57:01 -0700916 return true;
917}
918
Andreas Huberc9410c72016-07-28 12:18:40 -0700919} // namespace android
920