Cleanup KeyguardIndicationController on tearDown

In case messages come in on the handler after the KeyguardIndication
class is already gone which can cause NPEs.

Test: atest SystemUITests
Fixes: 222215310
Change-Id: Iafa5379b68994fecdea6540a20522da21af5c788
This commit is contained in:
Beverly
2022-03-02 15:48:10 +00:00
parent b78bf4e4d7
commit dd66917774
2 changed files with 12 additions and 0 deletions

View File

@@ -293,6 +293,14 @@ public class KeyguardIndicationController {
}
}
/**
* Cleanup
*/
public void destroy() {
mHandler.removeCallbacksAndMessages(null);
mBroadcastDispatcher.unregisterReceiver(mBroadcastReceiver);
}
private void handleAlignStateChanged(int alignState) {
String alignmentIndication = "";
if (alignState == DockManager.ALIGN_STATE_POOR) {

View File

@@ -226,6 +226,10 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
@After
public void tearDown() throws Exception {
mTextView.setAnimationsEnabled(true);
if (mController != null) {
mController.destroy();
mController = null;
}
}
private void createController() {