Renamed a few methods in ActivityRecord (42/n).

This is in preparation for having the ActivityRecord class
extend AppWindowToken where name distinction will be important.
There is no functional change in this CL.

ActivityRecord.realActivity -> mActivityComponent
ActivityRecord.userId -> mUserId
ActivityRecord.getTask() -> getTaskRecord()
ActivityRecord.getStack() -> getActivityStack()
ActivityRecord.service -> mAtmService
WindowContainer.mService -> mWmService

Bug: 80414790
Test: Existing tests pass.
Change-Id: Ie5788db7f2e823c7d5b64c7ce6eaade1c19c4dcd
diff --git a/services/core/java/com/android/server/wm/ActivityDisplay.java b/services/core/java/com/android/server/wm/ActivityDisplay.java
index 84750b3..7bf2c94 100644
--- a/services/core/java/com/android/server/wm/ActivityDisplay.java
+++ b/services/core/java/com/android/server/wm/ActivityDisplay.java
@@ -1242,7 +1242,7 @@
             for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
                 final ActivityRecord r = activities.get(activityNdx);
                 if (r.isActivityTypeHome()
-                        && ((userId == UserHandle.USER_ALL) || (r.userId == userId))) {
+                        && ((userId == UserHandle.USER_ALL) || (r.mUserId == userId))) {
                     return r;
                 }
             }
diff --git a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java
index 16df52d..12690a9 100644
--- a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java
+++ b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java
@@ -254,7 +254,7 @@
             type = getTransitionType(info);
             processRecord = findProcessForActivity(launchedActivity);
             processName = launchedActivity.processName;
-            userId = launchedActivity.userId;
+            userId = launchedActivity.mUserId;
             launchedActivityShortComponentName = launchedActivity.shortComponentName;
             activityRecordIdHashCode = System.identityHashCode(launchedActivity);
             this.windowsFullyDrawnDelayMs = windowsFullyDrawnDelayMs;
@@ -520,7 +520,7 @@
         if (info.launchedActivity != activityRecord) {
             return;
         }
-        final TaskRecord t = activityRecord.getTask();
+        final TaskRecord t = activityRecord.getTaskRecord();
         final SomeArgs args = SomeArgs.obtain();
         args.arg1 = t;
         args.arg2 = activityRecord;
@@ -893,7 +893,7 @@
             builder.addTaggedData(FIELD_ACTIVITY_RECORD_TARGET_ACTIVITY, r.info.targetActivity);
             builder.addTaggedData(FIELD_ACTIVITY_RECORD_FLAGS, r.info.flags);
             builder.addTaggedData(FIELD_ACTIVITY_RECORD_REAL_ACTIVITY,
-                    r.realActivity.toShortString());
+                    r.mActivityComponent.toShortString());
             builder.addTaggedData(FIELD_ACTIVITY_RECORD_SHORT_COMPONENT_NAME, r.shortComponentName);
             builder.addTaggedData(FIELD_ACTIVITY_RECORD_PROCESS_NAME, r.processName);
             builder.addTaggedData(FIELD_ACTIVITY_RECORD_IS_FULLSCREEN, r.fullscreen ? 1 : 0);
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 6f2461b..25399ef 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -244,7 +244,7 @@
     private static final String ATTR_COMPONENTSPECIFIED = "component_specified";
     static final String ACTIVITY_ICON_SUFFIX = "_activity_icon_";
 
-    final ActivityTaskManagerService service; // owner
+    final ActivityTaskManagerService mAtmService; // owner
     final IApplicationToken.Stub appToken; // window manager token
     // TODO: Remove after unification
     AppWindowToken mAppWindowToken;
@@ -255,9 +255,9 @@
     final int launchedFromPid; // always the pid who started the activity.
     final int launchedFromUid; // always the uid who started the activity.
     final String launchedFromPackage; // always the package who started the activity.
-    final int userId;          // Which user is this running for?
+    final int mUserId;          // Which user is this running for?
     final Intent intent;    // the original intent that generated us
-    final ComponentName realActivity;  // the intent component, or target of an alias.
+    final ComponentName mActivityComponent;  // the intent component, or target of an alias.
     final String shortComponentName; // the short component name of the intent
     final String resolvedType; // as per original caller;
     final String packageName; // the package implementing intent's component
@@ -407,14 +407,14 @@
                 pw.print(" processName="); pw.println(processName);
         pw.print(prefix); pw.print("launchedFromUid="); pw.print(launchedFromUid);
                 pw.print(" launchedFromPackage="); pw.print(launchedFromPackage);
-                pw.print(" userId="); pw.println(userId);
+                pw.print(" userId="); pw.println(mUserId);
         pw.print(prefix); pw.print("app="); pw.println(app);
         pw.print(prefix); pw.println(intent.toInsecureStringWithClip());
         pw.print(prefix); pw.print("frontOfTask="); pw.print(frontOfTask);
                 pw.print(" task="); pw.println(task);
         pw.print(prefix); pw.print("taskAffinity="); pw.println(taskAffinity);
-        pw.print(prefix); pw.print("realActivity=");
-                pw.println(realActivity.flattenToShortString());
+        pw.print(prefix); pw.print("mActivityComponent=");
+                pw.println(mActivityComponent.flattenToShortString());
         if (appInfo != null) {
             pw.print(prefix); pw.print("baseDir="); pw.println(appInfo.sourceDir);
             if (!Objects.equals(appInfo.sourceDir, appInfo.publicSourceDir)) {
@@ -644,7 +644,7 @@
                     "Reporting activity moved to display" + ", activityRecord=" + this
                             + ", displayId=" + displayId + ", config=" + config);
 
-            service.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
+            mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
                     MoveToDisplayItem.obtain(displayId, config));
         } catch (RemoteException e) {
             // If process died, whatever.
@@ -662,7 +662,7 @@
             if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending new config to " + this + ", config: "
                     + config);
 
-            service.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
+            mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
                     ActivityConfigurationChangeItem.obtain(config));
         } catch (RemoteException e) {
             // If process died, whatever.
@@ -689,7 +689,7 @@
 
     private void scheduleMultiWindowModeChanged(Configuration overrideConfig) {
         try {
-            service.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
+            mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
                     MultiWindowModeChangeItem.obtain(mLastReportedMultiWindowMode, overrideConfig));
         } catch (Exception e) {
             // If process died, I don't care.
@@ -720,7 +720,7 @@
 
     private void schedulePictureInPictureModeChanged(Configuration overrideConfig) {
         try {
-            service.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
+            mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
                     PipModeChangeItem.obtain(mLastReportedPictureInPictureMode,
                             overrideConfig));
         } catch (Exception e) {
@@ -741,10 +741,10 @@
 
     @Override
     protected ConfigurationContainer getParent() {
-        return getTask();
+        return getTaskRecord();
     }
 
-    TaskRecord getTask() {
+    TaskRecord getTaskRecord() {
         return task;
     }
 
@@ -765,12 +765,12 @@
      * @param reparenting   Whether we're in the middle of reparenting.
      */
     void setTask(TaskRecord task, boolean reparenting) {
-        // Do nothing if the {@link TaskRecord} is the same as the current {@link getTask}.
-        if (task != null && task == getTask()) {
+        // Do nothing if the {@link TaskRecord} is the same as the current {@link getTaskRecord}.
+        if (task != null && task == getTaskRecord()) {
             return;
         }
 
-        final ActivityStack oldStack = getStack();
+        final ActivityStack oldStack = getActivityStack();
         final ActivityStack newStack = task != null ? task.getStack() : null;
 
         // Inform old stack (if present) of activity removal and new stack (if set) of activity
@@ -819,7 +819,7 @@
                 return null;
             }
             ActivityRecord r = token.weakActivity.get();
-            if (r == null || r.getStack() == null) {
+            if (r == null || r.getActivityStack() == null) {
                 return null;
             }
             return r;
@@ -852,7 +852,7 @@
     }
 
     boolean isResolverActivity() {
-        return ResolverActivity.class.getName().equals(realActivity.getClassName());
+        return ResolverActivity.class.getName().equals(mActivityComponent.getClassName());
     }
 
     boolean isResolverOrChildActivity() {
@@ -861,7 +861,7 @@
         }
         try {
             return ResolverActivity.class.isAssignableFrom(
-                    Object.class.getClassLoader().loadClass(realActivity.getClassName()));
+                    Object.class.getClassLoader().loadClass(mActivityComponent.getClassName()));
         } catch (ClassNotFoundException e) {
             return false;
         }
@@ -873,14 +873,14 @@
             ActivityRecord _resultTo, String _resultWho, int _reqCode, boolean _componentSpecified,
             boolean _rootVoiceInteraction, ActivityStackSupervisor supervisor,
             ActivityOptions options, ActivityRecord sourceRecord) {
-        service = _service;
+        mAtmService = _service;
         mRootActivityContainer = _service.mRootActivityContainer;
         appToken = new Token(this, _intent);
         info = aInfo;
         launchedFromPid = _launchedFromPid;
         launchedFromUid = _launchedFromUid;
         launchedFromPackage = _launchedFromPackage;
-        userId = UserHandle.getUserId(aInfo.applicationInfo.uid);
+        mUserId = UserHandle.getUserId(aInfo.applicationInfo.uid);
         intent = _intent;
         shortComponentName = _intent.getComponent().flattenToShortString();
         resolvedType = _resolvedType;
@@ -917,9 +917,9 @@
                 || (aInfo.targetActivity.equals(_intent.getComponent().getClassName())
                 && (aInfo.launchMode == LAUNCH_MULTIPLE
                 || aInfo.launchMode == LAUNCH_SINGLE_TOP))) {
-            realActivity = _intent.getComponent();
+            mActivityComponent = _intent.getComponent();
         } else {
-            realActivity = new ComponentName(aInfo.packageName, aInfo.targetActivity);
+            mActivityComponent = new ComponentName(aInfo.packageName, aInfo.targetActivity);
         }
         taskAffinity = aInfo.taskAffinity;
         stateNotNeeded = (aInfo.flags & FLAG_STATE_NOT_NEEDED) != 0;
@@ -958,7 +958,7 @@
         launchMode = aInfo.launchMode;
 
         Entry ent = AttributeCache.instance().get(packageName,
-                realTheme, com.android.internal.R.styleable.Window, userId);
+                realTheme, com.android.internal.R.styleable.Window, mUserId);
 
         if (ent != null) {
             fullscreen = !ActivityInfo.isTranslucentOrFloating(ent.array);
@@ -1038,7 +1038,7 @@
         updateOverrideConfiguration();
 
         // TODO: remove after unification
-        mAppWindowToken = service.mWindowManager.mRoot.getAppWindowToken(appToken.asBinder());
+        mAppWindowToken = mAtmService.mWindowManager.mRoot.getAppWindowToken(appToken.asBinder());
         if (mAppWindowToken != null) {
             // TODO: Should this throw an exception instead?
             Slog.w(TAG, "Attempted to add existing app token: " + appToken);
@@ -1048,7 +1048,7 @@
                 throw new IllegalArgumentException("AppWindowContainerController: invalid "
                         + " controller=" + taskController);
             }
-            mAppWindowToken = createAppWindow(service.mWindowManager, appToken,
+            mAppWindowToken = createAppWindow(mAtmService.mWindowManager, appToken,
                     task.voiceSession != null, container.getDisplayContent(),
                     ActivityTaskManagerService.getInputDispatchingTimeoutLocked(this)
                             * 1000000L, fullscreen,
@@ -1098,16 +1098,16 @@
             boolean fullscreen, boolean showForAllUsers, int targetSdk, int orientation,
             int rotationAnimationHint, int configChanges, boolean launchTaskBehind,
             boolean alwaysFocusable) {
-        return new AppWindowToken(service, token, realActivity, voiceInteraction, dc,
+        return new AppWindowToken(service, token, mActivityComponent, voiceInteraction, dc,
                 inputDispatchingTimeoutNanos, fullscreen, showForAllUsers, targetSdk, orientation,
                 rotationAnimationHint, configChanges, launchTaskBehind, alwaysFocusable,
                 this);
     }
 
     void removeWindowContainer() {
-        if (service.mWindowManager.mRoot == null) return;
+        if (mAtmService.mWindowManager.mRoot == null) return;
 
-        final DisplayContent dc = service.mWindowManager.mRoot.getDisplayContent(
+        final DisplayContent dc = mAtmService.mWindowManager.mRoot.getDisplayContent(
                 getDisplayId());
         if (dc == null) {
             Slog.w(TAG, "removeWindowContainer: Attempted to remove token: "
@@ -1193,7 +1193,7 @@
      */
     private boolean canLaunchAssistActivity(String packageName) {
         final ComponentName assistComponent =
-                service.mActiveVoiceInteractionServiceComponent;
+                mAtmService.mActiveVoiceInteractionServiceComponent;
         if (assistComponent != null) {
             return assistComponent.getPackageName().equals(packageName);
         }
@@ -1213,8 +1213,8 @@
                 // We only allow home activities to be resizeable if they explicitly requested it.
                 info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
             }
-        } else if (realActivity.getClassName().contains(LEGACY_RECENTS_PACKAGE_NAME)
-                || service.getRecentTasks().isRecentsComponent(realActivity, appInfo.uid)) {
+        } else if (mActivityComponent.getClassName().contains(LEGACY_RECENTS_PACKAGE_NAME)
+                || mAtmService.getRecentTasks().isRecentsComponent(mActivityComponent, appInfo.uid)) {
             activityType = ACTIVITY_TYPE_RECENTS;
         } else if (options != null && options.getLaunchActivityType() == ACTIVITY_TYPE_ASSISTANT
                 && canLaunchAssistActivity(launchedFromPackage)) {
@@ -1232,16 +1232,16 @@
     /**
      * @return Stack value from current task, null if there is no task.
      */
-    <T extends ActivityStack> T getStack() {
+    <T extends ActivityStack> T getActivityStack() {
         return task != null ? (T) task.getStack() : null;
     }
 
     int getStackId() {
-        return getStack() != null ? getStack().mStackId : INVALID_STACK_ID;
+        return getActivityStack() != null ? getActivityStack().mStackId : INVALID_STACK_ID;
     }
 
     ActivityDisplay getDisplay() {
-        final ActivityStack stack = getStack();
+        final ActivityStack stack = getActivityStack();
         return stack != null ? stack.getDisplay() : null;
     }
 
@@ -1272,7 +1272,7 @@
     }
 
     boolean isInStackLocked() {
-        final ActivityStack stack = getStack();
+        final ActivityStack stack = getActivityStack();
         return stack != null && stack.isInStackLocked(this) != null;
     }
 
@@ -1302,7 +1302,7 @@
      * @return whether this activity supports PiP multi-window and can be put in the pinned stack.
      */
     boolean supportsPictureInPicture() {
-        return service.mSupportsPictureInPicture && isActivityTypeStandardOrUndefined()
+        return mAtmService.mSupportsPictureInPicture && isActivityTypeStandardOrUndefined()
                 && info.supportsPictureInPicture();
     }
 
@@ -1315,7 +1315,7 @@
         // An activity can not be docked even if it is considered resizeable because it only
         // supports picture-in-picture mode but has a non-resizeable resizeMode
         return super.supportsSplitScreenWindowingMode()
-                && service.mSupportsSplitScreenMultiWindow && supportsResizeableMultiWindow();
+                && mAtmService.mSupportsSplitScreenMultiWindow && supportsResizeableMultiWindow();
     }
 
     /**
@@ -1323,16 +1323,16 @@
      *         stack.
      */
     boolean supportsFreeform() {
-        return service.mSupportsFreeformWindowManagement && supportsResizeableMultiWindow();
+        return mAtmService.mSupportsFreeformWindowManagement && supportsResizeableMultiWindow();
     }
 
     /**
      * @return whether this activity supports non-PiP multi-window.
      */
     private boolean supportsResizeableMultiWindow() {
-        return service.mSupportsMultiWindow && !isActivityTypeHome()
+        return mAtmService.mSupportsMultiWindow && !isActivityTypeHome()
                 && (ActivityInfo.isResizeableMode(info.resizeMode)
-                        || service.mForceResizableActivities);
+                        || mAtmService.mForceResizableActivities);
     }
 
     /**
@@ -1343,7 +1343,7 @@
      *         secondary screen.
      */
     boolean canBeLaunchedOnDisplay(int displayId) {
-        return service.mStackSupervisor.canPlaceEntityOnDisplay(displayId, launchedFromPid,
+        return mAtmService.mStackSupervisor.canPlaceEntityOnDisplay(displayId, launchedFromPid,
                 launchedFromUid, info);
     }
 
@@ -1364,13 +1364,13 @@
         }
 
         // Check to see if we are in VR mode, and disallow PiP if so
-        if (service.shouldDisableNonVrUiLocked()) {
+        if (mAtmService.shouldDisableNonVrUiLocked()) {
             return false;
         }
 
-        boolean isKeyguardLocked = service.isKeyguardLocked();
+        boolean isKeyguardLocked = mAtmService.isKeyguardLocked();
         boolean isCurrentAppLocked =
-                service.getLockTaskModeState() != LOCK_TASK_MODE_NONE;
+                mAtmService.getLockTaskModeState() != LOCK_TASK_MODE_NONE;
         final ActivityDisplay display = getDisplay();
         boolean hasPinnedStack = display != null && display.hasPinnedStack();
         // Don't return early if !isNotLocked, since we want to throw an exception if the activity
@@ -1411,7 +1411,7 @@
      * @return Whether AppOps allows this package to enter picture-in-picture.
      */
     private boolean checkEnterPictureInPictureAppOpsState() {
-        return service.getAppOpsService().checkOperation(
+        return mAtmService.getAppOpsService().checkOperation(
                 OP_PICTURE_IN_PICTURE, appInfo.uid, packageName) == MODE_ALLOWED;
     }
 
@@ -1428,8 +1428,8 @@
             return false;
         }
 
-        final TaskRecord task = getTask();
-        final ActivityStack stack = getStack();
+        final TaskRecord task = getTaskRecord();
+        final ActivityStack stack = getActivityStack();
         if (stack == null) {
             Slog.w(TAG, "moveActivityStackToFront: invalid task or stack: activity="
                     + this + " task=" + task);
@@ -1451,7 +1451,7 @@
         // Report top activity change to tracking services and WM
         if (mRootActivityContainer.getTopResumedActivity() == this) {
             // TODO(b/111361570): Support multiple focused apps in WM
-            service.setResumedActivityUncheckLocked(this, reason);
+            mAtmService.setResumedActivityUncheckLocked(this, reason);
         }
         return true;
     }
@@ -1461,7 +1461,7 @@
      *         {@link LayoutParams#FLAG_DISMISS_KEYGUARD} set
      */
     boolean hasDismissKeyguardWindows() {
-        return service.mWindowManager.containsDismissKeyguardWindow(appToken);
+        return mAtmService.mWindowManager.containsDismissKeyguardWindow(appToken);
     }
 
     void makeFinishingLocked() {
@@ -1473,14 +1473,14 @@
             clearOptionsLocked();
         }
 
-        if (service != null) {
-            service.getTaskChangeNotificationController().notifyTaskStackChanged();
+        if (mAtmService != null) {
+            mAtmService.getTaskChangeNotificationController().notifyTaskStackChanged();
         }
     }
 
     UriPermissionOwner getUriPermissionsLocked() {
         if (uriPermissions == null) {
-            uriPermissions = new UriPermissionOwner(service.mUgmInternal, this);
+            uriPermissions = new UriPermissionOwner(mAtmService.mUgmInternal, this);
         }
         return uriPermissions;
     }
@@ -1522,8 +1522,8 @@
     }
 
     final boolean isSleeping() {
-        final ActivityStack stack = getStack();
-        return stack != null ? stack.shouldSleepActivities() : service.isSleepingLocked();
+        final ActivityStack stack = getActivityStack();
+        return stack != null ? stack.shouldSleepActivities() : mAtmService.isSleepingLocked();
     }
 
     /**
@@ -1532,8 +1532,8 @@
      */
     final void deliverNewIntentLocked(int callingUid, Intent intent, String referrer) {
         // The activity now gets access to the data associated with this Intent.
-        service.mUgmInternal.grantUriPermissionFromIntent(callingUid, packageName,
-                intent, getUriPermissionsLocked(), userId);
+        mAtmService.mUgmInternal.grantUriPermissionFromIntent(callingUid, packageName,
+                intent, getUriPermissionsLocked(), mUserId);
         final ReferrerIntent rintent = new ReferrerIntent(intent, referrer);
         boolean unsent = true;
         final boolean isTopActivityWhileSleeping = isTopRunningActivity() && isSleeping();
@@ -1547,7 +1547,7 @@
             try {
                 ArrayList<ReferrerIntent> ar = new ArrayList<>(1);
                 ar.add(rintent);
-                service.getLifecycleManager().scheduleTransaction(
+                mAtmService.getLifecycleManager().scheduleTransaction(
                         app.getThread(), appToken, NewIntentItem.obtain(ar, mState == PAUSED));
                 unsent = false;
             } catch (RemoteException e) {
@@ -1781,7 +1781,7 @@
 
         mState = state;
 
-        final TaskRecord parent = getTask();
+        final TaskRecord parent = getTaskRecord();
 
         if (parent != null) {
             parent.onActivityStateChanged(this, state, reason);
@@ -1879,7 +1879,7 @@
         // If this activity is paused, tell it to now show its window.
         if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY,
                 "Making visible and scheduling visibility: " + this);
-        final ActivityStack stack = getStack();
+        final ActivityStack stack = getActivityStack();
         try {
             if (stack.mTranslucentActivityWaiting != null) {
                 updateOptionsLocked(returningOptions);
@@ -1907,13 +1907,13 @@
     void makeClientVisible() {
         mClientVisibilityDeferred = false;
         try {
-            service.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
+            mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
                     WindowVisibilityItem.obtain(true /* showWindow */));
             if (shouldPauseWhenBecomingVisible()) {
                 // An activity must be in the {@link PAUSING} state for the system to validate
                 // the move to {@link PAUSED}.
                 setState(PAUSING, "makeVisibleIfNeeded");
-                service.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
+                mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
                         PauseActivityItem.obtain(finishing, false /* userLeaving */,
                                 configChangeFlags, false /* dontReport */));
             }
@@ -1931,7 +1931,7 @@
         // paused state. We also avoid doing this for the activity the stack supervisor
         // considers the resumed activity, as normal means will bring the activity from STOPPED
         // to RESUMED. Adding PAUSING in this scenario will lead to double lifecycles.
-        if (!isState(STOPPED, STOPPING) || getStack().mTranslucentActivityWaiting != null
+        if (!isState(STOPPED, STOPPING) || getActivityStack().mTranslucentActivityWaiting != null
                 || isResumedActivityOnDisplay()) {
             return false;
         }
@@ -1994,8 +1994,8 @@
 
         if (isActivityTypeHome()) {
             WindowProcessController app = task.mActivities.get(0).app;
-            if (hasProcess() && app != service.mHomeProcess) {
-                service.mHomeProcess = app;
+            if (hasProcess() && app != mAtmService.mHomeProcess) {
+                mAtmService.mHomeProcess = app;
             }
         }
 
@@ -2010,7 +2010,7 @@
         mStackSupervisor.reportResumedActivityLocked(this);
 
         resumeKeyDispatchingLocked();
-        final ActivityStack stack = getStack();
+        final ActivityStack stack = getActivityStack();
         mStackSupervisor.mNoAnimActivities.clear();
 
         // Mark the point when the activity is resuming
@@ -2036,7 +2036,7 @@
 
     final void activityStoppedLocked(Bundle newIcicle, PersistableBundle newPersistentState,
             CharSequence description) {
-        final ActivityStack stack = getStack();
+        final ActivityStack stack = getActivityStack();
         if (mState != STOPPING) {
             Slog.i(TAG, "Activity reported stop, but no longer stopping: " + this);
             stack.mHandler.removeMessages(STOP_TIMEOUT_MSG, this);
@@ -2044,7 +2044,7 @@
         }
         if (newPersistentState != null) {
             persistentState = newPersistentState;
-            service.notifyTaskPersisterLocked(task, false);
+            mAtmService.notifyTaskPersisterLocked(task, false);
         }
         if (DEBUG_SAVED_STATE) Slog.i(TAG_SAVED_STATE, "Saving icicle of " + this + ": " + icicle);
 
@@ -2094,7 +2094,7 @@
             return false;
         }
 
-        final ActivityStack stack = getStack();
+        final ActivityStack stack = getActivityStack();
         if (stack == null) {
             return false;
         }
@@ -2107,7 +2107,7 @@
 
     void finishLaunchTickingLocked() {
         launchTickTime = 0;
-        final ActivityStack stack = getStack();
+        final ActivityStack stack = getActivityStack();
         if (stack != null) {
             stack.mHandler.removeMessages(LAUNCH_TICK_MSG);
         }
@@ -2168,7 +2168,7 @@
      * Called when the starting window for this container is drawn.
      */
     public void onStartingWindowDrawn(long timestamp) {
-        synchronized (service.mGlobalLock) {
+        synchronized (mAtmService.mGlobalLock) {
             mStackSupervisor.getActivityMetricsLogger().notifyStartingWindowDrawn(
                     getWindowingMode(), timestamp);
         }
@@ -2176,7 +2176,7 @@
 
     /** Called when the windows associated app window container are drawn. */
     public void onWindowsDrawn(boolean drawn, long timestamp) {
-        synchronized (service.mGlobalLock) {
+        synchronized (mAtmService.mGlobalLock) {
             mDrawn = drawn;
             if (!drawn) {
                 return;
@@ -2196,7 +2196,7 @@
 
     /** Called when the windows associated app window container are visible. */
     public void onWindowsVisible() {
-        synchronized (service.mGlobalLock) {
+        synchronized (mAtmService.mGlobalLock) {
             mStackSupervisor.reportActivityVisibleLocked(this);
             if (DEBUG_SWITCH) Log.v(TAG_SWITCH, "windowsVisibleLocked(): " + this);
             if (!nowVisible) {
@@ -2223,14 +2223,14 @@
                     mStackSupervisor.processStoppingActivitiesLocked(null /* idleActivity */,
                             false /* remove */, true /* processPausingActivities */);
                 }
-                service.scheduleAppGcsLocked();
+                mAtmService.scheduleAppGcsLocked();
             }
         }
     }
 
     /** Called when the windows associated app window container are no longer visible. */
     public void onWindowsGone() {
-        synchronized (service.mGlobalLock) {
+        synchronized (mAtmService.mGlobalLock) {
             if (DEBUG_SWITCH) Log.v(TAG_SWITCH, "windowsGone(): " + this);
             nowVisible = false;
         }
@@ -2248,7 +2248,7 @@
         ActivityRecord anrActivity;
         WindowProcessController anrApp;
         boolean windowFromSameProcessAsActivity;
-        synchronized (service.mGlobalLock) {
+        synchronized (mAtmService.mGlobalLock) {
             anrActivity = getWaitingHistoryRecordLocked();
             anrApp = app;
             windowFromSameProcessAsActivity =
@@ -2256,13 +2256,13 @@
         }
 
         if (windowFromSameProcessAsActivity) {
-            return service.mAmInternal.inputDispatchingTimedOut(anrApp.mOwner,
+            return mAtmService.mAmInternal.inputDispatchingTimedOut(anrApp.mOwner,
                     anrActivity.shortComponentName, anrActivity.appInfo, shortComponentName,
                     app, false, reason);
         } else {
             // In this case another process added windows using this activity token. So, we call the
             // generic service input dispatch timed out method so that the right process is blamed.
-            return service.mAmInternal.inputDispatchingTimedOut(
+            return mAtmService.mAmInternal.inputDispatchingTimedOut(
                     windowPid, false /* aboveSystem */, reason) < 0;
         }
     }
@@ -2289,14 +2289,14 @@
     public boolean okToShowLocked() {
         // We cannot show activities when the device is locked and the application is not
         // encryption aware.
-        if (!StorageManager.isUserKeyUnlocked(userId)
+        if (!StorageManager.isUserKeyUnlocked(mUserId)
                 && !info.applicationInfo.isEncryptionAware()) {
             return false;
         }
 
         return (info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0
-                || (mStackSupervisor.isCurrentProfileLocked(userId)
-                && service.mAmInternal.isUserRunning(userId, 0 /* flags */));
+                || (mStackSupervisor.isCurrentProfileLocked(mUserId)
+                && mAtmService.mAmInternal.isUserRunning(mUserId, 0 /* flags */));
     }
 
     /**
@@ -2343,13 +2343,13 @@
 
     static ActivityRecord isInStackLocked(IBinder token) {
         final ActivityRecord r = ActivityRecord.forTokenLocked(token);
-        return (r != null) ? r.getStack().isInStackLocked(r) : null;
+        return (r != null) ? r.getActivityStack().isInStackLocked(r) : null;
     }
 
     static ActivityStack getStackLocked(IBinder token) {
         final ActivityRecord r = ActivityRecord.isInStackLocked(token);
         if (r != null) {
-            return r.getStack();
+            return r.getActivityStack();
         }
         return null;
     }
@@ -2359,7 +2359,7 @@
      *         {@link android.view.Display#INVALID_DISPLAY} if not attached.
      */
     int getDisplayId() {
-        final ActivityStack stack = getStack();
+        final ActivityStack stack = getActivityStack();
         if (stack == null) {
             return INVALID_DISPLAY;
         }
@@ -2371,7 +2371,7 @@
             // This would be redundant.
             return false;
         }
-        final ActivityStack stack = getStack();
+        final ActivityStack stack = getActivityStack();
         if (stack == null || this == stack.getResumedActivity() || this == stack.mPausingActivity
                 || !haveState || !stopped) {
             // We're not ready for this kind of thing.
@@ -2397,7 +2397,7 @@
             final File iconFile = new File(TaskPersister.getUserImagesDir(task.userId),
                     iconFilename);
             final String iconFilePath = iconFile.getAbsolutePath();
-            service.getRecentTasks().saveImage(icon, iconFilePath);
+            mAtmService.getRecentTasks().saveImage(icon, iconFilePath);
             _taskDescription.setIconFilename(iconFilePath);
         }
         taskDescription = _taskDescription;
@@ -2433,7 +2433,7 @@
         }
 
         final CompatibilityInfo compatInfo =
-                service.compatibilityInfoForPackageLocked(info.applicationInfo);
+                mAtmService.compatibilityInfoForPackageLocked(info.applicationInfo);
         final boolean shown = addStartingWindow(packageName, theme,
                 compatInfo, nonLocalizedLabel, labelRes, icon, logo, windowFlags,
                 prev != null ? prev.appToken : null, newTask, taskSwitch, isProcessRunning(),
@@ -2466,12 +2466,12 @@
                 displayId, displayConfig, mayFreezeScreenLocked(app));
         if (config != null) {
             frozenBeforeDestroy = true;
-            if (!service.updateDisplayOverrideConfigurationLocked(config, this,
+            if (!mAtmService.updateDisplayOverrideConfigurationLocked(config, this,
                     false /* deferResume */, displayId)) {
                 mRootActivityContainer.resumeFocusedStacksTopActivities();
             }
         }
-        service.getTaskChangeNotificationController().notifyActivityRequestedOrientationChanged(
+        mAtmService.getTaskChangeNotificationController().notifyActivityRequestedOrientationChanged(
                 task.taskId, requestedOrientation);
     }
 
@@ -2486,7 +2486,7 @@
         mAppWindowToken.setOrientation(requestedOrientation);
 
         final IBinder binder = freezeScreenIfNeeded ? appToken.asBinder() : null;
-        return service.mWindowManager.updateOrientationFromAppTokens(displayConfig, binder,
+        return mAtmService.mWindowManager.updateOrientationFromAppTokens(displayConfig, binder,
                 displayId);
     }
 
@@ -2572,7 +2572,7 @@
     private void computeBounds(Rect outBounds) {
         outBounds.setEmpty();
         final float maxAspectRatio = info.maxAspectRatio;
-        final ActivityStack stack = getStack();
+        final ActivityStack stack = getActivityStack();
         if (task == null || stack == null || task.inMultiWindowMode() || maxAspectRatio == 0
                 || isInVrUiMode(getConfiguration())) {
             // We don't set override configuration if that activity task isn't fullscreen. I.e. the
@@ -2618,7 +2618,7 @@
         // bounds would end up too small.
         outBounds.set(0, 0, maxActivityWidth + appBounds.left, maxActivityHeight + appBounds.top);
 
-        if (service.mWindowManager.getNavBarPosition(getDisplayId()) == NAV_BAR_LEFT) {
+        if (mAtmService.mWindowManager.getNavBarPosition(getDisplayId()) == NAV_BAR_LEFT) {
             // Position the activity frame on the opposite side of the nav bar.
             outBounds.left = appBounds.right - maxActivityWidth;
             outBounds.right = appBounds.right;
@@ -2654,7 +2654,7 @@
      */
     boolean ensureActivityConfiguration(int globalChanges, boolean preserveWindow,
             boolean ignoreStopState) {
-        final ActivityStack stack = getStack();
+        final ActivityStack stack = getActivityStack();
         if (stack.mConfigWillChange) {
             if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
                     "Skipping config check (will change): " + this);
@@ -2717,7 +2717,7 @@
         // Update last reported values.
         final Configuration newMergedOverrideConfig = getMergedOverrideConfiguration();
 
-        setLastReportedConfiguration(service.getGlobalConfiguration(), newMergedOverrideConfig);
+        setLastReportedConfiguration(mAtmService.getGlobalConfiguration(), newMergedOverrideConfig);
 
         if (mState == INITIALIZING) {
             // No need to relaunch or schedule new config for activity that hasn't been launched
@@ -2771,7 +2771,7 @@
             final boolean hasResizeChange = hasResizeChange(changes & ~info.getRealConfigChanged());
             if (hasResizeChange) {
                 final boolean isDragResizing =
-                        getTask().getWindowContainerController().isDragResizing();
+                        getTaskRecord().getWindowContainerController().isDragResizing();
                 mRelaunchReason = isDragResizing ? RELAUNCH_REASON_FREE_RESIZE
                         : RELAUNCH_REASON_WINDOWING_MODE_RESIZE;
             } else {
@@ -2904,7 +2904,7 @@
     }
 
     void relaunchActivityLocked(boolean andResume, boolean preserveWindow) {
-        if (service.mSuppressResizeConfigChanges && preserveWindow) {
+        if (mAtmService.mSuppressResizeConfigChanges && preserveWindow) {
             configChangeFlags = 0;
             return;
         }
@@ -2920,7 +2920,7 @@
                         + " newIntents=" + pendingNewIntents + " andResume=" + andResume
                         + " preserveWindow=" + preserveWindow);
         EventLog.writeEvent(andResume ? AM_RELAUNCH_RESUME_ACTIVITY
-                        : AM_RELAUNCH_ACTIVITY, userId, System.identityHashCode(this),
+                        : AM_RELAUNCH_ACTIVITY, mUserId, System.identityHashCode(this),
                 task.taskId, shortComponentName);
 
         startFreezingScreenLocked(app, 0);
@@ -2933,7 +2933,7 @@
             mStackSupervisor.activityRelaunchingLocked(this);
             final ClientTransactionItem callbackItem = ActivityRelaunchItem.obtain(pendingResults,
                     pendingNewIntents, configChangeFlags,
-                    new MergedConfiguration(service.getGlobalConfiguration(),
+                    new MergedConfiguration(mAtmService.getGlobalConfiguration(),
                             getMergedOverrideConfiguration()),
                     preserveWindow);
             final ActivityLifecycleItem lifecycleItem;
@@ -2946,7 +2946,7 @@
             final ClientTransaction transaction = ClientTransaction.obtain(app.getThread(), appToken);
             transaction.addCallback(callbackItem);
             transaction.setLifecycleStateRequest(lifecycleItem);
-            service.getLifecycleManager().scheduleTransaction(transaction);
+            mAtmService.getLifecycleManager().scheduleTransaction(transaction);
             // Note: don't need to call pauseIfSleepingLocked() here, because the caller will only
             // request resume if this activity is currently resumed, which implies we aren't
             // sleeping.
@@ -2960,9 +2960,9 @@
             }
             results = null;
             newIntents = null;
-            service.getAppWarningsLocked().onResumeActivity(this);
+            mAtmService.getAppWarningsLocked().onResumeActivity(this);
         } else {
-            final ActivityStack stack = getStack();
+            final ActivityStack stack = getActivityStack();
             if (stack != null) {
                 stack.mHandler.removeMessages(PAUSE_TIMEOUT_MSG, this);
             }
@@ -2977,7 +2977,7 @@
     private boolean isProcessRunning() {
         WindowProcessController proc = app;
         if (proc == null) {
-            proc = service.mProcessNames.get(processName, info.applicationInfo.uid);
+            proc = mAtmService.mProcessNames.get(processName, info.applicationInfo.uid);
         }
         return proc != null && proc.hasThread();
     }
@@ -3021,7 +3021,7 @@
             out.attribute(null, ATTR_RESOLVEDTYPE, resolvedType);
         }
         out.attribute(null, ATTR_COMPONENTSPECIFIED, String.valueOf(componentSpecified));
-        out.attribute(null, ATTR_USERID, String.valueOf(userId));
+        out.attribute(null, ATTR_USERID, String.valueOf(mUserId));
 
         if (taskDescription != null) {
             taskDescription.saveToXml(out);
@@ -3144,7 +3144,7 @@
      */
     boolean canShowWhenLocked() {
         return !inPinnedWindowingMode() && (mShowWhenLocked
-                || service.mWindowManager.containsShowWhenLockedWindow(appToken));
+                || mAtmService.mWindowManager.containsShowWhenLockedWindow(appToken));
     }
 
     void setTurnScreenOn(boolean turnScreenOn) {
@@ -3159,7 +3159,7 @@
      * @return true if the screen can be turned on, false otherwise.
      */
     boolean canTurnScreenOn() {
-        final ActivityStack stack = getStack();
+        final ActivityStack stack = getActivityStack();
         return mTurnScreenOn && stack != null &&
                 stack.checkKeyguardVisibility(this, true /* shouldBeVisible */, true /* isTop */);
     }
@@ -3200,7 +3200,7 @@
         sb.append("ActivityRecord{");
         sb.append(Integer.toHexString(System.identityHashCode(this)));
         sb.append(" u");
-        sb.append(userId);
+        sb.append(mUserId);
         sb.append(' ');
         sb.append(intent.getComponent().flattenToShortString());
         stringName = sb.toString();
@@ -3210,7 +3210,7 @@
     void writeIdentifierToProto(ProtoOutputStream proto, long fieldId) {
         final long token = proto.start(fieldId);
         proto.write(HASH_CODE, System.identityHashCode(this));
-        proto.write(USER_ID, userId);
+        proto.write(USER_ID, mUserId);
         proto.write(TITLE, intent.getComponent().flattenToShortString());
         proto.end(token);
     }
diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java
index 9fbeaf8..d40a4fa 100644
--- a/services/core/java/com/android/server/wm/ActivityStack.java
+++ b/services/core/java/com/android/server/wm/ActivityStack.java
@@ -538,7 +538,7 @@
                 // TODO(b/111361570): Support multiple focused apps in WM
                 mService.setResumedActivityUncheckLocked(record, reason);
             }
-            mStackSupervisor.mRecentTasks.add(record.getTask());
+            mStackSupervisor.mRecentTasks.add(record.getTaskRecord());
         }
     }
 
@@ -1106,8 +1106,8 @@
         if (r == null) {
             return null;
         }
-        final TaskRecord task = r.getTask();
-        final ActivityStack stack = r.getStack();
+        final TaskRecord task = r.getTaskRecord();
+        final ActivityStack stack = r.getActivityStack();
         if (stack != null && task.mActivities.contains(r) && mTaskHistory.contains(task)) {
             if (stack != this) Slog.w(TAG,
                     "Illegal state! task does not point to stack it is in.");
@@ -1282,7 +1282,7 @@
 
             // Overlays should not be considered as the task's logical top activity.
             final ActivityRecord r = task.getTopActivity(false /* includeOverlays */);
-            if (r == null || r.finishing || r.userId != userId ||
+            if (r == null || r.finishing || r.mUserId != userId ||
                     r.launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE) {
                 if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Skipping " + task + ": mismatch root " + r);
                 continue;
@@ -1309,7 +1309,7 @@
 
             if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Comparing existing cls="
                     + taskIntent.getComponent().flattenToShortString()
-                    + "/aff=" + r.getTask().rootAffinity + " to new cls="
+                    + "/aff=" + r.getTaskRecord().rootAffinity + " to new cls="
                     + intent.getComponent().flattenToShortString() + "/aff=" + info.taskAffinity);
             // TODO Refactor to remove duplications. Check if logic can be simplified.
             if (taskIntent != null && taskIntent.getComponent() != null &&
@@ -1368,7 +1368,7 @@
                 if (!r.okToShowLocked()) {
                     continue;
                 }
-                if (!r.finishing && r.userId == userId) {
+                if (!r.finishing && r.mUserId == userId) {
                     if (compareIntentFilters) {
                         if (r.intent.filterEquals(intent)) {
                             return r;
@@ -1452,7 +1452,7 @@
             for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
                 final ActivityRecord ar = activities.get(activityNdx);
 
-                if ((userId == ar.userId) && packageName.equals(ar.packageName)) {
+                if ((userId == ar.mUserId) && packageName.equals(ar.packageName)) {
                     ar.updateApplicationInfo(aInfo);
                 }
             }
@@ -1538,7 +1538,7 @@
 
     private boolean containsActivityFromStack(List<ActivityRecord> rs) {
         for (ActivityRecord r : rs) {
-            if (r.getStack() == this) {
+            if (r.getActivityStack() == this) {
                 return true;
             }
         }
@@ -1606,7 +1606,7 @@
         mLastNoHistoryActivity = (prev.intent.getFlags() & Intent.FLAG_ACTIVITY_NO_HISTORY) != 0
                 || (prev.info.flags & ActivityInfo.FLAG_NO_HISTORY) != 0 ? prev : null;
         prev.setState(PAUSING, "startPausingLocked");
-        prev.getTask().touchActiveTime();
+        prev.getTaskRecord().touchActiveTime();
         clearLaunchTime(prev);
 
         mService.updateCpuStats();
@@ -1614,7 +1614,7 @@
         if (prev.attachedToProcess()) {
             if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "Enqueueing pending pause: " + prev);
             try {
-                EventLogTags.writeAmPauseActivity(prev.userId, System.identityHashCode(prev),
+                EventLogTags.writeAmPauseActivity(prev.mUserId, System.identityHashCode(prev),
                         prev.shortComponentName, "userLeaving=" + userLeaving);
                 mService.updateUsageStats(prev, false);
 
@@ -1692,7 +1692,7 @@
                 return;
             } else {
                 EventLog.writeEvent(EventLogTags.AM_FAILED_TO_PAUSE,
-                        r.userId, System.identityHashCode(r), r.shortComponentName,
+                        r.mUserId, System.identityHashCode(r), r.shortComponentName,
                         mPausingActivity != null
                             ? mPausingActivity.shortComponentName : "(none)");
                 if (r.isState(PAUSING)) {
@@ -2573,9 +2573,9 @@
         // Make sure that the user who owns this activity is started.  If not,
         // we will just leave it as is because someone should be bringing
         // another user's activities to the top of the stack.
-        if (!mService.mAmInternal.hasStartedUserState(next.userId)) {
+        if (!mService.mAmInternal.hasStartedUserState(next.mUserId)) {
             Slog.w(TAG, "Skipping resume of top activity " + next
-                    + ": user " + next.userId + " is stopped");
+                    + ": user " + next.mUserId + " is stopped");
             return false;
         }
 
@@ -2702,7 +2702,7 @@
         // considered stopped.
         try {
             AppGlobals.getPackageManager().setPackageStoppedState(
-                    next.packageName, false, next.userId); /* TODO: Verify if correct userid */
+                    next.packageName, false, next.mUserId); /* TODO: Verify if correct userid */
         } catch (RemoteException e1) {
         } catch (IllegalArgumentException e) {
             Slog.w(TAG, "Failed trying to unstop package "
@@ -2723,7 +2723,7 @@
                     dwc.prepareAppTransition(TRANSIT_NONE, false);
                 } else {
                     dwc.prepareAppTransition(
-                            prev.getTask() == next.getTask() ? TRANSIT_ACTIVITY_CLOSE
+                            prev.getTaskRecord() == next.getTaskRecord() ? TRANSIT_ACTIVITY_CLOSE
                                     : TRANSIT_TASK_CLOSE, false);
                 }
                 prev.setVisibility(false);
@@ -2735,7 +2735,7 @@
                     dwc.prepareAppTransition(TRANSIT_NONE, false);
                 } else {
                     dwc.prepareAppTransition(
-                            prev.getTask() == next.getTask() ? TRANSIT_ACTIVITY_OPEN
+                            prev.getTaskRecord() == next.getTaskRecord() ? TRANSIT_ACTIVITY_OPEN
                                     : next.mLaunchTaskBehind ? TRANSIT_TASK_OPEN_BEHIND
                                             : TRANSIT_TASK_OPEN, false);
                 }
@@ -2858,8 +2858,8 @@
                 // Clear app token stopped state in window manager if needed.
                 next.notifyAppResumed(next.stopped);
 
-                EventLog.writeEvent(EventLogTags.AM_RESUME_ACTIVITY, next.userId,
-                        System.identityHashCode(next), next.getTask().taskId,
+                EventLog.writeEvent(EventLogTags.AM_RESUME_ACTIVITY, next.mUserId,
+                        System.identityHashCode(next), next.getTaskRecord().taskId,
                         next.shortComponentName);
 
                 next.sleeping = false;
@@ -3008,7 +3008,7 @@
 
     void startActivityLocked(ActivityRecord r, ActivityRecord focusedTopActivity,
             boolean newTask, boolean keepCurTransition, ActivityOptions options) {
-        TaskRecord rTask = r.getTask();
+        TaskRecord rTask = r.getTaskRecord();
         final int taskId = rTask.taskId;
         // mLaunchTaskBehind tasks get placed at the back of the task stack.
         if (!r.mLaunchTaskBehind && (taskForIdLocked(taskId) == null || newTask)) {
@@ -3049,7 +3049,7 @@
 
         // If we are not placing the new activity frontmost, we do not want to deliver the
         // onUserLeaving callback to the actual frontmost activity
-        final TaskRecord activityTask = r.getTask();
+        final TaskRecord activityTask = r.getTaskRecord();
         if (task == activityTask && mTaskHistory.indexOf(task) != (mTaskHistory.size() - 1)) {
             mStackSupervisor.mUserLeaving = false;
             if (DEBUG_USER_LEAVING) Slog.v(TAG_USER_LEAVING,
@@ -3122,12 +3122,12 @@
                 // "has the same starting icon" as the next one.  This allows the
                 // window manager to keep the previous window it had previously
                 // created, if it still had one.
-                TaskRecord prevTask = r.getTask();
+                TaskRecord prevTask = r.getTaskRecord();
                 ActivityRecord prev = prevTask.topRunningActivityWithStartingWindowLocked();
                 if (prev != null) {
                     // We don't want to reuse the previous starting preview if:
                     // (1) The current activity is in a different task.
-                    if (prev.getTask() != prevTask) {
+                    if (prev.getTaskRecord() != prevTask) {
                         prev = null;
                     }
                     // (2) The current activity is already displayed.
@@ -3160,7 +3160,7 @@
             return false;
         }
         final ActivityStack targetStack = toFrontTask != null
-                ? toFrontTask.getStack() : toFrontActivity.getStack();
+                ? toFrontTask.getStack() : toFrontActivity.getActivityStack();
         if (targetStack != null && targetStack.isActivityTypeAssistant()) {
             // Ensure the task/activity being brought forward is not the assistant
             return false;
@@ -3170,7 +3170,7 @@
 
     private boolean isTaskSwitch(ActivityRecord r,
             ActivityRecord topFocusedActivity) {
-        return topFocusedActivity != null && r.getTask() != topFocusedActivity.getTask();
+        return topFocusedActivity != null && r.getTaskRecord() != topFocusedActivity.getTaskRecord();
     }
 
     /**
@@ -3237,16 +3237,16 @@
                         !mTaskHistory.isEmpty() && !mTaskHistory.get(0).mActivities.isEmpty() ?
                                 mTaskHistory.get(0).mActivities.get(0) : null;
                 if (bottom != null && target.taskAffinity != null
-                        && target.taskAffinity.equals(bottom.getTask().affinity)) {
+                        && target.taskAffinity.equals(bottom.getTaskRecord().affinity)) {
                     // If the activity currently at the bottom has the
                     // same task affinity as the one we are moving,
                     // then merge it into the same task.
-                    targetTask = bottom.getTask();
+                    targetTask = bottom.getTaskRecord();
                     if (DEBUG_TASKS) Slog.v(TAG_TASKS, "Start pushing activity " + target
                             + " out to bottom task " + targetTask);
                 } else {
                     targetTask = createTaskRecord(
-                            mStackSupervisor.getNextTaskIdForUserLocked(target.userId),
+                            mStackSupervisor.getNextTaskIdForUserLocked(target.mUserId),
                             target.info, null, null, null, false);
                     targetTask.affinityIntent = target.intent;
                     if (DEBUG_TASKS) Slog.v(TAG_TASKS, "Start pushing activity " + target
@@ -3440,7 +3440,7 @@
             ActivityRecord newActivity) {
         final boolean forceReset =
                 (newActivity.info.flags & ActivityInfo.FLAG_CLEAR_TASK_ON_LAUNCH) != 0;
-        final TaskRecord task = taskTop.getTask();
+        final TaskRecord task = taskTop.getTaskRecord();
 
         /** False until we evaluate the TaskRecord associated with taskTop. Switches to true
          * for remaining tasks. Used for later tasks to reparent to task. */
@@ -3489,7 +3489,7 @@
 
         if (callingUid > 0) {
             mService.mUgmInternal.grantUriPermissionFromIntent(callingUid, r.packageName,
-                    data, r.getUriPermissionsLocked(), r.userId);
+                    data, r.getUriPermissionsLocked(), r.mUserId);
         }
 
         if (DEBUG_RESULTS) Slog.v(TAG, "Send activity result to " + r
@@ -3551,7 +3551,7 @@
 
         // Task is not guaranteed to be non-null. For example, destroying the
         // {@link ActivityRecord} will disassociate the task from the activity.
-        final TaskRecord task = r.getTask();
+        final TaskRecord task = r.getTaskRecord();
 
         if (task == null) {
             throw new IllegalStateException("activity no longer associated with task:" + r);
@@ -3643,7 +3643,7 @@
                     r.setVisible(false);
                 }
                 EventLogTags.writeAmStopActivity(
-                        r.userId, System.identityHashCode(r), r.shortComponentName);
+                        r.mUserId, System.identityHashCode(r), r.shortComponentName);
                 mService.getLifecycleManager().scheduleTransaction(r.app.getThread(), r.appToken,
                         StopActivityItem.obtain(r.visible, r.configChangeFlags));
                 if (shouldSleepOrShutDownActivities()) {
@@ -3719,7 +3719,7 @@
         }
         Slog.w(TAG, "  Force finishing activity "
                 + r.intent.getComponent().flattenToShortString());
-        finishedTask = r.getTask();
+        finishedTask = r.getTaskRecord();
         int taskNdx = mTaskHistory.indexOf(finishedTask);
         final TaskRecord task = finishedTask;
         int activityNdx = task.mActivities.indexOf(r);
@@ -3793,7 +3793,7 @@
     }
 
     final boolean finishActivityAffinityLocked(ActivityRecord r) {
-        ArrayList<ActivityRecord> activities = r.getTask().mActivities;
+        ArrayList<ActivityRecord> activities = r.getTaskRecord().mActivities;
         for (int index = activities.indexOf(r); index >= 0; --index) {
             ActivityRecord cur = activities.get(index);
             if (!Objects.equals(cur.taskAffinity, r.taskAffinity)) {
@@ -3811,15 +3811,15 @@
             if (DEBUG_RESULTS) Slog.v(TAG_RESULTS, "Adding result to " + resultTo
                     + " who=" + r.resultWho + " req=" + r.requestCode
                     + " res=" + resultCode + " data=" + resultData);
-            if (resultTo.userId != r.userId) {
+            if (resultTo.mUserId != r.mUserId) {
                 if (resultData != null) {
-                    resultData.prepareToLeaveUser(r.userId);
+                    resultData.prepareToLeaveUser(r.mUserId);
                 }
             }
             if (r.info.applicationInfo.uid > 0) {
                 mService.mUgmInternal.grantUriPermissionFromIntent(r.info.applicationInfo.uid,
                         resultTo.packageName, resultData,
-                        resultTo.getUriPermissionsLocked(), resultTo.userId);
+                        resultTo.getUriPermissionsLocked(), resultTo.mUserId);
             }
             resultTo.addResultLocked(r, r.resultWho, r.requestCode, resultCode, resultData);
             r.resultTo = null;
@@ -3857,9 +3857,9 @@
         mWindowManager.deferSurfaceLayout();
         try {
             r.makeFinishingLocked();
-            final TaskRecord task = r.getTask();
+            final TaskRecord task = r.getTaskRecord();
             EventLog.writeEvent(EventLogTags.AM_FINISH_ACTIVITY,
-                    r.userId, System.identityHashCode(r),
+                    r.mUserId, System.identityHashCode(r),
                     task.taskId, r.shortComponentName, reason);
             final ArrayList<ActivityRecord> activities = task.mActivities;
             final int index = activities.indexOf(r);
@@ -3992,7 +3992,7 @@
 
         r.setState(FINISHING, "finishCurrentActivityLocked");
         final boolean finishingInNonFocusedStackOrNoRunning = mode == FINISH_AFTER_VISIBLE
-                && prevState == PAUSED && (r.getStack() != display.getFocusedStack()
+                && prevState == PAUSED && (r.getActivityStack() != display.getFocusedStack()
                         || (next == null && display.topRunningActivity() == null));
 
         if (mode == FINISH_IMMEDIATELY
@@ -4068,15 +4068,15 @@
     boolean shouldUpRecreateTaskLocked(ActivityRecord srec, String destAffinity) {
         // Basic case: for simple app-centric recents, we need to recreate
         // the task if the affinity has changed.
-        if (srec == null || srec.getTask().affinity == null ||
-                !srec.getTask().affinity.equals(destAffinity)) {
+        if (srec == null || srec.getTaskRecord().affinity == null ||
+                !srec.getTaskRecord().affinity.equals(destAffinity)) {
             return true;
         }
         // Document-centric case: an app may be split in to multiple documents;
         // they need to re-create their task if this current activity is the root
         // of a document, unless simply finishing it will return them to the the
         // correct app behind.
-        final TaskRecord task = srec.getTask();
+        final TaskRecord task = srec.getTaskRecord();
         if (srec.frontOfTask && task.getBaseIntent() != null && task.getBaseIntent().isDocument()) {
             // Okay, this activity is at the root of its task.  What to do, what to do...
             if (!inFrontOfStandardStack()) {
@@ -4100,7 +4100,7 @@
 
     final boolean navigateUpToLocked(ActivityRecord srec, Intent destIntent, int resultCode,
             Intent resultData) {
-        final TaskRecord task = srec.getTask();
+        final TaskRecord task = srec.getTaskRecord();
         final ArrayList<ActivityRecord> activities = task.mActivities;
         final int start = activities.indexOf(srec);
         if (!mTaskHistory.contains(task) || (start < 0)) {
@@ -4165,7 +4165,7 @@
                 try {
                     ActivityInfo aInfo = AppGlobals.getPackageManager().getActivityInfo(
                             destIntent.getComponent(), ActivityManagerService.STOCK_PM_FLAGS,
-                            srec.userId);
+                            srec.mUserId);
                     // TODO(b/64750076): Check if calling pid should really be -1.
                     final int res = mService.getActivityStartController()
                             .obtainStarter(destIntent, "navigateUpTo")
@@ -4282,7 +4282,7 @@
         if (DEBUG_APP) Slog.v(TAG_APP, "Clearing app during remove for activity " + r);
         r.app = null;
         r.removeWindowContainer();
-        final TaskRecord task = r.getTask();
+        final TaskRecord task = r.getTaskRecord();
         final boolean lastActivity = task != null ? task.removeActivity(r) : false;
         // If we are removing the last activity in the task, not including task overlay activities,
         // then fall through into the block below to remove the entire task itself
@@ -4446,8 +4446,8 @@
         }
 
         EventLog.writeEvent(EventLogTags.AM_DESTROY_ACTIVITY,
-                r.userId, System.identityHashCode(r),
-                r.getTask().taskId, r.shortComponentName, reason);
+                r.mUserId, System.identityHashCode(r),
+                r.getTaskRecord().taskId, r.shortComponentName, reason);
 
         boolean removedFromHistory = false;
 
@@ -4646,8 +4646,8 @@
                         if (!r.finishing) {
                             Slog.w(TAG, "Force removing " + r + ": app died, no saved state");
                             EventLog.writeEvent(EventLogTags.AM_FINISH_ACTIVITY,
-                                    r.userId, System.identityHashCode(r),
-                                    r.getTask().taskId, r.shortComponentName,
+                                    r.mUserId, System.identityHashCode(r),
+                                    r.getTaskRecord().taskId, r.shortComponentName,
                                     "proc died without state saved");
                             if (r.getState() == RESUMED) {
                                 mService.updateUsageStats(r, false);
@@ -4746,7 +4746,7 @@
             final ActivityRecord top = tr.getTopActivity();
             if (top == null || !top.okToShowLocked()) {
                 if (top != null) {
-                    mStackSupervisor.mRecentTasks.add(top.getTask());
+                    mStackSupervisor.mRecentTasks.add(top.getTaskRecord());
                 }
                 ActivityOptions.abort(options);
                 return;
@@ -4861,7 +4861,7 @@
         final String strData = data != null ? data.toSafeString() : null;
 
         EventLog.writeEvent(tag,
-                r.userId, System.identityHashCode(r), task.taskId,
+                r.mUserId, System.identityHashCode(r), task.taskId,
                 r.shortComponentName, r.intent.getAction(),
                 r.intent.getType(), strData, r.intent.getFlags());
     }
@@ -4874,15 +4874,15 @@
             return;
         }
 
-        final TaskRecord startTask = start.getTask();
+        final TaskRecord startTask = start.getTaskRecord();
         boolean behindFullscreen = false;
         boolean updatedConfig = false;
 
         for (int taskIndex = mTaskHistory.indexOf(startTask); taskIndex >= 0; --taskIndex) {
             final TaskRecord task = mTaskHistory.get(taskIndex);
             final ArrayList<ActivityRecord> activities = task.mActivities;
-            int activityIndex =
-                    (start.getTask() == task) ? activities.indexOf(start) : activities.size() - 1;
+            int activityIndex = (start.getTaskRecord() == task)
+                    ? activities.indexOf(start) : activities.size() - 1;
             for (; activityIndex >= 0; --activityIndex) {
                 final ActivityRecord r = activities.get(activityIndex);
                 updatedConfig |= r.ensureActivityConfiguration(0 /* globalChanges */,
@@ -5046,10 +5046,10 @@
                 ActivityRecord r = mTmpActivities.remove(0);
                 final boolean sameComponent =
                         (r.packageName.equals(packageName) && (filterByClasses == null
-                                || filterByClasses.contains(r.realActivity.getClassName())))
-                        || (packageName == null && r.userId == userId);
-                if ((userId == UserHandle.USER_ALL || r.userId == userId)
-                        && (sameComponent || r.getTask() == lastTask)
+                                || filterByClasses.contains(r.mActivityComponent.getClassName())))
+                        || (packageName == null && r.mUserId == userId);
+                if ((userId == UserHandle.USER_ALL || r.mUserId == userId)
+                        && (sameComponent || r.getTaskRecord() == lastTask)
                         && (r.app == null || evenPersistent || !r.app.isPersistent())) {
                     if (!doit) {
                         if (r.finishing) {
@@ -5060,11 +5060,11 @@
                         return true;
                     }
                     if (r.isActivityTypeHome()) {
-                        if (homeActivity != null && homeActivity.equals(r.realActivity)) {
+                        if (homeActivity != null && homeActivity.equals(r.mActivityComponent)) {
                             Slog.i(TAG, "Skip force-stop again " + r);
                             continue;
                         } else {
-                            homeActivity = r.realActivity;
+                            homeActivity = r.mActivityComponent;
                         }
                     }
                     didSomething = true;
@@ -5075,7 +5075,7 @@
                         }
                         r.app = null;
                     }
-                    lastTask = r.getTask();
+                    lastTask = r.getTaskRecord();
                     finishActivityLocked(r, Activity.RESULT_CANCELED, null, "force-stop",
                             true);
                 }
diff --git a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
index 987c706..8045fd5 100644
--- a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
@@ -91,9 +91,6 @@
 import android.app.ProfilerInfo;
 import android.app.ResultInfo;
 import android.app.WaitResult;
-import android.app.WindowConfiguration;
-import android.app.WindowConfiguration.ActivityType;
-import android.app.WindowConfiguration.WindowingMode;
 import android.app.servertransaction.ActivityLifecycleItem;
 import android.app.servertransaction.ClientTransaction;
 import android.app.servertransaction.LaunchActivityItem;
@@ -111,7 +108,6 @@
 import android.content.res.Configuration;
 import android.graphics.Rect;
 import android.os.Binder;
-import android.os.Build;
 import android.os.Bundle;
 import android.os.Debug;
 import android.os.Handler;
@@ -544,7 +540,7 @@
         mActivitiesWaitingForVisibleActivity.remove(r);
 
         for (int i = mWaitingForActivityVisible.size() - 1; i >= 0; --i) {
-            if (mWaitingForActivityVisible.get(i).matches(r.realActivity)) {
+            if (mWaitingForActivityVisible.get(i).matches(r.mActivityComponent)) {
                 mWaitingForActivityVisible.remove(i);
             }
         }
@@ -558,7 +554,7 @@
         boolean changed = false;
         for (int i = mWaitingForActivityVisible.size() - 1; i >= 0; --i) {
             final WaitInfo w = mWaitingForActivityVisible.get(i);
-            if (w.matches(r.realActivity)) {
+            if (w.matches(r.mActivityComponent)) {
                 final WaitResult result = w.getResult();
                 changed = true;
                 result.timeout = false;
@@ -592,7 +588,7 @@
                 // Unlike START_TASK_TO_FRONT, When an intent is delivered to top, there
                 // will be no followup launch signals. Assign the result and launched component.
                 if (result == START_DELIVERED_TO_TOP) {
-                    w.who = r.realActivity;
+                    w.who = r.mActivityComponent;
                 }
             }
         }
@@ -713,7 +709,7 @@
             return false;
         }
 
-        final TaskRecord task = r.getTask();
+        final TaskRecord task = r.getTaskRecord();
         final ActivityStack stack = task.getStack();
 
         beginDeferResume();
@@ -742,7 +738,7 @@
                         false /* markFrozenIfConfigChanged */, true /* deferResume */);
             }
 
-            if (r.getStack().checkKeyguardVisibility(r, true /* shouldBeVisible */,
+            if (r.getActivityStack().checkKeyguardVisibility(r, true /* shouldBeVisible */,
                     true /* isTop */)) {
                 // We only set the visibility to true if the activity is allowed to be visible
                 // based on
@@ -754,7 +750,7 @@
 
             final int applicationInfoUid =
                     (r.info.applicationInfo != null) ? r.info.applicationInfo.uid : -1;
-            if ((r.userId != proc.mUserId) || (r.appInfo.uid != applicationInfoUid)) {
+            if ((r.mUserId != proc.mUserId) || (r.appInfo.uid != applicationInfoUid)) {
                 Slog.wtf(TAG,
                         "User ID for activity changing for " + r
                                 + " appInfo.uid=" + r.appInfo.uid
@@ -795,7 +791,7 @@
                 if (DEBUG_SWITCH) Slog.v(TAG_SWITCH,
                         "Launching: " + r + " icicle=" + r.icicle + " with results=" + results
                                 + " newIntents=" + newIntents + " andResume=" + andResume);
-                EventLog.writeEvent(EventLogTags.AM_RESTART_ACTIVITY, r.userId,
+                EventLog.writeEvent(EventLogTags.AM_RESTART_ACTIVITY, r.mUserId,
                         System.identityHashCode(r), task.taskId, r.shortComponentName);
                 if (r.isActivityTypeHome()) {
                     // Home process is the root process of the task.
@@ -1312,7 +1308,7 @@
         // waiting for the next one to start.
         for (int i = 0; i < NS; i++) {
             r = stops.get(i);
-            final ActivityStack stack = r.getStack();
+            final ActivityStack stack = r.getActivityStack();
             if (stack != null) {
                 if (r.finishing) {
                     stack.finishCurrentActivityLocked(r, ActivityStack.FINISH_IMMEDIATELY, false,
@@ -1327,7 +1323,7 @@
         // waiting for the next one to start.
         for (int i = 0; i < NF; i++) {
             r = finishes.get(i);
-            final ActivityStack stack = r.getStack();
+            final ActivityStack stack = r.getActivityStack();
             if (stack != null) {
                 activityRemoved |= stack.destroyActivityLocked(r, true, "finish-idle");
             }
@@ -2009,7 +2005,7 @@
 
     void activitySleptLocked(ActivityRecord r) {
         mGoingToSleepActivities.remove(r);
-        final ActivityStack s = r.getStack();
+        final ActivityStack s = r.getActivityStack();
         if (s != null) {
             s.checkReadyForSleep();
         } else {
@@ -2045,7 +2041,7 @@
         // A resumed activity cannot be stopping. remove from list
         mStoppingActivities.remove(r);
 
-        final ActivityStack stack = r.getStack();
+        final ActivityStack stack = r.getActivityStack();
         if (mRootActivityContainer.isTopDisplayFocusedStack(stack)) {
             mService.updateUsageStats(r, true);
         }
@@ -2061,7 +2057,7 @@
 
     // Called when WindowManager has finished animating the launchingBehind activity to the back.
     private void handleLaunchTaskBehindCompleteLocked(ActivityRecord r) {
-        final TaskRecord task = r.getTask();
+        final TaskRecord task = r.getTaskRecord();
         final ActivityStack stack = task.getStack();
 
         r.mLaunchTaskBehind = false;
@@ -2073,7 +2069,7 @@
         // task has been shown briefly
         final ActivityRecord top = stack.getTopActivity();
         if (top != null) {
-            top.getTask().touchActiveTime();
+            top.getTaskRecord().touchActiveTime();
         }
     }
 
@@ -2128,7 +2124,7 @@
                 }
             }
             if (remove) {
-                final ActivityStack stack = s.getStack();
+                final ActivityStack stack = s.getActivityStack();
                 final boolean shouldSleepOrShutDown = stack != null
                         ? stack.shouldSleepOrShutDownActivities()
                         : mService.isSleepingOrShuttingDownLocked();
@@ -2218,8 +2214,8 @@
                 pw.println(header);
                 header = null;
             }
-            if (lastTask != r.getTask()) {
-                lastTask = r.getTask();
+            if (lastTask != r.getTaskRecord()) {
+                lastTask = r.getTaskRecord();
                 pw.print(prefix);
                 pw.print(full ? "* " : "  ");
                 pw.println(lastTask);
@@ -2376,7 +2372,7 @@
         mWindowManager.notifyAppRelaunchingFinished(token);
         final ActivityRecord r = ActivityRecord.isInStackLocked(token);
         if (r != null) {
-            if (r.getStack().shouldSleepOrShutDownActivities()) {
+            if (r.getActivityStack().shouldSleepOrShutDownActivities()) {
                 r.setSleeping(true, true);
             }
         }
diff --git a/services/core/java/com/android/server/wm/ActivityStartInterceptor.java b/services/core/java/com/android/server/wm/ActivityStartInterceptor.java
index 54a63a1..b8442a8 100644
--- a/services/core/java/com/android/server/wm/ActivityStartInterceptor.java
+++ b/services/core/java/com/android/server/wm/ActivityStartInterceptor.java
@@ -282,10 +282,10 @@
         }
 
         ActivityRecord homeActivityRecord = mRootActivityContainer.getDefaultDisplayHomeActivity();
-        if (homeActivityRecord != null && homeActivityRecord.getTask() != null) {
-            // Showing credential confirmation activity in home task to avoid stopping multi-windowed
-            // mode after showing the full-screen credential confirmation activity.
-            mActivityOptions.setLaunchTaskId(homeActivityRecord.getTask().taskId);
+        if (homeActivityRecord != null && homeActivityRecord.getTaskRecord() != null) {
+            // Showing credential confirmation activity in home task to avoid stopping
+            // multi-windowed mode after showing the full-screen credential confirmation activity.
+            mActivityOptions.setLaunchTaskId(homeActivityRecord.getTaskRecord().taskId);
         }
 
         final UserInfo parent = mUserManager.getProfileParent(mUserId);
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index c4421ba..bc2136e 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -678,7 +678,7 @@
         }
 
         if (err == ActivityManager.START_SUCCESS && sourceRecord != null
-                && sourceRecord.getTask().voiceSession != null) {
+                && sourceRecord.getTaskRecord().voiceSession != null) {
             // If this activity is being launched as part of a voice session, we need
             // to ensure that it is safe to do so.  If the upcoming activity will also
             // be part of the voice session, we can only launch it if it has explicitly
@@ -718,7 +718,8 @@
             }
         }
 
-        final ActivityStack resultStack = resultRecord == null ? null : resultRecord.getStack();
+        final ActivityStack resultStack = resultRecord == null
+                ? null : resultRecord.getActivityStack();
 
         if (err != START_SUCCESS) {
             if (resultRecord != null) {
@@ -1234,7 +1235,7 @@
                     }
                     case START_DELIVERED_TO_TOP: {
                         outResult.timeout = false;
-                        outResult.who = r.realActivity;
+                        outResult.who = r.mActivityComponent;
                         outResult.totalTime = 0;
                         break;
                     }
@@ -1243,11 +1244,12 @@
                         // in the resumed state.
                         if (r.nowVisible && r.isState(RESUMED)) {
                             outResult.timeout = false;
-                            outResult.who = r.realActivity;
+                            outResult.who = r.mActivityComponent;
                             outResult.totalTime = 0;
                         } else {
                             final long startTimeMs = SystemClock.uptimeMillis();
-                            mSupervisor.waitActivityVisible(r.realActivity, outResult, startTimeMs);
+                            mSupervisor.waitActivityVisible(
+                                    r.mActivityComponent, outResult, startTimeMs);
                             // Note: the timeout variable is not currently not ever set.
                             do {
                                 try {
@@ -1293,7 +1295,7 @@
             result = startActivityUnchecked(r, sourceRecord, voiceSession, voiceInteractor,
                     startFlags, doResume, options, inTask, outActivity);
         } finally {
-            final ActivityStack currentStack = r.getStack();
+            final ActivityStack currentStack = r.getActivityStack();
             startedActivityStack = currentStack != null ? currentStack : mTargetStack;
 
             if (ActivityManager.isStartResultSuccessful(result)) {
@@ -1313,7 +1315,7 @@
                 // If we are not able to proceed, disassociate the activity from the task.
                 // Leaving an activity in an incomplete state can lead to issues, such as
                 // performing operations without a window container.
-                final ActivityStack stack = mStartActivity.getStack();
+                final ActivityStack stack = mStartActivity.getActivityStack();
                 if (stack != null) {
                     stack.finishActivityLocked(mStartActivity, RESULT_CANCELED,
                             null /* intentResultData */, "startActivity", true /* oomAdj */);
@@ -1358,7 +1360,8 @@
             // When the flags NEW_TASK and CLEAR_TASK are set, then the task gets reused but
             // still needs to be a lock task mode violation since the task gets cleared out and
             // the device would otherwise leave the locked task.
-            if (mService.getLockTaskController().isLockTaskModeViolation(reusedActivity.getTask(),
+            if (mService.getLockTaskController().isLockTaskModeViolation(
+                    reusedActivity.getTaskRecord(),
                     (mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK))
                             == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK))) {
                 Slog.e(TAG, "startActivityUnchecked: Attempt to violate Lock Task Mode");
@@ -1375,14 +1378,14 @@
             // If mStartActivity does not have a task associated with it, associate it with the
             // reused activity's task. Do not do so if we're clearing top and resetting for a
             // standard launchMode activity.
-            if (mStartActivity.getTask() == null && !clearTopAndResetStandardLaunchMode) {
-                mStartActivity.setTask(reusedActivity.getTask());
+            if (mStartActivity.getTaskRecord() == null && !clearTopAndResetStandardLaunchMode) {
+                mStartActivity.setTask(reusedActivity.getTaskRecord());
             }
 
-            if (reusedActivity.getTask().intent == null) {
+            if (reusedActivity.getTaskRecord().intent == null) {
                 // This task was started because of movement of the activity based on affinity...
                 // Now that we are actually launching it, we can assign the base intent.
-                reusedActivity.getTask().setIntent(mStartActivity);
+                reusedActivity.getTaskRecord().setIntent(mStartActivity);
             }
 
             // This code path leads to delivering a new intent, we want to make sure we schedule it
@@ -1391,7 +1394,7 @@
             if ((mLaunchFlags & FLAG_ACTIVITY_CLEAR_TOP) != 0
                     || isDocumentLaunchesIntoExisting(mLaunchFlags)
                     || isLaunchModeOneOf(LAUNCH_SINGLE_INSTANCE, LAUNCH_SINGLE_TASK)) {
-                final TaskRecord task = reusedActivity.getTask();
+                final TaskRecord task = reusedActivity.getTaskRecord();
 
                 // In this situation we want to remove all activities from the task up to the one
                 // being started. In most cases this means we are resetting the task to its initial
@@ -1403,7 +1406,7 @@
                 // the {@code ActivityRecord} removing its reference to the {@code TaskRecord}. The
                 // task reference is needed in the call below to
                 // {@link setTargetStackAndMoveToFrontIfNeeded}.
-                if (reusedActivity.getTask() == null) {
+                if (reusedActivity.getTaskRecord() == null) {
                     reusedActivity.setTask(task);
                 }
 
@@ -1411,7 +1414,7 @@
                     if (top.frontOfTask) {
                         // Activity aliases may mean we use different intents for the top activity,
                         // so make sure the task now has the identity of the new intent.
-                        top.getTask().setIntent(mStartActivity);
+                        top.getTaskRecord().setIntent(mStartActivity);
                     }
                     deliverNewIntent(top);
                 }
@@ -1458,7 +1461,7 @@
 
         if (mStartActivity.packageName == null) {
             final ActivityStack sourceStack = mStartActivity.resultTo != null
-                    ? mStartActivity.resultTo.getStack() : null;
+                    ? mStartActivity.resultTo.getActivityStack() : null;
             if (sourceStack != null) {
                 sourceStack.sendActivityResultLocked(-1 /* callingUid */, mStartActivity.resultTo,
                         mStartActivity.resultWho, mStartActivity.requestCode, RESULT_CANCELED,
@@ -1474,8 +1477,8 @@
         final ActivityRecord topFocused = topStack.getTopActivity();
         final ActivityRecord top = topStack.topRunningNonDelayedActivityLocked(mNotTop);
         final boolean dontStart = top != null && mStartActivity.resultTo == null
-                && top.realActivity.equals(mStartActivity.realActivity)
-                && top.userId == mStartActivity.userId
+                && top.mActivityComponent.equals(mStartActivity.mActivityComponent)
+                && top.mUserId == mStartActivity.mUserId
                 && top.attachedToProcess()
                 && ((mLaunchFlags & FLAG_ACTIVITY_SINGLE_TOP) != 0
                 || isLaunchModeOneOf(LAUNCH_SINGLE_TOP, LAUNCH_SINGLE_TASK))
@@ -1500,7 +1503,7 @@
 
             // Don't use mStartActivity.task to show the toast. We're not starting a new activity
             // but reusing 'top'. Fields in mStartActivity may not be fully initialized.
-            mSupervisor.handleNonResizableTaskIfNeeded(top.getTask(), preferredWindowingMode,
+            mSupervisor.handleNonResizableTaskIfNeeded(top.getTaskRecord(), preferredWindowingMode,
                     mPreferredDisplayId, topStack);
 
             return START_DELIVERED_TO_TOP;
@@ -1508,7 +1511,7 @@
 
         boolean newTask = false;
         final TaskRecord taskToAffiliate = (mLaunchTaskBehind && mSourceRecord != null)
-                ? mSourceRecord.getTask() : null;
+                ? mSourceRecord.getTaskRecord() : null;
 
         // Should this be considered a new task?
         int result = START_SUCCESS;
@@ -1530,16 +1533,16 @@
         }
 
         mService.mUgmInternal.grantUriPermissionFromIntent(mCallingUid, mStartActivity.packageName,
-                mIntent, mStartActivity.getUriPermissionsLocked(), mStartActivity.userId);
+                mIntent, mStartActivity.getUriPermissionsLocked(), mStartActivity.mUserId);
         mService.getPackageManagerInternalLocked().grantEphemeralAccess(
-                mStartActivity.userId, mIntent, UserHandle.getAppId(mStartActivity.appInfo.uid),
+                mStartActivity.mUserId, mIntent, UserHandle.getAppId(mStartActivity.appInfo.uid),
                 UserHandle.getAppId(mCallingUid));
         if (newTask) {
-            EventLog.writeEvent(EventLogTags.AM_CREATE_TASK, mStartActivity.userId,
-                    mStartActivity.getTask().taskId);
+            EventLog.writeEvent(EventLogTags.AM_CREATE_TASK, mStartActivity.mUserId,
+                    mStartActivity.getTaskRecord().taskId);
         }
         ActivityStack.logStartActivity(
-                EventLogTags.AM_CREATE_ACTIVITY, mStartActivity, mStartActivity.getTask());
+                EventLogTags.AM_CREATE_ACTIVITY, mStartActivity, mStartActivity.getTaskRecord());
         mTargetStack.mLastPausedActivity = null;
 
         mRootActivityContainer.sendPowerHintForLaunchStartIfNeeded(
@@ -1549,7 +1552,7 @@
                 mOptions);
         if (mDoResume) {
             final ActivityRecord topTaskActivity =
-                    mStartActivity.getTask().topRunningActivityLocked();
+                    mStartActivity.getTaskRecord().topRunningActivityLocked();
             if (!mTargetStack.isFocusable()
                     || (topTaskActivity != null && topTaskActivity.mTaskOverlay
                     && mStartActivity != topTaskActivity)) {
@@ -1577,12 +1580,12 @@
                         mTargetStack, mStartActivity, mOptions);
             }
         } else if (mStartActivity != null) {
-            mSupervisor.mRecentTasks.add(mStartActivity.getTask());
+            mSupervisor.mRecentTasks.add(mStartActivity.getTaskRecord());
         }
-        mRootActivityContainer.updateUserStack(mStartActivity.userId, mTargetStack);
+        mRootActivityContainer.updateUserStack(mStartActivity.mUserId, mTargetStack);
 
-        mSupervisor.handleNonResizableTaskIfNeeded(mStartActivity.getTask(), preferredWindowingMode,
-                mPreferredDisplayId, mTargetStack);
+        mSupervisor.handleNonResizableTaskIfNeeded(mStartActivity.getTaskRecord(),
+                preferredWindowingMode, mPreferredDisplayId, mTargetStack);
 
         return START_SUCCESS;
     }
@@ -1739,7 +1742,7 @@
                 checkedCaller = mRootActivityContainer.getTopDisplayFocusedStack()
                         .topRunningNonDelayedActivityLocked(mNotTop);
             }
-            if (!checkedCaller.realActivity.equals(r.realActivity)) {
+            if (!checkedCaller.mActivityComponent.equals(r.mActivityComponent)) {
                 // Caller is not the same as launcher, so always needed.
                 mStartFlags &= ~START_FLAG_ONLY_IF_NEEDED;
             }
@@ -1750,7 +1753,7 @@
 
     private void sendNewTaskResultRequestIfNeeded() {
         final ActivityStack sourceStack = mStartActivity.resultTo != null
-                ? mStartActivity.resultTo.getStack() : null;
+                ? mStartActivity.resultTo.getActivityStack() : null;
         if (sourceStack != null && (mLaunchFlags & FLAG_ACTIVITY_NEW_TASK) != 0) {
             // For whatever reason this activity is being launched into a new task...
             // yet the caller has requested a result back.  Well, that is pretty messed up,
@@ -1854,7 +1857,7 @@
             return;
         }
         if (!mSourceRecord.finishing) {
-            mSourceStack = mSourceRecord.getStack();
+            mSourceStack = mSourceRecord.getActivityStack();
             return;
         }
 
@@ -1872,7 +1875,7 @@
             // example, if this method is being called for processing a pending activity launch, it
             // is possible that the activity has been removed from the task after the launch was
             // enqueued.
-            final TaskRecord sourceTask = mSourceRecord.getTask();
+            final TaskRecord sourceTask = mSourceRecord.getTaskRecord();
             mNewTaskIntent = sourceTask != null ? sourceTask.intent : null;
         }
         mSourceRecord = null;
@@ -1935,7 +1938,7 @@
      * @return {@link ActivityRecord} brought to front.
      */
     private ActivityRecord setTargetStackAndMoveToFrontIfNeeded(ActivityRecord intentActivity) {
-        mTargetStack = intentActivity.getStack();
+        mTargetStack = intentActivity.getActivityStack();
         mTargetStack.mLastPausedActivity = null;
         // If the target task is not in the front, then we need to bring it to the front...
         // except...  well, with SINGLE_TASK_LAUNCH it's not entirely clear. We'd like to have
@@ -1946,9 +1949,9 @@
             final ActivityStack focusStack = mTargetStack.getDisplay().getFocusedStack();
             final ActivityRecord curTop = (focusStack == null)
                     ? null : focusStack.topRunningNonDelayedActivityLocked(mNotTop);
-            final TaskRecord topTask = curTop != null ? curTop.getTask() : null;
+            final TaskRecord topTask = curTop != null ? curTop.getTaskRecord() : null;
             differentTopTask = topTask != null
-                    && (topTask != intentActivity.getTask() || topTask != focusStack.topTask());
+                    && (topTask != intentActivity.getTaskRecord() || topTask != focusStack.topTask());
         } else {
             // The existing task should always be different from those in other displays.
             differentTopTask = true;
@@ -1957,10 +1960,11 @@
         if (differentTopTask && !mAvoidMoveToFront) {
             mStartActivity.intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
             if (mSourceRecord == null || (mSourceStack.getTopActivity() != null &&
-                    mSourceStack.getTopActivity().getTask() == mSourceRecord.getTask())) {
+                    mSourceStack.getTopActivity().getTaskRecord()
+                            == mSourceRecord.getTaskRecord())) {
                 // We really do want to push this one into the user's face, right now.
                 if (mLaunchTaskBehind && mSourceRecord != null) {
-                    intentActivity.setTaskToAffiliateWith(mSourceRecord.getTask());
+                    intentActivity.setTaskToAffiliateWith(mSourceRecord.getTaskRecord());
                 }
 
                 // If the launch flags carry both NEW_TASK and CLEAR_TASK, the task's activities
@@ -1974,8 +1978,8 @@
                             == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK);
                 if (!willClearTask) {
                     final ActivityStack launchStack = getLaunchStack(
-                            mStartActivity, mLaunchFlags, mStartActivity.getTask(), mOptions);
-                    final TaskRecord intentTask = intentActivity.getTask();
+                            mStartActivity, mLaunchFlags, mStartActivity.getTaskRecord(), mOptions);
+                    final TaskRecord intentTask = intentActivity.getTaskRecord();
                     if (launchStack == null || launchStack == mTargetStack) {
                         // We only want to move to the front, if we aren't going to launch on a
                         // different stack. If we launch on a different stack, we will put the
@@ -2005,7 +2009,7 @@
                         // Target and computed stacks are on different displays and we've
                         // found a matching task - move the existing instance to that display and
                         // move it to front.
-                        intentActivity.getTask().reparent(launchStack, ON_TOP,
+                        intentActivity.getTaskRecord().reparent(launchStack, ON_TOP,
                                 REPARENT_MOVE_STACK_TO_FRONT, ANIMATE, DEFER_RESUME,
                                 "reparentToDisplay");
                         mMovedToFront = true;
@@ -2015,7 +2019,7 @@
                         // For example, the activity may have been initially started with an intent
                         // which placed it in the fullscreen stack. To ensure the proper handling of
                         // the activity based on home stack assumptions, we must move it over.
-                        intentActivity.getTask().reparent(launchStack, ON_TOP,
+                        intentActivity.getTaskRecord().reparent(launchStack, ON_TOP,
                                 REPARENT_MOVE_STACK_TO_FRONT, ANIMATE, DEFER_RESUME,
                                 "reparentingHome");
                         mMovedToFront = true;
@@ -2031,14 +2035,14 @@
         }
         // Need to update mTargetStack because if task was moved out of it, the original stack may
         // be destroyed.
-        mTargetStack = intentActivity.getStack();
+        mTargetStack = intentActivity.getActivityStack();
         if (!mMovedToFront && mDoResume) {
             if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Bring to front target: " + mTargetStack
                     + " from " + intentActivity);
             mTargetStack.moveToFront("intentActivityFound");
         }
 
-        mSupervisor.handleNonResizableTaskIfNeeded(intentActivity.getTask(),
+        mSupervisor.handleNonResizableTaskIfNeeded(intentActivity.getTaskRecord(),
                 WINDOWING_MODE_UNDEFINED, DEFAULT_DISPLAY, mTargetStack);
 
         // If the caller has requested that the target task be reset, then do so.
@@ -2060,14 +2064,14 @@
             // launching another activity.
             // TODO(b/36119896):  We shouldn't trigger activity launches in this path since we are
             // already launching one.
-            final TaskRecord task = intentActivity.getTask();
+            final TaskRecord task = intentActivity.getTaskRecord();
             task.performClearTaskLocked();
             mReuseTask = task;
             mReuseTask.setIntent(mStartActivity);
         } else if ((mLaunchFlags & FLAG_ACTIVITY_CLEAR_TOP) != 0
                 || isLaunchModeOneOf(LAUNCH_SINGLE_INSTANCE, LAUNCH_SINGLE_TASK)) {
-            ActivityRecord top = intentActivity.getTask().performClearTaskLocked(mStartActivity,
-                    mLaunchFlags);
+            final ActivityRecord top = intentActivity.getTaskRecord().performClearTaskLocked(
+                    mStartActivity, mLaunchFlags);
             if (top == null) {
                 // A special case: we need to start the activity because it is not currently
                 // running, and the caller has asked to clear the current task to have this
@@ -2079,7 +2083,7 @@
                 // Now pretend like this activity is being started by the top of its task, so it
                 // is put in the right place.
                 mSourceRecord = intentActivity;
-                final TaskRecord task = mSourceRecord.getTask();
+                final TaskRecord task = mSourceRecord.getTaskRecord();
                 if (task != null && task.getStack() == null) {
                     // Target stack got cleared when we all activities were removed above.
                     // Go ahead and reset it.
@@ -2089,19 +2093,21 @@
                             !mLaunchTaskBehind /* toTop */, "startActivityUnchecked");
                 }
             }
-        } else if (mStartActivity.realActivity.equals(intentActivity.getTask().realActivity)) {
+        } else if (mStartActivity.mActivityComponent.equals(
+                intentActivity.getTaskRecord().realActivity)) {
             // In this case the top activity on the task is the same as the one being launched,
             // so we take that as a request to bring the task to the foreground. If the top
             // activity in the task is the root activity, deliver this new intent to it if it
             // desires.
             if (((mLaunchFlags & FLAG_ACTIVITY_SINGLE_TOP) != 0
                         || LAUNCH_SINGLE_TOP == mLaunchMode)
-                    && intentActivity.realActivity.equals(mStartActivity.realActivity)) {
+                    && intentActivity.mActivityComponent.equals(
+                            mStartActivity.mActivityComponent)) {
                 if (intentActivity.frontOfTask) {
-                    intentActivity.getTask().setIntent(mStartActivity);
+                    intentActivity.getTaskRecord().setIntent(mStartActivity);
                 }
                 deliverNewIntent(intentActivity);
-            } else if (!intentActivity.getTask().isSameIntentFilter(mStartActivity)) {
+            } else if (!intentActivity.getTaskRecord().isSameIntentFilter(mStartActivity)) {
                 // In this case we are launching the root activity of the task, but with a
                 // different intent. We should start a new instance on top.
                 mAddingToTask = true;
@@ -2114,13 +2120,13 @@
             // current task.
             mAddingToTask = true;
             mSourceRecord = intentActivity;
-        } else if (!intentActivity.getTask().rootWasReset) {
+        } else if (!intentActivity.getTaskRecord().rootWasReset) {
             // In this case we are launching into an existing task that has not yet been started
             // from its front door. The current task has been brought to the front. Ideally,
             // we'd probably like to place this new task at the bottom of its stack, but that's
             // a little hard to do with the current organization of the code so for now we'll
             // just drop it.
-            intentActivity.getTask().setIntent(mStartActivity);
+            intentActivity.getTaskRecord().setIntent(mStartActivity);
         }
     }
 
@@ -2130,7 +2136,7 @@
         } else {
             ActivityOptions.abort(mOptions);
         }
-        mRootActivityContainer.updateUserStack(mStartActivity.userId, mTargetStack);
+        mRootActivityContainer.updateUserStack(mStartActivity.mUserId, mTargetStack);
     }
 
     private int setTaskFromReuseOrCreateNewTask(TaskRecord taskToAffiliate) {
@@ -2141,16 +2147,16 @@
 
         if (mReuseTask == null) {
             final TaskRecord task = mTargetStack.createTaskRecord(
-                    mSupervisor.getNextTaskIdForUserLocked(mStartActivity.userId),
+                    mSupervisor.getNextTaskIdForUserLocked(mStartActivity.mUserId),
                     mNewTaskInfo != null ? mNewTaskInfo : mStartActivity.info,
                     mNewTaskIntent != null ? mNewTaskIntent : mIntent, mVoiceSession,
                     mVoiceInteractor, !mLaunchTaskBehind /* toTop */, mStartActivity, mSourceRecord,
                     mOptions);
             addOrReparentStartingActivity(task, "setTaskFromReuseOrCreateNewTask - mReuseTask");
-            updateBounds(mStartActivity.getTask(), mLaunchParams.mBounds);
+            updateBounds(mStartActivity.getTaskRecord(), mLaunchParams.mBounds);
 
             if (DEBUG_TASKS) Slog.v(TAG_TASKS, "Starting new activity " + mStartActivity
-                    + " in new task " + mStartActivity.getTask());
+                    + " in new task " + mStartActivity.getTaskRecord());
         } else {
             addOrReparentStartingActivity(mReuseTask, "setTaskFromReuseOrCreateNewTask");
         }
@@ -2159,7 +2165,8 @@
             mStartActivity.setTaskToAffiliateWith(taskToAffiliate);
         }
 
-        if (mService.getLockTaskController().isLockTaskModeViolation(mStartActivity.getTask())) {
+        if (mService.getLockTaskController().isLockTaskModeViolation(
+                mStartActivity.getTaskRecord())) {
             Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity);
             return START_RETURN_LOCK_TASK_MODE_VIOLATION;
         }
@@ -2175,20 +2182,21 @@
             return;
         }
 
-        ActivityStack.logStartActivity(AM_NEW_INTENT, activity, activity.getTask());
+        ActivityStack.logStartActivity(AM_NEW_INTENT, activity, activity.getTaskRecord());
         activity.deliverNewIntentLocked(mCallingUid, mStartActivity.intent,
                 mStartActivity.launchedFromPackage);
         mIntentDelivered = true;
     }
 
     private int setTaskFromSourceRecord() {
-        if (mService.getLockTaskController().isLockTaskModeViolation(mSourceRecord.getTask())) {
+        if (mService.getLockTaskController().isLockTaskModeViolation(
+                mSourceRecord.getTaskRecord())) {
             Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity);
             return START_RETURN_LOCK_TASK_MODE_VIOLATION;
         }
 
-        final TaskRecord sourceTask = mSourceRecord.getTask();
-        final ActivityStack sourceStack = mSourceRecord.getStack();
+        final TaskRecord sourceTask = mSourceRecord.getTaskRecord();
+        final ActivityStack sourceStack = mSourceRecord.getActivityStack();
         // We only want to allow changing stack in two cases:
         // 1. If the target task is not the top one. Otherwise we would move the launching task to
         //    the other side, rather than show two side by side.
@@ -2198,8 +2206,8 @@
         final boolean moveStackAllowed = sourceStack.topTask() != sourceTask
                 || !mStartActivity.canBeLaunchedOnDisplay(targetDisplayId);
         if (moveStackAllowed) {
-            mTargetStack = getLaunchStack(mStartActivity, mLaunchFlags, mStartActivity.getTask(),
-                    mOptions);
+            mTargetStack = getLaunchStack(mStartActivity, mLaunchFlags,
+                    mStartActivity.getTaskRecord(), mOptions);
             // If target stack is not found now - we can't just rely on the source stack, as it may
             // be not suitable. Let's check other displays.
             if (mTargetStack == null && targetDisplayId != sourceStack.mDisplayId) {
@@ -2236,7 +2244,7 @@
             ActivityRecord top = sourceTask.performClearTaskLocked(mStartActivity, mLaunchFlags);
             mKeepCurTransition = true;
             if (top != null) {
-                ActivityStack.logStartActivity(AM_NEW_INTENT, mStartActivity, top.getTask());
+                ActivityStack.logStartActivity(AM_NEW_INTENT, mStartActivity, top.getTaskRecord());
                 deliverNewIntent(top);
                 // For paranoia, make sure we have correctly resumed the top activity.
                 mTargetStack.mLastPausedActivity = null;
@@ -2252,7 +2260,7 @@
             // stack if so.
             final ActivityRecord top = sourceTask.findActivityInHistoryLocked(mStartActivity);
             if (top != null) {
-                final TaskRecord task = top.getTask();
+                final TaskRecord task = top.getTaskRecord();
                 task.moveActivityToFrontLocked(top);
                 top.updateOptionsLocked(mOptions);
                 ActivityStack.logStartActivity(AM_NEW_INTENT, mStartActivity, task);
@@ -2269,7 +2277,8 @@
         // the same task as the one that is starting it.
         addOrReparentStartingActivity(sourceTask, "setTaskFromSourceRecord");
         if (DEBUG_TASKS) Slog.v(TAG_TASKS, "Starting new activity " + mStartActivity
-                + " in existing task " + mStartActivity.getTask() + " from source " + mSourceRecord);
+                + " in existing task " + mStartActivity.getTaskRecord()
+                + " from source " + mSourceRecord);
         return START_SUCCESS;
     }
 
@@ -2286,8 +2295,8 @@
         // Check whether we should actually launch the new activity in to the task,
         // or just reuse the current activity on top.
         ActivityRecord top = mInTask.getTopActivity();
-        if (top != null && top.realActivity.equals(mStartActivity.realActivity)
-                && top.userId == mStartActivity.userId) {
+        if (top != null && top.mActivityComponent.equals(mStartActivity.mActivityComponent)
+                && top.mUserId == mStartActivity.mUserId) {
             if ((mLaunchFlags & FLAG_ACTIVITY_SINGLE_TOP) != 0
                     || isLaunchModeOneOf(LAUNCH_SINGLE_TOP, LAUNCH_SINGLE_TASK)) {
                 mTargetStack.moveTaskToFrontLocked(mInTask, mNoAnimation, mOptions,
@@ -2329,7 +2338,7 @@
 
         addOrReparentStartingActivity(mInTask, "setTaskFromInTask");
         if (DEBUG_TASKS) Slog.v(TAG_TASKS, "Starting new activity " + mStartActivity
-                + " in explicit task " + mStartActivity.getTask());
+                + " in explicit task " + mStartActivity.getTaskRecord());
 
         return START_SUCCESS;
     }
@@ -2355,17 +2364,18 @@
             mTargetStack.moveToFront("addingToTopTask");
         }
         final ActivityRecord prev = mTargetStack.getTopActivity();
-        final TaskRecord task = (prev != null) ? prev.getTask() : mTargetStack.createTaskRecord(
-                mSupervisor.getNextTaskIdForUserLocked(mStartActivity.userId), mStartActivity.info,
+        final TaskRecord task = (prev != null)
+                ? prev.getTaskRecord() : mTargetStack.createTaskRecord(
+                mSupervisor.getNextTaskIdForUserLocked(mStartActivity.mUserId), mStartActivity.info,
                 mIntent, null, null, true, mStartActivity, mSourceRecord, mOptions);
         addOrReparentStartingActivity(task, "setTaskToCurrentTopOrCreateNewTask");
         mTargetStack.positionChildWindowContainerAtTop(task);
         if (DEBUG_TASKS) Slog.v(TAG_TASKS, "Starting new activity " + mStartActivity
-                + " in new guessed " + mStartActivity.getTask());
+                + " in new guessed " + mStartActivity.getTaskRecord());
     }
 
     private void addOrReparentStartingActivity(TaskRecord parent, String reason) {
-        if (mStartActivity.getTask() == null || mStartActivity.getTask() == parent) {
+        if (mStartActivity.getTaskRecord() == null || mStartActivity.getTaskRecord() == parent) {
             parent.addActivityToTop(mStartActivity);
         } else {
             mStartActivity.reparent(parent, parent.mActivities.size() /* top */, reason);
@@ -2401,7 +2411,7 @@
 
     private ActivityStack computeStackFocus(ActivityRecord r, boolean newTask, int launchFlags,
             ActivityOptions aOptions) {
-        final TaskRecord task = r.getTask();
+        final TaskRecord task = r.getTaskRecord();
         ActivityStack stack = getLaunchStack(r, launchFlags, task, aOptions);
         if (stack != null) {
             return stack;
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index e1a1e61..4ad97bb 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -1442,7 +1442,7 @@
                 return true;
             }
             // Keep track of the root activity of the task before we finish it
-            TaskRecord tr = r.getTask();
+            final TaskRecord tr = r.getTaskRecord();
             ActivityRecord rootR = tr.getRootActivity();
             if (rootR == null) {
                 Slog.w(TAG, "Finishing task with all activities already finished");
@@ -1457,7 +1457,7 @@
             // We should consolidate.
             if (mController != null) {
                 // Find the first activity that is not finishing.
-                ActivityRecord next = r.getStack().topRunningActivityLocked(token, 0);
+                final ActivityRecord next = r.getActivityStack().topRunningActivityLocked(token, 0);
                 if (next != null) {
                     // ask watcher if this is allowed
                     boolean resumeOK = true;
@@ -1519,7 +1519,7 @@
 
                 // Do not allow task to finish if last task in lockTask mode. Launchable priv-apps
                 // can finish.
-                final TaskRecord task = r.getTask();
+                final TaskRecord task = r.getTaskRecord();
                 if (getLockTaskController().activityBlockedFromFinish(r)) {
                     return false;
                 }
@@ -1822,7 +1822,7 @@
                 if (r == null) {
                     return false;
                 }
-                final TaskRecord task = r.getTask();
+                final TaskRecord task = r.getTaskRecord();
                 int index = task.mActivities.lastIndexOf(r);
                 if (index > 0) {
                     ActivityRecord under = task.mActivities.get(index - 1);
@@ -1830,7 +1830,7 @@
                 }
                 final boolean translucentChanged = r.changeWindowTranslucency(false);
                 if (translucentChanged) {
-                    r.getStack().convertActivityToTranslucent(r);
+                    r.getActivityStack().convertActivityToTranslucent(r);
                 }
                 mRootActivityContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
                 mWindowManager.setAppFullscreen(token, false);
@@ -1847,7 +1847,7 @@
         synchronized (mGlobalLock) {
             ActivityRecord r = mRootActivityContainer.isInAnyStack(token);
             if (r != null) {
-                r.getStack().notifyActivityDrawnLocked(r);
+                r.getActivityStack().notifyActivityDrawnLocked(r);
             }
         }
     }
@@ -1967,7 +1967,7 @@
         synchronized (mGlobalLock) {
             final ActivityRecord srec = ActivityRecord.forTokenLocked(token);
             if (srec != null) {
-                return srec.getStack().shouldUpRecreateTaskLocked(srec, destAffinity);
+                return srec.getActivityStack().shouldUpRecreateTaskLocked(srec, destAffinity);
             }
         }
         return false;
@@ -1980,7 +1980,8 @@
         synchronized (mGlobalLock) {
             final ActivityRecord r = ActivityRecord.forTokenLocked(token);
             if (r != null) {
-                return r.getStack().navigateUpToLocked(r, destIntent, resultCode, resultData);
+                return r.getActivityStack().navigateUpToLocked(
+                        r, destIntent, resultCode, resultData);
             }
             return false;
         }
@@ -2300,7 +2301,7 @@
             final long origId = Binder.clearCallingIdentity();
             ActivityRecord r = ActivityRecord.isInStackLocked(token);
             if (r != null) {
-                r.getStack().finishSubActivityLocked(r, resultWho, requestCode);
+                r.getActivityStack().finishSubActivityLocked(r, resultWho, requestCode);
             }
             Binder.restoreCallingIdentity(origId);
         }
@@ -2545,7 +2546,7 @@
             if (r == null) {
                 return;
             }
-            startLockTaskModeLocked(r.getTask(), false /* isSystemCaller */);
+            startLockTaskModeLocked(r.getTaskRecord(), false /* isSystemCaller */);
         }
     }
 
@@ -2578,7 +2579,7 @@
             if (r == null) {
                 return;
             }
-            stopLockTaskModeInternal(r.getTask(), false /* isSystemCaller */);
+            stopLockTaskModeInternal(r.getTaskRecord(), false /* isSystemCaller */);
         }
     }
 
@@ -2671,7 +2672,7 @@
             ActivityRecord r = ActivityRecord.isInStackLocked(token);
             if (r != null) {
                 r.setTaskDescription(td);
-                final TaskRecord task = r.getTask();
+                final TaskRecord task = r.getTaskRecord();
                 task.updateTaskDescription();
                 mTaskChangeNotificationController.notifyTaskDescriptionChanged(task.taskId, td);
             }
@@ -2727,7 +2728,7 @@
     public boolean isTopOfTask(IBinder token) {
         synchronized (mGlobalLock) {
             ActivityRecord r = ActivityRecord.isInStackLocked(token);
-            return r != null && r.getTask().getTopActivity() == r;
+            return r != null && r.getTaskRecord().getTopActivity() == r;
         }
     }
 
@@ -2766,8 +2767,8 @@
             }
             if (structure != null) {
                 // Pre-fill the task/activity component for all assist data receivers
-                structure.setTaskId(pae.activity.getTask().taskId);
-                structure.setActivityComponent(pae.activity.realActivity);
+                structure.setTaskId(pae.activity.getTaskRecord().taskId);
+                structure.setActivityComponent(pae.activity.mActivityComponent);
                 structure.setHomeActivity(pae.isHome);
             }
             pae.haveResult = true;
@@ -2875,9 +2876,9 @@
                                     + ainfo.applicationInfo.uid + ", calling uid=" + callingUid);
                 }
 
-                final ActivityStack stack = r.getStack();
+                final ActivityStack stack = r.getActivityStack();
                 final TaskRecord task = stack.createTaskRecord(
-                        mStackSupervisor.getNextTaskIdForUserLocked(r.userId), ainfo, intent,
+                        mStackSupervisor.getNextTaskIdForUserLocked(r.mUserId), ainfo, intent,
                         null /* voiceSession */, null /* voiceInteractor */, !ON_TOP);
                 if (!mRecentTasks.addToBottom(task)) {
                     // The app has too many tasks already and we can't add any more
@@ -2973,7 +2974,7 @@
                 if (r == null) {
                     return false;
                 }
-                return r.getStack().safelyDestroyActivityLocked(r, "app-req");
+                return r.getActivityStack().safelyDestroyActivityLocked(r, "app-req");
             } finally {
                 Binder.restoreCallingIdentity(origId);
             }
@@ -3123,7 +3124,7 @@
                             "exitFreeformMode: No activity record matching token=" + token);
                 }
 
-                final ActivityStack stack = r.getStack();
+                final ActivityStack stack = r.getActivityStack();
                 if (stack == null || !stack.inFreeformWindowingMode()) {
                     throw new IllegalStateException(
                             "exitFreeformMode: You can only go fullscreen from freeform.");
@@ -3409,7 +3410,7 @@
             if (activity == null) {
                 return false;
             }
-            userId = activity.userId;
+            userId = activity.mUserId;
         }
         return !DevicePolicyCache.getInstance().getScreenCaptureDisabled(userId);
     }
@@ -3783,14 +3784,14 @@
     }
 
     private boolean isInPictureInPictureMode(ActivityRecord r) {
-        if (r == null || r.getStack() == null || !r.inPinnedWindowingMode()
-                || r.getStack().isInStackLocked(r) == null) {
+        if (r == null || r.getActivityStack() == null || !r.inPinnedWindowingMode()
+                || r.getActivityStack().isInStackLocked(r) == null) {
             return false;
         }
 
         // If we are animating to fullscreen then we have already dispatched the PIP mode
         // changed, so we should reflect that check here as well.
-        final PinnedActivityStack stack = r.getStack();
+        final PinnedActivityStack stack = r.getActivityStack();
         final PinnedStackWindowController windowController = stack.getWindowContainerController();
         return !windowController.isAnimatingBoundsToFullscreen();
     }
@@ -3826,7 +3827,7 @@
                                 r.pictureInPictureArgs.getSourceRectHint());
                         mRootActivityContainer.moveActivityToPinnedStack(
                                 r, sourceBounds, aspectRatio, "enterPictureInPictureMode");
-                        final PinnedActivityStack stack = r.getStack();
+                        final PinnedActivityStack stack = r.getActivityStack();
                         stack.setPictureInPictureAspectRatio(aspectRatio);
                         stack.setPictureInPictureActions(actions);
                         MetricsLoggerWrapper.logPictureInPictureEnter(mContext, r.appInfo.uid,
@@ -3870,7 +3871,7 @@
                     // If the activity is already in picture-in-picture, update the pinned stack now
                     // if it is not already expanding to fullscreen. Otherwise, the arguments will
                     // be used the next time the activity enters PiP
-                    final PinnedActivityStack stack = r.getStack();
+                    final PinnedActivityStack stack = r.getActivityStack();
                     if (!stack.isAnimatingBoundsToFullscreen()) {
                         stack.setPictureInPictureAspectRatio(
                                 r.pictureInPictureArgs.getAspectRatio());
@@ -3928,8 +3929,8 @@
         }
 
         if (params.hasSetAspectRatio()
-                && !mWindowManager.isValidPictureInPictureAspectRatio(r.getStack().mDisplayId,
-                params.getAspectRatio())) {
+                && !mWindowManager.isValidPictureInPictureAspectRatio(
+                        r.getActivityStack().mDisplayId, params.getAspectRatio())) {
             final float minAspectRatio = mContext.getResources().getFloat(
                     com.android.internal.R.dimen.config_pictureInPictureMinAspectRatio);
             final float maxAspectRatio = mContext.getResources().getFloat(
@@ -4015,7 +4016,7 @@
         }
 
         int err;
-        if ((err = vrService.hasVrPackage(packageName, r.userId)) !=
+        if ((err = vrService.hasVrPackage(packageName, r.mUserId)) !=
                 VrManagerInternal.NO_ERROR) {
             return err;
         }
@@ -4045,7 +4046,7 @@
             if (ActivityRecord.forTokenLocked(callingActivity) != activity) {
                 throw new SecurityException("Only focused activity can call startVoiceInteraction");
             }
-            if (mRunningVoice != null || activity.getTask().voiceSession != null
+            if (mRunningVoice != null || activity.getTaskRecord().voiceSession != null
                     || activity.voiceSession != null) {
                 Slog.w(TAG, "Already in a voice interaction, cannot start new voice interaction");
                 return;
@@ -4255,7 +4256,7 @@
             if (mLastResumedActivity == null) {
                 return getCurrentUserId();
             }
-            return mLastResumedActivity.userId;
+            return mLastResumedActivity.mUserId;
         }
     }
 
@@ -4435,7 +4436,7 @@
                     + " to main stack for VR");
             final ActivityStack stack = mRootActivityContainer.getDefaultDisplay().getOrCreateStack(
                     WINDOWING_MODE_FULLSCREEN, r.getActivityType(), true /* toTop */);
-            moveTaskToStack(r.getTask().taskId, stack.mStackId, true /* toTop */);
+            moveTaskToStack(r.getTaskRecord().taskId, stack.mStackId, true /* toTop */);
         }
         mH.post(() -> {
             if (!mVrController.onVrModeChanged(r)) {
@@ -4646,7 +4647,7 @@
             }
             needSep = true;
             synchronized (mGlobalLock) {
-                final TaskRecord task = r.getTask();
+                final TaskRecord task = r.getTaskRecord();
                 if (lastTask != task) {
                     lastTask = task;
                     pw.print("TASK "); pw.print(lastTask.affinity);
@@ -5110,7 +5111,7 @@
 
     /** Update AMS states when an activity is resumed. */
     void setResumedActivityUncheckLocked(ActivityRecord r, String reason) {
-        final TaskRecord task = r.getTask();
+        final TaskRecord task = r.getTaskRecord();
         if (task.isActivityTypeStandard()) {
             if (mCurAppTimeTracker != r.appTimeTracker) {
                 // We are switching app tracking.  Complete the current one.
@@ -5142,7 +5143,7 @@
             if (mLastResumedActivity != null) {
                 final IVoiceInteractionSession session;
 
-                final TaskRecord lastResumedActivityTask = mLastResumedActivity.getTask();
+                final TaskRecord lastResumedActivityTask = mLastResumedActivity.getTaskRecord();
                 if (lastResumedActivityTask != null
                         && lastResumedActivityTask.voiceSession != null) {
                     session = lastResumedActivityTask.voiceSession;
@@ -5160,8 +5161,8 @@
             }
         }
 
-        if (mLastResumedActivity != null && r.userId != mLastResumedActivity.userId) {
-            mAmInternal.sendForegroundProfileChanged(r.userId);
+        if (mLastResumedActivity != null && r.mUserId != mLastResumedActivity.mUserId) {
+            mAmInternal.sendForegroundProfileChanged(r.mUserId);
         }
         updateResumedAppTrace(r);
         mLastResumedActivity = r;
@@ -5172,7 +5173,7 @@
         applyUpdateVrModeLocked(r);
 
         EventLogTags.writeAmSetResumedActivity(
-                r == null ? -1 : r.userId,
+                r == null ? -1 : r.mUserId,
                 r == null ? "NULL" : r.shortComponentName,
                 reason);
     }
@@ -5234,7 +5235,8 @@
 
     void updateUsageStats(ActivityRecord component, boolean resumed) {
         final Message m = PooledLambda.obtainMessage(ActivityManagerInternal::updateUsageStats,
-                mAmInternal, component.realActivity, component.app.mUid, component.userId, resumed);
+                mAmInternal, component.mActivityComponent, component.app.mUid, component.mUserId,
+                resumed);
         mH.sendMessage(m);
     }
 
@@ -5269,7 +5271,7 @@
         mHeavyWeightProcess = root.app;
         final Message m = PooledLambda.obtainMessage(
                 ActivityTaskManagerService::postHeavyWeightProcessNotification, this,
-                root.app, root.intent, root.userId);
+                root.app, root.intent, root.mUserId);
         mH.sendMessage(m);
     }
 
@@ -5637,7 +5639,7 @@
             synchronized (mGlobalLock) {
                 final ActivityRecord homeActivity =
                         mRootActivityContainer.getDefaultDisplayHomeActivityForUser(userId);
-                return homeActivity == null ? null : homeActivity.realActivity;
+                return homeActivity == null ? null : homeActivity.mActivityComponent;
             }
         }
 
@@ -6131,9 +6133,9 @@
                 int requestCode, int resultCode, Intent data) {
             synchronized (mGlobalLock) {
                 final ActivityRecord r = ActivityRecord.isInStackLocked(activityToken);
-                if (r != null && r.getStack() != null) {
-                    r.getStack().sendActivityResultLocked(callingUid, r, resultWho, requestCode,
-                            resultCode, data);
+                if (r != null && r.getActivityStack() != null) {
+                    r.getActivityStack().sendActivityResultLocked(callingUid, r, resultWho,
+                            requestCode, resultCode, data);
                 }
             }
         }
@@ -6407,7 +6409,7 @@
                     final ActivityRecord homeActivity =
                             mRootActivityContainer.getDefaultDisplayHomeActivity();
                     if (homeActivity != null) {
-                        activityOptions.setLaunchTaskId(homeActivity.getTask().taskId);
+                        activityOptions.setLaunchTaskId(homeActivity.getTaskRecord().taskId);
                     }
                     mContext.startActivityAsUser(intent, activityOptions.toBundle(),
                             UserHandle.CURRENT);
diff --git a/services/core/java/com/android/server/wm/AppWarnings.java b/services/core/java/com/android/server/wm/AppWarnings.java
index 0436857..6c3fbc1 100644
--- a/services/core/java/com/android/server/wm/AppWarnings.java
+++ b/services/core/java/com/android/server/wm/AppWarnings.java
@@ -123,7 +123,8 @@
 
         // TODO(b/75318890): Need to move this to when the app actually crashes.
         if (/*ActivityManager.isRunningInTestHarness()
-                &&*/ !mAlwaysShowUnsupportedCompileSdkWarningActivities.contains(r.realActivity)) {
+                &&*/ !mAlwaysShowUnsupportedCompileSdkWarningActivities.contains(
+                        r.mActivityComponent)) {
             // Don't show warning if we are running in a test harness and we don't have to always
             // show for this activity.
             return;
diff --git a/services/core/java/com/android/server/wm/AppWindowThumbnail.java b/services/core/java/com/android/server/wm/AppWindowThumbnail.java
index b9b9d31..bb38f30 100644
--- a/services/core/java/com/android/server/wm/AppWindowThumbnail.java
+++ b/services/core/java/com/android/server/wm/AppWindowThumbnail.java
@@ -53,7 +53,8 @@
 
     AppWindowThumbnail(Transaction t, AppWindowToken appToken, GraphicBuffer thumbnailHeader) {
         mAppToken = appToken;
-        mSurfaceAnimator = new SurfaceAnimator(this, this::onAnimationFinished, appToken.mService);
+        mSurfaceAnimator =
+                new SurfaceAnimator(this, this::onAnimationFinished, appToken.mWmService);
         mWidth = thumbnailHeader.getWidth();
         mHeight = thumbnailHeader.getHeight();
 
@@ -93,11 +94,11 @@
 
     void startAnimation(Transaction t, Animation anim, Point position) {
         anim.restrictDuration(MAX_ANIMATION_DURATION);
-        anim.scaleCurrentDuration(mAppToken.mService.getTransitionAnimationScaleLocked());
+        anim.scaleCurrentDuration(mAppToken.mWmService.getTransitionAnimationScaleLocked());
         mSurfaceAnimator.startAnimation(t, new LocalAnimationAdapter(
                 new WindowAnimationSpec(anim, position,
                         mAppToken.getDisplayContent().mAppTransition.canSkipFirstFrame()),
-                mAppToken.mService.mSurfaceAnimationRunner), false /* hidden */);
+                mAppToken.mWmService.mSurfaceAnimationRunner), false /* hidden */);
     }
 
     private void onAnimationFinished() {
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index df81c07..fb93d39 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -554,7 +554,8 @@
         // * or this is an opening app and windows are being replaced.
         boolean visibilityChanged = false;
         if (isHidden() == visible || (isHidden() && mIsExiting) || (visible && waitingForReplacement())) {
-            final AccessibilityController accessibilityController = mService.mAccessibilityController;
+            final AccessibilityController accessibilityController =
+                    mWmService.mAccessibilityController;
             boolean changed = false;
             if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
                     "Changing app " + this + " hidden=" + isHidden() + " performLayout=" + performLayout);
@@ -595,7 +596,7 @@
 
                 // We are becoming visible, so better freeze the screen with the windows that are
                 // getting visible so we also wait for them.
-                forAllWindows(mService::makeWindowFreezingScreenIfNeededLocked, true);
+                forAllWindows(mWmService::makeWindowFreezingScreenIfNeededLocked, true);
             }
 
             if (DEBUG_APP_TRANSITIONS) {
@@ -606,9 +607,9 @@
             if (changed) {
                 getDisplayContent().getInputMonitor().setUpdateInputWindowsNeededLw();
                 if (performLayout) {
-                    mService.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,
+                    mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,
                             false /*updateInputWindows*/);
-                    mService.mWindowPlacerLocked.performSurfacePlacement();
+                    mWmService.mWindowPlacerLocked.performSurfacePlacement();
                 }
                 getDisplayContent().getInputMonitor().updateInputWindowsLw(false /*force*/);
             }
@@ -635,7 +636,8 @@
                 // The token was made immediately visible, there will be no entrance animation.
                 // We need to inform the client the enter animation was finished.
                 mEnteringAnimation = true;
-                mService.mActivityManagerAppTransitionNotifier.onAppTransitionFinishedLocked(token);
+                mWmService.mActivityManagerAppTransitionNotifier.onAppTransitionFinishedLocked(
+                        token);
             }
 
             // If we're becoming visible, immediately change client visibility as well. there seem
@@ -658,7 +660,7 @@
 
                 // Take the screenshot before possibly hiding the WSA, otherwise the screenshot
                 // will not be taken.
-                mService.mTaskSnapshotController.notifyAppVisibilityChanged(this, visible);
+                mWmService.mTaskSnapshotController.notifyAppVisibilityChanged(this, visible);
             }
 
             // If we are hidden but there is no delay needed we immediately
@@ -774,7 +776,7 @@
 
         getDisplayContent().mOpeningApps.remove(this);
         getDisplayContent().mUnknownAppVisibilityController.appRemovedOrHidden(this);
-        mService.mTaskSnapshotController.onAppRemoved(this);
+        mWmService.mTaskSnapshotController.onAppRemoved(this);
         waitingToShow = false;
         if (getDisplayContent().mClosingApps.contains(this)) {
             delayed = true;
@@ -827,7 +829,7 @@
             if (DEBUG_FOCUS_LIGHT) Slog.v(TAG_WM, "Removing focused app token:" + this
                    + " displayId=" + dc.getDisplayId());
             dc.setFocusedApp(null);
-            mService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, true /*updateInputWindows*/);
+            mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, true /*updateInputWindows*/);
         }
 
         if (!delayed) {
@@ -1141,7 +1143,7 @@
 
         // if we got a replacement window, reset the timeout to give drawing more time
         if (gotReplacementWindow) {
-            mService.scheduleWindowReplacementTimeouts(this);
+            mWmService.scheduleWindowReplacementTimeouts(this);
         }
         checkKeyguardFlagsChanged();
     }
@@ -1271,7 +1273,7 @@
             final WindowState win = mChildren.get(i);
             win.onUnfreezeBounds();
         }
-        mService.mWindowPlacerLocked.performSurfacePlacement();
+        mWmService.mWindowPlacerLocked.performSurfacePlacement();
     }
 
     void setAppLayoutChanges(int changes, String reason) {
@@ -1279,7 +1281,7 @@
             final DisplayContent dc = getDisplayContent();
             dc.pendingLayoutChanges |= changes;
             if (DEBUG_LAYOUT_REPEATS) {
-                mService.mWindowPlacerLocked.debugLayoutRepeats(reason, dc.pendingLayoutChanges);
+                mWmService.mWindowPlacerLocked.debugLayoutRepeats(reason, dc.pendingLayoutChanges);
             }
         }
     }
@@ -1300,12 +1302,12 @@
         if (!hiddenRequested) {
             if (!mFreezingScreen) {
                 mFreezingScreen = true;
-                mService.registerAppFreezeListener(this);
-                mService.mAppsFreezingScreen++;
-                if (mService.mAppsFreezingScreen == 1) {
-                    mService.startFreezingDisplayLocked(0, 0, getDisplayContent());
-                    mService.mH.removeMessages(H.APP_FREEZE_TIMEOUT);
-                    mService.mH.sendEmptyMessageDelayed(H.APP_FREEZE_TIMEOUT, 2000);
+                mWmService.registerAppFreezeListener(this);
+                mWmService.mAppsFreezingScreen++;
+                if (mWmService.mAppsFreezingScreen == 1) {
+                    mWmService.startFreezingDisplayLocked(0, 0, getDisplayContent());
+                    mWmService.mH.removeMessages(H.APP_FREEZE_TIMEOUT);
+                    mWmService.mH.sendEmptyMessageDelayed(H.APP_FREEZE_TIMEOUT, 2000);
                 }
             }
             final int count = mChildren.size();
@@ -1330,15 +1332,15 @@
         if (force || unfrozeWindows) {
             if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "No longer freezing: " + this);
             mFreezingScreen = false;
-            mService.unregisterAppFreezeListener(this);
-            mService.mAppsFreezingScreen--;
-            mService.mLastFinishedFreezeSource = this;
+            mWmService.unregisterAppFreezeListener(this);
+            mWmService.mAppsFreezingScreen--;
+            mWmService.mLastFinishedFreezeSource = this;
         }
         if (unfreezeSurfaceNow) {
             if (unfrozeWindows) {
-                mService.mWindowPlacerLocked.performSurfacePlacement();
+                mWmService.mWindowPlacerLocked.performSurfacePlacement();
             }
-            mService.stopFreezingDisplayLocked();
+            mWmService.stopFreezingDisplayLocked();
         }
     }
 
@@ -1429,10 +1431,10 @@
                 // pending opening apps.
                 getDisplayContent().mOpeningApps.remove(this);
 
-                mService.updateFocusedWindowLocked(
+                mWmService.updateFocusedWindowLocked(
                         UPDATE_FOCUS_WILL_PLACE_SURFACES, true /*updateInputWindows*/);
                 getDisplayContent().setLayoutNeeded();
-                mService.mWindowPlacerLocked.performSurfacePlacement();
+                mWmService.mWindowPlacerLocked.performSurfacePlacement();
             } finally {
                 Binder.restoreCallingIdentity(origId);
             }
@@ -1602,7 +1604,7 @@
                 if (mDisplayContent != null) {
                     mDisplayContent.setLayoutNeeded();
                 }
-                mService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
+                mWmService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
 
                 // Notify the pinned stack upon all windows drawn. If there was an animation in
                 // progress then this signal will resume that animation.
@@ -1636,8 +1638,8 @@
             return false;
         }
 
-        if (mLastTransactionSequence != mService.mTransactionSequence) {
-            mLastTransactionSequence = mService.mTransactionSequence;
+        if (mLastTransactionSequence != mWmService.mTransactionSequence) {
+            mLastTransactionSequence = mWmService.mTransactionSequence;
             mNumDrawnWindows = 0;
             startingDisplayed = false;
 
@@ -1769,7 +1771,7 @@
         }
 
         final ActivityManager.TaskSnapshot snapshot =
-                mService.mTaskSnapshotController.getSnapshot(
+                mWmService.mTaskSnapshotController.getSnapshot(
                         getTask().mTaskId, getTask().mUserId,
                         false /* restoreFromDisk */, false /* reducedResolution */);
         final int type = getStartingWindowType(newTask, taskSwitch, processRunning,
@@ -1788,7 +1790,7 @@
         if (theme != 0) {
             AttributeCache.Entry ent = AttributeCache.instance().get(pkg, theme,
                     com.android.internal.R.styleable.Window,
-                    mService.mCurrentUserId);
+                    mWmService.mCurrentUserId);
             if (ent == null) {
                 // Whoops!  App doesn't exist. Um. Okay. We'll just pretend like we didn't
                 // see that.
@@ -1838,7 +1840,7 @@
             }
 
             if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Creating SplashScreenStartingData");
-            startingData = new SplashScreenStartingData(mService, pkg,
+            startingData = new SplashScreenStartingData(mWmService, pkg,
                     theme, compatInfo, nonLocalizedLabel, labelRes, icon, logo, windowFlags,
                     getMergedOverrideConfiguration());
             scheduleAddStartingWindow();
@@ -1853,7 +1855,7 @@
         }
 
         if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Creating SnapshotStartingData");
-        startingData = new SnapshotStartingData(mService, snapshot);
+        startingData = new SnapshotStartingData(mWmService, snapshot);
         scheduleAddStartingWindow();
         return true;
     }
@@ -1862,9 +1864,9 @@
         // Note: we really want to do sendMessageAtFrontOfQueue() because we
         // want to process the message ASAP, before any other queued
         // messages.
-        if (!mService.mAnimationHandler.hasCallbacks(mAddStartingWindow)) {
+        if (!mWmService.mAnimationHandler.hasCallbacks(mAddStartingWindow)) {
             if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Enqueueing ADD_STARTING");
-            mService.mAnimationHandler.postAtFrontOfQueue(mAddStartingWindow);
+            mWmService.mAnimationHandler.postAtFrontOfQueue(mAddStartingWindow);
         }
     }
 
@@ -1872,9 +1874,9 @@
 
         @Override
         public void run() {
-            synchronized (mService.mGlobalLock) {
+            synchronized (mWmService.mGlobalLock) {
                 // There can only be one adding request, silly caller!
-                mService.mAnimationHandler.removeCallbacks(this);
+                mWmService.mAnimationHandler.removeCallbacks(this);
             }
 
             if (startingData == null) {
@@ -1898,7 +1900,7 @@
             }
             if (surface != null) {
                 boolean abort = false;
-                synchronized (mService.mGlobalLock) {
+                synchronized (mWmService.mGlobalLock) {
                     // If the window was successfully added, then
                     // we need to remove it.
                     if (removed || startingData == null) {
@@ -1998,7 +2000,7 @@
 
         // Use the same thread to remove the window as we used to add it, as otherwise we end up
         // with things in the view hierarchy being called from different threads.
-        mService.mAnimationHandler.post(() -> {
+        mWmService.mAnimationHandler.post(() -> {
             if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Removing startingView=" + surface);
             try {
                 surface.remove();
@@ -2054,7 +2056,7 @@
         final boolean containsShowWhenLocked = containsShowWhenLockedWindow();
         if (containsDismissKeyguard != mLastContainsDismissKeyguardWindow
                 || containsShowWhenLocked != mLastContainsShowWhenLockedWindow) {
-            mService.notifyKeyguardFlagsChanged(null /* callback */,
+            mWmService.notifyKeyguardFlagsChanged(null /* callback */,
                     getDisplayContent().getDisplayId());
         }
         mLastContainsDismissKeyguardWindow = containsDismissKeyguard;
@@ -2194,7 +2196,7 @@
     boolean applyAnimationLocked(WindowManager.LayoutParams lp, int transit, boolean enter,
             boolean isVoiceInteraction) {
 
-        if (mService.mDisableTransitionAnimation || !shouldAnimate(transit)) {
+        if (mWmService.mDisableTransitionAnimation || !shouldAnimate(transit)) {
             if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
                 Slog.v(TAG_WM, "applyAnimation: transition animation is disabled or skipped."
                         + " atoken=" + this);
@@ -2228,7 +2230,7 @@
                                     getDisplayContent().mAppTransition.canSkipFirstFrame(),
                                     appStackClipMode,
                                     true /* isAppAnimation */),
-                            mService.mSurfaceAnimationRunner);
+                            mWmService.mSurfaceAnimationRunner);
                     if (a.getZAdjustment() == Animation.ZORDER_TOP) {
                         mNeedsZBoost = true;
                     }
@@ -2311,7 +2313,7 @@
             final int containingWidth = frame.width();
             final int containingHeight = frame.height();
             a.initialize(containingWidth, containingHeight, width, height);
-            a.scaleCurrentDuration(mService.getTransitionAnimationScaleLocked());
+            a.scaleCurrentDuration(mWmService.getTransitionAnimationScaleLocked());
         }
         return a;
     }
@@ -2516,7 +2518,7 @@
             return;
         }
         final Rect frame = win.getFrameLw();
-        final int thumbnailDrawableRes = getTask().mUserId == mService.mCurrentUserId
+        final int thumbnailDrawableRes = getTask().mUserId == mWmService.mCurrentUserId
                 ? R.drawable.ic_account_circle
                 : R.drawable.ic_corp_badge;
         final GraphicBuffer thumbnail =
diff --git a/services/core/java/com/android/server/wm/Dimmer.java b/services/core/java/com/android/server/wm/Dimmer.java
index fa3c7ca..aea071f 100644
--- a/services/core/java/com/android/server/wm/Dimmer.java
+++ b/services/core/java/com/android/server/wm/Dimmer.java
@@ -131,7 +131,7 @@
                 if (!mDimming) {
                     dimAnimatable.getPendingTransaction().destroy(mDimLayer);
                 }
-            }, mHost.mService);
+            }, mHost.mWmService);
         }
     }
 
@@ -333,7 +333,7 @@
             SurfaceControl.Transaction t, float startAlpha, float endAlpha) {
         mSurfaceAnimatorStarter.startAnimation(animator, t, new LocalAnimationAdapter(
                 new AlphaAnimationSpec(startAlpha, endAlpha, getDimDuration(container)),
-                mHost.mService.mSurfaceAnimationRunner), false /* hidden */);
+                mHost.mWmService.mSurfaceAnimationRunner), false /* hidden */);
     }
 
     private long getDimDuration(WindowContainer container) {
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index c0e9836..871ceaf 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -100,6 +100,7 @@
 import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
 import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
 import static com.android.server.wm.WindowManagerService.CUSTOM_SCREEN_ROTATION;
+import static com.android.server.wm.WindowManagerService.H.REPORT_HARD_KEYBOARD_STATUS_CHANGE;
 import static com.android.server.wm.WindowManagerService.H.REPORT_LOSING_FOCUS;
 import static com.android.server.wm.WindowManagerService.H.SEND_NEW_CONFIGURATION;
 import static com.android.server.wm.WindowManagerService.H.UPDATE_DOCKED_STACK_DIVIDER;
@@ -208,21 +209,21 @@
 
     /** The containers below are the only child containers the display can have. */
     // Contains all window containers that are related to apps (Activities)
-    private final TaskStackContainers mTaskStackContainers = new TaskStackContainers(mService);
+    private final TaskStackContainers mTaskStackContainers = new TaskStackContainers(mWmService);
     // Contains all non-app window containers that should be displayed above the app containers
     // (e.g. Status bar)
     private final AboveAppWindowContainers mAboveAppWindowsContainers =
-            new AboveAppWindowContainers("mAboveAppWindowsContainers", mService);
+            new AboveAppWindowContainers("mAboveAppWindowsContainers", mWmService);
     // Contains all non-app window containers that should be displayed below the app containers
     // (e.g. Wallpaper).
     private final NonAppWindowContainers mBelowAppWindowsContainers =
-            new NonAppWindowContainers("mBelowAppWindowsContainers", mService);
+            new NonAppWindowContainers("mBelowAppWindowsContainers", mWmService);
     // Contains all IME window containers. Note that the z-ordering of the IME windows will depend
     // on the IME target. We mainly have this container grouping so we can keep track of all the IME
     // window containers together and move them in-sync if/when needed. We use a subclass of
     // WindowContainer which is omitted from screen magnification, as the IME is never magnified.
     private final NonMagnifiableWindowContainers mImeWindowsContainers =
-            new NonMagnifiableWindowContainers("mImeWindowsContainers", mService);
+            new NonMagnifiableWindowContainers("mImeWindowsContainers", mWmService);
 
     private WindowState mTmpWindow;
     private WindowState mTmpWindow2;
@@ -525,7 +526,7 @@
                 if (w.performShowLocked()) {
                     pendingLayoutChanges |= FINISH_LAYOUT_REDO_ANIM;
                     if (DEBUG_LAYOUT_REPEATS) {
-                        mService.mWindowPlacerLocked.debugLayoutRepeats(
+                        mWmService.mWindowPlacerLocked.debugLayoutRepeats(
                                 "updateWindowsAndWallpaperLocked 5", pendingLayoutChanges);
                     }
                 }
@@ -556,7 +557,7 @@
 
     private final Consumer<WindowState> mScheduleToastTimeout = w -> {
         final int lostFocusUid = mTmpWindow.mOwnerUid;
-        final Handler handler = mService.mH;
+        final Handler handler = mWmService.mH;
         if (w.mAttrs.type == TYPE_TOAST && w.mOwnerUid == lostFocusUid) {
             if (!handler.hasMessages(WINDOW_HIDE_TIMEOUT, w)) {
                 handler.sendMessageDelayed(handler.obtainMessage(WINDOW_HIDE_TIMEOUT, w),
@@ -618,7 +619,7 @@
     private final Consumer<WindowState> mPerformLayout = w -> {
         // Don't do layout of a window if it is not visible, or soon won't be visible, to avoid
         // wasting time and funky changes while a window is animating away.
-        final boolean gone = (mTmpWindow != null && mService.mPolicy.canBeHiddenByKeyguardLw(w))
+        final boolean gone = (mTmpWindow != null && mWmService.mPolicy.canBeHiddenByKeyguardLw(w))
                 || w.isGoneForLayoutLw();
 
         if (DEBUG_LAYOUT && !w.mLayoutAttached) {
@@ -686,7 +687,7 @@
             // If this view is GONE, then skip it -- keep the current frame, and let the caller
             // know so they can ignore it if they want.  (We do the normal layout for INVISIBLE
             // windows, since that means "perform layout as normal, just don't display").
-            if (mTmpWindow != null && mService.mPolicy.canBeHiddenByKeyguardLw(w)) {
+            if (mTmpWindow != null && mWmService.mPolicy.canBeHiddenByKeyguardLw(w)) {
                 return;
             }
             if ((w.mViewVisibility != GONE && w.mRelayoutCalled) || !w.mHaveFrame
@@ -721,10 +722,10 @@
                     mInputMethodTarget);
 
     private final Consumer<WindowState> mApplySurfaceChangesTransaction = w -> {
-        final WindowSurfacePlacer surfacePlacer = mService.mWindowPlacerLocked;
+        final WindowSurfacePlacer surfacePlacer = mWmService.mWindowPlacerLocked;
         final boolean obscuredChanged = w.mObscured !=
                 mTmpApplySurfaceChangesTransactionState.obscured;
-        final RootWindowContainer root = mService.mRoot;
+        final RootWindowContainer root = mWmService.mRoot;
 
         // Update effect.
         w.mObscured = mTmpApplySurfaceChangesTransactionState.obscured;
@@ -815,7 +816,7 @@
         }
 
         if (!mLosingFocus.isEmpty() && w.isFocused() && w.isDisplayedLw()) {
-            mService.mH.obtainMessage(REPORT_LOSING_FOCUS, this).sendToTarget();
+            mWmService.mH.obtainMessage(REPORT_LOSING_FOCUS, this).sendToTarget();
         }
 
         w.updateResizingWindowIfNeeded();
@@ -840,7 +841,7 @@
 
         mDisplay = display;
         mDisplayId = display.getDisplayId();
-        mWallpaperController = new WallpaperController(mService, this);
+        mWallpaperController = new WallpaperController(mWmService, this);
         display.getDisplayInfo(mDisplayInfo);
         display.getMetrics(mDisplayMetrics);
         isDefaultDisplay = mDisplayId == DEFAULT_DISPLAY;
@@ -857,8 +858,8 @@
         mBoundsAnimationController = new BoundsAnimationController(service.mContext,
                 mAppTransition, SurfaceAnimationThread.getHandler(), animationHandler);
 
-        if (mService.mInputManager != null) {
-            final InputChannel inputChannel = mService.mInputManager.monitorInput("Display "
+        if (mWmService.mInputManager != null) {
+            final InputChannel inputChannel = mWmService.mInputManager.monitorInput("Display "
                     + mDisplayId, mDisplayId);
             mPointerEventDispatcher = inputChannel != null
                     ? new PointerEventDispatcher(inputChannel) : null;
@@ -870,18 +871,18 @@
         if (isDefaultDisplay) {
             // The policy may be invoked right after here, so it requires the necessary default
             // fields of this display content.
-            mService.mPolicy.setDefaultDisplay(this);
+            mWmService.mPolicy.setDefaultDisplay(this);
         }
-        if (mService.mDisplayReady) {
+        if (mWmService.mDisplayReady) {
             mDisplayPolicy.onConfigurationChanged();
         }
-        if (mService.mSystemReady) {
+        if (mWmService.mSystemReady) {
             mDisplayPolicy.systemReady();
         }
         mDividerControllerLocked = new DockedStackDividerController(service, this);
         mPinnedStackControllerLocked = new PinnedStackController(service, this);
 
-        final SurfaceControl.Builder b = mService.makeSurfaceBuilder(mSession).setOpaque(true);
+        final SurfaceControl.Builder b = mWmService.makeSurfaceBuilder(mSession).setOpaque(true);
         mWindowingLayer = b.setName("Display Root").build();
         mOverlayLayer = b.setName("Display Overlays").build();
 
@@ -900,20 +901,20 @@
         super.addChild(mImeWindowsContainers, null);
 
         // Add itself as a child to the root container.
-        mService.mRoot.addChild(this, null);
+        mWmService.mRoot.addChild(this, null);
 
         // TODO(b/62541591): evaluate whether this is the best spot to declare the
         // {@link DisplayContent} ready for use.
         mDisplayReady = true;
 
-        mService.mAnimator.addDisplayLocked(mDisplayId);
+        mWmService.mAnimator.addDisplayLocked(mDisplayId);
         mInputMonitor = new InputMonitor(service, mDisplayId);
         mInsetsStateController = new InsetsStateController(this);
     }
 
     boolean isReady() {
         // The display is ready when the system and the individual display are both ready.
-        return mService.mDisplayReady && mDisplayReady;
+        return mWmService.mDisplayReady && mDisplayReady;
     }
 
     int getDisplayId() {
@@ -933,7 +934,7 @@
     }
 
     private void addWindowToken(IBinder binder, WindowToken token) {
-        final DisplayContent dc = mService.mRoot.getWindowTokenDisplay(token);
+        final DisplayContent dc = mWmService.mRoot.getWindowTokenDisplay(token);
         if (dc != null) {
             // We currently don't support adding a window token to the display if the display
             // already has the binder mapped to another token. If there is a use case for supporting
@@ -1139,7 +1140,7 @@
 
     /** Notify the configuration change of this display. */
     void sendNewConfiguration() {
-        mService.mH.obtainMessage(SEND_NEW_CONFIGURATION, this).sendToTarget();
+        mWmService.mH.obtainMessage(SEND_NEW_CONFIGURATION, this).sendToTarget();
     }
 
     /**
@@ -1214,7 +1215,7 @@
             }
 
             screenRotationAnimation =
-                    mService.mAnimator.getScreenRotationAnimationLocked(mDisplayId);
+                    mWmService.mAnimator.getScreenRotationAnimationLocked(mDisplayId);
             if (screenRotationAnimation != null && screenRotationAnimation.isAnimating()) {
                 // Rotation updates cannot be performed while the previous rotation change
                 // animation is still in progress.  Skip this update.  We will try updating
@@ -1222,7 +1223,7 @@
                 if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Deferring rotation, animation in progress.");
                 return false;
             }
-            if (mService.mDisplayFrozen) {
+            if (mWmService.mDisplayFrozen) {
                 // Even if the screen rotation animation has finished (e.g. isAnimating
                 // returns false), there is still some time where we haven't yet unfrozen
                 // the display. We also need to abort rotation here.
@@ -1232,7 +1233,7 @@
             }
         }
 
-        if (!mService.mDisplayEnabled) {
+        if (!mWmService.mDisplayEnabled) {
             // No point choosing a rotation if the display is not enabled.
             if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Deferring rotation, display is not enabled.");
             return false;
@@ -1263,8 +1264,8 @@
             if (hasPinnedStack()) {
                 mayRotateSeamlessly = false;
             }
-            for (int i = 0; i < mService.mSessions.size(); i++) {
-                if (mService.mSessions.valueAt(i).hasAlertWindowSurfaces()) {
+            for (int i = 0; i < mWmService.mSessions.size(); i++) {
+                if (mWmService.mSessions.valueAt(i).hasAlertWindowSurfaces()) {
                     mayRotateSeamlessly = false;
                     break;
                 }
@@ -1302,8 +1303,8 @@
         mRotation = rotation;
         mAltOrientation = altOrientation;
 
-        mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_ACTIVE;
-        mService.mH.sendNewMessageDelayed(WindowManagerService.H.WINDOW_FREEZE_TIMEOUT,
+        mWmService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_ACTIVE;
+        mWmService.mH.sendNewMessageDelayed(WindowManagerService.H.WINDOW_FREEZE_TIMEOUT,
                 this, WINDOW_FREEZE_TIMEOUT_DURATION);
 
         setLayoutNeeded();
@@ -1311,14 +1312,14 @@
         mDisplayPolicy.selectRotationAnimationLw(anim);
 
         if (!rotateSeamlessly) {
-            mService.startFreezingDisplayLocked(anim[0], anim[1], this);
+            mWmService.startFreezingDisplayLocked(anim[0], anim[1], this);
             // startFreezingDisplayLocked can reset the ScreenRotationAnimation.
         } else {
             // The screen rotation animation uses a screenshot to freeze the screen
             // while windows resize underneath.
             // When we are rotating seamlessly, we allow the elements to transition
             // to their rotated state independently and without a freeze required.
-            mService.startSeamlessRotation();
+            mWmService.startSeamlessRotation();
         }
 
         return true;
@@ -1333,9 +1334,9 @@
      */
     void applyRotationLocked(final int oldRotation, final int rotation) {
         mDisplayRotation.setRotation(rotation);
-        final boolean rotateSeamlessly = mService.isRotatingSeamlessly();
+        final boolean rotateSeamlessly = mWmService.isRotatingSeamlessly();
         ScreenRotationAnimation screenRotationAnimation = rotateSeamlessly
-                ? null : mService.mAnimator.getScreenRotationAnimationLocked(mDisplayId);
+                ? null : mWmService.mAnimator.getScreenRotationAnimationLocked(mDisplayId);
         // We need to update our screen size information to match the new rotation. If the rotation
         // has actually changed then this method will return true and, according to the comment at
         // the top of the method, the caller is obligated to call computeNewConfigurationLocked().
@@ -1348,9 +1349,9 @@
         if (CUSTOM_SCREEN_ROTATION && screenRotationAnimation != null
                 && screenRotationAnimation.hasScreenshot()) {
             if (screenRotationAnimation.setRotation(getPendingTransaction(), rotation,
-                    MAX_ANIMATION_DURATION, mService.getTransitionAnimationScaleLocked(),
+                    MAX_ANIMATION_DURATION, mWmService.getTransitionAnimationScaleLocked(),
                     mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight)) {
-                mService.scheduleAnimationLocked();
+                mWmService.scheduleAnimationLocked();
             }
         }
 
@@ -1359,27 +1360,27 @@
                     rotateSeamlessly);
         }, true /* traverseTopToBottom */);
 
-        mService.mDisplayManagerInternal.performTraversal(getPendingTransaction());
+        mWmService.mDisplayManagerInternal.performTraversal(getPendingTransaction());
         scheduleAnimation();
 
         forAllWindows(w -> {
             if (w.mHasSurface && !rotateSeamlessly) {
                 if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Set mOrientationChanging of " + w);
                 w.setOrientationChanging(true);
-                mService.mRoot.mOrientationChangeComplete = false;
+                mWmService.mRoot.mOrientationChangeComplete = false;
                 w.mLastFreezeDuration = 0;
             }
             w.mReportOrientationChanged = true;
         }, true /* traverseTopToBottom */);
 
         if (rotateSeamlessly) {
-            mService.mH.sendNewMessageDelayed(WindowManagerService.H.SEAMLESS_ROTATION_TIMEOUT,
+            mWmService.mH.sendNewMessageDelayed(WindowManagerService.H.SEAMLESS_ROTATION_TIMEOUT,
                     this, SEAMLESS_ROTATION_TIMEOUT_DURATION);
         }
 
-        for (int i = mService.mRotationWatchers.size() - 1; i >= 0; i--) {
+        for (int i = mWmService.mRotationWatchers.size() - 1; i >= 0; i--) {
             final WindowManagerService.RotationWatcher rotationWatcher
-                    = mService.mRotationWatchers.get(i);
+                    = mWmService.mRotationWatchers.get(i);
             if (rotationWatcher.mDisplayId == mDisplayId) {
                 try {
                     rotationWatcher.mWatcher.onRotationChanged(rotation);
@@ -1392,9 +1393,9 @@
         // TODO (multi-display): Magnification is supported only for the default display.
         // Announce rotation only if we will not animate as we already have the
         // windows in final state. Otherwise, we make this call at the rotation end.
-        if (screenRotationAnimation == null && mService.mAccessibilityController != null
+        if (screenRotationAnimation == null && mWmService.mAccessibilityController != null
                 && isDefaultDisplay) {
-            mService.mAccessibilityController.onRotationChangedLocked(this);
+            mWmService.mAccessibilityController.onRotationChangedLocked(this);
         }
     }
 
@@ -1428,9 +1429,9 @@
                 Slog.d(TAG,
                         "Registering PointerEventListener for DisplayId: " + mDisplayId);
             }
-            mTapDetector = new TaskTapPointerEventListener(mService, this);
+            mTapDetector = new TaskTapPointerEventListener(mWmService, this);
             registerPointerEventListener(mTapDetector);
-            registerPointerEventListener(mService.mMousePositionTracker);
+            registerPointerEventListener(mWmService.mMousePositionTracker);
         }
     }
 
@@ -1495,7 +1496,7 @@
         // because we don't want letter-/pillar-boxing during resize.
         final DisplayInfo overrideDisplayInfo = mShouldOverrideDisplayConfiguration
                 ? mDisplayInfo : null;
-        mService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(mDisplayId,
+        mWmService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(mDisplayId,
                 overrideDisplayInfo);
 
         mBaseDisplayRect.set(0, 0, dw, dh);
@@ -1581,10 +1582,10 @@
         config.densityDpi = displayInfo.logicalDensityDpi;
 
         config.colorMode =
-                ((displayInfo.isHdr() && mService.hasHdrSupport())
+                ((displayInfo.isHdr() && mWmService.hasHdrSupport())
                         ? Configuration.COLOR_MODE_HDR_YES
                         : Configuration.COLOR_MODE_HDR_NO)
-                        | (displayInfo.isWideColorGamut() && mService.hasWideColorGamutSupport()
+                        | (displayInfo.isWideColorGamut() && mWmService.hasWideColorGamutSupport()
                         ? Configuration.COLOR_MODE_WIDE_COLOR_GAMUT_YES
                         : Configuration.COLOR_MODE_WIDE_COLOR_GAMUT_NO);
 
@@ -1596,7 +1597,7 @@
 
         int keyboardPresence = 0;
         int navigationPresence = 0;
-        final InputDevice[] devices = mService.mInputManager.getInputDevices();
+        final InputDevice[] devices = mWmService.mInputManager.getInputDevices();
         final int len = devices != null ? devices.length : 0;
         for (int i = 0; i < len; i++) {
             InputDevice device = devices[i];
@@ -1607,7 +1608,7 @@
                         WindowManagerPolicy.PRESENCE_INTERNAL;
 
                 // TODO(multi-display): Configure on per-display basis.
-                if (mService.mIsTouchDevice) {
+                if (mWmService.mIsTouchDevice) {
                     if ((sources & InputDevice.SOURCE_TOUCHSCREEN) ==
                             InputDevice.SOURCE_TOUCHSCREEN) {
                         config.touchscreen = Configuration.TOUCHSCREEN_FINGER;
@@ -1632,7 +1633,7 @@
             }
         }
 
-        if (config.navigation == Configuration.NAVIGATION_NONAV && mService.mHasPermanentDpad) {
+        if (config.navigation == Configuration.NAVIGATION_NONAV && mWmService.mHasPermanentDpad) {
             config.navigation = Configuration.NAVIGATION_DPAD;
             navigationPresence |= WindowManagerPolicy.PRESENCE_INTERNAL;
         }
@@ -1640,10 +1641,10 @@
         // Determine whether a hard keyboard is available and enabled.
         // TODO(multi-display): Should the hardware keyboard be tied to a display or to a device?
         boolean hardKeyboardAvailable = config.keyboard != Configuration.KEYBOARD_NOKEYS;
-        if (hardKeyboardAvailable != mService.mHardKeyboardAvailable) {
-            mService.mHardKeyboardAvailable = hardKeyboardAvailable;
-            mService.mH.removeMessages(WindowManagerService.H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
-            mService.mH.sendEmptyMessage(WindowManagerService.H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
+        if (hardKeyboardAvailable != mWmService.mHardKeyboardAvailable) {
+            mWmService.mHardKeyboardAvailable = hardKeyboardAvailable;
+            mWmService.mH.removeMessages(REPORT_HARD_KEYBOARD_STATUS_CHANGE);
+            mWmService.mH.sendEmptyMessage(REPORT_HARD_KEYBOARD_STATUS_CHANGE);
         }
 
         mDisplayPolicy.updateConfigurationDependentBehaviors();
@@ -1652,7 +1653,7 @@
         config.keyboardHidden = Configuration.KEYBOARDHIDDEN_NO;
         config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_NO;
         config.navigationHidden = Configuration.NAVIGATIONHIDDEN_NO;
-        mService.mPolicy.adjustConfigurationLw(config, keyboardPresence, navigationPresence);
+        mWmService.mPolicy.adjustConfigurationLw(config, keyboardPresence, navigationPresence);
     }
 
     private int computeCompatSmallestWidth(boolean rotated, int uiMode, int dw, int dh,
@@ -1949,7 +1950,7 @@
     @Override
     void onAppTransitionDone() {
         super.onAppTransitionDone();
-        mService.mWindowsChanged = true;
+        mWmService.mWindowsChanged = true;
     }
 
     /**
@@ -2001,9 +2002,9 @@
 
     @Override
     int getOrientation() {
-        final WindowManagerPolicy policy = mService.mPolicy;
+        final WindowManagerPolicy policy = mWmService.mPolicy;
 
-        if (mService.mDisplayFrozen) {
+        if (mWmService.mDisplayFrozen) {
             if (mLastWindowForcedOrientation != SCREEN_ORIENTATION_UNSPECIFIED) {
                 if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Display id=" + mDisplayId
                         + " is frozen, return " + mLastWindowForcedOrientation);
@@ -2044,7 +2045,7 @@
     }
 
     void initializeDisplayBaseInfo() {
-        final DisplayManagerInternal displayManagerInternal = mService.mDisplayManagerInternal;
+        final DisplayManagerInternal displayManagerInternal = mWmService.mDisplayManagerInternal;
         if (displayManagerInternal != null) {
             // Bootstrap the default logical display from the display manager.
             final DisplayInfo newDisplayInfo = displayManagerInternal.getDisplayInfo(mDisplayId);
@@ -2067,7 +2068,7 @@
      */
     private void updateBaseDisplayMetricsIfNeeded() {
         // Get real display metrics without overrides from WM.
-        mService.mDisplayManagerInternal.getNonOverrideDisplayInfo(mDisplayId, mDisplayInfo);
+        mWmService.mDisplayManagerInternal.getNonOverrideDisplayInfo(mDisplayId, mDisplayInfo);
         final int orientation = mDisplayInfo.rotation;
         final boolean rotated = (orientation == ROTATION_90 || orientation == ROTATION_270);
         final int newWidth = rotated ? mDisplayInfo.logicalHeight : mDisplayInfo.logicalWidth;
@@ -2096,7 +2097,7 @@
             mInitialDisplayHeight = newHeight;
             mInitialDisplayDensity = newDensity;
             mInitialDisplayCutout = newCutout;
-            mService.reconfigureDisplayLocked(this);
+            mWmService.reconfigureDisplayLocked(this);
         }
     }
 
@@ -2147,9 +2148,9 @@
     void setForcedDensity(int density, int userId) {
         final boolean clear = density == mInitialDisplayDensity;
         final boolean updateCurrent = userId == UserHandle.USER_CURRENT;
-        if (mService.mCurrentUserId == userId || updateCurrent) {
+        if (mWmService.mCurrentUserId == userId || updateCurrent) {
             mBaseDisplayDensity = density;
-            mService.reconfigureDisplayLocked(this);
+            mWmService.reconfigureDisplayLocked(this);
         }
         if (updateCurrent) {
             // We are applying existing settings so no need to save it again.
@@ -2159,7 +2160,7 @@
         if (density == mInitialDisplayDensity) {
             density = 0;
         }
-        mService.mDisplayWindowSettings.setForcedDensity(this, density, userId);
+        mWmService.mDisplayWindowSettings.setForcedDensity(this, density, userId);
     }
 
     /** @param mode {@link #FORCE_SCALING_MODE_AUTO} or {@link #FORCE_SCALING_MODE_DISABLED}. */
@@ -2170,9 +2171,9 @@
 
         mDisplayScalingDisabled = (mode != FORCE_SCALING_MODE_AUTO);
         Slog.i(TAG_WM, "Using display scaling mode: " + (mDisplayScalingDisabled ? "off" : "auto"));
-        mService.reconfigureDisplayLocked(this);
+        mWmService.reconfigureDisplayLocked(this);
 
-        mService.mDisplayWindowSettings.setForcedScalingMode(this, mode);
+        mWmService.mDisplayWindowSettings.setForcedScalingMode(this, mode);
     }
 
     /** If the given width and height equal to initial size, the setting will be cleared. */
@@ -2189,12 +2190,12 @@
 
         Slog.i(TAG_WM, "Using new display size: " + width + "x" + height);
         updateBaseDisplayMetrics(width, height, mBaseDisplayDensity);
-        mService.reconfigureDisplayLocked(this);
+        mWmService.reconfigureDisplayLocked(this);
 
         if (clear) {
             width = height = 0;
         }
-        mService.mDisplayWindowSettings.setForcedSize(this, width, height);
+        mWmService.mDisplayWindowSettings.setForcedSize(this, width, height);
     }
 
     void getStableRect(Rect out) {
@@ -2205,7 +2206,7 @@
         if (DEBUG_STACK) Slog.d(TAG_WM, "Create new stackId=" + stackId + " on displayId="
                 + mDisplayId);
 
-        final TaskStack stack = new TaskStack(mService, stackId, controller);
+        final TaskStack stack = new TaskStack(mWmService, stackId, controller);
         mTaskStackContainers.addStackToDisplay(stack, onTop);
         return stack;
     }
@@ -2361,7 +2362,7 @@
     @Override
     void switchUser() {
         super.switchUser();
-        mService.mWindowsChanged = true;
+        mWmService.mWindowsChanged = true;
     }
 
     private void resetAnimationBackgroundAnimator() {
@@ -2389,15 +2390,15 @@
             mUnknownAppVisibilityController.clear();
             mAppTransition.removeAppTransitionTimeoutCallbacks();
             handleAnimatingStoppedAndTransition();
-            mService.stopFreezingDisplayLocked();
+            mWmService.stopFreezingDisplayLocked();
             super.removeImmediately();
             if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Removing display=" + this);
             if (mPointerEventDispatcher != null && mTapDetector != null) {
                 unregisterPointerEventListener(mTapDetector);
-                unregisterPointerEventListener(mService.mMousePositionTracker);
+                unregisterPointerEventListener(mWmService.mMousePositionTracker);
                 mTapDetector = null;
             }
-            mService.mAnimator.removeDisplayLocked(mDisplayId);
+            mWmService.mAnimator.removeDisplayLocked(mDisplayId);
             mWindowingLayer.release();
             mOverlayLayer.release();
         } finally {
@@ -2406,7 +2407,7 @@
         }
 
         mDisplayPolicy.onDisplayRemoved();
-        mService.mWindowPlacerLocked.requestTraversal();
+        mWmService.mWindowPlacerLocked.requestTraversal();
     }
 
     /** Returns true if a removal action is still being deferred. */
@@ -2483,7 +2484,7 @@
         final boolean imeVisible = imeWin != null && imeWin.isVisibleLw() && imeWin.isDisplayedLw()
                 && !mDividerControllerLocked.isImeHideRequested();
         final boolean dockVisible = isStackVisible(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
-        final TaskStack imeTargetStack = mService.getImeFocusStackLocked();
+        final TaskStack imeTargetStack = mWmService.getImeFocusStackLocked();
         final int imeDockSide = (dockVisible && imeTargetStack != null) ?
                 imeTargetStack.getDockSide() : DOCKED_INVALID;
         final boolean imeOnTop = (imeDockSide == DOCKED_TOP);
@@ -2610,7 +2611,7 @@
         mDisplayInfo.writeToProto(proto, DISPLAY_INFO);
         proto.write(ROTATION, mRotation);
         final ScreenRotationAnimation screenRotationAnimation =
-                mService.mAnimator.getScreenRotationAnimationLocked(mDisplayId);
+                mWmService.mAnimator.getScreenRotationAnimationLocked(mDisplayId);
         if (screenRotationAnimation != null) {
             screenRotationAnimation.writeToProto(proto, SCREEN_ROTATION_ANIMATION);
         }
@@ -2855,11 +2856,11 @@
         }
 
         if (imWindowChanged) {
-            mService.mWindowsChanged = true;
+            mWmService.mWindowsChanged = true;
             setLayoutNeeded();
         }
 
-        if (DEBUG_FOCUS_LIGHT || mService.localLOGV) Slog.v(TAG_WM, "Changing focus from "
+        if (DEBUG_FOCUS_LIGHT || mWmService.localLOGV) Slog.v(TAG_WM, "Changing focus from "
                 + mCurrentFocus + " to " + newFocus + " displayId=" + getDisplayId()
                 + " Callers=" + Debug.getCallers(4));
         final WindowState oldFocus = mCurrentFocus;
@@ -2898,7 +2899,7 @@
             if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
                 performLayout(true /*initial*/, updateInputWindows);
             } else if (mode == UPDATE_FOCUS_REMOVING_FOCUS) {
-                mService.mRoot.performSurfacePlacement(false);
+                mWmService.mRoot.performSurfacePlacement(false);
             }
         }
 
@@ -2963,16 +2964,16 @@
     // moving containers or resizing them. Need to investigate the best way to have it automatically
     // happen so we don't run into issues with programmers forgetting to do it.
     void layoutAndAssignWindowLayersIfNeeded() {
-        mService.mWindowsChanged = true;
+        mWmService.mWindowsChanged = true;
         setLayoutNeeded();
 
-        if (!mService.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,
+        if (!mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,
                 false /*updateInputWindows*/)) {
             assignWindowLayers(false /* setLayoutNeeded */);
         }
 
         mInputMonitor.setUpdateInputWindowsNeededLw();
-        mService.mWindowPlacerLocked.performSurfacePlacement();
+        mWmService.mWindowPlacerLocked.performSurfacePlacement();
         mInputMonitor.updateInputWindowsLw(false /*force*/);
     }
 
@@ -2985,14 +2986,14 @@
             if (wsa.mSurfaceController == null) {
                 return;
             }
-            if (!mService.mSessions.contains(wsa.mSession)) {
+            if (!mWmService.mSessions.contains(wsa.mSession)) {
                 Slog.w(TAG_WM, "LEAKED SURFACE (session doesn't exist): "
                         + w + " surface=" + wsa.mSurfaceController
                         + " token=" + w.mToken
                         + " pid=" + w.mSession.mPid
                         + " uid=" + w.mSession.mUid);
                 wsa.destroySurface();
-                mService.mForceRemoves.add(w);
+                mWmService.mForceRemoves.add(w);
                 mTmpWindow = w;
             } else if (w.mAppToken != null && w.mAppToken.isClientHidden()) {
                 Slog.w(TAG_WM, "LEAKED SURFACE (app token hidden): "
@@ -3016,7 +3017,7 @@
         // Update display configuration for IME process.
         if (mInputMethodWindow != null) {
             final int imePid = mInputMethodWindow.mSession.mPid;
-            mService.mAtmInternal.onImeWindowSetOnDisplay(imePid,
+            mWmService.mAtmInternal.onImeWindowSetOnDisplay(imePid,
                     mInputMethodWindow.getDisplayId());
         }
         computeImeTarget(true /* updateImeTarget */);
@@ -3237,7 +3238,7 @@
      * Starts the Keyguard exit animation on all windows that don't belong to an app token.
      */
     void startKeyguardExitOnNonAppWindows(boolean onWallpaper, boolean goingToShade) {
-        final WindowManagerPolicy policy = mService.mPolicy;
+        final WindowManagerPolicy policy = mWmService.mPolicy;
         forAllWindows(w -> {
             if (w.mAppToken == null && policy.canBeHiddenByKeyguardLw(w)
                     && w.wouldBeVisibleIfPolicyIgnored() && !w.isVisible()) {
@@ -3266,7 +3267,7 @@
                 } else if (w.mAttrs.type == TYPE_WALLPAPER) {
                     mHaveWallpaper = true;
                 } else if (w.mAttrs.type == TYPE_STATUS_BAR) {
-                    mHaveKeyguard = mService.mPolicy.isKeyguardDrawnLw();
+                    mHaveKeyguard = mWmService.mPolicy.isKeyguardDrawnLw();
                 }
             }
             return false;
@@ -3279,28 +3280,28 @@
 
         // if the wallpaper service is disabled on the device, we're never going to have
         // wallpaper, don't bother waiting for it
-        boolean wallpaperEnabled = mService.mContext.getResources().getBoolean(
+        boolean wallpaperEnabled = mWmService.mContext.getResources().getBoolean(
                 com.android.internal.R.bool.config_enableWallpaperService)
-                && mService.mContext.getResources().getBoolean(
+                && mWmService.mContext.getResources().getBoolean(
                         com.android.internal.R.bool.config_checkWallpaperAtBoot)
-                && !mService.mOnlyCore;
+                && !mWmService.mOnlyCore;
 
         if (DEBUG_SCREEN_ON || DEBUG_BOOT) Slog.i(TAG_WM,
-                "******** booted=" + mService.mSystemBooted
-                + " msg=" + mService.mShowingBootMessages
+                "******** booted=" + mWmService.mSystemBooted
+                + " msg=" + mWmService.mShowingBootMessages
                 + " haveBoot=" + mHaveBootMsg + " haveApp=" + mHaveApp
                 + " haveWall=" + mHaveWallpaper + " wallEnabled=" + wallpaperEnabled
                 + " haveKeyguard=" + mHaveKeyguard);
 
         // If we are turning on the screen to show the boot message, don't do it until the boot
         // message is actually displayed.
-        if (!mService.mSystemBooted && !mHaveBootMsg) {
+        if (!mWmService.mSystemBooted && !mHaveBootMsg) {
             return true;
         }
 
         // If we are turning on the screen after the boot is completed normally, don't do so until
         // we have the application and wallpaper.
-        if (mService.mSystemBooted
+        if (mWmService.mSystemBooted
                 && ((!mHaveApp && !mHaveKeyguard) || (wallpaperEnabled && !mHaveWallpaper))) {
             return true;
         }
@@ -3366,7 +3367,7 @@
 
         mLastDispatchedSystemUiVisibility = visibility;
         if (isDefaultDisplay) {
-            mService.mInputManager.setSystemUiVisibility(visibility);
+            mWmService.mInputManager.setSystemUiVisibility(visibility);
         }
         updateSystemUiVisibility(visibility, globalDiff);
         return true;
@@ -3395,13 +3396,13 @@
     void reevaluateStatusBarVisibility() {
         int visibility = getDisplayPolicy().adjustSystemUiVisibilityLw(mLastStatusBarVisibility);
         if (updateStatusBarVisibilityLocked(visibility)) {
-            mService.mWindowPlacerLocked.requestTraversal();
+            mWmService.mWindowPlacerLocked.requestTraversal();
         }
     }
 
     void onWindowFreezeTimeout() {
         Slog.w(TAG_WM, "Window freeze timeout expired.");
-        mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_TIMEOUT;
+        mWmService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_TIMEOUT;
 
         forAllWindows(w -> {
             if (!w.getOrientationChanging()) {
@@ -3409,28 +3410,28 @@
             }
             w.orientationChangeTimedOut();
             w.mLastFreezeDuration = (int)(SystemClock.elapsedRealtime()
-                    - mService.mDisplayFreezeTime);
+                    - mWmService.mDisplayFreezeTime);
             Slog.w(TAG_WM, "Force clearing orientation change: " + w);
         }, true /* traverseTopToBottom */);
-        mService.mWindowPlacerLocked.performSurfacePlacement();
+        mWmService.mWindowPlacerLocked.performSurfacePlacement();
     }
 
     void waitForAllWindowsDrawn() {
-        final WindowManagerPolicy policy = mService.mPolicy;
+        final WindowManagerPolicy policy = mWmService.mPolicy;
         forAllWindows(w -> {
             final boolean keyguard = policy.isKeyguardHostWindow(w.mAttrs);
             if (w.isVisibleLw() && (w.mAppToken != null || keyguard)) {
                 w.mWinAnimator.mDrawState = DRAW_PENDING;
                 // Force add to mResizingWindows.
                 w.resetLastContentInsets();
-                mService.mWaitingForDrawn.add(w);
+                mWmService.mWaitingForDrawn.add(w);
             }
         }, true /* traverseTopToBottom */);
     }
 
     // TODO: Super crazy long method that should be broken down...
     void applySurfaceChangesTransaction(boolean recoveringMemory) {
-        final WindowSurfacePlacer surfacePlacer = mService.mWindowPlacerLocked;
+        final WindowSurfacePlacer surfacePlacer = mWmService.mWindowPlacerLocked;
 
         mTmpUpdateAllDrawn.clear();
 
@@ -3487,7 +3488,7 @@
         prepareSurfaces();
 
         mLastHasContent = mTmpApplySurfaceChangesTransactionState.displayHasContent;
-        mService.mDisplayManagerInternal.setDisplayProperties(mDisplayId,
+        mWmService.mDisplayManagerInternal.setDisplayProperties(mDisplayId,
                 mLastHasContent,
                 mTmpApplySurfaceChangesTransactionState.preferredRefreshRate,
                 mTmpApplySurfaceChangesTransactionState.preferredModeId,
@@ -3496,7 +3497,7 @@
         final boolean wallpaperVisible = mWallpaperController.isWallpaperVisible();
         if (wallpaperVisible != mLastWallpaperVisible) {
             mLastWallpaperVisible = wallpaperVisible;
-            mService.mWallpaperVisibilityListeners.notifyWallpaperVisibilityChanged(this);
+            mWmService.mWallpaperVisibilityListeners.notifyWallpaperVisibilityChanged(this);
         }
 
         while (!mTmpUpdateAllDrawn.isEmpty()) {
@@ -3594,7 +3595,7 @@
             mInputMonitor.updateInputWindowsLw(false /*force*/);
         }
 
-        mService.mH.sendEmptyMessage(UPDATE_DOCKED_STACK_DIVIDER);
+        mWmService.mH.sendEmptyMessage(UPDATE_DOCKED_STACK_DIVIDER);
     }
 
     /**
@@ -3604,7 +3605,7 @@
      * @param config of the output bitmap
      */
     Bitmap screenshotDisplayLocked(Bitmap.Config config) {
-        if (!mService.mPolicy.isScreenOn()) {
+        if (!mWmService.mPolicy.isScreenOn()) {
             if (DEBUG_SCREENSHOT) {
                 Slog.i(TAG_WM, "Attempted to take screenshot while display was off.");
             }
@@ -3632,7 +3633,7 @@
         convertCropForSurfaceFlinger(frame, rot, dw, dh);
 
         final ScreenRotationAnimation screenRotationAnimation =
-                mService.mAnimator.getScreenRotationAnimationLocked(DEFAULT_DISPLAY);
+                mWmService.mAnimator.getScreenRotationAnimationLocked(DEFAULT_DISPLAY);
         final boolean inRotation = screenRotationAnimation != null &&
                 screenRotationAnimation.isAnimating();
         if (DEBUG_SCREENSHOT && inRotation) Slog.v(TAG_WM, "Taking screenshot while rotating");
@@ -3688,11 +3689,11 @@
             mTmpWindow = w;
             w.setDisplayLayoutNeeded();
             w.finishSeamlessRotation(true /* timeout */);
-            mService.markForSeamlessRotation(w, false);
+            mWmService.markForSeamlessRotation(w, false);
         }, true /* traverseTopToBottom */);
 
         if (mTmpWindow != null) {
-            mService.mWindowPlacerLocked.performSurfacePlacement();
+            mWmService.mWindowPlacerLocked.performSurfacePlacement();
         }
     }
 
@@ -3720,20 +3721,20 @@
     @Override
     void onDescendantOverrideConfigurationChanged() {
         setLayoutNeeded();
-        mService.requestTraversal();
+        mWmService.requestTraversal();
     }
 
     boolean okToDisplay() {
         if (mDisplayId == DEFAULT_DISPLAY) {
-            return !mService.mDisplayFrozen
-                    && mService.mDisplayEnabled && mService.mPolicy.isScreenOn();
+            return !mWmService.mDisplayFrozen
+                    && mWmService.mDisplayEnabled && mWmService.mPolicy.isScreenOn();
         }
         return mDisplayInfo.state == Display.STATE_ON;
     }
 
     boolean okToAnimate() {
         return okToDisplay() &&
-                (mDisplayId != DEFAULT_DISPLAY || mService.mPolicy.okToAnimate());
+                (mDisplayId != DEFAULT_DISPLAY || mWmService.mPolicy.okToAnimate());
     }
 
     static final class TaskForResizePointSearchResult {
@@ -3951,7 +3952,7 @@
             } else if (stack == mSplitScreenPrimaryStack) {
                 mSplitScreenPrimaryStack = null;
                 // Re-set the split-screen create mode whenever the split-screen stack is removed.
-                mService.setDockedStackCreateStateLocked(
+                mWmService.setDockedStackCreateStateLocked(
                         SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT, null /* initialBounds */);
                 mDividerControllerLocked.notifyDockedStackExistsChanged(false);
             }
@@ -4169,7 +4170,7 @@
             }
 
             final int orientation = super.getOrientation();
-            boolean isCar = mService.mContext.getPackageManager().hasSystemFeature(
+            boolean isCar = mWmService.mContext.getPackageManager().hasSystemFeature(
                     PackageManager.FEATURE_AUTOMOTIVE);
             if (isCar) {
                 // In a car, you cannot physically rotate the screen, so it doesn't make sense to
@@ -4350,10 +4351,10 @@
                 wt.assignLayer(t, j);
                 wt.assignChildLayers(t);
 
-                int layer = mService.mPolicy.getWindowLayerFromTypeLw(
+                int layer = mWmService.mPolicy.getWindowLayerFromTypeLw(
                         wt.windowType, wt.mOwnerCanManageAppTokens);
 
-                if (needAssignIme && layer >= mService.mPolicy.getWindowLayerFromTypeLw(
+                if (needAssignIme && layer >= mWmService.mPolicy.getWindowLayerFromTypeLw(
                                 TYPE_INPUT_METHOD_DIALOG, true)) {
                     imeContainer.assignRelativeLayer(t, wt.getSurfaceControl(), -1);
                     needAssignIme = false;
@@ -4376,9 +4377,9 @@
          */
         private final Comparator<WindowToken> mWindowComparator = (token1, token2) ->
                 // Tokens with higher base layer are z-ordered on-top.
-                mService.mPolicy.getWindowLayerFromTypeLw(token1.windowType,
+                mWmService.mPolicy.getWindowLayerFromTypeLw(token1.windowType,
                         token1.mOwnerCanManageAppTokens)
-                < mService.mPolicy.getWindowLayerFromTypeLw(token2.windowType,
+                < mWmService.mPolicy.getWindowLayerFromTypeLw(token2.windowType,
                         token2.mOwnerCanManageAppTokens) ? -1 : 1;
 
         private final Predicate<WindowState> mGetOrientingWindow = w -> {
@@ -4408,7 +4409,7 @@
 
         @Override
         int getOrientation() {
-            final WindowManagerPolicy policy = mService.mPolicy;
+            final WindowManagerPolicy policy = mWmService.mPolicy;
             // Find a window requesting orientation.
             final WindowState win = getWindow(mGetOrientingWindow);
 
@@ -4416,7 +4417,7 @@
                 final int req = win.mAttrs.screenOrientation;
                 if (policy.isKeyguardHostWindow(win.mAttrs)) {
                     mLastKeyguardForcedOrientation = req;
-                    if (mService.mKeyguardGoingAway) {
+                    if (mWmService.mKeyguardGoingAway) {
                         // Keyguard can't affect the orientation if it is going away...
                         mLastWindowForcedOrientation = SCREEN_ORIENTATION_UNSPECIFIED;
                         return SCREEN_ORIENTATION_UNSET;
@@ -4474,7 +4475,7 @@
     };
 
     SurfaceControl.Builder makeSurface(SurfaceSession s) {
-        return mService.makeSurfaceBuilder(s)
+        return mWmService.makeSurfaceBuilder(s)
                 .setParent(mWindowingLayer);
     }
 
@@ -4486,7 +4487,7 @@
     @Override
     SurfaceControl.Builder makeChildSurface(WindowContainer child) {
         SurfaceSession s = child != null ? child.getSession() : getSession();
-        final SurfaceControl.Builder b = mService.makeSurfaceBuilder(s);
+        final SurfaceControl.Builder b = mWmService.makeSurfaceBuilder(s);
         if (child == null) {
             return b;
         }
@@ -4502,7 +4503,7 @@
      * and other potpourii.
      */
     SurfaceControl.Builder makeOverlay() {
-        return mService.makeSurfaceBuilder(mSession)
+        return mWmService.makeSurfaceBuilder(mSession)
             .setParent(mOverlayLayer);
     }
 
@@ -4601,7 +4602,7 @@
     @Override
     void prepareSurfaces() {
         final ScreenRotationAnimation screenRotationAnimation =
-                mService.mAnimator.getScreenRotationAnimationLocked(mDisplayId);
+                mWmService.mAnimator.getScreenRotationAnimationLocked(mDisplayId);
         if (screenRotationAnimation != null && screenRotationAnimation.isAnimating()) {
             screenRotationAnimation.getEnterTransformation().getMatrix().getValues(mTmpFloats);
             mPendingTransaction.setMatrix(mWindowingLayer,
@@ -4689,7 +4690,7 @@
                         + mDisplayId + " Callers=" + Debug.getCallers(5));
             }
             mAppTransition.setReady();
-            mService.mWindowPlacerLocked.requestTraversal();
+            mWmService.mWindowPlacerLocked.requestTraversal();
         }
     }
 
@@ -4719,7 +4720,7 @@
         mWallpaperMayChange = true;
         // Since the window list has been rebuilt, focus might have to be recomputed since the
         // actual order of windows might have changed again.
-        mService.mFocusMayChange = true;
+        mWmService.mFocusMayChange = true;
 
         pendingLayoutChanges |= changes;
     }
@@ -4732,7 +4733,7 @@
         return mDisplay.supportsSystemDecorations()
                 // TODO (b/111363427): Remove this and set the new FLAG_SHOULD_SHOW_LAUNCHER flag
                 // (b/114338689) whenever vr 2d display id is set.
-                || mDisplayId == mService.mVr2dDisplayId
-                || mService.mForceDesktopModeOnExternalDisplays;
+                || mDisplayId == mWmService.mVr2dDisplayId
+                || mWmService.mForceDesktopModeOnExternalDisplays;
     }
 }
diff --git a/services/core/java/com/android/server/wm/DisplayWindowController.java b/services/core/java/com/android/server/wm/DisplayWindowController.java
index 864f7e1..55b3def 100644
--- a/services/core/java/com/android/server/wm/DisplayWindowController.java
+++ b/services/core/java/com/android/server/wm/DisplayWindowController.java
@@ -90,7 +90,7 @@
     public void onOverrideConfigurationChanged(Configuration overrideConfiguration) {
         synchronized (mGlobalLock) {
             if (mContainer != null) {
-                mContainer.mService.setNewDisplayOverrideConfiguration(overrideConfiguration,
+                mContainer.mWmService.setNewDisplayOverrideConfiguration(overrideConfiguration,
                         mContainer);
             }
         }
diff --git a/services/core/java/com/android/server/wm/LaunchParamsPersister.java b/services/core/java/com/android/server/wm/LaunchParamsPersister.java
index bc6a690..3062d34 100644
--- a/services/core/java/com/android/server/wm/LaunchParamsPersister.java
+++ b/services/core/java/com/android/server/wm/LaunchParamsPersister.java
@@ -246,8 +246,8 @@
     }
 
     void getLaunchParams(TaskRecord task, ActivityRecord activity, LaunchParams outParams) {
-        final ComponentName name = task != null ? task.realActivity : activity.realActivity;
-        final int userId = task != null ? task.userId : activity.userId;
+        final ComponentName name = task != null ? task.realActivity : activity.mActivityComponent;
+        final int userId = task != null ? task.userId : activity.mUserId;
 
         outParams.reset();
         Map<ComponentName, PersistableLaunchParams> map = mMap.get(userId);
diff --git a/services/core/java/com/android/server/wm/LockTaskController.java b/services/core/java/com/android/server/wm/LockTaskController.java
index 80dc245..d2f2863 100644
--- a/services/core/java/com/android/server/wm/LockTaskController.java
+++ b/services/core/java/com/android/server/wm/LockTaskController.java
@@ -225,7 +225,7 @@
      * of the last locked task and finishing it would mean that lock task mode is ended illegally.
      */
     boolean activityBlockedFromFinish(ActivityRecord activity) {
-        final TaskRecord task = activity.getTask();
+        final TaskRecord task = activity.getTaskRecord();
         if (activity == task.getRootActivity()
                 && activity == task.getTopActivity()
                 && task.mLockTaskAuth != LOCK_TASK_AUTH_LAUNCHABLE_PRIV
@@ -647,7 +647,7 @@
         }
 
         final ActivityRecord r = mSupervisor.mRootActivityContainer.topRunningActivity();
-        final TaskRecord task = (r != null) ? r.getTask() : null;
+        final TaskRecord task = (r != null) ? r.getTaskRecord() : null;
         if (mLockTaskModeTasks.isEmpty() && task!= null
                 && task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE) {
             // This task must have just been authorized.
diff --git a/services/core/java/com/android/server/wm/RecentsAnimation.java b/services/core/java/com/android/server/wm/RecentsAnimation.java
index 24c5228..1e287b4 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimation.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimation.java
@@ -148,8 +148,8 @@
                 // If there are multiple tasks in the target stack (ie. the home stack, with 3p
                 // and default launchers coexisting), then move the task to the top as a part of
                 // moving the stack to the front
-                if (targetStack.topTask() != targetActivity.getTask()) {
-                    targetStack.addTask(targetActivity.getTask(), true /* toTop */,
+                if (targetStack.topTask() != targetActivity.getTaskRecord()) {
+                    targetStack.addTask(targetActivity.getTaskRecord(), true /* toTop */,
                             "startRecentsActivity");
                 }
             } else {
diff --git a/services/core/java/com/android/server/wm/RootActivityContainer.java b/services/core/java/com/android/server/wm/RootActivityContainer.java
index 4dd48c4..1d86b46 100644
--- a/services/core/java/com/android/server/wm/RootActivityContainer.java
+++ b/services/core/java/com/android/server/wm/RootActivityContainer.java
@@ -414,7 +414,7 @@
         // Only resume home activity if isn't finishing.
         if (r != null && !r.finishing) {
             r.moveFocusableActivityToTop(myReason);
-            return resumeFocusedStacksTopActivities(r.getStack(), prev, null);
+            return resumeFocusedStacksTopActivities(r.getActivityStack(), prev, null);
         }
         return startHomeOnDisplay(mCurrentUser, myReason, displayId);
     }
@@ -843,7 +843,7 @@
 
         mWindowManager.deferSurfaceLayout();
 
-        final ActivityDisplay display = r.getStack().getDisplay();
+        final ActivityDisplay display = r.getActivityStack().getDisplay();
         PinnedActivityStack stack = display.getPinnedStack();
 
         // This will clear the pinned stack by moving an existing task to the full screen stack,
@@ -860,7 +860,7 @@
         final Rect destBounds = stack.getDefaultPictureInPictureBounds(aspectRatio);
 
         try {
-            final TaskRecord task = r.getTask();
+            final TaskRecord task = r.getTaskRecord();
             // Resize the pinned stack to match the current size of the task the activity we are
             // going to be moving is currently contained in. We do this to have the right starting
             // animation bounds for the pinned stack to the desired bounds the caller wants.
@@ -882,7 +882,7 @@
                 // ensures that all the necessary work to migrate states in the old and new stacks
                 // is also done.
                 final TaskRecord newTask = task.getStack().createTaskRecord(
-                        mStackSupervisor.getNextTaskIdForUserLocked(r.userId), r.info,
+                        mStackSupervisor.getNextTaskIdForUserLocked(r.mUserId), r.info,
                         r.intent, null, null, true);
                 r.reparent(newTask, MAX_VALUE, "moveActivityToStack");
 
@@ -1538,7 +1538,7 @@
             stack = candidateTask.getStack();
         }
         if (stack == null && r != null) {
-            stack = r.getStack();
+            stack = r.getActivityStack();
         }
         if (stack != null) {
             display = stack.getDisplay();
@@ -1604,7 +1604,7 @@
         // If {@code r} is already in target display and its task is the same as the candidate task,
         // the intention should be getting a launch stack for the reusable activity, so we can use
         // the existing stack.
-        if (r.getDisplayId() == displayId && r.getTask() == candidateTask) {
+        if (r.getDisplayId() == displayId && r.getTaskRecord() == candidateTask) {
             return candidateTask.getStack();
         }
 
@@ -1950,8 +1950,8 @@
         final ActivityRecord activityRecord = task.getTopActivity();
         final ActivityRecord resultTo = (activityRecord != null ? activityRecord.resultTo : null);
 
-        return (activityRecord != null && activityRecord.userId == userId)
-                || (resultTo != null && resultTo.userId == userId);
+        return (activityRecord != null && activityRecord.mUserId == userId)
+                || (resultTo != null && resultTo.mUserId == userId);
     }
 
     void cancelInitializingActivities() {
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java
index 80d1368..b98d154 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -182,7 +182,7 @@
                 mTopFocusedDisplayId != topFocusedDisplayId && mode == UPDATE_FOCUS_NORMAL;
         if (mTopFocusedDisplayId != topFocusedDisplayId) {
             mTopFocusedDisplayId = topFocusedDisplayId;
-            mService.mInputManager.setFocusedDisplay(mTopFocusedDisplayId);
+            mWmService.mInputManager.setFocusedDisplay(mTopFocusedDisplayId);
             if (DEBUG_FOCUS_LIGHT) Slog.v(TAG_WM, "New topFocusedDisplayId="
                     + mTopFocusedDisplayId);
         }
@@ -194,10 +194,10 @@
             final boolean isTopFocusedDisplay =
                     topFocusedDisplayChanged && dc.getDisplayId() == mTopFocusedDisplayId;
             if (windowFocusChanged || isTopFocusedDisplay) {
-                final Message msg = mService.mH.obtainMessage(
+                final Message msg = mWmService.mH.obtainMessage(
                         WindowManagerService.H.REPORT_FOCUS_CHANGE, dc);
                 msg.arg1 = topFocusedDisplayChanged ? 1 : 0;
-                mService.mH.sendMessage(msg);
+                mWmService.mH.sendMessage(msg);
             }
         });
 
@@ -211,7 +211,7 @@
 
     @Override
     void onChildPositionChanged() {
-        mService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, false /* updateInputWindows */);
+        mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, false /* updateInputWindows */);
     }
 
     DisplayContent getDisplayContent(int displayId) {
@@ -238,20 +238,20 @@
             return existing;
         }
 
-        final DisplayContent dc = new DisplayContent(display, mService, controller);
+        final DisplayContent dc = new DisplayContent(display, mWmService, controller);
 
         if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Adding display=" + display);
 
-        mService.mDisplayWindowSettings.applySettingsToDisplayLocked(dc);
+        mWmService.mDisplayWindowSettings.applySettingsToDisplayLocked(dc);
         initializeDisplayOverrideConfiguration(controller, dc);
 
-        if (mService.mDisplayManagerInternal != null) {
-            mService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(
+        if (mWmService.mDisplayManagerInternal != null) {
+            mWmService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(
                     displayId, dc.getDisplayInfo());
             dc.configureDisplayPolicy();
         }
 
-        mService.reconfigureDisplayLocked(dc);
+        mWmService.reconfigureDisplayLocked(dc);
 
         return dc;
     }
@@ -436,11 +436,11 @@
 
     void removeReplacedWindows() {
         if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION removeReplacedWindows");
-        mService.openSurfaceTransaction();
+        mWmService.openSurfaceTransaction();
         try {
             forAllWindows(sRemoveReplacedWindowsConsumer, true /* traverseTopToBottom */);
         } finally {
-            mService.closeSurfaceTransaction("removeReplacedWindows");
+            mWmService.closeSurfaceTransaction("removeReplacedWindows");
             if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION removeReplacedWindows");
         }
     }
@@ -488,7 +488,7 @@
                 final SparseIntArray pidCandidates = new SparseIntArray();
                 for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
                     mChildren.get(displayNdx).forAllWindows((w) -> {
-                        if (mService.mForceRemoves.contains(w)) {
+                        if (mWmService.mForceRemoves.contains(w)) {
                             return;
                         }
                         final WindowStateAnimator wsa = w.mWinAnimator;
@@ -503,7 +503,7 @@
                             pids[i] = pidCandidates.keyAt(i);
                         }
                         try {
-                            if (mService.mActivityManager.killPids(pids, "Free memory", secure)) {
+                            if (mWmService.mActivityManager.killPids(pids, "Free memory", secure)) {
                                 killedApps = true;
                             }
                         } catch (RemoteException e) {
@@ -547,9 +547,9 @@
         int i;
         boolean updateInputWindowsNeeded = false;
 
-        if (mService.mFocusMayChange) {
-            mService.mFocusMayChange = false;
-            updateInputWindowsNeeded = mService.updateFocusedWindowLocked(
+        if (mWmService.mFocusMayChange) {
+            mWmService.mFocusMayChange = false;
+            updateInputWindowsNeeded = mWmService.updateFocusedWindowLocked(
                     UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/);
         }
 
@@ -565,31 +565,31 @@
         mUserActivityTimeout = -1;
         mObscureApplicationContentOnSecondaryDisplays = false;
         mSustainedPerformanceModeCurrent = false;
-        mService.mTransactionSequence++;
+        mWmService.mTransactionSequence++;
 
         // TODO(multi-display): recents animation & wallpaper need support multi-display.
-        final DisplayContent defaultDisplay = mService.getDefaultDisplayContentLocked();
-        final WindowSurfacePlacer surfacePlacer = mService.mWindowPlacerLocked;
+        final DisplayContent defaultDisplay = mWmService.getDefaultDisplayContentLocked();
+        final WindowSurfacePlacer surfacePlacer = mWmService.mWindowPlacerLocked;
 
         if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
                 ">>> OPEN TRANSACTION performLayoutAndPlaceSurfaces");
-        mService.openSurfaceTransaction();
+        mWmService.openSurfaceTransaction();
         try {
             applySurfaceChangesTransaction(recoveringMemory);
         } catch (RuntimeException e) {
             Slog.wtf(TAG, "Unhandled exception in Window Manager", e);
         } finally {
-            mService.closeSurfaceTransaction("performLayoutAndPlaceSurfaces");
+            mWmService.closeSurfaceTransaction("performLayoutAndPlaceSurfaces");
             if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
                     "<<< CLOSE TRANSACTION performLayoutAndPlaceSurfaces");
         }
-        mService.mAnimator.executeAfterPrepareSurfacesRunnables();
+        mWmService.mAnimator.executeAfterPrepareSurfacesRunnables();
 
         checkAppTransitionReady(surfacePlacer);
 
         // Defer starting the recents animation until the wallpaper has drawn
         final RecentsAnimationController recentsAnimationController =
-                mService.getRecentsAnimationController();
+                mWmService.getRecentsAnimationController();
         if (recentsAnimationController != null) {
             recentsAnimationController.checkAnimationReady(defaultDisplay.mWallpaperController);
         }
@@ -606,9 +606,9 @@
             }
         }
 
-        if (mService.mFocusMayChange) {
-            mService.mFocusMayChange = false;
-            if (mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES,
+        if (mWmService.mFocusMayChange) {
+            mWmService.mFocusMayChange = false;
+            if (mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES,
                     false /*updateInputWindows*/)) {
                 updateInputWindowsNeeded = true;
             }
@@ -622,23 +622,23 @@
 
         handleResizingWindows();
 
-        if (DEBUG_ORIENTATION && mService.mDisplayFrozen) Slog.v(TAG,
+        if (DEBUG_ORIENTATION && mWmService.mDisplayFrozen) Slog.v(TAG,
                 "With display frozen, orientationChangeComplete=" + mOrientationChangeComplete);
         if (mOrientationChangeComplete) {
-            if (mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) {
-                mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_NONE;
-                mService.mLastFinishedFreezeSource = mLastWindowFreezeSource;
-                mService.mH.removeMessages(WINDOW_FREEZE_TIMEOUT);
+            if (mWmService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) {
+                mWmService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_NONE;
+                mWmService.mLastFinishedFreezeSource = mLastWindowFreezeSource;
+                mWmService.mH.removeMessages(WINDOW_FREEZE_TIMEOUT);
             }
-            mService.stopFreezingDisplayLocked();
+            mWmService.stopFreezingDisplayLocked();
         }
 
         // Destroy the surface of any windows that are no longer visible.
-        i = mService.mDestroySurface.size();
+        i = mWmService.mDestroySurface.size();
         if (i > 0) {
             do {
                 i--;
-                WindowState win = mService.mDestroySurface.get(i);
+                WindowState win = mWmService.mDestroySurface.get(i);
                 win.mDestroying = false;
                 final DisplayContent displayContent = win.getDisplayContent();
                 if (displayContent.mInputMethodWindow == win) {
@@ -650,7 +650,7 @@
                 win.destroySurfaceUnchecked();
                 win.mWinAnimator.destroyPreservedSurfaceLocked();
             } while (i > 0);
-            mService.mDestroySurface.clear();
+            mWmService.mDestroySurface.clear();
         }
 
         // Time to remove any exiting tokens?
@@ -671,8 +671,8 @@
             dc.getInputMonitor().updateInputWindowsLw(true /*force*/);
         });
 
-        mService.setHoldScreenLocked(mHoldScreen);
-        if (!mService.mDisplayFrozen) {
+        mWmService.setHoldScreenLocked(mHoldScreen);
+        if (!mWmService.mDisplayFrozen) {
             final int brightness = mScreenBrightness < 0 || mScreenBrightness > 1.0f
                     ? -1 : toBrightnessOverride(mScreenBrightness);
 
@@ -684,7 +684,7 @@
 
         if (mSustainedPerformanceModeCurrent != mSustainedPerformanceModeEnabled) {
             mSustainedPerformanceModeEnabled = mSustainedPerformanceModeCurrent;
-            mService.mPowerManagerInternal.powerHint(
+            mWmService.mPowerManagerInternal.powerHint(
                     PowerHint.SUSTAINED_PERFORMANCE,
                     (mSustainedPerformanceModeEnabled ? 1 : 0));
         }
@@ -694,22 +694,22 @@
             mUpdateRotation = updateRotationUnchecked();
         }
 
-        if (mService.mWaitingForDrawnCallback != null
+        if (mWmService.mWaitingForDrawnCallback != null
                 || (mOrientationChangeComplete && !isLayoutNeeded()
                         && !mUpdateRotation)) {
-            mService.checkDrawnWindowsLocked();
+            mWmService.checkDrawnWindowsLocked();
         }
 
-        final int N = mService.mPendingRemove.size();
+        final int N = mWmService.mPendingRemove.size();
         if (N > 0) {
-            if (mService.mPendingRemoveTmp.length < N) {
-                mService.mPendingRemoveTmp = new WindowState[N + 10];
+            if (mWmService.mPendingRemoveTmp.length < N) {
+                mWmService.mPendingRemoveTmp = new WindowState[N + 10];
             }
-            mService.mPendingRemove.toArray(mService.mPendingRemoveTmp);
-            mService.mPendingRemove.clear();
+            mWmService.mPendingRemove.toArray(mWmService.mPendingRemoveTmp);
+            mWmService.mPendingRemove.clear();
             ArrayList<DisplayContent> displayList = new ArrayList();
             for (i = 0; i < N; i++) {
-                final WindowState w = mService.mPendingRemoveTmp[i];
+                final WindowState w = mWmService.mPendingRemoveTmp[i];
                 w.removeImmediately();
                 final DisplayContent displayContent = w.getDisplayContent();
                 if (displayContent != null && !displayList.contains(displayContent)) {
@@ -737,12 +737,13 @@
 
         // Check to see if we are now in a state where the screen should
         // be enabled, because the window obscured flags have changed.
-        mService.enableScreenIfNeededLocked();
+        mWmService.enableScreenIfNeededLocked();
 
-        mService.scheduleAnimationLocked();
+        mWmService.scheduleAnimationLocked();
 
         if (DEBUG_WINDOW_TRACE) Slog.e(TAG,
-                "performSurfacePlacementInner exit: animating=" + mService.mAnimator.isAnimating());
+                "performSurfacePlacementInner exit: animating="
+                        + mWmService.mAnimator.isAnimating());
     }
 
     private void checkAppTransitionReady(WindowSurfacePlacer surfacePlacer) {
@@ -782,23 +783,23 @@
         mObscuringWindow = null;
 
         // TODO(multi-display): Support these features on secondary screens.
-        final DisplayContent defaultDc = mService.getDefaultDisplayContentLocked();
+        final DisplayContent defaultDc = mWmService.getDefaultDisplayContentLocked();
         final DisplayInfo defaultInfo = defaultDc.getDisplayInfo();
         final int defaultDw = defaultInfo.logicalWidth;
         final int defaultDh = defaultInfo.logicalHeight;
-        if (mService.mWatermark != null) {
-            mService.mWatermark.positionSurface(defaultDw, defaultDh);
+        if (mWmService.mWatermark != null) {
+            mWmService.mWatermark.positionSurface(defaultDw, defaultDh);
         }
-        if (mService.mStrictModeFlash != null) {
-            mService.mStrictModeFlash.positionSurface(defaultDw, defaultDh);
+        if (mWmService.mStrictModeFlash != null) {
+            mWmService.mStrictModeFlash.positionSurface(defaultDw, defaultDh);
         }
-        if (mService.mCircularDisplayMask != null) {
-            mService.mCircularDisplayMask.positionSurface(defaultDw, defaultDh,
-                    mService.getDefaultDisplayRotation());
+        if (mWmService.mCircularDisplayMask != null) {
+            mWmService.mCircularDisplayMask.positionSurface(defaultDw, defaultDh,
+                    mWmService.getDefaultDisplayRotation());
         }
-        if (mService.mEmulatorDisplayOverlay != null) {
-            mService.mEmulatorDisplayOverlay.positionSurface(defaultDw, defaultDh,
-                    mService.getDefaultDisplayRotation());
+        if (mWmService.mEmulatorDisplayOverlay != null) {
+            mWmService.mEmulatorDisplayOverlay.positionSurface(defaultDw, defaultDh,
+                    mWmService.getDefaultDisplayRotation());
         }
 
         final int count = mChildren.size();
@@ -809,7 +810,7 @@
 
         // Give the display manager a chance to adjust properties like display rotation if it needs
         // to.
-        mService.mDisplayManagerInternal.performTraversal(mDisplayTransaction);
+        mWmService.mDisplayManagerInternal.performTraversal(mDisplayTransaction);
         SurfaceControl.mergeToGlobalTransaction(mDisplayTransaction);
     }
 
@@ -817,14 +818,14 @@
      * Handles resizing windows during surface placement.
      */
     private void handleResizingWindows() {
-        for (int i = mService.mResizingWindows.size() - 1; i >= 0; i--) {
-            WindowState win = mService.mResizingWindows.get(i);
+        for (int i = mWmService.mResizingWindows.size() - 1; i >= 0; i--) {
+            WindowState win = mWmService.mResizingWindows.get(i);
             if (win.mAppFreezing) {
                 // Don't remove this window until rotation has completed.
                 continue;
             }
             win.reportResized();
-            mService.mResizingWindows.remove(i);
+            mWmService.mResizingWindows.remove(i);
         }
     }
 
@@ -862,7 +863,7 @@
             if ((attrFlags & FLAG_KEEP_SCREEN_ON) != 0) {
                 mHoldScreen = w.mSession;
                 mHoldScreenWindow = w;
-            } else if (DEBUG_KEEP_SCREEN_ON && w == mService.mLastWakeLockHoldingWindow) {
+            } else if (DEBUG_KEEP_SCREEN_ON && w == mWmService.mLastWakeLockHoldingWindow) {
                 Slog.d(TAG_KEEP_SCREEN_ON, "handleNotObscuredLocked: " + w + " was holding "
                         + "screen wakelock but no longer has FLAG_KEEP_SCREEN_ON!!! called by"
                         + Debug.getCallers(10));
@@ -911,7 +912,7 @@
     boolean copyAnimToLayoutParams() {
         boolean doRequest = false;
 
-        final int bulkUpdateParams = mService.mAnimator.mBulkUpdateParams;
+        final int bulkUpdateParams = mWmService.mAnimator.mBulkUpdateParams;
         if ((bulkUpdateParams & SET_UPDATE_ROTATION) != 0) {
             mUpdateRotation = true;
             doRequest = true;
@@ -920,8 +921,8 @@
             mOrientationChangeComplete = false;
         } else {
             mOrientationChangeComplete = true;
-            mLastWindowFreezeSource = mService.mAnimator.mLastWindowFreezeSource;
-            if (mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) {
+            mLastWindowFreezeSource = mWmService.mAnimator.mLastWindowFreezeSource;
+            if (mWmService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) {
                 doRequest = true;
             }
         }
@@ -947,12 +948,12 @@
         public void handleMessage(Message msg) {
             switch (msg.what) {
                 case SET_SCREEN_BRIGHTNESS_OVERRIDE:
-                    mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(
+                    mWmService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(
                             msg.arg1);
                     break;
                 case SET_USER_ACTIVITY_TIMEOUT:
-                    mService.mPowerManagerInternal.setUserActivityTimeoutOverrideFromWindowManager(
-                            (Long) msg.obj);
+                    mWmService.mPowerManagerInternal.
+                            setUserActivityTimeoutOverrideFromWindowManager((Long) msg.obj);
                     break;
                 default:
                     break;
@@ -962,7 +963,7 @@
 
     void dumpDisplayContents(PrintWriter pw) {
         pw.println("WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays)");
-        if (mService.mDisplayReady) {
+        if (mWmService.mDisplayReady) {
             final int count = mChildren.size();
             for (int i = 0; i < count; ++i) {
                 final DisplayContent displayContent = mChildren.get(i);
@@ -1015,7 +1016,7 @@
     public void writeToProto(ProtoOutputStream proto, long fieldId, boolean trim) {
         final long token = proto.start(fieldId);
         super.writeToProto(proto, WINDOW_CONTAINER, trim);
-        if (mService.mDisplayReady) {
+        if (mWmService.mDisplayReady) {
             final int count = mChildren.size();
             for (int i = 0; i < count; ++i) {
                 final DisplayContent displayContent = mChildren.get(i);
@@ -1050,7 +1051,7 @@
 
     @Override
     void scheduleAnimation() {
-        mService.scheduleAnimationLocked();
+        mWmService.scheduleAnimationLocked();
     }
 
     /**
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 6904ef5..d3db5df 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -332,7 +332,7 @@
 
     boolean isResizeable() {
         return ActivityInfo.isResizeableMode(mResizeMode) || mSupportsPictureInPicture
-                || mService.mForceResizableTasks;
+                || mWmService.mForceResizableTasks;
     }
 
     /**
@@ -581,7 +581,7 @@
     }
 
     boolean isTaskAnimating() {
-        final RecentsAnimationController recentsAnim = mService.getRecentsAnimationController();
+        final RecentsAnimationController recentsAnim = mWmService.getRecentsAnimationController();
         if (recentsAnim != null) {
             if (recentsAnim.isAnimatingTask(this)) {
                 return true;
@@ -628,13 +628,13 @@
     }
 
     void forceWindowsScaleable(boolean force) {
-        mService.openSurfaceTransaction();
+        mWmService.openSurfaceTransaction();
         try {
             for (int i = mChildren.size() - 1; i >= 0; i--) {
                 mChildren.get(i).forceWindowsScaleableInTransaction(force);
             }
         } finally {
-            mService.closeSurfaceTransaction("forceWindowsScaleable");
+            mWmService.closeSurfaceTransaction("forceWindowsScaleable");
         }
     }
 
diff --git a/services/core/java/com/android/server/wm/TaskChangeNotificationController.java b/services/core/java/com/android/server/wm/TaskChangeNotificationController.java
index 3b3feac..bb3df02 100644
--- a/services/core/java/com/android/server/wm/TaskChangeNotificationController.java
+++ b/services/core/java/com/android/server/wm/TaskChangeNotificationController.java
@@ -283,8 +283,8 @@
     void notifyActivityPinned(ActivityRecord r) {
         mHandler.removeMessages(NOTIFY_ACTIVITY_PINNED_LISTENERS_MSG);
         final Message msg = mHandler.obtainMessage(NOTIFY_ACTIVITY_PINNED_LISTENERS_MSG,
-                r.getTask().taskId, r.getStackId(), r.packageName);
-        msg.sendingUid = r.userId;
+                r.getTaskRecord().taskId, r.getStackId(), r.packageName);
+        msg.sendingUid = r.mUserId;
         forAllLocalListeners(mNotifyActivityPinned, msg);
         msg.sendToTarget();
     }
diff --git a/services/core/java/com/android/server/wm/TaskRecord.java b/services/core/java/com/android/server/wm/TaskRecord.java
index 8a3dbad..30751bc 100644
--- a/services/core/java/com/android/server/wm/TaskRecord.java
+++ b/services/core/java/com/android/server/wm/TaskRecord.java
@@ -903,7 +903,7 @@
         // Correct the activity intent for aliasing. The task record intent will always be based on
         // the real activity that will be launched not the alias, so we need to use an intent with
         // the component name pointing to the real activity not the alias in the activity record.
-        intent.setComponent(r.realActivity);
+        intent.setComponent(r.mActivityComponent);
         return intent.filterEquals(this.intent);
     }
 
@@ -1211,7 +1211,7 @@
      * be in the current task or unparented to any task.
      */
     void addActivityAtIndex(int index, ActivityRecord r) {
-        TaskRecord task = r.getTask();
+        TaskRecord task = r.getTaskRecord();
         if (task != null && task != this) {
             throw new IllegalArgumentException("Can not add r=" + " to task=" + this
                     + " current parent=" + task);
@@ -1285,7 +1285,7 @@
     }
 
     boolean removeActivity(ActivityRecord r, boolean reparenting) {
-        if (r.getTask() != this) {
+        if (r.getTaskRecord() != this) {
             throw new IllegalArgumentException(
                     "Activity=" + r + " does not belong to task=" + this);
         }
@@ -1401,7 +1401,7 @@
             if (r.finishing) {
                 continue;
             }
-            if (r.realActivity.equals(newR.realActivity)) {
+            if (r.mActivityComponent.equals(newR.mActivityComponent)) {
                 // Here it is!  Now finish everything in front...
                 final ActivityRecord ret = r;
 
@@ -1559,13 +1559,13 @@
      * the index within the history at which it's found, or < 0 if not found.
      */
     final ActivityRecord findActivityInHistoryLocked(ActivityRecord r) {
-        final ComponentName realActivity = r.realActivity;
+        final ComponentName realActivity = r.mActivityComponent;
         for (int activityNdx = mActivities.size() - 1; activityNdx >= 0; --activityNdx) {
             ActivityRecord candidate = mActivities.get(activityNdx);
             if (candidate.finishing) {
                 continue;
             }
-            if (candidate.realActivity.equals(realActivity)) {
+            if (candidate.mActivityComponent.equals(realActivity)) {
                 return candidate;
             }
         }
@@ -1990,7 +1990,7 @@
                 ? reuseActivitiesReport.base.intent.getComponent()
                 : null;
         info.topActivity = reuseActivitiesReport.top != null
-                ? reuseActivitiesReport.top.realActivity
+                ? reuseActivitiesReport.top.mActivityComponent
                 : null;
         info.origActivity = origActivity;
         info.realActivity = realActivity;
@@ -2041,7 +2041,7 @@
             pw.println(origActivity.flattenToShortString());
         }
         if (realActivity != null) {
-            pw.print(prefix); pw.print("realActivity=");
+            pw.print(prefix); pw.print("mActivityComponent=");
             pw.println(realActivity.flattenToShortString());
         }
         if (autoRemoveRecents || isPersistable || !isActivityTypeStandard() || numFullscreen != 0) {
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index 5deb4f1..b1f95f8 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -450,7 +450,7 @@
             final int newDockSide = getDockSide(parentConfig, inOutBounds);
             // Update the dock create mode and clear the dock create bounds, these
             // might change after a rotation and the original values will be invalid.
-            mService.setDockedStackCreateStateLocked(
+            mWmService.setDockedStackCreateStateLocked(
                     (newDockSide == DOCKED_LEFT || newDockSide == DOCKED_TOP)
                             ? SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT
                             : SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT,
@@ -523,7 +523,7 @@
         mDisplayContent.getDisplayPolicy().getStableInsetsLw(rotation, displayWidth, displayHeight,
                 displayCutout, outBounds);
         final DividerSnapAlgorithm algorithm = new DividerSnapAlgorithm(
-                mService.mContext.getResources(), displayWidth, displayHeight,
+                mWmService.mContext.getResources(), displayWidth, displayHeight,
                 dividerSize, orientation == Configuration.ORIENTATION_PORTRAIT, outBounds,
                 getDockSide(), isMinimizedDockAndHomeStackResizable());
         final SnapTarget target = algorithm.calculateNonDismissingSnapTarget(dividerPosition);
@@ -594,7 +594,7 @@
     private int findPositionForTask(Task task, int targetPosition, boolean showForAllUsers,
             boolean addingNew) {
         final boolean canShowTask =
-                showForAllUsers || mService.isCurrentProfileLocked(task.mUserId);
+                showForAllUsers || mWmService.isCurrentProfileLocked(task.mUserId);
 
         final int stackSize = mChildren.size();
         int minPosition = 0;
@@ -628,7 +628,7 @@
             final Task tmpTask = mChildren.get(minPosition);
             final boolean canShowTmpTask =
                     tmpTask.showForAllUsers()
-                            || mService.isCurrentProfileLocked(tmpTask.mUserId);
+                            || mWmService.isCurrentProfileLocked(tmpTask.mUserId);
             if (canShowTmpTask) {
                 break;
             }
@@ -647,7 +647,7 @@
             final Task tmpTask = mChildren.get(maxPosition);
             final boolean canShowTmpTask =
                     tmpTask.showForAllUsers()
-                            || mService.isCurrentProfileLocked(tmpTask.mUserId);
+                            || mWmService.isCurrentProfileLocked(tmpTask.mUserId);
             if (!canShowTmpTask) {
                 break;
             }
@@ -728,7 +728,7 @@
 
             // We multiply by two to match the client logic for converting view elevation
             // to insets, as in {@link WindowManager.LayoutParams#setSurfaceInsets}
-            return (int)Math.ceil(mService.dipToPixel(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP,
+            return (int)Math.ceil(mWmService.dipToPixel(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP,
                     displayMetrics) * 2);
         }
         return 0;
@@ -791,7 +791,7 @@
 
         if (dockedBounds == null || dockedBounds.isEmpty()) {
             // Calculate the primary docked bounds.
-            final boolean dockedOnTopOrLeft = mService.mDockedStackCreateMode
+            final boolean dockedOnTopOrLeft = mWmService.mDockedStackCreateMode
                     == SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
             getStackDockedModeBounds(parentConfig,
                     true /* primary */, outStackBounds, dockedBounds,
@@ -856,8 +856,8 @@
 
         outBounds.set(displayRect);
         if (primary) {
-            if (mService.mDockedStackCreateBounds != null) {
-                outBounds.set(mService.mDockedStackCreateBounds);
+            if (mWmService.mDockedStackCreateBounds != null) {
+                outBounds.set(mWmService.mDockedStackCreateBounds);
                 return;
             }
 
@@ -868,7 +868,7 @@
             mDisplayContent.getDisplayPolicy().getStableInsetsLw(
                     parentConfig.windowConfiguration.getRotation(),
                     displayRect.width(), displayRect.height(), displayCutout, mTmpRect2);
-            final int position = new DividerSnapAlgorithm(mService.mContext.getResources(),
+            final int position = new DividerSnapAlgorithm(mWmService.mContext.getResources(),
                     displayRect.width(),
                     displayRect.height(),
                     dockDividerWidth,
@@ -913,7 +913,7 @@
             throw new IllegalStateException("Not a docked stack=" + this);
         }
 
-        mService.mDockedStackCreateBounds = null;
+        mWmService.mDockedStackCreateBounds = null;
 
         final Rect bounds = new Rect();
         final Rect tempBounds = new Rect();
@@ -955,7 +955,7 @@
         }
 
         mDisplayContent = null;
-        mService.mWindowPlacerLocked.requestTraversal();
+        mWmService.mWindowPlacerLocked.requestTraversal();
     }
 
     void resetAnimationBackgroundAnimator() {
@@ -977,7 +977,7 @@
         int top = mChildren.size();
         for (int taskNdx = 0; taskNdx < top; ++taskNdx) {
             Task task = mChildren.get(taskNdx);
-            if (mService.isCurrentProfileLocked(task.mUserId) || task.showForAllUsers()) {
+            if (mWmService.isCurrentProfileLocked(task.mUserId) || task.showForAllUsers()) {
                 mChildren.remove(taskNdx);
                 mChildren.add(task);
                 --top;
@@ -1046,7 +1046,7 @@
             }
             mAdjustedForIme = false;
             updateAdjustedBounds();
-            mService.setResizeDimLayer(false, getWindowingMode(), 1.0f);
+            mWmService.setResizeDimLayer(false, getWindowingMode(), 1.0f);
         } else {
             mImeGoingAway |= mAdjustedForIme;
         }
@@ -1179,7 +1179,7 @@
         }
 
         if (dockSide == DOCKED_TOP) {
-            mService.getStableInsetsLocked(DEFAULT_DISPLAY, mTmpRect);
+            mWmService.getStableInsetsLocked(DEFAULT_DISPLAY, mTmpRect);
             int topInset = mTmpRect.top;
             mTmpAdjustedBounds.set(getRawBounds());
             mTmpAdjustedBounds.bottom = (int) (minimizeAmount * topInset + (1 - minimizeAmount)
@@ -1215,7 +1215,7 @@
         }
 
         if (dockSide == DOCKED_TOP) {
-            mService.getStableInsetsLocked(DEFAULT_DISPLAY, mTmpRect);
+            mWmService.getStableInsetsLocked(DEFAULT_DISPLAY, mTmpRect);
             int topInset = mTmpRect.top;
             return getRawBounds().bottom - topInset;
         } else if (dockSide == DOCKED_LEFT || dockSide == DOCKED_RIGHT) {
@@ -1240,11 +1240,11 @@
         }
         setAdjustedBounds(mTmpAdjustedBounds);
 
-        final boolean isImeTarget = (mService.getImeFocusStackLocked() == this);
+        final boolean isImeTarget = (mWmService.getImeFocusStackLocked() == this);
         if (mAdjustedForIme && adjust && !isImeTarget) {
             final float alpha = Math.max(mAdjustImeAmount, mAdjustDividerAmount)
                     * IME_ADJUST_DIM_AMOUNT;
-            mService.setResizeDimLayer(true, getWindowingMode(), alpha);
+            mWmService.setResizeDimLayer(true, getWindowingMode(), alpha);
         }
     }
 
@@ -1510,14 +1510,14 @@
 
     public boolean setPinnedStackSize(Rect stackBounds, Rect tempTaskBounds) {
         // Hold the lock since this is called from the BoundsAnimator running on the UiThread
-        synchronized (mService.mGlobalLock) {
+        synchronized (mWmService.mGlobalLock) {
             if (mCancelCurrentBoundsAnimation) {
                 return false;
             }
         }
 
         try {
-            mService.mActivityTaskManager.resizePinnedStack(stackBounds, tempTaskBounds);
+            mWmService.mActivityTaskManager.resizePinnedStack(stackBounds, tempTaskBounds);
         } catch (RemoteException e) {
             // I don't believe you.
         }
@@ -1535,7 +1535,7 @@
     @Override  // AnimatesBounds
     public boolean onAnimationStart(boolean schedulePipModeChangedCallback, boolean forceUpdate) {
         // Hold the lock since this is called from the BoundsAnimator running on the UiThread
-        synchronized (mService.mGlobalLock) {
+        synchronized (mWmService.mGlobalLock) {
             if (!isAttached()) {
                 // Don't run the animation if the stack is already detached
                 return false;
@@ -1555,7 +1555,7 @@
 
         if (inPinnedWindowingMode()) {
             try {
-                mService.mActivityTaskManager.notifyPinnedStackAnimationStarted();
+                mWmService.mActivityTaskManager.notifyPinnedStackAnimationStarted();
             } catch (RemoteException e) {
                 // I don't believe you...
             }
@@ -1598,9 +1598,9 @@
             }
 
             try {
-                mService.mActivityTaskManager.notifyPinnedStackAnimationEnded();
+                mWmService.mActivityTaskManager.notifyPinnedStackAnimationEnded();
                 if (moveToFullscreen) {
-                    mService.mActivityTaskManager.moveTasksToFullscreenStack(mStackId,
+                    mWmService.mActivityTaskManager.moveTasksToFullscreenStack(mStackId,
                             true /* onTop */);
                 }
             } catch (RemoteException e) {
@@ -1614,7 +1614,7 @@
 
     @Override
     public boolean isAttached() {
-        synchronized (mService.mGlobalLock) {
+        synchronized (mWmService.mGlobalLock) {
             return mDisplayContent != null;
         }
     }
@@ -1623,19 +1623,19 @@
      * Called immediately prior to resizing the tasks at the end of the pinned stack animation.
      */
     public void onPipAnimationEndResize() {
-        synchronized (mService.mGlobalLock) {
+        synchronized (mWmService.mGlobalLock) {
             mBoundsAnimating = false;
             for (int i = 0; i < mChildren.size(); i++) {
                 final Task t = mChildren.get(i);
                 t.clearPreserveNonFloatingState();
             }
-            mService.requestTraversal();
+            mWmService.requestTraversal();
         }
     }
 
     @Override
     public boolean shouldDeferStartOnMoveToFullscreen() {
-        synchronized (mService.mGlobalLock) {
+        synchronized (mWmService.mGlobalLock) {
             if (!isAttached()) {
                 // Unnecessary to pause the animation because the stack is detached.
                 return false;
diff --git a/services/core/java/com/android/server/wm/VrController.java b/services/core/java/com/android/server/wm/VrController.java
index abe40a7..3e136d35 100644
--- a/services/core/java/com/android/server/wm/VrController.java
+++ b/services/core/java/com/android/server/wm/VrController.java
@@ -187,7 +187,7 @@
         synchronized (mGlobalAmLock) {
             vrMode = record.requestedVrComponent != null;
             requestedPackage = record.requestedVrComponent;
-            userId = record.userId;
+            userId = record.mUserId;
             callingPackage = record.info.getComponentName();
 
             // Tell the VrController that a VR mode change is requested.
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index 7e4c629..1275ca0 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -115,7 +115,7 @@
      */
     protected final Transaction mPendingTransaction;
     protected final SurfaceAnimator mSurfaceAnimator;
-    protected final WindowManagerService mService;
+    protected final WindowManagerService mWmService;
 
     private final Point mTmpPos = new Point();
     protected final Point mLastSurfacePosition = new Point();
@@ -129,10 +129,10 @@
      */
     private boolean mCommittedReparentToAnimationLeash;
 
-    WindowContainer(WindowManagerService service) {
-        mService = service;
-        mPendingTransaction = service.mTransactionFactory.make();
-        mSurfaceAnimator = new SurfaceAnimator(this, this::onAnimationFinished, service);
+    WindowContainer(WindowManagerService wms) {
+        mWmService = wms;
+        mPendingTransaction = wms.mTransactionFactory.make();
+        mSurfaceAnimator = new SurfaceAnimator(this, this::onAnimationFinished, wms);
     }
 
     @Override
diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java
index 578af2e..2dec4dd 100644
--- a/services/core/java/com/android/server/wm/WindowProcessController.java
+++ b/services/core/java/com/android/server/wm/WindowProcessController.java
@@ -443,7 +443,7 @@
             for (int i = 0; i < activities.size(); i++) {
                 final ActivityRecord r = activities.get(i);
                 if (!r.finishing && r.isInStackLocked()) {
-                    r.getStack().finishActivityLocked(r, Activity.RESULT_CANCELED,
+                    r.getActivityStack().finishActivityLocked(r, Activity.RESULT_CANCELED,
                             null, "finish-heavy", true);
                 }
             }
@@ -513,7 +513,7 @@
             }
             ActivityRecord hist = mActivities.get(0);
             intent.putExtra(HeavyWeightSwitcherActivity.KEY_CUR_APP, hist.packageName);
-            intent.putExtra(HeavyWeightSwitcherActivity.KEY_CUR_TASK, hist.getTask().taskId);
+            intent.putExtra(HeavyWeightSwitcherActivity.KEY_CUR_TASK, hist.getTaskRecord().taskId);
         }
     }
 
@@ -524,7 +524,7 @@
                 // Don't kill process(es) that has an activity not stopped.
                 return false;
             }
-            final TaskRecord otherTask = activity.getTask();
+            final TaskRecord otherTask = activity.getTaskRecord();
             if (tr.taskId != otherTask.taskId && otherTask.inRecents) {
                 // Don't kill process(es) that has an activity in a different task that is
                 // also in recents.
@@ -557,7 +557,7 @@
                 continue;
             }
 
-            final TaskRecord task = r.getTask();
+            final TaskRecord task = r.getTaskRecord();
             if (task != null) {
                 if (DEBUG_RELEASE) Slog.d(TAG_RELEASE, "Collecting release task " + task
                         + " from " + r);
@@ -600,7 +600,7 @@
                 }
                 if (r.visible) {
                     callback.onVisibleActivity();
-                    final TaskRecord task = r.getTask();
+                    final TaskRecord task = r.getTaskRecord();
                     if (task != null && minTaskLayer > 0) {
                         final int layer = task.mLayerRank;
                         if (layer >= 0 && minTaskLayer > layer) {
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index cfd1f86..cdf9118 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -195,7 +195,6 @@
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.util.ToBooleanFunction;
 import com.android.server.policy.WindowManagerPolicy;
-import com.android.server.policy.WindowManagerPolicy.DisplayContentInfo;
 import com.android.server.wm.LocalAnimationAdapter.AnimationSpec;
 import com.android.server.wm.utils.InsetUtils;
 import com.android.server.wm.utils.WmDisplayCutout;
@@ -598,7 +597,7 @@
         if (mForceSeamlesslyRotate || requested) {
             mPendingSeamlessRotate = new SeamlessRotator(oldRotation, rotation, getDisplayInfo());
             mPendingSeamlessRotate.unrotate(transaction, this);
-            mService.markForSeamlessRotation(this, true);
+            mWmService.markForSeamlessRotation(this, true);
         }
     }
 
@@ -607,7 +606,7 @@
             mPendingSeamlessRotate.finish(this, timeout);
             mFinishSeamlessRotateFrameNumber = getFrameNumber();
             mPendingSeamlessRotate = null;
-            mService.markForSeamlessRotation(this, false);
+            mWmService.markForSeamlessRotation(this, false);
         }
     }
 
@@ -651,8 +650,8 @@
         mAttrs.copyFrom(a);
         mLastSurfaceInsets.set(mAttrs.surfaceInsets);
         mViewVisibility = viewVisibility;
-        mPolicy = mService.mPolicy;
-        mContext = mService.mContext;
+        mPolicy = mWmService.mPolicy;
+        mContext = mWmService.mContext;
         DeathRecipient deathRecipient = new DeathRecipient();
         mSeq = seq;
         mEnforceSizeCompat = (mAttrs.privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0;
@@ -846,7 +845,7 @@
                 mWindowFrames.mContainingFrame.bottom =
                         mWindowFrames.mContainingFrame.top + frozen.height();
             }
-            final WindowState imeWin = mService.mRoot.getCurrentInputMethodWindow();
+            final WindowState imeWin = mWmService.mRoot.getCurrentInputMethodWindow();
             // IME is up and obscuring this window. Adjust the window position so it is visible.
             if (imeWin != null && imeWin.isVisibleNow() && isInputMethodTarget()) {
                 if (inFreeformWindowingMode() && mWindowFrames.mContainingFrame.bottom
@@ -1204,7 +1203,7 @@
             }
 
             updateLastInsetValues();
-            mService.makeWindowFreezingScreenIfNeededLocked(this);
+            mWmService.makeWindowFreezingScreenIfNeededLocked(this);
 
             // If the orientation is changing, or we're starting or ending a drag resizing action,
             // then we need to hold off on unfreezing the display until this window has been
@@ -1221,9 +1220,9 @@
                     mAppToken.clearAllDrawn();
                 }
             }
-            if (!mService.mResizingWindows.contains(this)) {
+            if (!mWmService.mResizingWindows.contains(this)) {
                 if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG_WM, "Resizing window " + this);
-                mService.mResizingWindows.add(this);
+                mWmService.mResizingWindows.add(this);
             }
         } else if (getOrientationChanging()) {
             if (isDrawnLw()) {
@@ -1231,7 +1230,7 @@
                         + this + ", surfaceController " + winAnimator.mSurfaceController);
                 setOrientationChanging(false);
                 mLastFreezeDuration = (int)(SystemClock.elapsedRealtime()
-                        - mService.mDisplayFreezeTime);
+                        - mWmService.mDisplayFreezeTime);
             }
         }
     }
@@ -1604,7 +1603,7 @@
             // 3. WS is currently visible
             if (!runningAppAnimation && isVisibleNow) {
                 final AccessibilityController accessibilityController =
-                        mService.mAccessibilityController;
+                        mWmService.mAccessibilityController;
                 final int winTransit = TRANSIT_EXIT;
                 mWinAnimator.applyAnimationLocked(winTransit, false /* isEntrance */);
                 //TODO (multidisplay): Magnification is supported only for the default
@@ -1626,8 +1625,8 @@
         if (isVisibleNow()) {
             mWinAnimator.applyAnimationLocked(TRANSIT_EXIT, false);
             //TODO (multidisplay): Magnification is supported only for the default
-            if (mService.mAccessibilityController != null && isDefaultDisplay()) {
-                mService.mAccessibilityController.onWindowTransitionLocked(this, TRANSIT_EXIT);
+            if (mWmService.mAccessibilityController != null && isDefaultDisplay()) {
+                mWmService.mAccessibilityController.onWindowTransitionLocked(this, TRANSIT_EXIT);
             }
             changed = true;
             if (displayContent != null) {
@@ -1645,7 +1644,7 @@
 
     @Override
     void onResize() {
-        final ArrayList<WindowState> resizingWindows = mService.mResizingWindows;
+        final ArrayList<WindowState> resizingWindows = mWmService.mResizingWindows;
         if (mHasSurface && !isGoneForLayoutLw() && !resizingWindows.contains(this)) {
             if (DEBUG_RESIZE) Slog.d(TAG, "onResize: Resizing " + this);
             resizingWindows.add(this);
@@ -1669,8 +1668,8 @@
 
         mLayoutNeeded = true;
         setDisplayLayoutNeeded();
-        if (!mService.mResizingWindows.contains(this)) {
-            mService.mResizingWindows.add(this);
+        if (!mWmService.mResizingWindows.contains(this)) {
+            mWmService.mResizingWindows.add(this);
         }
     }
 
@@ -1702,9 +1701,9 @@
         }
 
         //TODO (multidisplay): Accessibility supported only for the default display.
-        if (mService.mAccessibilityController != null
+        if (mWmService.mAccessibilityController != null
                 && getDisplayContent().getDisplayId() == DEFAULT_DISPLAY) {
-            mService.mAccessibilityController.onSomeWindowResizedOrMovedLocked();
+            mWmService.mAccessibilityController.onSomeWindowResizedOrMovedLocked();
         }
 
         try {
@@ -1818,7 +1817,7 @@
             // we are doing this as part of processing a death note.)
         }
 
-        mService.postWindowRemoveCleanupLocked(this);
+        mWmService.postWindowRemoveCleanupLocked(this);
     }
 
     @Override
@@ -1859,7 +1858,7 @@
                     + " mWillReplaceWindow=" + mWillReplaceWindow
                     + " inPendingTransaction="
                     + (mAppToken != null ? mAppToken.inPendingTransaction : false)
-                    + " mDisplayFrozen=" + mService.mDisplayFrozen
+                    + " mDisplayFrozen=" + mWmService.mDisplayFrozen
                     + " callers=" + Debug.getCallers(6));
 
             // Visibility of the removed window. Will be used later to update orientation later on.
@@ -1894,7 +1893,7 @@
 
                     mAppDied = true;
                     setDisplayLayoutNeeded();
-                    mService.mWindowPlacerLocked.performSurfacePlacement();
+                    mWmService.mWindowPlacerLocked.performSurfacePlacement();
 
                     // Set up a replacement input channel since the app is now dead.
                     // We need to catch tapping on the dead window to restart the app.
@@ -1913,11 +1912,12 @@
                         // mAnimatingExit affects canAffectSystemUiFlags(). Run layout such that
                         // any change from that is performed immediately.
                         setDisplayLayoutNeeded();
-                        mService.requestTraversal();
+                        mWmService.requestTraversal();
                     }
                     //TODO (multidisplay): Magnification is supported only for the default display.
-                    if (mService.mAccessibilityController != null && displayId == DEFAULT_DISPLAY) {
-                        mService.mAccessibilityController.onWindowTransitionLocked(this, transit);
+                    if (mWmService.mAccessibilityController != null
+                            && displayId == DEFAULT_DISPLAY) {
+                        mWmService.mAccessibilityController.onWindowTransitionLocked(this, transit);
                     }
                 }
                 final boolean isAnimating = isAnimating()
@@ -1951,7 +1951,7 @@
                     displayContent.sendNewConfiguration();
                 }
             }
-            mService.updateFocusedWindowLocked(isFocused()
+            mWmService.updateFocusedWindowLocked(isFocused()
                             ? UPDATE_FOCUS_REMOVING_FOCUS
                             : UPDATE_FOCUS_NORMAL,
                     true /*updateInputWindows*/);
@@ -1965,9 +1965,9 @@
         setDisplayLayoutNeeded();
         // Request a focus update as this window's input channel is already gone. Otherwise
         // we could have no focused window in input manager.
-        final boolean focusChanged = mService.updateFocusedWindowLocked(
+        final boolean focusChanged = mWmService.updateFocusedWindowLocked(
                 UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/);
-        mService.mWindowPlacerLocked.performSurfacePlacement();
+        mWmService.mWindowPlacerLocked.performSurfacePlacement();
         if (focusChanged) {
             getDisplayContent().getInputMonitor().updateInputWindowsLw(false /*force*/);
         }
@@ -2020,7 +2020,7 @@
 
     private final class DeadWindowEventReceiver extends InputEventReceiver {
         DeadWindowEventReceiver(InputChannel inputChannel) {
-            super(inputChannel, mService.mH.getLooper());
+            super(inputChannel, mWmService.mH.getLooper());
         }
         @Override
         public void onInputEvent(InputEvent event) {
@@ -2051,7 +2051,7 @@
             // Create dummy event receiver that simply reports all events as handled.
             mDeadWindowEventReceiver = new DeadWindowEventReceiver(mClientChannel);
         }
-        mService.mInputManager.registerInputChannel(mInputChannel, mClient.asBinder());
+        mWmService.mInputManager.registerInputChannel(mInputChannel, mClient.asBinder());
     }
 
     void disposeInputChannel() {
@@ -2062,7 +2062,7 @@
 
         // unregister server channel first otherwise it complains about broken channel
         if (mInputChannel != null) {
-            mService.mInputManager.unregisterInputChannel(mInputChannel);
+            mWmService.mInputManager.unregisterInputChannel(mInputChannel);
 
             mInputChannel.dispose();
             mInputChannel = null;
@@ -2194,13 +2194,13 @@
                 if (isFocused()) {
                     if (DEBUG_FOCUS_LIGHT) Slog.i(TAG,
                             "setAnimationLocked: setting mFocusMayChange true");
-                    mService.mFocusMayChange = true;
+                    mWmService.mFocusMayChange = true;
                 }
                 setDisplayLayoutNeeded();
                 // Window is no longer visible -- make sure if we were waiting
                 // for it to be displayed before enabling the display, that
                 // we allow the display to be enabled now.
-                mService.enableScreenIfNeededLocked();
+                mWmService.enableScreenIfNeededLocked();
             }
         }
     }
@@ -2217,8 +2217,8 @@
         // We need to turn on screen regardless of visibility.
         boolean hasTurnScreenOnFlag = (mAttrs.flags & FLAG_TURN_SCREEN_ON) != 0;
         boolean allowTheaterMode =
-                mService.mAllowTheaterModeWakeFromLayout || Settings.Global.getInt(
-                        mService.mContext.getContentResolver(), Settings.Global.THEATER_MODE_ON, 0)
+                mWmService.mAllowTheaterModeWakeFromLayout || Settings.Global.getInt(
+                        mWmService.mContext.getContentResolver(), Settings.Global.THEATER_MODE_ON, 0)
                         == 0;
         boolean canTurnScreenOn = mAppToken == null || mAppToken.canTurnScreenOn();
 
@@ -2268,8 +2268,8 @@
         // For child windows we want to use the pid for the parent window in case the the child
         // window was added from another process.
         final int pid = getParentWindow() != null ? getParentWindow().mSession.mPid : mSession.mPid;
-        mTempConfiguration.setTo(mService.mProcessConfigurations.get(
-                pid, mService.mRoot.getConfiguration()));
+        mTempConfiguration.setTo(mWmService.mProcessConfigurations.get(
+                pid, mWmService.mRoot.getConfiguration()));
         return mTempConfiguration;
     }
 
@@ -2325,13 +2325,14 @@
         public void binderDied() {
             try {
                 boolean resetSplitScreenResizing = false;
-                synchronized (mService.mGlobalLock) {
-                    final WindowState win = mService.windowForClientLocked(mSession, mClient, false);
+                synchronized (mWmService.mGlobalLock) {
+                    final WindowState win = mWmService
+                            .windowForClientLocked(mSession, mClient, false);
                     Slog.i(TAG, "WIN DEATH: " + win);
                     if (win != null) {
                         final DisplayContent dc = getDisplayContent();
                         if (win.mAppToken != null && win.mAppToken.findMainWindow() == win) {
-                            mService.mTaskSnapshotController.onAppDied(win.mAppToken);
+                            mWmService.mTaskSnapshotController.onAppDied(win.mAppToken);
                         }
                         win.removeIfPossible(shouldKeepVisibleDeadAppWindow());
                         if (win.mAttrs.type == TYPE_DOCK_DIVIDER) {
@@ -2355,7 +2356,7 @@
                     try {
                         // Note: this calls into ActivityManager, so we must *not* hold the window
                         // manager lock while calling this.
-                        mService.mActivityTaskManager.setSplitScreenResizing(false);
+                        mWmService.mActivityTaskManager.setSplitScreenResizing(false);
                     } catch (RemoteException e) {
                         // Local call, shouldn't return RemoteException.
                         throw e.rethrowAsRuntimeException();
@@ -2462,10 +2463,10 @@
             mWinAnimator.applyAnimationLocked(TRANSIT_ENTER, true);
         }
         if (requestAnim) {
-            mService.scheduleAnimationLocked();
+            mWmService.scheduleAnimationLocked();
         }
         if ((mAttrs.flags & FLAG_NOT_FOCUSABLE) == 0) {
-            mService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, false /* updateImWindows */);
+            mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, false /* updateImWindows */);
         }
         return true;
     }
@@ -2500,18 +2501,18 @@
             // Window is no longer visible -- make sure if we were waiting
             // for it to be displayed before enabling the display, that
             // we allow the display to be enabled now.
-            mService.enableScreenIfNeededLocked();
+            mWmService.enableScreenIfNeededLocked();
             if (isFocused) {
                 if (DEBUG_FOCUS_LIGHT) Slog.i(TAG,
                         "WindowState.hideLw: setting mFocusMayChange true");
-                mService.mFocusMayChange = true;
+                mWmService.mFocusMayChange = true;
             }
         }
         if (requestAnim) {
-            mService.scheduleAnimationLocked();
+            mWmService.scheduleAnimationLocked();
         }
         if (isFocused) {
-            mService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, false /* updateImWindows */);
+            mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, false /* updateImWindows */);
         }
         return true;
     }
@@ -2573,7 +2574,7 @@
         // and add the window only if the permission was granted. Therefore, if
         // the mode is MODE_DEFAULT we want the op to succeed as the window is
         // shown.
-        final int mode = mService.mAppOps.startOpNoThrow(mAppOp,
+        final int mode = mWmService.mAppOps.startOpNoThrow(mAppOp,
                 getOwningUid(), getOwningPackage(), true);
         if (mode != MODE_ALLOWED && mode != MODE_DEFAULT) {
             setAppOpVisibilityLw(false);
@@ -2582,7 +2583,7 @@
 
     void resetAppOpsState() {
         if (mAppOp != OP_NONE && mAppOpVisibility) {
-            mService.mAppOps.finishOp(mAppOp, getOwningUid(), getOwningPackage());
+            mWmService.mAppOps.finishOp(mAppOp, getOwningUid(), getOwningPackage());
         }
     }
 
@@ -2595,13 +2596,13 @@
         if (mAppOpVisibility) {
             // There is a race between the check and the finish calls but this is fine
             // as this would mean we will get another change callback and will reconcile.
-            int mode = mService.mAppOps.checkOpNoThrow(mAppOp, uid, packageName);
+            int mode = mWmService.mAppOps.checkOpNoThrow(mAppOp, uid, packageName);
             if (mode != MODE_ALLOWED && mode != MODE_DEFAULT) {
-                mService.mAppOps.finishOp(mAppOp, uid, packageName);
+                mWmService.mAppOps.finishOp(mAppOp, uid, packageName);
                 setAppOpVisibilityLw(false);
             }
         } else {
-            final int mode = mService.mAppOps.startOpNoThrow(mAppOp, uid, packageName, true);
+            final int mode = mWmService.mAppOps.startOpNoThrow(mAppOp, uid, packageName, true);
             if (mode == MODE_ALLOWED || mode == MODE_DEFAULT) {
                 setAppOpVisibilityLw(true);
             }
@@ -2622,7 +2623,7 @@
                 // in wake lock statistics.  So in particular, we don't want to include the
                 // window's hash code as in toString().
                 final CharSequence tag = getWindowTag();
-                mDrawLock = mService.mPowerManager.newWakeLock(DRAW_WAKE_LOCK, "Window:" + tag);
+                mDrawLock = mWmService.mPowerManager.newWakeLock(DRAW_WAKE_LOCK, "Window:" + tag);
                 mDrawLock.setReferenceCounted(false);
                 mDrawLock.setWorkSource(new WorkSource(mOwnerUid, mAttrs.packageName));
             }
@@ -2707,10 +2708,10 @@
         mAppFreezing = false;
 
         if (mHasSurface && !getOrientationChanging()
-                && mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_TIMEOUT) {
+                && mWmService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_TIMEOUT) {
             if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "set mOrientationChanging of " + this);
             setOrientationChanging(true);
-            mService.mRoot.mOrientationChangeComplete = false;
+            mWmService.mRoot.mOrientationChangeComplete = false;
         }
         mLastFreezeDuration = 0;
         setDisplayLayoutNeeded();
@@ -2800,7 +2801,7 @@
         }
 
         return win.mShowToOwnerOnly
-                && !mService.isCurrentProfileLocked(UserHandle.getUserId(win.mOwnerUid));
+                && !mWmService.isCurrentProfileLocked(UserHandle.getUserId(win.mOwnerUid));
     }
 
     private static void applyInsets(Region outRegion, Rect frame, Rect inset) {
@@ -2899,7 +2900,7 @@
             if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG, "Reporting new frame to " + this
                     + ": " + mWindowFrames.mCompatFrame);
             final MergedConfiguration mergedConfiguration =
-                    new MergedConfiguration(mService.mRoot.getConfiguration(),
+                    new MergedConfiguration(mWmService.mRoot.getConfiguration(),
                     getMergedOverrideConfiguration());
 
             setLastReportedMergedConfiguration(mergedConfiguration);
@@ -2920,7 +2921,7 @@
             if (mAttrs.type != WindowManager.LayoutParams.TYPE_APPLICATION_STARTING
                     && mClient instanceof IWindow.Stub) {
                 // To prevent deadlock simulate one-way call if win.mClient is a local object.
-                mService.mH.post(new Runnable() {
+                mWmService.mH.post(new Runnable() {
                     @Override
                     public void run() {
                         try {
@@ -2939,8 +2940,8 @@
             }
 
             //TODO (multidisplay): Accessibility supported only for the default display.
-            if (mService.mAccessibilityController != null && getDisplayId() == DEFAULT_DISPLAY) {
-                mService.mAccessibilityController.onSomeWindowResizedOrMovedLocked();
+            if (mWmService.mAccessibilityController != null && getDisplayId() == DEFAULT_DISPLAY) {
+                mWmService.mAccessibilityController.onSomeWindowResizedOrMovedLocked();
             }
 
             mWindowFrames.resetInsetsChanged();
@@ -2949,12 +2950,12 @@
         } catch (RemoteException e) {
             setOrientationChanging(false);
             mLastFreezeDuration = (int)(SystemClock.elapsedRealtime()
-                    - mService.mDisplayFreezeTime);
+                    - mWmService.mDisplayFreezeTime);
             // We are assuming the hosting process is dead or in a zombie state.
             Slog.w(TAG, "Failed to report 'resized' to the client of " + this
                     + ", removing this window.");
-            mService.mPendingRemove.add(this);
-            mService.mWindowPlacerLocked.requestTraversal();
+            mWmService.mPendingRemove.add(this);
+            mWmService.mWindowPlacerLocked.requestTraversal();
         }
         Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
     }
@@ -3015,7 +3016,7 @@
     }
 
     public void registerFocusObserver(IWindowFocusObserver observer) {
-        synchronized (mService.mGlobalLock) {
+        synchronized (mWmService.mGlobalLock) {
             if (mFocusCallbacks == null) {
                 mFocusCallbacks = new RemoteCallbackList<IWindowFocusObserver>();
             }
@@ -3024,7 +3025,7 @@
     }
 
     public void unregisterFocusObserver(IWindowFocusObserver observer) {
-        synchronized (mService.mGlobalLock) {
+        synchronized (mWmService.mGlobalLock) {
             if (mFocusCallbacks != null) {
                 mFocusCallbacks.unregister(observer);
             }
@@ -3097,7 +3098,7 @@
     @Override
     void setWaitingForDrawnIfResizingChanged() {
         if (isDragResizeChanged()) {
-            mService.mWaitingForDrawn.add(this);
+            mWmService.mWaitingForDrawn.add(this);
         }
         super.setWaitingForDrawnIfResizingChanged();
     }
@@ -3586,7 +3587,7 @@
         if (dc != null && (mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
             dc.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
             dc.setLayoutNeeded();
-            mService.mWindowPlacerLocked.requestTraversal();
+            mWmService.mWindowPlacerLocked.requestTraversal();
         }
 
         for (int i = mChildren.size() - 1; i >= 0; i--) {
@@ -3684,7 +3685,7 @@
 
         logPerformShow("Showing ");
 
-        mService.enableScreenIfNeededLocked();
+        mWmService.enableScreenIfNeededLocked();
         mWinAnimator.applyEnterAnimationLocked();
 
         // Force the show in the next prepareSurfaceLocked() call.
@@ -3692,7 +3693,7 @@
         if (DEBUG_ANIM) Slog.v(TAG,
                 "performShowLocked: mDrawState=HAS_DRAWN in " + this);
         mWinAnimator.mDrawState = HAS_DRAWN;
-        mService.scheduleAnimationLocked();
+        mWmService.scheduleAnimationLocked();
 
         if (mHidden) {
             mHidden = false;
@@ -3971,7 +3972,7 @@
 
         if (mWinAnimator.mEnteringAnimation) {
             mWinAnimator.mEnteringAnimation = false;
-            mService.requestTraversal();
+            mWmService.requestTraversal();
             // System windows don't have an activity and an app token as a result, but need a way
             // to be informed about their entrance animation end.
             if (mAppToken == null) {
@@ -3987,8 +3988,8 @@
         }
 
         //TODO (multidisplay): Accessibility is supported only for the default display.
-        if (mService.mAccessibilityController != null && getDisplayId() == DEFAULT_DISPLAY) {
-            mService.mAccessibilityController.onSomeWindowResizedOrMovedLocked();
+        if (mWmService.mAccessibilityController != null && getDisplayId() == DEFAULT_DISPLAY) {
+            mWmService.mAccessibilityController.onSomeWindowResizedOrMovedLocked();
         }
 
         if (!isSelfOrAncestorWindowAnimatingExit()) {
@@ -4014,10 +4015,10 @@
             mAppToken.destroySurfaces();
         } else {
             if (hasSurface) {
-                mService.mDestroySurface.add(this);
+                mWmService.mDestroySurface.add(this);
             }
             if (mRemoveOnExit) {
-                mService.mPendingRemove.add(this);
+                mWmService.mPendingRemove.add(this);
                 mRemoveOnExit = false;
             }
         }
@@ -4048,7 +4049,7 @@
             }
             if (mDestroying) {
                 mDestroying = false;
-                mService.mDestroySurface.remove(this);
+                mWmService.mDestroySurface.remove(this);
                 didSomething = true;
             }
         }
@@ -4077,7 +4078,7 @@
             if (displayContent != null) {
                 displayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
                 if (DEBUG_LAYOUT_REPEATS) {
-                    mService.mWindowPlacerLocked.debugLayoutRepeats("hideWallpaperWindow " + this,
+                    mWmService.mWindowPlacerLocked.debugLayoutRepeats("hideWallpaperWindow " + this,
                             displayContent.pendingLayoutChanges);
                 }
             }
@@ -4292,7 +4293,7 @@
         }
         if (mDestroying) {
             mDestroying = false;
-            mService.mDestroySurface.remove(this);
+            mWmService.mDestroySurface.remove(this);
         }
         if (oldVisibility == View.GONE) {
             mWinAnimator.mEnterAnimationPending = true;
@@ -4360,10 +4361,10 @@
         anim.initialize(mWindowFrames.mFrame.width(), mWindowFrames.mFrame.height(),
                 displayInfo.appWidth, displayInfo.appHeight);
         anim.restrictDuration(MAX_ANIMATION_DURATION);
-        anim.scaleCurrentDuration(mService.getWindowAnimationScaleLocked());
+        anim.scaleCurrentDuration(mWmService.getWindowAnimationScaleLocked());
         final AnimationAdapter adapter = new LocalAnimationAdapter(
                 new WindowAnimationSpec(anim, mSurfacePosition, false /* canSkipFirstFrame */),
-                mService.mSurfaceAnimationRunner);
+                mWmService.mSurfaceAnimationRunner);
         startAnimation(mPendingTransaction, adapter);
         commitPendingTransaction();
     }
@@ -4377,7 +4378,7 @@
         transformFrameToSurfacePosition(left, top, newPosition);
         final AnimationAdapter adapter = new LocalAnimationAdapter(
                 new MoveAnimationSpec(oldPosition.x, oldPosition.y, newPosition.x, newPosition.y),
-                mService.mSurfaceAnimationRunner);
+                mWmService.mSurfaceAnimationRunner);
         startAnimation(getPendingTransaction(), adapter);
     }
 
@@ -4471,7 +4472,7 @@
         public boolean isFocused() {
             final WindowState outer = mOuter.get();
             if (outer != null) {
-                synchronized (outer.mService.mGlobalLock) {
+                synchronized (outer.mWmService.mGlobalLock) {
                     return outer.isFocused();
                 }
             }
@@ -4811,7 +4812,7 @@
             final Animation anim = AnimationUtils.loadAnimation(mContext,
                     com.android.internal.R.anim.window_move_from_decor);
             mDuration = (long)
-                    (anim.computeDurationHint() * mService.getWindowAnimationScaleLocked());
+                    (anim.computeDurationHint() * mWmService.getWindowAnimationScaleLocked());
             mInterpolator = anim.getInterpolator();
             mFrom.set(fromX, fromY);
             mTo.set(toX, toY);
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 78a3fe5..8bc6db7 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -234,7 +234,7 @@
     private final Point mTmpPos = new Point();
 
     WindowStateAnimator(final WindowState win) {
-        final WindowManagerService service = win.mService;
+        final WindowManagerService service = win.mWmService;
 
         mService = service;
         mAnimator = service.mAnimator;
diff --git a/services/core/java/com/android/server/wm/WindowToken.java b/services/core/java/com/android/server/wm/WindowToken.java
index d8242f8..9c13782 100644
--- a/services/core/java/com/android/server/wm/WindowToken.java
+++ b/services/core/java/com/android/server/wm/WindowToken.java
@@ -172,8 +172,8 @@
         setHidden(true);
 
         if (changed) {
-            mService.mWindowPlacerLocked.performSurfacePlacement();
-            mService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, false /*updateInputWindows*/);
+            mWmService.mWindowPlacerLocked.performSurfacePlacement();
+            mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, false /*updateInputWindows*/);
         }
 
         if (delayed) {
@@ -202,7 +202,7 @@
         if (!mChildren.contains(win)) {
             if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM, "Adding " + win + " to " + this);
             addChild(win, mWindowComparator);
-            mService.mWindowsChanged = true;
+            mWmService.mWindowsChanged = true;
             // TODO: Should we also be setting layout needed here and other places?
         }
     }
@@ -326,9 +326,9 @@
      * system bars, or in other words extend outside of the "Decor Frame"
      */
     boolean canLayerAboveSystemBars() {
-        int layer = mService.mPolicy.getWindowLayerFromTypeLw(windowType,
+        int layer = mWmService.mPolicy.getWindowLayerFromTypeLw(windowType,
                 mOwnerCanManageAppTokens);
-        int navLayer = mService.mPolicy.getWindowLayerFromTypeLw(TYPE_NAVIGATION_BAR,
+        int navLayer = mWmService.mPolicy.getWindowLayerFromTypeLw(TYPE_NAVIGATION_BAR,
                 mOwnerCanManageAppTokens);
         return mOwnerCanManageAppTokens && (layer > navLayer);
     }