Fix error in DecorView's ViewConfiguration
In ViewConfiguration, we use isUiContext to verify if a context is an visual context. However, DecorContext uses Application context as a base context and return false as intended. This patch overrides isUiContext to report context#isUiContext instead. fixes: 153664027 Test: atest DecorContextTest#testIsUiContextFromVisualDecorContext Change-Id: Ida26b9617c74dc6997fc2c00d97d3420a0978fc7
This commit is contained in:
@@ -118,4 +118,13 @@ public class DecorContext extends ContextThemeWrapper {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUiContext() {
|
||||
Context context = mContext.get();
|
||||
if (context != null) {
|
||||
return context.isUiContext();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.internal.policy;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.EmptyActivity;
|
||||
@@ -102,4 +103,14 @@ public final class DecorContextTest {
|
||||
assertEquals(expectedWm.mContext, actualWm.mContext);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsUiContextFromVisualDecorContext() throws Throwable {
|
||||
mActivityRule.runOnUiThread(() -> {
|
||||
Activity activity = mActivityRule.getActivity();
|
||||
final DecorContext decorContext = new DecorContext(mContext.getApplicationContext(),
|
||||
(PhoneWindow) activity.getWindow());
|
||||
assertTrue(decorContext.isUiContext());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user