Search in sources :

Example 26 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project platform_frameworks_base by android.

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

use of android.telecom.PhoneAccountHandle in project robolectric by robolectric.

the class ShadowTelecomManager method getPhoneAccountsForPackage.

@Implementation
public List<PhoneAccountHandle> getPhoneAccountsForPackage() {
    Context context = ReflectionHelpers.getField(realObject, "mContext");
    List<PhoneAccountHandle> results = new LinkedList<>();
    for (PhoneAccountHandle handle : accounts.keySet()) {
        if (handle.getComponentName().getPackageName().equals(context.getPackageName())) {
            results.add(handle);
        }
    }
    return results;
}
Also used : Context(android.content.Context) PhoneAccountHandle(android.telecom.PhoneAccountHandle) LinkedList(java.util.LinkedList) Implementation(org.robolectric.annotation.Implementation)

Example 28 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project robolectric by robolectric.

the class ShadowTelecomManager method getCallCapablePhoneAccounts.

@Implementation(minSdk = M)
public List<PhoneAccountHandle> getCallCapablePhoneAccounts(boolean includeDisabledAccounts) {
    List<PhoneAccountHandle> result = new LinkedList<>();
    for (PhoneAccountHandle handle : accounts.keySet()) {
        PhoneAccount phoneAccount = accounts.get(handle);
        if (!phoneAccount.isEnabled() && !includeDisabledAccounts) {
            continue;
        }
        result.add(handle);
    }
    return result;
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) LinkedList(java.util.LinkedList) Implementation(org.robolectric.annotation.Implementation)

Example 29 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project robolectric by robolectric.

the class ShadowTelecomManagerTest method getCallCapablePhoneAccounts.

@Test
@Config(minSdk = M)
public void getCallCapablePhoneAccounts() {
    PhoneAccountHandle callCapableHandle = createHandle("id1");
    telecomService.registerPhoneAccount(PhoneAccount.builder(callCapableHandle, "enabled").setIsEnabled(true).build());
    PhoneAccountHandle notCallCapableHandler = createHandle("id2");
    telecomService.registerPhoneAccount(PhoneAccount.builder(notCallCapableHandler, "disabled").setIsEnabled(false).build());
    List<PhoneAccountHandle> callCapablePhoneAccounts = telecomService.getCallCapablePhoneAccounts();
    assertThat(callCapablePhoneAccounts).contains(callCapableHandle);
    assertThat(callCapablePhoneAccounts).doesNotContain(notCallCapableHandler);
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 30 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project robolectric by robolectric.

the class ShadowTelecomManagerTest method clearAccountsForPackage.

@Test
@Config(minSdk = LOLLIPOP_MR1)
public void clearAccountsForPackage() {
    PhoneAccountHandle accountHandle1 = createHandle("a.package", "id1");
    telecomService.registerPhoneAccount(PhoneAccount.builder(accountHandle1, "another_package").build());
    PhoneAccountHandle accountHandle2 = createHandle("some.other.package", "id2");
    telecomService.registerPhoneAccount(PhoneAccount.builder(accountHandle2, "another_package").build());
    telecomService.clearAccountsForPackage(accountHandle1.getComponentName().getPackageName());
    assertThat(telecomService.getPhoneAccount(accountHandle1)).isNull();
    assertThat(telecomService.getPhoneAccount(accountHandle2)).isNotNull();
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

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