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

Commit 4afd6b9c authored by Andre Eisenbach's avatar Andre Eisenbach Committed by Android (Google) Code Review
Browse files

Merge changes from topic 'pts-test-fix-sync-20160335-1' into nyc-dev

* changes:
  Fix more merge issues in BluetoothPbapVcardManager.java
  PBAPS: Don't filter out DateTime when requested
  PBAPS: Fix duplicate entries fetched from database
  PBAPS: Get vcard when asked in alphabetical order
  PBAPS: Enable contact search with full or part of given string
  SAP: Fix ANR(s) in SAP server code
  SAP: Remove sdp record while BT is being turned off to prevent leak
  SAP: Fix issue of socket listener not getting re-started
  SAP: Update UI connection and notifications properly
  SAP: Handle disconnect request during call ongoing state
  OPP: Update share status when interrupted at remote side.
  OPP: Use long instead of int
  MAP: Fix ANR for blocking operations on UI thread
  MAP: Track ProfileState, register and unregister of BroadcastReceivers
  MAP: CleanUp for SDP record in MAP Service shutdown
  MAP: GETMessagesLisitng include mandatory field always.
  MAP: Cleanup PendingIntent in cancelUserTimeoutAlarm.
  MAP: Handle possible NPE while disconnect map.
  MAP: Add MNS SDP Search during setNotificationRegistration.
  MAP: Declare and fetch only 'INTERESTED_MESSAGE_TYPE_CLAUSE' MMS.
  MAP: Synchronize notifcationReg reply and MNS connect action.
  Send error for if VR is initiated during call.
parents 2a6d08a8 c4384634
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -2183,9 +2183,7 @@ final class HeadsetStateMachine extends StateMachine {
            mVoiceRecognitionStarted + " mWaitingforVoiceRecognition: " + mWaitingForVoiceRecognition +
            " isInCall: " + isInCall());
        if (state == HeadsetHalConstants.VR_STATE_STARTED) {
            if (!isVirtualCallInProgress() &&
                !isInCall())
            {
            if (!isVirtualCallInProgress() && !isInCall()) {
                IDeviceIdleController dic = IDeviceIdleController.Stub.asInterface(
                        ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER));
                if (dic != null) {
@@ -2202,6 +2200,11 @@ final class HeadsetStateMachine extends StateMachine {
                    return;
                }
                expectVoiceRecognition(device);
            } else {
                // send error response if call is ongoing
                atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_ERROR,
                        0, getByteAddress(device));
                return;
            }
        } else if (state == HeadsetHalConstants.VR_STATE_STOPPED) {
            if (mVoiceRecognitionStarted || mWaitingForVoiceRecognition)
+2 −1
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@ public class BluetoothMapAccountLoader {
                    " - returning empty account list" );
            return children;
        } finally {
            if (mProviderClient != null)
                mProviderClient.release();
        }

+38 −10
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ public class BluetoothMapAppObserver{
    private PackageManager mPackageManager = null;
    BluetoothMapAccountLoader mLoader;
    BluetoothMapService mMapService = null;
    private boolean mRegisteredReceiver = false;

    public BluetoothMapAppObserver(final Context context, BluetoothMapService mapService) {
        mContext    = context;
@@ -91,8 +92,12 @@ public class BluetoothMapAppObserver{
            ArrayList<BluetoothMapAccountItem> oldAccountList = mFullList.get(app);
            ArrayList<BluetoothMapAccountItem> addedAccountList =
                    (ArrayList<BluetoothMapAccountItem>)newAccountList.clone();
            ArrayList<BluetoothMapAccountItem> removedAccountList = mFullList.get(app);
            // Same as oldAccountList.clone
            ArrayList<BluetoothMapAccountItem> removedAccountList = mFullList.get(app);
            if (oldAccountList == null)
                oldAccountList = new ArrayList <BluetoothMapAccountItem>();
            if (removedAccountList == null)
                removedAccountList = new ArrayList <BluetoothMapAccountItem>();

            mFullList.put(app, newAccountList);
            for(BluetoothMapAccountItem newAcc: newAccountList){
@@ -155,7 +160,7 @@ public class BluetoothMapAppObserver{
    public void registerObserver(BluetoothMapAccountItem app) {
        Uri uri = BluetoothMapContract.buildAccountUri(app.getProviderAuthority());
        if (V) Log.d(TAG, "registerObserver for URI "+uri.toString()+"\n");
        ContentObserver observer = new ContentObserver(new Handler()) {
        ContentObserver observer = new ContentObserver(null) {
            @Override
            public void onChange(boolean selfChange) {
                onChange(selfChange, null);
@@ -174,7 +179,8 @@ public class BluetoothMapAppObserver{
            }
        };
        mObserverMap.put(uri.toString(), observer);
        mResolver.registerContentObserver(uri, true, observer);
        //False "notifyForDescendents" : Get notified whenever a change occurs to the exact URI.
        mResolver.registerContentObserver(uri, false, observer);
    }

    public void unregisterObserver(BluetoothMapAccountItem app) {
@@ -279,12 +285,26 @@ public class BluetoothMapAppObserver{
                }
            }
        };
        if (!mRegisteredReceiver) {
            try {
                mContext.registerReceiver(mReceiver,intentFilter);
                mRegisteredReceiver = true;
            } catch (Exception e) {
                Log.e(TAG,"Unable to register MapAppObserver receiver", e);
            }
        }
    }

    private void removeReceiver(){
        if(D)Log.d(TAG,"removeReceiver()\n");
        if (mRegisteredReceiver) {
            try {
                mRegisteredReceiver = false;
                mContext.unregisterReceiver(mReceiver);
            } catch (Exception e) {
                Log.e(TAG,"Unable to unregister mapAppObserver receiver", e);
            }
        }
    }

    /**
@@ -296,12 +316,20 @@ public class BluetoothMapAppObserver{
        if(D)Log.d(TAG,"getEnabledAccountItems()\n");
        ArrayList<BluetoothMapAccountItem> list = new ArrayList<BluetoothMapAccountItem>();
        for (BluetoothMapAccountItem app:mFullList.keySet()){
            if (app != null) {
                ArrayList<BluetoothMapAccountItem> accountList = mFullList.get(app);
                if (accountList != null) {
                    for (BluetoothMapAccountItem acc: accountList) {
                        if (acc.mIsChecked) {
                            list.add(acc);
                        }
                    }
                } else {
                    Log.w(TAG,"getEnabledAccountItems() - No AccountList enabled\n");
                }
            } else {
                Log.w(TAG,"getEnabledAccountItems() - No Account in App enabled\n");
            }
        }
        return list;
    }
+12 −0
Original line number Diff line number Diff line
@@ -139,6 +139,15 @@ public class BluetoothMapContent {
    public static final int MMS_BCC     = 0x81;
    public static final int MMS_CC      = 0x82;

    /* OMA-TS-MMS-ENC defined many types in X-Mms-Message-Type.
       Only m-send-req (128) m-retrieve-conf (132), m-notification-ind (130)
       are interested by user */
    private static final String INTERESTED_MESSAGE_TYPE_CLAUSE = String
            .format("( %s = %d OR %s = %d OR %s = %d )", Mms.MESSAGE_TYPE,
            PduHeaders.MESSAGE_TYPE_SEND_REQ, Mms.MESSAGE_TYPE,
            PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF, Mms.MESSAGE_TYPE,
            PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND );

    public static final String INSERT_ADDRES_TOKEN = "insert-address-token";

    private final Context mContext;
@@ -1240,6 +1249,8 @@ public class BluetoothMapContent {
            }
            if (subject != null && subject.length() > subLength) {
                subject = subject.substring(0, subLength);
            } else if (subject == null ) {
                subject = "";
            }
            if (V) Log.d(TAG, "setSubject: " + subject);
            e.setSubject(subject);
@@ -2119,6 +2130,7 @@ public class BluetoothMapContent {
                }
                fi.mMsgType = FilterInfo.TYPE_MMS;
                String where = setWhereFilter(folderElement, fi, ap);
                where += " AND " + INTERESTED_MESSAGE_TYPE_CLAUSE;
                if(!where.isEmpty()) {
                    if (D) Log.d(TAG, "msgType: " + fi.mMsgType + " where: " + where);
                    mmsCursor = mResolver.query(Mms.CONTENT_URI,
+57 −14
Original line number Diff line number Diff line
@@ -326,6 +326,26 @@ public class BluetoothMapContentObserver {
        }
    }

    public int getObserverRemoteFeatureMask() {
        if (V) Log.v(TAG, "getObserverRemoteFeatureMask : " + mMapEventReportVersion
            + " mMapSupportedFeatures: " + mMapSupportedFeatures);
        return mMapSupportedFeatures;
    }

    public void setObserverRemoteFeatureMask(int remoteSupportedFeatures) {
        mMapSupportedFeatures = remoteSupportedFeatures;
        if ((BluetoothMapUtils.MAP_FEATURE_EXTENDED_EVENT_REPORT_11_BIT
                & mMapSupportedFeatures) != 0) {
            mMapEventReportVersion = BluetoothMapUtils.MAP_EVENT_REPORT_V11;
        }
        // Make sure support for all formats result in latest version returned
        if ((BluetoothMapUtils.MAP_FEATURE_EVENT_REPORT_V12_BIT
                & mMapSupportedFeatures) != 0) {
            mMapEventReportVersion = BluetoothMapUtils.MAP_EVENT_REPORT_V12;
        }
        if (V) Log.d(TAG, "setObserverRemoteFeatureMask : " + mMapEventReportVersion
            + " mMapSupportedFeatures : " + mMapSupportedFeatures);
    }

    private Map<Long, Msg> getMsgListSms() {
        return mMsgListSms;
@@ -448,8 +468,7 @@ public class BluetoothMapContentObserver {
        return smsType;
    }

    private final ContentObserver mObserver = new ContentObserver(
            new Handler(Looper.getMainLooper())) {
    private final ContentObserver mObserver = new ContentObserver(new Handler()) {
        @Override
        public void onChange(boolean selfChange) {
            onChange(selfChange, null);
@@ -864,28 +883,48 @@ public class BluetoothMapContentObserver {
    public int setNotificationRegistration(int notificationStatus) throws RemoteException {
        // Forward the request to the MNS thread as a message - including the MAS instance ID.
        if(D) Log.d(TAG,"setNotificationRegistration() enter");
        if (mMnsClient == null) {
            return ResponseCodes.OBEX_HTTP_UNAVAILABLE;
        }
        Handler mns = mMnsClient.getMessageHandler();
        if (mns != null) {
            Message msg = mns.obtainMessage();
            if (mMnsClient.isValidMnsRecord()) {
                msg.what = BluetoothMnsObexClient.MSG_MNS_NOTIFICATION_REGISTRATION;
            } else {
                //Trigger SDP Search and notificaiton registration , if SDP record not found.
                msg.what = BluetoothMnsObexClient.MSG_MNS_SDP_SEARCH_REGISTRATION;
                if (mMnsClient.mMnsLstRegRqst != null &&
                        (mMnsClient.mMnsLstRegRqst.isSearchInProgress())) {
                    /*  1. Disallow next Notification ON Request :
                     *     - Respond "Service Unavailable" as SDP Search and last notification
                     *       registration ON request is already InProgress.
                     *     - Next notification ON Request will be allowed ONLY after search
                     *       and connect for last saved request [Replied with OK ] is processed.
                     */
                    if (notificationStatus == BluetoothMapAppParams.NOTIFICATION_STATUS_YES) {
                        return ResponseCodes.OBEX_HTTP_UNAVAILABLE;
                    } else {
                        /*  2. Allow next Notification OFF Request:
                         *    - Keep the SDP search still in progress.
                         *    - Disconnect and Deregister the contentObserver.
                         */
                        msg.what = BluetoothMnsObexClient.MSG_MNS_NOTIFICATION_REGISTRATION;
                    }
                }
            }
            msg.arg1 = mMasId;
            msg.arg2 = notificationStatus;
            mns.sendMessageDelayed(msg, 10); // Send message without forcing a context switch
            /* Some devices - e.g. PTS needs to get the unregister confirm before we actually
             * disconnect the MNS. */
            if(D) Log.d(TAG,"setNotificationRegistration() MSG_MNS_NOTIFICATION_REGISTRATION " +
                    "send to MNS");
            if(D) Log.d(TAG,"setNotificationRegistration() send : " + msg.what + " to MNS ");
            return ResponseCodes.OBEX_HTTP_OK;
        } else {
            // This should not happen except at shutdown.
            if(D) Log.d(TAG,"setNotificationRegistration() Unable to send registration request");
            return ResponseCodes.OBEX_HTTP_UNAVAILABLE;
        }
        if(notificationStatus == BluetoothMapAppParams.NOTIFICATION_STATUS_YES) {
            registerObserver();
        } else {
            unregisterObserver();
        }
        return ResponseCodes.OBEX_HTTP_OK;
    }

    boolean eventMaskContainsContacts(long mask) {
@@ -3359,7 +3398,9 @@ public class BluetoothMapContentObserver {
    };

    public void init() {
        if (mSmsBroadcastReceiver != null) {
            mSmsBroadcastReceiver.register();
        }
        registerPhoneServiceStateListener();
        mInitialized = true;
    }
@@ -3367,7 +3408,9 @@ public class BluetoothMapContentObserver {
    public void deinit() {
        mInitialized = false;
        unregisterObserver();
        if (mSmsBroadcastReceiver != null) {
            mSmsBroadcastReceiver.unregister();
        }
        unRegisterPhoneServiceStateListener();
        failPendingMessages();
        removeDeletedMessages();
Loading