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

Commit 98a872d7 authored by Eugene Susla's avatar Eugene Susla
Browse files

Fix dialer cts test

Whether setting default dialer succeeds is propagated all the way to API,
and (apparently) enforced by cts, so it looks like we should wait for it

Fixes: 123718729
Test: atest android.telecom.cts.DefaultDialerOperationsTest#testSetDefaultDialerNoDialIntent_notSupported
Change-Id: I2f7b8d4a32d1b570d0aba8cc4cc529f58a9dbc20
parent 2f10a26a
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -28,11 +28,15 @@ import android.os.Binder;
import android.os.Process;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Slog;

import com.android.internal.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

/**
 * Class for managing the default dialer application that will receive incoming calls, and be
@@ -71,19 +75,15 @@ public class DefaultDialerManager {
            int user) {
        long identity = Binder.clearCallingIdentity();
        try {
            RoleManagerCallback.Future cb = new RoleManagerCallback.Future();
            context.getSystemService(RoleManager.class).addRoleHolderAsUser(
                    RoleManager.ROLE_DIALER, packageName, UserHandle.of(user),
                    AsyncTask.THREAD_POOL_EXECUTOR, new RoleManagerCallback() {
                        @Override
                        public void onSuccess() {}

                        @Override
                        public void onFailure() {
                            Log.w(TAG, "Failed to set default dialer to %s for user %s",
                                    packageName, user);
                        }
                    });
                    AsyncTask.THREAD_POOL_EXECUTOR, cb);
            cb.get(5, TimeUnit.SECONDS);
            return true;
        } catch (InterruptedException | ExecutionException | TimeoutException e) {
            Slog.e(TAG, "Failed to set default dialer to " + packageName + " for user " + user, e);
            return false;
        } finally {
            Binder.restoreCallingIdentity(identity);
        }