From 5281b6b4c06f3b6b3d63ed9877101229645df9a9 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Mon, 15 Oct 2018 07:38:25 +0800 Subject: 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 --- test-mock/src/android/test/mock/MockContext.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test-mock/src') 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 @@ -772,6 +772,12 @@ public class MockContext extends Context { throw new UnsupportedOperationException(); } + /** @hide */ + @Override + public int getDisplayId() { + throw new UnsupportedOperationException(); + } + /** @hide */ @Override public void updateDisplay(int displayId) { -- cgit v1.2.3-59-g8ed1b