From f753ea6cd655a3972d9f8933d34a4772d6496a48 Mon Sep 17 00:00:00 2001 From: Andrii Kulian Date: Thu, 20 Feb 2020 20:53:47 -0800 Subject: [PATCH] Do not verify display context in DecorContext constructor Non-activity context can be passed to DecorContext, so an exception can be thrown when Context#getDisplay() call does verification. An example is that a free dialog uses Application context as its context. Bug: 149928768 Test: manual: test crashed apps reported in bugs before/after this patch. Change-Id: Ib302c23cb8e2e388e7468f37f1b63b83ef52ef0e --- core/java/com/android/internal/policy/DecorContext.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/com/android/internal/policy/DecorContext.java b/core/java/com/android/internal/policy/DecorContext.java index da1b72f05a983..99b4b5fb77077 100644 --- a/core/java/com/android/internal/policy/DecorContext.java +++ b/core/java/com/android/internal/policy/DecorContext.java @@ -46,9 +46,10 @@ public class DecorContext extends ContextThemeWrapper { private WeakReference mActivityContext; + // TODO(b/149928768): Non-activity context can be passed. @VisibleForTesting public DecorContext(Context context, Context activityContext) { - super(context.createDisplayContext(activityContext.getDisplay()), null); + super(context.createDisplayContext(activityContext.getDisplayNoVerify()), null); mActivityContext = new WeakReference<>(activityContext); mActivityResources = activityContext.getResources(); }