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