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

Commit fd237e10 authored by Thomas Stuart's avatar Thomas Stuart Committed by Alexandre Roux
Browse files

switch TelecomManager List getters to ParceledListSlice

It was shown that given a large phoneAccountHandles that are
over 1 mb, a TransactionTooLarge exception can be silently thrown
causing an empty list to be returned.

In order to prevent this behavior, all Lists that return a
PhoneAccountHandle or PhoneAccount have been switched to
ParceledListSlice.

bug: 236263294
Test: atest android.telecom.cts.PhoneAccountRegistrarTest
             #testRegisterPhoneAccountHandleWithFieldOverLimit
Change-Id: I025245b2a6f8cfaca86f268851a9d8f0817e07dd
Merged-In: I025245b2a6f8cfaca86f268851a9d8f0817e07dd
(cherry picked from commit d54a48f4)
Merged-In: I025245b2a6f8cfaca86f268851a9d8f0817e07dd
parent 0afdf58c
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -1274,7 +1274,7 @@ public class TelecomManager {
        if (service != null) {
        if (service != null) {
            try {
            try {
                return service.getPhoneAccountsSupportingScheme(uriScheme,
                return service.getPhoneAccountsSupportingScheme(uriScheme,
                        mContext.getOpPackageName());
                        mContext.getOpPackageName()).getList();
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsSupportingScheme", e);
                Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsSupportingScheme", e);
            }
            }
@@ -1316,7 +1316,7 @@ public class TelecomManager {
        if (service != null) {
        if (service != null) {
            try {
            try {
                return service.getSelfManagedPhoneAccounts(mContext.getOpPackageName(),
                return service.getSelfManagedPhoneAccounts(mContext.getOpPackageName(),
                        mContext.getAttributionTag());
                        mContext.getAttributionTag()).getList();
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.e(TAG, "Error calling ITelecomService#getSelfManagedPhoneAccounts()", e);
                Log.e(TAG, "Error calling ITelecomService#getSelfManagedPhoneAccounts()", e);
            }
            }
@@ -1342,7 +1342,7 @@ public class TelecomManager {
        if (service != null) {
        if (service != null) {
            try {
            try {
                return service.getCallCapablePhoneAccounts(includeDisabledAccounts,
                return service.getCallCapablePhoneAccounts(includeDisabledAccounts,
                        mContext.getOpPackageName(), mContext.getAttributionTag());
                        mContext.getOpPackageName(), mContext.getAttributionTag()).getList();
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts("
                Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts("
                        + includeDisabledAccounts + ")", e);
                        + includeDisabledAccounts + ")", e);
@@ -1366,7 +1366,7 @@ public class TelecomManager {
        ITelecomService service = getTelecomService();
        ITelecomService service = getTelecomService();
        if (service != null) {
        if (service != null) {
            try {
            try {
                return service.getPhoneAccountsForPackage(mContext.getPackageName());
                return service.getPhoneAccountsForPackage(mContext.getPackageName()).getList();
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsForPackage", e);
                Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsForPackage", e);
            }
            }
@@ -1426,7 +1426,7 @@ public class TelecomManager {
        ITelecomService service = getTelecomService();
        ITelecomService service = getTelecomService();
        if (service != null) {
        if (service != null) {
            try {
            try {
                return service.getAllPhoneAccounts();
                return service.getAllPhoneAccounts().getList();
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccounts", e);
                Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccounts", e);
            }
            }
@@ -1445,7 +1445,7 @@ public class TelecomManager {
        ITelecomService service = getTelecomService();
        ITelecomService service = getTelecomService();
        if (service != null) {
        if (service != null) {
            try {
            try {
                return service.getAllPhoneAccountHandles();
                return service.getAllPhoneAccountHandles().getList();
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountHandles", e);
                Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountHandles", e);
            }
            }
+7 −6
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import android.telecom.PhoneAccountHandle;
import android.net.Uri;
import android.net.Uri;
import android.os.Bundle;
import android.os.Bundle;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccount;
import android.content.pm.ParceledListSlice;


/**
/**
 * Interface used to interact with Telecom. Mostly this is used by TelephonyManager for passing
 * Interface used to interact with Telecom. Mostly this is used by TelephonyManager for passing
@@ -56,25 +57,25 @@ interface ITelecomService {
    /**
    /**
     * @see TelecomServiceImpl#getCallCapablePhoneAccounts
     * @see TelecomServiceImpl#getCallCapablePhoneAccounts
     */
     */
    List<PhoneAccountHandle> getCallCapablePhoneAccounts(
    ParceledListSlice<PhoneAccountHandle> getCallCapablePhoneAccounts(
            boolean includeDisabledAccounts, String callingPackage, String callingFeatureId);
            boolean includeDisabledAccounts, String callingPackage, String callingFeatureId);


    /**
    /**
     * @see TelecomServiceImpl#getSelfManagedPhoneAccounts
     * @see TelecomServiceImpl#getSelfManagedPhoneAccounts
     */
     */
    List<PhoneAccountHandle> getSelfManagedPhoneAccounts(String callingPackage,
    ParceledListSlice<PhoneAccountHandle> getSelfManagedPhoneAccounts(String callingPackage,
            String callingFeatureId);
            String callingFeatureId);


    /**
    /**
     * @see TelecomManager#getPhoneAccountsSupportingScheme
     * @see TelecomManager#getPhoneAccountsSupportingScheme
     */
     */
    List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(in String uriScheme,
    ParceledListSlice<PhoneAccountHandle> getPhoneAccountsSupportingScheme(in String uriScheme,
            String callingPackage);
            String callingPackage);


    /**
    /**
     * @see TelecomManager#getPhoneAccountsForPackage
     * @see TelecomManager#getPhoneAccountsForPackage
     */
     */
    List<PhoneAccountHandle> getPhoneAccountsForPackage(in String packageName);
    ParceledListSlice<PhoneAccountHandle> getPhoneAccountsForPackage(in String packageName);


    /**
    /**
     * @see TelecomManager#getPhoneAccount
     * @see TelecomManager#getPhoneAccount
@@ -89,12 +90,12 @@ interface ITelecomService {
    /**
    /**
     * @see TelecomManager#getAllPhoneAccounts
     * @see TelecomManager#getAllPhoneAccounts
     */
     */
    List<PhoneAccount> getAllPhoneAccounts();
    ParceledListSlice<PhoneAccount> getAllPhoneAccounts();


    /**
    /**
     * @see TelecomManager#getAllPhoneAccountHandles
     * @see TelecomManager#getAllPhoneAccountHandles
     */
     */
    List<PhoneAccountHandle> getAllPhoneAccountHandles();
    ParceledListSlice<PhoneAccountHandle> getAllPhoneAccountHandles();


    /**
    /**
     * @see TelecomServiceImpl#getSimCallManager
     * @see TelecomServiceImpl#getSimCallManager