Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 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 | package android.os; |
| 18 | |
| 19 | import libcore.util.NativeAllocationRegistry; |
| 20 | |
Steven Moreland | ec5eb7e | 2017-10-25 04:50:46 +0000 | [diff] [blame] | 21 | import java.util.NoSuchElementException; |
| 22 | |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 23 | /** @hide */ |
| 24 | public abstract class HwBinder implements IHwBinder { |
| 25 | private static final String TAG = "HwBinder"; |
| 26 | |
| 27 | private static final NativeAllocationRegistry sNativeRegistry; |
| 28 | |
| 29 | public HwBinder() { |
| 30 | native_setup(); |
| 31 | |
| 32 | sNativeRegistry.registerNativeAllocation( |
| 33 | this, |
| 34 | mNativeContext); |
| 35 | } |
| 36 | |
Steven Moreland | e62b1f3 | 2016-12-20 15:55:48 -0800 | [diff] [blame] | 37 | @Override |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 38 | public final native void transact( |
Steven Moreland | e62b1f3 | 2016-12-20 15:55:48 -0800 | [diff] [blame] | 39 | int code, HwParcel request, HwParcel reply, int flags) |
| 40 | throws RemoteException; |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 41 | |
| 42 | public abstract void onTransact( |
Steven Moreland | e62b1f3 | 2016-12-20 15:55:48 -0800 | [diff] [blame] | 43 | int code, HwParcel request, HwParcel reply, int flags) |
| 44 | throws RemoteException; |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 45 | |
Martijn Coenen | 85d12da | 2017-03-06 13:07:53 +0100 | [diff] [blame] | 46 | public native final void registerService(String serviceName) |
Steven Moreland | c0631d0 | 2017-01-04 10:37:59 -0800 | [diff] [blame] | 47 | throws RemoteException; |
Andreas Huber | 35eb799 | 2016-10-25 13:29:30 -0700 | [diff] [blame] | 48 | |
Steven Moreland | ec5eb7e | 2017-10-25 04:50:46 +0000 | [diff] [blame] | 49 | public static final IHwBinder getService( |
Steven Moreland | f3c5349 | 2016-11-03 15:17:04 -0700 | [diff] [blame] | 50 | String iface, |
Steven Moreland | cc9e67c | 2017-10-25 04:46:26 +0000 | [diff] [blame] | 51 | String serviceName) |
Steven Moreland | ec5eb7e | 2017-10-25 04:50:46 +0000 | [diff] [blame] | 52 | throws RemoteException, NoSuchElementException { |
| 53 | return getService(iface, serviceName, false /* retry */); |
| 54 | } |
| 55 | public static native final IHwBinder getService( |
| 56 | String iface, |
| 57 | String serviceName, |
| 58 | boolean retry) |
Steven Moreland | c0631d0 | 2017-01-04 10:37:59 -0800 | [diff] [blame] | 59 | throws RemoteException, NoSuchElementException; |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 60 | |
Timur Iskhakov | b6a6283 | 2017-07-10 10:08:38 -0700 | [diff] [blame] | 61 | public static native final void configureRpcThreadpool( |
| 62 | long maxThreads, boolean callerWillJoin); |
| 63 | |
| 64 | public static native final void joinRpcThreadpool(); |
| 65 | |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 66 | // Returns address of the "freeFunction". |
| 67 | private static native final long native_init(); |
| 68 | |
| 69 | private native final void native_setup(); |
| 70 | |
| 71 | static { |
| 72 | long freeFunction = native_init(); |
| 73 | |
| 74 | sNativeRegistry = new NativeAllocationRegistry( |
| 75 | HwBinder.class.getClassLoader(), |
| 76 | freeFunction, |
| 77 | 128 /* size */); |
| 78 | } |
| 79 | |
| 80 | private long mNativeContext; |
Sundong Ahn | 28cc6e8 | 2017-07-13 16:34:01 +0900 | [diff] [blame] | 81 | |
| 82 | private static native void native_report_sysprop_change(); |
| 83 | |
| 84 | /** |
| 85 | * Notifies listeners that a system property has changed |
| 86 | */ |
| 87 | public static void reportSyspropChanged() { |
| 88 | native_report_sysprop_change(); |
| 89 | } |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 90 | } |