blob: 952064c7f5c68f4a3ab2fadd419eec379a1e3a8a [file] [log] [blame]
Martijn Coenen115d4282016-12-19 05:14:04 +01001/*
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
17#include "DeathRecipientType.h"
18
19#include <hidl-util/Formatter.h>
20#include <android-base/logging.h>
21
22namespace android {
23
24DeathRecipientType::DeathRecipientType() {}
25
26void DeathRecipientType::addNamedTypesToSet(std::set<const FQName> &) const {
27 // do nothing
28}
29
30std::string DeathRecipientType::getCppType(StorageMode mode,
31 bool specifyNamespaces) const {
32 const std::string base =
33 std::string(specifyNamespaces ? "::android::" : "")
34 + "sp<"
35 + (specifyNamespaces ? "::android::hardware::" : "")
36 + "hidl_death_recipient>";
37
38 switch (mode) {
39 case StorageMode_Stack:
40 return base;
41
42 case StorageMode_Argument:
43 return "const " + base + "&";
44
45 case StorageMode_Result:
46 return "const " + base + "*";
47 }
48}
49
50std::string DeathRecipientType::getJavaType(bool /* forInitializer */) const {
51 return "android.os.IBinder.DeathRecipient";
52}
53
54std::string DeathRecipientType::getVtsType() const {
55 return "TYPE_DEATH_RECIPIENT";
56}
57
58void DeathRecipientType::emitReaderWriter(
59 Formatter& out,
60 const std::string& /* name */,
61 const std::string& /* parcelObj */,
62 bool /* parcelObjIsPointer */,
63 bool /* isReader */,
64 ErrorMode /* mode */) const {
65 out << "LOG_ALWAYS_FATAL(\"DeathRecipient is only supported in passthrough mode\");\n";
66}
67
68bool DeathRecipientType::needsEmbeddedReadWrite() const {
69 return false;
70}
71
72bool DeathRecipientType::resultNeedsDeref() const {
73 return true;
74}
75
76bool DeathRecipientType::isJavaCompatible() const {
77 return true;
78}
79
80void DeathRecipientType::getAlignmentAndSize(size_t *align, size_t *size) const {
81 *align = *size = 0; // this object should only be used in passthrough mode
82}
83
84status_t DeathRecipientType::emitVtsTypeDeclarations(Formatter &out) const {
85 out << "type: " << getVtsType() << "\n";
86 return OK;
87}
88
89} // namespace android
90