[automerger skipped] [Satellite MMS Support] Fix sending mms over Iwlan during non terrestrial network am: 628c180a87 -s ours

am skip reason: Merged-In Ie919c5af447b70eac72b8a9ffd57ebb5a40ddb34 with SHA-1 d0208d49bc is already in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Mms/+/27069239

Change-Id: I8ad34f985d34b44d282ad197b90153229550d2c5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/OWNERS b/OWNERS
index 01985bc..1befe3e 100644
--- a/OWNERS
+++ b/OWNERS
@@ -6,3 +6,4 @@
 jianxiangp@google.com
 stephshi@google.com
 bellavicevh@google.com
+sasindran@google.com
diff --git a/src/com/android/mms/service/LogUtil.java b/src/com/android/mms/service/LogUtil.java
index 349af32..49ab3f1 100644
--- a/src/com/android/mms/service/LogUtil.java
+++ b/src/com/android/mms/service/LogUtil.java
@@ -16,71 +16,72 @@
 
 package com.android.mms.service;
 
-import android.util.Log;
+
+import android.telephony.Rlog;
 
 /**
  * Logging utility
  */
 public class LogUtil {
-    private static final String TAG = "MmsService";
+    public static final String TAG = "MmsService";
 
     public static void i(final String requestId, final String message) {
-        Log.i(TAG, "[" + requestId + "] " + message);
+        Rlog.i(TAG, "[" + requestId + "] " + message);
     }
 
     public static void i(final String message) {
-        Log.i(TAG, message);
+        Rlog.i(TAG, message);
     }
 
     public static void d(final String requestId, final String message) {
-        Log.d(TAG, "[" + requestId + "] " + message);
+        Rlog.d(TAG, "[" + requestId + "] " + message);
     }
 
     public static void d(final String message) {
-        Log.d(TAG, message);
+        Rlog.d(TAG, message);
     }
 
     public static void v(final String requestId, final String message) {
-        Log.v(TAG, "[" + requestId + "] " + message);
+        Rlog.v(TAG, "[" + requestId + "] " + message);
     }
 
     public static void v(final String message) {
-        Log.v(TAG, message);
+        Rlog.v(TAG, message);
     }
 
     public static void e(final String requestId, final String message, final Throwable t) {
-        Log.e(TAG, "[" + requestId + "] " + message, t);
+        Rlog.e(TAG, "[" + requestId + "] " + message, t);
     }
 
     public static void e(final String message, final Throwable t) {
-        Log.e(TAG, message, t);
+        Rlog.e(TAG, message, t);
     }
 
     public static void e(final String requestId, final String message) {
-        Log.e(TAG, "[" + requestId + "] " + message);
+        Rlog.e(TAG, "[" + requestId + "] " + message);
     }
 
     public static void e(final String message) {
-        Log.e(TAG, message);
+        Rlog.e(TAG, message);
     }
 
     public static void w(final String requestId, final String message, final Throwable t) {
-        Log.w(TAG, "[" + requestId + "] " + message, t);
+        Rlog.w(TAG, "[" + requestId + "] " + message, t);
     }
 
     public static void w(final String message, final Throwable t) {
-        Log.w(TAG, message, t);
+        Rlog.w(TAG, message, t);
     }
 
     public static void w(final String requestId, final String message) {
-        Log.w(TAG, "[" + requestId + "] " + message);
+        Rlog.w(TAG, "[" + requestId + "] " + message);
     }
 
     public static void w(final String message) {
-        Log.w(TAG, message);
+        Rlog.w(TAG, message);
     }
 
     public static boolean isLoggable(final int logLevel) {
-        return Log.isLoggable(TAG, logLevel);
+        return Rlog.isLoggable(TAG, logLevel);
     }
 }
diff --git a/src/com/android/mms/service/MmsHttpClient.java b/src/com/android/mms/service/MmsHttpClient.java
index 7978a71..367253e 100644
--- a/src/com/android/mms/service/MmsHttpClient.java
+++ b/src/com/android/mms/service/MmsHttpClient.java
@@ -31,7 +31,6 @@
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.mms.service.exception.MmsHttpException;
-import com.android.mms.service.exception.VoluntaryDisconnectMmsHttpException;
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
@@ -51,9 +50,6 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -90,11 +86,6 @@
     private final Network mNetwork;
     private final ConnectivityManager mConnectivityManager;
 
-    /** Store all currently open connections, for potential voluntarily early disconnect. */
-    private final Set<HttpURLConnection> mAllUrlConnections = ConcurrentHashMap.newKeySet();
-    /** Flag indicating whether a disconnection is voluntary. */
-    private final AtomicBoolean mVoluntarilyDisconnectingConnections = new AtomicBoolean(false);
-
     /**
      * Constructor
      *
@@ -144,7 +135,6 @@
             maybeWaitForIpv4(requestId, url);
             // Now get the connection
             connection = (HttpURLConnection) mNetwork.openConnection(url, proxy);
-            if (connection != null) mAllUrlConnections.add(connection);
             connection.setDoInput(true);
             connection.setConnectTimeout(
                     mmsConfig.getInt(SmsManager.MMS_CONFIG_HTTP_SOCKET_TIMEOUT));
@@ -247,46 +237,15 @@
             LogUtil.e(requestId, "HTTP: invalid URL protocol " + redactedUrl, e);
             throw new MmsHttpException(0/*statusCode*/, "Invalid URL protocol " + redactedUrl, e);
         } catch (IOException e) {
-            if (mVoluntarilyDisconnectingConnections.get()) {
-                // If in the process of voluntarily disconnecting all connections, the exception
-                // is casted as VoluntaryDisconnectMmsHttpException to indicate this attempt is
-                // cancelled rather than failure.
-                LogUtil.d(requestId,
-                        "HTTP voluntarily disconnected due to WLAN network available");
-                throw new VoluntaryDisconnectMmsHttpException(0/*statusCode*/,
-                        "Expected disconnection due to WLAN network available");
-            } else {
-                LogUtil.e(requestId, "HTTP: IO failure ", e);
-                throw new MmsHttpException(0/*statusCode*/, e);
-            }
+            LogUtil.e(requestId, "HTTP: IO failure", e);
+            throw new MmsHttpException(0/*statusCode*/, e);
         } finally {
             if (connection != null) {
                 connection.disconnect();
-                mAllUrlConnections.remove(connection);
-                // If all connections are done disconnected, flag voluntary disconnection done if
-                // applicable.
-                if (mAllUrlConnections.isEmpty() && mVoluntarilyDisconnectingConnections
-                        .compareAndSet(/*expectedValue*/true, /*newValue*/false)) {
-                    LogUtil.d("All voluntarily disconnected connections are removed.");
-                }
             }
         }
     }
 
-    /**
-     * Voluntarily disconnect all Http URL connections. This will trigger
-     * {@link VoluntaryDisconnectMmsHttpException} to be thrown, to indicate voluntary disconnection
-     */
-    public void disconnectAllUrlConnections() {
-        LogUtil.d("Disconnecting all Url connections, size = " + mAllUrlConnections.size());
-        if (mAllUrlConnections.isEmpty()) return;
-        mVoluntarilyDisconnectingConnections.set(true);
-        for (HttpURLConnection connection : mAllUrlConnections) {
-            // TODO: An improvement is to check the writing/reading progress before disconnect.
-            connection.disconnect();
-        }
-    }
-
     private void maybeWaitForIpv4(final String requestId, final URL url) {
         // If it's a literal IPv4 address and we're on an IPv6-only network,
         // wait until IPv4 is available.
diff --git a/src/com/android/mms/service/MmsNetworkManager.java b/src/com/android/mms/service/MmsNetworkManager.java
index 7b8da24..65718b7 100644
--- a/src/com/android/mms/service/MmsNetworkManager.java
+++ b/src/com/android/mms/service/MmsNetworkManager.java
@@ -45,10 +45,8 @@
  * Manages the MMS network connectivity
  */
 public class MmsNetworkManager {
-    /** Device Config Keys */
     private static final String MMS_SERVICE_NETWORK_REQUEST_TIMEOUT_MILLIS =
             "mms_service_network_request_timeout_millis";
-    private static final String MMS_ENHANCEMENT_ENABLED = "mms_enhancement_enabled";
 
     // Default timeout used to call ConnectivityManager.requestNetwork if the
     // MMS_SERVICE_NETWORK_REQUEST_TIMEOUT_MILLIS flag is not set.
@@ -61,8 +59,6 @@
 
     /* Event created when receiving ACTION_CARRIER_CONFIG_CHANGED */
     private static final int EVENT_CARRIER_CONFIG_CHANGED = 1;
-    /** Event when a WLAN network newly available despite of the existing available one. */
-    private static final int EVENT_IWLAN_NETWORK_NEWLY_AVAILABLE = 2;
 
     private final Context mContext;
 
@@ -70,8 +66,6 @@
     // We need this when we unbind from it. This is also used to indicate if the
     // MMS network is available.
     private Network mNetwork;
-    /** Whether an Iwlan MMS network is available to use. */
-    private boolean mIsLastAvailableNetworkIwlan;
     // The current count of MMS requests that require the MMS network
     // If mMmsRequestCount is 0, we should release the MMS network.
     private int mMmsRequestCount;
@@ -126,9 +120,6 @@
                     // Reload mNetworkReleaseTimeoutMillis from CarrierConfigManager.
                     handleCarrierConfigChanged();
                     break;
-                case EVENT_IWLAN_NETWORK_NEWLY_AVAILABLE:
-                    onIwlanNetworkNewlyAvailable();
-                    break;
                 default:
                     LogUtil.e("MmsNetworkManager: ignoring message of unexpected type " + msg.what);
             }
@@ -200,17 +191,6 @@
         }
     };
 
-    /**
-     * Called when a WLAN network newly available. This new WLAN network should replace the
-     * existing network and retry sending traffic on this network.
-     */
-    private void onIwlanNetworkNewlyAvailable() {
-        if (mMmsHttpClient == null || mNetwork == null) return;
-        LogUtil.d("onIwlanNetworkNewlyAvailable net " + mNetwork.getNetId());
-        mMmsHttpClient.disconnectAllUrlConnections();
-        populateHttpClientWithCurrentNetwork();
-    }
-
     private void handleCarrierConfigChanged() {
         final CarrierConfigManager configManager =
                 (CarrierConfigManager)
@@ -254,13 +234,8 @@
             // onAvailable will always immediately be followed by a onCapabilitiesChanged. Check
             // network status here is enough.
             super.onCapabilitiesChanged(network, nc);
-            final NetworkInfo networkInfo = getConnectivityManager().getNetworkInfo(network);
-            // wlan network is preferred over wwan network, because its existence meaning it's
-            // recommended by QualifiedNetworksService.
-            final boolean isWlan = networkInfo != null
-                    && networkInfo.getSubtype() == TelephonyManager.NETWORK_TYPE_IWLAN;
             LogUtil.w("NetworkCallbackListener.onCapabilitiesChanged: network="
-                    + network + ", isWlan=" + isWlan + ", nc=" + nc);
+                    + network + ", nc=" + nc);
             synchronized (MmsNetworkManager.this) {
                 final boolean isAvailable =
                         nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED);
@@ -273,20 +248,12 @@
                     return;
                 }
 
-                // Use new available network
-                if (isAvailable) {
-                    if (mNetwork == null) {
-                        mNetwork = network;
-                        MmsNetworkManager.this.notifyAll();
-                    } else if (mDeps.isMmsEnhancementEnabled()
-                            // Iwlan network newly available, try send MMS over the new network.
-                            && !mIsLastAvailableNetworkIwlan && isWlan) {
-                        mNetwork = network;
-                        mEventHandler.sendEmptyMessage(EVENT_IWLAN_NETWORK_NEWLY_AVAILABLE);
-                    }
-                    mIsLastAvailableNetworkIwlan = isWlan;
+                // New available network
+                if (mNetwork == null && isAvailable) {
                     mIsSatelliteTransport = Flags.satelliteInternet()
                             && nc.hasTransport(NetworkCapabilities.TRANSPORT_SATELLITE);
+                    mNetwork = network;
+                    MmsNetworkManager.this.notifyAll();
                 }
             }
         }
@@ -310,11 +277,6 @@
                     DEFAULT_MMS_SERVICE_NETWORK_REQUEST_TIMEOUT_MILLIS);
         }
 
-        public boolean isMmsEnhancementEnabled() {
-            return DeviceConfig.getBoolean(
-                    DeviceConfig.NAMESPACE_TELEPHONY, MMS_ENHANCEMENT_ENABLED, true);
-        }
-
         public int getAdditionalNetworkAcquireTimeoutMillis() {
             return ADDITIONAL_NETWORK_ACQUIRE_TIMEOUT_MILLIS;
         }
@@ -452,22 +414,17 @@
      * Release the MMS network when nobody is holding on to it.
      *
      * @param requestId          request ID for logging.
-     * @param canRelease         whether the request can be released. An early release of a request
-     *                           can result in unexpected network torn down, as that network is used
-     *                           for immediate retry.
      * @param shouldDelayRelease whether the release should be delayed for a carrier-configured
      *                           timeout (default 5 seconds), the regular use case is to delay this
      *                           for DownloadRequests to use the network for sending an
      *                           acknowledgement on the same network.
      */
-    public void releaseNetwork(final String requestId, final boolean canRelease,
-            final boolean shouldDelayRelease) {
+    public void releaseNetwork(final String requestId, final boolean shouldDelayRelease) {
         synchronized (this) {
             if (mMmsRequestCount > 0) {
                 mMmsRequestCount -= 1;
-                LogUtil.d(requestId, "MmsNetworkManager: release, count=" + mMmsRequestCount
-                        + " canRelease=" + canRelease);
-                if (mMmsRequestCount < 1 && canRelease) {
+                LogUtil.d(requestId, "MmsNetworkManager: release, count=" + mMmsRequestCount);
+                if (mMmsRequestCount < 1) {
                     if (shouldDelayRelease) {
                         // remove previously posted task and post a delayed task on the release
                         // handler to release the network
@@ -542,19 +499,15 @@
     public MmsHttpClient getOrCreateHttpClient() {
         synchronized (this) {
             if (mMmsHttpClient == null) {
-                populateHttpClientWithCurrentNetwork();
+                if (mNetwork != null) {
+                    // Create new MmsHttpClient for the current Network
+                    mMmsHttpClient = new MmsHttpClient(mContext, mNetwork, mConnectivityManager);
+                }
             }
             return mMmsHttpClient;
         }
     }
 
-    // Create new MmsHttpClient for the current Network
-    private void populateHttpClientWithCurrentNetwork() {
-        if (mNetwork != null) {
-            mMmsHttpClient = new MmsHttpClient(mContext, mNetwork, mConnectivityManager);
-        }
-    }
-
     /**
      * Get the APN name for the active network
      *
diff --git a/src/com/android/mms/service/MmsRequest.java b/src/com/android/mms/service/MmsRequest.java
index ce743aa..02480f3 100644
--- a/src/com/android/mms/service/MmsRequest.java
+++ b/src/com/android/mms/service/MmsRequest.java
@@ -44,7 +44,6 @@
 import com.android.mms.service.exception.ApnException;
 import com.android.mms.service.exception.MmsHttpException;
 import com.android.mms.service.exception.MmsNetworkException;
-import com.android.mms.service.exception.VoluntaryDisconnectMmsHttpException;
 import com.android.mms.service.metrics.MmsStats;
 
 import java.util.UUID;
@@ -177,14 +176,14 @@
         byte[] response = null;
         int retryId = 0;
         currentState = MmsRequestState.PrepareForHttpRequest;
-        int attemptedTimes = 0;
+
         if (!prepareForHttpRequest()) { // Prepare request, like reading pdu data from user
             LogUtil.e(requestId, "Failed to prepare for request");
             result = SmsManager.MMS_ERROR_IO_ERROR;
         } else { // Execute
             long retryDelaySecs = 2;
             // Try multiple times of MMS HTTP request, depending on the error.
-            while (retryId < RETRY_TIMES) {
+            for (retryId = 0; retryId < RETRY_TIMES; retryId++) {
                 httpStatusCode = 0; // Clear for retry.
                 MonitorTelephonyCallback connectionStateCallback = new MonitorTelephonyCallback();
                 try {
@@ -229,12 +228,8 @@
                     result = SmsManager.MMS_ERROR_UNABLE_CONNECT_MMS;
                     break;
                 } catch (MmsHttpException e) {
-                    if (e instanceof VoluntaryDisconnectMmsHttpException) {
-                        result = Activity.RESULT_CANCELED;
-                    } else {
-                        LogUtil.e(requestId, "HTTP or network I/O failure", e);
-                        result = SmsManager.MMS_ERROR_HTTP_FAILURE;
-                    }
+                    LogUtil.e(requestId, "HTTP or network I/O failure", e);
+                    result = SmsManager.MMS_ERROR_HTTP_FAILURE;
                     httpStatusCode = e.getStatusCode();
                     // Retry
                 } catch (Exception e) {
@@ -242,36 +237,13 @@
                     result = SmsManager.MMS_ERROR_UNSPECIFIED;
                     break;
                 } finally {
-                    // Don't release the MMS network if the last attempt was voluntarily
-                    // cancelled (due to better network available), because releasing the request
-                    // could result that network being torn down as it's thought to be useless.
-                    boolean canRelease = false;
-                    if (result != Activity.RESULT_CANCELED) {
-                        retryId++;
-                        canRelease = true;
-                    }
-                    // Otherwise, delay the release for successful download request.
-                    networkManager.releaseNetwork(requestId, canRelease,
-                            this instanceof DownloadRequest && result == Activity.RESULT_OK);
-
+                    // Release the MMS network immediately except successful DownloadRequest.
+                    networkManager.releaseNetwork(requestId,
+                            this instanceof DownloadRequest
+                                    && result == Activity.RESULT_OK);
                     stopListeningToDataConnectionState(connectionStateCallback);
                 }
 
-                // THEORETICALLY WOULDN'T OCCUR - PUTTING HERE AS A SAFETY NET.
-                // TODO: REMOVE WITH FLAG mms_enhancement_enabled after soaking enough time, V-QPR.
-                // Only possible if network kept disconnecting due to Activity.RESULT_CANCELED,
-                // causing retryId doesn't increase and thus stuck in the infinite loop.
-                // However, it's theoretically impossible because RESULT_CANCELED is only triggered
-                // when a WLAN network becomes newly available in addition to an existing network.
-                // Therefore, the WLAN network's own death cannot be triggered by RESULT_CANCELED,
-                // and thus must result in retryId++.
-                if (++attemptedTimes > RETRY_TIMES * 2) {
-                    LogUtil.e(requestId, "Retry is performed too many times");
-                    reportAnomaly("MMS retried too many times",
-                            UUID.fromString("038c9155-5daa-4515-86ae-aafdd33c1435"));
-                    break;
-                }
-
                 if (result != Activity.RESULT_CANCELED) {
                     try { // Cool down retry if the previous attempt wasn't voluntarily cancelled.
                         new CountDownLatch(1).await(retryDelaySecs, TimeUnit.SECONDS);
diff --git a/src/com/android/mms/service/MmsService.java b/src/com/android/mms/service/MmsService.java
index 388eceb..6213513 100644
--- a/src/com/android/mms/service/MmsService.java
+++ b/src/com/android/mms/service/MmsService.java
@@ -24,6 +24,7 @@
 import android.annotation.Nullable;
 import android.app.PendingIntent;
 import android.app.Service;
+import android.content.ContentProvider;
 import android.content.ContentResolver;
 import android.content.ContentUris;
 import android.content.ContentValues;
@@ -1095,6 +1096,11 @@
             LogUtil.e("Uri is null");
             return 0;
         }
+        int contentUriUserID = ContentProvider.getUserIdFromUri(contentUri, UserHandle.myUserId());
+        if (UserHandle.myUserId() != contentUriUserID) {
+            LogUtil.e("Uri is invalid");
+            return 0;
+        }
         Callable<Integer> copyPduToArray = new Callable<Integer>() {
             public Integer call() {
                 ParcelFileDescriptor.AutoCloseInputStream inStream = null;
diff --git a/src/com/android/mms/service/exception/VoluntaryDisconnectMmsHttpException.java b/src/com/android/mms/service/exception/VoluntaryDisconnectMmsHttpException.java
deleted file mode 100644
index 2b6840a..0000000
--- a/src/com/android/mms/service/exception/VoluntaryDisconnectMmsHttpException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.mms.service.exception;
-
-/**
- * Thrown when voluntarily disconnect an MMS http connection to trigger immediate retry. This
- * exception indicates the connection is voluntarily cancelled, instead of a failure.
- */
-public class VoluntaryDisconnectMmsHttpException extends MmsHttpException{
-    public VoluntaryDisconnectMmsHttpException(int statusCode, String message) {
-        super(statusCode, message);
-    }
-}
diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp
index 5821367..9689e31 100644
--- a/tests/robotests/Android.bp
+++ b/tests/robotests/Android.bp
@@ -3,6 +3,7 @@
 //############################################################
 
 package {
+    default_team: "trendy_team_fwk_telephony",
     default_applicable_licenses: ["Android-Apache-2.0"],
 }
 
diff --git a/tests/robotests/src/com/android/mms/service/MmsNetworkManagerTest.java b/tests/robotests/src/com/android/mms/service/MmsNetworkManagerTest.java
index 70b1a0a..dff2bab 100644
--- a/tests/robotests/src/com/android/mms/service/MmsNetworkManagerTest.java
+++ b/tests/robotests/src/com/android/mms/service/MmsNetworkManagerTest.java
@@ -22,16 +22,13 @@
 import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.fail;
 
-import static org.junit.Assert.assertNotSame;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.verify;
-import static org.robolectric.RuntimeEnvironment.getMasterScheduler;
 
 import android.content.Context;
 import android.net.ConnectivityManager;
@@ -41,7 +38,6 @@
 import android.net.NetworkInfo;
 import android.os.PersistableBundle;
 import android.telephony.CarrierConfigManager;
-import android.telephony.TelephonyManager;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -51,7 +47,6 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 
-import java.lang.reflect.Field;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -155,29 +150,6 @@
     }
 
     @Test
-    public void testAvailableNetwork_wwanNetworkReplacedByWlanNetwork() throws Exception {
-        MmsHttpClient mockMmsHttpClient = mock(MmsHttpClient.class);
-        doReturn(true).when(mDeps).isMmsEnhancementEnabled();
-
-        // WWAN network is always available, whereas WLAN network needs extra time to be set up.
-        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mNetworkInfo).getSubtype();
-        doReturn(TelephonyManager.NETWORK_TYPE_IWLAN).when(mNetworkInfo2).getSubtype();
-
-        final NetworkCallback callback = acquireAvailableNetworkAndGetCallback(
-                mTestNetwork /* expectNetwork */, MMS_APN /* expectApn */);
-        replaceInstance(MmsNetworkManager.class, "mMmsHttpClient", mMnm,
-                mockMmsHttpClient);
-
-        // The WLAN network become available.
-        callback.onCapabilitiesChanged(mTestNetwork2, USABLE_NC);
-        getMasterScheduler().advanceToLastPostedRunnable();
-
-        // Verify current connections disconnect, then the client is replaced with a new network.
-        verify(mockMmsHttpClient).disconnectAllUrlConnections();
-        assertNotSame(mMnm.getOrCreateHttpClient(), mockMmsHttpClient);
-    }
-
-    @Test
     public void testAvailableNetwork_networkBecomeSuspend() throws Exception {
         final NetworkCallback callback = acquireAvailableNetworkAndGetCallback(
                 mTestNetwork /* expectNetwork */, MMS_APN /* expectApn */);
@@ -284,12 +256,4 @@
 
         return future;
     }
-
-    /** Helper to replace instance field with reflection. */
-    private void replaceInstance(final Class c, final String instanceName,
-            final Object obj, final Object newValue) throws Exception {
-        Field field = c.getDeclaredField(instanceName);
-        field.setAccessible(true);
-        field.set(obj, newValue);
-    }
 }
diff --git a/tests/unittests/Android.bp b/tests/unittests/Android.bp
index 6ac0586..ced87a9 100644
--- a/tests/unittests/Android.bp
+++ b/tests/unittests/Android.bp
@@ -1,4 +1,5 @@
 package {
+    default_team: "trendy_team_fwk_telecom",
     // See: http://go/android-license-faq
     default_applicable_licenses: ["Android-Apache-2.0"],
 }
diff --git a/tests/unittests/src/com/android/mms/service/MmsHttpClientTest.java b/tests/unittests/src/com/android/mms/service/MmsHttpClientTest.java
index e144ef7..6fc2e72 100644
--- a/tests/unittests/src/com/android/mms/service/MmsHttpClientTest.java
+++ b/tests/unittests/src/com/android/mms/service/MmsHttpClientTest.java
@@ -18,10 +18,7 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.junit.Assert.assertThrows;
-import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
@@ -31,29 +28,17 @@
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.Network;
 import android.os.Bundle;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 
 import androidx.test.core.app.ApplicationProvider;
 
-import com.android.mms.service.exception.VoluntaryDisconnectMmsHttpException;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.MockitoAnnotations;
 
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.net.SocketException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
 public class MmsHttpClientTest {
     // Mocked classes
     private Context mContext;
@@ -153,39 +138,4 @@
         assertThat(phoneNo).contains(subscriberPhoneNumber);
         verify(mSubscriptionManager).getPhoneNumber(subId);
     }
-
-    @Test
-    public void testDisconnectAllUrlConnections() throws IOException {
-        Network mockNetwork = mock(Network.class);
-        HttpURLConnection mockConnection = mock(HttpURLConnection.class);
-        doReturn(mockConnection).when(mockNetwork).openConnection(any(), any());
-        doReturn(mockNetwork).when(mockNetwork).getPrivateDnsBypassingCopy();
-        ConnectivityManager mockCm = mock(ConnectivityManager.class);
-        Bundle config = new Bundle();
-
-        // The external thread that voluntarily silently close the socket.
-        CountDownLatch latch = new CountDownLatch(1);
-        final ExecutorService externalThread = Executors.newSingleThreadExecutor();
-        doAnswer(invok -> {
-            latch.countDown();
-            return null;
-        }).when(mockConnection).disconnect();
-
-        MmsHttpClient clientUT = new MmsHttpClient(mContext, mockNetwork, mockCm);
-        doAnswer(invok -> {
-            externalThread.execute(clientUT::disconnectAllUrlConnections);
-            // connection.disconnect is silent, but it will trigger SocketException thrown from the
-            // connect thread.
-            if (latch.await(1, TimeUnit.SECONDS)) {
-                throw new SocketException("Socket Closed");
-            }
-            return null;
-        }).when(mockConnection).getResponseCode();
-
-        // Verify SocketException is transformed into VoluntaryDisconnectMmsHttpException
-        assertThrows(VoluntaryDisconnectMmsHttpException.class, () -> {
-            clientUT.execute("http://test", new byte[0], "GET", false,
-                                "", 0, config, 1, "requestId");
-        });
-    }
 }