Always call unbindService no matter what bindService returns

According to Android API reference, unbindService should be called
as long as bindService was called (no matter succeed or not).

CarrierServiceBindHelper only call unbindService when bindService
succeed, this may leaks the ServiceConnection.

mServiceBound, which is used to mark if the bindService succeed, is
removed. We don't need it to conditionally call unbindService now.

Bug: 201423849
Test: CarrierServiceBindHelperTest
Change-Id: Icfb3de7154bf6f3324ce39d71a0b8cb484b52605
diff --git a/src/java/com/android/internal/telephony/CarrierServiceBindHelper.java b/src/java/com/android/internal/telephony/CarrierServiceBindHelper.java
index 4b4980e..162da24 100644
--- a/src/java/com/android/internal/telephony/CarrierServiceBindHelper.java
+++ b/src/java/com/android/internal/telephony/CarrierServiceBindHelper.java
@@ -71,9 +71,6 @@
     private final PackageChangeReceiver mPackageMonitor = new CarrierServicePackageMonitor();
     private final LocalLog mLocalLog = new LocalLog(100);
 
-    // 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) {
@@ -291,7 +288,6 @@
                         (r) -> mHandler.post(r),
                         connection)) {
                     logdWithLocalLog("service bound");
-                    mServiceBound = true;
                     return;
                 }
 
@@ -346,16 +342,13 @@
             carrierPackage = null;
             carrierServiceClass = null;
 
-            // Actually unbind
-            if (mServiceBound) {
-                logdWithLocalLog("Unbinding from carrier app");
-                mServiceBound = false;
+            // Always call unbindService, no matter if bindService succeed.
+            if (connection != null) {
                 mContext.unbindService(connection);
-            } else {
-                logdWithLocalLog("Not bound, skipping unbindService call");
+                logdWithLocalLog("Unbinding from carrier app");
+                connection = null;
+                mUnbindScheduledUptimeMillis = -1;
             }
-            connection = null;
-            mUnbindScheduledUptimeMillis = -1;
         }
 
         private void cancelScheduledUnbind() {