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 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 19 | import android.annotation.IntDef; |
Steven Moreland | 0ff061a | 2019-03-04 17:56:30 -0800 | [diff] [blame] | 20 | import android.annotation.NonNull; |
| 21 | import android.annotation.Nullable; |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 22 | import android.annotation.SystemApi; |
Steven Moreland | 14b9eb6 | 2019-01-11 10:19:51 -0800 | [diff] [blame] | 23 | import android.annotation.TestApi; |
Andrei Onea | dcb6773 | 2019-03-18 11:37:25 +0000 | [diff] [blame] | 24 | import android.annotation.UnsupportedAppUsage; |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 25 | |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 26 | import dalvik.annotation.optimization.FastNative; |
| 27 | |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 28 | import libcore.util.NativeAllocationRegistry; |
| 29 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 30 | import java.lang.annotation.Retention; |
| 31 | import java.lang.annotation.RetentionPolicy; |
| 32 | import java.util.ArrayList; |
| 33 | import java.util.Arrays; |
| 34 | |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 35 | /** @hide */ |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 36 | @SystemApi |
Steven Moreland | 14b9eb6 | 2019-01-11 10:19:51 -0800 | [diff] [blame] | 37 | @TestApi |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 38 | public class HwParcel { |
| 39 | private static final String TAG = "HwParcel"; |
| 40 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 41 | @IntDef(prefix = { "STATUS_" }, value = { |
| 42 | STATUS_SUCCESS, |
| 43 | }) |
| 44 | @Retention(RetentionPolicy.SOURCE) |
| 45 | public @interface Status {} |
| 46 | |
| 47 | /** |
| 48 | * Success return error for a transaction. Written to parcels |
| 49 | * using writeStatus. |
| 50 | */ |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 51 | public static final int STATUS_SUCCESS = 0; |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 52 | |
| 53 | private static final NativeAllocationRegistry sNativeRegistry; |
| 54 | |
Andrei Onea | dcb6773 | 2019-03-18 11:37:25 +0000 | [diff] [blame] | 55 | @UnsupportedAppUsage |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 56 | private HwParcel(boolean allocate) { |
| 57 | native_setup(allocate); |
| 58 | |
| 59 | sNativeRegistry.registerNativeAllocation( |
| 60 | this, |
| 61 | mNativeContext); |
| 62 | } |
| 63 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 64 | /** |
| 65 | * Creates an initialized and empty parcel. |
| 66 | */ |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 67 | public HwParcel() { |
| 68 | native_setup(true /* allocate */); |
| 69 | |
| 70 | sNativeRegistry.registerNativeAllocation( |
| 71 | this, |
| 72 | mNativeContext); |
| 73 | } |
| 74 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 75 | /** |
| 76 | * Writes an interface token into the parcel used to verify that |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 77 | * a transaction has made it to the right type of interface. |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 78 | * |
| 79 | * @param interfaceName fully qualified name of interface message |
| 80 | * is being sent to. |
| 81 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 82 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 83 | public native final void writeInterfaceToken(String interfaceName); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 84 | /** |
| 85 | * Writes a boolean value to the end of the parcel. |
| 86 | * @param val to write |
| 87 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 88 | @FastNative |
Andreas Huber | 86635bb | 2016-08-24 16:19:03 -0700 | [diff] [blame] | 89 | public native final void writeBool(boolean val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 90 | /** |
| 91 | * Writes a byte value to the end of the parcel. |
| 92 | * @param val to write |
| 93 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 94 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 95 | public native final void writeInt8(byte val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 96 | /** |
| 97 | * Writes a short value to the end of the parcel. |
| 98 | * @param val to write |
| 99 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 100 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 101 | public native final void writeInt16(short val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 102 | /** |
| 103 | * Writes a int value to the end of the parcel. |
| 104 | * @param val to write |
| 105 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 106 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 107 | public native final void writeInt32(int val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 108 | /** |
| 109 | * Writes a long value to the end of the parcel. |
| 110 | * @param val to write |
| 111 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 112 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 113 | public native final void writeInt64(long val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 114 | /** |
| 115 | * Writes a float value to the end of the parcel. |
| 116 | * @param val to write |
| 117 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 118 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 119 | public native final void writeFloat(float val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 120 | /** |
| 121 | * Writes a double value to the end of the parcel. |
| 122 | * @param val to write |
| 123 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 124 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 125 | public native final void writeDouble(double val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 126 | /** |
| 127 | * Writes a String value to the end of the parcel. |
| 128 | * |
| 129 | * Note, this will be converted to UTF-8 when it is written. |
| 130 | * |
| 131 | * @param val to write |
| 132 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 133 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 134 | public native final void writeString(String val); |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 135 | /** |
| 136 | * Writes a native handle (without duplicating the underlying |
| 137 | * file descriptors) to the end of the parcel. |
| 138 | * |
| 139 | * @param val to write |
| 140 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 141 | @FastNative |
Steven Moreland | 0ff061a | 2019-03-04 17:56:30 -0800 | [diff] [blame] | 142 | public native final void writeNativeHandle(@Nullable NativeHandle val); |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 143 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 144 | /** |
| 145 | * Writes an array of boolean values to the end of the parcel. |
| 146 | * @param val to write |
| 147 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 148 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 149 | private native final void writeBoolVector(boolean[] val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 150 | /** |
| 151 | * Writes an array of byte values to the end of the parcel. |
| 152 | * @param val to write |
| 153 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 154 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 155 | private native final void writeInt8Vector(byte[] val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 156 | /** |
| 157 | * Writes an array of short values to the end of the parcel. |
| 158 | * @param val to write |
| 159 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 160 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 161 | private native final void writeInt16Vector(short[] val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 162 | /** |
| 163 | * Writes an array of int values to the end of the parcel. |
| 164 | * @param val to write |
| 165 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 166 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 167 | private native final void writeInt32Vector(int[] val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 168 | /** |
| 169 | * Writes an array of long values to the end of the parcel. |
| 170 | * @param val to write |
| 171 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 172 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 173 | private native final void writeInt64Vector(long[] val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 174 | /** |
| 175 | * Writes an array of float values to the end of the parcel. |
| 176 | * @param val to write |
| 177 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 178 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 179 | private native final void writeFloatVector(float[] val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 180 | /** |
| 181 | * Writes an array of double values to the end of the parcel. |
| 182 | * @param val to write |
| 183 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 184 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 185 | private native final void writeDoubleVector(double[] val); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 186 | /** |
| 187 | * Writes an array of String values to the end of the parcel. |
| 188 | * |
| 189 | * Note, these will be converted to UTF-8 as they are written. |
| 190 | * |
| 191 | * @param val to write |
| 192 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 193 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 194 | private native final void writeStringVector(String[] val); |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 195 | /** |
| 196 | * Writes an array of native handles to the end of the parcel. |
Steven Moreland | 0ff061a | 2019-03-04 17:56:30 -0800 | [diff] [blame] | 197 | * |
| 198 | * Individual elements may be null but not the whole array. |
| 199 | * |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 200 | * @param val array of {@link NativeHandle} objects to write |
| 201 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 202 | @FastNative |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 203 | private native final void writeNativeHandleVector(NativeHandle[] val); |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 204 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 205 | /** |
| 206 | * Helper method to write a list of Booleans to val. |
| 207 | * @param val list to write |
| 208 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 209 | public final void writeBoolVector(ArrayList<Boolean> val) { |
| 210 | final int n = val.size(); |
| 211 | boolean[] array = new boolean[n]; |
| 212 | for (int i = 0; i < n; ++i) { |
| 213 | array[i] = val.get(i); |
| 214 | } |
| 215 | |
| 216 | writeBoolVector(array); |
| 217 | } |
| 218 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 219 | /** |
| 220 | * Helper method to write a list of Booleans to the end of the parcel. |
| 221 | * @param val list to write |
| 222 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 223 | public final void writeInt8Vector(ArrayList<Byte> val) { |
| 224 | final int n = val.size(); |
| 225 | byte[] array = new byte[n]; |
| 226 | for (int i = 0; i < n; ++i) { |
| 227 | array[i] = val.get(i); |
| 228 | } |
| 229 | |
| 230 | writeInt8Vector(array); |
| 231 | } |
| 232 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 233 | /** |
| 234 | * Helper method to write a list of Shorts to the end of the parcel. |
| 235 | * @param val list to write |
| 236 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 237 | public final void writeInt16Vector(ArrayList<Short> val) { |
| 238 | final int n = val.size(); |
| 239 | short[] array = new short[n]; |
| 240 | for (int i = 0; i < n; ++i) { |
| 241 | array[i] = val.get(i); |
| 242 | } |
| 243 | |
| 244 | writeInt16Vector(array); |
| 245 | } |
| 246 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 247 | /** |
| 248 | * Helper method to write a list of Integers to the end of the parcel. |
| 249 | * @param val list to write |
| 250 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 251 | public final void writeInt32Vector(ArrayList<Integer> val) { |
| 252 | final int n = val.size(); |
| 253 | int[] array = new int[n]; |
| 254 | for (int i = 0; i < n; ++i) { |
| 255 | array[i] = val.get(i); |
| 256 | } |
| 257 | |
| 258 | writeInt32Vector(array); |
| 259 | } |
| 260 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 261 | /** |
| 262 | * Helper method to write a list of Longs to the end of the parcel. |
| 263 | * @param val list to write |
| 264 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 265 | public final void writeInt64Vector(ArrayList<Long> val) { |
| 266 | final int n = val.size(); |
| 267 | long[] array = new long[n]; |
| 268 | for (int i = 0; i < n; ++i) { |
| 269 | array[i] = val.get(i); |
| 270 | } |
| 271 | |
| 272 | writeInt64Vector(array); |
| 273 | } |
| 274 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 275 | /** |
| 276 | * Helper method to write a list of Floats to the end of the parcel. |
| 277 | * @param val list to write |
| 278 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 279 | public final void writeFloatVector(ArrayList<Float> val) { |
| 280 | final int n = val.size(); |
| 281 | float[] array = new float[n]; |
| 282 | for (int i = 0; i < n; ++i) { |
| 283 | array[i] = val.get(i); |
| 284 | } |
| 285 | |
| 286 | writeFloatVector(array); |
| 287 | } |
| 288 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 289 | /** |
| 290 | * Helper method to write a list of Doubles to the end of the parcel. |
| 291 | * @param val list to write |
| 292 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 293 | public final void writeDoubleVector(ArrayList<Double> val) { |
| 294 | final int n = val.size(); |
| 295 | double[] array = new double[n]; |
| 296 | for (int i = 0; i < n; ++i) { |
| 297 | array[i] = val.get(i); |
| 298 | } |
| 299 | |
| 300 | writeDoubleVector(array); |
| 301 | } |
| 302 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 303 | /** |
| 304 | * Helper method to write a list of Strings to the end of the parcel. |
| 305 | * @param val list to write |
| 306 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 307 | public final void writeStringVector(ArrayList<String> val) { |
| 308 | writeStringVector(val.toArray(new String[val.size()])); |
| 309 | } |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 310 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 311 | /** |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 312 | * Helper method to write a list of native handles to the end of the parcel. |
| 313 | * @param val list of {@link NativeHandle} objects to write |
| 314 | */ |
Steven Moreland | 0ff061a | 2019-03-04 17:56:30 -0800 | [diff] [blame] | 315 | public final void writeNativeHandleVector(@NonNull ArrayList<NativeHandle> val) { |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 316 | writeNativeHandleVector(val.toArray(new NativeHandle[val.size()])); |
| 317 | } |
| 318 | |
| 319 | /** |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 320 | * Write a hwbinder object to the end of the parcel. |
| 321 | * @param binder value to write |
| 322 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 323 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 324 | public native final void writeStrongBinder(IHwBinder binder); |
| 325 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 326 | /** |
| 327 | * Checks to make sure that the interface name matches the name written by the parcel |
| 328 | * sender by writeInterfaceToken |
| 329 | * |
| 330 | * @throws SecurityException interface doesn't match |
| 331 | */ |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 332 | public native final void enforceInterface(String interfaceName); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 333 | |
| 334 | /** |
| 335 | * Reads a boolean value from the current location in the parcel. |
| 336 | * @return value parsed from the parcel |
| 337 | * @throws IllegalArgumentException if the parcel has no more data |
| 338 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 339 | @FastNative |
Andreas Huber | 86635bb | 2016-08-24 16:19:03 -0700 | [diff] [blame] | 340 | public native final boolean readBool(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 341 | /** |
| 342 | * Reads a byte value from the current location in the parcel. |
| 343 | * @return value parsed from the parcel |
| 344 | * @throws IllegalArgumentException if the parcel has no more data |
| 345 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 346 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 347 | public native final byte readInt8(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 348 | /** |
| 349 | * Reads a short value from the current location in the parcel. |
| 350 | * @return value parsed from the parcel |
| 351 | * @throws IllegalArgumentException if the parcel has no more data |
| 352 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 353 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 354 | public native final short readInt16(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 355 | /** |
| 356 | * Reads a int value from the current location in the parcel. |
| 357 | * @return value parsed from the parcel |
| 358 | * @throws IllegalArgumentException if the parcel has no more data |
| 359 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 360 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 361 | public native final int readInt32(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 362 | /** |
| 363 | * Reads a long value from the current location in the parcel. |
| 364 | * @return value parsed from the parcel |
| 365 | * @throws IllegalArgumentException if the parcel has no more data |
| 366 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 367 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 368 | public native final long readInt64(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 369 | /** |
| 370 | * Reads a float value from the current location in the parcel. |
| 371 | * @return value parsed from the parcel |
| 372 | * @throws IllegalArgumentException if the parcel has no more data |
| 373 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 374 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 375 | public native final float readFloat(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 376 | /** |
| 377 | * Reads a double value from the current location in the parcel. |
| 378 | * @return value parsed from the parcel |
| 379 | * @throws IllegalArgumentException if the parcel has no more data |
| 380 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 381 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 382 | public native final double readDouble(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 383 | /** |
| 384 | * Reads a String value from the current location in the parcel. |
| 385 | * @return value parsed from the parcel |
| 386 | * @throws IllegalArgumentException if the parcel has no more data |
| 387 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 388 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 389 | public native final String readString(); |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 390 | /** |
| 391 | * Reads a native handle (without duplicating the underlying file |
| 392 | * descriptors) from the parcel. These file descriptors will only |
| 393 | * be open for the duration that the binder window is open. If they |
| 394 | * are needed further, you must call {@link NativeHandle#dup()}. |
| 395 | * |
| 396 | * @return a {@link NativeHandle} instance parsed from the parcel |
| 397 | * @throws IllegalArgumentException if the parcel has no more data |
| 398 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 399 | @FastNative |
Steven Moreland | 0ff061a | 2019-03-04 17:56:30 -0800 | [diff] [blame] | 400 | public native final @Nullable NativeHandle readNativeHandle(); |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 401 | /** |
| 402 | * Reads an embedded native handle (without duplicating the underlying |
| 403 | * file descriptors) from the parcel. These file descriptors will only |
| 404 | * be open for the duration that the binder window is open. If they |
| 405 | * are needed further, you must call {@link NativeHandle#dup()}. You |
| 406 | * do not need to call close on the NativeHandle returned from this. |
| 407 | * |
| 408 | * @param parentHandle handle from which to read the embedded object |
| 409 | * @param offset offset into parent |
| 410 | * @return a {@link NativeHandle} instance parsed from the parcel |
| 411 | * @throws IllegalArgumentException if the parcel has no more data |
| 412 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 413 | @FastNative |
Steven Moreland | 0ff061a | 2019-03-04 17:56:30 -0800 | [diff] [blame] | 414 | public native final @Nullable NativeHandle readEmbeddedNativeHandle( |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 415 | long parentHandle, long offset); |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 416 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 417 | /** |
| 418 | * Reads an array of boolean values from the parcel. |
| 419 | * @return array of parsed values |
| 420 | * @throws IllegalArgumentException if the parcel has no more data |
| 421 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 422 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 423 | private native final boolean[] readBoolVectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 424 | /** |
| 425 | * Reads an array of byte values from the parcel. |
| 426 | * @return array of parsed values |
| 427 | * @throws IllegalArgumentException if the parcel has no more data |
| 428 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 429 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 430 | private native final byte[] readInt8VectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 431 | /** |
| 432 | * Reads an array of short values from the parcel. |
| 433 | * @return array of parsed values |
| 434 | * @throws IllegalArgumentException if the parcel has no more data |
| 435 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 436 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 437 | private native final short[] readInt16VectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 438 | /** |
| 439 | * Reads an array of int values from the parcel. |
| 440 | * @return array of parsed values |
| 441 | * @throws IllegalArgumentException if the parcel has no more data |
| 442 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 443 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 444 | private native final int[] readInt32VectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 445 | /** |
| 446 | * Reads an array of long values from the parcel. |
| 447 | * @return array of parsed values |
| 448 | * @throws IllegalArgumentException if the parcel has no more data |
| 449 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 450 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 451 | private native final long[] readInt64VectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 452 | /** |
| 453 | * Reads an array of float values from the parcel. |
| 454 | * @return array of parsed values |
| 455 | * @throws IllegalArgumentException if the parcel has no more data |
| 456 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 457 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 458 | private native final float[] readFloatVectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 459 | /** |
| 460 | * Reads an array of double values from the parcel. |
| 461 | * @return array of parsed values |
| 462 | * @throws IllegalArgumentException if the parcel has no more data |
| 463 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 464 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 465 | private native final double[] readDoubleVectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 466 | /** |
| 467 | * Reads an array of String values from the parcel. |
| 468 | * @return array of parsed values |
| 469 | * @throws IllegalArgumentException if the parcel has no more data |
| 470 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 471 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 472 | private native final String[] readStringVectorAsArray(); |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 473 | /** |
| 474 | * Reads an array of native handles from the parcel. |
| 475 | * @return array of {@link NativeHandle} objects |
| 476 | * @throws IllegalArgumentException if the parcel has no more data |
| 477 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 478 | @FastNative |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 479 | private native final NativeHandle[] readNativeHandleAsArray(); |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 480 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 481 | /** |
| 482 | * Convenience method to read a Boolean vector as an ArrayList. |
| 483 | * @return array of parsed values. |
| 484 | * @throws IllegalArgumentException if the parcel has no more data |
| 485 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 486 | public final ArrayList<Boolean> readBoolVector() { |
| 487 | Boolean[] array = HwBlob.wrapArray(readBoolVectorAsArray()); |
| 488 | |
| 489 | return new ArrayList<Boolean>(Arrays.asList(array)); |
| 490 | } |
| 491 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 492 | /** |
| 493 | * Convenience method to read a Byte vector as an ArrayList. |
| 494 | * @return array of parsed values. |
| 495 | * @throws IllegalArgumentException if the parcel has no more data |
| 496 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 497 | public final ArrayList<Byte> readInt8Vector() { |
| 498 | Byte[] array = HwBlob.wrapArray(readInt8VectorAsArray()); |
| 499 | |
| 500 | return new ArrayList<Byte>(Arrays.asList(array)); |
| 501 | } |
| 502 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 503 | /** |
| 504 | * Convenience method to read a Short vector as an ArrayList. |
| 505 | * @return array of parsed values. |
| 506 | * @throws IllegalArgumentException if the parcel has no more data |
| 507 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 508 | public final ArrayList<Short> readInt16Vector() { |
| 509 | Short[] array = HwBlob.wrapArray(readInt16VectorAsArray()); |
| 510 | |
| 511 | return new ArrayList<Short>(Arrays.asList(array)); |
| 512 | } |
| 513 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 514 | /** |
| 515 | * Convenience method to read a Integer vector as an ArrayList. |
| 516 | * @return array of parsed values. |
| 517 | * @throws IllegalArgumentException if the parcel has no more data |
| 518 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 519 | public final ArrayList<Integer> readInt32Vector() { |
| 520 | Integer[] array = HwBlob.wrapArray(readInt32VectorAsArray()); |
| 521 | |
| 522 | return new ArrayList<Integer>(Arrays.asList(array)); |
| 523 | } |
| 524 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 525 | /** |
| 526 | * Convenience method to read a Long vector as an ArrayList. |
| 527 | * @return array of parsed values. |
| 528 | * @throws IllegalArgumentException if the parcel has no more data |
| 529 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 530 | public final ArrayList<Long> readInt64Vector() { |
| 531 | Long[] array = HwBlob.wrapArray(readInt64VectorAsArray()); |
| 532 | |
| 533 | return new ArrayList<Long>(Arrays.asList(array)); |
| 534 | } |
| 535 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 536 | /** |
| 537 | * Convenience method to read a Float vector as an ArrayList. |
| 538 | * @return array of parsed values. |
| 539 | * @throws IllegalArgumentException if the parcel has no more data |
| 540 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 541 | public final ArrayList<Float> readFloatVector() { |
| 542 | Float[] array = HwBlob.wrapArray(readFloatVectorAsArray()); |
| 543 | |
| 544 | return new ArrayList<Float>(Arrays.asList(array)); |
| 545 | } |
| 546 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 547 | /** |
| 548 | * Convenience method to read a Double vector as an ArrayList. |
| 549 | * @return array of parsed values. |
| 550 | * @throws IllegalArgumentException if the parcel has no more data |
| 551 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 552 | public final ArrayList<Double> readDoubleVector() { |
| 553 | Double[] array = HwBlob.wrapArray(readDoubleVectorAsArray()); |
| 554 | |
| 555 | return new ArrayList<Double>(Arrays.asList(array)); |
| 556 | } |
| 557 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 558 | /** |
| 559 | * Convenience method to read a String vector as an ArrayList. |
| 560 | * @return array of parsed values. |
| 561 | * @throws IllegalArgumentException if the parcel has no more data |
| 562 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 563 | public final ArrayList<String> readStringVector() { |
| 564 | return new ArrayList<String>(Arrays.asList(readStringVectorAsArray())); |
| 565 | } |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 566 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 567 | /** |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 568 | * Convenience method to read a vector of native handles as an ArrayList. |
| 569 | * @return array of {@link NativeHandle} objects. |
| 570 | * @throws IllegalArgumentException if the parcel has no more data |
| 571 | */ |
Steven Moreland | 0ff061a | 2019-03-04 17:56:30 -0800 | [diff] [blame] | 572 | public final @NonNull ArrayList<NativeHandle> readNativeHandleVector() { |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 573 | return new ArrayList<NativeHandle>(Arrays.asList(readNativeHandleAsArray())); |
| 574 | } |
| 575 | |
| 576 | /** |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 577 | * Reads a strong binder value from the parcel. |
| 578 | * @return binder object read from parcel or null if no binder can be read |
| 579 | * @throws IllegalArgumentException if the parcel has no more data |
| 580 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 581 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 582 | public native final IHwBinder readStrongBinder(); |
| 583 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 584 | /** |
| 585 | * Read opaque segment of data as a blob. |
| 586 | * @return blob of size expectedSize |
| 587 | * @throws IllegalArgumentException if the parcel has no more data |
| 588 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 589 | @FastNative |
Martijn Coenen | 932b504 | 2017-04-18 15:54:43 -0700 | [diff] [blame] | 590 | public native final HwBlob readBuffer(long expectedSize); |
Andreas Huber | 9266f99 | 2016-08-25 11:21:21 -0700 | [diff] [blame] | 591 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 592 | /** |
| 593 | * Read a buffer written using scatter gather. |
| 594 | * |
| 595 | * @param expectedSize size that buffer should be |
| 596 | * @param parentHandle handle from which to read the embedded buffer |
| 597 | * @param offset offset into parent |
| 598 | * @param nullable whether or not to allow for a null return |
| 599 | * @return blob of data with size expectedSize |
| 600 | * @throws NoSuchElementException if an embedded buffer is not available to read |
| 601 | * @throws IllegalArgumentException if expectedSize < 0 |
| 602 | * @throws NullPointerException if the transaction specified the blob to be null |
| 603 | * but nullable is false |
| 604 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 605 | @FastNative |
Andreas Huber | 9266f99 | 2016-08-25 11:21:21 -0700 | [diff] [blame] | 606 | public native final HwBlob readEmbeddedBuffer( |
Martijn Coenen | 932b504 | 2017-04-18 15:54:43 -0700 | [diff] [blame] | 607 | long expectedSize, long parentHandle, long offset, |
| 608 | boolean nullable); |
Andreas Huber | 9266f99 | 2016-08-25 11:21:21 -0700 | [diff] [blame] | 609 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 610 | /** |
| 611 | * Write a buffer into the transaction. |
| 612 | * @param blob blob to write into the parcel. |
| 613 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 614 | @FastNative |
Andreas Huber | 9266f99 | 2016-08-25 11:21:21 -0700 | [diff] [blame] | 615 | public native final void writeBuffer(HwBlob blob); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 616 | /** |
| 617 | * Write a status value into the blob. |
| 618 | * @param status value to write |
| 619 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 620 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 621 | public native final void writeStatus(int status); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 622 | /** |
| 623 | * @throws IllegalArgumentException if a success vaue cannot be read |
| 624 | * @throws RemoteException if success value indicates a transaction error |
| 625 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 626 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 627 | public native final void verifySuccess(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 628 | /** |
| 629 | * Should be called to reduce memory pressure when this object no longer needs |
| 630 | * to be written to. |
| 631 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 632 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 633 | public native final void releaseTemporaryStorage(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 634 | /** |
| 635 | * Should be called when object is no longer needed to reduce possible memory |
| 636 | * pressure if the Java GC does not get to this object in time. |
| 637 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 638 | @FastNative |
Martijn Coenen | 3d726d1 | 2017-03-16 18:46:42 +0100 | [diff] [blame] | 639 | public native final void release(); |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 640 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 641 | /** |
| 642 | * Sends the parcel to the specified destination. |
| 643 | */ |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 644 | public native final void send(); |
| 645 | |
| 646 | // Returns address of the "freeFunction". |
| 647 | private static native final long native_init(); |
| 648 | |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 649 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 650 | private native final void native_setup(boolean allocate); |
| 651 | |
| 652 | static { |
| 653 | long freeFunction = native_init(); |
| 654 | |
| 655 | sNativeRegistry = new NativeAllocationRegistry( |
| 656 | HwParcel.class.getClassLoader(), |
| 657 | freeFunction, |
| 658 | 128 /* size */); |
| 659 | } |
| 660 | |
| 661 | private long mNativeContext; |
| 662 | } |
| 663 | |