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

Commit 5922ec2b authored by Hall Liu's avatar Hall Liu Committed by Android (Google) Code Review
Browse files

Merge "Add API to inform Telephony that call filtering is complete"

parents 71a2c83a 49cabccc
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -10231,6 +10231,7 @@ package android.telecom {
    method @Nullable public android.telecom.PhoneAccountHandle getPhoneAccountHandle();
    method @Nullable public final String getTelecomCallId();
    method @Deprecated public void onAudioStateChanged(android.telecom.AudioState);
    method @RequiresPermission(android.Manifest.permission.READ_CONTACTS) public void onCallFilteringCompleted(boolean, boolean);
    method public final void resetConnectionTime();
    method public void setCallDirection(int);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public final void setConnectTimeMillis(@IntRange(from=0) long);
@@ -10407,6 +10408,7 @@ package android.telecom {
  }
  public final class RemoteConnection {
    method @RequiresPermission(android.Manifest.permission.READ_CONTACTS) public void onCallFilteringCompleted(boolean, boolean);
    method @Deprecated public void setAudioState(android.telecom.AudioState);
  }
+19 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.telecom;

import static android.Manifest.permission.MODIFY_PHONE_STATE;

import android.Manifest;
import android.annotation.ElapsedRealtimeLong;
import android.annotation.IntDef;
import android.annotation.IntRange;
@@ -3357,6 +3358,24 @@ public abstract class Connection extends Conferenceable {
     */
    public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}

    /**
     * Indicates that call filtering in Telecom is complete
     *
     * This method is called for a connection created via
     * {@link ConnectionService#onCreateIncomingConnection} when call filtering completes in
     * Telecom, including checking the blocked number db, per-contact settings, and custom call
     * filtering apps.
     *
     * @param isBlocked {@code true} if the call was blocked, {@code false} otherwise. If this is
     *                  {@code true}, {@link #onDisconnect()} will be called soon after
     *                  this is called.
     * @param isInContacts Indicates whether the caller is in the user's contacts list.
     * @hide
     */
    @SystemApi
    @RequiresPermission(Manifest.permission.READ_CONTACTS)
    public void onCallFilteringCompleted(boolean isBlocked, boolean isInContacts) { }

    static String toLogSafePhoneNumber(String number) {
        // For unknown number, log empty string.
        if (number == null) {
+41 −0
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ public abstract class ConnectionService extends Service {
    private static final String SESSION_POST_DIAL_CONT = "CS.oPDC";
    private static final String SESSION_PULL_EXTERNAL_CALL = "CS.pEC";
    private static final String SESSION_SEND_CALL_EVENT = "CS.sCE";
    private static final String SESSION_CALL_FILTERING_COMPLETED = "CS.oCFC";
    private static final String SESSION_HANDOVER_COMPLETE = "CS.hC";
    private static final String SESSION_EXTRAS_CHANGED = "CS.oEC";
    private static final String SESSION_START_RTT = "CS.+RTT";
@@ -200,6 +201,7 @@ public abstract class ConnectionService extends Service {
    private static final int MSG_ADD_PARTICIPANT = 39;
    private static final int MSG_EXPLICIT_CALL_TRANSFER = 40;
    private static final int MSG_EXPLICIT_CALL_TRANSFER_CONSULTATIVE = 41;
    private static final int MSG_ON_CALL_FILTERING_COMPLETED = 42;

    private static Connection sNullConnection;

@@ -721,6 +723,22 @@ public abstract class ConnectionService extends Service {
            }
        }

        @Override
        public void onCallFilteringCompleted(String callId, boolean isBlocked, boolean isInContacts,
                Session.Info sessionInfo) {
            Log.startSession(sessionInfo, SESSION_CALL_FILTERING_COMPLETED);
            try {
                SomeArgs args = SomeArgs.obtain();
                args.arg1 = callId;
                args.arg2 = isBlocked;
                args.arg3 = isInContacts;
                args.arg4 = Log.createSubsession();
                mHandler.obtainMessage(MSG_ON_CALL_FILTERING_COMPLETED, args).sendToTarget();
            } finally {
                Log.endSession();
            }
        }

        @Override
        public void onExtrasChanged(String callId, Bundle extras, Session.Info sessionInfo) {
            Log.startSession(sessionInfo, SESSION_EXTRAS_CHANGED);
@@ -1354,6 +1372,21 @@ public abstract class ConnectionService extends Service {
                    }
                    break;
                }
                case MSG_ON_CALL_FILTERING_COMPLETED: {
                    SomeArgs args = (SomeArgs) msg.obj;
                    try {
                        Log.continueSession((Session) args.arg4,
                                SESSION_HANDLER + SESSION_CALL_FILTERING_COMPLETED);
                        String callId = (String) args.arg1;
                        boolean isBlocked = (boolean) args.arg2;
                        boolean isInContacts = (boolean) args.arg3;
                        onCallFilteringCompleted(callId, isBlocked, isInContacts);
                    } finally {
                        args.recycle();
                        Log.endSession();
                    }
                    break;
                }
                case MSG_HANDOVER_COMPLETE: {
                    SomeArgs args = (SomeArgs) msg.obj;
                    try {
@@ -2345,6 +2378,14 @@ public abstract class ConnectionService extends Service {
        }
    }

    private void onCallFilteringCompleted(String callId, boolean isBlocked, boolean isInContacts) {
        Log.i(this, "onCallFilteringCompleted(%s, %b, %b)", isBlocked, isInContacts);
        Connection connection = findConnectionForAction(callId, "onCallFilteringCompleted");
        if (connection != null) {
            connection.onCallFilteringCompleted(isBlocked, isInContacts);
        }
    }

    /**
     * Notifies a {@link Connection} that a handover has completed.
     *
+24 −0
Original line number Diff line number Diff line
@@ -16,8 +16,10 @@

package android.telecom;

import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.hardware.camera2.CameraManager;
import android.net.Uri;
@@ -1197,6 +1199,28 @@ public final class RemoteConnection {
        }
    }

    /**
     * Notifies this {@link RemoteConnection} that call filtering has completed, as well as
     * the results of a contacts lookup for the remote party.
     * @param isBlocked Whether call filtering indicates that the call should be blocked
     * @param isInContacts Whether the remote party is in the user's contacts
     * @hide
     */
    @SystemApi
    @RequiresPermission(Manifest.permission.READ_CONTACTS)
    public void onCallFilteringCompleted(boolean isBlocked, boolean isInContacts) {
        Log.startSession("RC.oCFC", getActiveOwnerInfo());
        try {
            if (mConnected) {
                mConnectionService.onCallFilteringCompleted(mConnectionId, isBlocked, isInContacts,
                        null /*Session.Info*/);
            }
        } catch (RemoteException ignored) {
        } finally {
            Log.endSession();
        }
    }

    /**
     * Notifies this {@link RemoteConnection} of a response to a previous remotely-initiated RTT
     * upgrade request sent via {@link Connection#sendRemoteRttRequest}.
+3 −0
Original line number Diff line number Diff line
@@ -118,6 +118,9 @@ oneway interface IConnectionService {

    void sendCallEvent(String callId, String event, in Bundle extras, in Session.Info sessionInfo);

    void onCallFilteringCompleted(String callId, boolean isBlocked, boolean isInContacts,
            in Session.Info sessionInfo);

    void onExtrasChanged(String callId, in Bundle extras, in Session.Info sessionInfo);

    void startRtt(String callId, in ParcelFileDescriptor fromInCall,