1 /* 2 * Copyright (C) 2015 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 package android.aidl.tests; 18 19 import android.aidl.tests.INamedCallback; 20 import android.aidl.tests.SimpleParcelable; 21 import android.aidl.tests.StructuredParcelable; 22 import android.os.PersistableBundle; 23 24 interface ITestService { 25 // Test that constants are accessible 26 const int TEST_CONSTANT = 42; 27 const int TEST_CONSTANT2 = -42; 28 const int TEST_CONSTANT3 = +42; 29 const int TEST_CONSTANT4 = +4; 30 const int TEST_CONSTANT5 = -4; 31 const int TEST_CONSTANT6 = -0; 32 const int TEST_CONSTANT7 = +0; 33 const int TEST_CONSTANT8 = 0; 34 const int TEST_CONSTANT9 = 0x56; 35 const int TEST_CONSTANT10 = 0xa5; 36 const int TEST_CONSTANT11 = 0xFA; 37 const int TEST_CONSTANT12 = 0xffffffff; 38 39 const String STRING_TEST_CONSTANT = "foo"; 40 const String STRING_TEST_CONSTANT2 = "bar"; 41 42 const @utf8InCpp String STRING_TEST_CONSTANT_UTF8 = "baz"; 43 44 // Test that primitives work as parameters and return types. RepeatBoolean(boolean token)45 boolean RepeatBoolean(boolean token); RepeatByte(byte token)46 byte RepeatByte(byte token); RepeatChar(char token)47 char RepeatChar(char token); RepeatInt(int token)48 int RepeatInt(int token); RepeatLong(long token)49 long RepeatLong(long token); RepeatFloat(float token)50 float RepeatFloat(float token); RepeatDouble(double token)51 double RepeatDouble(double token); RepeatString(String token)52 String RepeatString(String token); RepeatMap(in Map token)53 Map RepeatMap(in Map token); 54 RepeatSimpleParcelable(in SimpleParcelable input, out SimpleParcelable repeat)55 SimpleParcelable RepeatSimpleParcelable(in SimpleParcelable input, 56 out SimpleParcelable repeat); RepeatPersistableBundle(in PersistableBundle input)57 PersistableBundle RepeatPersistableBundle(in PersistableBundle input); 58 59 // Test that arrays work as parameters and return types. ReverseBoolean(in boolean[] input, out boolean[] repeated)60 boolean[] ReverseBoolean(in boolean[] input, out boolean[] repeated); ReverseByte(in byte[] input, out byte[] repeated)61 byte[] ReverseByte (in byte[] input, out byte[] repeated); ReverseChar(in char[] input, out char[] repeated)62 char[] ReverseChar (in char[] input, out char[] repeated); ReverseInt(in int[] input, out int[] repeated)63 int[] ReverseInt (in int[] input, out int[] repeated); ReverseLong(in long[] input, out long[] repeated)64 long[] ReverseLong (in long[] input, out long[] repeated); ReverseFloat(in float[] input, out float[] repeated)65 float[] ReverseFloat (in float[] input, out float[] repeated); ReverseDouble(in double[] input, out double[] repeated)66 double[] ReverseDouble (in double[] input, out double[] repeated); ReverseString(in String[] input, out String[] repeated)67 String[] ReverseString (in String[] input, out String[] repeated); 68 ReverseSimpleParcelables(in SimpleParcelable[] input, out SimpleParcelable[] repeated)69 SimpleParcelable[] ReverseSimpleParcelables(in SimpleParcelable[] input, 70 out SimpleParcelable[] repeated); ReversePersistableBundles( in PersistableBundle[] input, out PersistableBundle[] repeated)71 PersistableBundle[] ReversePersistableBundles( 72 in PersistableBundle[] input, out PersistableBundle[] repeated); 73 74 // Test that clients can send and receive Binders. GetOtherTestService(String name)75 INamedCallback GetOtherTestService(String name); VerifyName(INamedCallback service, String name)76 boolean VerifyName(INamedCallback service, String name); 77 78 // Test that List<T> types work correctly. ReverseStringList(in List<String> input, out List<String> repeated)79 List<String> ReverseStringList(in List<String> input, 80 out List<String> repeated); ReverseNamedCallbackList(in List<IBinder> input, out List<IBinder> repeated)81 List<IBinder> ReverseNamedCallbackList(in List<IBinder> input, 82 out List<IBinder> repeated); 83 RepeatFileDescriptor(in FileDescriptor read)84 FileDescriptor RepeatFileDescriptor(in FileDescriptor read); ReverseFileDescriptorArray(in FileDescriptor[] input, out FileDescriptor[] repeated)85 FileDescriptor[] ReverseFileDescriptorArray(in FileDescriptor[] input, 86 out FileDescriptor[] repeated); 87 RepeatParcelFileDescriptor(in ParcelFileDescriptor read)88 ParcelFileDescriptor RepeatParcelFileDescriptor(in ParcelFileDescriptor read); ReverseParcelFileDescriptorArray(in ParcelFileDescriptor[] input, out ParcelFileDescriptor[] repeated)89 ParcelFileDescriptor[] ReverseParcelFileDescriptorArray(in ParcelFileDescriptor[] input, 90 out ParcelFileDescriptor[] repeated); 91 92 // Test that service specific exceptions work correctly. ThrowServiceException(int code)93 void ThrowServiceException(int code); 94 95 // Test nullability RepeatNullableIntArray(in @ullable int[] input)96 @nullable int[] RepeatNullableIntArray(in @nullable int[] input); RepeatNullableString(in @ullable String input)97 @nullable String RepeatNullableString(in @nullable String input); RepeatNullableStringList(in @ullable List<String> input)98 @nullable List<String> RepeatNullableStringList(in @nullable List<String> input); RepeatNullableParcelable(in @ullable SimpleParcelable input)99 @nullable SimpleParcelable RepeatNullableParcelable(in @nullable SimpleParcelable input); 100 TakesAnIBinder(in IBinder input)101 void TakesAnIBinder(in IBinder input); TakesAnIBinderList(in List<IBinder> input)102 void TakesAnIBinderList(in List<IBinder> input); TakesANullableIBinder(in @ullable IBinder input)103 void TakesANullableIBinder(in @nullable IBinder input); TakesANullableIBinderList(in @ullable List<IBinder> input)104 void TakesANullableIBinderList(in @nullable List<IBinder> input); 105 106 // Test utf8 decoding from utf16 wire format RepeatUtf8CppString(@tf8InCpp String token)107 @utf8InCpp String RepeatUtf8CppString(@utf8InCpp String token); RepeatNullableUtf8CppString( @ullable @tf8InCpp String token)108 @nullable @utf8InCpp String RepeatNullableUtf8CppString( 109 @nullable @utf8InCpp String token); 110 ReverseUtf8CppString(in @tf8InCpp String[] input, out @utf8InCpp String[] repeated)111 @utf8InCpp String[] ReverseUtf8CppString (in @utf8InCpp String[] input, 112 out @utf8InCpp String[] repeated); 113 ReverseNullableUtf8CppString( in @ullable @tf8InCpp String[] input, out @nullable @utf8InCpp String[] repeated)114 @nullable @utf8InCpp String[] ReverseNullableUtf8CppString ( 115 in @nullable @utf8InCpp String[] input, 116 out @nullable @utf8InCpp String[] repeated); 117 ReverseUtf8CppStringList( in @ullable @tf8InCpp List<String> input, out @nullable @utf8InCpp List<String> repeated)118 @nullable @utf8InCpp List<String> ReverseUtf8CppStringList( 119 in @nullable @utf8InCpp List<String> input, 120 out @nullable @utf8InCpp List<String> repeated); 121 GetCallback(boolean return_null)122 @nullable INamedCallback GetCallback(boolean return_null); 123 124 // Since this paracelable has clearly defined default values, it would be 125 // inefficient to use an IPC to fill it out in practice. FillOutStructuredParcelable(inout StructuredParcelable parcel)126 void FillOutStructuredParcelable(inout StructuredParcelable parcel); 127 128 // This is to emulate a method that is added after the service is implemented. 129 // So the client cannot assume that call to this method will be successful 130 // or not. However, inside the test environment, we can't build client and 131 // the server with different version of this AIDL file. So, we let the server 132 // to actually implement this, but intercept the dispatch to the method 133 // inside onTransact(). UnimplementedMethod(int arg)134 int UnimplementedMethod(int arg); 135 } 136