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

Commit 8a4c787c authored by Qijing Yao's avatar Qijing Yao
Browse files

Add ShellDesktopThread

This CL extracts the ShellDesktopThread and related changes from
ag/30771569 to enable faster integration.
This thread will be used for visual indicators in desktop mode as part
of the new system UI threading model to reduce jank.

Bug: 366413536
Test: build
Flag: EXEMPT adding new unused thread, no functional changes
Change-Id: Id6484194485bd88a47302078ae796b8fab79ceaf
parent 45d73de7
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.shared.annotations;

import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import javax.inject.Qualifier;

/** Annotates a method or qualifies a provider that runs on the Shell desktop thread */
@Documented
@Inherited
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
public @interface ShellDesktopThread {
}
+15 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.shared.annotations.ExternalMainThread;
import com.android.wm.shell.shared.annotations.ShellAnimationThread;
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 com.android.wm.shell.shared.annotations.ShellSplashscreenThread;

@@ -192,6 +193,19 @@ public abstract class WMShellConcurrencyModule {
        return new HandlerExecutor(shellSplashscreenThread.getThreadHandler());
    }

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

    /**
     * Provides a Shell background thread Handler for low priority background tasks.
     */
@@ -199,7 +213,7 @@ public abstract class WMShellConcurrencyModule {
    @Provides
    @ShellBackgroundThread
    public static Handler provideSharedBackgroundHandler() {
        HandlerThread shellBackgroundThread = new HandlerThread("wmshell.background",
        final HandlerThread shellBackgroundThread = new HandlerThread("wmshell.background",
                THREAD_PRIORITY_BACKGROUND);
        shellBackgroundThread.start();
        return shellBackgroundThread.getThreadHandler();