Loading src/java/com/android/internal/telephony/dataconnection/DataConnection.java +1 −3 Original line number Original line Diff line number Diff line Loading @@ -1394,9 +1394,7 @@ public class DataConnection extends StateMachine { result.mFailCause = DataFailCause.getFailCause(response.getCause()); result.mFailCause = DataFailCause.getFailCause(response.getCause()); } } } else if (cp.mApnContext.getApnTypeBitmask() == ApnSetting.TYPE_ENTERPRISE } else if (cp.mApnContext.getApnTypeBitmask() == ApnSetting.TYPE_ENTERPRISE && mDcController.getActiveDcByCid(response.getId()) != null && mDcController.getActiveDcByCid(response.getId()) != null) { && mDcController.getTrafficDescriptorsForCid(response.getId()) .equals(response.getTrafficDescriptors())) { if (DBG) log("DataConnection already exists for cid: " + response.getId()); if (DBG) log("DataConnection already exists for cid: " + response.getId()); result = SetupResult.ERROR_DUPLICATE_CID; result = SetupResult.ERROR_DUPLICATE_CID; result.mFailCause = DataFailCause.DUPLICATE_CID; result.mFailCause = DataFailCause.DUPLICATE_CID; Loading src/java/com/android/internal/telephony/dataconnection/DcController.java +7 −49 Original line number Original line Diff line number Diff line Loading @@ -28,7 +28,6 @@ import android.telephony.AccessNetworkConstants; import android.telephony.DataFailCause; import android.telephony.DataFailCause; import android.telephony.data.ApnSetting; import android.telephony.data.ApnSetting; import android.telephony.data.DataCallResponse; import android.telephony.data.DataCallResponse; import android.telephony.data.TrafficDescriptor; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.DctConstants; import com.android.internal.telephony.DctConstants; Loading Loading @@ -87,9 +86,6 @@ public class DcController extends Handler { final ArrayList<DataConnection> mDcListAll = new ArrayList<>(); final ArrayList<DataConnection> mDcListAll = new ArrayList<>(); // @GuardedBy("mDcListAll") // @GuardedBy("mDcListAll") private final HashMap<Integer, DataConnection> mDcListActiveByCid = new HashMap<>(); private final HashMap<Integer, DataConnection> mDcListActiveByCid = new HashMap<>(); // @GuardedBy("mTrafficDescriptorsByCid") private final HashMap<Integer, List<TrafficDescriptor>> mTrafficDescriptorsByCid = new HashMap<>(); /** /** * Aggregated physical link state from all data connections. This reflects the device's RRC * Aggregated physical link state from all data connections. This reflects the device's RRC Loading Loading @@ -142,9 +138,6 @@ public class DcController extends Handler { mDcListActiveByCid.remove(dc.mCid); mDcListActiveByCid.remove(dc.mCid); mDcListAll.remove(dc); mDcListAll.remove(dc); } } synchronized (mTrafficDescriptorsByCid) { mTrafficDescriptorsByCid.remove(dc.mCid); } } } public void addActiveDcByCid(DataConnection dc) { public void addActiveDcByCid(DataConnection dc) { Loading @@ -154,7 +147,6 @@ public class DcController extends Handler { synchronized (mDcListAll) { synchronized (mDcListAll) { mDcListActiveByCid.put(dc.mCid, dc); mDcListActiveByCid.put(dc.mCid, dc); } } updateTrafficDescriptorsForCid(dc.mCid, dc.getTrafficDescriptors()); } } DataConnection getActiveDcByCid(int cid) { DataConnection getActiveDcByCid(int cid) { Loading @@ -170,9 +162,6 @@ public class DcController extends Handler { log("removeActiveDcByCid removedDc=null dc=" + dc); log("removeActiveDcByCid removedDc=null dc=" + dc); } } } } synchronized (mTrafficDescriptorsByCid) { mTrafficDescriptorsByCid.remove(dc.mCid); } } } boolean isDefaultDataActive() { boolean isDefaultDataActive() { Loading @@ -183,18 +172,6 @@ public class DcController extends Handler { } } } } List<TrafficDescriptor> getTrafficDescriptorsForCid(int cid) { synchronized (mTrafficDescriptorsByCid) { return mTrafficDescriptorsByCid.get(cid); } } void updateTrafficDescriptorsForCid(int cid, List<TrafficDescriptor> tds) { synchronized (mTrafficDescriptorsByCid) { mTrafficDescriptorsByCid.put(cid, tds); } } @Override @Override public void handleMessage(Message msg) { public void handleMessage(Message msg) { AsyncResult ar; AsyncResult ar; Loading Loading @@ -230,29 +207,19 @@ public class DcController extends Handler { } } // Create hashmap of cid to DataCallResponse // Create hashmap of cid to DataCallResponse HashMap<Integer, DataCallResponse> dataCallResponseListByCid = new HashMap<>(); HashMap<Integer, DataCallResponse> dataCallResponseListByCid = new HashMap<Integer, DataCallResponse>(); for (DataCallResponse dcs : dcsList) { for (DataCallResponse dcs : dcsList) { dataCallResponseListByCid.put(dcs.getId(), dcs); dataCallResponseListByCid.put(dcs.getId(), dcs); } } // Add a DC that is active but not in the dcsList to the list of DC's to retry // Add a DC that is active but not in the ArrayList<DataConnection> dcsToRetry = new ArrayList<>(); // dcsList to the list of DC's to retry ArrayList<DataConnection> dcsToRetry = new ArrayList<DataConnection>(); for (DataConnection dc : dcListActiveByCid.values()) { for (DataConnection dc : dcListActiveByCid.values()) { DataCallResponse response = dataCallResponseListByCid.get(dc.mCid); if (dataCallResponseListByCid.get(dc.mCid) == null) { if (response == null) { if (DBG) log("onDataStateChanged: add to retry dc=" + dc); if (DBG) log("onDataStateChanged: add to retry dc=" + dc); dcsToRetry.add(dc); dcsToRetry.add(dc); } else { List<TrafficDescriptor> oldTds = getTrafficDescriptorsForCid(dc.mCid); List<TrafficDescriptor> newTds = response.getTrafficDescriptors(); if (oldTds.equals(newTds)) { if (DBG) { log("onDataStateChanged: add to retry due to TD changed dc=" + dc + ", oldTds=" + oldTds + ", newTds=" + newTds); } updateTrafficDescriptorsForCid(dc.mCid, newTds); dcsToRetry.add(dc); } } } } } if (DBG) log("onDataStateChanged: dcsToRetry=" + dcsToRetry); if (DBG) log("onDataStateChanged: dcsToRetry=" + dcsToRetry); Loading Loading @@ -482,15 +449,9 @@ public class DcController extends Handler { @Override @Override public String toString() { public String toString() { StringBuilder sb = new StringBuilder(); synchronized (mDcListAll) { synchronized (mDcListAll) { sb.append("mDcListAll=").append(mDcListAll) return "mDcListAll=" + mDcListAll + " mDcListActiveByCid=" + mDcListActiveByCid; .append(" mDcListActiveByCid=").append(mDcListActiveByCid); } synchronized (mTrafficDescriptorsByCid) { sb.append("mTrafficDescriptorsByCid=").append(mTrafficDescriptorsByCid); } } return sb.toString(); } } public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { Loading @@ -499,8 +460,5 @@ public class DcController extends Handler { pw.println(" mDcListAll=" + mDcListAll); pw.println(" mDcListAll=" + mDcListAll); pw.println(" mDcListActiveByCid=" + mDcListActiveByCid); pw.println(" mDcListActiveByCid=" + mDcListActiveByCid); } } synchronized (mTrafficDescriptorsByCid) { pw.println(" mTrafficDescriptorsByCid=" + mTrafficDescriptorsByCid); } } } } } tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataConnectionTest.java +4 −30 Original line number Original line Diff line number Diff line Loading @@ -94,7 +94,6 @@ import java.util.function.Consumer; public class DataConnectionTest extends TelephonyTest { public class DataConnectionTest extends TelephonyTest { private static final int DEFAULT_DC_CID = 10; private static final int DEFAULT_DC_CID = 10; private static final ArrayList<TrafficDescriptor> DEFAULT_TD_LIST = new ArrayList<>(); @Mock @Mock DcTesterFailBringUpAll mDcTesterFailBringUpAll; DcTesterFailBringUpAll mDcTesterFailBringUpAll; Loading Loading @@ -302,7 +301,7 @@ public class DataConnectionTest extends TelephonyTest { } } } } private void setSuccessfulSetupDataResponse(int cid, ArrayList<TrafficDescriptor> tds) { private void setSuccessfulSetupDataResponse(int cid) { doAnswer(invocation -> { doAnswer(invocation -> { final Message msg = (Message) invocation.getArguments()[10]; final Message msg = (Message) invocation.getArguments()[10]; Loading Loading @@ -330,7 +329,7 @@ public class DataConnectionTest extends TelephonyTest { .setMtuV6(1500) .setMtuV6(1500) .setPduSessionId(1) .setPduSessionId(1) .setQosBearerSessions(new ArrayList<>()) .setQosBearerSessions(new ArrayList<>()) .setTrafficDescriptors(tds) .setTrafficDescriptors(new ArrayList<>()) .build(); .build(); msg.getData().putParcelable("data_call_response", response); msg.getData().putParcelable("data_call_response", response); msg.arg1 = DataServiceCallback.RESULT_SUCCESS; msg.arg1 = DataServiceCallback.RESULT_SUCCESS; Loading Loading @@ -385,7 +384,7 @@ public class DataConnectionTest extends TelephonyTest { mDcp.mApnContext = mApnContext; mDcp.mApnContext = mApnContext; setSuccessfulSetupDataResponse(DEFAULT_DC_CID, DEFAULT_TD_LIST); setSuccessfulSetupDataResponse(DEFAULT_DC_CID); doAnswer(invocation -> { doAnswer(invocation -> { final Message msg = (Message) invocation.getArguments()[2]; final Message msg = (Message) invocation.getArguments()[2]; Loading Loading @@ -521,32 +520,7 @@ public class DataConnectionTest extends TelephonyTest { assertTrue(mDc.isInactive()); assertTrue(mDc.isInactive()); // Change the CID // Change the CID setSuccessfulSetupDataResponse(DEFAULT_DC_CID + 1, DEFAULT_TD_LIST); setSuccessfulSetupDataResponse(DEFAULT_DC_CID + 1); // Verify that ENTERPRISE was set up connectEvent(true); assertTrue(mDc.getNetworkCapabilities().hasCapability( NetworkCapabilities.NET_CAPABILITY_ENTERPRISE)); } @Test public void testConnectEventDuplicateContextIdsDifferentTDs() throws Exception { setUpDefaultData(DEFAULT_DC_CID); // Try to connect ENTERPRISE with the same CID as default replaceInstance(ConnectionParams.class, "mApnContext", mCp, mEnterpriseApnContext); doReturn(mApn1).when(mEnterpriseApnContext).getApnSetting(); doReturn(ApnSetting.TYPE_ENTERPRISE_STRING).when(mEnterpriseApnContext).getApnType(); doReturn(ApnSetting.TYPE_ENTERPRISE).when(mEnterpriseApnContext).getApnTypeBitmask(); // Verify that ENTERPRISE wasn't set up connectEvent(false); assertTrue(mDc.isInactive()); // Change the TrafficDescriptors ArrayList<TrafficDescriptor> tdList = new ArrayList<>(); tdList.add(new TrafficDescriptor("dnn", DataConnection.getEnterpriseOsAppId())); setSuccessfulSetupDataResponse(DEFAULT_DC_CID, tdList); // Verify that ENTERPRISE was set up // Verify that ENTERPRISE was set up connectEvent(true); connectEvent(true); Loading Loading
src/java/com/android/internal/telephony/dataconnection/DataConnection.java +1 −3 Original line number Original line Diff line number Diff line Loading @@ -1394,9 +1394,7 @@ public class DataConnection extends StateMachine { result.mFailCause = DataFailCause.getFailCause(response.getCause()); result.mFailCause = DataFailCause.getFailCause(response.getCause()); } } } else if (cp.mApnContext.getApnTypeBitmask() == ApnSetting.TYPE_ENTERPRISE } else if (cp.mApnContext.getApnTypeBitmask() == ApnSetting.TYPE_ENTERPRISE && mDcController.getActiveDcByCid(response.getId()) != null && mDcController.getActiveDcByCid(response.getId()) != null) { && mDcController.getTrafficDescriptorsForCid(response.getId()) .equals(response.getTrafficDescriptors())) { if (DBG) log("DataConnection already exists for cid: " + response.getId()); if (DBG) log("DataConnection already exists for cid: " + response.getId()); result = SetupResult.ERROR_DUPLICATE_CID; result = SetupResult.ERROR_DUPLICATE_CID; result.mFailCause = DataFailCause.DUPLICATE_CID; result.mFailCause = DataFailCause.DUPLICATE_CID; Loading
src/java/com/android/internal/telephony/dataconnection/DcController.java +7 −49 Original line number Original line Diff line number Diff line Loading @@ -28,7 +28,6 @@ import android.telephony.AccessNetworkConstants; import android.telephony.DataFailCause; import android.telephony.DataFailCause; import android.telephony.data.ApnSetting; import android.telephony.data.ApnSetting; import android.telephony.data.DataCallResponse; import android.telephony.data.DataCallResponse; import android.telephony.data.TrafficDescriptor; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.DctConstants; import com.android.internal.telephony.DctConstants; Loading Loading @@ -87,9 +86,6 @@ public class DcController extends Handler { final ArrayList<DataConnection> mDcListAll = new ArrayList<>(); final ArrayList<DataConnection> mDcListAll = new ArrayList<>(); // @GuardedBy("mDcListAll") // @GuardedBy("mDcListAll") private final HashMap<Integer, DataConnection> mDcListActiveByCid = new HashMap<>(); private final HashMap<Integer, DataConnection> mDcListActiveByCid = new HashMap<>(); // @GuardedBy("mTrafficDescriptorsByCid") private final HashMap<Integer, List<TrafficDescriptor>> mTrafficDescriptorsByCid = new HashMap<>(); /** /** * Aggregated physical link state from all data connections. This reflects the device's RRC * Aggregated physical link state from all data connections. This reflects the device's RRC Loading Loading @@ -142,9 +138,6 @@ public class DcController extends Handler { mDcListActiveByCid.remove(dc.mCid); mDcListActiveByCid.remove(dc.mCid); mDcListAll.remove(dc); mDcListAll.remove(dc); } } synchronized (mTrafficDescriptorsByCid) { mTrafficDescriptorsByCid.remove(dc.mCid); } } } public void addActiveDcByCid(DataConnection dc) { public void addActiveDcByCid(DataConnection dc) { Loading @@ -154,7 +147,6 @@ public class DcController extends Handler { synchronized (mDcListAll) { synchronized (mDcListAll) { mDcListActiveByCid.put(dc.mCid, dc); mDcListActiveByCid.put(dc.mCid, dc); } } updateTrafficDescriptorsForCid(dc.mCid, dc.getTrafficDescriptors()); } } DataConnection getActiveDcByCid(int cid) { DataConnection getActiveDcByCid(int cid) { Loading @@ -170,9 +162,6 @@ public class DcController extends Handler { log("removeActiveDcByCid removedDc=null dc=" + dc); log("removeActiveDcByCid removedDc=null dc=" + dc); } } } } synchronized (mTrafficDescriptorsByCid) { mTrafficDescriptorsByCid.remove(dc.mCid); } } } boolean isDefaultDataActive() { boolean isDefaultDataActive() { Loading @@ -183,18 +172,6 @@ public class DcController extends Handler { } } } } List<TrafficDescriptor> getTrafficDescriptorsForCid(int cid) { synchronized (mTrafficDescriptorsByCid) { return mTrafficDescriptorsByCid.get(cid); } } void updateTrafficDescriptorsForCid(int cid, List<TrafficDescriptor> tds) { synchronized (mTrafficDescriptorsByCid) { mTrafficDescriptorsByCid.put(cid, tds); } } @Override @Override public void handleMessage(Message msg) { public void handleMessage(Message msg) { AsyncResult ar; AsyncResult ar; Loading Loading @@ -230,29 +207,19 @@ public class DcController extends Handler { } } // Create hashmap of cid to DataCallResponse // Create hashmap of cid to DataCallResponse HashMap<Integer, DataCallResponse> dataCallResponseListByCid = new HashMap<>(); HashMap<Integer, DataCallResponse> dataCallResponseListByCid = new HashMap<Integer, DataCallResponse>(); for (DataCallResponse dcs : dcsList) { for (DataCallResponse dcs : dcsList) { dataCallResponseListByCid.put(dcs.getId(), dcs); dataCallResponseListByCid.put(dcs.getId(), dcs); } } // Add a DC that is active but not in the dcsList to the list of DC's to retry // Add a DC that is active but not in the ArrayList<DataConnection> dcsToRetry = new ArrayList<>(); // dcsList to the list of DC's to retry ArrayList<DataConnection> dcsToRetry = new ArrayList<DataConnection>(); for (DataConnection dc : dcListActiveByCid.values()) { for (DataConnection dc : dcListActiveByCid.values()) { DataCallResponse response = dataCallResponseListByCid.get(dc.mCid); if (dataCallResponseListByCid.get(dc.mCid) == null) { if (response == null) { if (DBG) log("onDataStateChanged: add to retry dc=" + dc); if (DBG) log("onDataStateChanged: add to retry dc=" + dc); dcsToRetry.add(dc); dcsToRetry.add(dc); } else { List<TrafficDescriptor> oldTds = getTrafficDescriptorsForCid(dc.mCid); List<TrafficDescriptor> newTds = response.getTrafficDescriptors(); if (oldTds.equals(newTds)) { if (DBG) { log("onDataStateChanged: add to retry due to TD changed dc=" + dc + ", oldTds=" + oldTds + ", newTds=" + newTds); } updateTrafficDescriptorsForCid(dc.mCid, newTds); dcsToRetry.add(dc); } } } } } if (DBG) log("onDataStateChanged: dcsToRetry=" + dcsToRetry); if (DBG) log("onDataStateChanged: dcsToRetry=" + dcsToRetry); Loading Loading @@ -482,15 +449,9 @@ public class DcController extends Handler { @Override @Override public String toString() { public String toString() { StringBuilder sb = new StringBuilder(); synchronized (mDcListAll) { synchronized (mDcListAll) { sb.append("mDcListAll=").append(mDcListAll) return "mDcListAll=" + mDcListAll + " mDcListActiveByCid=" + mDcListActiveByCid; .append(" mDcListActiveByCid=").append(mDcListActiveByCid); } synchronized (mTrafficDescriptorsByCid) { sb.append("mTrafficDescriptorsByCid=").append(mTrafficDescriptorsByCid); } } return sb.toString(); } } public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { Loading @@ -499,8 +460,5 @@ public class DcController extends Handler { pw.println(" mDcListAll=" + mDcListAll); pw.println(" mDcListAll=" + mDcListAll); pw.println(" mDcListActiveByCid=" + mDcListActiveByCid); pw.println(" mDcListActiveByCid=" + mDcListActiveByCid); } } synchronized (mTrafficDescriptorsByCid) { pw.println(" mTrafficDescriptorsByCid=" + mTrafficDescriptorsByCid); } } } } }
tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataConnectionTest.java +4 −30 Original line number Original line Diff line number Diff line Loading @@ -94,7 +94,6 @@ import java.util.function.Consumer; public class DataConnectionTest extends TelephonyTest { public class DataConnectionTest extends TelephonyTest { private static final int DEFAULT_DC_CID = 10; private static final int DEFAULT_DC_CID = 10; private static final ArrayList<TrafficDescriptor> DEFAULT_TD_LIST = new ArrayList<>(); @Mock @Mock DcTesterFailBringUpAll mDcTesterFailBringUpAll; DcTesterFailBringUpAll mDcTesterFailBringUpAll; Loading Loading @@ -302,7 +301,7 @@ public class DataConnectionTest extends TelephonyTest { } } } } private void setSuccessfulSetupDataResponse(int cid, ArrayList<TrafficDescriptor> tds) { private void setSuccessfulSetupDataResponse(int cid) { doAnswer(invocation -> { doAnswer(invocation -> { final Message msg = (Message) invocation.getArguments()[10]; final Message msg = (Message) invocation.getArguments()[10]; Loading Loading @@ -330,7 +329,7 @@ public class DataConnectionTest extends TelephonyTest { .setMtuV6(1500) .setMtuV6(1500) .setPduSessionId(1) .setPduSessionId(1) .setQosBearerSessions(new ArrayList<>()) .setQosBearerSessions(new ArrayList<>()) .setTrafficDescriptors(tds) .setTrafficDescriptors(new ArrayList<>()) .build(); .build(); msg.getData().putParcelable("data_call_response", response); msg.getData().putParcelable("data_call_response", response); msg.arg1 = DataServiceCallback.RESULT_SUCCESS; msg.arg1 = DataServiceCallback.RESULT_SUCCESS; Loading Loading @@ -385,7 +384,7 @@ public class DataConnectionTest extends TelephonyTest { mDcp.mApnContext = mApnContext; mDcp.mApnContext = mApnContext; setSuccessfulSetupDataResponse(DEFAULT_DC_CID, DEFAULT_TD_LIST); setSuccessfulSetupDataResponse(DEFAULT_DC_CID); doAnswer(invocation -> { doAnswer(invocation -> { final Message msg = (Message) invocation.getArguments()[2]; final Message msg = (Message) invocation.getArguments()[2]; Loading Loading @@ -521,32 +520,7 @@ public class DataConnectionTest extends TelephonyTest { assertTrue(mDc.isInactive()); assertTrue(mDc.isInactive()); // Change the CID // Change the CID setSuccessfulSetupDataResponse(DEFAULT_DC_CID + 1, DEFAULT_TD_LIST); setSuccessfulSetupDataResponse(DEFAULT_DC_CID + 1); // Verify that ENTERPRISE was set up connectEvent(true); assertTrue(mDc.getNetworkCapabilities().hasCapability( NetworkCapabilities.NET_CAPABILITY_ENTERPRISE)); } @Test public void testConnectEventDuplicateContextIdsDifferentTDs() throws Exception { setUpDefaultData(DEFAULT_DC_CID); // Try to connect ENTERPRISE with the same CID as default replaceInstance(ConnectionParams.class, "mApnContext", mCp, mEnterpriseApnContext); doReturn(mApn1).when(mEnterpriseApnContext).getApnSetting(); doReturn(ApnSetting.TYPE_ENTERPRISE_STRING).when(mEnterpriseApnContext).getApnType(); doReturn(ApnSetting.TYPE_ENTERPRISE).when(mEnterpriseApnContext).getApnTypeBitmask(); // Verify that ENTERPRISE wasn't set up connectEvent(false); assertTrue(mDc.isInactive()); // Change the TrafficDescriptors ArrayList<TrafficDescriptor> tdList = new ArrayList<>(); tdList.add(new TrafficDescriptor("dnn", DataConnection.getEnterpriseOsAppId())); setSuccessfulSetupDataResponse(DEFAULT_DC_CID, tdList); // Verify that ENTERPRISE was set up // Verify that ENTERPRISE was set up connectEvent(true); connectEvent(true); Loading