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

Commit 8555d952 authored by Ayush Sharma's avatar Ayush Sharma
Browse files

Flag guard switch to work profile dialog for call

Bug: 258629881
Test: Manual
Change-Id: I170ad40ad642e75b5dde19626cee9e05854214e8
parent 69c948cc
Loading
Loading
Loading
Loading
+23 −13
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ import android.os.UserManager;
import android.provider.BlockedNumberContract;
import android.provider.BlockedNumberContract.SystemContract;
import android.provider.CallLog.Calls;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.sysprop.TelephonyProperties;
import android.telecom.CallAttributes;
@@ -1916,14 +1917,17 @@ public class CallsManager extends Call.ListenerBase
                                return CompletableFuture.completedFuture(null);
                            }
                            if (accountSuggestions == null || accountSuggestions.isEmpty()) {
                                if (isSwitchToManagedProfileDialogFlagEnabled()) {
                                    Uri callUri = callToPlace.getHandle();
                                    if (PhoneAccount.SCHEME_TEL.equals(callUri.getScheme())) {
                                        int managedProfileUserId = getManagedProfileUserId(mContext,
                                                initiatingUser.getIdentifier());
                                        if (managedProfileUserId != UserHandle.USER_NULL
                                            && mPhoneAccountRegistrar.getCallCapablePhoneAccounts(
                                                &&
                                                mPhoneAccountRegistrar.getCallCapablePhoneAccounts(
                                                        handle.getScheme(), false,
                                            UserHandle.of(managedProfileUserId), false).size()
                                                        UserHandle.of(managedProfileUserId),
                                                        false).size()
                                                        != 0) {
                                            boolean dialogShown = showSwitchToManagedProfileDialog(
                                                    callUri, initiatingUser, managedProfileUserId);
@@ -1932,6 +1936,7 @@ public class CallsManager extends Call.ListenerBase
                                            }
                                        }
                                    }
                                }

                                Log.i(CallsManager.this, "Aborting call since there are no"
                                        + " available accounts.");
@@ -2085,6 +2090,11 @@ public class CallsManager extends Call.ListenerBase
        return UserHandle.USER_NULL;
    }

    private boolean isSwitchToManagedProfileDialogFlagEnabled() {
        return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER,
                "enable_switch_to_managed_profile_dialog", false);
    }

    private boolean showSwitchToManagedProfileDialog(Uri callUri, UserHandle initiatingUser,
            int managedProfileUserId) {
        try {