Merge changes I348c18dc,I0c33d519
* changes: SysUiLeaks: Detect leaks in TunerService SysUiLeaks: Detect leaks of NotificationData.Entry
This commit is contained in:
committed by
Android (Google) Code Review
commit
34895c404b
@@ -196,6 +196,8 @@ import com.android.systemui.statusbar.policy.UserSwitcherController;
|
||||
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
|
||||
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout.OnChildLocationsChangedListener;
|
||||
|
||||
|
||||
import com.android.systemui.util.leak.LeakDetector;
|
||||
import com.android.systemui.volume.VolumeComponent;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
@@ -6596,6 +6598,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
return null;
|
||||
}
|
||||
updateNotifications();
|
||||
Dependency.get(LeakDetector.class).trackGarbage(entry);
|
||||
return entry.notification;
|
||||
}
|
||||
|
||||
@@ -6604,6 +6607,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
Log.d(TAG, "createNotificationViews(notification=" + sbn);
|
||||
}
|
||||
NotificationData.Entry entry = new NotificationData.Entry(sbn);
|
||||
Dependency.get(LeakDetector.class).trackInstance(entry);
|
||||
try {
|
||||
entry.createIcons(mContext, sbn);
|
||||
} catch (NotificationData.IconException exception) {
|
||||
|
||||
@@ -48,8 +48,10 @@ import com.android.systemui.SystemUIApplication;
|
||||
import com.android.systemui.settings.CurrentUserTracker;
|
||||
import com.android.systemui.statusbar.phone.StatusBarIconController;
|
||||
import com.android.systemui.statusbar.phone.SystemUIDialog;
|
||||
import com.android.systemui.util.leak.LeakDetector;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@@ -66,6 +68,8 @@ public class TunerService {
|
||||
private final ArrayMap<Uri, String> mListeningUris = new ArrayMap<>();
|
||||
// Map of settings keys to the listener.
|
||||
private final HashMap<String, Set<Tunable>> mTunableLookup = new HashMap<>();
|
||||
// Set of all tunables, used for leak detection.
|
||||
private final HashSet<Tunable> mTunables = LeakDetector.ENABLED ? new HashSet<>() : null;
|
||||
private final Context mContext;
|
||||
|
||||
private ContentResolver mContentResolver;
|
||||
@@ -150,6 +154,10 @@ public class TunerService {
|
||||
mTunableLookup.put(key, new ArraySet<Tunable>());
|
||||
}
|
||||
mTunableLookup.get(key).add(tunable);
|
||||
if (LeakDetector.ENABLED) {
|
||||
mTunables.add(tunable);
|
||||
Dependency.get(LeakDetector.class).trackCollection(mTunables, "TunerService.mTunables");
|
||||
}
|
||||
Uri uri = Settings.Secure.getUriFor(key);
|
||||
if (!mListeningUris.containsKey(uri)) {
|
||||
mListeningUris.put(uri, key);
|
||||
@@ -164,6 +172,9 @@ public class TunerService {
|
||||
for (Set<Tunable> list : mTunableLookup.values()) {
|
||||
list.remove(tunable);
|
||||
}
|
||||
if (LeakDetector.ENABLED) {
|
||||
mTunables.remove(tunable);
|
||||
}
|
||||
}
|
||||
|
||||
protected void reregisterAll() {
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.Collection;
|
||||
*/
|
||||
public class LeakDetector implements Dumpable {
|
||||
|
||||
private static final boolean ENABLED = Build.IS_DEBUGGABLE;
|
||||
public static final boolean ENABLED = Build.IS_DEBUGGABLE;
|
||||
|
||||
private final TrackedCollections mTrackedCollections;
|
||||
private final TrackedGarbage mTrackedGarbage;
|
||||
|
||||
Reference in New Issue
Block a user