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 | |
| 21 | /** @hide */ |
| 22 | public class HwRemoteBinder implements IHwBinder { |
| 23 | private static final String TAG = "HwRemoteBinder"; |
| 24 | |
| 25 | private static final NativeAllocationRegistry sNativeRegistry; |
| 26 | |
| 27 | public HwRemoteBinder() { |
| 28 | native_setup_empty(); |
| 29 | |
| 30 | sNativeRegistry.registerNativeAllocation( |
| 31 | this, |
| 32 | mNativeContext); |
| 33 | } |
| 34 | |
Steven Moreland | 27538df | 2016-12-20 15:55:48 -0800 | [diff] [blame] | 35 | @Override |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 36 | public IHwInterface queryLocalInterface(String descriptor) { |
| 37 | return null; |
| 38 | } |
| 39 | |
Steven Moreland | 27538df | 2016-12-20 15:55:48 -0800 | [diff] [blame] | 40 | @Override |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 41 | public native final void transact( |
Steven Moreland | 27538df | 2016-12-20 15:55:48 -0800 | [diff] [blame] | 42 | int code, HwParcel request, HwParcel reply, int flags) |
| 43 | throws RemoteException; |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 44 | |
Martijn Coenen | 727f7bf | 2016-12-27 14:33:09 +0100 | [diff] [blame] | 45 | public native boolean linkToDeath(DeathRecipient recipient, long cookie); |
| 46 | public native boolean unlinkToDeath(DeathRecipient recipient); |
| 47 | |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 48 | private static native final long native_init(); |
| 49 | |
| 50 | private native final void native_setup_empty(); |
| 51 | |
| 52 | static { |
| 53 | long freeFunction = native_init(); |
| 54 | |
| 55 | sNativeRegistry = new NativeAllocationRegistry( |
| 56 | HwRemoteBinder.class.getClassLoader(), |
| 57 | freeFunction, |
| 58 | 128 /* size */); |
| 59 | } |
| 60 | |
Martijn Coenen | 727f7bf | 2016-12-27 14:33:09 +0100 | [diff] [blame] | 61 | private static final void sendDeathNotice(DeathRecipient recipient, long cookie) { |
| 62 | recipient.serviceDied(cookie); |
| 63 | } |
| 64 | |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 65 | private long mNativeContext; |
| 66 | } |