Skip to content

Commit 5df8cbb

Browse files
committedMay 17, 2015
Ignored UserManager leak
Fixes square#62
1 parent 7a02fe7 commit 5df8cbb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

‎leakcanary-android/src/main/java/com/squareup/leakcanary/AndroidExcludedRefs.java

+14
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,20 @@ public enum AndroidExcludedRefs {
221221
}
222222
},
223223

224+
USER_MANAGER__SINSTANCE(SDK_INT >= JELLY_BEAN && SDK_INT <= LOLLIPOP_MR1) {
225+
@Override void add(ExcludedRefs.Builder excluded) {
226+
// UserManager has a static sInstance field that creates an instance and caches it the first
227+
// time UserManager.get() is called. This instance is created with the outer context (which
228+
// is an activity base context).
229+
// Tracked here: https://code.google.com/p/android/issues/detail?id=173789
230+
// Introduced by: https://github.com/android/platform_frameworks_base/commit
231+
// /27db46850b708070452c0ce49daf5f79503fbde6
232+
// Fix: trigger a call to UserManager.get() in Application.onCreate(), so that the
233+
// UserManager instance gets cached with a reference to the application context.
234+
excluded.instanceField("android.os.UserManager", "mContext");
235+
}
236+
},
237+
224238
DEVICE_POLICY_MANAGER__SETTINGS_OBSERVER(MOTOROLA.equals(MANUFACTURER) && SDK_INT == KITKAT) {
225239
@Override void add(ExcludedRefs.Builder excluded) {
226240
if (MOTOROLA.equals(MANUFACTURER) && SDK_INT == KITKAT) {

0 commit comments

Comments
 (0)
Please sign in to comment.