コード例 #1
0
  public void destroy() {
    if (discoveryReceiver != null) {
      getContext().unregisterReceiver(discoveryReceiver);
    }

    if (mPlatformServiceProviderBinding != null) {
      mPlatformServiceProviderBinding.unbind().close();
      mPlatformServiceProvider.unbindServices();
    }

    if (mViewServiceProviderBinding != null) {
      mViewServiceProviderBinding.unbind().close();
      mViewServiceProvider.unbindServices();
    }

    getHolder().removeCallback(mSurfaceCallback);
    nativeDetach(mNativePlatformView);
    mNativePlatformView = 0;

    mSkyEngine.close();
    mDartServiceProvider.close();
    mFlutterAppMessages.close();
  }
コード例 #2
0
  private void preRun() {
    if (mPlatformServiceProviderBinding != null) {
      mPlatformServiceProviderBinding.unbind().close();
      mPlatformServiceProvider.unbindServices();
    }
    if (mViewServiceProviderBinding != null) {
      mViewServiceProviderBinding.unbind().close();
      mViewServiceProvider.unbindServices();
    }
    if (mDartServiceProvider != null) {
      mDartServiceProvider.close();
    }

    Core core = CoreImpl.getInstance();

    Pair<ServiceProvider.Proxy, InterfaceRequest<ServiceProvider>> dartServiceProvider =
        ServiceProvider.MANAGER.getInterfaceRequest(core);
    mDartServiceProvider = dartServiceProvider.first;

    Pair<ServiceProvider.Proxy, InterfaceRequest<ServiceProvider>> platformServiceProvider =
        ServiceProvider.MANAGER.getInterfaceRequest(core);
    mPlatformServiceProviderBinding =
        ServiceProvider.MANAGER.bind(mPlatformServiceProvider, platformServiceProvider.second);

    Pair<ServiceProvider.Proxy, InterfaceRequest<ServiceProvider>> viewServiceProvider =
        ServiceProvider.MANAGER.getInterfaceRequest(core);
    mViewServiceProviderBinding =
        ServiceProvider.MANAGER.bind(mViewServiceProvider, viewServiceProvider.second);

    ServicesData services = new ServicesData();
    services.incomingServices = platformServiceProvider.first;
    services.outgoingServices = dartServiceProvider.second;
    services.viewServices = viewServiceProvider.first;
    mSkyEngine.setServices(services);

    resetAccessibilityTree();
  }