The open source OpenXR runtime
at main 614 lines 16 kB view raw
1// Copyright 2020-2025, Collabora, Ltd. 2// SPDX-License-Identifier: BSL-1.0 3// Author: Rylie Pavlik <rylie.pavlik@collabora.com> 4 5#pragma once 6 7#include "ObjectWrapperBase.h" 8#include <string> 9 10namespace wrap { 11namespace android::content { 12class ComponentName; 13class ContentResolver; 14class Context; 15class Intent; 16} // namespace android::content 17 18namespace android::content::pm { 19class PackageManager; 20} // namespace android::content::pm 21 22namespace android::database { 23class Cursor; 24} // namespace android::database 25 26namespace android::net { 27class Uri; 28class Uri_Builder; 29} // namespace android::net 30 31namespace android::os { 32class Bundle; 33} // namespace android::os 34 35namespace android::view { 36class Display; 37} // namespace android::view 38 39namespace java::io { 40class File; 41} // namespace java::io 42 43namespace java::lang { 44class Class; 45class ClassLoader; 46} // namespace java::lang 47 48} // namespace wrap 49 50namespace wrap { 51namespace android::content { 52/*! 53 * Wrapper for android.content.Context objects. 54 */ 55class Context : public ObjectWrapperBase { 56 public: 57 using ObjectWrapperBase::ObjectWrapperBase; 58 static constexpr const char *getTypeName() noexcept { 59 return "android/content/Context"; 60 } 61 62 /*! 63 * Getter for the DISPLAY_SERVICE static field value 64 * 65 * Java prototype: 66 * `public static final java.lang.String DISPLAY_SERVICE;` 67 * 68 * JNI signature: Ljava/lang/String; 69 * 70 */ 71 static std::string DISPLAY_SERVICE(); 72 73 /*! 74 * Getter for the WINDOW_SERVICE static field value 75 * 76 * Java prototype: 77 * `public static final java.lang.String WINDOW_SERVICE;` 78 * 79 * JNI signature: Ljava/lang/String; 80 * 81 */ 82 static std::string WINDOW_SERVICE(); 83 84 /*! 85 * Wrapper for the getPackageManager method 86 * 87 * Java prototype: 88 * `public abstract android.content.pm.PackageManager getPackageManager();` 89 * 90 * JNI signature: ()Landroid/content/pm/PackageManager; 91 * 92 */ 93 pm::PackageManager getPackageManager(); 94 95 /*! 96 * Wrapper for the getPackageName method 97 * 98 * Java prototype: 99 * `public abstract android.content.Context getPackageName();` 100 * 101 * JNI signature: ()Ljava/lang/String; 102 * 103 */ 104 std::string getPackageName(); 105 106 /*! 107 * Wrapper for the getContentResolver method 108 * 109 * Java prototype: 110 * `public abstract android.content.ContentResolver getContentResolver();` 111 * 112 * JNI signature: ()Landroid/content/ContentResolver; 113 * 114 */ 115 ContentResolver getContentResolver() const; 116 117 /*! 118 * Wrapper for the getApplicationContext method 119 * 120 * Java prototype: 121 * `public abstract android.content.Context getApplicationContext();` 122 * 123 * JNI signature: ()Landroid/content/Context; 124 * 125 */ 126 Context getApplicationContext(); 127 128 /*! 129 * Wrapper for the getClassLoader method 130 * 131 * Java prototype: 132 * `public abstract java.lang.ClassLoader getClassLoader();` 133 * 134 * JNI signature: ()Ljava/lang/ClassLoader; 135 * 136 */ 137 java::lang::ClassLoader getClassLoader(); 138 139 /*! 140 * Wrapper for the getExternalFilesDir method 141 * 142 * Java prototype: 143 * `public abstract java.io.File getExternalFilesDir(java.lang.String);` 144 * 145 * JNI signature: (Ljava/lang/String;)Ljava/io/File; 146 * 147 */ 148 java::io::File getExternalFilesDir(std::string const &type); 149 150 /*! 151 * Wrapper for the getFilesDir method 152 * 153 * Java prototype: 154 * `public abstract java.io.File getFilesDir();` 155 * 156 * JNI signature: ()Ljava/io/File; 157 * 158 */ 159 java::io::File getFilesDir(); 160 161 /*! 162 * Wrapper for the startActivity method 163 * 164 * Java prototype: 165 * `public abstract void startActivity(android.content.Intent);` 166 * 167 * JNI signature: (Landroid/content/Intent;)V 168 * 169 */ 170 void startActivity(Intent const &intent); 171 172 /*! 173 * Wrapper for the startActivity method 174 * 175 * Java prototype: 176 * `public abstract void startActivity(android.content.Intent, 177 * android.os.Bundle);` 178 * 179 * JNI signature: (Landroid/content/Intent;Landroid/os/Bundle;)V 180 * 181 */ 182 void startActivity(Intent const &intent, os::Bundle const &bundle); 183 184 /*! 185 * Wrapper for the getSystemService method 186 * 187 * Java prototype: 188 * `public abstract java.lang.Object getSystemService(java.lang.String);` 189 * 190 * JNI signature: (Ljava/lang/String;)Ljava/lang/Object; 191 * 192 */ 193 jni::Object getSystemService(std::string const &name); 194 195 /*! 196 * Wrapper for the createPackageContext method 197 * 198 * Java prototype: 199 * `public abstract android.content.Context 200 * createPackageContext(java.lang.String, int) throws 201 * android.content.pm.PackageManager$NameNotFoundException;` 202 * 203 * JNI signature: (Ljava/lang/String;I)Landroid/content/Context; 204 * 205 */ 206 Context createPackageContext(std::string const &packageName, int32_t flags); 207 208 /*! 209 * Wrapper for the createDisplayContext method 210 * 211 * Java prototype: 212 * `public abstract android.content.Context 213 * createDisplayContext(android.view.Display);` 214 * 215 * JNI signature: (Landroid/view/Display;)Landroid/content/Context; 216 * 217 */ 218 Context createDisplayContext(view::Display const &display); 219 220 enum { 221 CONTEXT_INCLUDE_CODE = 1, 222 CONTEXT_IGNORE_SECURITY = 2, 223 }; 224 225 /*! 226 * Class metadata 227 */ 228 struct Meta : public MetaBaseDroppable { 229 impl::StaticFieldId<std::string> DISPLAY_SERVICE; 230 impl::StaticFieldId<std::string> WINDOW_SERVICE; 231 jni::method_t getPackageManager; 232 jni::method_t getPackageName; 233 jni::method_t getContentResolver; 234 jni::method_t getApplicationContext; 235 jni::method_t getClassLoader; 236 jni::method_t getExternalFilesDir; 237 jni::method_t getFilesDir; 238 jni::method_t startActivity; 239 jni::method_t startActivity1; 240 jni::method_t getSystemService; 241 jni::method_t createPackageContext; 242 jni::method_t createDisplayContext; 243 244 /*! 245 * Singleton accessor 246 */ 247 static Meta &data(bool deferDrop = false) { 248 static Meta instance{deferDrop}; 249 return instance; 250 } 251 252 private: 253 explicit Meta(bool deferDrop); 254 }; 255}; 256 257/*! 258 * Wrapper for android.content.ContentUris objects. 259 */ 260class ContentUris : public ObjectWrapperBase { 261 public: 262 using ObjectWrapperBase::ObjectWrapperBase; 263 static constexpr const char *getTypeName() noexcept { 264 return "android/content/ContentUris"; 265 } 266 267 /*! 268 * Wrapper for the appendId static method 269 * 270 * Java prototype: 271 * `public static android.net.Uri$Builder appendId(android.net.Uri$Builder, 272 * long);` 273 * 274 * JNI signature: (Landroid/net/Uri$Builder;J)Landroid/net/Uri$Builder; 275 * 276 */ 277 static net::Uri_Builder appendId(net::Uri_Builder &uri_Builder, 278 long long longParam); 279 280 /*! 281 * Class metadata 282 */ 283 struct Meta : public MetaBaseDroppable { 284 jni::method_t appendId; 285 286 /*! 287 * Singleton accessor 288 */ 289 static Meta &data(bool deferDrop = false) { 290 static Meta instance{deferDrop}; 291 return instance; 292 } 293 294 private: 295 explicit Meta(bool deferDrop); 296 }; 297}; 298 299/*! 300 * Wrapper for android.content.ComponentName objects. 301 */ 302class ComponentName : public ObjectWrapperBase { 303 public: 304 using ObjectWrapperBase::ObjectWrapperBase; 305 static constexpr const char *getTypeName() noexcept { 306 return "android/content/ComponentName"; 307 } 308 309 /*! 310 * Wrapper for a constructor 311 * 312 * Java prototype: 313 * `public android.content.ComponentName(java.lang.String, 314 * java.lang.String);` 315 * 316 * JNI signature: (Ljava/lang/String;Ljava/lang/String;)V 317 * 318 */ 319 static ComponentName construct(std::string const &pkg, 320 std::string const &className); 321 322 /*! 323 * Wrapper for a constructor 324 * 325 * Java prototype: 326 * `public android.content.ComponentName(android.content.Context, 327 * java.lang.String);` 328 * 329 * JNI signature: (Landroid/content/Context;Ljava/lang/String;)V 330 * 331 */ 332 static ComponentName construct(Context const &context, 333 std::string const &className); 334 335 /*! 336 * Wrapper for a constructor 337 * 338 * Java prototype: 339 * `public android.content.ComponentName(android.content.Context, 340 * java.lang.Class<?>);` 341 * 342 * JNI signature: (Landroid/content/Context;Ljava/lang/Class;)V 343 * 344 */ 345 static ComponentName construct(Context const &context, 346 java::lang::Class const &cls); 347 348 /*! 349 * Wrapper for a constructor 350 * 351 * Java prototype: 352 * `public android.content.ComponentName(android.os.Parcel);` 353 * 354 * JNI signature: (Landroid/os/Parcel;)V 355 * 356 */ 357 static ComponentName construct(jni::Object const &parcel); 358 359 /*! 360 * Class metadata 361 */ 362 struct Meta : public MetaBase { 363 jni::method_t init; 364 jni::method_t init1; 365 jni::method_t init2; 366 jni::method_t init3; 367 368 /*! 369 * Singleton accessor 370 */ 371 static Meta &data() { 372 static Meta instance{}; 373 return instance; 374 } 375 376 private: 377 Meta(); 378 }; 379}; 380 381/*! 382 * Wrapper for android.content.Intent objects. 383 */ 384class Intent : public ObjectWrapperBase { 385 public: 386 using ObjectWrapperBase::ObjectWrapperBase; 387 static constexpr const char *getTypeName() noexcept { 388 return "android/content/Intent"; 389 } 390 391 /*! 392 * Getter for the FLAG_ACTIVITY_NEW_TASK static field value 393 * 394 * Java prototype: 395 * `public static final int FLAG_ACTIVITY_NEW_TASK;` 396 * 397 * JNI signature: I 398 * 399 */ 400 static int32_t FLAG_ACTIVITY_NEW_TASK(); 401 402 /*! 403 * Wrapper for a constructor 404 * 405 * Java prototype: 406 * `public android.content.Intent();` 407 * 408 * JNI signature: ()V 409 * 410 */ 411 static Intent construct(); 412 413 /*! 414 * Wrapper for a constructor 415 * 416 * Java prototype: 417 * `public android.content.Intent(android.content.Intent);` 418 * 419 * JNI signature: (Landroid/content/Intent;)V 420 * 421 */ 422 static Intent construct(Intent const &intent); 423 424 /*! 425 * Wrapper for a constructor 426 * 427 * Java prototype: 428 * `public android.content.Intent(java.lang.String);` 429 * 430 * JNI signature: (Ljava/lang/String;)V 431 * 432 */ 433 static Intent construct(std::string const &action); 434 435 /*! 436 * Wrapper for a constructor 437 * 438 * Java prototype: 439 * `public android.content.Intent(java.lang.String, android.net.Uri);` 440 * 441 * JNI signature: (Ljava/lang/String;Landroid/net/Uri;)V 442 * 443 */ 444 static Intent construct(std::string const &action, net::Uri const &uri); 445 446 /*! 447 * Wrapper for a constructor 448 * 449 * Java prototype: 450 * `public android.content.Intent(android.content.Context, 451 * java.lang.Class<?>);` 452 * 453 * JNI signature: (Landroid/content/Context;Ljava/lang/Class;)V 454 * 455 */ 456 static Intent construct(Context const &context, 457 java::lang::Class const &classParam); 458 459 /*! 460 * Wrapper for a constructor 461 * 462 * Java prototype: 463 * `public android.content.Intent(java.lang.String, android.net.Uri, 464 * android.content.Context, java.lang.Class<?>);` 465 * 466 * JNI signature: 467 * (Ljava/lang/String;Landroid/net/Uri;Landroid/content/Context;Ljava/lang/Class;)V 468 * 469 */ 470 static Intent construct(std::string const &action, net::Uri const &uri, 471 Context const &context, 472 java::lang::Class const &classParam); 473 474 /*! 475 * Wrapper for the setFlags method 476 * 477 * Java prototype: 478 * `public android.content.Intent setFlags(int);` 479 * 480 * JNI signature: (I)Landroid/content/Intent; 481 * 482 */ 483 Intent setFlags(int32_t flags); 484 485 /*! 486 * Class metadata 487 */ 488 struct Meta : public MetaBase { 489 impl::StaticFieldId<int32_t> FLAG_ACTIVITY_NEW_TASK; 490 jni::method_t init; 491 jni::method_t init1; 492 jni::method_t init2; 493 jni::method_t init3; 494 jni::method_t init4; 495 jni::method_t init5; 496 jni::method_t setFlags; 497 498 /*! 499 * Singleton accessor 500 */ 501 static Meta &data() { 502 static Meta instance{}; 503 return instance; 504 } 505 506 private: 507 Meta(); 508 }; 509}; 510 511/*! 512 * Wrapper for android.content.ContentResolver objects. 513 */ 514class ContentResolver : public ObjectWrapperBase { 515 public: 516 using ObjectWrapperBase::ObjectWrapperBase; 517 static constexpr const char *getTypeName() noexcept { 518 return "android/content/ContentResolver"; 519 } 520 521 /*! 522 * Wrapper for the query method - overload added in API level 1 523 * 524 * Java prototype: 525 * `public final android.database.Cursor query(android.net.Uri, 526 * java.lang.String[], java.lang.String, java.lang.String[], 527 * java.lang.String);` 528 * 529 * JNI signature: 530 * (Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor; 531 * 532 */ 533 database::Cursor query(net::Uri const &uri, 534 jni::Array<std::string> const &projection, 535 std::string const &selection, 536 jni::Array<std::string> const &selectionArgs, 537 std::string const &sortOrder); 538 539 /*! 540 * Wrapper for the query method - overload added in API level 1 541 * 542 * Java prototype: 543 * `public final android.database.Cursor query(android.net.Uri, 544 * java.lang.String[], java.lang.String, java.lang.String[], 545 * java.lang.String);` 546 * 547 * JNI signature: 548 * (Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor; 549 * 550 * This is a way to call the main query() function without the three 551 * trailing optional arguments. 552 */ 553 database::Cursor query(net::Uri const &uri, 554 jni::Array<std::string> const &projection); 555 556 /*! 557 * Wrapper for the query method - overload added in API level 16 558 * 559 * Java prototype: 560 * `public final android.database.Cursor query(android.net.Uri, 561 * java.lang.String[], java.lang.String, java.lang.String[], 562 * java.lang.String, android.os.CancellationSignal);` 563 * 564 * JNI signature: 565 * (Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Landroid/os/CancellationSignal;)Landroid/database/Cursor; 566 * 567 */ 568 database::Cursor query(net::Uri const &uri, 569 jni::Array<std::string> const &projection, 570 std::string const &selection, 571 jni::Array<std::string> const &selectionArgs, 572 std::string const &sortOrder, 573 jni::Object const &cancellationSignal); 574 575 /*! 576 * Wrapper for the query method - overload added in API level 26 577 * 578 * Java prototype: 579 * `public final android.database.Cursor query(android.net.Uri, 580 * java.lang.String[], android.os.Bundle, android.os.CancellationSignal);` 581 * 582 * JNI signature: 583 * (Landroid/net/Uri;[Ljava/lang/String;Landroid/os/Bundle;Landroid/os/CancellationSignal;)Landroid/database/Cursor; 584 * 585 */ 586 database::Cursor query(net::Uri const &uri, 587 jni::Array<std::string> const &projection, 588 os::Bundle const &queryArgs, 589 jni::Object const &cancellationSignal); 590 591 /*! 592 * Class metadata 593 */ 594 struct Meta : public MetaBaseDroppable { 595 jni::method_t query; 596 jni::method_t query1; 597 jni::method_t query2; 598 599 /*! 600 * Singleton accessor 601 */ 602 static Meta &data() { 603 static Meta instance{}; 604 return instance; 605 } 606 607 private: 608 Meta(); 609 }; 610}; 611 612} // namespace android::content 613} // namespace wrap 614#include "android.content.impl.h"