Loading core/java/android/view/Display.java +112 −51 Original line number Diff line number Diff line Loading @@ -25,16 +25,18 @@ import android.os.SystemClock; import android.util.DisplayMetrics; import android.util.Slog; /** * Provides information about the display size and density. */ public class Display { static final String TAG = "Display"; static final boolean DEBUG_COMPAT = false; /** * Specify the default Display * The default Display id. */ public static final int DEFAULT_DISPLAY = 0; /** * Use {@link android.view.WindowManager#getDefaultDisplay() * WindowManager.getDefaultDisplay()} to create a Display object. Loading @@ -55,16 +57,6 @@ public class Display { init(display); } /** @hide */ public static void setCompatibilityInfo(CompatibilityInfo compatInfo) { if (compatInfo != null && (compatInfo.isScalingRequired() || !compatInfo.supportsScreen())) { sCompatibilityInfo = compatInfo; } else { sCompatibilityInfo = null; } } /** * Returns the index of this display. This is currently undefined; do * not use. Loading @@ -80,25 +72,29 @@ public class Display { native static int getDisplayCount(); /** * Returns the raw size of the display, in pixels. Note that this * should <em>not</em> generally be used for computing layouts, since * a device will typically have screen decoration (such as a status bar) * Gets the size of the display, in pixels. * <p> * Note that this value should <em>not</em> be used for computing layouts, * since a device will typically have screen decoration (such as a status bar) * along the edges of the display that reduce the amount of application * space available from the raw size returned here. This value is * adjusted for you based on the current rotation of the display. * space available from the size returned here. Layouts should instead use * the window size. * </p><p> * The size is adjusted based on the current rotation of the display. * </p><p> * The size returned by this method does not necessarily represent the * actual raw size (native resolution) of the display. The returned size may * be adjusted to exclude certain system decor elements that are always visible. * It may also be scaled to provide compatibility with older applications that * were originally designed for smaller displays. * </p> * * @param outSize A {@link Point} object to receive the size information. */ public void getSize(Point outSize) { getSizeInternal(outSize, true); } /** * Returns the raw size of the display, in pixels. Note that this * should <em>not</em> generally be used for computing layouts, since * a device will typically have screen decoration (such as a status bar) * along the edges of the display that reduce the amount of application * space available from the raw size returned here. This value is * adjusted for you based on the current rotation of the display. */ private void getSizeInternal(Point outSize, boolean doCompat) { try { IWindowManager wm = getWindowManager(); Loading @@ -118,8 +114,8 @@ public class Display { } else { // This is just for boot-strapping, initializing the // system process before the window manager is up. outSize.x = getRealWidth(); outSize.y = getRealHeight(); outSize.x = getRawWidth(); outSize.y = getRawHeight(); } if (DEBUG_COMPAT && doCompat) Slog.v(TAG, "Returning display size: " + outSize); } catch (RemoteException e) { Loading @@ -128,7 +124,10 @@ public class Display { } /** * This is just easier for some parts of the framework. * Gets the size of the display as a rectangle, in pixels. * * @param outSize A {@link Rect} object to receive the size information. * @see #getSize(Point) */ public void getRectSize(Rect outSize) { synchronized (mTmpPoint) { Loading Loading @@ -182,14 +181,49 @@ public class Display { } } /** @hide Returns the actual screen size, not including any decor. */ native public int getRealWidth(); /** @hide Returns the actual screen size, not including any decor. */ native public int getRealHeight(); /** * Gets the real size of the display without subtracting any window decor or * applying any compatibility scale factors. * <p> * The real size may be smaller than the raw size when the window manager * is emulating a smaller display (using adb shell am display-size). * </p><p> * The size is adjusted based on the current rotation of the display. * </p> * @hide */ public void getRealSize(Point outSize) { try { IWindowManager wm = getWindowManager(); if (wm != null) { wm.getRealDisplaySize(outSize); } else { // This is just for boot-strapping, initializing the // system process before the window manager is up. outSize.x = getRawWidth(); outSize.y = getRawHeight(); } } catch (RemoteException e) { Slog.w("Display", "Unable to get real display size", e); } } /** @hide special for when we are faking the screen size. */ /** * Gets the raw width of the display, in pixels. * <p> * The size is adjusted based on the current rotation of the display. * </p> * @hide */ native public int getRawWidth(); /** @hide special for when we are faking the screen size. */ /** * Gets the raw height of the display, in pixels. * <p> * The size is adjusted based on the current rotation of the display. * </p> * @hide */ native public int getRawHeight(); /** Loading Loading @@ -235,17 +269,24 @@ public class Display { } /** * Initialize a DisplayMetrics object from this display's data. * Gets display metrics that describe the size and density of this display. * <p> * The size is adjusted based on the current rotation of the display. * </p><p> * The size returned by this method does not necessarily represent the * actual raw size (native resolution) of the display. The returned size may * be adjusted to exclude certain system decor elements that are always visible. * It may also be scaled to provide compatibility with older applications that * were originally designed for smaller displays. * </p> * * @param outMetrics * @param outMetrics A {@link DisplayMetrics} object to receive the metrics. */ public void getMetrics(DisplayMetrics outMetrics) { synchronized (mTmpPoint) { getSizeInternal(mTmpPoint, false); outMetrics.widthPixels = mTmpPoint.x; outMetrics.heightPixels = mTmpPoint.y; getMetricsWithSize(outMetrics, mTmpPoint.x, mTmpPoint.y); } getNonSizeMetrics(outMetrics); CompatibilityInfo ci = mCompatibilityInfo.getIfNeeded(); if (ci != null) { Loading @@ -257,22 +298,44 @@ public class Display { } /** * Initialize a DisplayMetrics object from this display's data. * * @param outMetrics * Gets display metrics based on the real size of this display. * @hide */ public void getRealMetrics(DisplayMetrics outMetrics) { outMetrics.widthPixels = getRealWidth(); outMetrics.heightPixels = getRealHeight(); getNonSizeMetrics(outMetrics); synchronized (mTmpPoint) { getRealSize(mTmpPoint); getMetricsWithSize(outMetrics, mTmpPoint.x, mTmpPoint.y); } } /** * If the display is mirrored to an external HDMI display, returns the * width of that display. * @hide */ public int getRawExternalWidth() { return 1280; } /** * If the display is mirrored to an external HDMI display, returns the * height of that display. * @hide */ public int getRawExternalHeight() { return 720; } private void getNonSizeMetrics(DisplayMetrics outMetrics) { /** * Gets display metrics based on an explicit assumed display size. * @hide */ public void getMetricsWithSize(DisplayMetrics outMetrics, int width, int height) { outMetrics.densityDpi = (int)((mDensity*DisplayMetrics.DENSITY_DEFAULT)+.5f); outMetrics.noncompatWidthPixels = outMetrics.widthPixels; outMetrics.noncompatHeightPixels = outMetrics.heightPixels; outMetrics.noncompatWidthPixels = outMetrics.widthPixels = width; outMetrics.noncompatHeightPixels = outMetrics.heightPixels = height; outMetrics.density = outMetrics.noncompatDensity = mDensity; outMetrics.scaledDensity = outMetrics.noncompatScaledDensity = outMetrics.density; Loading Loading @@ -315,8 +378,6 @@ public class Display { private static boolean sInitialized = false; private static IWindowManager sWindowManager; private static volatile CompatibilityInfo sCompatibilityInfo; /** * Returns a display object which uses the metric's width/height instead. * @hide Loading core/java/android/view/IWindowManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ interface IWindowManager boolean inputMethodClientHasFocus(IInputMethodClient client); void getDisplaySize(out Point size); void getRealDisplaySize(out Point size); int getMaximumSizeDimension(); void setForcedDisplaySize(int longDimen, int shortDimen); Loading core/java/android/view/ViewRootImpl.java +8 −4 Original line number Diff line number Diff line Loading @@ -825,8 +825,10 @@ public final class ViewRootImpl extends Handler implements ViewParent, if (lp.type == WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL) { // NOTE -- system code, won't try to do compat mode. Display disp = WindowManagerImpl.getDefault().getDefaultDisplay(); desiredWindowWidth = disp.getRealWidth(); desiredWindowHeight = disp.getRealHeight(); Point size = new Point(); disp.getRealSize(size); desiredWindowWidth = size.x; desiredWindowHeight = size.y; } else { DisplayMetrics packageMetrics = mView.getContext().getResources().getDisplayMetrics(); Loading Loading @@ -980,8 +982,10 @@ public final class ViewRootImpl extends Handler implements ViewParent, if (lp.type == WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL) { // NOTE -- system code, won't try to do compat mode. Display disp = WindowManagerImpl.getDefault().getDefaultDisplay(); desiredWindowWidth = disp.getRealWidth(); desiredWindowHeight = disp.getRealHeight(); Point size = new Point(); disp.getRealSize(size); desiredWindowWidth = size.x; desiredWindowHeight = size.y; } else { DisplayMetrics packageMetrics = res.getDisplayMetrics(); desiredWindowWidth = packageMetrics.widthPixels; Loading core/jni/android_view_Display.cpp +0 −51 Original line number Diff line number Diff line Loading @@ -45,11 +45,6 @@ struct offsets_t { }; static offsets_t offsets; static int gShortSize = -1; static int gLongSize = -1; static int gOldSize = -1; static int gNewSize = -1; // ---------------------------------------------------------------------------- static void android_view_Display_init( Loading @@ -68,30 +63,6 @@ static void android_view_Display_init( env->SetFloatField(clazz, offsets.ydpi, info.ydpi); } static jint android_view_Display_getWidth( JNIEnv* env, jobject clazz) { DisplayID dpy = env->GetIntField(clazz, offsets.display); jint w = SurfaceComposerClient::getDisplayWidth(dpy); if (gShortSize > 0) { jint h = SurfaceComposerClient::getDisplayHeight(dpy); return w < h ? gShortSize : gLongSize; } return w == gOldSize ? gNewSize : w; } static jint android_view_Display_getHeight( JNIEnv* env, jobject clazz) { DisplayID dpy = env->GetIntField(clazz, offsets.display); int h = SurfaceComposerClient::getDisplayHeight(dpy); if (gShortSize > 0) { jint w = SurfaceComposerClient::getDisplayWidth(dpy); return h < w ? gShortSize : gLongSize; } return h == gOldSize ? gNewSize : h; } static jint android_view_Display_getRawWidth( JNIEnv* env, jobject clazz) { Loading Loading @@ -132,10 +103,6 @@ static JNINativeMethod gMethods[] = { (void*)android_view_Display_getDisplayCount }, { "init", "(I)V", (void*)android_view_Display_init }, { "getRealWidth", "()I", (void*)android_view_Display_getWidth }, { "getRealHeight", "()I", (void*)android_view_Display_getHeight }, { "getRawWidth", "()I", (void*)android_view_Display_getRawWidth }, { "getRawHeight", "()I", Loading @@ -156,24 +123,6 @@ void nativeClassInit(JNIEnv* env, jclass clazz) int register_android_view_Display(JNIEnv* env) { char buf[PROPERTY_VALUE_MAX]; int len = property_get("persist.demo.screensizehack", buf, ""); if (len > 0) { int temp1, temp2; if (sscanf(buf, "%dx%d", &temp1, &temp2) == 2) { if (temp1 < temp2) { gShortSize = temp1; gLongSize = temp2; } else { gShortSize = temp2; gLongSize = temp1; } } else if (sscanf(buf, "%d=%d", &temp1, &temp2) == 2) { gOldSize = temp1; gNewSize = temp2; } } return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); } Loading packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java +16 −6 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.content.IntentFilter; import android.content.res.Resources; import android.util.DisplayMetrics; import android.util.Slog; import android.view.View; import android.view.Display; import android.view.WindowManager; import android.view.WindowManagerImpl; import android.view.WindowManagerPolicy; Loading @@ -41,6 +41,7 @@ public class HeightReceiver extends BroadcastReceiver { ArrayList<OnBarHeightChangedListener> mListeners = new ArrayList<OnBarHeightChangedListener>(); WindowManager mWindowManager; int mHeight; boolean mPlugged; public HeightReceiver(Context context) { mContext = context; Loading Loading @@ -71,15 +72,24 @@ public class HeightReceiver extends BroadcastReceiver { } private void setPlugged(boolean plugged) { mPlugged = plugged; updateHeight(); } public void updateHeight() { final Resources res = mContext.getResources(); int height = -1; if (plugged) { if (mPlugged) { final DisplayMetrics metrics = new DisplayMetrics(); mWindowManager.getDefaultDisplay().getRealMetrics(metrics); //Slog.i(TAG, "setPlugged: display metrics=" + metrics); Display display = mWindowManager.getDefaultDisplay(); display.getRealMetrics(metrics); //Slog.i(TAG, "updateHeight: display metrics=" + metrics); final int shortSide = Math.min(metrics.widthPixels, metrics.heightPixels); height = shortSide - 720; final int externalShortSide = Math.min(display.getRawExternalWidth(), display.getRawExternalHeight()); height = shortSide - externalShortSide; } final int minHeight Loading @@ -87,7 +97,7 @@ public class HeightReceiver extends BroadcastReceiver { if (height < minHeight) { height = minHeight; } Slog.i(TAG, "Resizing status bar plugged=" + plugged + " height=" Slog.i(TAG, "Resizing status bar plugged=" + mPlugged + " height=" + height + " old=" + mHeight); mHeight = height; Loading Loading
core/java/android/view/Display.java +112 −51 Original line number Diff line number Diff line Loading @@ -25,16 +25,18 @@ import android.os.SystemClock; import android.util.DisplayMetrics; import android.util.Slog; /** * Provides information about the display size and density. */ public class Display { static final String TAG = "Display"; static final boolean DEBUG_COMPAT = false; /** * Specify the default Display * The default Display id. */ public static final int DEFAULT_DISPLAY = 0; /** * Use {@link android.view.WindowManager#getDefaultDisplay() * WindowManager.getDefaultDisplay()} to create a Display object. Loading @@ -55,16 +57,6 @@ public class Display { init(display); } /** @hide */ public static void setCompatibilityInfo(CompatibilityInfo compatInfo) { if (compatInfo != null && (compatInfo.isScalingRequired() || !compatInfo.supportsScreen())) { sCompatibilityInfo = compatInfo; } else { sCompatibilityInfo = null; } } /** * Returns the index of this display. This is currently undefined; do * not use. Loading @@ -80,25 +72,29 @@ public class Display { native static int getDisplayCount(); /** * Returns the raw size of the display, in pixels. Note that this * should <em>not</em> generally be used for computing layouts, since * a device will typically have screen decoration (such as a status bar) * Gets the size of the display, in pixels. * <p> * Note that this value should <em>not</em> be used for computing layouts, * since a device will typically have screen decoration (such as a status bar) * along the edges of the display that reduce the amount of application * space available from the raw size returned here. This value is * adjusted for you based on the current rotation of the display. * space available from the size returned here. Layouts should instead use * the window size. * </p><p> * The size is adjusted based on the current rotation of the display. * </p><p> * The size returned by this method does not necessarily represent the * actual raw size (native resolution) of the display. The returned size may * be adjusted to exclude certain system decor elements that are always visible. * It may also be scaled to provide compatibility with older applications that * were originally designed for smaller displays. * </p> * * @param outSize A {@link Point} object to receive the size information. */ public void getSize(Point outSize) { getSizeInternal(outSize, true); } /** * Returns the raw size of the display, in pixels. Note that this * should <em>not</em> generally be used for computing layouts, since * a device will typically have screen decoration (such as a status bar) * along the edges of the display that reduce the amount of application * space available from the raw size returned here. This value is * adjusted for you based on the current rotation of the display. */ private void getSizeInternal(Point outSize, boolean doCompat) { try { IWindowManager wm = getWindowManager(); Loading @@ -118,8 +114,8 @@ public class Display { } else { // This is just for boot-strapping, initializing the // system process before the window manager is up. outSize.x = getRealWidth(); outSize.y = getRealHeight(); outSize.x = getRawWidth(); outSize.y = getRawHeight(); } if (DEBUG_COMPAT && doCompat) Slog.v(TAG, "Returning display size: " + outSize); } catch (RemoteException e) { Loading @@ -128,7 +124,10 @@ public class Display { } /** * This is just easier for some parts of the framework. * Gets the size of the display as a rectangle, in pixels. * * @param outSize A {@link Rect} object to receive the size information. * @see #getSize(Point) */ public void getRectSize(Rect outSize) { synchronized (mTmpPoint) { Loading Loading @@ -182,14 +181,49 @@ public class Display { } } /** @hide Returns the actual screen size, not including any decor. */ native public int getRealWidth(); /** @hide Returns the actual screen size, not including any decor. */ native public int getRealHeight(); /** * Gets the real size of the display without subtracting any window decor or * applying any compatibility scale factors. * <p> * The real size may be smaller than the raw size when the window manager * is emulating a smaller display (using adb shell am display-size). * </p><p> * The size is adjusted based on the current rotation of the display. * </p> * @hide */ public void getRealSize(Point outSize) { try { IWindowManager wm = getWindowManager(); if (wm != null) { wm.getRealDisplaySize(outSize); } else { // This is just for boot-strapping, initializing the // system process before the window manager is up. outSize.x = getRawWidth(); outSize.y = getRawHeight(); } } catch (RemoteException e) { Slog.w("Display", "Unable to get real display size", e); } } /** @hide special for when we are faking the screen size. */ /** * Gets the raw width of the display, in pixels. * <p> * The size is adjusted based on the current rotation of the display. * </p> * @hide */ native public int getRawWidth(); /** @hide special for when we are faking the screen size. */ /** * Gets the raw height of the display, in pixels. * <p> * The size is adjusted based on the current rotation of the display. * </p> * @hide */ native public int getRawHeight(); /** Loading Loading @@ -235,17 +269,24 @@ public class Display { } /** * Initialize a DisplayMetrics object from this display's data. * Gets display metrics that describe the size and density of this display. * <p> * The size is adjusted based on the current rotation of the display. * </p><p> * The size returned by this method does not necessarily represent the * actual raw size (native resolution) of the display. The returned size may * be adjusted to exclude certain system decor elements that are always visible. * It may also be scaled to provide compatibility with older applications that * were originally designed for smaller displays. * </p> * * @param outMetrics * @param outMetrics A {@link DisplayMetrics} object to receive the metrics. */ public void getMetrics(DisplayMetrics outMetrics) { synchronized (mTmpPoint) { getSizeInternal(mTmpPoint, false); outMetrics.widthPixels = mTmpPoint.x; outMetrics.heightPixels = mTmpPoint.y; getMetricsWithSize(outMetrics, mTmpPoint.x, mTmpPoint.y); } getNonSizeMetrics(outMetrics); CompatibilityInfo ci = mCompatibilityInfo.getIfNeeded(); if (ci != null) { Loading @@ -257,22 +298,44 @@ public class Display { } /** * Initialize a DisplayMetrics object from this display's data. * * @param outMetrics * Gets display metrics based on the real size of this display. * @hide */ public void getRealMetrics(DisplayMetrics outMetrics) { outMetrics.widthPixels = getRealWidth(); outMetrics.heightPixels = getRealHeight(); getNonSizeMetrics(outMetrics); synchronized (mTmpPoint) { getRealSize(mTmpPoint); getMetricsWithSize(outMetrics, mTmpPoint.x, mTmpPoint.y); } } /** * If the display is mirrored to an external HDMI display, returns the * width of that display. * @hide */ public int getRawExternalWidth() { return 1280; } /** * If the display is mirrored to an external HDMI display, returns the * height of that display. * @hide */ public int getRawExternalHeight() { return 720; } private void getNonSizeMetrics(DisplayMetrics outMetrics) { /** * Gets display metrics based on an explicit assumed display size. * @hide */ public void getMetricsWithSize(DisplayMetrics outMetrics, int width, int height) { outMetrics.densityDpi = (int)((mDensity*DisplayMetrics.DENSITY_DEFAULT)+.5f); outMetrics.noncompatWidthPixels = outMetrics.widthPixels; outMetrics.noncompatHeightPixels = outMetrics.heightPixels; outMetrics.noncompatWidthPixels = outMetrics.widthPixels = width; outMetrics.noncompatHeightPixels = outMetrics.heightPixels = height; outMetrics.density = outMetrics.noncompatDensity = mDensity; outMetrics.scaledDensity = outMetrics.noncompatScaledDensity = outMetrics.density; Loading Loading @@ -315,8 +378,6 @@ public class Display { private static boolean sInitialized = false; private static IWindowManager sWindowManager; private static volatile CompatibilityInfo sCompatibilityInfo; /** * Returns a display object which uses the metric's width/height instead. * @hide Loading
core/java/android/view/IWindowManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ interface IWindowManager boolean inputMethodClientHasFocus(IInputMethodClient client); void getDisplaySize(out Point size); void getRealDisplaySize(out Point size); int getMaximumSizeDimension(); void setForcedDisplaySize(int longDimen, int shortDimen); Loading
core/java/android/view/ViewRootImpl.java +8 −4 Original line number Diff line number Diff line Loading @@ -825,8 +825,10 @@ public final class ViewRootImpl extends Handler implements ViewParent, if (lp.type == WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL) { // NOTE -- system code, won't try to do compat mode. Display disp = WindowManagerImpl.getDefault().getDefaultDisplay(); desiredWindowWidth = disp.getRealWidth(); desiredWindowHeight = disp.getRealHeight(); Point size = new Point(); disp.getRealSize(size); desiredWindowWidth = size.x; desiredWindowHeight = size.y; } else { DisplayMetrics packageMetrics = mView.getContext().getResources().getDisplayMetrics(); Loading Loading @@ -980,8 +982,10 @@ public final class ViewRootImpl extends Handler implements ViewParent, if (lp.type == WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL) { // NOTE -- system code, won't try to do compat mode. Display disp = WindowManagerImpl.getDefault().getDefaultDisplay(); desiredWindowWidth = disp.getRealWidth(); desiredWindowHeight = disp.getRealHeight(); Point size = new Point(); disp.getRealSize(size); desiredWindowWidth = size.x; desiredWindowHeight = size.y; } else { DisplayMetrics packageMetrics = res.getDisplayMetrics(); desiredWindowWidth = packageMetrics.widthPixels; Loading
core/jni/android_view_Display.cpp +0 −51 Original line number Diff line number Diff line Loading @@ -45,11 +45,6 @@ struct offsets_t { }; static offsets_t offsets; static int gShortSize = -1; static int gLongSize = -1; static int gOldSize = -1; static int gNewSize = -1; // ---------------------------------------------------------------------------- static void android_view_Display_init( Loading @@ -68,30 +63,6 @@ static void android_view_Display_init( env->SetFloatField(clazz, offsets.ydpi, info.ydpi); } static jint android_view_Display_getWidth( JNIEnv* env, jobject clazz) { DisplayID dpy = env->GetIntField(clazz, offsets.display); jint w = SurfaceComposerClient::getDisplayWidth(dpy); if (gShortSize > 0) { jint h = SurfaceComposerClient::getDisplayHeight(dpy); return w < h ? gShortSize : gLongSize; } return w == gOldSize ? gNewSize : w; } static jint android_view_Display_getHeight( JNIEnv* env, jobject clazz) { DisplayID dpy = env->GetIntField(clazz, offsets.display); int h = SurfaceComposerClient::getDisplayHeight(dpy); if (gShortSize > 0) { jint w = SurfaceComposerClient::getDisplayWidth(dpy); return h < w ? gShortSize : gLongSize; } return h == gOldSize ? gNewSize : h; } static jint android_view_Display_getRawWidth( JNIEnv* env, jobject clazz) { Loading Loading @@ -132,10 +103,6 @@ static JNINativeMethod gMethods[] = { (void*)android_view_Display_getDisplayCount }, { "init", "(I)V", (void*)android_view_Display_init }, { "getRealWidth", "()I", (void*)android_view_Display_getWidth }, { "getRealHeight", "()I", (void*)android_view_Display_getHeight }, { "getRawWidth", "()I", (void*)android_view_Display_getRawWidth }, { "getRawHeight", "()I", Loading @@ -156,24 +123,6 @@ void nativeClassInit(JNIEnv* env, jclass clazz) int register_android_view_Display(JNIEnv* env) { char buf[PROPERTY_VALUE_MAX]; int len = property_get("persist.demo.screensizehack", buf, ""); if (len > 0) { int temp1, temp2; if (sscanf(buf, "%dx%d", &temp1, &temp2) == 2) { if (temp1 < temp2) { gShortSize = temp1; gLongSize = temp2; } else { gShortSize = temp2; gLongSize = temp1; } } else if (sscanf(buf, "%d=%d", &temp1, &temp2) == 2) { gOldSize = temp1; gNewSize = temp2; } } return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java +16 −6 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.content.IntentFilter; import android.content.res.Resources; import android.util.DisplayMetrics; import android.util.Slog; import android.view.View; import android.view.Display; import android.view.WindowManager; import android.view.WindowManagerImpl; import android.view.WindowManagerPolicy; Loading @@ -41,6 +41,7 @@ public class HeightReceiver extends BroadcastReceiver { ArrayList<OnBarHeightChangedListener> mListeners = new ArrayList<OnBarHeightChangedListener>(); WindowManager mWindowManager; int mHeight; boolean mPlugged; public HeightReceiver(Context context) { mContext = context; Loading Loading @@ -71,15 +72,24 @@ public class HeightReceiver extends BroadcastReceiver { } private void setPlugged(boolean plugged) { mPlugged = plugged; updateHeight(); } public void updateHeight() { final Resources res = mContext.getResources(); int height = -1; if (plugged) { if (mPlugged) { final DisplayMetrics metrics = new DisplayMetrics(); mWindowManager.getDefaultDisplay().getRealMetrics(metrics); //Slog.i(TAG, "setPlugged: display metrics=" + metrics); Display display = mWindowManager.getDefaultDisplay(); display.getRealMetrics(metrics); //Slog.i(TAG, "updateHeight: display metrics=" + metrics); final int shortSide = Math.min(metrics.widthPixels, metrics.heightPixels); height = shortSide - 720; final int externalShortSide = Math.min(display.getRawExternalWidth(), display.getRawExternalHeight()); height = shortSide - externalShortSide; } final int minHeight Loading @@ -87,7 +97,7 @@ public class HeightReceiver extends BroadcastReceiver { if (height < minHeight) { height = minHeight; } Slog.i(TAG, "Resizing status bar plugged=" + plugged + " height=" Slog.i(TAG, "Resizing status bar plugged=" + mPlugged + " height=" + height + " old=" + mHeight); mHeight = height; Loading