Merge "Improved error handling." into nyc-dev
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 1add346..96ae488 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -72,6 +72,8 @@
#define RECOVERY_DIR "/cache/recovery"
#define RECOVERY_DATA_DIR "/data/misc/recovery"
#define LOGPERSIST_DATA_DIR "/data/misc/logd"
+#define PROFILE_DATA_DIR_CUR "/data/misc/profiles/cur"
+#define PROFILE_DATA_DIR_REF "/data/misc/profiles/ref"
#define TOMBSTONE_DIR "/data/tombstones"
#define TOMBSTONE_FILE_PREFIX TOMBSTONE_DIR "/tombstone_"
/* Can accomodate a tombstone number up to 9999. */
@@ -824,7 +826,7 @@
#endif
dump_file("INTERRUPTS (1)", "/proc/interrupts");
- run_command("NETWORK DIAGNOSTICS", 10, "dumpsys", "connectivity", "--diag", NULL);
+ run_command("NETWORK DIAGNOSTICS", 10, "dumpsys", "-t", "10", "connectivity", "--diag", NULL);
#ifdef FWDUMP_bcmdhd
run_command("DUMP WIFI STATUS", 20,
@@ -900,30 +902,30 @@
printf("== Checkins\n");
printf("========================================================\n");
- run_command("CHECKIN BATTERYSTATS", 30, "dumpsys", "batterystats", "-c", NULL);
- run_command("CHECKIN MEMINFO", 30, "dumpsys", "meminfo", "--checkin", NULL);
- run_command("CHECKIN NETSTATS", 30, "dumpsys", "netstats", "--checkin", NULL);
- run_command("CHECKIN PROCSTATS", 30, "dumpsys", "procstats", "-c", NULL);
- run_command("CHECKIN USAGESTATS", 30, "dumpsys", "usagestats", "-c", NULL);
- run_command("CHECKIN PACKAGE", 30, "dumpsys", "package", "--checkin", NULL);
+ run_command("CHECKIN BATTERYSTATS", 30, "dumpsys", "-t", "30", "batterystats", "-c", NULL);
+ run_command("CHECKIN MEMINFO", 30, "dumpsys", "-t", "30", "meminfo", "--checkin", NULL);
+ run_command("CHECKIN NETSTATS", 30, "dumpsys", "-t", "30", "netstats", "--checkin", NULL);
+ run_command("CHECKIN PROCSTATS", 30, "dumpsys", "-t", "30", "procstats", "-c", NULL);
+ run_command("CHECKIN USAGESTATS", 30, "dumpsys", "-t", "30", "usagestats", "-c", NULL);
+ run_command("CHECKIN PACKAGE", 30, "dumpsys", "-t", "30", "package", "--checkin", NULL);
printf("========================================================\n");
printf("== Running Application Activities\n");
printf("========================================================\n");
- run_command("APP ACTIVITIES", 30, "dumpsys", "activity", "all", NULL);
+ run_command("APP ACTIVITIES", 30, "-t", "30", "dumpsys", "activity", "all", NULL);
printf("========================================================\n");
printf("== Running Application Services\n");
printf("========================================================\n");
- run_command("APP SERVICES", 30, "dumpsys", "activity", "service", "all", NULL);
+ run_command("APP SERVICES", 30, "-t", "30", "dumpsys", "activity", "service", "all", NULL);
printf("========================================================\n");
printf("== Running Application Providers\n");
printf("========================================================\n");
- run_command("APP SERVICES", 30, "dumpsys", "activity", "provider", "all", NULL);
+ run_command("APP SERVICES", 30, "-t", "30", "dumpsys", "activity", "provider", "all", NULL);
printf("========================================================\n");
@@ -1278,7 +1280,7 @@
// Invoking the following dumpsys calls before dump_traces() to try and
// keep the system stats as close to its initial state as possible.
run_command_as_shell("DUMPSYS MEMINFO", 30, "dumpsys", "-t", "30", "meminfo", "-a", NULL);
- run_command_as_shell("DUMPSYS CPUINFO", 10, "dumpsys", "cpuinfo", "-a", NULL);
+ run_command_as_shell("DUMPSYS CPUINFO", 10, "dumpsys", "-t", "10", "cpuinfo", "-a", NULL);
/* collect stack traces from Dalvik and native processes (needs root) */
dump_traces_path = dump_traces();
@@ -1288,6 +1290,10 @@
add_dir(RECOVERY_DIR, true);
add_dir(RECOVERY_DATA_DIR, true);
add_dir(LOGPERSIST_DATA_DIR, false);
+ if (!is_user_build()) {
+ add_dir(PROFILE_DATA_DIR_CUR, true);
+ add_dir(PROFILE_DATA_DIR_REF, true);
+ }
add_mountinfo();
if (!drop_root_user()) {
diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h
index 73f923c..312e02f 100644
--- a/include/gui/SurfaceComposerClient.h
+++ b/include/gui/SurfaceComposerClient.h
@@ -140,6 +140,8 @@
const sp<IBinder>& handle, uint64_t frameNumber);
status_t setOverrideScalingMode(const sp<IBinder>& id,
int32_t overrideScalingMode);
+ status_t setPositionAppliesWithResize(const sp<IBinder>& id);
+
status_t destroySurface(const sp<IBinder>& id);
status_t clearLayerFrameStats(const sp<IBinder>& token) const;
diff --git a/include/gui/SurfaceControl.h b/include/gui/SurfaceControl.h
index bedebb6..fafd194 100644
--- a/include/gui/SurfaceControl.h
+++ b/include/gui/SurfaceControl.h
@@ -73,6 +73,11 @@
status_t setCrop(const Rect& crop);
status_t setFinalCrop(const Rect& crop);
+ // If the size changes in this transaction, position updates specified
+ // in this transaction will not complete until a buffer of the new size
+ // arrives.
+ status_t setPositionAppliesWithResize();
+
// Defers applying any changes made in this transaction until the Layer
// identified by handle reaches the given frameNumber
status_t deferTransactionUntil(sp<IBinder> handle, uint64_t frameNumber);
diff --git a/include/private/gui/LayerState.h b/include/private/gui/LayerState.h
index 92d31d1..4885e05 100644
--- a/include/private/gui/LayerState.h
+++ b/include/private/gui/LayerState.h
@@ -54,7 +54,8 @@
eCropChanged = 0x00000100,
eDeferTransaction = 0x00000200,
eFinalCropChanged = 0x00000400,
- eOverrideScalingModeChanged = 0x00000800
+ eOverrideScalingModeChanged = 0x00000800,
+ ePositionAppliesWithResize = 0x00001000,
};
layer_state_t()
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index e33cc37..92ae41e 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -165,6 +165,8 @@
uint64_t frameNumber);
status_t setOverrideScalingMode(const sp<SurfaceComposerClient>& client,
const sp<IBinder>& id, int32_t overrideScalingMode);
+ status_t setPositionAppliesWithResize(const sp<SurfaceComposerClient>& client,
+ const sp<IBinder>& id);
void setDisplaySurface(const sp<IBinder>& token,
const sp<IGraphicBufferProducer>& bufferProducer);
@@ -443,6 +445,18 @@
return NO_ERROR;
}
+status_t Composer::setPositionAppliesWithResize(
+ const sp<SurfaceComposerClient>& client,
+ const sp<IBinder>& id) {
+ Mutex::Autolock lock(mLock);
+ layer_state_t* s = getLayerStateLocked(client, id);
+ if (!s) {
+ return BAD_INDEX;
+ }
+ s->what |= layer_state_t::ePositionAppliesWithResize;
+ return NO_ERROR;
+}
+
// ---------------------------------------------------------------------------
DisplayState& Composer::getDisplayStateLocked(const sp<IBinder>& token) {
@@ -685,6 +699,11 @@
this, id, overrideScalingMode);
}
+status_t SurfaceComposerClient::setPositionAppliesWithResize(
+ const sp<IBinder>& id) {
+ return getComposer().setPositionAppliesWithResize(this, id);
+}
+
// ----------------------------------------------------------------------------
void SurfaceComposerClient::setDisplaySurface(const sp<IBinder>& token,
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp
index 314d83a..4671e50 100644
--- a/libs/gui/SurfaceControl.cpp
+++ b/libs/gui/SurfaceControl.cpp
@@ -112,6 +112,11 @@
if (err < 0) return err;
return mClient->setPosition(mHandle, x, y);
}
+status_t SurfaceControl::setPositionAppliesWithResize() {
+ status_t err = validate();
+ if (err < 0) return err;
+ return mClient->setPositionAppliesWithResize(mHandle);
+}
status_t SurfaceControl::setSize(uint32_t w, uint32_t h) {
status_t err = validate();
if (err < 0) return err;
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index b5d3262..0247723 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -95,7 +95,8 @@
mQueueItems(),
mLastFrameNumberReceived(0),
mUpdateTexImageFailed(false),
- mAutoRefresh(false)
+ mAutoRefresh(false),
+ mFreezePositionUpdates(false)
{
#ifdef USE_HWC2
ALOGV("Creating Layer %s", name.string());
@@ -1415,11 +1416,9 @@
c.requested.w, c.requested.h);
}
+ const bool resizePending = (c.requested.w != c.active.w) ||
+ (c.requested.h != c.active.h);
if (!isFixedSize()) {
-
- const bool resizePending = (c.requested.w != c.active.w) ||
- (c.requested.h != c.active.h);
-
if (resizePending && mSidebandStream == NULL) {
// don't let Layer::doTransaction update the drawing state
// if we have a pending resize, unless we are in fixed-size mode.
@@ -1443,8 +1442,16 @@
if (flags & eDontUpdateGeometryState) {
} else {
Layer::State& editCurrentState(getCurrentState());
- editCurrentState.active = editCurrentState.requested;
- c.active = c.requested;
+ if (mFreezePositionUpdates) {
+ float tx = c.active.transform.tx();
+ float ty = c.active.transform.ty();
+ c.active = c.requested;
+ c.active.transform.set(tx, ty);
+ editCurrentState.active = c.active;
+ } else {
+ editCurrentState.active = editCurrentState.requested;
+ c.active = c.requested;
+ }
}
if (s.active != c.active) {
@@ -1491,7 +1498,7 @@
return android_atomic_or(flags, &mTransactionFlags);
}
-bool Layer::setPosition(float x, float y) {
+bool Layer::setPosition(float x, float y, bool immediate) {
if (mCurrentState.requested.transform.tx() == x && mCurrentState.requested.transform.ty() == y)
return false;
mCurrentState.sequence++;
@@ -1500,12 +1507,16 @@
// we want to apply the position portion of the transform matrix immediately,
// but still delay scaling when resizing a SCALING_MODE_FREEZE layer.
mCurrentState.requested.transform.set(x, y);
- mCurrentState.active.transform.set(x, y);
+ if (immediate && !mFreezePositionUpdates) {
+ mCurrentState.active.transform.set(x, y);
+ }
+ mFreezePositionUpdates = mFreezePositionUpdates || !immediate;
mCurrentState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
+
bool Layer::setLayer(uint32_t z) {
if (mCurrentState.z == z)
return false;
@@ -1585,6 +1596,7 @@
if (scalingMode == mOverrideScalingMode)
return false;
mOverrideScalingMode = scalingMode;
+ setTransactionFlags(eTransactionNeeded);
return true;
}
@@ -2004,6 +2016,7 @@
if (bufWidth != uint32_t(oldActiveBuffer->width) ||
bufHeight != uint32_t(oldActiveBuffer->height)) {
recomputeVisibleRegions = true;
+ mFreezePositionUpdates = false;
}
}
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 7d085a4..ba7184f 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -145,7 +145,7 @@
status_t setBuffers(uint32_t w, uint32_t h, PixelFormat format, uint32_t flags);
// modify current state
- bool setPosition(float x, float y);
+ bool setPosition(float x, float y, bool immediate);
bool setLayer(uint32_t z);
bool setSize(uint32_t w, uint32_t h);
#ifdef USE_HWC2
@@ -596,6 +596,7 @@
bool mUpdateTexImageFailed; // This is only modified from the main thread
bool mAutoRefresh;
+ bool mFreezePositionUpdates;
};
// ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 80b4d75..a10a813 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2251,9 +2251,12 @@
sp<Layer> layer(client->getLayerUser(s.surface));
if (layer != 0) {
const uint32_t what = s.what;
+ bool positionAppliesWithResize =
+ what & layer_state_t::ePositionAppliesWithResize;
if (what & layer_state_t::ePositionChanged) {
- if (layer->setPosition(s.x, s.y))
+ if (layer->setPosition(s.x, s.y, !positionAppliesWithResize)) {
flags |= eTraversalNeeded;
+ }
}
if (what & layer_state_t::eLayerChanged) {
// NOTE: index needs to be calculated before we update the state
diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
index 5721db7..7f3b269 100644
--- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
+++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
@@ -2267,9 +2267,12 @@
sp<Layer> layer(client->getLayerUser(s.surface));
if (layer != 0) {
const uint32_t what = s.what;
+ bool positionAppliesWithResize =
+ what & layer_state_t::ePositionAppliesWithResize;
if (what & layer_state_t::ePositionChanged) {
- if (layer->setPosition(s.x, s.y))
+ if (layer->setPosition(s.x, s.y, !positionAppliesWithResize)) {
flags |= eTraversalNeeded;
+ }
}
if (what & layer_state_t::eLayerChanged) {
// NOTE: index needs to be calculated before we update the state