From 2a588443f23c3bcc8b9784f8c6c5b55e9620fca2 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 11 Apr 2019 09:47:49 +0200 Subject: [PATCH] Log saved instance size --- app/src/main/java/eu/faircode/email/ActivityBase.java | 10 ++++++++++ app/src/main/java/eu/faircode/email/FragmentBase.java | 6 ++++++ app/src/main/java/eu/faircode/email/Helper.java | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/ActivityBase.java b/app/src/main/java/eu/faircode/email/ActivityBase.java index bf2c916022..c53c3fa206 100644 --- a/app/src/main/java/eu/faircode/email/ActivityBase.java +++ b/app/src/main/java/eu/faircode/email/ActivityBase.java @@ -68,6 +68,16 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc super.onCreate(savedInstanceState); } + @Override + protected void onSaveInstanceState(Bundle outState) { + int before = Helper.getSize(outState); + super.onSaveInstanceState(outState); + int after = Helper.getSize(outState); + Log.i("Saved instance " + this + " size=" + before + "/" + after); + for (String key : outState.keySet()) + Log.i("Saved " + key + "=" + outState.get(key)); + } + @Override protected void onResume() { Log.i("Resume " + this.getClass().getName()); diff --git a/app/src/main/java/eu/faircode/email/FragmentBase.java b/app/src/main/java/eu/faircode/email/FragmentBase.java index e99d488c21..5b7f2f03ab 100644 --- a/app/src/main/java/eu/faircode/email/FragmentBase.java +++ b/app/src/main/java/eu/faircode/email/FragmentBase.java @@ -55,8 +55,14 @@ public class FragmentBase extends Fragment { @Override public void onSaveInstanceState(Bundle outState) { Log.i("Save instance " + this); + int base = Helper.getSize(outState); super.onSaveInstanceState(outState); + int before = Helper.getSize(outState); outState.putString("fair:subtitle", subtitle); + int after = Helper.getSize(outState); + Log.i("Saved instance " + this + " base=" + base + " size=" + before + "/" + after); + for (String key : outState.keySet()) + Log.i("Saved " + key + "=" + outState.get(key)); } @Override diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 3b4fe6aaab..d32b379b9b 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -42,6 +42,7 @@ import android.net.NetworkInfo; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.os.Parcel; import android.os.PowerManager; import android.text.TextUtils; import android.view.Display; @@ -1153,4 +1154,10 @@ public class Helper { return organization; } } + + static int getSize(Bundle bundle) { + Parcel p = Parcel.obtain(); + bundle.writeToParcel(p, 0); + return p.dataSize(); + } }