Fix test failure not hold Object of PackageMonitor
PackageMonitorCallback holds a weak reference to PackageMonitor. If no other holder, the PackageMonitor object will be recycled. Currently, the object in SearchManagerService is held by a registered broadcast receiver. But in PackageMonitor, registering a receiver is not a must. PackageMonitor refactor the structure to only register receivers if the client is interested in a package restart query. Otherwise, they will not register any receiver. That will cause the object of PackageMonitor to have no any holder. After the object is recycled, there will not be any package events that are received and cause tests to fail. Bug: 340410698 Test: atest CtsAppTestCases:android.app.cts.SearchManagerTest Change-Id: I2005e257ed34523a2896bec3299a52700afab4d5
Loading
Please register or sign in to comment