Merge "Don't set override display info for ActivityView" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
982973934d
@@ -27,6 +27,7 @@ import android.os.RemoteException;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.InputDevice;
|
||||
import android.view.InputEvent;
|
||||
import android.view.MotionEvent;
|
||||
@@ -308,8 +309,14 @@ public class ActivityView extends ViewGroup {
|
||||
return;
|
||||
}
|
||||
|
||||
mInputForwarder = InputManager.getInstance().createInputForwarder(
|
||||
mVirtualDisplay.getDisplay().getDisplayId());
|
||||
final int displayId = mVirtualDisplay.getDisplay().getDisplayId();
|
||||
final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
|
||||
try {
|
||||
wm.dontOverrideDisplayInfo(displayId);
|
||||
} catch (RemoteException e) {
|
||||
e.rethrowAsRuntimeException();
|
||||
}
|
||||
mInputForwarder = InputManager.getInstance().createInputForwarder(displayId);
|
||||
mTaskStackListener = new TaskBackgroundChangeListener();
|
||||
try {
|
||||
mActivityManager.registerTaskStackListener(mTaskStackListener);
|
||||
|
||||
@@ -428,4 +428,14 @@ interface IWindowManager
|
||||
* on the next user activity.
|
||||
*/
|
||||
void requestUserActivityNotification();
|
||||
|
||||
/**
|
||||
* Notify WindowManager that it should not override the info in DisplayManager for the specified
|
||||
* display. This can disable letter- or pillar-boxing applied in DisplayManager when the metrics
|
||||
* of the logical display reported from WindowManager do not correspond to the metrics of the
|
||||
* physical display it is based on.
|
||||
*
|
||||
* @param displayId The id of the display.
|
||||
*/
|
||||
void dontOverrideDisplayInfo(int displayId);
|
||||
}
|
||||
|
||||
@@ -305,6 +305,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
|
||||
int pendingLayoutChanges;
|
||||
// TODO(multi-display): remove some of the usages.
|
||||
boolean isDefaultDisplay;
|
||||
/**
|
||||
* Flag indicating whether WindowManager should override info for this display in
|
||||
* DisplayManager.
|
||||
*/
|
||||
boolean mShouldOverrideDisplayConfiguration = true;
|
||||
|
||||
/** Window tokens that are in the process of exiting, but still on screen for animations. */
|
||||
final ArrayList<WindowToken> mExitingTokens = new ArrayList<>();
|
||||
@@ -1177,8 +1182,14 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
|
||||
mDisplayInfo.flags &= ~Display.FLAG_SCALING_DISABLED;
|
||||
}
|
||||
|
||||
// We usually set the override info in DisplayManager so that we get consistent display
|
||||
// metrics values when displays are changing and don't send out new values until WM is aware
|
||||
// of them. However, we don't do this for displays that serve as containers for ActivityView
|
||||
// because we don't want letter-/pillar-boxing during resize.
|
||||
final DisplayInfo overrideDisplayInfo = mShouldOverrideDisplayConfiguration
|
||||
? mDisplayInfo : null;
|
||||
mService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(mDisplayId,
|
||||
mDisplayInfo);
|
||||
overrideDisplayInfo);
|
||||
|
||||
mBaseDisplayRect.set(0, 0, dw, dh);
|
||||
|
||||
|
||||
@@ -1117,17 +1117,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
throw new IllegalStateException("Display has not been initialialized");
|
||||
}
|
||||
|
||||
DisplayContent displayContent = mRoot.getDisplayContent(displayId);
|
||||
|
||||
// Adding a window is an exception where the WindowManagerService can create the
|
||||
// display instead of waiting for the ActivityManagerService to drive creation.
|
||||
if (displayContent == null) {
|
||||
final Display display = mDisplayManager.getDisplay(displayId);
|
||||
|
||||
if (display != null) {
|
||||
displayContent = mRoot.createDisplayContent(display, null /* controller */);
|
||||
}
|
||||
}
|
||||
final DisplayContent displayContent = getDisplayContentOrCreate(displayId);
|
||||
|
||||
if (displayContent == null) {
|
||||
Slog.w(TAG_WM, "Attempted to add window to a display that does not exist: "
|
||||
@@ -1493,6 +1483,32 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get existing {@link DisplayContent} or create a new one if the display is registered in
|
||||
* DisplayManager.
|
||||
*
|
||||
* NOTE: This should only be used in cases when there is a chance that a {@link DisplayContent}
|
||||
* that corresponds to a display just added to DisplayManager has not yet been created. This
|
||||
* usually means that the call of this method was initiated from outside of Activity or Window
|
||||
* Manager. In most cases the regular getter should be used.
|
||||
* @see RootWindowContainer#getDisplayContent(int)
|
||||
*/
|
||||
private DisplayContent getDisplayContentOrCreate(int displayId) {
|
||||
DisplayContent displayContent = mRoot.getDisplayContent(displayId);
|
||||
|
||||
// Create an instance if possible instead of waiting for the ActivityManagerService to drive
|
||||
// the creation.
|
||||
if (displayContent == null) {
|
||||
final Display display = mDisplayManager.getDisplay(displayId);
|
||||
|
||||
if (display != null) {
|
||||
displayContent = mRoot.createDisplayContent(display, null /* controller */);
|
||||
}
|
||||
}
|
||||
|
||||
return displayContent;
|
||||
}
|
||||
|
||||
private boolean doesAddToastWindowRequireToken(String packageName, int callingUid,
|
||||
WindowState attachedWindow) {
|
||||
// Try using the target SDK of the root window
|
||||
@@ -6986,6 +7002,24 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dontOverrideDisplayInfo(int displayId) {
|
||||
synchronized (mWindowMap) {
|
||||
final DisplayContent dc = getDisplayContentOrCreate(displayId);
|
||||
if (dc == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Trying to register a non existent display.");
|
||||
}
|
||||
// We usually set the override info in DisplayManager so that we get consistent
|
||||
// values when displays are changing. However, we don't do this for displays that
|
||||
// serve as containers for ActivityViews because we don't want letter-/pillar-boxing
|
||||
// during resize.
|
||||
dc.mShouldOverrideDisplayConfiguration = false;
|
||||
mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(displayId,
|
||||
null /* info */);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver)
|
||||
throws RemoteException {
|
||||
|
||||
@@ -31,7 +31,10 @@ import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION;
|
||||
import static com.android.server.wm.WindowContainer.POSITION_TOP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -457,6 +460,18 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
SCREEN_ORIENTATION_LANDSCAPE, dc.getOrientation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisableDisplayInfoOverrideFromWindowManager() {
|
||||
final DisplayContent dc = createNewDisplay();
|
||||
|
||||
assertTrue(dc.mShouldOverrideDisplayConfiguration);
|
||||
sWm.dontOverrideDisplayInfo(dc.getDisplayId());
|
||||
|
||||
assertFalse(dc.mShouldOverrideDisplayConfiguration);
|
||||
verify(sWm.mDisplayManagerInternal, times(1))
|
||||
.setDisplayInfoOverrideFromWindowManager(dc.getDisplayId(), null);
|
||||
}
|
||||
|
||||
private static void verifySizes(DisplayContent displayContent, int expectedBaseWidth,
|
||||
int expectedBaseHeight, int expectedBaseDensity) {
|
||||
assertEquals(displayContent.mBaseDisplayWidth, expectedBaseWidth);
|
||||
|
||||
Reference in New Issue
Block a user