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

Commit c87639eb authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Merge changes I60816545,Ib8c46b40

am: 9601ecbb

Change-Id: I9c760c5c85ca0282d94578538df360ca9a348886
parents 37c32185 9601ecbb
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ import com.android.server.telecom.callfiltering.AsyncBlockCheckFilter;
import com.android.server.telecom.callfiltering.BlockCheckerAdapter;
import com.android.server.telecom.callfiltering.CallFilterResultCallback;
import com.android.server.telecom.callfiltering.CallFilteringResult;
import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
import com.android.server.telecom.callfiltering.CallScreeningServiceController;
import com.android.server.telecom.callfiltering.DirectToVoicemailCallFilter;
import com.android.server.telecom.callfiltering.IncomingCallFilter;
@@ -609,7 +610,12 @@ public class CallsManager extends Call.ListenerBase
                    incomingCall.hasProperty(Connection.PROPERTY_EMERGENCY_CALLBACK_MODE),
                    incomingCall.isSelfManaged(),
                    extras.getBoolean(PhoneAccount.EXTRA_SKIP_CALL_FILTERING));
            onCallFilteringComplete(incomingCall, new CallFilteringResult(true, false, true, true));
            onCallFilteringComplete(incomingCall, new Builder()
                    .setShouldAllowCall(true)
                    .setShouldReject(false)
                    .setShouldAddToCallLog(true)
                    .setShouldShowNotification(true)
                    .build());
            incomingCall.setIsUsingCallFiltering(false);
            return;
        }
+1 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ public class LogUtils {
        public static final String BIND_SCREENING = "BIND_SCREENING";
        public static final String SCREENING_BOUND = "SCREENING_BOUND";
        public static final String SCREENING_SENT = "SCREENING_SENT";
        public static final String SCREENING_SKIPPED = "SCREENING_SKIPPED";
        public static final String CONTROLLER_SCREENING_COMPLETED =
                "CONTROLLER_SCREENING_COMPLETED";
        public static final String SCREENING_COMPLETED = "SCREENING_COMPLETED";
+16 −15
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.internal.telephony.CallerInfo;
import com.android.server.telecom.Call;
import com.android.server.telecom.CallerInfoLookupHelper;
import com.android.server.telecom.LogUtils;
import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
import com.android.server.telecom.settings.BlockedNumbersUtil;

/**
@@ -121,15 +122,15 @@ public class AsyncBlockCheckFilter extends AsyncTask<String, Void, Boolean>
        try {
            CallFilteringResult result;
            if (isBlocked) {
                result = new CallFilteringResult(
                        false, // shouldAllowCall
                        true, //shouldReject
                        true, //shouldAddToCallLog
                        false, // shouldShowNotification
                        convertBlockStatusToReason(), //callBlockReason
                        null, //callScreeningAppName
                        null //callScreeningComponentName
                );
                result = new Builder()
                        .setShouldAllowCall(false)
                        .setShouldReject(true)
                        .setShouldAddToCallLog(true)
                        .setShouldShowNotification(false)
                        .setCallBlockReason(convertBlockStatusToReason())
                        .setCallScreeningAppName(null)
                        .setCallScreeningComponentName(null)
                        .build();
                if (mCallBlockListener != null) {
                    String number = mIncomingCall.getHandle() == null ? null
                            : mIncomingCall.getHandle().getSchemeSpecificPart();
@@ -137,12 +138,12 @@ public class AsyncBlockCheckFilter extends AsyncTask<String, Void, Boolean>
                            mIncomingCall.getInitiatingUser());
                }
            } else {
                result = new CallFilteringResult(
                        true, // shouldAllowCall
                        false, // shouldReject
                        true, // shouldAddToCallLog
                        true // shouldShowNotification
                );
                result = new Builder()
                        .setShouldAllowCall(true)
                        .setShouldReject(false)
                        .setShouldAddToCallLog(true)
                        .setShouldShowNotification(true)
                        .build();
            }
            Log.addEvent(mIncomingCall, LogUtils.Events.BLOCK_CHECK_FINISHED,
                    BlockedNumberContract.SystemContract.blockStatusToString(mBlockStatus) + " "
+78 −50
Original line number Diff line number Diff line
@@ -21,47 +21,73 @@ import android.provider.CallLog.Calls;
import android.text.TextUtils;

public class CallFilteringResult {
    public boolean shouldAllowCall;
    public boolean shouldReject;
    public boolean shouldSilence;
    public boolean shouldAddToCallLog;
    public boolean shouldShowNotification;
    public int mCallBlockReason = CallLog.Calls.BLOCK_REASON_NOT_BLOCKED;
    public CharSequence mCallScreeningAppName = null;
    public String mCallScreeningComponentName = null;
    public static class Builder {
        private boolean mShouldAllowCall;
        private boolean mShouldReject;
        private boolean mShouldAddToCallLog;
        private boolean mShouldShowNotification;
        private boolean mShouldSilence = false;
        private int mCallBlockReason = Calls.BLOCK_REASON_NOT_BLOCKED;
        private CharSequence mCallScreeningAppName = null;
        private String mCallScreeningComponentName = null;

        public Builder setShouldAllowCall(boolean shouldAllowCall) {
            mShouldAllowCall = shouldAllowCall;
            return this;
        }

    public CallFilteringResult(boolean shouldAllowCall, boolean shouldReject, boolean
            shouldAddToCallLog, boolean shouldShowNotification) {
        this.shouldAllowCall = shouldAllowCall;
        this.shouldReject = shouldReject;
        this.shouldSilence = false;
        this.shouldAddToCallLog = shouldAddToCallLog;
        this.shouldShowNotification = shouldShowNotification;
        public Builder setShouldReject(boolean shouldReject) {
            mShouldReject = shouldReject;
            return this;
        }

    public CallFilteringResult(boolean shouldAllowCall, boolean shouldReject, boolean
            shouldAddToCallLog, boolean shouldShowNotification, int callBlockReason,
            CharSequence callScreeningAppName, String callScreeningComponentName) {
        this.shouldAllowCall = shouldAllowCall;
        this.shouldReject = shouldReject;
        this.shouldSilence = false;
        this.shouldAddToCallLog = shouldAddToCallLog;
        this.shouldShowNotification = shouldShowNotification;
        this.mCallBlockReason = callBlockReason;
        this.mCallScreeningAppName = callScreeningAppName;
        this.mCallScreeningComponentName = callScreeningComponentName;
        public Builder setShouldAddToCallLog(boolean shouldAddToCallLog) {
            mShouldAddToCallLog = shouldAddToCallLog;
            return this;
        }

    public CallFilteringResult(boolean shouldAllowCall, boolean shouldReject, boolean
            shouldSilence, boolean shouldAddToCallLog, boolean shouldShowNotification) {
        this.shouldAllowCall = shouldAllowCall;
        this.shouldReject = shouldReject;
        this.shouldSilence = shouldSilence;
        this.shouldAddToCallLog = shouldAddToCallLog;
        this.shouldShowNotification = shouldShowNotification;
        public Builder setShouldShowNotification(boolean shouldShowNotification) {
            mShouldShowNotification = shouldShowNotification;
            return this;
        }

        public Builder setShouldSilence(boolean shouldSilence) {
            mShouldSilence = shouldSilence;
            return this;
        }

        public Builder setCallBlockReason(int callBlockReason) {
            mCallBlockReason = callBlockReason;
            return this;
        }

        public Builder setCallScreeningAppName(CharSequence callScreeningAppName) {
            mCallScreeningAppName = callScreeningAppName;
            return this;
        }

        public Builder setCallScreeningComponentName(String callScreeningComponentName) {
            mCallScreeningComponentName = callScreeningComponentName;
            return this;
        }

        public CallFilteringResult build() {
            return new CallFilteringResult(mShouldAllowCall, mShouldReject, mShouldSilence,
                    mShouldAddToCallLog, mShouldShowNotification, mCallBlockReason,
                    mCallScreeningAppName, mCallScreeningComponentName);
        }
    }

    public CallFilteringResult(boolean shouldAllowCall, boolean shouldReject, boolean
    public boolean shouldAllowCall;
    public boolean shouldReject;
    public boolean shouldSilence;
    public boolean shouldAddToCallLog;
    public boolean shouldShowNotification;
    public int mCallBlockReason;
    public CharSequence mCallScreeningAppName;
    public String mCallScreeningComponentName;

    private CallFilteringResult(boolean shouldAllowCall, boolean shouldReject, boolean
            shouldSilence, boolean shouldAddToCallLog, boolean shouldShowNotification, int
            callBlockReason, CharSequence callScreeningAppName, String callScreeningComponentName) {
        this.shouldAllowCall = shouldAllowCall;
@@ -109,12 +135,13 @@ public class CallFilteringResult {
                other.mCallScreeningAppName, other.mCallScreeningComponentName);
        }

        return new CallFilteringResult(
            shouldAllowCall && other.shouldAllowCall,
            shouldReject || other.shouldReject,
            shouldSilence || other.shouldSilence,
            shouldAddToCallLog && other.shouldAddToCallLog,
            shouldShowNotification && other.shouldShowNotification);
        return new Builder()
                .setShouldAllowCall(shouldAllowCall && other.shouldAllowCall)
                .setShouldReject(shouldReject || other.shouldReject)
                .setShouldSilence(shouldSilence || other.shouldSilence)
                .setShouldAddToCallLog(shouldAddToCallLog && other.shouldAddToCallLog)
                .setShouldShowNotification(shouldShowNotification && other.shouldShowNotification)
                .build();
    }

    private boolean isBlockedByProvider(int blockReason) {
@@ -131,15 +158,16 @@ public class CallFilteringResult {

    private CallFilteringResult getCombinedCallFilteringResult(CallFilteringResult other,
        int callBlockReason, CharSequence callScreeningAppName, String callScreeningComponentName) {
        return new CallFilteringResult(
            shouldAllowCall && other.shouldAllowCall,
            shouldReject || other.shouldReject,
            shouldSilence|| other.shouldSilence,
            shouldAddToCallLog && other.shouldAddToCallLog,
            shouldShowNotification && other.shouldShowNotification,
            callBlockReason,
            callScreeningAppName,
            callScreeningComponentName);
        return new Builder()
                .setShouldAllowCall(shouldAllowCall && other.shouldAllowCall)
                .setShouldReject(shouldReject || other.shouldReject)
                .setShouldSilence(shouldSilence || other.shouldSilence)
                .setShouldAddToCallLog(shouldAddToCallLog && other.shouldAddToCallLog)
                .setShouldShowNotification(shouldShowNotification && other.shouldShowNotification)
                .setCallBlockReason(callBlockReason)
                .setCallScreeningAppName(callScreeningAppName)
                .setCallScreeningComponentName(callScreeningComponentName)
                .build();
    }


+19 −10
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import com.android.server.telecom.ParcelableCallUtils;
import com.android.server.telecom.PhoneAccountRegistrar;
import com.android.server.telecom.TelecomServiceImpl;
import com.android.server.telecom.TelecomSystem;
import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;

/**
 * This class supports binding to the various {@link android.telecom.CallScreeningService}:
@@ -66,12 +67,12 @@ public class CallScreeningServiceController implements IncomingCallFilter.CallFi
    private Call mCall;
    private CallFilterResultCallback mCallback;

    private CallFilteringResult mResult = new CallFilteringResult(
            true, // shouldAllowCall
            false, // shouldReject
            true, // shouldAddToCallLog
            true // shouldShowNotification
    );
    private CallFilteringResult mResult = new Builder()
            .setShouldAllowCall(true)
            .setShouldReject(false)
            .setShouldAddToCallLog(true)
            .setShouldShowNotification(true)
            .build();

    private boolean mIsFinished;
    private boolean mIsCarrierFinished;
@@ -194,12 +195,20 @@ public class CallScreeningServiceController implements IncomingCallFilter.CallFi
            String userChosenPackageName = getUserChosenPackageName();
            if (TextUtils.isEmpty(userChosenPackageName)) {
                mIsUserChosenFinished = true;
            } else {
                // If the user chosen call screening service is the same as the default dialer, then
                // we have already bound to it above and don't need to do so again here.
                if (userChosenPackageName.equals(dialerPackageName)) {
                    Log.addEvent(mCall, LogUtils.Events.SCREENING_SKIPPED,
                            "user pkg same as dialer: " + userChosenPackageName);
                    mIsUserChosenFinished = true;
                } else {
                    createCallScreeningServiceFilter().startCallScreeningFilter(mCall,
                            CallScreeningServiceController.this, userChosenPackageName,
                            mAppLabelProxy.getAppLabel(userChosenPackageName),
                            CallScreeningServiceFilter.CALL_SCREENING_FILTER_TYPE_USER_SELECTED);
                }
            }

            if (mIsDefaultDialerFinished && mIsUserChosenFinished) {
                finishCallScreening();
Loading