Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e889bf79 authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "Misc clean up before requesting focus via setFocusedWindow api"

parents 42572552 904ea677
Loading
Loading
Loading
Loading
+48 −60
Original line number Diff line number Diff line
@@ -325,12 +325,6 @@
      "group": "WM_DEBUG_REMOTE_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RemoteAnimationController.java"
    },
    "-1587841219": {
      "message": "Focus moving from %s to %s displayId=%d",
      "level": "INFO",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-1568331821": {
      "message": "Enabling listeners",
      "level": "VERBOSE",
@@ -415,6 +409,12 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-1438175584": {
      "message": "Input focus has changed to %s display=%d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/InputMonitor.java"
    },
    "-1434147454": {
      "message": "cleanupAnimation(): Notify animation finished mPendingAnimations=%d reorderMode=%d",
      "level": "DEBUG",
@@ -565,6 +565,12 @@
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/WindowStateAnimator.java"
    },
    "-1142279614": {
      "message": "Looking for focus: %s, flags=%d, canReceive=%b, reason=%s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_FOCUS",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "-1130891072": {
      "message": "Orientation continue waiting for draw in %s",
      "level": "VERBOSE",
@@ -799,12 +805,6 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-771282525": {
      "message": "Losing focus: %s",
      "level": "INFO",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-771177730": {
      "message": "Removing focused app token:%s displayId=%d",
      "level": "VERBOSE",
@@ -847,12 +847,6 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/DragState.java"
    },
    "-687185281": {
      "message": "New topFocusedDisplayId=%d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/RootWindowContainer.java"
    },
    "-668956537": {
      "message": "  THUMBNAIL %s: CREATE",
      "level": "INFO",
@@ -877,6 +871,12 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowToken.java"
    },
    "-639217716": {
      "message": "setFocusedApp %s displayId=%d Callers=%s",
      "level": "INFO",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "-635082269": {
      "message": "******** booted=%b msg=%b haveBoot=%b haveApp=%b haveWall=%b wallEnabled=%b haveKeyguard=%b",
      "level": "INFO",
@@ -895,12 +895,6 @@
      "group": "WM_DEBUG_BOOT",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-603199586": {
      "message": "Clearing focused app, displayId=%d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "-593535526": {
      "message": "Binding proc %s with config %s",
      "level": "VERBOSE",
@@ -919,6 +913,12 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/DisplayRotation.java"
    },
    "-561092364": {
      "message": "onPointerDownOutsideFocusLocked called on %s",
      "level": "INFO",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-549028919": {
      "message": "enableScreenIfNeededLocked: mDisplayEnabled=%b mForceDisplayEnabled=%b mShowingBootMessages=%b mSystemBooted=%b. %s",
      "level": "INFO",
@@ -1201,12 +1201,6 @@
      "group": "WM_DEBUG_RECENTS_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RecentsAnimation.java"
    },
    "-96848838": {
      "message": "Gaining focus: %s",
      "level": "INFO",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-90559682": {
      "message": "Config is skipping already pausing %s",
      "level": "VERBOSE",
@@ -1363,6 +1357,12 @@
      "group": "WM_DEBUG_STARTING_WINDOW",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "115358443": {
      "message": "Focus changing: %s -> %s",
      "level": "INFO",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "123161180": {
      "message": "SEVER CHILDREN",
      "level": "INFO",
@@ -1495,12 +1495,6 @@
      "group": "WM_DEBUG_APP_TRANSITIONS_ANIM",
      "at": "com\/android\/server\/wm\/AppTransition.java"
    },
    "285317231": {
      "message": "Input focus has changed to %s",
      "level": "DEBUG",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/InputMonitor.java"
    },
    "288485303": {
      "message": "Attempted to set remove mode to a display that does not exist: %d",
      "level": "WARN",
@@ -1537,6 +1531,12 @@
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/WindowSurfaceController.java"
    },
    "312030608": {
      "message": "New topFocusedDisplayId=%d",
      "level": "DEBUG",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/RootWindowContainer.java"
    },
    "315395835": {
      "message": "Trying to add window with invalid user=%d",
      "level": "WARN",
@@ -1699,12 +1699,6 @@
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/WindowSurfaceController.java"
    },
    "584499099": {
      "message": "Set focused app to: %s moveFocusNow=%b displayId=%d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "585096182": {
      "message": "SURFACE isColorSpaceAgnostic=%b: %s",
      "level": "INFO",
@@ -1747,6 +1741,12 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "620519522": {
      "message": "findFocusedWindow: No focusable windows, display=%d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "628276090": {
      "message": "Delaying app transition for screen rotation animation to finish",
      "level": "VERBOSE",
@@ -1903,6 +1903,12 @@
      "group": "WM_DEBUG_ADD_REMOVE",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "872933199": {
      "message": "Changing focus from %s to %s displayId=%d Callers=%s",
      "level": "DEBUG",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "873914452": {
      "message": "goodToGo()",
      "level": "DEBUG",
@@ -2137,12 +2143,6 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/ScreenRotationAnimation.java"
    },
    "1358462645": {
      "message": "Looking for focus: %s, flags=%d, canReceive=%b",
      "level": "VERBOSE",
      "group": "WM_DEBUG_FOCUS",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "1360551978": {
      "message": "Trying to update display configuration for non-existing displayId=%d",
      "level": "WARN",
@@ -2233,12 +2233,6 @@
      "group": "WM_DEBUG_APP_TRANSITIONS_ANIM",
      "at": "com\/android\/server\/wm\/AppTransitionController.java"
    },
    "1469292670": {
      "message": "Changing focus from %s to %s displayId=%d Callers=%s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "1495525537": {
      "message": "createWallpaperAnimations()",
      "level": "DEBUG",
@@ -2677,12 +2671,6 @@
      "group": "WM_DEBUG_IME",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "2128604122": {
      "message": "findFocusedWindow: No focusable windows.",
      "level": "VERBOSE",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "2128917433": {
      "message": "onProposedRotationChanged, rotation=%d",
      "level": "VERBOSE",
+2 −10
Original line number Diff line number Diff line
@@ -401,7 +401,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    final ActivityTaskManagerService mAtmService;
    final ActivityInfo info; // activity info provided by developer in AndroidManifest
    // Non-null only for application tokens.
    // TODO: rename to mActivityToken
    final ActivityRecord.Token appToken;
    // Which user is this running for?
@@ -5480,10 +5479,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    void updateReportedVisibilityLocked() {
        if (appToken == null) {
            return;
        }

        if (DEBUG_VISIBILITY) Slog.v(TAG, "Update reported visibility: " + this);
        final int count = mChildren.size();

@@ -6330,8 +6325,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    private void setOrientation(int requestedOrientation, boolean freezeScreenIfNeeded) {
        final IBinder binder =
                (freezeScreenIfNeeded && appToken != null) ? appToken.asBinder() : null;
        final IBinder binder = freezeScreenIfNeeded ? appToken.asBinder() : null;
        setOrientation(requestedOrientation, binder, this);

        // Push the new configuration to the requested app in case where it's not pushed, e.g. when
@@ -7713,10 +7707,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    void writeNameToProto(ProtoOutputStream proto, long fieldId) {
        if (appToken != null) {
        proto.write(fieldId, appToken.getName());
    }
    }

    @Override
    void writeIdentifierToProto(ProtoOutputStream proto, long fieldId) {
+6 −2
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ import static com.android.server.wm.Task.LOCK_TASK_AUTH_DONT_LOCK;
import static com.android.server.wm.Task.REPARENT_KEEP_STACK_AT_FRONT;
import static com.android.server.wm.Task.REPARENT_LEAVE_STACK_IN_PLACE;
import static com.android.server.wm.WindowContainer.POSITION_TOP;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL;

import android.Manifest;
import android.annotation.IntDef;
@@ -5465,8 +5466,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        updateResumedAppTrace(r);
        mLastResumedActivity = r;

        r.getDisplay().setFocusedApp(r, true);

        final boolean changed = r.getDisplay().setFocusedApp(r);
        if (changed) {
            mWindowManager.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL,
                    true /*updateInputWindows*/);
        }
        if (prevTask == null || task != prevTask) {
            if (prevTask != null) {
                mTaskChangeNotificationController.notifyTaskFocusChanged(prevTask.mTaskId, false);
+31 −40
Original line number Diff line number Diff line
@@ -115,13 +115,11 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WALLPAPER_LIG
import static com.android.server.wm.WindowManagerDebugConfig.SHOW_STACK_CRAWLS;
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.H.REPORT_FOCUS_CHANGE;
import static com.android.server.wm.WindowManagerService.H.REPORT_HARD_KEYBOARD_STATUS_CHANGE;
import static com.android.server.wm.WindowManagerService.H.UPDATE_MULTI_WINDOW_STACKS;
import static com.android.server.wm.WindowManagerService.H.WINDOW_HIDE_TIMEOUT;
import static com.android.server.wm.WindowManagerService.LAYOUT_REPEAT_THRESHOLD;
import static com.android.server.wm.WindowManagerService.SEAMLESS_ROTATION_TIMEOUT_DURATION;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_PLACING_SURFACES;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_REMOVING_FOCUS;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_ASSIGN_LAYERS;
@@ -649,8 +647,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

    private final ToBooleanFunction<WindowState> mFindFocusedWindow = w -> {
        final ActivityRecord focusedApp = mFocusedApp;
        ProtoLog.v(WM_DEBUG_FOCUS, "Looking for focus: %s, flags=%d, canReceive=%b",
                w, w.mAttrs.flags, w.canReceiveKeys());
        ProtoLog.v(WM_DEBUG_FOCUS, "Looking for focus: %s, flags=%d, canReceive=%b, reason=%s",
                w, w.mAttrs.flags, w.canReceiveKeys(),
                w.canReceiveKeysReason(false /* fromUserTouch */));

        if (!w.canReceiveKeys()) {
            return false;
@@ -3081,7 +3080,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        forAllWindows(mFindFocusedWindow, true /* traverseTopToBottom */);

        if (mTmpWindow == null) {
            ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "findFocusedWindow: No focusable windows.");
            ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "findFocusedWindow: No focusable windows, display=%d",
                    getDisplayId());
            return null;
        }
        return mTmpWindow;
@@ -3116,18 +3116,15 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                    && mode != UPDATE_FOCUS_WILL_PLACE_SURFACES) {
                assignWindowLayers(false /* setLayoutNeeded */);
            }
        }

            if (imWindowChanged) {
                mWmService.mWindowsChanged = true;
                setLayoutNeeded();
                newFocus = findFocusedWindowIfNeeded(topFocusedDisplayId);
            }
        if (mCurrentFocus != newFocus) {
            mWmService.mH.obtainMessage(REPORT_FOCUS_CHANGE, this).sendToTarget();
        }

        ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "Changing focus from %s to %s displayId=%d Callers=%s",
        ProtoLog.d(WM_DEBUG_FOCUS_LIGHT, "Changing focus from %s to %s displayId=%d Callers=%s",
                mCurrentFocus, newFocus, getDisplayId(), Debug.getCallers(4));
        final WindowState oldFocus = mCurrentFocus;
        mCurrentFocus = newFocus;
@@ -3185,9 +3182,25 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
            pendingLayoutChanges |= FINISH_LAYOUT_REDO_ANIM;
        }

        // Notify the accessibility manager for the change so it has the windows before the newly
        // focused one starts firing events.
        // TODO(b/151179149) investigate what info accessibility service needs before input can
        // dispatch focus to clients.
        if (mWmService.mAccessibilityController != null) {
            mWmService.mH.sendMessage(PooledLambda.obtainMessage(
                    this::updateAccessibilityOnWindowFocusChanged,
                    mWmService.mAccessibilityController));
        }

        mLastFocus = mCurrentFocus;
        return true;
    }

    void updateAccessibilityOnWindowFocusChanged(AccessibilityController accessibilityController) {
        accessibilityController.onWindowFocusChangedNotLocked(getDisplayId());
    }

    private static void onWindowFocusChanged(WindowState oldFocus, WindowState newFocus) {
        final Task focusedTask = newFocus != null ? newFocus.getTask() : null;
        final Task unfocusedTask = oldFocus != null ? oldFocus.getTask() : null;
@@ -3219,6 +3232,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        if (mFocusedApp == newFocus) {
            return false;
        }
        ProtoLog.i(WM_DEBUG_FOCUS_LIGHT, "setFocusedApp %s displayId=%d Callers=%s",
                newFocus, getDisplayId(), Debug.getCallers(4));
        mFocusedApp = newFocus;
        getInputMonitor().setFocusedAppLw(newFocus);
        updateTouchExcludeRegion();
@@ -4708,7 +4723,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        // Traverse all windows top down to assemble the gesture exclusion rects.
        // For each window, we only take the rects that fall within its touchable region.
        forAllWindows(w -> {
            if (w.cantReceiveTouchInput() || !w.isVisible()
            if (!w.canReceiveTouchInput() || !w.isVisible()
                    || (w.getAttrs().flags & FLAG_NOT_TOUCHABLE) != 0
                    || unhandled.isEmpty()) {
                return;
@@ -5225,30 +5240,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                && (mAtmService.mRunningVoice == null);
    }

    void setFocusedApp(ActivityRecord r, boolean moveFocusNow) {
        final ActivityRecord newFocus;
        final IBinder token = r.appToken;
        if (token == null) {
            ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "Clearing focused app, displayId=%d",
                    mDisplayId);
            newFocus = null;
        } else {
            newFocus = mWmService.mRoot.getActivityRecord(token);
            if (newFocus == null) {
                Slog.w(TAG_WM, "Attempted to set focus to non-existing app token: " + token
                        + ", displayId=" + mDisplayId);
            }
            ProtoLog.v(WM_DEBUG_FOCUS_LIGHT,
                    "Set focused app to: %s moveFocusNow=%b displayId=%d", newFocus,
                    moveFocusNow, mDisplayId);
        }

        final boolean changed = setFocusedApp(newFocus);
        if (moveFocusNow && changed) {
            mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL,
                    true /*updateInputWindows*/);
        }
    }

    void ensureActivitiesVisible(ActivityRecord starting, int configChanges,
            boolean preserveWindows, boolean notifyClients) {
+1 −1
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ class DragDropController {

                    final WindowState callingWin = mService.windowForClientLocked(
                            null, window, false);
                    if (callingWin == null || callingWin.cantReceiveTouchInput()) {
                    if (callingWin == null || !callingWin.canReceiveTouchInput()) {
                        Slog.w(TAG_WM, "Bad requesting window " + window);
                        return null;  // !!! TODO: throw here?
                    }
Loading