ScreenShapeHelper.java revision 4bb6b751fbbb218e8a298db4aa008472a0aa8d31
1package com.android.internal.util; 2 3import android.content.res.Resources; 4import android.content.res.TypedArray; 5import android.os.Build; 6import android.os.SystemProperties; 7import android.util.DisplayMetrics; 8import android.util.TypedValue; 9import android.view.ViewRootImpl; 10 11import com.android.internal.R; 12 13/** 14 * @hide 15 */ 16public class ScreenShapeHelper { 17 private static final boolean IS_EMULATOR = Build.HARDWARE.contains("goldfish"); 18 19 /** 20 * Return the bottom pixel window outset of a window given its style attributes. 21 * @param displayMetrics Display metrics of the current device 22 * @param windowStyle Window style attributes for the window. 23 * @return An outset dimension in pixels or 0 if no outset should be applied. 24 */ 25 public static int getWindowOutsetBottomPx(DisplayMetrics displayMetrics, 26 TypedArray windowStyle) { 27 if (IS_EMULATOR) { 28 return SystemProperties.getInt(ViewRootImpl.PROPERTY_EMULATOR_WIN_OUTSET_BOTTOM_PX, 0); 29 } else if (windowStyle.hasValue(R.styleable.Window_windowOutsetBottom)) { 30 TypedValue outsetBottom = new TypedValue(); 31 windowStyle.getValue(R.styleable.Window_windowOutsetBottom, outsetBottom); 32 return (int) outsetBottom.getDimension(displayMetrics); 33 } 34 return 0; 35 } 36} 37