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

Commit 2268e7ee authored by Craig Mautner's avatar Craig Mautner
Browse files

Minor refactorings.

Change-Id: Ia0218bf86d142be80dd12d04de97da5d19293815
parent 6fd651eb
Loading
Loading
Loading
Loading
+23 −53
Original line number Diff line number Diff line
@@ -2247,8 +2247,6 @@ public class WindowManagerService extends IWindowManager.Stub
            // Don't do layout here, the window must call
            // relayout to be displayed, so we'll do it there.

            //dump();

            if (focusChanged) {
                finishUpdateFocusedWindowAfterAssignLayersLocked(false /*updateInputWindows*/);
            }
@@ -2349,9 +2347,7 @@ public class WindowManagerService extends IWindowManager.Stub
        removeWindowInnerLocked(session, win);
        // Removing a visible window will effect the computed orientation
        // So just update orientation if needed.
        if (wasVisible && computeForcedAppOrientationLocked()
                != mForcedAppOrientation
                && updateOrientationFromAppTokensLocked(false)) {
        if (wasVisible && updateOrientationFromAppTokensLocked(false)) {
            mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
        }
        updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, true /*updateInputWindows*/);
@@ -3405,11 +3401,9 @@ public class WindowManagerService extends IWindowManager.Stub

        if (updateOrientationFromAppTokensLocked(false)) {
            if (freezeThisOneIfNeeded != null) {
                AppWindowToken atoken = findAppWindowToken(
                        freezeThisOneIfNeeded);
                AppWindowToken atoken = findAppWindowToken(freezeThisOneIfNeeded);
                if (atoken != null) {
                    startAppFreezingScreenLocked(atoken,
                            ActivityInfo.CONFIG_ORIENTATION);
                    startAppFreezingScreenLocked(atoken, ActivityInfo.CONFIG_ORIENTATION);
                }
            }
            config = computeNewConfigurationLocked();
@@ -3451,7 +3445,10 @@ public class WindowManagerService extends IWindowManager.Stub
    boolean updateOrientationFromAppTokensLocked(boolean inTransaction) {
        long ident = Binder.clearCallingIdentity();
        try {
            int req = computeForcedAppOrientationLocked();
            int req = getOrientationFromWindowsLocked();
            if (req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
                req = getOrientationFromAppTokensLocked();
            }

            if (req != mForcedAppOrientation) {
                mForcedAppOrientation = req;
@@ -3470,14 +3467,6 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    int computeForcedAppOrientationLocked() {
        int req = getOrientationFromWindowsLocked();
        if (req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
            req = getOrientationFromAppTokensLocked();
        }
        return req;
    }

    @Override
    public void setNewConfiguration(Configuration config) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
@@ -4495,40 +4484,6 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    private void moveAppWindowsLocked(AppWindowToken wtoken, int tokenPos,
            boolean updateFocusAndLayout) {
        // First remove all of the windows from the list.
        tmpRemoveAppWindowsLocked(wtoken);

        // And now add them back at the correct place.
        DisplayContentsIterator iterator = new DisplayContentsIterator();
        while (iterator.hasNext()) {
            final DisplayContent displayContent = iterator.next();
            final WindowList windows = displayContent.getWindowList();
            final int pos = findWindowOffsetLocked(windows, tokenPos);
            final int newPos = reAddAppWindowsLocked(displayContent, pos, wtoken);
            if (pos != newPos) {
                displayContent.layoutNeeded = true;
            }

            if (updateFocusAndLayout && !updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,
                    false /*updateInputWindows*/)) {
                assignLayersLocked(windows);
            }
        }

        if (updateFocusAndLayout) {
            mInputMonitor.setUpdateInputWindowsNeededLw();

            // Note that the above updateFocusedWindowLocked conditional used to sit here.

            if (!mInLayout) {
                performLayoutAndPlaceSurfacesLocked();
            }
            mInputMonitor.updateInputWindowsLw(false /*force*/);
        }
    }

    private void moveAppWindowsLocked(List<IBinder> tokens, int tokenPos) {
        // First remove all of the windows from the list.
        final int N = tokens.size();
@@ -4573,6 +4528,7 @@ public class WindowManagerService extends IWindowManager.Stub
        //dump();
    }

    @Override
    public void moveAppTokensToTop(List<IBinder> tokens) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
                "moveAppTokensToTop()")) {
@@ -4714,12 +4670,14 @@ public class WindowManagerService extends IWindowManager.Stub
    /**
     * @see android.app.KeyguardManager#exitKeyguardSecurely
     */
    @Override
    public void exitKeyguardSecurely(final IOnKeyguardExitResult callback) {
        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
            != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException("Requires DISABLE_KEYGUARD permission");
        }
        mPolicy.exitKeyguardSecurely(new WindowManagerPolicy.OnKeyguardExitResult() {
            @Override
            public void onKeyguardExitResult(boolean success) {
                try {
                    callback.onKeyguardExitResult(success);
@@ -4730,18 +4688,22 @@ public class WindowManagerService extends IWindowManager.Stub
        });
    }

    @Override
    public boolean inKeyguardRestrictedInputMode() {
        return mPolicy.inKeyguardRestrictedKeyInputMode();
    }

    @Override
    public boolean isKeyguardLocked() {
        return mPolicy.isKeyguardLocked();
    }

    @Override
    public boolean isKeyguardSecure() {
        return mPolicy.isKeyguardSecure();
    }

    @Override
    public void dismissKeyguard() {
        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
                != PackageManager.PERMISSION_GRANTED) {
@@ -8837,6 +8799,7 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    @Override
    public boolean waitForWindowDrawn(IBinder token, IRemoteCallback callback) {
        if (token != null && callback != null) {
            synchronized (mWindowMap) {
@@ -9360,9 +9323,10 @@ public class WindowManagerService extends IWindowManager.Stub

        File file = new File("/system/etc/setup.conf");
        FileInputStream in = null;
        DataInputStream ind = null;
        try {
            in = new FileInputStream(file);
            DataInputStream ind = new DataInputStream(in);
            ind = new DataInputStream(in);
            String line = ind.readLine();
            if (line != null) {
                String[] toks = line.split("%");
@@ -9380,6 +9344,12 @@ public class WindowManagerService extends IWindowManager.Stub
                } catch (IOException e) {
                }
            }
            if (ind != null) {
                try {
                    ind.close();
                } catch (IOException e) {
                }
            }
        }
    }

+6 −4
Original line number Diff line number Diff line
@@ -215,10 +215,12 @@ final class WindowState implements WindowManagerPolicy.WindowState {
    int mXOffset;
    int mYOffset;

    // This is set after IWindowSession.relayout() has been called at
    // least once for the window.  It allows us to detect the situation
    // where we don't yet have a surface, but should have one soon, so
    // we can give the window focus before waiting for the relayout.
    /**
     * This is set after IWindowSession.relayout() has been called at
     * least once for the window.  It allows us to detect the situation
     * where we don't yet have a surface, but should have one soon, so
     * we can give the window focus before waiting for the relayout.
     */
    boolean mRelayoutCalled;

    // If the application has called relayout() with changes that can