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

Commit ea5883a0 authored by Jack He's avatar Jack He Committed by android-build-merger
Browse files

Merge "PBAP: Use ACTION_CONNECTION_STATE_CHANGED intent" am: f5a0a505 am: c3b2e311

am: 767b5d3e

Change-Id: I56465469b159d6103a3afd6d061ce324bf7a0457
parents 8dcffb58 767b5d3e
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -139,6 +139,9 @@ class AdapterProperties {
                case BluetoothPbapClient.ACTION_CONNECTION_STATE_CHANGED:
                case BluetoothPbapClient.ACTION_CONNECTION_STATE_CHANGED:
                    sendConnectionStateChange(BluetoothProfile.PBAP_CLIENT, intent);
                    sendConnectionStateChange(BluetoothProfile.PBAP_CLIENT, intent);
                    break;
                    break;
                case BluetoothPbap.ACTION_CONNECTION_STATE_CHANGED:
                    sendConnectionStateChange(BluetoothProfile.PBAP, intent);
                    break;
                default:
                default:
                    Log.w(TAG, "Received unknown intent " + intent);
                    Log.w(TAG, "Received unknown intent " + intent);
                    break;
                    break;
+9 −9
Original line number Original line Diff line number Diff line
@@ -239,7 +239,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
    private BluetoothPbapContentObserver mContactChangeObserver;
    private BluetoothPbapContentObserver mContactChangeObserver;


    public BluetoothPbapService() {
    public BluetoothPbapService() {
        mState = BluetoothPbap.STATE_DISCONNECTED;
        mState = BluetoothProfile.STATE_DISCONNECTED;
        mContext = this;
        mContext = this;
    }
    }


@@ -480,7 +480,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
        }
        }
        BluetoothObexTransport transport = new BluetoothObexTransport(mConnSocket);
        BluetoothObexTransport transport = new BluetoothObexTransport(mConnSocket);
        mServerSession = new ServerSession(transport, mPbapServer, mAuth);
        mServerSession = new ServerSession(transport, mPbapServer, mAuth);
        setState(BluetoothPbap.STATE_CONNECTED);
        setState(BluetoothProfile.STATE_CONNECTED);


        mSessionStatusHandler.removeMessages(MSG_RELEASE_WAKE_LOCK);
        mSessionStatusHandler.removeMessages(MSG_RELEASE_WAKE_LOCK);
        mSessionStatusHandler.sendMessageDelayed(mSessionStatusHandler
        mSessionStatusHandler.sendMessageDelayed(mSessionStatusHandler
@@ -512,7 +512,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
        if (mAdapter != null && mAdapter.isEnabled()) {
        if (mAdapter != null && mAdapter.isEnabled()) {
            startSocketListeners();
            startSocketListeners();
        }
        }
        setState(BluetoothPbap.STATE_DISCONNECTED);
        setState(BluetoothProfile.STATE_DISCONNECTED);
    }
    }


    private void notifyAuthKeyInput(final String key) {
    private void notifyAuthKeyInput(final String key) {
@@ -732,7 +732,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
                    + result);
                    + result);
            int prevState = mState;
            int prevState = mState;
            mState = state;
            mState = state;
            Intent intent = new Intent(BluetoothPbap.PBAP_STATE_CHANGED_ACTION);
            Intent intent = new Intent(BluetoothPbap.ACTION_CONNECTION_STATE_CHANGED);
            intent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, prevState);
            intent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, prevState);
            intent.putExtra(BluetoothProfile.EXTRA_STATE, mState);
            intent.putExtra(BluetoothProfile.EXTRA_STATE, mState);
            intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mRemoteDevice);
            intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mRemoteDevice);
@@ -858,13 +858,13 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
            Log.w(TAG, "Unable to unregister pbap receiver", e);
            Log.w(TAG, "Unable to unregister pbap receiver", e);
        }
        }
        mSessionStatusHandler.obtainMessage(SHUTDOWN).sendToTarget();
        mSessionStatusHandler.obtainMessage(SHUTDOWN).sendToTarget();
        setState(BluetoothPbap.STATE_DISCONNECTED, BluetoothPbap.RESULT_CANCELED);
        setState(BluetoothProfile.STATE_DISCONNECTED, BluetoothPbap.RESULT_CANCELED);
        return true;
        return true;
    }
    }


    protected void disconnect() {
    protected void disconnect() {
        synchronized (this) {
        synchronized (this) {
            if (mState == BluetoothPbap.STATE_CONNECTED) {
            if (mState == BluetoothProfile.STATE_CONNECTED) {
                if (mServerSession != null) {
                if (mServerSession != null) {
                    mServerSession.close();
                    mServerSession.close();
                    mServerSession = null;
                    mServerSession = null;
@@ -872,7 +872,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect


                closeConnectionSocket();
                closeConnectionSocket();


                setState(BluetoothPbap.STATE_DISCONNECTED, BluetoothPbap.RESULT_CANCELED);
                setState(BluetoothProfile.STATE_DISCONNECTED, BluetoothPbap.RESULT_CANCELED);
            }
            }
        }
        }
    }
    }
@@ -906,7 +906,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
        public int getState() {
        public int getState() {
            if (DEBUG) Log.d(TAG, "getState = " + mService.getState());
            if (DEBUG) Log.d(TAG, "getState = " + mService.getState());
            BluetoothPbapService service = getService(BLUETOOTH_PERM);
            BluetoothPbapService service = getService(BLUETOOTH_PERM);
            if (service == null) return BluetoothPbap.STATE_DISCONNECTED;
            if (service == null) return BluetoothProfile.STATE_DISCONNECTED;


            return service.getState();
            return service.getState();
        }
        }
@@ -922,7 +922,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
            if (DEBUG) Log.d(TAG, "isConnected " + device);
            if (DEBUG) Log.d(TAG, "isConnected " + device);
            BluetoothPbapService service = getService(BLUETOOTH_PERM);
            BluetoothPbapService service = getService(BLUETOOTH_PERM);
            if (service == null) return false;
            if (service == null) return false;
            return service.getState() == BluetoothPbap.STATE_CONNECTED
            return service.getState() == BluetoothProfile.STATE_CONNECTED
                    && service.getRemoteDevice().equals(device);
                    && service.getRemoteDevice().equals(device);
        }
        }