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 | |
Artur Satayev | afdb23a | 2019-12-10 17:47:53 +0000 | [diff] [blame] | 19 | import android.compat.annotation.UnsupportedAppUsage; |
| 20 | |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 21 | import libcore.util.NativeAllocationRegistry; |
| 22 | |
| 23 | /** @hide */ |
| 24 | public class HwRemoteBinder implements IHwBinder { |
| 25 | private static final String TAG = "HwRemoteBinder"; |
| 26 | |
| 27 | private static final NativeAllocationRegistry sNativeRegistry; |
| 28 | |
Andrei Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 29 | @UnsupportedAppUsage |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 30 | public HwRemoteBinder() { |
| 31 | native_setup_empty(); |
| 32 | |
| 33 | sNativeRegistry.registerNativeAllocation( |
| 34 | this, |
| 35 | mNativeContext); |
| 36 | } |
| 37 | |
Steven Moreland | 27538df | 2016-12-20 15:55:48 -0800 | [diff] [blame] | 38 | @Override |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 39 | public IHwInterface queryLocalInterface(String descriptor) { |
| 40 | return null; |
| 41 | } |
| 42 | |
Steven Moreland | 27538df | 2016-12-20 15:55:48 -0800 | [diff] [blame] | 43 | @Override |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 44 | public native final void transact( |
Steven Moreland | 27538df | 2016-12-20 15:55:48 -0800 | [diff] [blame] | 45 | int code, HwParcel request, HwParcel reply, int flags) |
| 46 | throws RemoteException; |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 47 | |
Martijn Coenen | 727f7bf | 2016-12-27 14:33:09 +0100 | [diff] [blame] | 48 | public native boolean linkToDeath(DeathRecipient recipient, long cookie); |
| 49 | public native boolean unlinkToDeath(DeathRecipient recipient); |
| 50 | |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 51 | private static native final long native_init(); |
| 52 | |
| 53 | private native final void native_setup_empty(); |
| 54 | |
| 55 | static { |
| 56 | long freeFunction = native_init(); |
| 57 | |
| 58 | sNativeRegistry = new NativeAllocationRegistry( |
| 59 | HwRemoteBinder.class.getClassLoader(), |
| 60 | freeFunction, |
| 61 | 128 /* size */); |
| 62 | } |
| 63 | |
Martijn Coenen | 727f7bf | 2016-12-27 14:33:09 +0100 | [diff] [blame] | 64 | private static final void sendDeathNotice(DeathRecipient recipient, long cookie) { |
| 65 | recipient.serviceDied(cookie); |
| 66 | } |
| 67 | |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 68 | private long mNativeContext; |
Yifan Hong | 73b6c27 | 2017-10-31 17:32:15 -0700 | [diff] [blame] | 69 | |
| 70 | @Override |
| 71 | public final native boolean equals(Object other); |
| 72 | @Override |
| 73 | public final native int hashCode(); |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 74 | } |