Search in sources :

Example 46 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project android_frameworks_base by crdroidandroid.

the class Telecom method runUnregisterPhoneAccount.

private void runUnregisterPhoneAccount() throws RemoteException {
    final PhoneAccountHandle handle = getPhoneAccountHandleFromArgs();
    mTelecomService.unregisterPhoneAccount(handle);
    System.out.println("Success - " + handle + " unregistered.");
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle)

Example 47 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project android_frameworks_base by crdroidandroid.

the class Telecom method getPhoneAccountHandleFromArgs.

private PhoneAccountHandle getPhoneAccountHandleFromArgs() throws RemoteException {
    final ComponentName component = parseComponentName(nextArgRequired());
    final String accountId = nextArgRequired();
    final String userSnInStr = nextArgRequired();
    UserHandle userHandle;
    try {
        final int userSn = Integer.parseInt(userSnInStr);
        userHandle = UserHandle.of(mUserManager.getUserHandle(userSn));
    } catch (NumberFormatException ex) {
        throw new IllegalArgumentException("Invalid user serial number " + userSnInStr);
    }
    return new PhoneAccountHandle(component, accountId, userHandle);
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) UserHandle(android.os.UserHandle) ComponentName(android.content.ComponentName)

Example 48 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project android_frameworks_base by crdroidandroid.

the class TelecomLoaderService method updateSimCallManagerPermissions.

private void updateSimCallManagerPermissions(PackageManagerInternal packageManagerInternal, int userId) {
    TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
    PhoneAccountHandle phoneAccount = telecomManager.getSimCallManager(userId);
    if (phoneAccount != null) {
        Slog.i(TAG, "updating sim call manager permissions for userId:" + userId);
        String packageName = phoneAccount.getComponentName().getPackageName();
        packageManagerInternal.grantDefaultPermissionsToDefaultSimCallManager(packageName, userId);
    }
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelecomManager(android.telecom.TelecomManager)

Example 49 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project android_frameworks_base by crdroidandroid.

the class TelecomLoaderService method registerDefaultAppProviders.

private void registerDefaultAppProviders() {
    final PackageManagerInternal packageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
    // Set a callback for the package manager to query the default sms app.
    packageManagerInternal.setSmsAppPackagesProvider(new PackageManagerInternal.PackagesProvider() {

        @Override
        public String[] getPackages(int userId) {
            synchronized (mLock) {
                if (mServiceConnection == null) {
                    if (mDefaultSmsAppRequests == null) {
                        mDefaultSmsAppRequests = new IntArray();
                    }
                    mDefaultSmsAppRequests.add(userId);
                    return null;
                }
            }
            ComponentName smsComponent = SmsApplication.getDefaultSmsApplication(mContext, true);
            if (smsComponent != null) {
                return new String[] { smsComponent.getPackageName() };
            }
            return null;
        }
    });
    // Set a callback for the package manager to query the default dialer app.
    packageManagerInternal.setDialerAppPackagesProvider(new PackageManagerInternal.PackagesProvider() {

        @Override
        public String[] getPackages(int userId) {
            synchronized (mLock) {
                if (mServiceConnection == null) {
                    if (mDefaultDialerAppRequests == null) {
                        mDefaultDialerAppRequests = new IntArray();
                    }
                    mDefaultDialerAppRequests.add(userId);
                    return null;
                }
            }
            String packageName = DefaultDialerManager.getDefaultDialerApplication(mContext);
            if (packageName != null) {
                return new String[] { packageName };
            }
            return null;
        }
    });
    // Set a callback for the package manager to query the default sim call manager.
    packageManagerInternal.setSimCallManagerPackagesProvider(new PackageManagerInternal.PackagesProvider() {

        @Override
        public String[] getPackages(int userId) {
            synchronized (mLock) {
                if (mServiceConnection == null) {
                    if (mDefaultSimCallManagerRequests == null) {
                        mDefaultSimCallManagerRequests = new IntArray();
                    }
                    mDefaultSimCallManagerRequests.add(userId);
                    return null;
                }
            }
            TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
            PhoneAccountHandle phoneAccount = telecomManager.getSimCallManager(userId);
            if (phoneAccount != null) {
                return new String[] { phoneAccount.getComponentName().getPackageName() };
            }
            return null;
        }
    });
}
Also used : IntArray(android.util.IntArray) PhoneAccountHandle(android.telecom.PhoneAccountHandle) PackageManagerInternal(android.content.pm.PackageManagerInternal) ComponentName(android.content.ComponentName) TelecomManager(android.telecom.TelecomManager)

Aggregations

PhoneAccountHandle (android.telecom.PhoneAccountHandle)49 PhoneAccount (android.telecom.PhoneAccount)17 TelecomManager (android.telecom.TelecomManager)14 ComponentName (android.content.ComponentName)9 Test (org.junit.Test)7 UserHandle (android.os.UserHandle)5 PackageManagerInternal (android.content.pm.PackageManagerInternal)4 SubscriptionInfo (android.telephony.SubscriptionInfo)4 TelephonyManager (android.telephony.TelephonyManager)4 IntArray (android.util.IntArray)4 Config (org.robolectric.annotation.Config)3 AlertDialog (android.app.AlertDialog)2 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 LinkedList (java.util.LinkedList)2 Implementation (org.robolectric.annotation.Implementation)2 Dialog (android.app.Dialog)1 Resources (android.content.res.Resources)1 SwitchPreference (android.support.v14.preference.SwitchPreference)1 Preference (android.support.v7.preference.Preference)1