blob: e02549426cb540ae48e0096e94cd1f6e2c8ff8a8 [file] [log] [blame]
Andreas Huberdab5fc62016-08-15 09:25:02 -07001/*
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
17package android.os;
18
Steven Morelandf3c53492016-11-03 15:17:04 -070019import java.util.ArrayList;
Steven Morelandc0631d02017-01-04 10:37:59 -080020import java.util.NoSuchElementException;
Andreas Huberdab5fc62016-08-15 09:25:02 -070021import libcore.util.NativeAllocationRegistry;
22
23/** @hide */
24public 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 Morelande62b1f32016-12-20 15:55:48 -080037 @Override
Andreas Huberdab5fc62016-08-15 09:25:02 -070038 public final native void transact(
Steven Morelande62b1f32016-12-20 15:55:48 -080039 int code, HwParcel request, HwParcel reply, int flags)
40 throws RemoteException;
Andreas Huberdab5fc62016-08-15 09:25:02 -070041
42 public abstract void onTransact(
Steven Morelande62b1f32016-12-20 15:55:48 -080043 int code, HwParcel request, HwParcel reply, int flags)
44 throws RemoteException;
Andreas Huberdab5fc62016-08-15 09:25:02 -070045
Andreas Huber35eb7992016-10-25 13:29:30 -070046 public native final void registerService(
Steven Morelandf3c53492016-11-03 15:17:04 -070047 ArrayList<String> interfaceChain,
Steven Morelandc0631d02017-01-04 10:37:59 -080048 String serviceName)
49 throws RemoteException;
Andreas Huber35eb7992016-10-25 13:29:30 -070050
51 public static native final IHwBinder getService(
Steven Morelandf3c53492016-11-03 15:17:04 -070052 String iface,
Steven Morelandc0631d02017-01-04 10:37:59 -080053 String serviceName)
54 throws RemoteException, NoSuchElementException;
Andreas Huberdab5fc62016-08-15 09:25:02 -070055
56 // Returns address of the "freeFunction".
57 private static native final long native_init();
58
59 private native final void native_setup();
60
61 static {
62 long freeFunction = native_init();
63
64 sNativeRegistry = new NativeAllocationRegistry(
65 HwBinder.class.getClassLoader(),
66 freeFunction,
67 128 /* size */);
68 }
69
70 private long mNativeContext;
71}