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

Commit 544bf6ce authored by David van Tonder's avatar David van Tonder Committed by Gerrit Code Review
Browse files

Merge "Fix up expanded desktop behaviour." into cm-10.1

parents 03a42019 667cdc82
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -265,4 +265,9 @@ interface IWindowManager
     * credentials.
     */
    void showAssistant();

    /**
     * Update the application display metrics
     */
    void updateDisplayMetrics();
}
+67 −19
Original line number Diff line number Diff line
@@ -475,6 +475,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    boolean mForcingShowNavBar;
    int mForcingShowNavBarLayer;

    int mExpandedDesktopStyle = -1;

    // States of keyguard dismiss.
    private static final int DISMISS_KEYGUARD_NONE = 0; // Keyguard not being dismissed.
    private static final int DISMISS_KEYGUARD_START = 1; // Keyguard needs to be dismissed.
@@ -1334,7 +1336,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    public void updateSettings() {
        ContentResolver resolver = mContext.getContentResolver();
        boolean updateRotation = false;
        boolean updateRotation = false, updateDisplayMetrics = false;
        synchronized (mLock) {
            mEndcallBehavior = Settings.System.getIntForUser(resolver,
                    Settings.System.END_BUTTON_BEHAVIOR,
@@ -1415,6 +1417,18 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                }
            }

            int expandedDesktopStyle = Settings.System.getIntForUser(resolver,
                    Settings.System.EXPANDED_DESKTOP_STYLE, 0, UserHandle.USER_CURRENT);
            if (Settings.System.getIntForUser(resolver,
                        Settings.System.EXPANDED_DESKTOP_STATE, 0, UserHandle.USER_CURRENT) == 0) {
                expandedDesktopStyle = 0;
            }

            if (expandedDesktopStyle != mExpandedDesktopStyle) {
                mExpandedDesktopStyle = expandedDesktopStyle;
                updateDisplayMetrics = true;
            }

            // Configure rotation lock.
            int userRotation = Settings.System.getIntForUser(resolver,
                    Settings.System.USER_ROTATION, Surface.ROTATION_0,
@@ -1459,9 +1473,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            }

            // Update navigation bar dimensions
            boolean desktopExpanded = Settings.System.getInt(mContext.getContentResolver(),
                    Settings.System.EXPANDED_DESKTOP_STATE, 0) == 1;
            if (desktopExpanded) {
            if (expandedDesktopHidesNavigationBar()) {
                // Set the navigation bar's dimensions to 0 in expanded desktop mode
                mNavigationBarWidthForRotation[mPortraitRotation]
                        = mNavigationBarWidthForRotation[mUpsideDownRotation]
@@ -1494,6 +1506,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {

        if (updateRotation) {
            updateRotation(true);
        } else if (updateDisplayMetrics) {
            updateDisplayMetrics();
        }
    }

@@ -2833,8 +2847,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR))
                == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) {
            int availRight, availBottom;
            if (mCanHideNavigationBar &&
                    (systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0) {
            if (shouldHideNavigationBarLw(systemUiVisibility)) {
                availRight = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth;
                availBottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
            } else {
@@ -2919,8 +2932,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            // For purposes of positioning and showing the nav bar, if we have
            // decided that it can't be hidden (because of the screen aspect ratio),
            // then take that into account.
            navVisible |= !mCanHideNavigationBar;
            navVisible &= (Settings.System.getInt(mContext.getContentResolver(), Settings.System.EXPANDED_DESKTOP_STATE, 0) == 0);
            if (expandedDesktopHidesNavigationBar()) {
                navVisible = false;
            } else if (!mCanHideNavigationBar) {
                navVisible = true;
            }

            if (mNavigationBar != null) {
                // Force the navigation bar to its appropriate place and
@@ -2999,8 +3015,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                // Let the status bar determine its size.
                mStatusBar.computeFrameLw(pf, df, vf, vf);

                // For layout, the status bar is always at the top with our fixed height.
                // For layout, the status bar is always at the top with our fixed height
                // (except if it's hidden by expanded desktop, in which case we know it's
                // never shown)
                if (!expandedDesktopHidesStatusBar()) {
                    mStableTop = mUnrestrictedScreenTop + mStatusBarHeight;
                }

                // If the status bar is hidden, we don't want to cause
                // windows behind it to scroll.
@@ -3202,8 +3222,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                                        "Laying out status bar window: (%d,%d - %d,%d)",
                                        pf.left, pf.top, pf.right, pf.bottom));
                        }
                    } else if (mCanHideNavigationBar
                            && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0
                    } else if (shouldHideNavigationBarLw(sysUiFl)
                            && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
                            && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
                        // Asking for layout as if the nav bar is hidden, lets the
@@ -3293,8 +3312,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    pf.right = df.right = cf.right = mUnrestrictedScreenLeft+mUnrestrictedScreenWidth;
                    pf.bottom = df.bottom = cf.bottom
                            = mUnrestrictedScreenTop+mUnrestrictedScreenHeight;
                } else if (mCanHideNavigationBar
                        && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0
                } else if (shouldHideNavigationBarLw(sysUiFl)
                        && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
                        && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
                    // Asking for layout as if the nav bar is hidden, lets the
@@ -3399,6 +3417,28 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    private boolean expandedDesktopHidesStatusBar() {
        return mExpandedDesktopStyle == 2;
    }

    private boolean expandedDesktopHidesNavigationBar() {
        return mExpandedDesktopStyle != 0;
    }

    private boolean shouldHideNavigationBarLw(int systemUiVisibility) {
        if (expandedDesktopHidesNavigationBar()) {
            return true;
        }

        if (mCanHideNavigationBar) {
            if ((systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0) {
                return true;
            }
        }

        return false;
    }

    private void offsetInputMethodWindowLw(WindowState win) {
        int top = win.getContentFrameLw().top;
        top += win.getGivenContentInsetsLw().top;
@@ -3521,7 +3561,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            if (DEBUG_LAYOUT) Log.i(TAG, "force=" + mForceStatusBar
                    + " forcefkg=" + mForceStatusBarFromKeyguard
                    + " top=" + mTopFullscreenOpaqueWindowState);
            if (mForceStatusBar || mForceStatusBarFromKeyguard) {
            if (expandedDesktopHidesStatusBar()) {
                if (DEBUG_LAYOUT) Log.v(TAG, "Hiding status bar: expanded desktop enabled");
                if (mStatusBar.hideLw(true)) changes |= FINISH_LAYOUT_REDO_LAYOUT;
            } else if (mForceStatusBar || mForceStatusBarFromKeyguard) {
                if (DEBUG_LAYOUT) Log.v(TAG, "Showing status bar: forced");
                if (mStatusBar.showLw(true)) changes |= FINISH_LAYOUT_REDO_LAYOUT;
            } else if (mTopFullscreenOpaqueWindowState != null) {
@@ -3537,10 +3580,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                // and mTopIsFullscreen is that that mTopIsFullscreen is set only if the window
                // has the FLAG_FULLSCREEN set.  Not sure if there is another way that to be the
                // case though.
                if (topIsFullscreen || (Settings.System.getInt(mContext.getContentResolver(),
                                        Settings.System.EXPANDED_DESKTOP_STATE, 0) == 1 &&
                                        Settings.System.getInt(mContext.getContentResolver(),
                                        Settings.System.EXPANDED_DESKTOP_STYLE, 0) == 2)) {
                if (topIsFullscreen) {
                    if (DEBUG_LAYOUT) Log.v(TAG, "** HIDING status bar");
                    if (mStatusBar.hideLw(true)) {
                        changes |= FINISH_LAYOUT_REDO_LAYOUT;
@@ -4931,6 +4971,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    void updateDisplayMetrics() {
        try {
            mWindowManager.updateDisplayMetrics();
        } catch (RemoteException e) {
            // Ignore
        }
    }

    /**
     * Return an Intent to launch the currently active dock app as home.  Returns
     * null if the standard home should be launched, which is the case if any of the following is
+62 −25
Original line number Diff line number Diff line
@@ -6925,53 +6925,54 @@ public class WindowManagerService extends IWindowManager.Stub
        return sw;
    }

    boolean computeScreenConfigurationLocked(Configuration config) {
        if (!mDisplayReady) {
            return false;
    private static class ApplicationDisplayMetrics {
        boolean rotated;
        int dh;
        int dw;
    }

        // TODO(multidisplay): For now, apply Configuration to main screen only.
        final DisplayContent displayContent = getDefaultDisplayContentLocked();
    private ApplicationDisplayMetrics calculateDisplayMetrics(DisplayContent displayContent) {
        ApplicationDisplayMetrics dm = new ApplicationDisplayMetrics();

        // Use the effective "visual" dimensions based on current rotation
        final boolean rotated = (mRotation == Surface.ROTATION_90
                || mRotation == Surface.ROTATION_270);
        final int realdw = rotated ?
        dm.rotated = (mRotation == Surface.ROTATION_90 || mRotation == Surface.ROTATION_270);
        final int realdw = dm.rotated ?
                displayContent.mBaseDisplayHeight : displayContent.mBaseDisplayWidth;
        final int realdh = rotated ?
        final int realdh = dm.rotated ?
                displayContent.mBaseDisplayWidth : displayContent.mBaseDisplayHeight;
        int dw = realdw;
        int dh = realdh;

        dm.dw = realdw;
        dm.dh = realdh;

        if (mAltOrientation) {
            if (realdw > realdh) {
                // Turn landscape into portrait.
                int maxw = (int)(realdh/1.3f);
                if (maxw < realdw) {
                    dw = maxw;
                    dm.dw = maxw;
                }
            } else {
                // Turn portrait into landscape.
                int maxh = (int)(realdw/1.3f);
                if (maxh < realdh) {
                    dh = maxh;
                    dm.dh = maxh;
                }
            }
        }

        if (config != null) {
            config.orientation = (dw <= dh) ? Configuration.ORIENTATION_PORTRAIT :
                    Configuration.ORIENTATION_LANDSCAPE;
        return dm;
    }

        // Update application display metrics.
        final int appWidth = mPolicy.getNonDecorDisplayWidth(dw, dh, mRotation);
        final int appHeight = mPolicy.getNonDecorDisplayHeight(dw, dh, mRotation);
    private ApplicationDisplayMetrics updateApplicationDisplayMetricsLocked(
            DisplayContent displayContent) {
        final ApplicationDisplayMetrics m = calculateDisplayMetrics(displayContent);
        final int appWidth = mPolicy.getNonDecorDisplayWidth(m.dw, m.dh, mRotation);
        final int appHeight = mPolicy.getNonDecorDisplayHeight(m.dw, m.dh, mRotation);
        final DisplayInfo displayInfo = displayContent.getDisplayInfo();

        synchronized(displayContent.mDisplaySizeLock) {
            displayInfo.rotation = mRotation;
            displayInfo.logicalWidth = dw;
            displayInfo.logicalHeight = dh;
            displayInfo.logicalWidth = m.dw;
            displayInfo.logicalHeight = m.dh;
            displayInfo.logicalDensityDpi = displayContent.mBaseDisplayDensity;
            displayInfo.appWidth = appWidth;
            displayInfo.appHeight = appHeight;
@@ -6980,12 +6981,37 @@ public class WindowManagerService extends IWindowManager.Stub
            mDisplayManagerService.setDisplayInfoOverrideFromWindowManager(
                    displayContent.getDisplayId(), displayInfo);

            mAnimator.setDisplayDimensions(dw, dh, appWidth, appHeight);
            mAnimator.setDisplayDimensions(m.dw, m.dh, appWidth, appHeight);
        }

        if (false) {
            Slog.i(TAG, "Set app display size: " + appWidth + " x " + appHeight);
        }

        return m;
    }

    boolean computeScreenConfigurationLocked(Configuration config) {
        if (!mDisplayReady) {
            return false;
        }

        // TODO(multidisplay): For now, apply Configuration to main screen only.
        final DisplayContent displayContent = getDefaultDisplayContentLocked();

        // Update application display metrics.
        final ApplicationDisplayMetrics appDm = updateApplicationDisplayMetricsLocked(
                displayContent);
        final boolean rotated = appDm.rotated;
        final int dw = appDm.dw;
        final int dh = appDm.dh;

        if (config != null) {
            config.orientation = (dw <= dh) ? Configuration.ORIENTATION_PORTRAIT :
                    Configuration.ORIENTATION_LANDSCAPE;
        }

        final DisplayInfo displayInfo = displayContent.getDisplayInfo();
        final DisplayMetrics dm = mDisplayMetrics;
        mCompatibleScreenScale = CompatibilityInfo.computeCompatibleScaling(dm,
                mCompatDisplayMetrics);
@@ -10445,6 +10471,17 @@ public class WindowManagerService extends IWindowManager.Stub
        mPolicy.showAssistant();
    }

    public void updateDisplayMetrics() {
        long origId = Binder.clearCallingIdentity();

        synchronized (mWindowMap) {
            final DisplayContent displayContent = getDefaultDisplayContentLocked();
            updateApplicationDisplayMetricsLocked(displayContent);
        }

        Binder.restoreCallingIdentity(origId);
    }

    void dumpPolicyLocked(PrintWriter pw, String[] args, boolean dumpAll) {
        pw.println("WINDOW MANAGER POLICY STATE (dumpsys window policy)");
        mPolicy.dump("    ", pw, args);
+1 −1
Original line number Diff line number Diff line
@@ -498,7 +498,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
            mCompatFrame.scale(mInvGlobalScale);
        }

        if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) {
        if (mIsWallpaper) {
            final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
            mService.updateWallpaperOffsetLocked(this, displayInfo.appWidth, displayInfo.appHeight,
                    false);
+5 −0
Original line number Diff line number Diff line
@@ -457,6 +457,11 @@ public class IWindowManagerImpl implements IWindowManager {

    }

    @Override
    public void updateDisplayMetrics() {

    }

    @Override
    public IBinder getFocusedWindowToken() {
        // TODO Auto-generated method stub