Fixes service disconnect crash when changing users

Changing users crashes system ui because service disconnected from
unprovisioned user that had no connection. Fix by always disconnecting
if connected before trying to connect to service. Requires follow up
change to have new provisioned user to connect to service.

Change-Id: I350ec45b90fa297c6ffe4932325c3b07653538f3
Fixes: 68929438
Test: manual
diff --git a/packages/SystemUI/src/com/android/systemui/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/OverviewProxyService.java
index 3878cd1..4194701 100644
--- a/packages/SystemUI/src/com/android/systemui/OverviewProxyService.java
+++ b/packages/SystemUI/src/com/android/systemui/OverviewProxyService.java
@@ -78,7 +78,6 @@
 
             @Override
             public void onUserSwitched() {
-                disconnectFromLauncherService();
                 mConnectionBackoffAttempts = 0;
                 startConnectionToCurrentUser();
             }
@@ -100,8 +99,10 @@
     }
 
     public void startConnectionToCurrentUser() {
+        disconnectFromLauncherService();
+
         // If user has not setup yet or already connected, do not try to connect
-        if (!mDeviceProvisionedController.isCurrentUserSetup() || mOverviewProxy != null) {
+        if (!mDeviceProvisionedController.isCurrentUserSetup()) {
             return;
         }
         mHandler.removeCallbacks(mConnectionRunnable);
@@ -124,7 +125,9 @@
     }
 
     private void disconnectFromLauncherService() {
-        mContext.unbindService(mOverviewServiceConnection);
-        mOverviewProxy = null;
+        if (mOverviewProxy != null) {
+            mContext.unbindService(mOverviewServiceConnection);
+            mOverviewProxy = null;
+        }
     }
 }