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

Commit 5ed30d9b authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Only unbind if bind() returned success" am: 1d128c38 am: 7b724208

Change-Id: Iad5fa8385918f9dd0a67be5e893a924454957a88
parents 1c68c19a 7b724208
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -69,6 +69,9 @@ public class CarrierServiceBindHelper {
    public SparseArray<String> mLastSimState = new SparseArray<>();
    private final PackageChangeReceiver mPackageMonitor = new CarrierServicePackageMonitor();

    // whether we have successfully bound to the service
    private boolean mServiceBound = false;

    private BroadcastReceiver mUserUnlockedReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
@@ -279,6 +282,7 @@ public class CarrierServiceBindHelper {
                                Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE,
                                (r) -> mHandler.post(r),
                                connection)) {
                    mServiceBound = true;
                    return;
                }

@@ -333,11 +337,12 @@ public class CarrierServiceBindHelper {
            carrierServiceClass = null;

            // Actually unbind
            if (connection != null && connection.connected) {
            if (mServiceBound) {
                log("Unbinding from carrier app");
                mServiceBound = false;
                mContext.unbindService(connection);
            } else {
                log("Already unbound, skipping unbindService call");
                log("Not bound, skipping unbindService call");
            }
            connection = null;
            mUnbindScheduledUptimeMillis = -1;
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ public class CarrierServiceBindHelperTest extends TelephonyTest {
    }

    @Test
    public void testUnbindWhenNotConnected() throws Exception {
    public void testUnbindWhenNotBound() throws Exception {
        mCarrierServiceBindHelper = new CarrierServiceBindHelper(mContext);

        // Try unbinding without binding and make sure we don't throw an Exception