Try to fix stale mDisplaySize

WM#getMaximumWindowMetrics#getBounds report max window bounds with
the Configuration in Resources.
However, EdgeBackGestureHandler#onConfigurationChanged counld not
guarantee that WM#getMaximumWindowMetrics is updated because
the configuration updates are not on the same Context, and also
it Resources#getConfiguration.
This CL applies the reported Configuration from #onConfigurationChanged
callback to mDisplaySize directly. In this way, mDisplaySize is
up-to-date with the latest configuration.

Bug: 235711424
Test: manual - rotate the device dozens of times and check if
        mDisplaySize is updated.
Change-Id: Iafeb1c580bb0c7b3680a5c32616754c00666768c
This commit is contained in:
Charles Chen
2022-07-13 21:32:36 +08:00
parent 0251a89274
commit 7859ecee1e

View File

@@ -53,7 +53,6 @@ import android.view.MotionEvent;
import android.view.Surface;
import android.view.ViewConfiguration;
import android.view.WindowManager;
import android.view.WindowMetrics;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.internal.policy.GestureNavigationSettingsObserver;
@@ -183,6 +182,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
private final IWindowManager mWindowManagerService;
private final Optional<Pip> mPipOptional;
private final FalsingManager mFalsingManager;
private final Configuration mLastReportedConfig = new Configuration();
// Activities which should not trigger Back gesture.
private final List<ComponentName> mGestureBlockingActivities = new ArrayList<>();
@@ -334,6 +334,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
mFalsingManager = falsingManager;
mLatencyTracker = latencyTracker;
mFeatureFlags = featureFlags;
mLastReportedConfig.setTo(mContext.getResources().getConfiguration());
ComponentName recentsComponentName = ComponentName.unflattenFromString(
context.getString(com.android.internal.R.string.config_recentsComponentName));
if (recentsComponentName != null) {
@@ -885,12 +886,12 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
if (DEBUG_MISSING_GESTURE) {
Log.d(DEBUG_MISSING_GESTURE_TAG, "Config changed: config=" + newConfig);
}
mLastReportedConfig.updateFrom(newConfig);
updateDisplaySize();
}
private void updateDisplaySize() {
WindowMetrics metrics = mWindowManager.getMaximumWindowMetrics();
Rect bounds = metrics.getBounds();
Rect bounds = mLastReportedConfig.windowConfiguration.getMaxBounds();
mDisplaySize.set(bounds.width(), bounds.height());
if (DEBUG_MISSING_GESTURE) {
Log.d(DEBUG_MISSING_GESTURE_TAG, "Update display size: mDisplaySize=" + mDisplaySize);