• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 java.util.ArrayList;
20 import java.util.NoSuchElementException;
21 import libcore.util.NativeAllocationRegistry;
22 
23 /** @hide */
24 public abstract class HwBinder implements IHwBinder {
25     private static final String TAG = "HwBinder";
26 
27     private static final NativeAllocationRegistry sNativeRegistry;
28 
HwBinder()29     public HwBinder() {
30         native_setup();
31 
32         sNativeRegistry.registerNativeAllocation(
33                 this,
34                 mNativeContext);
35     }
36 
37     @Override
transact( int code, HwParcel request, HwParcel reply, int flags)38     public final native void transact(
39             int code, HwParcel request, HwParcel reply, int flags)
40         throws RemoteException;
41 
onTransact( int code, HwParcel request, HwParcel reply, int flags)42     public abstract void onTransact(
43             int code, HwParcel request, HwParcel reply, int flags)
44         throws RemoteException;
45 
registerService(String serviceName)46     public native final void registerService(String serviceName)
47         throws RemoteException;
48 
getService( String iface, String serviceName)49     public static native final IHwBinder getService(
50             String iface,
51             String serviceName)
52         throws RemoteException, NoSuchElementException;
53 
configureRpcThreadpool( long maxThreads, boolean callerWillJoin)54     public static native final void configureRpcThreadpool(
55             long maxThreads, boolean callerWillJoin);
56 
joinRpcThreadpool()57     public static native final void joinRpcThreadpool();
58 
59     // Returns address of the "freeFunction".
native_init()60     private static native final long native_init();
61 
native_setup()62     private native final void native_setup();
63 
64     static {
65         long freeFunction = native_init();
66 
67         sNativeRegistry = new NativeAllocationRegistry(
68                 HwBinder.class.getClassLoader(),
69                 freeFunction,
70                 128 /* size */);
71     }
72 
73     private long mNativeContext;
74 }
75