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();
  }
Ejemplo n.º 2
0
 /** @see Shell#connectToApplication(String, InterfaceRequest, ServiceProvider) */
 @Override
 public void connectToApplication(
     String applicationUrl,
     InterfaceRequest<ServiceProvider> services,
     ServiceProvider exposedServices) {
   int exposedServicesHandle = CoreImpl.INVALID_HANDLE;
   if (exposedServices != null) {
     if (exposedServices instanceof ServiceProvider.Proxy) {
       ServiceProvider.Proxy proxy = (ServiceProvider.Proxy) exposedServices;
       exposedServicesHandle = proxy.getProxyHandler().passHandle().releaseNativeHandle();
     } else {
       Pair<MessagePipeHandle, MessagePipeHandle> pipes =
           CoreImpl.getInstance().createMessagePipe(null);
       ServiceProvider.MANAGER.bind(exposedServices, pipes.first);
       exposedServicesHandle = pipes.second.releaseNativeHandle();
     }
   }
   nativeConnectToApplication(
       applicationUrl,
       services == null ? CoreImpl.INVALID_HANDLE : services.passHandle().releaseNativeHandle(),
       exposedServicesHandle);
 }