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 | bdb53ab | 2021-05-05 17:57:41 +0000 | [diff] [blame] | 21 | // number of known RPC binders to process, RpcState::countBinders by session |
Steven Moreland | 736664b | 2021-05-01 04:27:25 +0000 | [diff] [blame] | 22 | int[] countBinders(); |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 23 | |
| 24 | // Caller sends server, callee pings caller's server and returns error code. |
| 25 | int pingMe(IBinder binder); |
| 26 | @nullable IBinder repeatBinder(@nullable IBinder binder); |
| 27 | |
| 28 | void holdBinder(@nullable IBinder binder); |
| 29 | @nullable IBinder getHeldBinder(); |
| 30 | |
| 31 | // Idea is client creates its own instance of IBinderRpcTest and calls this, |
| 32 | // and the server calls 'binder' with (calls - 1) passing itself as 'binder', |
| 33 | // going back and forth until calls = 0 |
| 34 | void nestMe(IBinderRpcTest binder, int calls); |
| 35 | |
| 36 | // should always return the same binder |
| 37 | IBinder alwaysGiveMeTheSameBinder(); |
| 38 | |
Steven Moreland | bdb53ab | 2021-05-05 17:57:41 +0000 | [diff] [blame] | 39 | // 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] | 40 | // object must. This is to test lifetimes of binder objects, and consequently, also |
| 41 | // identity (since by assigning sessions names, we can make sure a section always |
| 42 | // references the session it was originally opened with). |
| 43 | IBinderRpcSession openSession(@utf8InCpp String name); |
| 44 | |
| 45 | // Decremented in ~IBinderRpcSession |
| 46 | int getNumOpenSessions(); |
| 47 | |
| 48 | // primitives to test threading behavior |
| 49 | void lock(); |
| 50 | oneway void unlockInMsAsync(int ms); |
| 51 | void lockUnlock(); // locks and unlocks a mutex |
| 52 | |
| 53 | // take up binder thread for some time |
| 54 | void sleepMs(int ms); |
| 55 | oneway void sleepMsAsync(int ms); |
| 56 | |
Steven Moreland | 659416d | 2021-05-11 00:47:50 +0000 | [diff] [blame] | 57 | void doCallback(IBinderRpcCallback callback, boolean isOneway, boolean delayed, @utf8InCpp String value); |
| 58 | |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 59 | void die(boolean cleanup); |
Steven Moreland | af4ca71 | 2021-05-24 23:22:08 +0000 | [diff] [blame] | 60 | void scheduleShutdown(); |
Steven Moreland | d730207 | 2021-05-15 01:32:04 +0000 | [diff] [blame] | 61 | |
| 62 | void useKernelBinderCallingId(); |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 63 | } |