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

Commit fc43ea86 authored by Sailesh Nepal's avatar Sailesh Nepal
Browse files

Add user ID parameter for getSimCallMangaer

The sim call manager depends on the default dialer
which is a per user setting.

This CL adds a user ID to the getSimCallManager API.

BUG: 22790160
Change-Id: Icaf1db6c6943b3ddbd16a946a81d1bfb734d761f
parent 03bb751b
Loading
Loading
Loading
Loading
+22 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.server.telecom;
package com.android.server.telecom;


import android.app.ActivityManager;
import android.Manifest;
import android.Manifest;
import android.content.ComponentName;
import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
@@ -275,8 +276,28 @@ public final class PhoneAccountRegistrar {
     * 3. Otherwise, we return null.
     * 3. Otherwise, we return null.
     */
     */
    public PhoneAccountHandle getSimCallManager() {
    public PhoneAccountHandle getSimCallManager() {
        long token = Binder.clearCallingIdentity();
        int user;
        try {
            user = ActivityManager.getCurrentUser();
        } finally {
            Binder.restoreCallingIdentity(token);
        }
        return getSimCallManager(user);
    }

    /**
     * Returns the {@link PhoneAccountHandle} corresponding to the currently active SIM Call
     * Manager. SIM Call Manager returned corresponds to the following priority order:
     * 1. If a SIM Call Manager {@link PhoneAccount} is registered for the same package as the
     * default dialer, then that one is returned.
     * 2. If there is a SIM Call Manager {@link PhoneAccount} registered which matches the
     * carrier configuration's default, then that one is returned.
     * 3. Otherwise, we return null.
     */
    public PhoneAccountHandle getSimCallManager(int user) {
        // Get the default dialer in case it has a connection manager associated with it.
        // Get the default dialer in case it has a connection manager associated with it.
        String dialerPackage = DefaultDialerManager.getDefaultDialerApplication(mContext);
        String dialerPackage = DefaultDialerManager.getDefaultDialerApplication(mContext, user);


        // Check carrier config.
        // Check carrier config.
        String defaultSimCallManager = null;
        String defaultSimCallManager = null;
+13 −1
Original line number Original line Diff line number Diff line
@@ -256,13 +256,25 @@ public class TelecomServiceImpl {


        @Override
        @Override
        public PhoneAccountHandle getSimCallManager() {
        public PhoneAccountHandle getSimCallManager() {
            long token  = Binder.clearCallingIdentity();
            int user;
            try {
                user = ActivityManager.getCurrentUser();
            } finally {
                Binder.restoreCallingIdentity(token);
            }
            return getSimCallManagerForUser(user);
        }

        @Override
        public PhoneAccountHandle getSimCallManagerForUser(int user) {
            synchronized (mLock) {
            synchronized (mLock) {
                try {
                try {
                    PhoneAccountHandle accountHandle = null;
                    PhoneAccountHandle accountHandle = null;


                    long token = Binder.clearCallingIdentity();
                    long token = Binder.clearCallingIdentity();
                    try {
                    try {
                        accountHandle = mPhoneAccountRegistrar.getSimCallManager();
                        accountHandle = mPhoneAccountRegistrar.getSimCallManager(user);
                    } finally {
                    } finally {
                        // We restore early so that isVisibleToCaller invocation below uses the
                        // We restore early so that isVisibleToCaller invocation below uses the
                        // right user context.
                        // right user context.