• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 interface IBinderRpcTest {
sendString(@tf8InCpp String str)18     oneway void sendString(@utf8InCpp String str);
doubleString(@tf8InCpp String str)19     @utf8InCpp String doubleString(@utf8InCpp String str);
20 
21     // get the port that a client used to connect to this object
getClientPort()22     int getClientPort();
23 
24     // number of known RPC binders to process, RpcState::countBinders by session
countBinders()25     int[] countBinders();
26 
27     // Return a null binder with a non-nullable return type.
getNullBinder()28     IBinder getNullBinder();
29 
30     // Caller sends server, callee pings caller's server and returns error code.
pingMe(IBinder binder)31     int pingMe(IBinder binder);
repeatBinder(@ullable IBinder binder)32     @nullable IBinder repeatBinder(@nullable IBinder binder);
33 
holdBinder(@ullable IBinder binder)34     void holdBinder(@nullable IBinder binder);
getHeldBinder()35     @nullable IBinder getHeldBinder();
36 
repeatBytes(in byte[] bytes)37     byte[] repeatBytes(in byte[] bytes);
38 
39     // Idea is client creates its own instance of IBinderRpcTest and calls this,
40     // and the server calls 'binder' with (calls - 1) passing itself as 'binder',
41     // going back and forth until calls = 0
nestMe(IBinderRpcTest binder, int calls)42     void nestMe(IBinderRpcTest binder, int calls);
43 
44     // should always return the same binder
alwaysGiveMeTheSameBinder()45     IBinder alwaysGiveMeTheSameBinder();
46 
47     // Idea is that the server will not hold onto the session, the remote session
48     // object must. This is to test lifetimes of binder objects, and consequently, also
49     // identity (since by assigning sessions names, we can make sure a section always
50     // references the session it was originally opened with).
openSession(@tf8InCpp String name)51     IBinderRpcSession openSession(@utf8InCpp String name);
52 
53     // Decremented in ~IBinderRpcSession
getNumOpenSessions()54     int getNumOpenSessions();
55 
56     // primitives to test threading behavior
lock()57     void lock();
unlockInMsAsync(int ms)58     oneway void unlockInMsAsync(int ms);
lockUnlock()59     void lockUnlock(); // locks and unlocks a mutex
60 
61     // take up binder thread for some time
sleepMs(int ms)62     void sleepMs(int ms);
sleepMsAsync(int ms)63     oneway void sleepMsAsync(int ms);
64 
doCallback(IBinderRpcCallback callback, boolean isOneway, boolean delayed, @utf8InCpp String value)65     void doCallback(IBinderRpcCallback callback, boolean isOneway, boolean delayed, @utf8InCpp String value);
doCallbackAsync(IBinderRpcCallback callback, boolean isOneway, boolean delayed, @utf8InCpp String value)66     oneway void doCallbackAsync(IBinderRpcCallback callback, boolean isOneway, boolean delayed, @utf8InCpp String value);
67 
die(boolean cleanup)68     void die(boolean cleanup);
scheduleShutdown()69     void scheduleShutdown();
70 
useKernelBinderCallingId()71     void useKernelBinderCallingId();
72 
echoAsFile(@tf8InCpp String content)73     ParcelFileDescriptor echoAsFile(@utf8InCpp String content);
74 
concatFiles(in List<ParcelFileDescriptor> files)75     ParcelFileDescriptor concatFiles(in List<ParcelFileDescriptor> files);
76 
77     // FDs sent via `blockingSendFdOneway` can be received via
78     // `blockingRecvFd`. The handler for `blockingSendFdOneway` will block
79     // until the next `blockingRecvFd` call.
80     //
81     // This is useful for carefully controlling how/when oneway transactions
82     // get queued.
blockingSendFdOneway(in ParcelFileDescriptor fd)83     oneway void blockingSendFdOneway(in ParcelFileDescriptor fd);
blockingRecvFd()84     ParcelFileDescriptor blockingRecvFd();
85 
86     // Same as blockingSendFdOneway, but with integers.
blockingSendIntOneway(int n)87     oneway void blockingSendIntOneway(int n);
blockingRecvInt()88     int blockingRecvInt();
89 }
90