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

Commit 6a4a3f3e authored by Aishwarya Mallampati's avatar Aishwarya Mallampati
Browse files

Do not create multiple satellite listeners in onServiceConnected.

Bug: 341835822
Test: atest SatelliteManagerTestOnMockService
Manual Testing: b/341835822#comment21

Change-Id: I16c30c7ce24cdc1b0d0386edd8c90cd07e7aa3e3
parent e207f934
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -66,6 +66,8 @@ public class SatelliteModemInterface {
    @NonNull private static SatelliteModemInterface sInstance;
    @NonNull private static SatelliteModemInterface sInstance;
    @NonNull private final Context mContext;
    @NonNull private final Context mContext;
    @NonNull private final DemoSimulator mDemoSimulator;
    @NonNull private final DemoSimulator mDemoSimulator;
    @NonNull private final SatelliteListener mVendorListener;
    @NonNull private final SatelliteListener mDemoListener;
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    @NonNull protected final ExponentialBackoff mExponentialBackoff;
    @NonNull protected final ExponentialBackoff mExponentialBackoff;
    @NonNull private final Object mLock = new Object();
    @NonNull private final Object mLock = new Object();
@@ -237,6 +239,8 @@ public class SatelliteModemInterface {
            SatelliteController satelliteController, @NonNull Looper looper) {
            SatelliteController satelliteController, @NonNull Looper looper) {
        mContext = context;
        mContext = context;
        mDemoSimulator = DemoSimulator.make(context, satelliteController);
        mDemoSimulator = DemoSimulator.make(context, satelliteController);
        mVendorListener = new SatelliteListener(false);
        mDemoListener = new SatelliteListener(true);
        mIsSatelliteServiceSupported = getSatelliteServiceSupport();
        mIsSatelliteServiceSupported = getSatelliteServiceSupport();
        mSatelliteController = satelliteController;
        mSatelliteController = satelliteController;
        mExponentialBackoff = new ExponentialBackoff(REBIND_INITIAL_DELAY, REBIND_MAXIMUM_DELAY,
        mExponentialBackoff = new ExponentialBackoff(REBIND_INITIAL_DELAY, REBIND_MAXIMUM_DELAY,
@@ -349,11 +353,8 @@ public class SatelliteModemInterface {
            mSatelliteService = ISatellite.Stub.asInterface(service);
            mSatelliteService = ISatellite.Stub.asInterface(service);
            mExponentialBackoff.stop();
            mExponentialBackoff.stop();
            try {
            try {
                SatelliteListener vendorListener = new SatelliteListener(false);
                mSatelliteService.setSatelliteListener(mVendorListener);
                mSatelliteService.setSatelliteListener(vendorListener);
                mDemoSimulator.setSatelliteListener(mDemoListener);

                SatelliteListener demoListener = new SatelliteListener(true);
                mDemoSimulator.setSatelliteListener(demoListener);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                // TODO: Retry setSatelliteListener
                // TODO: Retry setSatelliteListener
                logd("setSatelliteListener: RemoteException " + e);
                logd("setSatelliteListener: RemoteException " + e);