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 | /** |
Ytai Ben-Tsvi | 4659e18 | 2019-11-06 09:53:34 -0800 | [diff] [blame] | 327 | * Write a HidlMemory object (without duplicating the underlying file descriptors) to the end |
| 328 | * of the parcel. |
| 329 | * |
| 330 | * @param memory value to write |
| 331 | */ |
| 332 | @FastNative |
| 333 | public native final void writeHidlMemory(@NonNull HidlMemory memory); |
| 334 | |
| 335 | /** |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 336 | * Checks to make sure that the interface name matches the name written by the parcel |
| 337 | * sender by writeInterfaceToken |
| 338 | * |
| 339 | * @throws SecurityException interface doesn't match |
| 340 | */ |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 341 | public native final void enforceInterface(String interfaceName); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 342 | |
| 343 | /** |
| 344 | * Reads a boolean value from the current location in the parcel. |
| 345 | * @return value parsed from the parcel |
| 346 | * @throws IllegalArgumentException if the parcel has no more data |
| 347 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 348 | @FastNative |
Andreas Huber | 86635bb | 2016-08-24 16:19:03 -0700 | [diff] [blame] | 349 | public native final boolean readBool(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 350 | /** |
| 351 | * Reads a byte value from the current location in the parcel. |
| 352 | * @return value parsed from the parcel |
| 353 | * @throws IllegalArgumentException if the parcel has no more data |
| 354 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 355 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 356 | public native final byte readInt8(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 357 | /** |
| 358 | * Reads a short value from the current location in the parcel. |
| 359 | * @return value parsed from the parcel |
| 360 | * @throws IllegalArgumentException if the parcel has no more data |
| 361 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 362 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 363 | public native final short readInt16(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 364 | /** |
| 365 | * Reads a int value from the current location in the parcel. |
| 366 | * @return value parsed from the parcel |
| 367 | * @throws IllegalArgumentException if the parcel has no more data |
| 368 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 369 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 370 | public native final int readInt32(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 371 | /** |
| 372 | * Reads a long value from the current location in the parcel. |
| 373 | * @return value parsed from the parcel |
| 374 | * @throws IllegalArgumentException if the parcel has no more data |
| 375 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 376 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 377 | public native final long readInt64(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 378 | /** |
| 379 | * Reads a float value from the current location in the parcel. |
| 380 | * @return value parsed from the parcel |
| 381 | * @throws IllegalArgumentException if the parcel has no more data |
| 382 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 383 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 384 | public native final float readFloat(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 385 | /** |
| 386 | * Reads a double value from the current location in the parcel. |
| 387 | * @return value parsed from the parcel |
| 388 | * @throws IllegalArgumentException if the parcel has no more data |
| 389 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 390 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 391 | public native final double readDouble(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 392 | /** |
| 393 | * Reads a String value from the current location in the parcel. |
| 394 | * @return value parsed from the parcel |
| 395 | * @throws IllegalArgumentException if the parcel has no more data |
| 396 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 397 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 398 | public native final String readString(); |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 399 | /** |
| 400 | * Reads a native handle (without duplicating the underlying file |
| 401 | * descriptors) from the parcel. These file descriptors will only |
| 402 | * be open for the duration that the binder window is open. If they |
| 403 | * are needed further, you must call {@link NativeHandle#dup()}. |
| 404 | * |
| 405 | * @return a {@link NativeHandle} instance parsed from the parcel |
| 406 | * @throws IllegalArgumentException if the parcel has no more data |
| 407 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 408 | @FastNative |
Steven Moreland | 0ff061a | 2019-03-04 17:56:30 -0800 | [diff] [blame] | 409 | public native final @Nullable NativeHandle readNativeHandle(); |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 410 | /** |
| 411 | * Reads an embedded native handle (without duplicating the underlying |
| 412 | * file descriptors) from the parcel. These file descriptors will only |
| 413 | * be open for the duration that the binder window is open. If they |
| 414 | * are needed further, you must call {@link NativeHandle#dup()}. You |
| 415 | * do not need to call close on the NativeHandle returned from this. |
| 416 | * |
| 417 | * @param parentHandle handle from which to read the embedded object |
| 418 | * @param offset offset into parent |
| 419 | * @return a {@link NativeHandle} instance parsed from the parcel |
| 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 |
Steven Moreland | 0ff061a | 2019-03-04 17:56:30 -0800 | [diff] [blame] | 423 | public native final @Nullable NativeHandle readEmbeddedNativeHandle( |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 424 | long parentHandle, long offset); |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 425 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 426 | /** |
| 427 | * Reads an array of boolean values from the parcel. |
| 428 | * @return array of parsed values |
| 429 | * @throws IllegalArgumentException if the parcel has no more data |
| 430 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 431 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 432 | private native final boolean[] readBoolVectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 433 | /** |
| 434 | * Reads an array of byte values from the parcel. |
| 435 | * @return array of parsed values |
| 436 | * @throws IllegalArgumentException if the parcel has no more data |
| 437 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 438 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 439 | private native final byte[] readInt8VectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 440 | /** |
| 441 | * Reads an array of short values from the parcel. |
| 442 | * @return array of parsed values |
| 443 | * @throws IllegalArgumentException if the parcel has no more data |
| 444 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 445 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 446 | private native final short[] readInt16VectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 447 | /** |
| 448 | * Reads an array of int values from the parcel. |
| 449 | * @return array of parsed values |
| 450 | * @throws IllegalArgumentException if the parcel has no more data |
| 451 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 452 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 453 | private native final int[] readInt32VectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 454 | /** |
| 455 | * Reads an array of long values from the parcel. |
| 456 | * @return array of parsed values |
| 457 | * @throws IllegalArgumentException if the parcel has no more data |
| 458 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 459 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 460 | private native final long[] readInt64VectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 461 | /** |
| 462 | * Reads an array of float values from the parcel. |
| 463 | * @return array of parsed values |
| 464 | * @throws IllegalArgumentException if the parcel has no more data |
| 465 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 466 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 467 | private native final float[] readFloatVectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 468 | /** |
| 469 | * Reads an array of double values from the parcel. |
| 470 | * @return array of parsed values |
| 471 | * @throws IllegalArgumentException if the parcel has no more data |
| 472 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 473 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 474 | private native final double[] readDoubleVectorAsArray(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 475 | /** |
| 476 | * Reads an array of String values from the parcel. |
| 477 | * @return array of parsed values |
| 478 | * @throws IllegalArgumentException if the parcel has no more data |
| 479 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 480 | @FastNative |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 481 | private native final String[] readStringVectorAsArray(); |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 482 | /** |
| 483 | * Reads an array of native handles from the parcel. |
| 484 | * @return array of {@link NativeHandle} objects |
| 485 | * @throws IllegalArgumentException if the parcel has no more data |
| 486 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 487 | @FastNative |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 488 | private native final NativeHandle[] readNativeHandleAsArray(); |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 489 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 490 | /** |
| 491 | * Convenience method to read a Boolean vector as an ArrayList. |
| 492 | * @return array of parsed values. |
| 493 | * @throws IllegalArgumentException if the parcel has no more data |
| 494 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 495 | public final ArrayList<Boolean> readBoolVector() { |
| 496 | Boolean[] array = HwBlob.wrapArray(readBoolVectorAsArray()); |
| 497 | |
| 498 | return new ArrayList<Boolean>(Arrays.asList(array)); |
| 499 | } |
| 500 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 501 | /** |
| 502 | * Convenience method to read a Byte vector as an ArrayList. |
| 503 | * @return array of parsed values. |
| 504 | * @throws IllegalArgumentException if the parcel has no more data |
| 505 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 506 | public final ArrayList<Byte> readInt8Vector() { |
| 507 | Byte[] array = HwBlob.wrapArray(readInt8VectorAsArray()); |
| 508 | |
| 509 | return new ArrayList<Byte>(Arrays.asList(array)); |
| 510 | } |
| 511 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 512 | /** |
| 513 | * Convenience method to read a Short vector as an ArrayList. |
| 514 | * @return array of parsed values. |
| 515 | * @throws IllegalArgumentException if the parcel has no more data |
| 516 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 517 | public final ArrayList<Short> readInt16Vector() { |
| 518 | Short[] array = HwBlob.wrapArray(readInt16VectorAsArray()); |
| 519 | |
| 520 | return new ArrayList<Short>(Arrays.asList(array)); |
| 521 | } |
| 522 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 523 | /** |
| 524 | * Convenience method to read a Integer vector as an ArrayList. |
| 525 | * @return array of parsed values. |
| 526 | * @throws IllegalArgumentException if the parcel has no more data |
| 527 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 528 | public final ArrayList<Integer> readInt32Vector() { |
| 529 | Integer[] array = HwBlob.wrapArray(readInt32VectorAsArray()); |
| 530 | |
| 531 | return new ArrayList<Integer>(Arrays.asList(array)); |
| 532 | } |
| 533 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 534 | /** |
| 535 | * Convenience method to read a Long vector as an ArrayList. |
| 536 | * @return array of parsed values. |
| 537 | * @throws IllegalArgumentException if the parcel has no more data |
| 538 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 539 | public final ArrayList<Long> readInt64Vector() { |
| 540 | Long[] array = HwBlob.wrapArray(readInt64VectorAsArray()); |
| 541 | |
| 542 | return new ArrayList<Long>(Arrays.asList(array)); |
| 543 | } |
| 544 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 545 | /** |
| 546 | * Convenience method to read a Float vector as an ArrayList. |
| 547 | * @return array of parsed values. |
| 548 | * @throws IllegalArgumentException if the parcel has no more data |
| 549 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 550 | public final ArrayList<Float> readFloatVector() { |
| 551 | Float[] array = HwBlob.wrapArray(readFloatVectorAsArray()); |
| 552 | |
| 553 | return new ArrayList<Float>(Arrays.asList(array)); |
| 554 | } |
| 555 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 556 | /** |
| 557 | * Convenience method to read a Double vector as an ArrayList. |
| 558 | * @return array of parsed values. |
| 559 | * @throws IllegalArgumentException if the parcel has no more data |
| 560 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 561 | public final ArrayList<Double> readDoubleVector() { |
| 562 | Double[] array = HwBlob.wrapArray(readDoubleVectorAsArray()); |
| 563 | |
| 564 | return new ArrayList<Double>(Arrays.asList(array)); |
| 565 | } |
| 566 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 567 | /** |
| 568 | * Convenience method to read a String vector as an ArrayList. |
| 569 | * @return array of parsed values. |
| 570 | * @throws IllegalArgumentException if the parcel has no more data |
| 571 | */ |
Andreas Huber | ef1a565 | 2016-10-18 09:24:04 -0700 | [diff] [blame] | 572 | public final ArrayList<String> readStringVector() { |
| 573 | return new ArrayList<String>(Arrays.asList(readStringVectorAsArray())); |
| 574 | } |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 575 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 576 | /** |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 577 | * Convenience method to read a vector of native handles as an ArrayList. |
| 578 | * @return array of {@link NativeHandle} objects. |
| 579 | * @throws IllegalArgumentException if the parcel has no more data |
| 580 | */ |
Steven Moreland | 0ff061a | 2019-03-04 17:56:30 -0800 | [diff] [blame] | 581 | public final @NonNull ArrayList<NativeHandle> readNativeHandleVector() { |
Nirav Atre | 9850dd9 | 2018-07-24 17:03:44 -0700 | [diff] [blame] | 582 | return new ArrayList<NativeHandle>(Arrays.asList(readNativeHandleAsArray())); |
| 583 | } |
| 584 | |
| 585 | /** |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 586 | * Reads a strong binder value from the parcel. |
| 587 | * @return binder object read from parcel or null if no binder can be read |
| 588 | * @throws IllegalArgumentException if the parcel has no more data |
| 589 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 590 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 591 | public native final IHwBinder readStrongBinder(); |
| 592 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 593 | /** |
Ytai Ben-Tsvi | 4659e18 | 2019-11-06 09:53:34 -0800 | [diff] [blame] | 594 | * Reads a HidlMemory value (without duplicating the underlying file |
| 595 | * descriptors) from the parcel. These file descriptors will only |
| 596 | * be open for the duration that the binder window is open. If they |
| 597 | * are needed further, you must call {@link HidlMemory#dup()}, which makes you also |
| 598 | * responsible for calling {@link HidlMemory#close()}. |
| 599 | * |
| 600 | * @return HidlMemory object read from parcel. |
| 601 | * @throws IllegalArgumentException if the parcel has no more data or is otherwise corrupt. |
| 602 | */ |
| 603 | @FastNative |
| 604 | @NonNull |
| 605 | public native final HidlMemory readHidlMemory(); |
| 606 | |
| 607 | /** |
| 608 | * Reads an embedded HidlMemory (without duplicating the underlying |
| 609 | * file descriptors) from the parcel. These file descriptors will only |
| 610 | * be open for the duration that the binder window is open. If they |
| 611 | * are needed further, you must call {@link HidlMemory#dup()}. You |
| 612 | * do not need to call close on the HidlMemory returned from this. |
| 613 | * |
| 614 | * @param fieldHandle handle of the field, obtained from the {@link HwBlob}. |
| 615 | * @param parentHandle parentHandle from which to read the embedded object |
| 616 | * @param offset offset into parent |
| 617 | * @return a {@link HidlMemory} instance parsed from the parcel |
| 618 | * @throws IllegalArgumentException if the parcel has no more data |
| 619 | */ |
| 620 | @FastNative |
| 621 | @NonNull |
| 622 | public native final @Nullable |
| 623 | HidlMemory readEmbeddedHidlMemory(long fieldHandle, long parentHandle, long offset); |
| 624 | |
| 625 | /** |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 626 | * Read opaque segment of data as a blob. |
| 627 | * @return blob of size expectedSize |
| 628 | * @throws IllegalArgumentException if the parcel has no more data |
| 629 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 630 | @FastNative |
Martijn Coenen | 932b504 | 2017-04-18 15:54:43 -0700 | [diff] [blame] | 631 | public native final HwBlob readBuffer(long expectedSize); |
Andreas Huber | 9266f99 | 2016-08-25 11:21:21 -0700 | [diff] [blame] | 632 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 633 | /** |
| 634 | * Read a buffer written using scatter gather. |
| 635 | * |
| 636 | * @param expectedSize size that buffer should be |
| 637 | * @param parentHandle handle from which to read the embedded buffer |
| 638 | * @param offset offset into parent |
| 639 | * @param nullable whether or not to allow for a null return |
| 640 | * @return blob of data with size expectedSize |
| 641 | * @throws NoSuchElementException if an embedded buffer is not available to read |
| 642 | * @throws IllegalArgumentException if expectedSize < 0 |
| 643 | * @throws NullPointerException if the transaction specified the blob to be null |
| 644 | * but nullable is false |
| 645 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 646 | @FastNative |
Andreas Huber | 9266f99 | 2016-08-25 11:21:21 -0700 | [diff] [blame] | 647 | public native final HwBlob readEmbeddedBuffer( |
Martijn Coenen | 932b504 | 2017-04-18 15:54:43 -0700 | [diff] [blame] | 648 | long expectedSize, long parentHandle, long offset, |
| 649 | boolean nullable); |
Andreas Huber | 9266f99 | 2016-08-25 11:21:21 -0700 | [diff] [blame] | 650 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 651 | /** |
| 652 | * Write a buffer into the transaction. |
| 653 | * @param blob blob to write into the parcel. |
| 654 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 655 | @FastNative |
Andreas Huber | 9266f99 | 2016-08-25 11:21:21 -0700 | [diff] [blame] | 656 | public native final void writeBuffer(HwBlob blob); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 657 | /** |
| 658 | * Write a status value into the blob. |
| 659 | * @param status value to write |
| 660 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 661 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 662 | public native final void writeStatus(int status); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 663 | /** |
| 664 | * @throws IllegalArgumentException if a success vaue cannot be read |
| 665 | * @throws RemoteException if success value indicates a transaction error |
| 666 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 667 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 668 | public native final void verifySuccess(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 669 | /** |
| 670 | * Should be called to reduce memory pressure when this object no longer needs |
| 671 | * to be written to. |
| 672 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 673 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 674 | public native final void releaseTemporaryStorage(); |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 675 | /** |
| 676 | * Should be called when object is no longer needed to reduce possible memory |
| 677 | * pressure if the Java GC does not get to this object in time. |
| 678 | */ |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 679 | @FastNative |
Martijn Coenen | 3d726d1 | 2017-03-16 18:46:42 +0100 | [diff] [blame] | 680 | public native final void release(); |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 681 | |
Steven Moreland | 4dde8a1 | 2018-01-10 15:45:36 -0800 | [diff] [blame] | 682 | /** |
| 683 | * Sends the parcel to the specified destination. |
| 684 | */ |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 685 | public native final void send(); |
| 686 | |
| 687 | // Returns address of the "freeFunction". |
| 688 | private static native final long native_init(); |
| 689 | |
Daniel Colascione | c94b8c3 | 2019-10-08 11:47:41 -0700 | [diff] [blame] | 690 | @FastNative |
Andreas Huber | dab5fc6 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 691 | private native final void native_setup(boolean allocate); |
| 692 | |
| 693 | static { |
| 694 | long freeFunction = native_init(); |
| 695 | |
| 696 | sNativeRegistry = new NativeAllocationRegistry( |
| 697 | HwParcel.class.getClassLoader(), |
| 698 | freeFunction, |
| 699 | 128 /* size */); |
| 700 | } |
| 701 | |
| 702 | private long mNativeContext; |
| 703 | } |
| 704 | |