1 /* 2 * Copyright (C) 2023 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 #pragma once 18 19 #include <android/binder_parcel.h> 20 #include <stdbool.h> 21 #include <stdint.h> 22 #include <sys/cdefs.h> 23 #include <sys/types.h> 24 25 #ifndef __clang__ 26 #define _Nullable 27 #define _Nonnull 28 #endif 29 30 __BEGIN_DECLS 31 32 /* 33 * A mapping from string keys to values of various types. 34 * See frameworks/base/core/java/android/os/PersistableBundle.java 35 * for the Java type than can be used in SDK APIs. 36 * APersistableBundle exists to be used in AIDL interfaces and seamlessly 37 * interact with framework services. 38 * frameworks/native/libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h 39 * contains the AIDL type used in the ndk backend of AIDL interfaces. 40 */ 41 struct APersistableBundle; 42 typedef struct APersistableBundle APersistableBundle; 43 44 enum { 45 /** 46 * This can be returned from functions that need to distinguish between an empty 47 * value and a non-existent key. 48 */ 49 APERSISTABLEBUNDLE_KEY_NOT_FOUND = -1, 50 51 /** 52 * This can be returned from functions that take a APersistableBundle_stringAllocator. 53 * This means the allocator has failed and returned a nullptr. 54 */ 55 APERSISTABLEBUNDLE_ALLOCATOR_FAILED = -2, 56 }; 57 58 /** 59 * This is a user supplied allocator that allocates a buffer for the 60 * APersistableBundle APIs to fill in with a UTF-8 string. 61 * The caller that supplies this function is responsible for freeing the 62 * returned data. 63 * 64 * \param the required size in bytes for the allocated buffer 65 * \param context pointer if needed by the callback 66 * 67 * \return allocated buffer of sizeBytes for a UTF-8 string. Null if allocation failed. 68 */ 69 typedef char* _Nullable (*_Nonnull APersistableBundle_stringAllocator)(int32_t sizeBytes, 70 void* _Nullable context); 71 72 /** 73 * Create a new APersistableBundle. 74 * 75 * Available since API level 202404. 76 * 77 * \return Pointer to a new APersistableBundle 78 */ 79 APersistableBundle* _Nullable APersistableBundle_new() __INTRODUCED_IN(__ANDROID_API_V__); 80 81 /** 82 * Create a new APersistableBundle based off an existing APersistableBundle. 83 * This is a deep copy, so the new APersistableBundle has its own values from 84 * copying the original underlying PersistableBundle. 85 * 86 * Available since API level 202404. 87 * 88 * \param pBundle to duplicate 89 * 90 * \return Pointer to a new APersistableBundle 91 */ 92 APersistableBundle* _Nullable APersistableBundle_dup(const APersistableBundle* _Nonnull pBundle) 93 __INTRODUCED_IN(__ANDROID_API_V__); 94 95 /** 96 * Delete an APersistableBundle. This must always be called when finished using 97 * the object. 98 * 99 * \param pBundle to delete. No-op if null. 100 * 101 * Available since API level 202404. 102 */ 103 void APersistableBundle_delete(APersistableBundle* _Nullable pBundle) 104 __INTRODUCED_IN(__ANDROID_API_V__); 105 106 /** 107 * Check for equality of APersistableBundles. 108 * 109 * Available since API level 202404. 110 * 111 * \param lhs bundle to compare against the other param 112 * \param rhs bundle to compare against the other param 113 * 114 * \return true when equal, false when not 115 */ 116 bool APersistableBundle_isEqual(const APersistableBundle* _Nonnull lhs, 117 const APersistableBundle* _Nonnull rhs) 118 __INTRODUCED_IN(__ANDROID_API_V__); 119 120 /** 121 * Read an APersistableBundle from an AParcel. 122 * 123 * Available since API level 202404. 124 * 125 * \param parcel to read from 126 * \param outPBundle bundle to write to 127 * 128 * \return STATUS_OK on success 129 * STATUS_BAD_VALUE if the parcel or outBuffer is null, or if there's an 130 * issue deserializing (eg, corrupted parcel) 131 * STATUS_BAD_TYPE if the parcel's current data position is not that of 132 * an APersistableBundle type 133 * STATUS_NO_MEMORY if an allocation fails 134 */ 135 binder_status_t APersistableBundle_readFromParcel( 136 const AParcel* _Nonnull parcel, APersistableBundle* _Nullable* _Nonnull outPBundle) 137 __INTRODUCED_IN(__ANDROID_API_V__); 138 139 /** 140 * Write an APersistableBundle to an AParcel. 141 * 142 * Available since API level 202404. 143 * 144 * \param pBundle bundle to write to the parcel 145 * \param parcel to write to 146 * 147 * \return STATUS_OK on success. 148 * STATUS_BAD_VALUE if either pBundle or parcel is null, or if the 149 * APersistableBundle* 150 * fails to serialize (eg, internally corrupted) 151 * STATUS_NO_MEMORY if the parcel runs out of space to store the pBundle & is 152 * unable to allocate more 153 * STATUS_FDS_NOT_ALLOWED if the parcel does not allow storing FDs 154 */ 155 binder_status_t APersistableBundle_writeToParcel(const APersistableBundle* _Nonnull pBundle, 156 AParcel* _Nonnull parcel) 157 __INTRODUCED_IN(__ANDROID_API_V__); 158 159 /** 160 * Get the size of an APersistableBundle. This is the number of mappings in the 161 * object. 162 * 163 * Available since API level 202404. 164 * 165 * \param pBundle to get the size of (number of mappings) 166 * 167 * \return number of mappings in the object 168 */ 169 int32_t APersistableBundle_size(const APersistableBundle* _Nonnull pBundle) 170 __INTRODUCED_IN(__ANDROID_API_V__); 171 172 /** 173 * Erase any entries added with the provided key. 174 * 175 * Available since API level 202404. 176 * 177 * \param pBundle to operate on 178 * \param key for the mapping in UTF-8 to erase 179 * 180 * \return number of entries erased. Either 0 or 1. 181 */ 182 int32_t APersistableBundle_erase(APersistableBundle* _Nonnull pBundle, const char* _Nonnull key) 183 __INTRODUCED_IN(__ANDROID_API_V__); 184 185 /** 186 * Put a boolean associated with the provided key. 187 * New values with the same key will overwrite existing values. 188 * 189 * \param pBundle to operate on 190 * \param key for the mapping in UTF-8 191 * \param value to put for the mapping 192 * 193 * Available since API level 202404. 194 */ 195 void APersistableBundle_putBoolean(APersistableBundle* _Nonnull pBundle, const char* _Nonnull key, 196 bool val) __INTRODUCED_IN(__ANDROID_API_V__); 197 198 /** 199 * Put an int32_t associated with the provided key. 200 * New values with the same key will overwrite existing values. 201 * 202 * \param pBundle to operate on 203 * \param key for the mapping in UTF-8 204 * \param val value to put for the mapping 205 * 206 * Available since API level 202404. 207 */ 208 void APersistableBundle_putInt(APersistableBundle* _Nonnull pBundle, const char* _Nonnull key, 209 int32_t val) __INTRODUCED_IN(__ANDROID_API_V__); 210 211 /** 212 * Put an int64_t associated with the provided key. 213 * New values with the same key will overwrite existing values. 214 * 215 * \param pBundle to operate on 216 * \param key for the mapping in UTF-8 217 * \param val value to put for the mapping 218 * 219 * Available since API level 202404. 220 */ 221 void APersistableBundle_putLong(APersistableBundle* _Nonnull pBundle, const char* _Nonnull key, 222 int64_t val) __INTRODUCED_IN(__ANDROID_API_V__); 223 224 /** 225 * Put a double associated with the provided key. 226 * New values with the same key will overwrite existing values. 227 * 228 * \param pBundle to operate on 229 * \param key for the mapping in UTF-8 230 * \param val value to put for the mapping 231 * 232 * Available since API level 202404. 233 */ 234 void APersistableBundle_putDouble(APersistableBundle* _Nonnull pBundle, const char* _Nonnull key, 235 double val) __INTRODUCED_IN(__ANDROID_API_V__); 236 237 /** 238 * Put a string associated with the provided key. 239 * New values with the same key will overwrite existing values. 240 * The value is copied. 241 * 242 * \param pBundle to operate on 243 * \param key for the mapping in UTF-8 244 * \param vec vector to put for the mapping 245 * 246 * Available since API level 202404. 247 */ 248 void APersistableBundle_putString(APersistableBundle* _Nonnull pBundle, const char* _Nonnull key, 249 const char* _Nonnull val) __INTRODUCED_IN(__ANDROID_API_V__); 250 251 /** 252 * Put a boolean vector associated with the provided key. 253 * New values with the same key will overwrite existing values. 254 * The values are copied. 255 * 256 * \param pBundle to operate on 257 * \param key for the mapping in UTF-8 258 * \param vec vector to put for the mapping 259 * \param num number of elements in the vector 260 * 261 * Available since API level 202404. 262 */ 263 void APersistableBundle_putBooleanVector(APersistableBundle* _Nonnull pBundle, 264 const char* _Nonnull key, const bool* _Nonnull vec, 265 int32_t num) __INTRODUCED_IN(__ANDROID_API_V__); 266 267 /** 268 * Put an int32_t vector associated with the provided key. 269 * New values with the same key will overwrite existing values. 270 * The values are copied. 271 * 272 * \param pBundle to operate on 273 * \param key for the mapping in UTF-8 274 * \param vec vector to put for the mapping 275 * \param num number of elements in the vector 276 * 277 * Available since API level 202404. 278 */ 279 void APersistableBundle_putIntVector(APersistableBundle* _Nonnull pBundle, const char* _Nonnull key, 280 const int32_t* _Nonnull vec, int32_t num) 281 __INTRODUCED_IN(__ANDROID_API_V__); 282 283 /** 284 * Put an int64_t vector associated with the provided key. 285 * New values with the same key will overwrite existing values. 286 * The values are copied. 287 * 288 * \param pBundle to operate on 289 * \param key for the mapping in UTF-8 290 * \param vec vector to put for the mapping 291 * \param num number of elements in the vector 292 * 293 * Available since API level 202404. 294 */ 295 void APersistableBundle_putLongVector(APersistableBundle* _Nonnull pBundle, 296 const char* _Nonnull key, const int64_t* _Nonnull vec, 297 int32_t num) __INTRODUCED_IN(__ANDROID_API_V__); 298 299 /** 300 * Put a double vector associated with the provided key. 301 * New values with the same key will overwrite existing values. 302 * The values are copied. 303 * 304 * \param pBundle to operate on 305 * \param key for the mapping in UTF-8 306 * \param vec vector to put for the mapping 307 * \param num number of elements in the vector 308 * 309 * Available since API level 202404. 310 */ 311 void APersistableBundle_putDoubleVector(APersistableBundle* _Nonnull pBundle, 312 const char* _Nonnull key, const double* _Nonnull vec, 313 int32_t num) __INTRODUCED_IN(__ANDROID_API_V__); 314 315 /** 316 * Put a string vector associated with the provided key. 317 * New values with the same key will overwrite existing values. 318 * The values are copied. 319 * 320 * \param pBundle to operate on 321 * \param key for the mapping in UTF-8 322 * \param vec vector to put for the mapping 323 * \param num number of elements in the vector 324 * 325 * Available since API level 202404. 326 */ 327 void APersistableBundle_putStringVector(APersistableBundle* _Nonnull pBundle, 328 const char* _Nonnull key, 329 const char* _Nullable const* _Nullable vec, int32_t num) 330 __INTRODUCED_IN(__ANDROID_API_V__); 331 332 /** 333 * Put an APersistableBundle associated with the provided key. 334 * New values with the same key will overwrite existing values. 335 * The value is deep-copied. 336 * 337 * \param pBundle to operate on 338 * \param key for the mapping in UTF-8 339 * \param val value to put for the mapping 340 * 341 * Available since API level 202404. 342 */ 343 void APersistableBundle_putPersistableBundle(APersistableBundle* _Nonnull pBundle, 344 const char* _Nonnull key, 345 const APersistableBundle* _Nonnull val) 346 __INTRODUCED_IN(__ANDROID_API_V__); 347 348 /** 349 * Get a boolean associated with the provided key. 350 * 351 * Available since API level 202404. 352 * 353 * \param pBundle to operate on 354 * \param key for the mapping in UTF-8 355 * \param val pointer to write the value to 356 * 357 * \return true if a value exists for the provided key 358 */ 359 bool APersistableBundle_getBoolean(const APersistableBundle* _Nonnull pBundle, 360 const char* _Nonnull key, bool* _Nonnull val) 361 __INTRODUCED_IN(__ANDROID_API_V__); 362 363 /** 364 * Get an int32_t associated with the provided key. 365 * 366 * Available since API level 202404. 367 * 368 * \param pBundle to operate on 369 * \param key for the mapping in UTF-8 370 * \param val pointer to write the value to 371 * 372 * \return true if a value exists for the provided key 373 */ 374 bool APersistableBundle_getInt(const APersistableBundle* _Nonnull pBundle, const char* _Nonnull key, 375 int32_t* _Nonnull val) __INTRODUCED_IN(__ANDROID_API_V__); 376 377 /** 378 * Get an int64_t associated with the provided key. 379 * 380 * Available since API level 202404. 381 * 382 * \param pBundle to operate on 383 * \param key for the mapping in UTF-8 384 * \param val pointer to write the value to 385 * 386 * \return true if a value exists for the provided key 387 */ 388 bool APersistableBundle_getLong(const APersistableBundle* _Nonnull pBundle, 389 const char* _Nonnull key, int64_t* _Nonnull val) 390 __INTRODUCED_IN(__ANDROID_API_V__); 391 392 /** 393 * Get a double associated with the provided key. 394 * 395 * Available since API level 202404. 396 * 397 * \param pBundle to operate on 398 * \param key for the mapping in UTF-8 399 * \param val pointer to write the value to 400 * 401 * \return true if a value exists for the provided key 402 */ 403 bool APersistableBundle_getDouble(const APersistableBundle* _Nonnull pBundle, 404 const char* _Nonnull key, double* _Nonnull val) 405 __INTRODUCED_IN(__ANDROID_API_V__); 406 407 /** 408 * Get a string associated with the provided key. 409 * The caller is responsible for freeing the returned data. 410 * 411 * Available since API level 202404. 412 * 413 * \param pBundle to operate on 414 * \param key for the mapping in UTF-8 415 * \param val pointer to write the value to in UTF-8 416 * \param stringAllocator function pointer to the string allocator 417 * \param context pointer that will be passed to the stringAllocator 418 * 419 * \return size of string in bytes associated with the provided key on success 420 * APERSISTABLEBUNDLE_KEY_NOT_FOUND if the key was not found 421 * APERSISTABLEBUNDLE_ALLOCATOR_FAILED if the provided allocator fails 422 */ 423 int32_t APersistableBundle_getString(const APersistableBundle* _Nonnull pBundle, 424 const char* _Nonnull key, char* _Nullable* _Nonnull val, 425 APersistableBundle_stringAllocator stringAllocator, 426 void* _Nullable context) __INTRODUCED_IN(__ANDROID_API_V__); 427 428 /** 429 * Get a boolean vector associated with the provided key and place it in the 430 * provided pre-allocated buffer from the user. 431 * 432 * This function returns the size in bytes of stored vector. 433 * The supplied buffer will be filled in based on the smaller of the supplied 434 * bufferSizeBytes or the actual size of the stored data. 435 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 436 * actual stored data, then not all of the stored data will be returned. 437 * 438 * Users can call this function with null buffer and 0 bufferSizeBytes to get 439 * the required size of the buffer to use on a subsequent call. 440 * 441 * \param pBundle to operate on 442 * \param key for the mapping in UTF-8 443 * \param buffer pointer to a pre-allocated buffer to write the values to 444 * \param bufferSizeBytes size of the pre-allocated buffer 445 * 446 * \return size of the stored vector in bytes. This is the required size of the 447 * pre-allocated user supplied buffer if all of the stored contents are desired. 448 * APERSISTABLEBUNDLE_KEY_NOT_FOUND if the key was not found 449 */ 450 int32_t APersistableBundle_getBooleanVector(const APersistableBundle* _Nonnull pBundle, 451 const char* _Nonnull key, bool* _Nullable buffer, 452 int32_t bufferSizeBytes) 453 __INTRODUCED_IN(__ANDROID_API_V__); 454 455 /** 456 * Get an int32_t vector associated with the provided key and place it in the 457 * provided pre-allocated buffer from the user. 458 * 459 * This function returns the size in bytes of stored vector. 460 * The supplied buffer will be filled in based on the smaller of the supplied 461 * bufferSizeBytes or the actual size of the stored data. 462 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 463 * actual stored data, then not all of the stored data will be returned. 464 * 465 * Users can call this function with null buffer and 0 bufferSizeBytes to get 466 * the required size of the buffer to use on a subsequent call. 467 * 468 * \param pBundle to operate on 469 * \param key for the mapping in UTF-8 470 * \param buffer pointer to a pre-allocated buffer to write the values to 471 * \param bufferSizeBytes size of the pre-allocated buffer 472 * 473 * \return size of the stored vector in bytes. This is the required size of the 474 * pre-allocated user supplied buffer if all of the stored contents are desired. 475 * APERSISTABLEBUNDLE_KEY_NOT_FOUND if the key was not found 476 */ 477 int32_t APersistableBundle_getIntVector(const APersistableBundle* _Nonnull pBundle, 478 const char* _Nonnull key, int32_t* _Nullable buffer, 479 int32_t bufferSizeBytes) __INTRODUCED_IN(__ANDROID_API_V__); 480 481 /** 482 * Get an int64_t vector associated with the provided key and place it in the 483 * provided pre-allocated buffer from the user. 484 * 485 * This function returns the size in bytes of stored vector. 486 * The supplied buffer will be filled in based on the smaller of the supplied 487 * bufferSizeBytes or the actual size of the stored data. 488 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 489 * actual stored data, then not all of the stored data will be returned. 490 * 491 * Users can call this function with null buffer and 0 bufferSizeBytes to get 492 * the required size of the buffer to use on a subsequent call. 493 * 494 * \param pBundle to operate on 495 * \param key for the mapping in UTF-8 496 * \param buffer pointer to a pre-allocated buffer to write the values to 497 * \param bufferSizeBytes size of the pre-allocated buffer 498 * 499 * \return size of the stored vector in bytes. This is the required size of the 500 * pre-allocated user supplied buffer if all of the stored contents are desired. 501 * APERSISTABLEBUNDLE_KEY_NOT_FOUND if the key was not found 502 */ 503 int32_t APersistableBundle_getLongVector(const APersistableBundle* _Nonnull pBundle, 504 const char* _Nonnull key, int64_t* _Nullable buffer, 505 int32_t bufferSizeBytes) 506 __INTRODUCED_IN(__ANDROID_API_V__); 507 508 /** 509 * Get a double vector associated with the provided key and place it in the 510 * provided pre-allocated buffer from the user. 511 * 512 * This function returns the size in bytes of stored vector. 513 * The supplied buffer will be filled in based on the smaller of the supplied 514 * bufferSizeBytes or the actual size of the stored data. 515 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 516 * actual stored data, then not all of the stored data will be returned. 517 * 518 * Users can call this function with null buffer and 0 bufferSizeBytes to get 519 * the required size of the buffer to use on a subsequent call. 520 * 521 * \param pBundle to operate on 522 * \param key for the mapping in UTF-8 523 * \param buffer pointer to a pre-allocated buffer to write the values to 524 * \param bufferSizeBytes size of the pre-allocated buffer 525 * 526 * \return size of the stored vector in bytes. This is the required size of the 527 * pre-allocated user supplied buffer if all of the stored contents are desired. 528 * APERSISTABLEBUNDLE_KEY_NOT_FOUND if the key was not found 529 */ 530 int32_t APersistableBundle_getDoubleVector(const APersistableBundle* _Nonnull pBundle, 531 const char* _Nonnull key, double* _Nullable buffer, 532 int32_t bufferSizeBytes) 533 __INTRODUCED_IN(__ANDROID_API_V__); 534 535 /** 536 * Get a string vector associated with the provided key and place it in the 537 * provided pre-allocated buffer from the user. The user must provide an 538 * APersistableBundle_stringAllocator for the individual strings to be 539 * allocated. 540 * The caller is responsible for freeing the returned data. 541 * 542 * This function returns the size in bytes of stored vector. 543 * The supplied buffer will be filled in based on the smaller of the supplied 544 * bufferSizeBytes or the actual size of the stored data. 545 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 546 * actual stored data, then not all of the stored data will be returned. 547 * 548 * Users can call this function with null buffer and 0 bufferSizeBytes to get 549 * the required size of the buffer to use on a subsequent call. 550 * 551 * \param pBundle to operate on 552 * \param key for the mapping in UTF-8 553 * \param buffer pointer to a pre-allocated buffer to write the string pointers to 554 * \param bufferSizeBytes size of the pre-allocated buffer 555 * \param stringAllocator function pointer to the string allocator 556 * \param context pointer that will be passed to the stringAllocator 557 * 558 * \return size of the stored vector in bytes. This is the required size of the 559 * pre-allocated user supplied buffer if all of the stored contents are desired. 560 * 0 if no string vector exists for the provided key 561 * APERSISTABLEBUNDLE_KEY_NOT_FOUND if the key was not found 562 * APERSISTABLEBUNDLE_ALLOCATOR_FAILED if the provided allocator fails 563 */ 564 int32_t APersistableBundle_getStringVector(const APersistableBundle* _Nonnull pBundle, 565 const char* _Nonnull key, 566 char* _Nullable* _Nullable buffer, 567 int32_t bufferSizeBytes, 568 APersistableBundle_stringAllocator stringAllocator, 569 void* _Nullable context) 570 __INTRODUCED_IN(__ANDROID_API_V__); 571 572 /** 573 * Get an APersistableBundle* associated with the provided key. 574 * 575 * Available since API level 202404. 576 * 577 * \param pBundle to operate on 578 * \param key for the mapping in UTF-8 579 * \param val pointer to an APersistableBundle pointer to write to point to 580 * a new copy of the stored APersistableBundle. The caller takes ownership of 581 * the new APersistableBundle and must be deleted with 582 * APersistableBundle_delete. 583 * 584 * \return true if a value exists for the provided key 585 */ 586 bool APersistableBundle_getPersistableBundle(const APersistableBundle* _Nonnull pBundle, 587 const char* _Nonnull key, 588 APersistableBundle* _Nullable* _Nonnull outBundle) 589 __INTRODUCED_IN(__ANDROID_API_V__); 590 591 /** 592 * Get all of the keys associated with this specific type and place it in the 593 * provided pre-allocated buffer from the user. The user must provide an 594 * APersistableBundle_stringAllocator for the individual strings to be 595 * allocated. 596 * The caller is responsible for freeing the returned data. 597 * 598 * This function returns the size in bytes required to fit the fill list of keys. 599 * The supplied buffer will be filled in based on the smaller of the supplied 600 * bufferSizeBytes or the actual size of the stored data. 601 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 602 * actual stored data, then not all of the stored data will be returned. 603 * 604 * Users can call this function with null buffer and 0 bufferSizeBytes to get 605 * the required size of the buffer to use on a subsequent call. 606 * 607 * \param pBundle to operate on 608 * \param outKeys pointer to a pre-allocated buffer to write the UTF-8 keys to 609 * \param bufferSizeBytes size of the pre-allocated buffer 610 * \param stringAllocator function pointer to the string allocator 611 * \param context pointer that will be passed to the stringAllocator 612 * 613 * \return size of the buffer of keys in bytes. This is the required size of the 614 * pre-allocated user supplied buffer if all of the stored contents are desired. 615 * APERSISTABLEBUNDLE_ALLOCATOR_FAILED if the provided allocator fails 616 */ 617 int32_t APersistableBundle_getBooleanKeys(const APersistableBundle* _Nonnull pBundle, 618 char* _Nullable* _Nullable outKeys, 619 int32_t bufferSizeBytes, 620 APersistableBundle_stringAllocator stringAllocator, 621 void* _Nullable context) 622 __INTRODUCED_IN(__ANDROID_API_V__); 623 624 /** 625 * Get all of the keys associated with this specific type and place it in the 626 * provided pre-allocated buffer from the user. The user must provide an 627 * APersistableBundle_stringAllocator for the individual strings to be 628 * allocated. 629 * The caller is responsible for freeing the returned data. 630 * 631 * This function returns the size in bytes required to fit the fill list of keys. 632 * The supplied buffer will be filled in based on the smaller of the supplied 633 * bufferSizeBytes or the actual size of the stored data. 634 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 635 * actual stored data, then not all of the stored data will be returned. 636 * 637 * Users can call this function with null buffer and 0 bufferSizeBytes to get 638 * the required size of the buffer to use on a subsequent call. 639 * 640 * \param pBundle to operate on 641 * \param outKeys pointer to a pre-allocated buffer to write the UTF-8 keys to 642 * \param bufferSizeBytes size of the pre-allocated buffer 643 * \param stringAllocator function pointer to the string allocator 644 * \param context pointer that will be passed to the stringAllocator 645 * 646 * \return size of the buffer of keys in bytes. This is the required size of the 647 * pre-allocated user supplied buffer if all of the stored contents are desired. 648 * APERSISTABLEBUNDLE_ALLOCATOR_FAILED if the provided allocator fails 649 */ 650 int32_t APersistableBundle_getIntKeys(const APersistableBundle* _Nonnull pBundle, 651 char* _Nullable* _Nullable outKeys, int32_t bufferSizeBytes, 652 APersistableBundle_stringAllocator stringAllocator, 653 void* _Nullable context) __INTRODUCED_IN(__ANDROID_API_V__); 654 655 /** 656 * Get all of the keys associated with this specific type and place it in the 657 * provided pre-allocated buffer from the user. The user must provide an 658 * APersistableBundle_stringAllocator for the individual strings to be 659 * allocated. 660 * The caller is responsible for freeing the returned data. 661 * 662 * This function returns the size in bytes required to fit the fill list of keys. 663 * The supplied buffer will be filled in based on the smaller of the supplied 664 * bufferSizeBytes or the actual size of the stored data. 665 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 666 * actual stored data, then not all of the stored data will be returned. 667 * 668 * Users can call this function with null buffer and 0 bufferSizeBytes to get 669 * the required size of the buffer to use on a subsequent call. 670 * 671 * \param pBundle to operate on 672 * \param outKeys pointer to a pre-allocated buffer to write the UTF-8 keys to 673 * \param bufferSizeBytes size of the pre-allocated buffer 674 * \param stringAllocator function pointer to the string allocator 675 * \param context pointer that will be passed to the stringAllocator 676 * 677 * \return size of the buffer of keys in bytes. This is the required size of the 678 * pre-allocated user supplied buffer if all of the stored contents are desired. 679 * APERSISTABLEBUNDLE_ALLOCATOR_FAILED if the provided allocator fails 680 */ 681 int32_t APersistableBundle_getLongKeys(const APersistableBundle* _Nonnull pBundle, 682 char* _Nullable* _Nullable outKeys, int32_t bufferSizeBytes, 683 APersistableBundle_stringAllocator stringAllocator, 684 void* _Nullable context) __INTRODUCED_IN(__ANDROID_API_V__); 685 686 /** 687 * Get all of the keys associated with this specific type and place it in the 688 * provided pre-allocated buffer from the user. The user must provide an 689 * APersistableBundle_stringAllocator for the individual strings to be 690 * allocated. 691 * The caller is responsible for freeing the returned data. 692 * 693 * This function returns the size in bytes required to fit the fill list of keys. 694 * The supplied buffer will be filled in based on the smaller of the supplied 695 * bufferSizeBytes or the actual size of the stored data. 696 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 697 * actual stored data, then not all of the stored data will be returned. 698 * 699 * Users can call this function with null buffer and 0 bufferSizeBytes to get 700 * the required size of the buffer to use on a subsequent call. 701 * 702 * \param pBundle to operate on 703 * \param outKeys pointer to a pre-allocated buffer to write the UTF-8 keys to 704 * \param bufferSizeBytes size of the pre-allocated buffer 705 * \param stringAllocator function pointer to the string allocator 706 * \param context pointer that will be passed to the stringAllocator 707 * 708 * \return size of the buffer of keys in bytes. This is the required size of the 709 * pre-allocated user supplied buffer if all of the stored contents are desired. 710 * APERSISTABLEBUNDLE_ALLOCATOR_FAILED if the provided allocator fails 711 */ 712 int32_t APersistableBundle_getDoubleKeys(const APersistableBundle* _Nonnull pBundle, 713 char* _Nullable* _Nullable outKeys, 714 int32_t bufferSizeBytes, 715 APersistableBundle_stringAllocator stringAllocator, 716 void* _Nullable context) 717 __INTRODUCED_IN(__ANDROID_API_V__); 718 719 /** 720 * Get all of the keys associated with this specific type and place it in the 721 * provided pre-allocated buffer from the user. The user must provide an 722 * APersistableBundle_stringAllocator for the individual strings to be 723 * allocated. 724 * The caller is responsible for freeing the returned data. 725 * 726 * This function returns the size in bytes required to fit the fill list of keys. 727 * The supplied buffer will be filled in based on the smaller of the supplied 728 * bufferSizeBytes or the actual size of the stored data. 729 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 730 * actual stored data, then not all of the stored data will be returned. 731 * 732 * Users can call this function with null buffer and 0 bufferSizeBytes to get 733 * the required size of the buffer to use on a subsequent call. 734 * 735 * \param pBundle to operate on 736 * \param outKeys pointer to a pre-allocated buffer to write the UTF-8 keys to 737 * \param bufferSizeBytes size of the pre-allocated buffer 738 * \param stringAllocator function pointer to the string allocator 739 * \param context pointer that will be passed to the stringAllocator 740 * 741 * \return size of the buffer of keys in bytes. This is the required size of the 742 * pre-allocated user supplied buffer if all of the stored contents are desired. 743 * APERSISTABLEBUNDLE_ALLOCATOR_FAILED if the provided allocator fails 744 */ 745 int32_t APersistableBundle_getStringKeys(const APersistableBundle* _Nonnull pBundle, 746 char* _Nullable* _Nullable outKeys, 747 int32_t bufferSizeBytes, 748 APersistableBundle_stringAllocator stringAllocator, 749 void* _Nullable context) 750 __INTRODUCED_IN(__ANDROID_API_V__); 751 752 /** 753 * Get all of the keys associated with this specific type and place it in the 754 * provided pre-allocated buffer from the user. The user must provide an 755 * APersistableBundle_stringAllocator for the individual strings to be 756 * allocated. 757 * The caller is responsible for freeing the returned data. 758 * 759 * This function returns the size in bytes required to fit the fill list of keys. 760 * The supplied buffer will be filled in based on the smaller of the supplied 761 * bufferSizeBytes or the actual size of the stored data. 762 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 763 * actual stored data, then not all of the stored data will be returned. 764 * 765 * Users can call this function with null buffer and 0 bufferSizeBytes to get 766 * the required size of the buffer to use on a subsequent call. 767 * 768 * \param pBundle to operate on 769 * \param outKeys pointer to a pre-allocated buffer to write the UTF-8 keys to 770 * \param bufferSizeBytes size of the pre-allocated buffer 771 * \param stringAllocator function pointer to the string allocator 772 * \param context pointer that will be passed to the stringAllocator 773 * 774 * \return size of the buffer of keys in bytes. This is the required size of the 775 * pre-allocated user supplied buffer if all of the stored contents are desired. 776 * APERSISTABLEBUNDLE_ALLOCATOR_FAILED if the provided allocator fails 777 */ 778 int32_t APersistableBundle_getBooleanVectorKeys(const APersistableBundle* _Nonnull pBundle, 779 char* _Nullable* _Nullable outKeys, 780 int32_t bufferSizeBytes, 781 APersistableBundle_stringAllocator stringAllocator, 782 void* _Nullable context) 783 __INTRODUCED_IN(__ANDROID_API_V__); 784 785 /** 786 * Get all of the keys associated with this specific type and place it in the 787 * provided pre-allocated buffer from the user. The user must provide an 788 * APersistableBundle_stringAllocator for the individual strings to be 789 * allocated. 790 * The caller is responsible for freeing the returned data. 791 * 792 * This function returns the size in bytes required to fit the fill list of keys. 793 * The supplied buffer will be filled in based on the smaller of the supplied 794 * bufferSizeBytes or the actual size of the stored data. 795 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 796 * actual stored data, then not all of the stored data will be returned. 797 * 798 * Users can call this function with null buffer and 0 bufferSizeBytes to get 799 * the required size of the buffer to use on a subsequent call. 800 * 801 * \param pBundle to operate on 802 * \param outKeys pointer to a pre-allocated buffer to write the UTF-8 keys to 803 * \param bufferSizeBytes size of the pre-allocated buffer 804 * \param stringAllocator function pointer to the string allocator 805 * \param context pointer that will be passed to the stringAllocator 806 * 807 * \return size of the buffer of keys in bytes. This is the required size of the 808 * pre-allocated user supplied buffer if all of the stored contents are desired. 809 * APERSISTABLEBUNDLE_ALLOCATOR_FAILED if the provided allocator fails 810 */ 811 int32_t APersistableBundle_getIntVectorKeys(const APersistableBundle* _Nonnull pBundle, 812 char* _Nullable* _Nullable outKeys, 813 int32_t bufferSizeBytes, 814 APersistableBundle_stringAllocator stringAllocator, 815 void* _Nullable context) 816 __INTRODUCED_IN(__ANDROID_API_V__); 817 818 /** 819 * Get all of the keys associated with this specific type and place it in the 820 * provided pre-allocated buffer from the user. The user must provide an 821 * APersistableBundle_stringAllocator for the individual strings to be 822 * allocated. 823 * The caller is responsible for freeing the returned data. 824 * 825 * This function returns the size in bytes required to fit the fill list of keys. 826 * The supplied buffer will be filled in based on the smaller of the supplied 827 * bufferSizeBytes or the actual size of the stored data. 828 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 829 * actual stored data, then not all of the stored data will be returned. 830 * 831 * Users can call this function with null buffer and 0 bufferSizeBytes to get 832 * the required size of the buffer to use on a subsequent call. 833 * 834 * \param pBundle to operate on 835 * \param outKeys pointer to a pre-allocated buffer to write the UTF-8 keys to 836 * \param bufferSizeBytes size of the pre-allocated buffer 837 * \param stringAllocator function pointer to the string allocator 838 * \param context pointer that will be passed to the stringAllocator 839 * 840 * \return size of the buffer of keys in bytes. This is the required size of the 841 * pre-allocated user supplied buffer if all of the stored contents are desired. 842 * APERSISTABLEBUNDLE_ALLOCATOR_FAILED if the provided allocator fails 843 */ 844 int32_t APersistableBundle_getLongVectorKeys(const APersistableBundle* _Nonnull pBundle, 845 char* _Nullable* _Nullable outKeys, 846 int32_t bufferSizeBytes, 847 APersistableBundle_stringAllocator stringAllocator, 848 void* _Nullable context) 849 __INTRODUCED_IN(__ANDROID_API_V__); 850 851 /** 852 * Get all of the keys associated with this specific type and place it in the 853 * provided pre-allocated buffer from the user. The user must provide an 854 * APersistableBundle_stringAllocator for the individual strings to be 855 * allocated. 856 * The caller is responsible for freeing the returned data. 857 * 858 * This function returns the size in bytes required to fit the fill list of keys. 859 * The supplied buffer will be filled in based on the smaller of the supplied 860 * bufferSizeBytes or the actual size of the stored data. 861 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 862 * actual stored data, then not all of the stored data will be returned. 863 * 864 * Users can call this function with null buffer and 0 bufferSizeBytes to get 865 * the required size of the buffer to use on a subsequent call. 866 * 867 * \param pBundle to operate on 868 * \param outKeys pointer to a pre-allocated buffer to write the UTF-8 keys to 869 * \param bufferSizeBytes size of the pre-allocated buffer 870 * \param stringAllocator function pointer to the string allocator 871 * \param context pointer that will be passed to the stringAllocator 872 * 873 * \return size of the buffer of keys in bytes. This is the required size of the 874 * pre-allocated user supplied buffer if all of the stored contents are desired. 875 */ 876 int32_t APersistableBundle_getDoubleVectorKeys(const APersistableBundle* _Nonnull pBundle, 877 char* _Nullable* _Nullable outKeys, 878 int32_t bufferSizeBytes, 879 APersistableBundle_stringAllocator stringAllocator, 880 void* _Nullable context) 881 __INTRODUCED_IN(__ANDROID_API_V__); 882 883 /** 884 * Get all of the keys associated with this specific type and place it in the 885 * provided pre-allocated buffer from the user. The user must provide an 886 * APersistableBundle_stringAllocator for the individual strings to be 887 * allocated. 888 * The caller is responsible for freeing the returned data. 889 * 890 * This function returns the size in bytes required to fit the fill list of keys. 891 * The supplied buffer will be filled in based on the smaller of the supplied 892 * bufferSizeBytes or the actual size of the stored data. 893 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 894 * actual stored data, then not all of the stored data will be returned. 895 * 896 * Users can call this function with null buffer and 0 bufferSizeBytes to get 897 * the required size of the buffer to use on a subsequent call. 898 * 899 * \param pBundle to operate on 900 * \param outKeys pointer to a pre-allocated buffer to write the UTF-8 keys to 901 * \param bufferSizeBytes size of the pre-allocated buffer 902 * \param stringAllocator function pointer to the string allocator 903 * \param context pointer that will be passed to the stringAllocator 904 * 905 * \return size of the buffer of keys in bytes. This is the required size of the 906 * pre-allocated user supplied buffer if all of the stored contents are desired. 907 * false 908 */ 909 int32_t APersistableBundle_getStringVectorKeys(const APersistableBundle* _Nonnull pBundle, 910 char* _Nullable* _Nullable outKeys, 911 int32_t bufferSizeBytes, 912 APersistableBundle_stringAllocator stringAllocator, 913 void* _Nullable context) 914 __INTRODUCED_IN(__ANDROID_API_V__); 915 916 /** 917 * Get all of the keys associated with this specific type and place it in the 918 * provided pre-allocated buffer from the user. The user must provide an 919 * APersistableBundle_stringAllocator for the individual strings to be 920 * allocated. 921 * The caller is responsible for freeing the returned data in bytes. 922 * 923 * This function returns the size in bytes required to fit the fill list of keys. 924 * The supplied buffer will be filled in based on the smaller of the supplied 925 * bufferSizeBytes or the actual size of the stored data. 926 * If the buffer is null or if the supplied bufferSizeBytes is smaller than the 927 * actual stored data, then not all of the stored data will be returned. 928 * 929 * Users can call this function with null buffer and 0 bufferSizeBytes to get 930 * the required size of the buffer to use on a subsequent call. 931 * 932 * \param pBundle to operate on 933 * \param outKeys pointer to a pre-allocated buffer to write the UTF-8 keys to 934 * \param bufferSizeBytes size of the pre-allocated buffer 935 * \param stringAllocator function pointer to the string allocator 936 * \param context pointer that will be passed to the stringAllocator 937 * 938 * \return size of the buffer of keys in bytes. This is the required size of the 939 * pre-allocated user supplied buffer if all of the stored contents are desired. 940 * APERSISTABLEBUNDLE_ALLOCATOR_FAILED if the provided allocator fails 941 */ 942 int32_t APersistableBundle_getPersistableBundleKeys( 943 const APersistableBundle* _Nonnull pBundle, char* _Nullable* _Nullable outKeys, 944 int32_t bufferSizeBytes, APersistableBundle_stringAllocator stringAllocator, 945 void* _Nullable context) __INTRODUCED_IN(__ANDROID_API_V__); 946 947 __END_DECLS 948