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

Commit 7e8f0c74 authored by Hung-ying Tyan's avatar Hung-ying Tyan Committed by Android Git Automerger
Browse files

am b9a17931: Merge "SipSession: make potential time-consuming ops run on...

am b9a17931: Merge "SipSession: make potential time-consuming ops run on background thread" into gingerbread

Merge commit 'b9a17931' into gingerbread-plus-aosp

* commit 'b9a17931':
  SipSession: make potential time-consuming ops run on background thread
parents 6cf5eb06 b9a17931
Loading
Loading
Loading
Loading
+26 −27
Original line number Diff line number Diff line
@@ -381,15 +381,30 @@ class SipSessionGroup implements SipListener {
                    : listener);
        }

        public void makeCall(SipProfile peerProfile,
                SessionDescription sessionDescription) {
        // process the command in a new thread
        private void doCommandAsync(final EventObject command) {
            new Thread(new Runnable() {
                    public void run() {
                        try {
                processCommand(
                        new MakeCallCommand(peerProfile, sessionDescription));
                            processCommand(command);
                        } catch (SipException e) {
                            // TODO: find a better way to do this
                            if ((command instanceof RegisterCommand)
                                    || (command == DEREGISTER)) {
                                onRegistrationFailed(e);
                            } else {
                                onError(e);
                            }
                        }
                    }
            }).start();
        }

        public void makeCall(SipProfile peerProfile,
                SessionDescription sessionDescription) {
            doCommandAsync(
                    new MakeCallCommand(peerProfile, sessionDescription));
        }

        public void answerCall(SessionDescription sessionDescription) {
            try {
@@ -401,36 +416,20 @@ class SipSessionGroup implements SipListener {
        }

        public void endCall() {
            try {
                processCommand(END_CALL);
            } catch (SipException e) {
                onError(e);
            }
            doCommandAsync(END_CALL);
        }

        public void changeCall(SessionDescription sessionDescription) {
            try {
                processCommand(
            doCommandAsync(
                    new MakeCallCommand(mPeerProfile, sessionDescription));
            } catch (SipException e) {
                onError(e);
            }
        }

        public void register(int duration) {
            try {
                processCommand(new RegisterCommand(duration));
            } catch (SipException e) {
                onRegistrationFailed(e);
            }
            doCommandAsync(new RegisterCommand(duration));
        }

        public void unregister() {
            try {
                processCommand(DEREGISTER);
            } catch (SipException e) {
                onRegistrationFailed(e);
            }
            doCommandAsync(DEREGISTER);
        }

        public boolean isReRegisterRequired() {