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

Commit e601fbaa authored by Hall Liu's avatar Hall Liu Committed by Automerger Merge Worker
Browse files

Merge "User arg object in onCallFilteringCompleted" into sc-dev am: babbd42d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13621161

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I1643d7dda3543aea9502e85dc8640f80dd7b3ff5
parents 3d2f090d babbd42d
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -10764,7 +10764,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, @Nullable android.telecom.CallScreeningService.CallResponse, boolean);
    method @RequiresPermission(android.Manifest.permission.READ_CONTACTS) public void onCallFilteringCompleted(@NonNull android.telecom.Connection.CallFilteringCompletionInfo);
    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);
@@ -10780,6 +10780,16 @@ package android.telecom {
    field public static final int PROPERTY_REMOTELY_HOSTED = 2048; // 0x800
  }
  public static final class Connection.CallFilteringCompletionInfo implements android.os.Parcelable {
    ctor public Connection.CallFilteringCompletionInfo(boolean, boolean, @Nullable android.telecom.CallScreeningService.CallResponse, @Nullable android.content.ComponentName);
    method public int describeContents();
    method @Nullable public android.telecom.CallScreeningService.CallResponse getCallResponse();
    method @Nullable public android.content.ComponentName getCallScreeningComponent();
    method public boolean isBlocked();
    method public boolean isInContacts();
    field @NonNull public static final android.os.Parcelable.Creator<android.telecom.Connection.CallFilteringCompletionInfo> CREATOR;
  }
  public final class ConnectionRequest implements android.os.Parcelable {
    method @Nullable public String getTelecomCallId();
  }
@@ -10941,7 +10951,7 @@ package android.telecom {
  }
  public final class RemoteConnection {
    method @RequiresPermission(android.Manifest.permission.READ_CONTACTS) public void onCallFilteringCompleted(boolean, boolean, @Nullable android.telecom.CallScreeningService.CallResponse, boolean);
    method @RequiresPermission(android.Manifest.permission.READ_CONTACTS) public void onCallFilteringCompleted(@NonNull android.telecom.Connection.CallFilteringCompletionInfo);
    method @Deprecated public void setAudioState(android.telecom.AudioState);
  }
+22 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package android.telecom;

/**
 * {@hide}
 */
parcelable Connection.CallFilteringCompletionInfo;
+121 −14
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.annotation.SystemApi;
import android.app.Notification;
import android.bluetooth.BluetoothDevice;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Intent;
import android.hardware.camera2.CameraManager;
import android.net.Uri;
@@ -38,7 +39,9 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.Parcel;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.SystemClock;
import android.telephony.ims.ImsStreamMediaProfile;
@@ -3378,6 +3381,121 @@ public abstract class Connection extends Conferenceable {
     */
    public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}

    /**
     * Information provided to a {@link Connection} upon completion of call filtering in Telecom.
     *
     * @hide
     */
    @SystemApi
    public static final class CallFilteringCompletionInfo implements Parcelable {
        private final boolean mIsBlocked;
        private final boolean mIsInContacts;
        private final CallScreeningService.CallResponse mCallResponse;
        private final ComponentName mCallScreeningComponent;

        /**
         * Constructor for {@link CallFilteringCompletionInfo}
         *
         * @param isBlocked Whether any part of the call filtering process indicated that this call
         *                  should be blocked.
         * @param isInContacts Whether the caller is in the user's contacts.
         * @param callResponse The instance of {@link CallScreeningService.CallResponse} provided
         *                     by the {@link CallScreeningService} that processed this call, or
         *                     {@code null} if no call screening service ran.
         * @param callScreeningComponent The component of the {@link CallScreeningService}
         *                                 that processed this call, or {@link null} if no
         *                                 call screening service ran.
         */
        public CallFilteringCompletionInfo(boolean isBlocked, boolean isInContacts,
                @Nullable CallScreeningService.CallResponse callResponse,
                @Nullable ComponentName callScreeningComponent) {
            mIsBlocked = isBlocked;
            mIsInContacts = isInContacts;
            mCallResponse = callResponse;
            mCallScreeningComponent = callScreeningComponent;
        }

        /** @hide */
        protected CallFilteringCompletionInfo(Parcel in) {
            mIsBlocked = in.readByte() != 0;
            mIsInContacts = in.readByte() != 0;
            CallScreeningService.ParcelableCallResponse response
                    = in.readParcelable(CallScreeningService.class.getClassLoader());
            mCallResponse = response == null ? null : response.toCallResponse();
            mCallScreeningComponent = in.readParcelable(ComponentName.class.getClassLoader());
        }

        @NonNull
        public static final Creator<CallFilteringCompletionInfo> CREATOR =
                new Creator<CallFilteringCompletionInfo>() {
                    @Override
                    public CallFilteringCompletionInfo createFromParcel(Parcel in) {
                        return new CallFilteringCompletionInfo(in);
                    }

                    @Override
                    public CallFilteringCompletionInfo[] newArray(int size) {
                        return new CallFilteringCompletionInfo[size];
                    }
                };

        /**
         * @return Whether any part of the call filtering process indicated that this call should be
         *         blocked.
         */
        public boolean isBlocked() {
            return mIsBlocked;
        }

        /**
         * @return Whether the caller is in the user's contacts.
         */
        public boolean isInContacts() {
            return mIsInContacts;
        }

        /**
         * @return The instance of {@link CallScreeningService.CallResponse} provided
         *         by the {@link CallScreeningService} that processed this
         *         call, or {@code null} if no call screening service ran.
         */
        public @Nullable CallScreeningService.CallResponse getCallResponse() {
            return mCallResponse;
        }

        /**
         * @return The component of the {@link CallScreeningService}
         *         that processed this call, or {@code null} if no call screening service ran.
         */
        public @Nullable ComponentName getCallScreeningComponent() {
            return mCallScreeningComponent;
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public String toString() {
            return "CallFilteringCompletionInfo{" +
                    "mIsBlocked=" + mIsBlocked +
                    ", mIsInContacts=" + mIsInContacts +
                    ", mCallResponse=" + mCallResponse +
                    ", mCallScreeningPackageName='" + mCallScreeningComponent + '\'' +
                    '}';
        }

        /** @hide */
        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeByte((byte) (mIsBlocked ? 1 : 0));
            dest.writeByte((byte) (mIsInContacts ? 1 : 0));
            dest.writeParcelable(mCallResponse == null ? null : mCallResponse.toParcelable(), 0);
            dest.writeParcelable(mCallScreeningComponent, 0);
        }
    }

    /**
     * Indicates that call filtering in Telecom is complete
     *
@@ -3386,24 +3504,13 @@ public abstract class Connection extends Conferenceable {
     * 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.
     * @param callScreeningResponse The response that was returned from the
     *                              {@link CallScreeningService} that handled this call. If no
     *                              response was received from a call screening service,
     *                              this will be {@code null}.
     * @param isResponseFromSystemDialer Whether {@code callScreeningResponse} was sent from the
     *                                  system dialer. If {@code callScreeningResponse} is
     *                                  {@code null}, this will be {@code false}.
     * @param callFilteringCompletionInfo Info provided by Telecom on the results of call filtering.
     * @hide
     */
    @SystemApi
    @RequiresPermission(Manifest.permission.READ_CONTACTS)
    public void onCallFilteringCompleted(boolean isBlocked, boolean isInContacts,
            @Nullable CallScreeningService.CallResponse callScreeningResponse,
            boolean isResponseFromSystemDialer) { }
    public void onCallFilteringCompleted(
            @NonNull CallFilteringCompletionInfo callFilteringCompletionInfo) { }

    static String toLogSafePhoneNumber(String number) {
        // For unknown number, log empty string.
+12 −24
Original line number Diff line number Diff line
@@ -758,19 +758,15 @@ public abstract class ConnectionService extends Service {
        }

        @Override
        public void onCallFilteringCompleted(String callId, boolean isBlocked, boolean isInContacts,
                CallScreeningService.ParcelableCallResponse callScreeningResponse,
                boolean isResponseFromSystemDialer,
        public void onCallFilteringCompleted(String callId,
                Connection.CallFilteringCompletionInfo completionInfo,
                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 = callScreeningResponse;
                args.arg5 = isResponseFromSystemDialer;
                args.arg6 = Log.createSubsession();
                args.arg2 = completionInfo;
                args.arg3 = Log.createSubsession();
                mHandler.obtainMessage(MSG_ON_CALL_FILTERING_COMPLETED, args).sendToTarget();
            } finally {
                Log.endSession();
@@ -1441,16 +1437,12 @@ public abstract class ConnectionService extends Service {
                case MSG_ON_CALL_FILTERING_COMPLETED: {
                    SomeArgs args = (SomeArgs) msg.obj;
                    try {
                        Log.continueSession((Session) args.arg6,
                        Log.continueSession((Session) args.arg3,
                                SESSION_HANDLER + SESSION_CALL_FILTERING_COMPLETED);
                        String callId = (String) args.arg1;
                        boolean isBlocked = (boolean) args.arg2;
                        boolean isInContacts = (boolean) args.arg3;
                        CallScreeningService.ParcelableCallResponse callScreeningResponse =
                                (CallScreeningService.ParcelableCallResponse) args.arg4;
                        boolean isResponseFromSystemDialer = (boolean) args.arg5;
                        onCallFilteringCompleted(callId, isBlocked, isInContacts,
                                callScreeningResponse, isResponseFromSystemDialer);
                        Connection.CallFilteringCompletionInfo completionInfo =
                                (Connection.CallFilteringCompletionInfo) args.arg2;
                        onCallFilteringCompleted(callId, completionInfo);
                    } finally {
                        args.recycle();
                        Log.endSession();
@@ -2466,16 +2458,12 @@ public abstract class ConnectionService extends Service {
        }
    }

    private void onCallFilteringCompleted(String callId, boolean isBlocked, boolean isInContacts,
            CallScreeningService.ParcelableCallResponse callScreeningResponse,
            boolean isResponseFromSystemDialer) {
        Log.i(this, "onCallFilteringCompleted(%s, %b, %b, %s, %b)", callId,
                isBlocked, isInContacts, callScreeningResponse, isResponseFromSystemDialer);
    private void onCallFilteringCompleted(String callId, Connection.CallFilteringCompletionInfo
            callFilteringCompletionInfo) {
        Log.i(this, "onCallFilteringCompleted(%s, %s)", callId, callFilteringCompletionInfo);
        Connection connection = findConnectionForAction(callId, "onCallFilteringCompleted");
        if (connection != null) {
            connection.onCallFilteringCompleted(isBlocked, isInContacts,
                    callScreeningResponse == null ? null : callScreeningResponse.toCallResponse(),
                    isResponseFromSystemDialer);
            connection.onCallFilteringCompleted(callFilteringCompletionInfo);
        }
    }

+5 −14
Original line number Diff line number Diff line
@@ -1202,27 +1202,18 @@ 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
     * @param callScreeningResponse The response that was returned from the
     *                              {@link CallScreeningService} that handled this call. If no
     *                              response was received from a call screening service,
     *                              this will be {@code null}.
     * @param isResponseFromSystemDialer Whether {@code callScreeningResponse} was sent from the
     *                                  system dialer. If {@code callScreeningResponse} is
     *                                  {@code null}, this will be {@code false}.
     *
     * @param completionInfo Info provided by Telecom on the results of call filtering.
     * @hide
     */
    @SystemApi
    @RequiresPermission(Manifest.permission.READ_CONTACTS)
    public void onCallFilteringCompleted(boolean isBlocked, boolean isInContacts,
            @Nullable CallScreeningService.CallResponse callScreeningResponse,
            boolean isResponseFromSystemDialer) {
    public void onCallFilteringCompleted(
            @NonNull Connection.CallFilteringCompletionInfo completionInfo) {
        Log.startSession("RC.oCFC", getActiveOwnerInfo());
        try {
            if (mConnected) {
                mConnectionService.onCallFilteringCompleted(mConnectionId, isBlocked, isInContacts,
                        callScreeningResponse.toParcelable(), isResponseFromSystemDialer,
                mConnectionService.onCallFilteringCompleted(mConnectionId, completionInfo,
                        null /*Session.Info*/);
            }
        } catch (RemoteException ignored) {
Loading