private void attach() {
   Core core = CoreImpl.getInstance();
   Pair<SkyEngine.Proxy, InterfaceRequest<SkyEngine>> engine =
       SkyEngine.MANAGER.getInterfaceRequest(core);
   mSkyEngine = engine.first;
   mNativePlatformView = nativeAttach(engine.second.passHandle().releaseNativeHandle(), this);
 }
  public FlutterView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // TODO(abarth): Remove this static and instead make everything that
    // depends on it into a view-associated service.
    ActivityImpl.setCurrentActivity((Activity) context);

    mMetrics = new ViewportMetrics();
    mMetrics.devicePixelRatio = context.getResources().getDisplayMetrics().density;
    setFocusable(true);
    setFocusableInTouchMode(true);

    attach();
    assert mNativePlatformView != 0;

    mSurfaceCallback =
        new SurfaceHolder.Callback() {
          @Override
          public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {}

          @Override
          public void surfaceCreated(SurfaceHolder holder) {
            assert mNativePlatformView != 0;
            nativeSurfaceCreated(mNativePlatformView, holder.getSurface());
          }

          @Override
          public void surfaceDestroyed(SurfaceHolder holder) {
            assert mNativePlatformView != 0;
            nativeSurfaceDestroyed(mNativePlatformView);
          }
        };
    getHolder().addCallback(mSurfaceCallback);

    mKeyboardState = new KeyboardViewState(this);
    mRawKeyboardState = new RawKeyboardServiceState();

    Core core = CoreImpl.getInstance();

    mPlatformServiceProvider = new ServiceProviderImpl(core, this, ServiceRegistry.SHARED);

    ServiceRegistry localRegistry = new ServiceRegistry();
    configureLocalServices(localRegistry);
    mViewServiceProvider = new ServiceProviderImpl(core, this, localRegistry);

    mAccessibilityManager =
        (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);

    mOnMessageListeners = new HashMap<String, OnMessageListener>();
    mAsyncOnMessageListeners = new HashMap<String, OnMessageListenerAsync>();
    mActivityLifecycleListeners = new ArrayList<ActivityLifecycleListener>();

    setLocale(getResources().getConfiguration().locale);

    if ((context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
      discoveryReceiver = new DiscoveryReceiver();
      context.registerReceiver(discoveryReceiver, new IntentFilter(ACTION_DISCOVER));
    }
  }
 private SemanticsServer.Proxy createSemanticsServer() {
   Core core = CoreImpl.getInstance();
   Pair<SemanticsServer.Proxy, InterfaceRequest<SemanticsServer>> server =
       SemanticsServer.MANAGER.getInterfaceRequest(core);
   mDartServiceProvider.connectToService(
       SemanticsServer.MANAGER.getName(), server.second.passHandle());
   return server.first;
 }
 private void postRun() {
   Core core = CoreImpl.getInstance();
   // Connect to the ApplicationMessages service exported by the Flutter framework
   Pair<ApplicationMessages.Proxy, InterfaceRequest<ApplicationMessages>> appMessages =
       ApplicationMessages.MANAGER.getInterfaceRequest(core);
   mDartServiceProvider.connectToService(
       ApplicationMessages.MANAGER.getName(), appMessages.second.passHandle());
   mFlutterAppMessages = appMessages.first;
 }
Example #5
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);
 }
  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();
  }
 /** @see org.chromium.mojo.system.Handle#getCore() */
 @Override
 public Core getCore() {
   return CoreImpl.getInstance();
 }