Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f48d67d authored by Hyundo Moon's avatar Hyundo Moon
Browse files

OppService: Fix IndexOutOfBoundException in UpdateThread

Due to the timing change between ProfileService#stop() and
ProfileService#cleanup(), the main thread and the UpdateThread were
accesing the same list (mShare) concurrently.

This CL calls the stopInternal() in BluetoothOppService#stop() so that
the list is cleaned up after the UpdateThread is stopped.

Bug: 321897599
Bug: 326135849
Test: atest BluetoothInstrumentationTests
Change-Id: I35d6507e32125aac63b38d0f26b8d8f1c62a1ac6
parent e8160a71
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import com.android.bluetooth.ObexServerSockets;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.content_profiles.ContentProfileErrorReportUtils;
import com.android.bluetooth.flags.Flags;
import com.android.bluetooth.sdp.SdpManagerNativeInterface;
import com.android.internal.annotations.VisibleForTesting;
import com.android.obex.ObexTransport;
@@ -289,7 +290,11 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                    1);
        }
        setBluetoothOppService(null);
        if (Flags.oppServiceFixIndexOutOfBoundsExceptionInUpdateThread()) {
            stopInternal();
        } else {
            mHandler.sendMessage(mHandler.obtainMessage(STOP_LISTENER));
        }

        setComponentAvailable(OPP_PROVIDER, false);
        setComponentAvailable(INCOMING_FILE_CONFIRM_ACTIVITY, false);
@@ -555,7 +560,9 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
        if (V) {
            Log.v(TAG, "onDestroy");
        }
        if (!Flags.oppServiceFixIndexOutOfBoundsExceptionInUpdateThread()) {
            stopListeners();
        }
        if (mBatches != null) {
            mBatches.clear();
        }
@@ -685,7 +692,9 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                        if (V) {
                            Log.v(TAG, "Bluetooth state changed: STATE_TURNING_OFF");
                        }
                        if (!Flags.oppServiceFixIndexOutOfBoundsExceptionInUpdateThread()) {
                            mHandler.sendMessage(mHandler.obtainMessage(STOP_LISTENER));
                        }
                        break;
                }
            }