From ce506dcf0059e41e42b22029ece2abfc534ebc76 Mon Sep 17 00:00:00 2001 From: Sravan Kumar Reddy Kallu Date: Fri, 22 Apr 2022 01:07:19 +0000 Subject: [PATCH] Revert "Fix testRegisterComponentCallbacksOnWindowContext flaky" This reverts commit edf1b37a0821b3bc1b0384386ded3cd3bad81be9. Reason for revert: ~2.49 seconds of BootTime regression b/230022846 Change-Id: Icaddb7aa21b95ad6f9f589528fe893ae8d5c9c93 Exempt-From-Owner-Approval: see go/perf-revert-first --- .../android/window/WindowProviderService.java | 5 ++-- .../android/window/WindowTokenClient.java | 8 +++---- .../server/wm/ConfigurationContainer.java | 11 ++------- .../android/server/wm/WindowContainer.java | 11 ++------- .../wm/WindowContextListenerController.java | 23 +++---------------- .../server/wm/WindowManagerService.java | 9 ++++---- 6 files changed, 18 insertions(+), 49 deletions(-) diff --git a/core/java/android/window/WindowProviderService.java b/core/java/android/window/WindowProviderService.java index 2d2c8de726466..f8484d15344e0 100644 --- a/core/java/android/window/WindowProviderService.java +++ b/core/java/android/window/WindowProviderService.java @@ -165,11 +165,10 @@ public abstract class WindowProviderService extends Service implements WindowPro } } - // Suppress the lint because ths is overridden from Context. @SuppressLint("OnNameExpected") @Override - @Nullable - public Object getSystemService(@NonNull String name) { + // Suppress the lint because ths is overridden from Context. + public @Nullable Object getSystemService(@NonNull String name) { if (WINDOW_SERVICE.equals(name)) { return mWindowManager; } diff --git a/core/java/android/window/WindowTokenClient.java b/core/java/android/window/WindowTokenClient.java index b0be0df80b295..547535d90e5aa 100644 --- a/core/java/android/window/WindowTokenClient.java +++ b/core/java/android/window/WindowTokenClient.java @@ -91,6 +91,7 @@ public class WindowTokenClient extends IWindowToken.Stub { throw new IllegalStateException("Context is already attached."); } mContextRef = new WeakReference<>(context); + mConfiguration.setTo(context.getResources().getConfiguration()); mShouldDumpConfigForIme = Build.IS_DEBUGGABLE && context instanceof AbstractInputMethodService; } @@ -111,8 +112,7 @@ public class WindowTokenClient extends IWindowToken.Stub { if (configuration == null) { return false; } - mHandler.runWithScissors(() -> onConfigurationChanged(configuration, displayId, - false /* shouldReportConfigChange */), 0 /* timeout */); + onConfigurationChanged(configuration, displayId, false /* shouldReportConfigChange */); mAttachToWindowContainer = true; return true; } catch (RemoteException e) { @@ -137,8 +137,8 @@ public class WindowTokenClient extends IWindowToken.Stub { if (configuration == null) { return false; } - mHandler.runWithScissors(() -> onConfigurationChanged(configuration, displayId, - false /* shouldReportConfigChange */), 0 /* timeout */); + mHandler.post(() -> onConfigurationChanged(configuration, displayId, + false /* shouldReportConfigChange */)); mAttachToWindowContainer = true; return true; } catch (RemoteException e) { diff --git a/services/core/java/com/android/server/wm/ConfigurationContainer.java b/services/core/java/com/android/server/wm/ConfigurationContainer.java index e7c03aa7a099c..dbc08cd5d1a94 100644 --- a/services/core/java/com/android/server/wm/ConfigurationContainer.java +++ b/services/core/java/com/android/server/wm/ConfigurationContainer.java @@ -637,19 +637,12 @@ public abstract class ConfigurationContainer { } void registerConfigurationChangeListener(ConfigurationContainerListener listener) { - registerConfigurationChangeListener(listener, true /* shouldDispatchConfig */); - } - - void registerConfigurationChangeListener(ConfigurationContainerListener listener, - boolean shouldDispatchConfig) { if (mChangeListeners.contains(listener)) { return; } mChangeListeners.add(listener); - if (shouldDispatchConfig) { - listener.onRequestedOverrideConfigurationChanged(mResolvedOverrideConfiguration); - listener.onMergedOverrideConfigurationChanged(mMergedOverrideConfiguration); - } + listener.onRequestedOverrideConfigurationChanged(mResolvedOverrideConfiguration); + listener.onMergedOverrideConfigurationChanged(mMergedOverrideConfiguration); } void unregisterConfigurationChangeListener(ConfigurationContainerListener listener) { diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index c7bc51356c765..f5af2b4e29fa9 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -3747,20 +3747,13 @@ class WindowContainer extends ConfigurationContainer< } void registerWindowContainerListener(WindowContainerListener listener) { - registerWindowContainerListener(listener, true /* shouldPropConfig */); - } - - void registerWindowContainerListener(WindowContainerListener listener, - boolean shouldDispatchConfig) { if (mListeners.contains(listener)) { return; } mListeners.add(listener); // Also register to ConfigurationChangeListener to receive configuration changes. - registerConfigurationChangeListener(listener, shouldDispatchConfig); - if (shouldDispatchConfig) { - listener.onDisplayChanged(getDisplayContent()); - } + registerConfigurationChangeListener(listener); + listener.onDisplayChanged(getDisplayContent()); } void unregisterWindowContainerListener(WindowContainerListener listener) { diff --git a/services/core/java/com/android/server/wm/WindowContextListenerController.java b/services/core/java/com/android/server/wm/WindowContextListenerController.java index 912fdb2e32af9..7956a112539e3 100644 --- a/services/core/java/com/android/server/wm/WindowContextListenerController.java +++ b/services/core/java/com/android/server/wm/WindowContextListenerController.java @@ -68,16 +68,6 @@ class WindowContextListenerController { @VisibleForTesting final ArrayMap mListeners = new ArrayMap<>(); - /** - * @see #registerWindowContainerListener(IBinder, WindowContainer, int, int, Bundle, boolean) - */ - void registerWindowContainerListener(@NonNull IBinder clientToken, - @NonNull WindowContainer container, int ownerUid, @WindowType int type, - @Nullable Bundle options) { - registerWindowContainerListener(clientToken, container, ownerUid, type, options, - true /* shouDispatchConfigWhenRegistering */); - } - /** * Registers the listener to a {@code container} which is associated with * a {@code clientToken}, which is a {@link android.window.WindowContext} representation. If the @@ -90,18 +80,15 @@ class WindowContextListenerController { * @param ownerUid the caller UID * @param type the window type * @param options a bundle used to pass window-related options. - * @param shouDispatchConfigWhenRegistering {@code true} to indicate the current - * {@code container}'s config will dispatch to the client side when - * registering the {@link WindowContextListenerImpl} */ void registerWindowContainerListener(@NonNull IBinder clientToken, @NonNull WindowContainer container, int ownerUid, @WindowType int type, - @Nullable Bundle options, boolean shouDispatchConfigWhenRegistering) { + @Nullable Bundle options) { WindowContextListenerImpl listener = mListeners.get(clientToken); if (listener == null) { listener = new WindowContextListenerImpl(clientToken, container, ownerUid, type, options); - listener.register(shouDispatchConfigWhenRegistering); + listener.register(); } else { listener.updateContainer(container); } @@ -241,16 +228,12 @@ class WindowContextListenerController { } private void register() { - register(true /* shouldDispatchConfig */); - } - - private void register(boolean shouldDispatchConfig) { final IBinder token = mClientToken.asBinder(); if (mDeathRecipient == null) { throw new IllegalStateException("Invalid client token: " + token); } mListeners.putIfAbsent(token, this); - mContainer.registerWindowContainerListener(this, shouldDispatchConfig); + mContainer.registerWindowContainerListener(this); } private void unregister() { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index c37c9cb72ec5e..2f4dc515fd117 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -2770,10 +2770,12 @@ public class WindowManagerService extends IWindowManager.Stub } // TODO(b/155340867): Investigate if we still need roundedCornerOverlay after // the feature b/155340867 is completed. - final DisplayArea da = dc.findAreaForWindowType(type, options, + final DisplayArea da = dc.findAreaForWindowType(type, options, callerCanManageAppTokens, false /* roundedCornerOverlay */); + // TODO(b/190019118): Avoid to send onConfigurationChanged because it has been done + // in return value of attachWindowContextToDisplayArea. mWindowContextListenerController.registerWindowContainerListener(clientToken, da, - callingUid, type, options, false /* shouDispatchConfigWhenRegistering */); + callingUid, type, options); return da.getConfiguration(); } } finally { @@ -2869,8 +2871,7 @@ public class WindowManagerService extends IWindowManager.Stub } mWindowContextListenerController.registerWindowContainerListener(clientToken, dc, - callingUid, INVALID_WINDOW_TYPE, null /* options */, - false /* shouDispatchConfigWhenRegistering */); + callingUid, INVALID_WINDOW_TYPE, null /* options */); return dc.getConfiguration(); } } finally {