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

Commit 9018354a authored by Griff Hazen's avatar Griff Hazen Committed by Android (Google) Code Review
Browse files

Merge "Merge commit '583c7c56' into master"

parents 3910eb55 daf5c0eb
Loading
Loading
Loading
Loading
+9 −28
Original line number Diff line number Diff line
@@ -17,15 +17,12 @@
package android.service.wallpaper;

import android.content.res.TypedArray;
import android.os.Build;
import android.os.SystemProperties;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.ViewRootImpl;
import android.view.WindowInsets;

import com.android.internal.R;
import com.android.internal.os.HandlerCaller;
import com.android.internal.util.ScreenShapeHelper;
import com.android.internal.view.BaseIWindow;
import com.android.internal.view.BaseSurfaceHolder;

@@ -158,7 +155,7 @@ public abstract class WallpaperService extends Service {
                WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS;
        int mCurWindowFlags = mWindowFlags;
        int mCurWindowPrivateFlags = mWindowPrivateFlags;
        TypedValue mOutsetBottom;
        int mOutsetBottomPx;
        final Rect mVisibleInsets = new Rect();
        final Rect mWinFrame = new Rect();
        final Rect mOverscanInsets = new Rect();
@@ -171,8 +168,6 @@ public abstract class WallpaperService extends Service {
        final Rect mFinalStableInsets = new Rect();
        final Configuration mConfiguration = new Configuration();

        private boolean mIsEmulator;
        private boolean mIsCircularEmulator;
        private boolean mWindowIsRound;

        final WindowManager.LayoutParams mLayout
@@ -637,23 +632,13 @@ public abstract class WallpaperService extends Service {
                        final Display display = windowService.getDefaultDisplay();
                        final boolean shouldUseBottomOutset =
                                display.getDisplayId() == Display.DEFAULT_DISPLAY;
                        if (shouldUseBottomOutset && windowStyle.hasValue(
                                R.styleable.Window_windowOutsetBottom)) {
                            if (mOutsetBottom == null) mOutsetBottom = new TypedValue();
                            windowStyle.getValue(R.styleable.Window_windowOutsetBottom,
                                    mOutsetBottom);
                        } else {
                            mOutsetBottom = null;
                        if (shouldUseBottomOutset) {
                            mOutsetBottomPx = ScreenShapeHelper.getWindowOutsetBottomPx(
                                    getResources().getDisplayMetrics(), windowStyle);
                        }
                        mWindowIsRound = getResources().getBoolean(
                                com.android.internal.R.bool.config_windowIsRound);
                        mWindowIsRound = ScreenShapeHelper.getWindowIsRound(getResources());
                        windowStyle.recycle();

                        // detect emulator
                        mIsEmulator = Build.HARDWARE.contains("goldfish");
                        mIsCircularEmulator = SystemProperties.getBoolean(
                                ViewRootImpl.PROPERTY_EMULATOR_CIRCULAR, false);

                        // Add window
                        mLayout.type = mIWallpaperEngine.mWindowType;
                        mLayout.gravity = Gravity.START|Gravity.TOP;
@@ -783,18 +768,14 @@ public abstract class WallpaperService extends Service {
                            mDispatchedOverscanInsets.set(mOverscanInsets);
                            mDispatchedContentInsets.set(mContentInsets);
                            mDispatchedStableInsets.set(mStableInsets);
                            final boolean isRound = (mIsEmulator && mIsCircularEmulator)
                                    || mWindowIsRound;
                            mFinalSystemInsets.set(mDispatchedOverscanInsets);
                            mFinalStableInsets.set(mDispatchedStableInsets);
                            if (mOutsetBottom != null) {
                                final DisplayMetrics metrics = getResources().getDisplayMetrics();
                            if (mOutsetBottomPx != 0) {
                                mFinalSystemInsets.bottom =
                                        ( (int) mOutsetBottom.getDimension(metrics) )
                                        + mIWallpaperEngine.mDisplayPadding.bottom;
                                        mIWallpaperEngine.mDisplayPadding.bottom + mOutsetBottomPx;
                            }
                            WindowInsets insets = new WindowInsets(mFinalSystemInsets,
                                    null, mFinalStableInsets, isRound);
                                    null, mFinalStableInsets, mWindowIsRound);
                            onApplyWindowInsets(insets);
                        }

+10 −12
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.app.SearchManager;
import android.os.UserHandle;

import com.android.internal.R;
import com.android.internal.util.ScreenShapeHelper;
import com.android.internal.view.RootViewSurfaceTaker;
import com.android.internal.view.StandaloneActionMode;
import com.android.internal.view.menu.ContextMenuBuilder;
@@ -64,6 +65,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.transition.Scene;
import android.transition.Transition;
import android.transition.TransitionInflater;
@@ -125,7 +127,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
    TypedValue mFixedWidthMinor;
    TypedValue mFixedHeightMajor;
    TypedValue mFixedHeightMinor;
    TypedValue mOutsetBottom;
    int mOutsetBottomPx;

    // This is the top-level view of the window, containing the window decor.
    private DecorView mDecor;
@@ -2368,12 +2370,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {

        @Override
        public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
            if (mOutsetBottom != null) {
                final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
                int bottom = (int) mOutsetBottom.getDimension(metrics);
            if (mOutsetBottomPx != 0) {
                WindowInsets newInsets = insets.replaceSystemWindowInsets(
                        insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                        insets.getSystemWindowInsetRight(), bottom);
                        insets.getSystemWindowInsetRight(), mOutsetBottomPx);
                return super.dispatchApplyWindowInsets(newInsets);
            } else {
                return super.dispatchApplyWindowInsets(insets);
@@ -2592,12 +2592,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                }
            }

            if (mOutsetBottom != null) {
            if (mOutsetBottomPx != 0) {
                int mode = MeasureSpec.getMode(heightMeasureSpec);
                if (mode != MeasureSpec.UNSPECIFIED) {
                    int outset = (int) mOutsetBottom.getDimension(metrics);
                    int height = MeasureSpec.getSize(heightMeasureSpec);
                    heightMeasureSpec = MeasureSpec.makeMeasureSpec(height + outset, mode);
                    heightMeasureSpec = MeasureSpec.makeMeasureSpec(height + mOutsetBottomPx, mode);
                }
            }

@@ -3472,10 +3471,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            final boolean shouldUseBottomOutset =
                    display.getDisplayId() == Display.DEFAULT_DISPLAY
                            || (getForcedWindowFlags() & FLAG_FULLSCREEN) != 0;
            if (shouldUseBottomOutset && a.hasValue(R.styleable.Window_windowOutsetBottom)) {
                if (mOutsetBottom == null) mOutsetBottom = new TypedValue();
                a.getValue(R.styleable.Window_windowOutsetBottom,
                        mOutsetBottom);
            if (shouldUseBottomOutset) {
                mOutsetBottomPx = ScreenShapeHelper.getWindowOutsetBottomPx(
                        getContext().getResources().getDisplayMetrics(), a);
            }
        }

+6 −13
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
import android.media.AudioManager;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
@@ -77,6 +76,7 @@ import android.widget.Scroller;

import com.android.internal.R;
import com.android.internal.os.SomeArgs;
import com.android.internal.util.ScreenShapeHelper;
import com.android.internal.view.BaseSurfaceHolder;
import com.android.internal.view.RootViewSurfaceTaker;

@@ -120,8 +120,10 @@ public final class ViewRootImpl implements ViewParent,
    private static final String PROPERTY_PROFILE_RENDERING = "viewroot.profile_rendering";
    private static final String PROPERTY_MEDIA_DISABLED = "config.disable_media";

    // property used by emulator to determine display shape
    // properties used by emulator to determine display shape
    public static final String PROPERTY_EMULATOR_CIRCULAR = "ro.emulator.circular";
    public static final String PROPERTY_EMULATOR_WIN_OUTSET_BOTTOM_PX =
            "ro.emu.win_outset_bottom_px";

    /**
     * Maximum time we allow the user to roll the trackball enough to generate
@@ -334,8 +336,6 @@ public final class ViewRootImpl implements ViewParent,
    /** Set to true once doDie() has been called. */
    private boolean mRemoved;

    private boolean mIsEmulator;
    private boolean mIsCircularEmulator;
    private final boolean mWindowIsRound;

    /**
@@ -392,8 +392,7 @@ public final class ViewRootImpl implements ViewParent,
        mChoreographer = Choreographer.getInstance();
        mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE);
        loadSystemProperties();
        mWindowIsRound = context.getResources().getBoolean(
                com.android.internal.R.bool.config_windowIsRound);
        mWindowIsRound = ScreenShapeHelper.getWindowIsRound(context.getResources());
    }

    public static void addFirstDrawHandler(Runnable callback) {
@@ -1248,9 +1247,8 @@ public final class ViewRootImpl implements ViewParent,
                contentInsets = mPendingContentInsets;
                stableInsets = mPendingStableInsets;
            }
            final boolean isRound = (mIsEmulator && mIsCircularEmulator) || mWindowIsRound;
            mLastWindowInsets = new WindowInsets(contentInsets,
                    null /* windowDecorInsets */, stableInsets, isRound);
                    null /* windowDecorInsets */, stableInsets, mWindowIsRound);
        }
        return mLastWindowInsets;
    }
@@ -5590,11 +5588,6 @@ public final class ViewRootImpl implements ViewParent,
                        mHandler.sendEmptyMessageDelayed(MSG_INVALIDATE_WORLD, 200);
                    }
                }

                // detect emulator
                mIsEmulator = Build.HARDWARE.contains("goldfish");
                mIsCircularEmulator =
                        SystemProperties.getBoolean(PROPERTY_EMULATOR_CIRCULAR, false);
            }
        });
    }
+48 −0
Original line number Diff line number Diff line
package com.android.internal.util;

import android.content.res.Resources;
import android.content.res.TypedArray;
import android.os.Build;
import android.os.SystemProperties;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.ViewRootImpl;

import com.android.internal.R;

/**
 * @hide
 */
public class ScreenShapeHelper {
    private static final boolean IS_EMULATOR = Build.HARDWARE.contains("goldfish");

    /**
     * Return the bottom pixel window outset of a window given its style attributes.
     * @param displayMetrics Display metrics of the current device
     * @param windowStyle Window style attributes for the window.
     * @return An outset dimension in pixels or 0 if no outset should be applied.
     */
    public static int getWindowOutsetBottomPx(DisplayMetrics displayMetrics,
            TypedArray windowStyle) {
        if (IS_EMULATOR) {
            return SystemProperties.getInt(ViewRootImpl.PROPERTY_EMULATOR_WIN_OUTSET_BOTTOM_PX, 0);
        } else if (windowStyle.hasValue(R.styleable.Window_windowOutsetBottom)) {
            TypedValue outsetBottom = new TypedValue();
            windowStyle.getValue(R.styleable.Window_windowOutsetBottom, outsetBottom);
            return (int) outsetBottom.getDimension(displayMetrics);
        }
        return 0;
    }

    /**
     * Get whether a device has has a round screen.
     */
    public static boolean getWindowIsRound(Resources resources) {
        if (IS_EMULATOR) {
            return SystemProperties.getBoolean(ViewRootImpl.PROPERTY_EMULATOR_CIRCULAR, false);
        } else {
            return resources.getBoolean(
                    com.android.internal.R.bool.config_windowIsRound);
        }
    }
}