Fix unlock sim thread leak
The class UnlockSim will be created for each request without the same
instance reuse, but the looper won't be quitted after complete.
To fix it, quit its looper after supply pin is finished.
Test: Manual and atest FrameworksTelephonyTests
Bug: 296322144
Change-Id: I4fea4321738edab284bf1146011c7719bc475649
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 706373b..809b1c2 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2608,6 +2608,9 @@
* If PUK is null, unlock SIM card with PIN
*
* If PUK is not null, unlock SIM card with PUK and set PIN code
+ *
+ * Besides, since it is reused in class level, the thread's looper will be stopped to avoid
+ * its thread leak.
*/
synchronized int[] unlockSim(String puk, String pin) {
@@ -2643,6 +2646,8 @@
if (mResult == PhoneConstants.PIN_RESULT_SUCCESS && pin.length() > 0) {
UiccController.getInstance().getPinStorage().storePin(pin, mPhoneId);
}
+ // This instance is no longer reused, so quit its thread's looper.
+ mHandler.getLooper().quitSafely();
return resultArray;
}