Update context object if split bounds changed
The RRS(runtime resolution switching) feature which supports users to change resolution directly. Split-screen did not update the Context object during the runtime resolution switching. That results in the split layout can not get the proper resource in time. This CL updates the new Context object whose resources are adjusted to match the new given Configuration when the split bound is different from existing. That’make sure to get the updated resources objects when calculating the divider snap target for this case. Bug: 235044746 Test: atest MultiWindowTests Change-Id: I94d1a95c6b4aeb3bf1b75aed2e0b3008f036c968
This commit is contained in:
@@ -211,24 +211,24 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
|
||||
/** Applies new configuration, returns {@code false} if there's no effect to the layout. */
|
||||
public boolean updateConfiguration(Configuration configuration) {
|
||||
// Always update configuration after orientation changed to make sure to render divider bar
|
||||
// with proper resources that matching screen orientation.
|
||||
final int orientation = configuration.orientation;
|
||||
if (mOrientation != orientation) {
|
||||
mContext = mContext.createConfigurationContext(configuration);
|
||||
mSplitWindowManager.setConfiguration(configuration);
|
||||
mOrientation = orientation;
|
||||
}
|
||||
|
||||
// Update the split bounds when necessary. Besides root bounds changed, split bounds need to
|
||||
// be updated when the rotation changed to cover the case that users rotated the screen 180
|
||||
// degrees.
|
||||
// Make sure to render the divider bar with proper resources that matching the screen
|
||||
// orientation.
|
||||
final int rotation = configuration.windowConfiguration.getRotation();
|
||||
final Rect rootBounds = configuration.windowConfiguration.getBounds();
|
||||
if (mRotation == rotation && mRootBounds.equals(rootBounds)) {
|
||||
final int orientation = configuration.orientation;
|
||||
|
||||
if (mOrientation == orientation
|
||||
&& mRotation == rotation
|
||||
&& mRootBounds.equals(rootBounds)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mContext = mContext.createConfigurationContext(configuration);
|
||||
mSplitWindowManager.setConfiguration(configuration);
|
||||
mOrientation = orientation;
|
||||
mTempRect.set(mRootBounds);
|
||||
mRootBounds.set(rootBounds);
|
||||
mRotation = rotation;
|
||||
|
||||
Reference in New Issue
Block a user