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 17 #include "tests/test_data.h" 18 19 namespace android { 20 namespace aidl { 21 namespace test_data { 22 namespace string_constants { 23 24 const char kCanonicalName[] = "android.os.IStringConstants"; 25 const char kInterfaceDefinition[] = R"( 26 package android.os; 27 28 interface IStringConstants { 29 const String EXAMPLE_CONSTANT = "foo"; 30 } 31 )"; 32 33 const char kJavaOutputPath[] = "some/path/to/output.java"; 34 const char kExpectedJavaOutput[] = 35 R"(/* 36 * This file is auto-generated. DO NOT MODIFY. 37 * Original file: android/os/IStringConstants.aidl 38 */ 39 package android.os; 40 public interface IStringConstants extends android.os.IInterface 41 { 42 /** Local-side IPC implementation stub class. */ 43 public static abstract class Stub extends android.os.Binder implements android.os.IStringConstants 44 { 45 private static final java.lang.String DESCRIPTOR = "android.os.IStringConstants"; 46 /** Construct the stub at attach it to the interface. */ 47 public Stub() 48 { 49 this.attachInterface(this, DESCRIPTOR); 50 } 51 /** 52 * Cast an IBinder object into an android.os.IStringConstants interface, 53 * generating a proxy if needed. 54 */ 55 public static android.os.IStringConstants asInterface(android.os.IBinder obj) 56 { 57 if ((obj==null)) { 58 return null; 59 } 60 android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR); 61 if (((iin!=null)&&(iin instanceof android.os.IStringConstants))) { 62 return ((android.os.IStringConstants)iin); 63 } 64 return new android.os.IStringConstants.Stub.Proxy(obj); 65 } 66 @Override public android.os.IBinder asBinder() 67 { 68 return this; 69 } 70 @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException 71 { 72 switch (code) 73 { 74 case INTERFACE_TRANSACTION: 75 { 76 reply.writeString(DESCRIPTOR); 77 return true; 78 } 79 } 80 return super.onTransact(code, data, reply, flags); 81 } 82 private static class Proxy implements android.os.IStringConstants 83 { 84 private android.os.IBinder mRemote; 85 Proxy(android.os.IBinder remote) 86 { 87 mRemote = remote; 88 } 89 @Override public android.os.IBinder asBinder() 90 { 91 return mRemote; 92 } 93 public java.lang.String getInterfaceDescriptor() 94 { 95 return DESCRIPTOR; 96 } 97 } 98 } 99 public static final String EXAMPLE_CONSTANT = "foo"; 100 } 101 )"; 102 103 const char kCppOutputPath[] = "some/path/to/output.cpp"; 104 const char kGenHeaderDir[] = "output"; 105 const char kGenInterfaceHeaderPath[] = "output/android/os/IStringConstants.h"; 106 const char kExpectedIHeaderOutput[] = 107 R"(#ifndef AIDL_GENERATED_ANDROID_OS_I_STRING_CONSTANTS_H_ 108 #define AIDL_GENERATED_ANDROID_OS_I_STRING_CONSTANTS_H_ 109 110 #include <binder/IBinder.h> 111 #include <binder/IInterface.h> 112 #include <binder/Status.h> 113 #include <utils/String16.h> 114 #include <utils/StrongPointer.h> 115 116 namespace android { 117 118 namespace os { 119 120 class IStringConstants : public ::android::IInterface { 121 public: 122 DECLARE_META_INTERFACE(StringConstants) 123 static const ::android::String16& EXAMPLE_CONSTANT(); 124 }; // class IStringConstants 125 126 } // namespace os 127 128 } // namespace android 129 130 #endif // AIDL_GENERATED_ANDROID_OS_I_STRING_CONSTANTS_H_ 131 )"; 132 133 const char kExpectedCppOutput[] = 134 R"(#include <android/os/IStringConstants.h> 135 #include <android/os/BpStringConstants.h> 136 137 namespace android { 138 139 namespace os { 140 141 IMPLEMENT_META_INTERFACE(StringConstants, "android.os.IStringConstants") 142 143 const ::android::String16& IStringConstants::EXAMPLE_CONSTANT() { 144 static const ::android::String16 value("foo"); 145 return value; 146 } 147 148 } // namespace os 149 150 } // namespace android 151 #include <android/os/BpStringConstants.h> 152 #include <binder/Parcel.h> 153 154 namespace android { 155 156 namespace os { 157 158 BpStringConstants::BpStringConstants(const ::android::sp<::android::IBinder>& _aidl_impl) 159 : BpInterface<IStringConstants>(_aidl_impl){ 160 } 161 162 } // namespace os 163 164 } // namespace android 165 #include <android/os/BnStringConstants.h> 166 #include <binder/Parcel.h> 167 168 namespace android { 169 170 namespace os { 171 172 ::android::status_t BnStringConstants::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) { 173 ::android::status_t _aidl_ret_status = ::android::OK; 174 switch (_aidl_code) { 175 default: 176 { 177 _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags); 178 } 179 break; 180 } 181 if (_aidl_ret_status == ::android::UNEXPECTED_NULL) { 182 _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply); 183 } 184 return _aidl_ret_status; 185 } 186 187 } // namespace os 188 189 } // namespace android 190 )"; 191 192 } // namespace string_constants 193 } // namespace test_data 194 } // namespace aidl 195 } // namespace android 196