blob: 5ff79f752c394d4862ebbccf5171c106fbd0aa6f [file] [log] [blame]
Andreas Huberc0b6c532016-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
19import libcore.util.NativeAllocationRegistry;
20
21/** @hide */
22public abstract class HwBinder implements IHwBinder {
23 private static final String TAG = "HwBinder";
24
25 private static final NativeAllocationRegistry sNativeRegistry;
26
27 public HwBinder() {
28 native_setup();
29
30 sNativeRegistry.registerNativeAllocation(
31 this,
32 mNativeContext);
33 }
34
35 public final native void transact(
36 int code, HwParcel request, HwParcel reply, int flags);
37
38 public abstract void onTransact(
39 int code, HwParcel request, HwParcel reply, int flags);
40
41 public native final void registerService(String serviceName);
42 public static native final IHwBinder getService(String serviceName);
43
44 // Returns address of the "freeFunction".
45 private static native final long native_init();
46
47 private native final void native_setup();
48
49 static {
50 long freeFunction = native_init();
51
52 sNativeRegistry = new NativeAllocationRegistry(
53 HwBinder.class.getClassLoader(),
54 freeFunction,
55 128 /* size */);
56 }
57
58 private long mNativeContext;
59}