From 57b39e3efa35daf1e495a0e4f217c3276d691d1d Mon Sep 17 00:00:00 2001 From: Yifan Bai Date: Fri, 1 Apr 2016 16:24:33 +0800 Subject: [PATCH] Fix issues of different phone objects sharing same mConnectionApns list. Due to different phone objects are sharing same mConnectionApns list, in some situation both SIMs will show data connection icons mistakenly. To fix, create different mConnectionApns list to track different phone objects. Change-Id: I1b176b62e9acf3cbe52cc38fb437570b88e03ff8 --- .../java/com/android/server/TelephonyRegistry.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 19a4851525a65..352254a737bc1 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -159,7 +159,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { private String[] mDataConnectionApn; - private ArrayList mConnectedApns; + private ArrayList[] mConnectedApns; private LinkProperties[] mDataConnectionLinkProperties; @@ -292,11 +292,11 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mContext = context; mBatteryStats = BatteryStatsService.getService(); - mConnectedApns = new ArrayList(); int numPhones = TelephonyManager.getDefault().getPhoneCount(); if (DBG) log("TelephonyRegistor: ctor numPhones=" + numPhones); mNumPhones = numPhones; + mConnectedApns = new ArrayList[numPhones]; mCallState = new int[numPhones]; mDataActivity = new int[numPhones]; mDataConnectionState = new int[numPhones]; @@ -327,6 +327,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mDataConnectionApn[i] = ""; mCellLocation[i] = new Bundle(); mCellInfo.add(i, null); + mConnectedApns[i] = new ArrayList(); } // Note that location can be null for non-phone builds like @@ -336,7 +337,6 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { location.fillInNotifierBundle(mCellLocation[i]); } } - mConnectedApns = new ArrayList(); mAppOps = mContext.getSystemService(AppOpsManager.class); } @@ -1059,16 +1059,16 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { if (validatePhoneId(phoneId)) { boolean modified = false; if (state == TelephonyManager.DATA_CONNECTED) { - if (!mConnectedApns.contains(apnType)) { - mConnectedApns.add(apnType); + if (!mConnectedApns[phoneId].contains(apnType)) { + mConnectedApns[phoneId].add(apnType); if (mDataConnectionState[phoneId] != state) { mDataConnectionState[phoneId] = state; modified = true; } } } else { - if (mConnectedApns.remove(apnType)) { - if (mConnectedApns.isEmpty()) { + if (mConnectedApns[phoneId].remove(apnType)) { + if (mConnectedApns[phoneId].isEmpty()) { mDataConnectionState[phoneId] = state; modified = true; } else {