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

Commit ccdf364c authored by Sanket Padawe's avatar Sanket Padawe
Browse files

API definitions for Call Handover.

Design doc:
https://docs.google.com/document/d/1qY3oAzjff_4A1ttYb_CGrE_OwTRmXMG_KGsIuPT1ey8/edit#

Bug: 65415068
Test: manual
Change-Id: I98000d01293f3c83697a0d6a95c3c415159ce8ea
parent c74b3e25
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2043,6 +2043,17 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable {
        }
    }

    /**
     * Initiates a handover of this Call to the {@link ConnectionService} identified
     * by destAcct.
     * @param destAcct ConnectionService to which the call should be handed over.
     * @param videoState The video state desired after the handover.
     * @param extras Extra information to be passed to ConnectionService
     */
    public void handoverTo(PhoneAccountHandle destAcct, int videoState, Bundle extras) {
        // TODO: Call requestHandover(destAcct, videoState, extras);
    }

    /**
     * Sets this {@link Call} to has the specified {@code parentCall}.  Also sets the parent to
     * have this call as a child.
+4 −0
Original line number Diff line number Diff line
@@ -3325,4 +3325,8 @@ public class CallsManager extends Call.ListenerBase
        }
        return ;
    }

    public void acceptHandover(Uri srcAddr, int videoState, PhoneAccountHandle destAcct) {
        // TODO:
    }
}
+23 −0
Original line number Diff line number Diff line
@@ -577,4 +577,27 @@ class InCallAdapter extends IInCallAdapter.Stub {
            Log.endSession();
        }
    }

    @Override
    public void handoverTo(String callId, PhoneAccountHandle destAcct, int videoState,
                           Bundle extras) {
        try {
            Log.startSession("ICA.hT", mOwnerComponentName);
            long token = Binder.clearCallingIdentity();
            try {
                synchronized (mLock) {
                    Call call = mCallIdMapper.getCall(callId);
                    if (call != null) {
                        call.handoverTo(destAcct, videoState, extras);
                    } else {
                        Log.w(this, "handoverTo, unknown call id: %s", callId);
                    }
                }
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        } finally {
            Log.endSession();
        }
    }
}
+36 −0
Original line number Diff line number Diff line
@@ -1081,6 +1081,42 @@ public class TelecomServiceImpl {
            }
        }

        /**
         * @see android.telecom.TelecomManager#acceptHandover
         */
        @Override
        public void acceptHandover(Uri srcAddr, int videoState, PhoneAccountHandle destAcct) {
            try {
                Log.startSession("TSI.aHO");
                synchronized (mLock) {
                    Log.i(this, "Handover call to phoneAccountHandle %s",
                            destAcct);
                    if (destAcct != null && destAcct.getComponentName() != null) {
                        mAppOpsManager.checkPackage(
                                Binder.getCallingUid(),
                                destAcct.getComponentName().getPackageName());
                        enforceUserHandleMatchesCaller(destAcct);
                        enforcePhoneAccountIsRegisteredEnabled(destAcct,
                                Binder.getCallingUserHandle());
                        if (isSelfManagedConnectionService(destAcct)) {
                            // Self-managed phone account, ensure it has MANAGE_OWN_CALLS.
                            mContext.enforceCallingOrSelfPermission(
                                    android.Manifest.permission.MANAGE_OWN_CALLS,
                                    "Self-managed phone accounts must have MANAGE_OWN_CALLS " +
                                            "permission.");
                        }

                        mCallsManager.acceptHandover(srcAddr, videoState, destAcct);
                    } else {
                        Log.w(this, "Null phoneAccountHandle. Ignoring request " +
                                "to handover the call");
                    }
                }
            } finally {
                Log.endSession();
            }
        }

        /**
         * @see android.telecom.TelecomManager#addNewUnknownCall
         */