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
This commit is contained in:
Andrii Kulian
2020-02-20 20:53:47 -08:00
committed by Charles Chen
parent e078ee507e
commit f753ea6cd6

View File

@@ -46,9 +46,10 @@ public class DecorContext extends ContextThemeWrapper {
private WeakReference<Context> 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();
}