summaryrefslogtreecommitdiffstats
path: root/core/jni/android_view_Display.cpp
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-12-16 16:37:39 -0800
committerDianne Hackborn <hackbod@google.com>2010-12-18 16:25:29 -0800
commit4c7cc34127efa3308e1a09b28728868911b79789 (patch)
treeb720c14dd1a5fdb52cc832101443740761585af0 /core/jni/android_view_Display.cpp
parentfb1b2317aba98ae1ce82a3feef9de4a8b72e4bf1 (diff)
downloadframeworks_base-4c7cc34127efa3308e1a09b28728868911b79789.zip
frameworks_base-4c7cc34127efa3308e1a09b28728868911b79789.tar.gz
frameworks_base-4c7cc34127efa3308e1a09b28728868911b79789.tar.bz2
Demo hack!
To make a 800 tall screen run like a 720: adb shell setprop persist.demo.screensizehack 800=720 Note this is a persistent property, so it will (intentionally) remain across boots. Change-Id: I8a8a9f937399327444e8fb154b91f0e642db116e
Diffstat (limited to 'core/jni/android_view_Display.cpp')
-rw-r--r--core/jni/android_view_Display.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/core/jni/android_view_Display.cpp b/core/jni/android_view_Display.cpp
index 2e160ae..ac8835a 100644
--- a/core/jni/android_view_Display.cpp
+++ b/core/jni/android_view_Display.cpp
@@ -17,6 +17,8 @@
#include <stdio.h>
#include <assert.h>
+#include <cutils/properties.h>
+
#include <surfaceflinger/SurfaceComposerClient.h>
#include <ui/PixelFormat.h>
#include <ui/DisplayInfo.h>
@@ -24,6 +26,7 @@
#include "jni.h"
#include <android_runtime/AndroidRuntime.h>
#include <utils/misc.h>
+#include <utils/Log.h>
// ----------------------------------------------------------------------------
@@ -41,6 +44,9 @@ struct offsets_t {
};
static offsets_t offsets;
+static int gOldSize = -1;
+static int gNewSize = -1;
+
static void doThrow(JNIEnv* env, const char* exc, const char* msg = NULL)
{
jclass npeClazz = env->FindClass(exc);
@@ -69,14 +75,16 @@ static jint android_view_Display_getWidth(
JNIEnv* env, jobject clazz)
{
DisplayID dpy = env->GetIntField(clazz, offsets.display);
- return SurfaceComposerClient::getDisplayWidth(dpy);
+ jint w = SurfaceComposerClient::getDisplayWidth(dpy);
+ return w == gOldSize ? gNewSize : w;
}
static jint android_view_Display_getHeight(
JNIEnv* env, jobject clazz)
{
DisplayID dpy = env->GetIntField(clazz, offsets.display);
- return SurfaceComposerClient::getDisplayHeight(dpy);
+ int h = SurfaceComposerClient::getDisplayHeight(dpy);
+ return h == gOldSize ? gNewSize : h;
}
static jint android_view_Display_getOrientation(
@@ -92,6 +100,13 @@ static jint android_view_Display_getDisplayCount(
return SurfaceComposerClient::getNumberOfDisplays();
}
+static jint android_view_Display_unmapDisplaySize(
+ JNIEnv* env, jclass clazz, jint newSize)
+{
+ if (newSize == gNewSize) return gOldSize;
+ return newSize;
+}
+
// ----------------------------------------------------------------------------
const char* const kClassPathName = "android/view/Display";
@@ -110,7 +125,9 @@ static JNINativeMethod gMethods[] = {
{ "getHeight", "()I",
(void*)android_view_Display_getHeight },
{ "getOrientation", "()I",
- (void*)android_view_Display_getOrientation }
+ (void*)android_view_Display_getOrientation },
+ { "unmapDisplaySize", "(I)I",
+ (void*)android_view_Display_unmapDisplaySize }
};
void nativeClassInit(JNIEnv* env, jclass clazz)
@@ -125,6 +142,16 @@ 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, "%d=%d", &temp1, &temp2) == 2) {
+ gOldSize = temp1;
+ gNewSize = temp2;
+ }
+ }
+
return AndroidRuntime::registerNativeMethods(env,
kClassPathName, gMethods, NELEM(gMethods));
}