Fix phone crash in MobileNetworkSettings.
+ Avoid crash due to race condition caused by
1)onCreate
2)Handler posts message
3)Orientation change of screen, destroys activity
4)Handler handles message and access getPreferenceScreen which is null.
Bug: 27425313
Change-Id: I39a34d860a58e16001a7163e30a2a308cd65bb10
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 622471d..5d8c549 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -266,6 +266,9 @@
};
private void initializeSubscriptions() {
+ if (isDestroyed()) { // Process preferences in activity only if its not destroyed
+ return;
+ }
int currentTab = 0;
if (DBG) log("initializeSubscriptions:+");
@@ -950,6 +953,10 @@
}
private void handleSetPreferredNetworkTypeResponse(Message msg) {
+ if (isDestroyed()) { // Access preferences of activity only if it is not destroyed
+ return;
+ }
+
AsyncResult ar = (AsyncResult) msg.obj;
final int phoneSubId = mPhone.getSubId();