summaryrefslogtreecommitdiff
path: root/test-mock/src/android/test/mock/MockContext.java
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2018-10-15 07:38:25 +0800
committerYohei Yukawa <yukawa@google.com>2018-10-15 07:38:25 +0800
commit5281b6b4c06f3b6b3d63ed9877101229645df9a9 (patch)
treed9281480b32b481c2e5fee4efc6bb265150757d3 /test-mock/src/android/test/mock/MockContext.java
parent2d3972e2f1b86c33adeb5d9bee953cebac4b20df (diff)
Add Context.getDisplayId() to avoid possible IPC
ContextImpl has an internal rule that when ContextImpl#mDisplay is null the Context is associated with the default display. The problem is that, as discussed in Bug 117709581, when ContextImpl#mDisplay is null ContextImpl#getDisplay() tries to get some non-null Display object by making an IPC to the system server, which is redundant when the display ID is the only thing that the caller wants to know. By having an @hide method Context.getDisplayId(), we can ensure that display ID can be obtained without any IPC. This enables us to re-submit my CL [1] that aimed to instantiate InputMethodManager (IMM) for each display but then got reverted due to a performance regression (Bug 117434607). There should be no developer-observable behavior change. [1]: I7242e765426353672823fcc8277f20ac361930d7 c53d78e992694e471ddaae73f9a30977db9cdb75 Fix: 117712745 Test: atest FrameworksCoreTests:android.content.ContextTest Test: prebuilts/checkstyle/checkstyle.py -f \ frameworks/base/core/tests/coretests/src/android/content/ContextTest.java Change-Id: I2534530a5ce90e2620c5039d793a6454a0a1e154
Diffstat (limited to 'test-mock/src/android/test/mock/MockContext.java')
-rw-r--r--test-mock/src/android/test/mock/MockContext.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/test-mock/src/android/test/mock/MockContext.java b/test-mock/src/android/test/mock/MockContext.java
index 9d260ebf7231..fa5b896ea126 100644
--- a/test-mock/src/android/test/mock/MockContext.java
+++ b/test-mock/src/android/test/mock/MockContext.java
@@ -774,6 +774,12 @@ public class MockContext extends Context {
/** @hide */
@Override
+ public int getDisplayId() {
+ throw new UnsupportedOperationException();
+ }
+
+ /** @hide */
+ @Override
public void updateDisplay(int displayId) {
throw new UnsupportedOperationException();
}