Merge "Allow emulator to select a window outset bottom" into lmp-mr1-modular-dev
This commit is contained in:
@@ -17,15 +17,12 @@
|
|||||||
package android.service.wallpaper;
|
package android.service.wallpaper;
|
||||||
|
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.ViewRootImpl;
|
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
|
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
import com.android.internal.os.HandlerCaller;
|
import com.android.internal.os.HandlerCaller;
|
||||||
|
import com.android.internal.util.ScreenShapeHelper;
|
||||||
import com.android.internal.view.BaseIWindow;
|
import com.android.internal.view.BaseIWindow;
|
||||||
import com.android.internal.view.BaseSurfaceHolder;
|
import com.android.internal.view.BaseSurfaceHolder;
|
||||||
|
|
||||||
@@ -64,8 +61,6 @@ import java.io.FileDescriptor;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wallpaper service is responsible for showing a live wallpaper behind
|
* A wallpaper service is responsible for showing a live wallpaper behind
|
||||||
* applications that would like to sit on top of it. This service object
|
* applications that would like to sit on top of it. This service object
|
||||||
@@ -160,7 +155,7 @@ public abstract class WallpaperService extends Service {
|
|||||||
WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS;
|
WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS;
|
||||||
int mCurWindowFlags = mWindowFlags;
|
int mCurWindowFlags = mWindowFlags;
|
||||||
int mCurWindowPrivateFlags = mWindowPrivateFlags;
|
int mCurWindowPrivateFlags = mWindowPrivateFlags;
|
||||||
TypedValue mOutsetBottom;
|
int mOutsetBottomPx;
|
||||||
final Rect mVisibleInsets = new Rect();
|
final Rect mVisibleInsets = new Rect();
|
||||||
final Rect mWinFrame = new Rect();
|
final Rect mWinFrame = new Rect();
|
||||||
final Rect mOverscanInsets = new Rect();
|
final Rect mOverscanInsets = new Rect();
|
||||||
@@ -173,8 +168,6 @@ public abstract class WallpaperService extends Service {
|
|||||||
final Rect mFinalStableInsets = new Rect();
|
final Rect mFinalStableInsets = new Rect();
|
||||||
final Configuration mConfiguration = new Configuration();
|
final Configuration mConfiguration = new Configuration();
|
||||||
|
|
||||||
private boolean mIsEmulator;
|
|
||||||
private boolean mIsCircularEmulator;
|
|
||||||
private boolean mWindowIsRound;
|
private boolean mWindowIsRound;
|
||||||
|
|
||||||
final WindowManager.LayoutParams mLayout
|
final WindowManager.LayoutParams mLayout
|
||||||
@@ -639,23 +632,13 @@ public abstract class WallpaperService extends Service {
|
|||||||
final Display display = windowService.getDefaultDisplay();
|
final Display display = windowService.getDefaultDisplay();
|
||||||
final boolean shouldUseBottomOutset =
|
final boolean shouldUseBottomOutset =
|
||||||
display.getDisplayId() == Display.DEFAULT_DISPLAY;
|
display.getDisplayId() == Display.DEFAULT_DISPLAY;
|
||||||
if (shouldUseBottomOutset && windowStyle.hasValue(
|
if (shouldUseBottomOutset) {
|
||||||
R.styleable.Window_windowOutsetBottom)) {
|
mOutsetBottomPx = ScreenShapeHelper.getWindowOutsetBottomPx(
|
||||||
if (mOutsetBottom == null) mOutsetBottom = new TypedValue();
|
getResources().getDisplayMetrics(), windowStyle);
|
||||||
windowStyle.getValue(R.styleable.Window_windowOutsetBottom,
|
|
||||||
mOutsetBottom);
|
|
||||||
} else {
|
|
||||||
mOutsetBottom = null;
|
|
||||||
}
|
}
|
||||||
mWindowIsRound = getResources().getBoolean(
|
mWindowIsRound = ScreenShapeHelper.getWindowIsRound(getResources());
|
||||||
com.android.internal.R.bool.config_windowIsRound);
|
|
||||||
windowStyle.recycle();
|
windowStyle.recycle();
|
||||||
|
|
||||||
// detect emulator
|
|
||||||
mIsEmulator = Build.HARDWARE.contains("goldfish");
|
|
||||||
mIsCircularEmulator = SystemProperties.getBoolean(
|
|
||||||
ViewRootImpl.PROPERTY_EMULATOR_CIRCULAR, false);
|
|
||||||
|
|
||||||
// Add window
|
// Add window
|
||||||
mLayout.type = mIWallpaperEngine.mWindowType;
|
mLayout.type = mIWallpaperEngine.mWindowType;
|
||||||
mLayout.gravity = Gravity.START|Gravity.TOP;
|
mLayout.gravity = Gravity.START|Gravity.TOP;
|
||||||
@@ -785,18 +768,14 @@ public abstract class WallpaperService extends Service {
|
|||||||
mDispatchedOverscanInsets.set(mOverscanInsets);
|
mDispatchedOverscanInsets.set(mOverscanInsets);
|
||||||
mDispatchedContentInsets.set(mContentInsets);
|
mDispatchedContentInsets.set(mContentInsets);
|
||||||
mDispatchedStableInsets.set(mStableInsets);
|
mDispatchedStableInsets.set(mStableInsets);
|
||||||
final boolean isRound = (mIsEmulator && mIsCircularEmulator)
|
|
||||||
|| mWindowIsRound;
|
|
||||||
mFinalSystemInsets.set(mDispatchedOverscanInsets);
|
mFinalSystemInsets.set(mDispatchedOverscanInsets);
|
||||||
mFinalStableInsets.set(mDispatchedStableInsets);
|
mFinalStableInsets.set(mDispatchedStableInsets);
|
||||||
if (mOutsetBottom != null) {
|
if (mOutsetBottomPx != 0) {
|
||||||
final DisplayMetrics metrics = getResources().getDisplayMetrics();
|
|
||||||
mFinalSystemInsets.bottom =
|
mFinalSystemInsets.bottom =
|
||||||
( (int) mOutsetBottom.getDimension(metrics) )
|
mIWallpaperEngine.mDisplayPadding.bottom + mOutsetBottomPx;
|
||||||
+ mIWallpaperEngine.mDisplayPadding.bottom;
|
|
||||||
}
|
}
|
||||||
WindowInsets insets = new WindowInsets(mFinalSystemInsets,
|
WindowInsets insets = new WindowInsets(mFinalSystemInsets,
|
||||||
null, mFinalStableInsets, isRound);
|
null, mFinalStableInsets, mWindowIsRound);
|
||||||
onApplyWindowInsets(insets);
|
onApplyWindowInsets(insets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,14 +40,12 @@ import android.hardware.display.DisplayManager;
|
|||||||
import android.hardware.display.DisplayManager.DisplayListener;
|
import android.hardware.display.DisplayManager.DisplayListener;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Debug;
|
import android.os.Debug;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
@@ -78,6 +76,7 @@ import android.widget.Scroller;
|
|||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
import com.android.internal.os.SomeArgs;
|
import com.android.internal.os.SomeArgs;
|
||||||
import com.android.internal.policy.PolicyManager;
|
import com.android.internal.policy.PolicyManager;
|
||||||
|
import com.android.internal.util.ScreenShapeHelper;
|
||||||
import com.android.internal.view.BaseSurfaceHolder;
|
import com.android.internal.view.BaseSurfaceHolder;
|
||||||
import com.android.internal.view.RootViewSurfaceTaker;
|
import com.android.internal.view.RootViewSurfaceTaker;
|
||||||
|
|
||||||
@@ -121,8 +120,10 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
private static final String PROPERTY_PROFILE_RENDERING = "viewroot.profile_rendering";
|
private static final String PROPERTY_PROFILE_RENDERING = "viewroot.profile_rendering";
|
||||||
private static final String PROPERTY_MEDIA_DISABLED = "config.disable_media";
|
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_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
|
* Maximum time we allow the user to roll the trackball enough to generate
|
||||||
@@ -333,8 +334,6 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
/** Set to true once doDie() has been called. */
|
/** Set to true once doDie() has been called. */
|
||||||
private boolean mRemoved;
|
private boolean mRemoved;
|
||||||
|
|
||||||
private boolean mIsEmulator;
|
|
||||||
private boolean mIsCircularEmulator;
|
|
||||||
private final boolean mWindowIsRound;
|
private final boolean mWindowIsRound;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -391,8 +390,7 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
mChoreographer = Choreographer.getInstance();
|
mChoreographer = Choreographer.getInstance();
|
||||||
mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE);
|
mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE);
|
||||||
loadSystemProperties();
|
loadSystemProperties();
|
||||||
mWindowIsRound = context.getResources().getBoolean(
|
mWindowIsRound = ScreenShapeHelper.getWindowIsRound(context.getResources());
|
||||||
com.android.internal.R.bool.config_windowIsRound);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addFirstDrawHandler(Runnable callback) {
|
public static void addFirstDrawHandler(Runnable callback) {
|
||||||
@@ -1224,10 +1222,9 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
void dispatchApplyInsets(View host) {
|
void dispatchApplyInsets(View host) {
|
||||||
mDispatchContentInsets.set(mAttachInfo.mContentInsets);
|
mDispatchContentInsets.set(mAttachInfo.mContentInsets);
|
||||||
mDispatchStableInsets.set(mAttachInfo.mStableInsets);
|
mDispatchStableInsets.set(mAttachInfo.mStableInsets);
|
||||||
final boolean isRound = (mIsEmulator && mIsCircularEmulator) || mWindowIsRound;
|
|
||||||
host.dispatchApplyWindowInsets(new WindowInsets(
|
host.dispatchApplyWindowInsets(new WindowInsets(
|
||||||
mDispatchContentInsets, null /* windowDecorInsets */,
|
mDispatchContentInsets, null /* windowDecorInsets */,
|
||||||
mDispatchStableInsets, isRound));
|
mDispatchStableInsets, mWindowIsRound));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performTraversals() {
|
private void performTraversals() {
|
||||||
@@ -5571,11 +5568,6 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
mHandler.sendEmptyMessageDelayed(MSG_INVALIDATE_WORLD, 200);
|
mHandler.sendEmptyMessageDelayed(MSG_INVALIDATE_WORLD, 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// detect emulator
|
|
||||||
mIsEmulator = Build.HARDWARE.contains("goldfish");
|
|
||||||
mIsCircularEmulator =
|
|
||||||
SystemProperties.getBoolean(PROPERTY_EMULATOR_CIRCULAR, false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
48
core/java/com/android/internal/util/ScreenShapeHelper.java
Normal file
48
core/java/com/android/internal/util/ScreenShapeHelper.java
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,7 @@ import static android.view.WindowManager.LayoutParams.*;
|
|||||||
import android.app.SearchManager;
|
import android.app.SearchManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
|
import com.android.internal.util.ScreenShapeHelper;
|
||||||
import com.android.internal.view.RootViewSurfaceTaker;
|
import com.android.internal.view.RootViewSurfaceTaker;
|
||||||
import com.android.internal.view.StandaloneActionMode;
|
import com.android.internal.view.StandaloneActionMode;
|
||||||
import com.android.internal.view.menu.ContextMenuBuilder;
|
import com.android.internal.view.menu.ContextMenuBuilder;
|
||||||
@@ -61,6 +62,7 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.transition.Scene;
|
import android.transition.Scene;
|
||||||
import android.transition.Transition;
|
import android.transition.Transition;
|
||||||
import android.transition.TransitionInflater;
|
import android.transition.TransitionInflater;
|
||||||
@@ -145,7 +147,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
|||||||
TypedValue mFixedWidthMinor;
|
TypedValue mFixedWidthMinor;
|
||||||
TypedValue mFixedHeightMajor;
|
TypedValue mFixedHeightMajor;
|
||||||
TypedValue mFixedHeightMinor;
|
TypedValue mFixedHeightMinor;
|
||||||
TypedValue mOutsetBottom;
|
int mOutsetBottomPx;
|
||||||
|
|
||||||
// This is the top-level view of the window, containing the window decor.
|
// This is the top-level view of the window, containing the window decor.
|
||||||
private DecorView mDecor;
|
private DecorView mDecor;
|
||||||
@@ -2379,12 +2381,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
|
public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
|
||||||
if (mOutsetBottom != null) {
|
if (mOutsetBottomPx != 0) {
|
||||||
final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
|
|
||||||
int bottom = (int) mOutsetBottom.getDimension(metrics);
|
|
||||||
WindowInsets newInsets = insets.replaceSystemWindowInsets(
|
WindowInsets newInsets = insets.replaceSystemWindowInsets(
|
||||||
insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
|
insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
|
||||||
insets.getSystemWindowInsetRight(), bottom);
|
insets.getSystemWindowInsetRight(), mOutsetBottomPx);
|
||||||
return super.dispatchApplyWindowInsets(newInsets);
|
return super.dispatchApplyWindowInsets(newInsets);
|
||||||
} else {
|
} else {
|
||||||
return super.dispatchApplyWindowInsets(insets);
|
return super.dispatchApplyWindowInsets(insets);
|
||||||
@@ -2603,12 +2603,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mOutsetBottom != null) {
|
if (mOutsetBottomPx != 0) {
|
||||||
int mode = MeasureSpec.getMode(heightMeasureSpec);
|
int mode = MeasureSpec.getMode(heightMeasureSpec);
|
||||||
if (mode != MeasureSpec.UNSPECIFIED) {
|
if (mode != MeasureSpec.UNSPECIFIED) {
|
||||||
int outset = (int) mOutsetBottom.getDimension(metrics);
|
|
||||||
int height = MeasureSpec.getSize(heightMeasureSpec);
|
int height = MeasureSpec.getSize(heightMeasureSpec);
|
||||||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height + outset, mode);
|
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height + mOutsetBottomPx, mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3441,10 +3440,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
|||||||
final boolean shouldUseBottomOutset =
|
final boolean shouldUseBottomOutset =
|
||||||
display.getDisplayId() == Display.DEFAULT_DISPLAY
|
display.getDisplayId() == Display.DEFAULT_DISPLAY
|
||||||
|| (getForcedWindowFlags() & FLAG_FULLSCREEN) != 0;
|
|| (getForcedWindowFlags() & FLAG_FULLSCREEN) != 0;
|
||||||
if (shouldUseBottomOutset && a.hasValue(R.styleable.Window_windowOutsetBottom)) {
|
if (shouldUseBottomOutset) {
|
||||||
if (mOutsetBottom == null) mOutsetBottom = new TypedValue();
|
mOutsetBottomPx = ScreenShapeHelper.getWindowOutsetBottomPx(
|
||||||
a.getValue(R.styleable.Window_windowOutsetBottom,
|
getContext().getResources().getDisplayMetrics(), a);
|
||||||
mOutsetBottom);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user