From 4ae10692a685c1253131fc83891c9d883dd22ac7 Mon Sep 17 00:00:00 2001 From: Josep del Rio Date: Wed, 1 Mar 2023 14:08:23 +0000 Subject: [PATCH] Use outerContext in the InputManager service We're having some random crashes that are the result of `InputManager` losing the reference to the `Context` object. This will be resolved as part of the refactoring being done in b/267758905, but until that is completed, we will change the service to use the outer context, which I'm confident will not be disposed by the garbage collector while the app is running. Bug: 267758905 Test: Presubmit, device test to confirm everything works Change-Id: Id8914a1ba954440999c65b91603ca22867938a97 --- core/java/android/app/SystemServiceRegistry.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index 83e0153575892..dbba0c6f5e50a 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -509,7 +509,7 @@ public final class SystemServiceRegistry { new ServiceFetcher() { @Override public InputManager getService(ContextImpl ctx) { - return InputManager.getInstance(ctx); + return InputManager.getInstance(ctx.getOuterContext()); }}); registerService(Context.DISPLAY_SERVICE, DisplayManager.class,