Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09e46db7 authored by Qijing Yao's avatar Qijing Yao
Browse files

Add DesktopDispatcher

to be used in coroutines for desktop mode related tasks.

Bug: 409218149
Test: manual test and atest releated classes using ShellDesktopThread
Flag: EXEMPT - can't guard module change; adding new unused dispatcher
Change-Id: I2330084f658e2f7514a9c5f299f471b0c8f035af
parent af966e53
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -203,16 +203,27 @@ public abstract class WMShellConcurrencyModule {
    }

    /**
     * Provides a Shell desktop thread Executor
     * Provides a Shell desktop thread Handler for desktop mode related tasks.
     */
    @WMSingleton
    @Provides
    @ShellDesktopThread
    public static ShellExecutor provideDesktopModeMiscExecutor() {
    public static Handler provideDesktopModeMiscHandler() {
        HandlerThread shellDesktopThread = new HandlerThread("wmshell.desktop",
                THREAD_PRIORITY_TOP_APP_BOOST);
        shellDesktopThread.start();
        return new HandlerExecutor(shellDesktopThread.getThreadHandler());
        return shellDesktopThread.getThreadHandler();
    }

    /**
     * Provides a Shell desktop thread Executor for desktop mode related tasks.
     */
    @WMSingleton
    @Provides
    @ShellDesktopThread
    public static ShellExecutor provideDesktopModeMiscExecutor(
            @ShellDesktopThread Handler handler) {
        return new HandlerExecutor(handler);
    }

    /**
+7 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.wm.shell.dagger
import android.os.Handler
import com.android.wm.shell.common.ShellExecutor
import com.android.wm.shell.shared.annotations.ShellBackgroundThread
import com.android.wm.shell.shared.annotations.ShellDesktopThread
import com.android.wm.shell.shared.annotations.ShellMainThread
import dagger.Module
import dagger.Provides
@@ -57,6 +58,12 @@ class WMShellCoroutinesModule {
      @ShellBackgroundThread backgroundHandler: Handler
  ): MainCoroutineDispatcher = backgroundHandler.asCoroutineDispatcher()

  @Provides
  @ShellDesktopThread
  fun provideDesktopDispatcher(
    @ShellDesktopThread desktopHandler: Handler
  ): MainCoroutineDispatcher = desktopHandler.asCoroutineDispatcher()

  @Provides
  @WMSingleton
  @ShellMainThread