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 java.lang.String descriptor = DESCRIPTOR; 73 switch (code) 74 { 75 case INTERFACE_TRANSACTION: 76 { 77 reply.writeString(descriptor); 78 return true; 79 } 80 default: 81 { 82 return super.onTransact(code, data, reply, flags); 83 } 84 } 85 } 86 private static class Proxy implements android.os.IStringConstants 87 { 88 private android.os.IBinder mRemote; 89 Proxy(android.os.IBinder remote) 90 { 91 mRemote = remote; 92 } 93 @Override public android.os.IBinder asBinder() 94 { 95 return mRemote; 96 } 97 public java.lang.String getInterfaceDescriptor() 98 { 99 return DESCRIPTOR; 100 } 101 } 102 } 103 public static final String EXAMPLE_CONSTANT = "foo"; 104 } 105 )"; 106 107 const char kCppOutputPath[] = "some/path/to/output.cpp"; 108 const char kGenHeaderDir[] = "output"; 109 const char kGenInterfaceHeaderPath[] = "output/android/os/IStringConstants.h"; 110 const char kExpectedIHeaderOutput[] = 111 R"(#ifndef AIDL_GENERATED_ANDROID_OS_I_STRING_CONSTANTS_H_ 112 #define AIDL_GENERATED_ANDROID_OS_I_STRING_CONSTANTS_H_ 113 114 #include <binder/IBinder.h> 115 #include <binder/IInterface.h> 116 #include <binder/Status.h> 117 #include <utils/String16.h> 118 #include <utils/StrongPointer.h> 119 120 namespace android { 121 122 namespace os { 123 124 class IStringConstants : public ::android::IInterface { 125 public: 126 DECLARE_META_INTERFACE(StringConstants) 127 static const ::android::String16& EXAMPLE_CONSTANT(); 128 }; // class IStringConstants 129 130 } // namespace os 131 132 } // namespace android 133 134 #endif // AIDL_GENERATED_ANDROID_OS_I_STRING_CONSTANTS_H_ 135 )"; 136 137 const char kExpectedCppOutput[] = 138 R"(#include <android/os/IStringConstants.h> 139 #include <android/os/BpStringConstants.h> 140 141 namespace android { 142 143 namespace os { 144 145 IMPLEMENT_META_INTERFACE(StringConstants, "android.os.IStringConstants") 146 147 const ::android::String16& IStringConstants::EXAMPLE_CONSTANT() { 148 static const ::android::String16 value("foo"); 149 return value; 150 } 151 152 } // namespace os 153 154 } // namespace android 155 #include <android/os/BpStringConstants.h> 156 #include <binder/Parcel.h> 157 158 namespace android { 159 160 namespace os { 161 162 BpStringConstants::BpStringConstants(const ::android::sp<::android::IBinder>& _aidl_impl) 163 : BpInterface<IStringConstants>(_aidl_impl){ 164 } 165 166 } // namespace os 167 168 } // namespace android 169 #include <android/os/BnStringConstants.h> 170 #include <binder/Parcel.h> 171 172 namespace android { 173 174 namespace os { 175 176 ::android::status_t BnStringConstants::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) { 177 ::android::status_t _aidl_ret_status = ::android::OK; 178 switch (_aidl_code) { 179 default: 180 { 181 _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags); 182 } 183 break; 184 } 185 if (_aidl_ret_status == ::android::UNEXPECTED_NULL) { 186 _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply); 187 } 188 return _aidl_ret_status; 189 } 190 191 } // namespace os 192 193 } // namespace android 194 )"; 195 196 } // namespace string_constants 197 } // namespace test_data 198 } // namespace aidl 199 } // namespace android 200