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

Commit 497613a1 authored by Hemant Gupta's avatar Hemant Gupta Committed by android-build-merger
Browse files

Merge "SAP: Update UI connection and notifications properly"

am: 61f14053

* commit '61f14053':
  SAP: Update UI connection and notifications properly
parents 43b15908 61f14053
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.bluetooth.BluetoothSap;

//import com.android.internal.telephony.RIL;
import com.google.protobuf.micro.CodedOutputStreamMicro;
@@ -314,7 +315,6 @@ public class SapServer extends Thread implements Callback {

            mRilBtReceiver = new SapRilReceiver(mSapHandler, mSapServiceHandler);
            mRilBtReceiverThread = new Thread(mRilBtReceiver, "RilBtReceiver");
            setNotification(SapMessage.DISC_GRACEFULL,0);
            boolean done = false;
            while (!done) {
                if(VERBOSE) Log.i(TAG, "Waiting for incomming RFCOMM message...");
@@ -790,6 +790,14 @@ public class SapServer extends Thread implements Callback {
                            mState == SAP_STATE.DISCONNECTING) {
                        sapMsg = null;
                    }
                    if (mSapServiceHandler != null && mState == SAP_STATE.CONNECTED) {
                        Message msg = Message.obtain(mSapServiceHandler);
                        msg.what = SapService.MSG_CHANGE_STATE;
                        msg.arg1 = BluetoothSap.STATE_CONNECTED;
                        msg.sendToTarget();
                        setNotification(SapMessage.DISC_GRACEFULL, 0);
                        if (DEBUG) Log.d(TAG, "MSG_CHANGE_STATE sent out.");
                    }
                    break;
                default:
                // Nothing special, just send the message
+6 −2
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ public class SapService extends ProfileService {
    public static final int MSG_ACQUIRE_WAKE_LOCK = 5005;
    public static final int MSG_RELEASE_WAKE_LOCK = 5006;

    public static final int MSG_CHANGE_STATE = 5007;

    /* Each time a transaction between the SIM and the BT Client is detected a wakelock is taken.
     * After an idle period of RELEASE_WAKE_LOCK_DELAY ms the wakelock is released.
     *
@@ -255,8 +257,6 @@ public class SapService extends ProfileService {
            mWakeLock.acquire();
        }

        setState(BluetoothSap.STATE_CONNECTED);

        /* Start the SAP I/O thread and associate with message handler */
        mSapServer = new SapServer(mSessionStatusHandler, this, mConnSocket.getInputStream(), mConnSocket.getOutputStream());
        mSapServer.start();
@@ -440,6 +440,10 @@ public class SapService extends ProfileService {
                        if (DEBUG) Log.i(TAG, "  Released Wake Lock by message");
                    }
                    break;
                case MSG_CHANGE_STATE:
                    if (DEBUG) Log.d(TAG, "change state message: newState = " + msg.arg1);
                    setState(msg.arg1);
                    break;
                case SHUTDOWN:
                    /* Ensure to call close from this handler to avoid starting new stuff
                       because of pending messages */