From 297abcadcb3005b0765987a5f3aedfed4d67f1c1 Mon Sep 17 00:00:00 2001 From: Dima Zavin Date: Wed, 21 Mar 2012 23:37:46 -0700 Subject: [PATCH 1/7] displayhardware: fix not obeying ro.sf.lcd_density when specified Change-Id: I71efd6aebfdb0323b07327f5e448a5cb5eb0fad6 Signed-off-by: Dima Zavin --- .../DisplayHardware/DisplayHardware.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp index 3a0ff7156..92d619d5b 100644 --- a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp +++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp @@ -245,27 +245,33 @@ void DisplayHardware::init(uint32_t dpy) mFlags |= BUFFER_PRESERVED; } } - + + /* use the xdpi as our density baseline */ + mDensity = mDpiX; + /* Read density from build-specific ro.sf.lcd_density property * except if it is overridden by qemu.sf.lcd_density. */ if (property_get("qemu.sf.lcd_density", property, NULL) <= 0) { if (property_get("ro.sf.lcd_density", property, NULL) <= 0) { if (mDpiX && mDpiY) { - ALOGI("Using density info from display: xdpi=%d ydpi=%d\n", + ALOGI("Using density info from display: xdpi=%.1f ydpi=%.1f\n", mDpiX, mDpiY); } else { ALOGW("No display dpi and ro.sf.lcd_density not defined, using 160 dpi by default."); - mDpiX = mDpiY = 160; + mDpiX = mDpiY = mDensity = 160; } + } else { + /* force density to what the build requested */ + mDensity = atoi(property); } } else { /* for the emulator case, reset the dpi values too */ - mDpiX = mDpiY = atoi(property); + mDpiX = mDpiY = mDensity = atoi(property); } - /* use the xdpi as our density baseline */ - mDensity = mDpiX * (1.0f / 160.0f); + /* set the actual density scale */ + mDensity *= (1.0f / 160.0f); /* * Create our OpenGL ES context From 0fddef34af3d74b6fa12a540a1b17eda18a8a6a9 Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Fri, 6 Apr 2012 09:31:28 -0700 Subject: [PATCH 2/7] Ensure that /data/anr/traces.txt is world-writable The umask changed for init. We have to force /data/anr to be world readble and /data/anr/traces.txt to be world writable so dalvik processes can write to it. Hopefully this is a short term change while we investigate tightening up these permissions. Bug: 6300296 Change-Id: Iacb4c9f1bc69d2ac679697f9cf9a52694f888489 --- cmds/dumpstate/utils.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c index 0d5ab9019..25505f818 100644 --- a/cmds/dumpstate/utils.c +++ b/cmds/dumpstate/utils.c @@ -375,6 +375,7 @@ const char *dump_vm_traces() { *slash = '\0'; if (!mkdir(anr_traces_dir, 0775)) { chown(anr_traces_dir, AID_SYSTEM, AID_SYSTEM); + chmod(anr_traces_dir, 0775); } else if (errno != EEXIST) { fprintf(stderr, "mkdir(%s): %s\n", anr_traces_dir, strerror(errno)); return NULL; @@ -387,6 +388,12 @@ const char *dump_vm_traces() { fprintf(stderr, "%s: %s\n", traces_path, strerror(errno)); return NULL; } + int chmod_ret = fchmod(fd, 0666); + if (chmod_ret < 0) { + fprintf(stderr, "fchmod on %s failed: %s\n", traces_path, strerror(errno)); + close(fd); + return NULL; + } close(fd); /* walk /proc and kill -QUIT all Dalvik processes */ From 9d188b0bc22d10b3f8eaf7fa850d5ed5a0b16ce1 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Wed, 11 Apr 2012 12:25:47 -0700 Subject: [PATCH 3/7] Add sdcard_r group to dumpstate. Bug: 6321962 Change-Id: I318cd88493396f3d8adb5d4d0fc7a12ee40ba737 --- cmds/dumpstate/dumpstate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index aa95b354a..dd015c690 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -358,7 +358,8 @@ int main(int argc, char *argv[]) { } /* switch to non-root user and group */ - gid_t groups[] = { AID_LOG, AID_SDCARD_RW, AID_MOUNT, AID_INET, AID_NET_BW_STATS }; + gid_t groups[] = { AID_LOG, AID_SDCARD_R, AID_SDCARD_RW, + AID_MOUNT, AID_INET, AID_NET_BW_STATS }; if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) { ALOGE("Unable to setgroups, aborting: %s\n", strerror(errno)); return -1; From 5f0878835093eb6286ef006bb9f5707a83a7be74 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 13 Apr 2012 16:18:55 -0700 Subject: [PATCH 4/7] make sure to repaint the screen when screen turns on Bug: 6336168 Change-Id: Ic6f11b6bf6c3d849f5cb6ac95961d10d7f88e4ec --- services/surfaceflinger/SurfaceFlinger.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index ce6c4a060..fb0c30520 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1471,15 +1471,14 @@ void SurfaceFlinger::onScreenAcquired() { // this is a temporary work-around, eventually this should be called // by the power-manager SurfaceFlinger::turnElectronBeamOn(mElectronBeamAnimationMode); - mDirtyRegion.set(hw.bounds()); // from this point on, SF will process updates again + repaintEverything(); } void SurfaceFlinger::onScreenReleased() { const DisplayHardware& hw(graphicPlane(0).displayHardware()); if (hw.isScreenAcquired()) { mEventThread->onScreenReleased(); - mDirtyRegion.set(hw.bounds()); hw.releaseScreen(); // from this point on, SF will stop drawing } From a17aea117eb1f449d5f50d7f4cc9cc42feae0ad6 Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Thu, 10 May 2012 15:50:19 -0700 Subject: [PATCH 5/7] Workaround for add_tid_to_cgroup failed to write Bug: 6467109 Change-Id: I6dff8e608d83c7a7c453c25c94ad100f113769b9 --- libs/utils/Threads.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/utils/Threads.cpp b/libs/utils/Threads.cpp index bc1c285f3..a25a81fbe 100644 --- a/libs/utils/Threads.cpp +++ b/libs/utils/Threads.cpp @@ -101,8 +101,10 @@ struct thread_data_t { if (gDoSchedulingGroup) { if (prio >= ANDROID_PRIORITY_BACKGROUND) { set_sched_policy(androidGetTid(), SP_BACKGROUND); - } else { + } else if (prio > ANDROID_PRIORITY_AUDIO) { set_sched_policy(androidGetTid(), SP_FOREGROUND); + } else { + // defaults to that of parent, or as set by requestPriority() } } From dd912baf1c4eaafed50d97e6381f9d5093e8c11e Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Thu, 10 May 2012 02:22:33 -0700 Subject: [PATCH 6/7] libgui: improve some logging and dumping This change updates some of the SurfaceTextureClient and BufferQueue logging and dumping to include the crop, transform and scaling mode. It also removes the uses of the NO_SCALE_CROP scaling mode enum, which was added by accident in a previous change. Change-Id: I62912716a1e48885fb22f12b92678aa13f10fcd9 Bug: 6470541 --- libs/gui/BufferQueue.cpp | 21 ++++++++++++++++----- libs/gui/SurfaceTextureClient.cpp | 9 ++++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp index e53162ba4..2d7c89b84 100644 --- a/libs/gui/BufferQueue.cpp +++ b/libs/gui/BufferQueue.cpp @@ -72,6 +72,15 @@ static int32_t createProcessUniqueId() { return android_atomic_inc(&globalCounter); } +static const char* scalingModeName(int scalingMode) { + switch (scalingMode) { + case NATIVE_WINDOW_SCALING_MODE_FREEZE: return "FREEZE"; + case NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW: return "SCALE_TO_WINDOW"; + case NATIVE_WINDOW_SCALING_MODE_SCALE_CROP: return "SCALE_CROP"; + default: return "Unknown"; + } +} + BufferQueue::BufferQueue( bool allowSynchronousMode, int bufferCount ) : mDefaultWidth(1), mDefaultHeight(1), @@ -543,8 +552,10 @@ status_t BufferQueue::queueBuffer(int buf, input.deflate(×tamp, &crop, &scalingMode, &transform); - ST_LOGV("queueBuffer: slot=%d time=%lld crop=[%d,%d,%d,%d]", - buf, timestamp, crop.left, crop.top, crop.right, crop.bottom); + ST_LOGV("queueBuffer: slot=%d time=%#llx crop=[%d,%d,%d,%d] tr=%#x " + "scale=%s", + buf, timestamp, crop.left, crop.top, crop.right, crop.bottom, + transform, scalingModeName(scalingMode)); sp listener; @@ -611,7 +622,6 @@ status_t BufferQueue::queueBuffer(int buf, case NATIVE_WINDOW_SCALING_MODE_FREEZE: case NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW: case NATIVE_WINDOW_SCALING_MODE_SCALE_CROP: - case NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP: break; default: ST_LOGE("unknown scaling mode: %d (ignoring)", scalingMode); @@ -796,11 +806,12 @@ void BufferQueue::dump(String8& result, const char* prefix, snprintf(buffer, SIZE, "%s%s[%02d] " "state=%-8s, crop=[%d,%d,%d,%d], " - "transform=0x%02x, timestamp=%lld", + "xform=0x%02x, time=%#llx, scale=%s", prefix, (slot.mBufferState == BufferSlot::ACQUIRED)?">":" ", i, stateName(slot.mBufferState), slot.mCrop.left, slot.mCrop.top, slot.mCrop.right, - slot.mCrop.bottom, slot.mTransform, slot.mTimestamp + slot.mCrop.bottom, slot.mTransform, slot.mTimestamp, + scalingModeName(slot.mScalingMode) ); result.append(buffer); diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp index 9c3e28db3..5d3bd1a1c 100644 --- a/libs/gui/SurfaceTextureClient.cpp +++ b/libs/gui/SurfaceTextureClient.cpp @@ -522,7 +522,6 @@ int SurfaceTextureClient::setUsage(uint32_t reqUsage) int SurfaceTextureClient::setCrop(Rect const* rect) { ATRACE_CALL(); - ALOGV("SurfaceTextureClient::setCrop"); Rect realRect; if (rect == NULL || rect->isEmpty()) { @@ -531,6 +530,9 @@ int SurfaceTextureClient::setCrop(Rect const* rect) realRect = *rect; } + ALOGV("SurfaceTextureClient::setCrop rect=[%d %d %d %d]", + realRect.left, realRect.top, realRect.right, realRect.bottom); + Mutex::Autolock lock(mMutex); mCrop = realRect; mCropNeedsTransform = false; @@ -540,7 +542,6 @@ int SurfaceTextureClient::setCrop(Rect const* rect) int SurfaceTextureClient::setPostTransformCrop(Rect const* rect) { ATRACE_CALL(); - ALOGV("SurfaceTextureClient::setPostTransformCrop"); Rect realRect; if (rect == NULL || rect->isEmpty()) { @@ -549,6 +550,9 @@ int SurfaceTextureClient::setPostTransformCrop(Rect const* rect) realRect = *rect; } + ALOGV("SurfaceTextureClient::setPostTransformCrop rect=[%d %d %d %d]", + realRect.left, realRect.top, realRect.right, realRect.bottom); + Mutex::Autolock lock(mMutex); mCrop = realRect; mCropNeedsTransform = true; @@ -627,7 +631,6 @@ int SurfaceTextureClient::setScalingMode(int mode) case NATIVE_WINDOW_SCALING_MODE_FREEZE: case NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW: case NATIVE_WINDOW_SCALING_MODE_SCALE_CROP: - case NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP: break; default: ALOGE("unknown scaling mode: %d", mode); From 322495411d8fb0953be6e0a2f14fc76a2c760557 Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Thu, 10 May 2012 02:22:33 -0700 Subject: [PATCH 7/7] libgui: improve some logging and dumping This change updates some of the SurfaceTextureClient and BufferQueue logging and dumping to include the crop, transform and scaling mode. It also removes the uses of the NO_SCALE_CROP scaling mode enum, which was added by accident in a previous change. Change-Id: I62912716a1e48885fb22f12b92678aa13f10fcd9 Bug: 6470541 --- libs/gui/BufferQueue.cpp | 21 ++++++++++++++++----- libs/gui/SurfaceTextureClient.cpp | 9 ++++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp index e53162ba4..2d7c89b84 100644 --- a/libs/gui/BufferQueue.cpp +++ b/libs/gui/BufferQueue.cpp @@ -72,6 +72,15 @@ static int32_t createProcessUniqueId() { return android_atomic_inc(&globalCounter); } +static const char* scalingModeName(int scalingMode) { + switch (scalingMode) { + case NATIVE_WINDOW_SCALING_MODE_FREEZE: return "FREEZE"; + case NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW: return "SCALE_TO_WINDOW"; + case NATIVE_WINDOW_SCALING_MODE_SCALE_CROP: return "SCALE_CROP"; + default: return "Unknown"; + } +} + BufferQueue::BufferQueue( bool allowSynchronousMode, int bufferCount ) : mDefaultWidth(1), mDefaultHeight(1), @@ -543,8 +552,10 @@ status_t BufferQueue::queueBuffer(int buf, input.deflate(×tamp, &crop, &scalingMode, &transform); - ST_LOGV("queueBuffer: slot=%d time=%lld crop=[%d,%d,%d,%d]", - buf, timestamp, crop.left, crop.top, crop.right, crop.bottom); + ST_LOGV("queueBuffer: slot=%d time=%#llx crop=[%d,%d,%d,%d] tr=%#x " + "scale=%s", + buf, timestamp, crop.left, crop.top, crop.right, crop.bottom, + transform, scalingModeName(scalingMode)); sp listener; @@ -611,7 +622,6 @@ status_t BufferQueue::queueBuffer(int buf, case NATIVE_WINDOW_SCALING_MODE_FREEZE: case NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW: case NATIVE_WINDOW_SCALING_MODE_SCALE_CROP: - case NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP: break; default: ST_LOGE("unknown scaling mode: %d (ignoring)", scalingMode); @@ -796,11 +806,12 @@ void BufferQueue::dump(String8& result, const char* prefix, snprintf(buffer, SIZE, "%s%s[%02d] " "state=%-8s, crop=[%d,%d,%d,%d], " - "transform=0x%02x, timestamp=%lld", + "xform=0x%02x, time=%#llx, scale=%s", prefix, (slot.mBufferState == BufferSlot::ACQUIRED)?">":" ", i, stateName(slot.mBufferState), slot.mCrop.left, slot.mCrop.top, slot.mCrop.right, - slot.mCrop.bottom, slot.mTransform, slot.mTimestamp + slot.mCrop.bottom, slot.mTransform, slot.mTimestamp, + scalingModeName(slot.mScalingMode) ); result.append(buffer); diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp index 9c3e28db3..5d3bd1a1c 100644 --- a/libs/gui/SurfaceTextureClient.cpp +++ b/libs/gui/SurfaceTextureClient.cpp @@ -522,7 +522,6 @@ int SurfaceTextureClient::setUsage(uint32_t reqUsage) int SurfaceTextureClient::setCrop(Rect const* rect) { ATRACE_CALL(); - ALOGV("SurfaceTextureClient::setCrop"); Rect realRect; if (rect == NULL || rect->isEmpty()) { @@ -531,6 +530,9 @@ int SurfaceTextureClient::setCrop(Rect const* rect) realRect = *rect; } + ALOGV("SurfaceTextureClient::setCrop rect=[%d %d %d %d]", + realRect.left, realRect.top, realRect.right, realRect.bottom); + Mutex::Autolock lock(mMutex); mCrop = realRect; mCropNeedsTransform = false; @@ -540,7 +542,6 @@ int SurfaceTextureClient::setCrop(Rect const* rect) int SurfaceTextureClient::setPostTransformCrop(Rect const* rect) { ATRACE_CALL(); - ALOGV("SurfaceTextureClient::setPostTransformCrop"); Rect realRect; if (rect == NULL || rect->isEmpty()) { @@ -549,6 +550,9 @@ int SurfaceTextureClient::setPostTransformCrop(Rect const* rect) realRect = *rect; } + ALOGV("SurfaceTextureClient::setPostTransformCrop rect=[%d %d %d %d]", + realRect.left, realRect.top, realRect.right, realRect.bottom); + Mutex::Autolock lock(mMutex); mCrop = realRect; mCropNeedsTransform = true; @@ -627,7 +631,6 @@ int SurfaceTextureClient::setScalingMode(int mode) case NATIVE_WINDOW_SCALING_MODE_FREEZE: case NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW: case NATIVE_WINDOW_SCALING_MODE_SCALE_CROP: - case NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP: break; default: ALOGE("unknown scaling mode: %d", mode);