Revert "Use TelecomManager.isInCall instead of TelephonyManager.getCallState"

This reverts commit c34796508035266fd5991490bb3a2301be6d0b5f.

Reason for revert: breaks tests

Bug: 257538981
Change-Id: Idadaf4a48d814d97644abe8c790d12b8912165d2
Fixes: 261505371
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 07c4b44..dd02e02 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -59,7 +59,7 @@
 import android.graphics.drawable.Drawable;
 import android.location.LocationManager;
 import android.provider.Settings;
-import android.telecom.TelecomManager;
+import android.telephony.TelephonyManager;
 import android.util.AndroidException;
 import android.util.ArraySet;
 import android.util.Log;
@@ -2139,8 +2139,13 @@
                 mContext.getContentResolver(),
                 Settings.Global.ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED, 0) != 0;
         boolean isSystemUserUnlocked = isUserUnlocked(UserHandle.SYSTEM);
+        boolean inCall = false;
+        TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
+        if (telephonyManager != null) {
+            inCall = telephonyManager.getCallState() != TelephonyManager.CALL_STATE_IDLE;
+        }
         boolean isUserSwitchDisallowed = hasUserRestrictionForUser(DISALLOW_USER_SWITCH, mUserId);
-        return (allowUserSwitchingWhenSystemUserLocked || isSystemUserUnlocked) && !inCall()
+        return (allowUserSwitchingWhenSystemUserLocked || isSystemUserUnlocked) && !inCall
                 && !isUserSwitchDisallowed;
     }
 
@@ -2179,8 +2184,11 @@
             android.Manifest.permission.MANAGE_USERS,
             android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional = true)
     public @UserSwitchabilityResult int getUserSwitchability(UserHandle userHandle) {
+        final TelephonyManager tm =
+                (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+
         int flags = SWITCHABILITY_STATUS_OK;
-        if (inCall()) {
+        if (tm.getCallState() != TelephonyManager.CALL_STATE_IDLE) {
             flags |= SWITCHABILITY_STATUS_USER_IN_CALL;
         }
         if (hasUserRestrictionForUser(DISALLOW_USER_SWITCH, userHandle)) {
@@ -5614,11 +5622,6 @@
         }
     }
 
-    private boolean inCall() {
-        final TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class);
-        return telecomManager != null && telecomManager.isInCall();
-    }
-
     /* Cache key for anything that assumes that userIds cannot be re-used without rebooting. */
     private static final String CACHE_KEY_STATIC_USER_PROPERTIES = "cache_key.static_user_props";