From e620ce75e3d874294e0270b40768f7199dd95cc3 Mon Sep 17 00:00:00 2001 From: "yifan.bai" Date: Fri, 22 Dec 2017 14:59:57 +0800 Subject: [PATCH] Fix low probability deadlock Low probability deadlock in com.android.phone and system_server. Bug: 70865607 Test: Build pass --- .../com/android/server/TelephonyRegistry.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 5e5eacb5c7677..3a68311bf8b8b 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -503,6 +503,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } } + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { // register IBinder b = callback.asBinder(); @@ -525,9 +526,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } else {//APP specify subID r.subId = subId; } - r.phoneId = SubscriptionManager.getPhoneId(r.subId); - - int phoneId = r.phoneId; + r.phoneId = phoneId; r.events = events; if (DBG) { log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId); @@ -1013,9 +1012,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { log("notifyCellInfoForSubscriber: subId=" + subId + " cellInfo=" + cellInfo); } - + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { - int phoneId = SubscriptionManager.getPhoneId(subId); if (validatePhoneId(phoneId)) { mCellInfo.set(phoneId, cellInfo); for (Record r : mRecords) { @@ -1103,8 +1101,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { log("notifyCallForwardingChangedForSubscriber: subId=" + subId + " cfi=" + cfi); } + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { - int phoneId = SubscriptionManager.getPhoneId(subId); if (validatePhoneId(phoneId)) { mCallForwarding[phoneId] = cfi; for (Record r : mRecords) { @@ -1131,8 +1129,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { if (!checkNotifyPermission("notifyDataActivity()" )) { return; } + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { - int phoneId = SubscriptionManager.getPhoneId(subId); if (validatePhoneId(phoneId)) { mDataActivity[phoneId] = state; for (Record r : mRecords) { @@ -1173,8 +1171,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType + " mRecords.size()=" + mRecords.size()); } + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { - int phoneId = SubscriptionManager.getPhoneId(subId); if (validatePhoneId(phoneId)) { boolean modified = false; if (state == TelephonyManager.DATA_CONNECTED) { @@ -1297,8 +1295,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { log("notifyCellLocationForSubscriber: subId=" + subId + " cellLocation=" + cellLocation); } + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { - int phoneId = SubscriptionManager.getPhoneId(subId); if (validatePhoneId(phoneId)) { mCellLocation[phoneId] = cellLocation; for (Record r : mRecords) {