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

Commit a76ee855 authored by Hall Liu's avatar Hall Liu
Browse files

Implement the call filtering completed api

Bug: 177613111
Test: atest ConnectionServiceTest
Change-Id: I73f52aaae736684e2dcfc73a120a9e3dd3cc3f8c
parent 09fe0689
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3837,6 +3837,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        mIsUsingCallFiltering = isUsingCallFiltering;
    }

    public boolean isUsingCallFiltering() {
        return mIsUsingCallFiltering;
    }

    /**
     * Returns whether or not Volte call was used.
     *
+8 −0
Original line number Diff line number Diff line
@@ -759,6 +759,14 @@ public class CallsManager extends Call.ListenerBase
            return;
        }

        // Inform our connection service that call filtering is done (if it was performed at all).
        if (incomingCall.isUsingCallFiltering()) {
            boolean isInContacts = incomingCall.getCallerInfo() != null
                    && incomingCall.getCallerInfo().contactExists;
            incomingCall.getConnectionService().onCallFilteringCompleted(incomingCall,
                    !result.shouldAllowCall, isInContacts);
        }

        if (result.shouldAllowCall) {
            incomingCall.setPostCallPackageName(
                    getRoleManagerAdapter().getDefaultCallScreeningApp());
+21 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.telecom;

import static android.Manifest.permission.MODIFY_PHONE_STATE;

import android.Manifest;
import android.app.AppOpsManager;
import android.content.ComponentName;
import android.content.Context;
@@ -1835,6 +1836,26 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        }
    }

    void onCallFilteringCompleted(Call call, boolean isBlocked, boolean isInContacts) {
        final String callId = mCallIdMapper.getCallId(call);
        if (callId != null && isServiceValid("onCallFilteringCompleted")) {
            try {
                logOutgoing("onCallFilteringCompleted %b %b", isBlocked, isInContacts);
                int contactsPermission = mContext.getPackageManager()
                        .checkPermission(Manifest.permission.READ_CONTACTS,
                                getComponentName().getPackageName());
                if (contactsPermission == PackageManager.PERMISSION_GRANTED) {
                    mServiceInterface.onCallFilteringCompleted(callId, isBlocked, isInContacts,
                            Log.getExternalSession(TELECOM_ABBREVIATION));
                } else {
                    logOutgoing("Skipping call filtering complete message for %s due"
                            + " to lack of READ_CONTACTS", getComponentName().getPackageName());
                }
            } catch (RemoteException ignored) {
            }
        }
    }

    void onExtrasChanged(Call call, Bundle extras) {
        final String callId = mCallIdMapper.getCallId(call);
        if (callId != null && isServiceValid("onExtrasChanged")) {
+4 −0
Original line number Diff line number Diff line
@@ -429,6 +429,10 @@ public class ConnectionServiceFixture implements TestFixture<IConnectionService>

        @Override
        public void handoverComplete(String callId, Session.Info sessionInfo) {}

        @Override
        public void onCallFilteringCompleted(String callId, boolean isBlocked, boolean isInContacts,
                Session.Info sessionInfo) { }
    }

    FakeConnectionServiceDelegate mConnectionServiceDelegate;