| 780 | AndroidPlatform::~AndroidPlatform() = default; |
| 781 | |
| 782 | int AndroidPlatform::init() { |
| 783 | #if CC_USE_XR |
| 784 | registerInterface(std::make_shared<XRInterface>()); |
| 785 | #endif |
| 786 | IXRInterface *xr = CC_GET_XR_INTERFACE(); |
| 787 | if (xr) { |
| 788 | JniHelper::getEnv(); |
| 789 | xr->initialize(JniHelper::getJavaVM(), getActivity()); |
| 790 | } |
| 791 | cc::FileUtilsAndroid::setAssetManager(_app->activity->assetManager); |
| 792 | _inputProxy = ccnew GameInputProxy(this); |
| 793 | _inputProxy->registerAppEventCallback([this](int32_t cmd) { |
| 794 | IXRInterface *xr = CC_GET_XR_INTERFACE(); |
| 795 | if (xr) { |
| 796 | xr->handleAppCommand(cmd); |
| 797 | } |
| 798 | |
| 799 | if (APP_CMD_START == cmd || APP_CMD_INIT_WINDOW == cmd) { |
| 800 | if (_inputProxy->isAnimating()) { |
| 801 | _isLowFrequencyLoopEnabled = false; |
| 802 | _loopTimeOut = 0; |
| 803 | } |
| 804 | } else if (APP_CMD_STOP == cmd) { |
| 805 | _lowFrequencyTimer.reset(); |
| 806 | _loopTimeOut = LOW_FREQUENCY_TIME_INTERVAL; |
| 807 | _isLowFrequencyLoopEnabled = true; |
| 808 | if (xr && !xr->getXRConfig(xr::XRConfigKey::INSTANCE_CREATED).getBool()) { |
| 809 | // xr will sleep, -1 we will block forever waiting for events. |
| 810 | _loopTimeOut = -1; |
| 811 | _isLowFrequencyLoopEnabled = false; |
| 812 | } |
| 813 | } |
| 814 | }); |
| 815 | _app->userData = _inputProxy; |
| 816 | _app->onAppCmd = handleCmdProxy; |
| 817 | |
| 818 | registerInterface(std::make_shared<Accelerometer>()); |
| 819 | registerInterface(std::make_shared<Battery>()); |
| 820 | registerInterface(std::make_shared<Network>()); |
| 821 | registerInterface(std::make_shared<Screen>()); |
| 822 | registerInterface(std::make_shared<System>()); |
| 823 | registerInterface(std::make_shared<SystemWindowManager>()); |
| 824 | registerInterface(std::make_shared<Vibrator>()); |
| 825 | |
| 826 | return 0; |
| 827 | } |
| 828 | |
| 829 | void AndroidPlatform::onDestroy() { |
| 830 | UniversalPlatform::onDestroy(); |
nothing calls this directly
no test coverage detected