Search in sources :

Example 36 with PhoneAccountHandle

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

the class Telecom method runRegisterSimPhoneAccount.

private void runRegisterSimPhoneAccount() throws RemoteException {
    final PhoneAccountHandle handle = getPhoneAccountHandleFromArgs();
    final String label = nextArgRequired();
    final String address = nextArgRequired();
    PhoneAccount account = PhoneAccount.builder(handle, label).setAddress(Uri.parse(address)).setSubscriptionAddress(Uri.parse(address)).setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER | PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION).setShortDescription(label).addSupportedUriScheme(PhoneAccount.SCHEME_TEL).addSupportedUriScheme(PhoneAccount.SCHEME_VOICEMAIL).build();
    mTelecomService.registerPhoneAccount(account);
    System.out.println("Success - " + handle + " registered.");
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle)

Example 37 with PhoneAccountHandle

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

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 38 with PhoneAccountHandle

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

the class Telecom method runSetPhoneAccountEnabled.

private void runSetPhoneAccountEnabled(boolean enabled) throws RemoteException {
    final PhoneAccountHandle handle = getPhoneAccountHandleFromArgs();
    final boolean success = mTelecomService.enablePhoneAccount(handle, enabled);
    if (success) {
        System.out.println("Success - " + handle + (enabled ? " enabled." : " disabled."));
    } else {
        System.out.println("Error - is " + handle + " a valid PhoneAccount?");
    }
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle)

Example 39 with PhoneAccountHandle

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

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 40 with PhoneAccountHandle

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

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