Log if parcel size is too large when launching an activity.
Bug: 37172206
Test: manual
Change-Id: I07ee7a8d1186d25716902eb00697eb9aa94c7629
diff --git a/core/java/android/os/Bundle.java b/core/java/android/os/Bundle.java
index 9b5ff29..ec01364 100644
--- a/core/java/android/os/Bundle.java
+++ b/core/java/android/os/Bundle.java
@@ -260,6 +260,19 @@
}
/**
+ * Return the size of {@link #mParcelledData} in bytes if available, otherwise {@code 0}.
+ *
+ * @hide
+ */
+ public int getSize() {
+ if (mParcelledData != null) {
+ return mParcelledData.dataSize();
+ } else {
+ return 0;
+ }
+ }
+
+ /**
* Reports whether the bundle contains any parcelled file descriptors.
*/
public boolean hasFileDescriptors() {
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 9fcd593..1775291 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -1461,6 +1461,7 @@
mService.getGlobalConfiguration(), r.getMergedOverrideConfiguration());
r.setLastReportedConfiguration(mergedConfiguration);
+ logIfTransactionTooLarge(r.intent, r.icicle);
app.thread.scheduleLaunchActivity(new Intent(r.intent), r.appToken,
System.identityHashCode(r), r.info,
// TODO: Have this take the merged configuration instead of separate global and
@@ -1546,6 +1547,21 @@
return true;
}
+ private void logIfTransactionTooLarge(Intent intent, Bundle icicle) {
+ int extrasSize = 0;
+ if (intent != null) {
+ final Bundle extras = intent.getExtras();
+ if (extras != null) {
+ extrasSize = extras.getSize();
+ }
+ }
+ int icicleSize = (icicle == null ? 0 : icicle.getSize());
+ if (extrasSize + icicleSize > 200000) {
+ Slog.e(TAG, "Transaction too large, intent: " + intent + ", extras size: " + extrasSize
+ + ", icicle size: " + icicleSize);
+ }
+ }
+
void startSpecificActivityLocked(ActivityRecord r,
boolean andResume, boolean checkConfig) {
// Is this activity's application already running?