Merge "Add background executor fow WmShell" into tm-dev am: a73a4428ff
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17693175 Change-Id: I1fb60ad0fb91405af6f2d57a44ef9885ebd658a9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 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.common.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 shared background thread */
|
||||||
|
@Documented
|
||||||
|
@Inherited
|
||||||
|
@Qualifier
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface ShellBackgroundThread {
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.wm.shell.dagger;
|
package com.android.wm.shell.dagger;
|
||||||
|
|
||||||
|
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
|
||||||
import static android.os.Process.THREAD_PRIORITY_DISPLAY;
|
import static android.os.Process.THREAD_PRIORITY_DISPLAY;
|
||||||
import static android.os.Process.THREAD_PRIORITY_TOP_APP_BOOST;
|
import static android.os.Process.THREAD_PRIORITY_TOP_APP_BOOST;
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ import com.android.wm.shell.common.ShellExecutor;
|
|||||||
import com.android.wm.shell.common.annotations.ChoreographerSfVsync;
|
import com.android.wm.shell.common.annotations.ChoreographerSfVsync;
|
||||||
import com.android.wm.shell.common.annotations.ExternalMainThread;
|
import com.android.wm.shell.common.annotations.ExternalMainThread;
|
||||||
import com.android.wm.shell.common.annotations.ShellAnimationThread;
|
import com.android.wm.shell.common.annotations.ShellAnimationThread;
|
||||||
|
import com.android.wm.shell.common.annotations.ShellBackgroundThread;
|
||||||
import com.android.wm.shell.common.annotations.ShellMainThread;
|
import com.android.wm.shell.common.annotations.ShellMainThread;
|
||||||
import com.android.wm.shell.common.annotations.ShellSplashscreenThread;
|
import com.android.wm.shell.common.annotations.ShellSplashscreenThread;
|
||||||
|
|
||||||
@@ -195,4 +197,28 @@ public abstract class WMShellConcurrencyModule {
|
|||||||
throw new RuntimeException("Failed to initialize SfVsync animation handler in 1s", e);
|
throw new RuntimeException("Failed to initialize SfVsync animation handler in 1s", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a Shell background thread Handler for low priority background tasks.
|
||||||
|
*/
|
||||||
|
@WMSingleton
|
||||||
|
@Provides
|
||||||
|
@ShellBackgroundThread
|
||||||
|
public static Handler provideSharedBackgroundHandler() {
|
||||||
|
HandlerThread shellBackgroundThread = new HandlerThread("wmshell.background",
|
||||||
|
THREAD_PRIORITY_BACKGROUND);
|
||||||
|
shellBackgroundThread.start();
|
||||||
|
return shellBackgroundThread.getThreadHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a Shell background thread Executor for low priority background tasks.
|
||||||
|
*/
|
||||||
|
@WMSingleton
|
||||||
|
@Provides
|
||||||
|
@ShellBackgroundThread
|
||||||
|
public static ShellExecutor provideSharedBackgroundExecutor(
|
||||||
|
@ShellBackgroundThread Handler handler) {
|
||||||
|
return new HandlerExecutor(handler);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user