Loading core/java/android/view/WindowManagerGlobal.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -179,9 +179,29 @@ public final class WindowManagerGlobal { } } } } /** * Sets {@link com.android.server.wm.WindowManagerService} for the system process. * <p> * It is needed to prevent possible deadlock. A possible scenario is: * In system process, WMS holds {@link com.android.server.wm.WindowManagerGlobalLock} to call * {@code WindowManagerGlobal} APIs and wait to lock {@code WindowManagerGlobal} itself * (i.e. call {@link #getWindowManagerService()} in the global lock), while * another component may lock {@code WindowManagerGlobal} and wait to lock * {@link com.android.server.wm.WindowManagerGlobalLock}(i.e call {@link #addView} in the * system process, which calls to {@link com.android.server.wm.WindowManagerService} API * directly). */ public static void setWindowManagerServiceForSystemProcess(@NonNull IWindowManager wms) { sWindowManagerService = wms; } @Nullable @Nullable @UnsupportedAppUsage @UnsupportedAppUsage public static IWindowManager getWindowManagerService() { public static IWindowManager getWindowManagerService() { if (sWindowManagerService != null) { // Use WMS directly without locking WMGlobal to prevent deadlock. return sWindowManagerService; } synchronized (WindowManagerGlobal.class) { synchronized (WindowManagerGlobal.class) { if (sWindowManagerService == null) { if (sWindowManagerService == null) { sWindowManagerService = IWindowManager.Stub.asInterface( sWindowManagerService = IWindowManager.Stub.asInterface( Loading services/core/java/com/android/server/wm/WindowManagerService.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -1114,8 +1114,11 @@ public class WindowManagerService extends IWindowManager.Stub public static WindowManagerService main(final Context context, final InputManagerService im, public static WindowManagerService main(final Context context, final InputManagerService im, final boolean showBootMsgs, WindowManagerPolicy policy, final boolean showBootMsgs, WindowManagerPolicy policy, ActivityTaskManagerService atm) { ActivityTaskManagerService atm) { return main(context, im, showBootMsgs, policy, atm, new DisplayWindowSettingsProvider(), final WindowManagerService wms = main(context, im, showBootMsgs, policy, atm, SurfaceControl.Transaction::new, SurfaceControl.Builder::new); new DisplayWindowSettingsProvider(), SurfaceControl.Transaction::new, SurfaceControl.Builder::new); WindowManagerGlobal.setWindowManagerServiceForSystemProcess(wms); return wms; } } /** /** Loading Loading
core/java/android/view/WindowManagerGlobal.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -179,9 +179,29 @@ public final class WindowManagerGlobal { } } } } /** * Sets {@link com.android.server.wm.WindowManagerService} for the system process. * <p> * It is needed to prevent possible deadlock. A possible scenario is: * In system process, WMS holds {@link com.android.server.wm.WindowManagerGlobalLock} to call * {@code WindowManagerGlobal} APIs and wait to lock {@code WindowManagerGlobal} itself * (i.e. call {@link #getWindowManagerService()} in the global lock), while * another component may lock {@code WindowManagerGlobal} and wait to lock * {@link com.android.server.wm.WindowManagerGlobalLock}(i.e call {@link #addView} in the * system process, which calls to {@link com.android.server.wm.WindowManagerService} API * directly). */ public static void setWindowManagerServiceForSystemProcess(@NonNull IWindowManager wms) { sWindowManagerService = wms; } @Nullable @Nullable @UnsupportedAppUsage @UnsupportedAppUsage public static IWindowManager getWindowManagerService() { public static IWindowManager getWindowManagerService() { if (sWindowManagerService != null) { // Use WMS directly without locking WMGlobal to prevent deadlock. return sWindowManagerService; } synchronized (WindowManagerGlobal.class) { synchronized (WindowManagerGlobal.class) { if (sWindowManagerService == null) { if (sWindowManagerService == null) { sWindowManagerService = IWindowManager.Stub.asInterface( sWindowManagerService = IWindowManager.Stub.asInterface( Loading
services/core/java/com/android/server/wm/WindowManagerService.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -1114,8 +1114,11 @@ public class WindowManagerService extends IWindowManager.Stub public static WindowManagerService main(final Context context, final InputManagerService im, public static WindowManagerService main(final Context context, final InputManagerService im, final boolean showBootMsgs, WindowManagerPolicy policy, final boolean showBootMsgs, WindowManagerPolicy policy, ActivityTaskManagerService atm) { ActivityTaskManagerService atm) { return main(context, im, showBootMsgs, policy, atm, new DisplayWindowSettingsProvider(), final WindowManagerService wms = main(context, im, showBootMsgs, policy, atm, SurfaceControl.Transaction::new, SurfaceControl.Builder::new); new DisplayWindowSettingsProvider(), SurfaceControl.Transaction::new, SurfaceControl.Builder::new); WindowManagerGlobal.setWindowManagerServiceForSystemProcess(wms); return wms; } } /** /** Loading