diff --git a/core/java/android/os/Bundle.java b/core/java/android/os/Bundle.java index 9b5ff29d592e5..ec01364b63b48 100644 --- a/core/java/android/os/Bundle.java +++ b/core/java/android/os/Bundle.java @@ -259,6 +259,19 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { } } + /** + * 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. */ diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 9fcd5934ec685..17752910edf8c 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 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D 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 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D 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?