diff options
| author | 2025-02-23 21:12:31 -0800 | |
|---|---|---|
| committer | 2025-02-23 21:12:31 -0800 | |
| commit | d94e59ba9a57bac536e2380026a35a5b39b7c021 (patch) | |
| tree | 9fabbc8bd0b78903205320547fc12bc428967e29 | |
| parent | 69022fadafdc1481797579ccda9e2d55c9d58b33 (diff) | |
| parent | 6f8c4d3b575e6ae29a2bbfca2ea3771eb34cec53 (diff) | |
Merge "Inline WindowState#getAttrs" into main
17 files changed, 58 insertions, 51 deletions
diff --git a/services/core/java/com/android/server/wm/AbsAppSnapshotController.java b/services/core/java/com/android/server/wm/AbsAppSnapshotController.java index 90c2216f6b22..a731bf7c64b3 100644 --- a/services/core/java/com/android/server/wm/AbsAppSnapshotController.java +++ b/services/core/java/com/android/server/wm/AbsAppSnapshotController.java @@ -334,7 +334,7 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer, builder.setId(System.currentTimeMillis()); builder.setContentInsets(contentInsets); builder.setLetterboxInsets(letterboxInsets); - final boolean isWindowTranslucent = mainWindow.getAttrs().format != PixelFormat.OPAQUE; + final boolean isWindowTranslucent = mainWindow.mAttrs.format != PixelFormat.OPAQUE; final boolean isShowWallpaper = mainWindow.hasWallpaper(); int pixelFormat = builder.getPixelFormat(); if (pixelFormat == PixelFormat.UNKNOWN) { @@ -432,7 +432,7 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer, final ActivityManager.TaskDescription taskDescription = getTaskDescription(source); final int color = ColorUtils.setAlphaComponent( taskDescription.getBackgroundColor(), 255); - final WindowManager.LayoutParams attrs = mainWindow.getAttrs(); + final WindowManager.LayoutParams attrs = mainWindow.mAttrs; final Rect taskBounds = source.getBounds(); final InsetsState insetsState = mainWindow.getInsetsStateWithVisibilityOverride(); final Rect systemBarInsets = getSystemBarInsets(mainWindow.getFrame(), insetsState); diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 7b6d408fbe2c..f61c022895f5 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -3076,7 +3076,7 @@ final class ActivityRecord extends WindowToken { if (win == null) { return; } - isOpaque = isOpaque & !PixelFormat.formatHasAlpha(win.getAttrs().format); + isOpaque = isOpaque & !PixelFormat.formatHasAlpha(win.mAttrs.format); win.mWinAnimator.setOpaqueLocked(isOpaque); } diff --git a/services/core/java/com/android/server/wm/AppCompatLetterboxPolicy.java b/services/core/java/com/android/server/wm/AppCompatLetterboxPolicy.java index 57811e24351f..6873270366ee 100644 --- a/services/core/java/com/android/server/wm/AppCompatLetterboxPolicy.java +++ b/services/core/java/com/android/server/wm/AppCompatLetterboxPolicy.java @@ -223,7 +223,7 @@ class AppCompatLetterboxPolicy { // Check for FLAG_SHOW_WALLPAPER explicitly instead of using // WindowContainer#showWallpaper because the later will return true when // this activity is using blurred wallpaper for letterbox background. - && (mainWindow.getAttrs().flags & FLAG_SHOW_WALLPAPER) == 0; + && (mainWindow.mAttrs.flags & FLAG_SHOW_WALLPAPER) == 0; mLastShouldShowLetterboxUi = shouldShowLetterboxUi; @@ -334,7 +334,7 @@ class AppCompatLetterboxPolicy { if (w == null) { return true; } - final int type = w.getAttrs().type; + final int type = w.mAttrs.type; // Allow letterbox to be displayed early for base application or application starting // windows even if it is not on the top z order to prevent flickering when the // letterboxed window is brought to the top diff --git a/services/core/java/com/android/server/wm/BackNavigationController.java b/services/core/java/com/android/server/wm/BackNavigationController.java index d652ea1e26a4..f00755ace76e 100644 --- a/services/core/java/com/android/server/wm/BackNavigationController.java +++ b/services/core/java/com/android/server/wm/BackNavigationController.java @@ -222,7 +222,7 @@ class BackNavigationController { } } } - final boolean canInterruptInView = (window.getAttrs().privateFlags + final boolean canInterruptInView = (window.mAttrs.privateFlags & PRIVATE_FLAG_APP_PROGRESS_GENERATION_ALLOWED) != 0; infoBuilder.setAppProgressAllowed(canInterruptInView && !transferGestureToEmbedded && callbackInfo.isAnimationCallback()); diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index fdf6bcaf3166..da283786b841 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -5816,7 +5816,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp // For each window, we only take the rects that fall within its touchable region. forAllWindows(w -> { if (!w.canReceiveTouchInput() || !w.isVisible() - || (w.getAttrs().flags & FLAG_NOT_TOUCHABLE) != 0 + || (w.mAttrs.flags & FLAG_NOT_TOUCHABLE) != 0 || unhandled.isEmpty()) { return; } @@ -5906,7 +5906,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp if (win.mWmService.mConstants.mSystemGestureExclusionLogDebounceTimeoutMillis <= 0) { return false; } - final WindowManager.LayoutParams attrs = win.getAttrs(); + final WindowManager.LayoutParams attrs = win.mAttrs; final int type = attrs.type; return type != TYPE_WALLPAPER && type != TYPE_APPLICATION_STARTING diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 7aa2101f516c..a03ecf51223a 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -2365,7 +2365,7 @@ public class DisplayPolicy { // Immersive mode confirmation should never affect the system bar visibility, otherwise // it will unhide the navigation bar and hide itself. - if ((winCandidate.getAttrs().privateFlags + if ((winCandidate.mAttrs.privateFlags & PRIVATE_FLAG_IMMERSIVE_CONFIRMATION_WINDOW) != 0) { if (mNotificationShade != null && mNotificationShade.canReceiveKeys()) { // Let notification shade control the system bar visibility. @@ -2633,9 +2633,9 @@ public class DisplayPolicy { } final boolean drawsSystemBars = - (win.getAttrs().flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0; + (win.mAttrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0; final boolean forceDrawsSystemBars = - (win.getAttrs().privateFlags & PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS) != 0; + (win.mAttrs.privateFlags & PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS) != 0; return forceDrawsSystemBars || drawsSystemBars; } diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java index 786161c07247..1a90bcc9b143 100644 --- a/services/core/java/com/android/server/wm/DisplayRotation.java +++ b/services/core/java/com/android/server/wm/DisplayRotation.java @@ -730,7 +730,7 @@ public class DisplayRotation { // We only enable seamless rotation if the top window has requested it and is in the // fullscreen opaque state. Seamless rotation requires freezing various Surface states and // won't work well with animations, so we disable it in the animation case for now. - if (w.getAttrs().rotationAnimation != ROTATION_ANIMATION_SEAMLESS || w.inMultiWindowMode() + if (w.mAttrs.rotationAnimation != ROTATION_ANIMATION_SEAMLESS || w.inMultiWindowMode() || w.isAnimatingLw()) { return false; } diff --git a/services/core/java/com/android/server/wm/InsetsPolicy.java b/services/core/java/com/android/server/wm/InsetsPolicy.java index 5c6695fe22c0..009d482ba316 100644 --- a/services/core/java/com/android/server/wm/InsetsPolicy.java +++ b/services/core/java/com/android/server/wm/InsetsPolicy.java @@ -272,7 +272,7 @@ class InsetsPolicy { */ InsetsState enforceInsetsPolicyForTarget(WindowState target, InsetsState state) { final InsetsState originalState = state; - final WindowManager.LayoutParams attrs = target.getAttrs(); + final WindowManager.LayoutParams attrs = target.mAttrs; // The caller should not receive the visible insets provided by itself. if (attrs.type == TYPE_INPUT_METHOD) { @@ -673,8 +673,8 @@ class InsetsPolicy { // If necessary, auto can control application windows when // config_remoteInsetsControllerControlsSystemBars is set to true. This is useful in cases // where we want to dictate system bar inset state for applications. - return win.getAttrs().type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW - && win.getAttrs().type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; + return win.mAttrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW + && win.mAttrs.type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; } private void dispatchTransientSystemBarsVisibilityChanged( diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 6cd1336122be..14328ec7e965 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -3580,7 +3580,7 @@ class Task extends TaskFragment { & StartingWindowInfo.TYPE_PARAMETER_ACTIVITY_CREATED) != 0) { final WindowState topMainWin = getTopFullscreenMainWindow(); if (topMainWin != null) { - info.mainWindowLayoutParams = topMainWin.getAttrs(); + info.mainWindowLayoutParams = topMainWin.mAttrs; info.requestedVisibleTypes = topMainWin.getRequestedVisibleTypes(); } } diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index fd7d96a646ae..63a8c86f5ba8 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -3332,14 +3332,14 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { if (mainWin == null) return ROTATION_ANIMATION_UNSPECIFIED; int anim = mainWin.getRotationAnimationHint(); if (anim >= 0) return anim; - anim = mainWin.getAttrs().rotationAnimation; + anim = mainWin.mAttrs.rotationAnimation; if (anim != ROTATION_ANIMATION_SEAMLESS) return anim; if (mainWin != task.mDisplayContent.getDisplayPolicy().getTopFullscreenOpaqueWindow() || !top.matchParentBounds()) { // At the moment, we only support seamless rotation if there is only one window showing. return ROTATION_ANIMATION_UNSPECIFIED; } - return mainWin.getAttrs().rotationAnimation; + return mainWin.mAttrs.rotationAnimation; } private void validateKeyguardOcclusion() { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 8aed91b2dc66..821c04011d97 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -1869,7 +1869,7 @@ public class WindowManagerService extends IWindowManager.Stub } else if (type == TYPE_INPUT_METHOD // IME window is always touchable. // Ignore non-touchable windows e.g. Stylus InkWindow.java. - && (win.getAttrs().flags & FLAG_NOT_TOUCHABLE) == 0) { + && (win.mAttrs.flags & FLAG_NOT_TOUCHABLE) == 0) { displayContent.setInputMethodWindowLocked(win); imMayMove = false; } else if (type == TYPE_INPUT_METHOD_DIALOG) { diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index bfedc90497ae..ec67dd87533a 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -1412,10 +1412,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP return mWindowFrames.mParentFrame; } - WindowManager.LayoutParams getAttrs() { - return mAttrs; - } - /** Retrieves the flags used to disable system UI functions. */ int getDisableFlags() { return mDisableFlags; @@ -5636,13 +5632,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP KeyInterceptionInfo getKeyInterceptionInfo() { if (mKeyInterceptionInfo == null - || mKeyInterceptionInfo.layoutParamsPrivateFlags != getAttrs().privateFlags - || mKeyInterceptionInfo.layoutParamsType != getAttrs().type + || mKeyInterceptionInfo.layoutParamsPrivateFlags != mAttrs.privateFlags + || mKeyInterceptionInfo.layoutParamsType != mAttrs.type || mKeyInterceptionInfo.windowTitle != getWindowTag() || mKeyInterceptionInfo.windowOwnerUid != getOwningUid() - || mKeyInterceptionInfo.inputFeaturesFlags != getAttrs().inputFeatures) { - mKeyInterceptionInfo = new KeyInterceptionInfo(getAttrs().type, getAttrs().privateFlags, - getWindowTag().toString(), getOwningUid(), getAttrs().inputFeatures); + || mKeyInterceptionInfo.inputFeaturesFlags != mAttrs.inputFeatures) { + mKeyInterceptionInfo = new KeyInterceptionInfo(mAttrs.type, mAttrs.privateFlags, + getWindowTag().toString(), getOwningUid(), mAttrs.inputFeatures); } return mKeyInterceptionInfo; } @@ -5666,7 +5662,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } else { outFrame.set(getParentFrame()); } - outSurfaceInsets.set(getAttrs().surfaceInsets); + outSurfaceInsets.set(mAttrs.surfaceInsets); final InsetsState state = getInsetsStateWithVisibilityOverride(); outInsets.set(state.calculateInsets(outFrame, systemBars(), false /* ignoreVisibility */).toRect()); diff --git a/services/tests/wmtests/src/com/android/server/wm/AppCompatLetterboxPolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/AppCompatLetterboxPolicyTest.java index 2603d787ae37..d38f3b09c4fa 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AppCompatLetterboxPolicyTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/AppCompatLetterboxPolicyTest.java @@ -350,8 +350,8 @@ public class AppCompatLetterboxPolicyTest extends WindowTestsBase { mWindowState.mInvGlobalScale = 1f; final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(); attrs.type = TYPE_BASE_APPLICATION; + setFieldValue(mWindowState, "mAttrs", attrs); doReturn(mInsetsState).when(mWindowState).getInsetsState(); - doReturn(attrs).when(mWindowState).getAttrs(); doReturn(true).when(mWindowState).isDrawn(); doReturn(true).when(mWindowState).isOnScreen(); doReturn(false).when(mWindowState).isLetterboxedForDisplayCutout(); diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java index a99bc4966c03..02ed67b50971 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -1414,7 +1414,7 @@ public class DisplayContentTests extends WindowTestsBase { final DisplayContent dc = createNewDisplay(); final WindowState win = newWindowBuilder("win", TYPE_BASE_APPLICATION).setDisplay( dc).build(); - win.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; + win.mAttrs.flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; win.setSystemGestureExclusion(Collections.singletonList(new Rect(10, 20, 30, 40))); performLayout(dc); @@ -1447,11 +1447,11 @@ public class DisplayContentTests extends WindowTestsBase { final DisplayContent dc = createNewDisplay(); final WindowState win = newWindowBuilder("win", TYPE_BASE_APPLICATION).setDisplay( dc).build(); - win.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; + win.mAttrs.flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; win.setSystemGestureExclusion(Collections.singletonList(new Rect(10, 20, 30, 40))); final WindowState win2 = newWindowBuilder("win2", TYPE_APPLICATION).setDisplay(dc).build(); - win2.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; + win2.mAttrs.flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; win2.setSystemGestureExclusion(Collections.singletonList(new Rect(20, 30, 40, 50))); performLayout(dc); @@ -1476,14 +1476,14 @@ public class DisplayContentTests extends WindowTestsBase { final DisplayContent dc = createNewDisplay(); final WindowState win = newWindowBuilder("base", TYPE_BASE_APPLICATION).setDisplay( dc).build(); - win.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; + win.mAttrs.flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; win.setSystemGestureExclusion(Collections.singletonList(new Rect(0, 0, 1000, 1000))); final WindowState win2 = newWindowBuilder("modal", TYPE_APPLICATION).setDisplay(dc).build(); - win2.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; - win2.getAttrs().privateFlags |= PRIVATE_FLAG_NO_MOVE_ANIMATION; - win2.getAttrs().width = 10; - win2.getAttrs().height = 10; + win2.mAttrs.flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; + win2.mAttrs.privateFlags |= PRIVATE_FLAG_NO_MOVE_ANIMATION; + win2.mAttrs.width = 10; + win2.mAttrs.height = 10; win2.setSystemGestureExclusion(Collections.emptyList()); performLayout(dc); @@ -1502,10 +1502,10 @@ public class DisplayContentTests extends WindowTestsBase { final DisplayContent dc = createNewDisplay(); final WindowState win = newWindowBuilder("win", TYPE_BASE_APPLICATION).setDisplay( dc).build(); - win.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; - win.getAttrs().layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; - win.getAttrs().privateFlags |= PRIVATE_FLAG_NO_MOVE_ANIMATION; - win.getAttrs().insetsFlags.behavior = BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE; + win.mAttrs.flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; + win.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; + win.mAttrs.privateFlags |= PRIVATE_FLAG_NO_MOVE_ANIMATION; + win.mAttrs.insetsFlags.behavior = BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE; win.setRequestedVisibleTypes(0, navigationBars() | statusBars()); win.mActivityRecord.mTargetSdk = P; @@ -1527,9 +1527,9 @@ public class DisplayContentTests extends WindowTestsBase { final DisplayContent dc = createNewDisplay(); final WindowState win = newWindowBuilder("win", TYPE_BASE_APPLICATION).setDisplay( dc).build(); - win.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; - win.getAttrs().layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; - win.getAttrs().privateFlags |= PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION; + win.mAttrs.flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; + win.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; + win.mAttrs.privateFlags |= PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION; win.setSystemGestureExclusion(Collections.singletonList(dc.getBounds())); performLayout(dc); diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java index 09fe75da18cb..19cdb13fbe7d 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java @@ -1084,7 +1084,7 @@ public class DisplayRotationTests { final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(); attrs.rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS; - doReturn(attrs).when(win).getAttrs(); + WindowTestsBase.setFieldValue(win, "mAttrs", attrs); doReturn(true).when(mMockDisplayPolicy).navigationBarCanMove(); doReturn(win).when(mMockDisplayPolicy).getTopFullscreenOpaqueWindow(); mMockDisplayContent.mCurrentFocus = win; diff --git a/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java index 358448e709f3..adeeb9810ce2 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java @@ -120,7 +120,7 @@ public class WallpaperControllerTests extends WindowTestsBase { // No wallpaper WSA Surface final WindowState wallpaperWindow = createWallpaperWindow(dc); - WindowManager.LayoutParams attrs = wallpaperWindow.getAttrs(); + WindowManager.LayoutParams attrs = wallpaperWindow.mAttrs; Rect bounds = dc.getBounds(); int displayWidth = dc.getBounds().width(); int displayHeight = dc.getBounds().height(); @@ -170,7 +170,7 @@ public class WallpaperControllerTests extends WindowTestsBase { public void testWallpaperZoom() throws RemoteException { final DisplayContent dc = mWm.mRoot.getDefaultDisplay(); final WindowState wallpaperWindow = createWallpaperWindow(dc); - wallpaperWindow.getAttrs().privateFlags |= + wallpaperWindow.mAttrs.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS; final WindowState homeWindow = createWallpaperTargetWindow(dc); @@ -201,7 +201,7 @@ public class WallpaperControllerTests extends WindowTestsBase { public void testWallpaperZoom_shouldNotScaleWallpaper() throws RemoteException { final DisplayContent dc = mWm.mRoot.getDefaultDisplay(); final WindowState wallpaperWindow = createWallpaperWindow(dc); - wallpaperWindow.getAttrs().privateFlags |= + wallpaperWindow.mAttrs.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS; final WindowState homeWindow = createWallpaperTargetWindow(dc); @@ -234,7 +234,7 @@ public class WallpaperControllerTests extends WindowTestsBase { public void testWallpaperZoom_multipleCallers() { final DisplayContent dc = mWm.mRoot.getDefaultDisplay(); final WindowState wallpaperWindow = createWallpaperWindow(dc); - wallpaperWindow.getAttrs().privateFlags |= + wallpaperWindow.mAttrs.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS; @@ -580,7 +580,7 @@ public class WallpaperControllerTests extends WindowTestsBase { WindowState appWindow = newWindowBuilder("wallpaperTargetWindow", TYPE_BASE_APPLICATION).setWindowToken(homeActivity).build(); - appWindow.getAttrs().flags |= FLAG_SHOW_WALLPAPER; + appWindow.mAttrs.flags |= FLAG_SHOW_WALLPAPER; appWindow.mHasSurface = true; spyOn(appWindow); doReturn(true).when(appWindow).isDrawFinishedLw(); diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java index c6416850c464..c0642f5533eb 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java @@ -136,6 +136,7 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -1024,6 +1025,16 @@ public class WindowTestsBase extends SystemServiceTestsBase { displayContent.performDisplayOverrideConfigUpdate(c); } + static void setFieldValue(Object o, String fieldName, Object value) { + try { + final Field field = o.getClass().getDeclaredField(fieldName); + field.setAccessible(true); + field.set(o, value); + } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + static void makeDisplayLargeScreen(DisplayContent displayContent) { final int swDp = displayContent.getConfiguration().smallestScreenWidthDp; if (swDp < WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP) { |