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

Commit 286c318a authored by Thomas Stuart's avatar Thomas Stuart Committed by Android (Google) Code Review
Browse files

Merge "decouple TelecomManager#getSelfManagedPhoneAccounts (2/3)" into tm-dev

parents bb72d0fe 4e1184dc
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -40754,8 +40754,9 @@ package android.telecom {
    method public String getDefaultDialerPackage();
    method public String getDefaultDialerPackage();
    method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public android.telecom.PhoneAccountHandle getDefaultOutgoingPhoneAccount(String);
    method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public android.telecom.PhoneAccountHandle getDefaultOutgoingPhoneAccount(String);
    method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.READ_SMS, android.Manifest.permission.READ_PHONE_NUMBERS}, conditional=true) public String getLine1Number(android.telecom.PhoneAccountHandle);
    method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.READ_SMS, android.Manifest.permission.READ_PHONE_NUMBERS}, conditional=true) public String getLine1Number(android.telecom.PhoneAccountHandle);
    method @NonNull @RequiresPermission(android.Manifest.permission.MANAGE_OWN_CALLS) public java.util.List<android.telecom.PhoneAccountHandle> getOwnSelfManagedPhoneAccounts();
    method public android.telecom.PhoneAccount getPhoneAccount(android.telecom.PhoneAccountHandle);
    method public android.telecom.PhoneAccount getPhoneAccount(android.telecom.PhoneAccountHandle);
    method @RequiresPermission(anyOf={"android.permission.READ_PRIVILEGED_PHONE_STATE", android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.MANAGE_OWN_CALLS}) public java.util.List<android.telecom.PhoneAccountHandle> getSelfManagedPhoneAccounts();
    method @NonNull @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public java.util.List<android.telecom.PhoneAccountHandle> getSelfManagedPhoneAccounts();
    method public android.telecom.PhoneAccountHandle getSimCallManager();
    method public android.telecom.PhoneAccountHandle getSimCallManager();
    method @Nullable public android.telecom.PhoneAccountHandle getSimCallManagerForSubscription(int);
    method @Nullable public android.telecom.PhoneAccountHandle getSimCallManagerForSubscription(int);
    method @Nullable public String getSystemDialerPackage();
    method @Nullable public String getSystemDialerPackage();
+35 −16
Original line number Original line Diff line number Diff line
@@ -1292,31 +1292,22 @@ public class TelecomManager {
    }
    }


    /**
    /**
     * Returns a list of {@link PhoneAccountHandle}s for self-managed {@link ConnectionService}s.
     * Returns a list of {@link PhoneAccountHandle}s for all self-managed
     * {@link ConnectionService}s owned by the calling {@link UserHandle}.
     * <p>
     * <p>
     * Self-Managed {@link ConnectionService}s have a {@link PhoneAccount} with
     * Self-Managed {@link ConnectionService}s have a {@link PhoneAccount} with
     * {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.
     * {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.
     * <p>
     * <p>
     * Requires permission {@link android.Manifest.permission#READ_PHONE_STATE}, or that the caller
     * Requires permission {@link android.Manifest.permission#READ_PHONE_STATE}, or that the caller
     * is the default dialer app to get all phone account handles.
     * is the default dialer app.
     * <P>
     * If the caller doesn't meet any of the above requirements and has {@link
     * android.Manifest.permission#MANAGE_OWN_CALLS}, the caller can get only the phone account
     * handles they have registered.
     * <p>
     * <p>
     * A {@link SecurityException} will be thrown if the caller is not the default dialer
     * A {@link SecurityException} will be thrown if a called is not the default dialer, or lacks
     * or the caller does not have at least one of the following permissions:
     * the {@link android.Manifest.permission#READ_PHONE_STATE} permission.
     * {@link android.Manifest.permission#READ_PHONE_STATE} permission,
     * {@link android.Manifest.permission#MANAGE_OWN_CALLS} permission
     *
     *
     * @return A list of {@code PhoneAccountHandle} objects.
     * @return A list of {@code PhoneAccountHandle} objects.
     */
     */
    @RequiresPermission(anyOf = {
    @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
            READ_PRIVILEGED_PHONE_STATE,
    public @NonNull List<PhoneAccountHandle> getSelfManagedPhoneAccounts() {
            android.Manifest.permission.READ_PHONE_STATE,
            android.Manifest.permission.MANAGE_OWN_CALLS
    })
    public List<PhoneAccountHandle> getSelfManagedPhoneAccounts() {
        ITelecomService service = getTelecomService();
        ITelecomService service = getTelecomService();
        if (service != null) {
        if (service != null) {
            try {
            try {
@@ -1329,6 +1320,34 @@ public class TelecomManager {
        return new ArrayList<>();
        return new ArrayList<>();
    }
    }


    /**
     * Returns a list of {@link PhoneAccountHandle}s owned by the calling self-managed
     * {@link ConnectionService}.
     * <p>
     * Self-Managed {@link ConnectionService}s have a {@link PhoneAccount} with
     * {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.
     * <p>
     * Requires permission {@link android.Manifest.permission#MANAGE_OWN_CALLS}
     * <p>
     * A {@link SecurityException} will be thrown if a caller lacks the
     * {@link android.Manifest.permission#MANAGE_OWN_CALLS} permission.
     *
     * @return A list of {@code PhoneAccountHandle} objects.
     */
    @RequiresPermission(Manifest.permission.MANAGE_OWN_CALLS)
    public @NonNull List<PhoneAccountHandle> getOwnSelfManagedPhoneAccounts() {
        ITelecomService service = getTelecomService();
        if (service != null) {
            try {
                return service.getOwnSelfManagedPhoneAccounts(mContext.getOpPackageName(),
                        mContext.getAttributionTag());
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        throw new IllegalStateException("Telecom is not available");
    }

    /**
    /**
     * Returns a list of {@link PhoneAccountHandle}s including those which have not been enabled
     * Returns a list of {@link PhoneAccountHandle}s including those which have not been enabled
     * by the user.
     * by the user.
+6 −0
Original line number Original line Diff line number Diff line
@@ -65,6 +65,12 @@ interface ITelecomService {
    List<PhoneAccountHandle> getSelfManagedPhoneAccounts(String callingPackage,
    List<PhoneAccountHandle> getSelfManagedPhoneAccounts(String callingPackage,
            String callingFeatureId);
            String callingFeatureId);


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

    /**
    /**
     * @see TelecomManager#getPhoneAccountsSupportingScheme
     * @see TelecomManager#getPhoneAccountsSupportingScheme
     */
     */