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

Commit b1854ccc authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Remove call identification APIs."

parents 0dc5968b 49fdedb1
Loading
Loading
Loading
Loading
+0 −32
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.os.SystemClock;
import android.os.Trace;
import android.provider.ContactsContract.Contacts;
import android.telecom.CallAudioState;
import android.telecom.CallIdentification;
import android.telecom.Conference;
import android.telecom.ConnectionService;
import android.telecom.DisconnectCause;
@@ -144,7 +143,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                                 Bundle extras, boolean isLegacy);
        void onHandoverFailed(Call call, int error);
        void onHandoverComplete(Call call);
        void onCallIdentificationChanged(Call call);
    }

    public abstract static class ListenerBase implements Listener {
@@ -227,8 +225,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        public void onHandoverFailed(Call call, int error) {}
        @Override
        public void onHandoverComplete(Call call) {}
        @Override
        public void onCallIdentificationChanged(Call call) {}
    }

    private final CallerInfoLookupHelper.OnQueryCompleteListener mCallerInfoQueryListener =
@@ -542,11 +538,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     */
    private boolean mIsUsingCallFiltering = false;

    /**
     * {@link CallIdentification} provided by a {@link android.telecom.CallScreeningService}.
     */
    private CallIdentification mCallIdentification = null;

    /**
     * Persists the specified parameters and initializes the new instance.
     * @param context The context.
@@ -3199,29 +3190,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        mIsUsingCallFiltering = isUsingCallFiltering;
    }

    /**
     * Update the {@link CallIdentification} for a call.
     * @param callIdentification the {@link CallIdentification}.
     */
    public void setCallIdentification(CallIdentification callIdentification) {
        if (callIdentification != null) {
            Log.addEvent(this, LogUtils.Events.CALL_IDENTIFICATION_SET,
                    callIdentification.getCallScreeningPackageName());
        }
        mCallIdentification = callIdentification;

        for (Listener l : mListeners) {
            l.onCallIdentificationChanged(this);
        }
    }

    /**
     * @return Call identification returned by a {@link android.telecom.CallScreeningService}.
     */
    public CallIdentification getCallIdentification() {
        return mCallIdentification;
    }

    /**
     * When upgrading a call to video via
     * {@link VideoProviderProxy#onSendSessionModifyRequest(VideoProfile, VideoProfile)}, if the
+6 −16
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.os.Looper;
import android.os.UserHandle;
import android.os.PersistableBundle;
import android.provider.CallLog.Calls;
import android.telecom.CallIdentification;
import android.telecom.Connection;
import android.telecom.DisconnectCause;
import android.telecom.Log;
@@ -82,8 +81,7 @@ public final class CallLogManager extends CallsManagerListenerBase {
                int features, PhoneAccountHandle accountHandle, long creationDate,
                long durationInMillis, Long dataUsage, UserHandle initiatingUser, boolean isRead,
                @Nullable LogCallCompletedListener logCallCompletedListener, int callBlockReason,
                CharSequence callScreeningAppName, String callScreeningComponentName,
                CallIdentification callIdentification) {
                CharSequence callScreeningAppName, String callScreeningComponentName) {
            this.context = context;
            this.callerInfo = callerInfo;
            this.number = number;
@@ -102,7 +100,6 @@ public final class CallLogManager extends CallsManagerListenerBase {
            this.callBockReason = callBlockReason;
            this.callScreeningAppName = callScreeningAppName;
            this.callScreeningComponentName = callScreeningComponentName;
            this.callIdentification = callIdentification;
        }
        // Since the members are accessed directly, we don't use the
        // mXxxx notation.
@@ -127,8 +124,6 @@ public final class CallLogManager extends CallsManagerListenerBase {
        public final int callBockReason;
        public final CharSequence callScreeningAppName;
        public final String callScreeningComponentName;

        public final CallIdentification callIdentification;
    }

    private static final String TAG = CallLogManager.class.getSimpleName();
@@ -300,22 +295,20 @@ public final class CallLogManager extends CallsManagerListenerBase {
                        Connection.PROPERTY_ASSISTED_DIALING_USED,
                call.wasEverRttCall());

        CallIdentification callIdentification = call.getCallIdentification();

        if (callLogType == Calls.BLOCKED_TYPE) {
            logCall(call.getCallerInfo(), logNumber, call.getPostDialDigits(), formattedViaNumber,
                    call.getHandlePresentation(), callLogType, callFeatures, accountHandle,
                    creationTime, age, callDataUsage, call.isEmergencyCall(),
                    call.getInitiatingUser(), call.isSelfManaged(), logCallCompletedListener,
                    result.mCallBlockReason, result.mCallScreeningAppName,
                    result.mCallScreeningComponentName, callIdentification);
                    result.mCallScreeningComponentName);
        } else {
            logCall(call.getCallerInfo(), logNumber, call.getPostDialDigits(), formattedViaNumber,
                    call.getHandlePresentation(), callLogType, callFeatures, accountHandle,
                    creationTime, age, callDataUsage, call.isEmergencyCall(),
                    call.getInitiatingUser(), call.isSelfManaged(), logCallCompletedListener,
                    Calls.BLOCK_REASON_NOT_BLOCKED, null /*callScreeningAppName*/,
                    null /*callScreeningComponentName*/, callIdentification);
                    null /*callScreeningComponentName*/);
        }
    }

@@ -339,8 +332,6 @@ public final class CallLogManager extends CallsManagerListenerBase {
     * @param callBlockReason The reason why the call is blocked.
     * @param callScreeningAppName The call screening application name which block the call.
     * @param callScreeningComponentName The call screening component name which block the call.
     * @param callIdentification Call identification information, if provided by a call screening
     *                           service.
     */
    private void logCall(
            CallerInfo callerInfo,
@@ -360,8 +351,7 @@ public final class CallLogManager extends CallsManagerListenerBase {
            @Nullable LogCallCompletedListener logCallCompletedListener,
            int callBlockReason,
            CharSequence callScreeningAppName,
            String callScreeningComponentName,
            @Nullable CallIdentification callIdentification) {
            String callScreeningComponentName) {

        // On some devices, to avoid accidental redialing of emergency numbers, we *never* log
        // emergency calls to the Call Log.  (This behavior is set on a per-product basis, based
@@ -395,7 +385,7 @@ public final class CallLogManager extends CallsManagerListenerBase {
            AddCallArgs args = new AddCallArgs(mContext, callerInfo, number, postDialDigits,
                    viaNumber, presentation, callType, features, accountHandle, start, duration,
                    dataUsage, initiatingUser, isRead, logCallCompletedListener, callBlockReason,
                    callScreeningAppName, callScreeningComponentName, callIdentification);
                    callScreeningAppName, callScreeningComponentName);
            logCallAsync(args);
        } else {
          Log.d(TAG, "Not adding emergency call to call log.");
@@ -557,7 +547,7 @@ public final class CallLogManager extends CallsManagerListenerBase {
                    c.presentation, c.callType, c.features, c.accountHandle, c.timestamp,
                    c.durationInSec, c.dataUsage, userToBeInserted == null,
                    userToBeInserted, c.isRead, c.callBockReason, c.callScreeningAppName,
                    c.callScreeningComponentName, c.callIdentification);
                    c.callScreeningComponentName);
        }


+4 −27
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.telecom.CallIdentification;
import android.telecom.CallScreeningService;
import android.telecom.Log;
import android.telecom.Logging.Session;
@@ -74,28 +73,6 @@ public class CallScreeningServiceHelper {
                ComponentName componentName) throws RemoteException {
            // no-op; we don't allow this on outgoing calls.
        }

        @Override
        public void provideCallIdentification(String callId, CallIdentification callIdentification)
                throws RemoteException {
            Log.startSession("CSA.pCI");
            long token = Binder.clearCallingIdentity();
            try {
                synchronized (mTelecomLock) {
                    if (mCall != null && mCall.getId().equals(callId)) {
                        Log.i(TAG, "provideCallIdentification - got call ID");
                        callIdentification.setCallScreeningAppName(mAppLabelProxy.getAppLabel(
                                mPackageName));
                        callIdentification.setCallScreeningPackageName(mPackageName);
                        mFuture.complete(callIdentification);
                    }
                }
            } finally {
                Binder.restoreCallingIdentity(token);
                Log.endSession();
            }
            mFuture.complete(null);
        }
    }

    private final ParcelableCallUtils.Converter mParcelableCallUtilsConverter;
@@ -105,7 +82,7 @@ public class CallScreeningServiceHelper {
    private final Context mContext;
    private final AppLabelProxy mAppLabelProxy;
    private final Session mLoggingSession;
    private CompletableFuture<CallIdentification> mFuture;
    private CompletableFuture mFuture;
    private String mPackageName;

    public CallScreeningServiceHelper(Context context, TelecomSystem.SyncRoot telecomLock,
@@ -125,18 +102,18 @@ public class CallScreeningServiceHelper {
     * Builds a {@link CompletableFuture} which performs a bind to a {@link CallScreeningService}
     * @return
     */
    public CompletableFuture<CallIdentification> process() {
    public CompletableFuture process() {
        Log.d(this, "process");
        return bindAndGetCallIdentification();
    }

    public CompletableFuture<CallIdentification> bindAndGetCallIdentification() {
    public CompletableFuture bindAndGetCallIdentification() {
        Log.d(this, "bindAndGetCallIdentification");
        if (mPackageName == null) {
            return CompletableFuture.completedFuture(null);
        }

        mFuture = new CompletableFuture<>();
        mFuture = new CompletableFuture();

        ServiceConnection serviceConnection = new ServiceConnection() {
            @Override
+5 −13
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ import android.provider.BlockedNumberContract.SystemContract;
import android.provider.CallLog.Calls;
import android.provider.Settings;
import android.telecom.CallAudioState;
import android.telecom.CallIdentification;
import android.telecom.Conference;
import android.telecom.Connection;
import android.telecom.DisconnectCause;
@@ -1491,7 +1490,7 @@ public class CallsManager extends Call.ListenerBase
                        // We only want to provide a CallScreeningService with a call if its not in
                        // contacts.
                        if (!isInContacts) {
                            performCallIdentification(theCall);
                            bindForOutgoingCallerId(theCall);
                        }
            }, new LoggedHandlerExecutor(outgoingCallHandler, "CM.pCSB", mLock));
        }
@@ -1563,12 +1562,12 @@ public class CallsManager extends Call.ListenerBase
     * Performs call identification for an outgoing phone call.
     * @param theCall The outgoing call to perform identification.
     */
    private void performCallIdentification(Call theCall) {
    private void bindForOutgoingCallerId(Call theCall) {
        // Find the user chosen call screening app.
        String callScreeningApp =
                mRoleManagerAdapter.getDefaultCallScreeningApp();

        CompletableFuture<CallIdentification> future =
        CompletableFuture future =
                new CallScreeningServiceHelper(mContext,
                mLock,
                callScreeningApp,
@@ -1590,15 +1589,8 @@ public class CallsManager extends Call.ListenerBase
                        return null;
                    }
                }).process();

        // When we are done, apply call identification to the call.
        future.thenApply( v -> {
            Log.i(CallsManager.this, "setting caller ID: %s", v);
            if (v != null) {
                synchronized (mLock) {
                    theCall.setCallIdentification(v);
                }
            }
            Log.i(this, "Outgoing caller ID complete");
            return null;
        });
    }
+0 −5
Original line number Diff line number Diff line
@@ -697,11 +697,6 @@ public class InCallController extends CallsManagerListenerBase {
        public void onRemoteRttRequest(Call call, int requestId) {
            notifyRemoteRttRequest(call, requestId);
        }

        @Override
        public void onCallIdentificationChanged(Call call) {
            updateCall(call);
        }
    };

    private final SystemStateListener mSystemStateListener = new SystemStateListener() {
Loading