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

Commit 21131a0c authored by Thomas Stuart's avatar Thomas Stuart Committed by Android (Google) Code Review
Browse files

Merge "Add monitor related code to make sure that voip app invoke platform...

Merge "Add monitor related code to make sure that voip app invoke platform APIs in expected way." into udc-dev
parents b301c715 aaf3e6a8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@ android_app {
    static_libs: [
        "androidx.annotation_annotation",
    ],
    libs: [
        "services",
    ],
    resource_dirs: ["res"],
    proto: {
        type: "nano",
+1 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@
    <uses-permission android:name="android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME"/>
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    <uses-permission android:name="com.android.phone.permission.ACCESS_LAST_KNOWN_CELL_ID"/>
    <uses-permission android:name="android.permission.STATUS_BAR_SERVICE" />

    <permission android:name="android.permission.BROADCAST_CALLLOG_INFO"
         android:label="Broadcast the call type/duration information"
+9 −0
Original line number Diff line number Diff line
@@ -556,6 +556,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
    private boolean mIsSelfManaged = false;

    private boolean mIsTransactionalCall = false;
    private int mOwnerPid = -1;

    /**
     * Indicates whether this call is streaming.
@@ -1831,6 +1832,14 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        setConnectionProperties(getConnectionProperties());
    }

    public void setOwnerPid(int pid) {
        mOwnerPid = pid;
    }

    public int getOwnerPid() {
        return mOwnerPid;
    }

    public void setTransactionServiceWrapper(TransactionalServiceWrapper service) {
        mTransactionalService = service;
    }
+14 −0
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ import com.android.server.telecom.ui.DisconnectedCallNotifier;
import com.android.server.telecom.ui.IncomingCallNotifier;
import com.android.server.telecom.ui.ToastFactory;
import com.android.server.telecom.voip.TransactionManager;
import com.android.server.telecom.voip.VoipCallMonitor;

import java.util.ArrayList;
import java.util.Arrays;
@@ -437,6 +438,7 @@ public class CallsManager extends Call.ListenerBase
    private final Handler mHandler = new Handler(Looper.getMainLooper());
    private final EmergencyCallHelper mEmergencyCallHelper;
    private final RoleManagerAdapter mRoleManagerAdapter;
    private final VoipCallMonitor mVoipCallMonitor;
    private final CallEndpointController mCallEndpointController;
    private final CallAnomalyWatchdog mCallAnomalyWatchdog;

@@ -642,6 +644,7 @@ public class CallsManager extends Call.ListenerBase
        mTransactionManager = transactionManager;
        mBlockedNumbersAdapter = blockedNumbersAdapter;
        mCallStreamingController = new CallStreamingController(mContext, mLock);
        mVoipCallMonitor = new VoipCallMonitor(mContext, mLock);

        mListeners.add(mInCallWakeLockController);
        mListeners.add(statusBarNotifier);
@@ -662,6 +665,9 @@ public class CallsManager extends Call.ListenerBase

        // this needs to be after the mCallAudioManager
        mListeners.add(mPhoneStateBroadcaster);
        mListeners.add(mVoipCallMonitor);

        mVoipCallMonitor.startMonitor();

        // There is no USER_SWITCHED broadcast for user 0, handle it here explicitly.
        final UserManager userManager = UserManager.get(mContext);
@@ -1399,6 +1405,8 @@ public class CallsManager extends Call.ListenerBase
        // set properties for transactional call
        if (extras.containsKey(TelecomManager.TRANSACTION_CALL_ID_KEY)) {
            call.setIsTransactionalCall(true);
            call.setOwnerPid(extras.getInt(CallAttributes.CALLER_PID, -1));
            extras.remove(CallAttributes.CALLER_PID);
            call.setConnectionCapabilities(
                    extras.getInt(CallAttributes.CALL_CAPABILITIES_KEY,
                            CallAttributes.SUPPORTS_SET_INACTIVE), true);
@@ -1709,6 +1717,8 @@ public class CallsManager extends Call.ListenerBase

            if (extras.containsKey(TelecomManager.TRANSACTION_CALL_ID_KEY)) {
                call.setIsTransactionalCall(true);
                call.setOwnerPid(extras.getInt(CallAttributes.CALLER_PID, -1));
                extras.remove(CallAttributes.CALLER_PID);
                call.setConnectionCapabilities(
                        extras.getInt(CallAttributes.CALL_CAPABILITIES_KEY,
                                CallAttributes.SUPPORTS_SET_INACTIVE), true);
@@ -6278,6 +6288,10 @@ public class CallsManager extends Call.ListenerBase
        return mRinger;
    }

    @VisibleForTesting
    public VoipCallMonitor getVoipCallMonitor() {
        return mVoipCallMonitor;
    }

    /**
     * This method should only be used for testing.
+5 −1
Original line number Diff line number Diff line
@@ -193,6 +193,10 @@ public class TelecomServiceImpl {
                enforcePhoneAccountIsRegisteredEnabled(handle, handle.getUserHandle());
                enforceCallingPackage(callingPackage, "addCall");

                // add extras about info used for FGS delegation
                Bundle extras = new Bundle();
                extras.putInt(CallAttributes.CALLER_PID, Binder.getCallingPid());

                VoipCallTransaction transaction = null;
                // create transaction based on the call direction
                switch (callAttributes.getDirection()) {
@@ -202,7 +206,7 @@ public class TelecomServiceImpl {
                        break;
                    case DIRECTION_INCOMING:
                        transaction = new IncomingCallTransaction(callId, callAttributes,
                                mCallsManager);
                                mCallsManager, extras);
                        break;
                    default:
                        throw new IllegalArgumentException(String.format("Invalid Call Direction. "
Loading