MCPcopy Create free account
hub / github.com/WiVRn/WiVRn / application

Method application

client/application.cpp:1478–1599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1476}
1477
1478application::application(application_info info) :
1479 app_info(std::move(info))
1480
1481{
1482#ifdef __ANDROID__
1483 // https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html
1484
1485 setup_jni();
1486 {
1487 jni::object<""> act(app_info.native_app->activity->clazz);
1488 auto app = act.call<jni::object<"android/app/Application">>("getApplication");
1489 auto ctx = app.call<jni::object<"android/content/Context">>("getApplicationContext");
1490
1491 // Get the intent, to handle wivrn://uri
1492 auto intent = act.call<jni::object<"android/content/Intent">>("getIntent");
1493 if (auto data_string = intent.call<jni::string>("getDataString"))
1494 {
1495 spdlog::info("Started with intent {}", (std::string)data_string);
1496 try
1497 {
1498 set_server_uri(data_string);
1499 }
1500 catch (std::exception & e)
1501 {
1502 spdlog::warn("failed to set server uri: {}", e.what());
1503 }
1504 }
1505
1506 auto files_dir = ctx.call<jni::object<"java/io/File">>("getFilesDir");
1507 if (auto files_dir_path = files_dir.call<jni::string>("getAbsolutePath"))
1508 {
1509 config_path = files_dir_path;
1510 cache_path = files_dir_path;
1511 }
1512 }
1513
1514 app_info.native_app->userData = this;
1515 app_info.native_app->onAppCmd = [](android_app * app, int32_t cmd) {
1516 switch (cmd)
1517 {
1518 // There is no APP_CMD_CREATE. The ANativeActivity creates the
1519 // application thread from onCreate(). The application thread
1520 // then calls android_main().
1521 case APP_CMD_START:
1522 break;
1523 case APP_CMD_RESUME:
1524 static_cast<application *>(app->userData)->resumed = true;
1525 break;
1526 case APP_CMD_PAUSE:
1527 static_cast<application *>(app->userData)->resumed = false;
1528 break;
1529 case APP_CMD_STOP:
1530 break;
1531 case APP_CMD_DESTROY:
1532 static_cast<application *>(app->userData)->native_window = nullptr;
1533 break;
1534 case APP_CMD_INIT_WINDOW:
1535 static_cast<application *>(app->userData)->native_window = app->window;

Callers

nothing calls this directly

Calls 7

xdg_config_homeFunction · 0.85
xdg_cache_homeFunction · 0.85
whatMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
handle_inputMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected