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

Commit 91a3f10c authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4428213 from 601061e2 to pi-release

Change-Id: I7d87c39b45a04f732a82eaa5c20b8f2e93bf6a16
parents b73e0686 601061e2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ public final class DeviceWorkArounds {
    public static final String HONDA_CARKIT = "64:D4:BD";
    public static final String SYNC_CARKIT = "D0:39:72";
    public static final String BREZZA_ZDI_CARKIT = "28:a1:83";
    public static final String MERCEDES_BENZ_CARKIT = "00:26:e8";

    /**
     * @hide
+2 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.os.ParcelUuid;
@@ -394,7 +395,7 @@ public class AdapterService extends Service {
    public void onCreate() {
        super.onCreate();
        debugLog("onCreate()");
        mRemoteDevices = new RemoteDevices(this);
        mRemoteDevices = new RemoteDevices(this, Looper.getMainLooper());
        mRemoteDevices.init();
        mBinder = new AdapterServiceBinder(this);
        mAdapterProperties = new AdapterProperties(this);
+27 −15
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.ParcelUuid;
import android.support.annotation.VisibleForTesting;
@@ -59,6 +60,30 @@ final class RemoteDevices {
    private final HashMap<String, DeviceProperties> mDevices;
    private Queue<String> mDeviceQueue;

    private final Handler mHandler;
    private class RemoteDevicesHandler extends Handler {

        /**
         * Handler must be created from an explicit looper to avoid threading ambiguity
         * @param looper The looper that this handler should be executed on
         */
        RemoteDevicesHandler(Looper looper) {
            super(looper);
        }

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MESSAGE_UUID_INTENT:
                    BluetoothDevice device = (BluetoothDevice) msg.obj;
                    if (device != null) {
                        sendUuidIntent(device);
                    }
                    break;
            }
        }
    }

    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
@@ -80,12 +105,13 @@ final class RemoteDevices {
        }
    };

    RemoteDevices(AdapterService service) {
    RemoteDevices(AdapterService service, Looper looper) {
        sAdapter = BluetoothAdapter.getDefaultAdapter();
        sAdapterService = service;
        sSdpTracker = new ArrayList<BluetoothDevice>();
        mDevices = new HashMap<String, DeviceProperties>();
        mDeviceQueue = new LinkedList<String>();
        mHandler = new RemoteDevicesHandler(looper);
    }

    /**
@@ -782,20 +808,6 @@ final class RemoteDevices {
        return batteryLevel * 100 / numberOfLevels;
    }

    private final Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MESSAGE_UUID_INTENT:
                    BluetoothDevice device = (BluetoothDevice) msg.obj;
                    if (device != null) {
                        sendUuidIntent(device);
                    }
                    break;
            }
        }
    };

    private static void errorLog(String msg) {
        Log.e(TAG, msg);
    }
+19 −4
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
package com.android.bluetooth.map;

import android.util.Log;
import android.util.Xml;

import com.android.bluetooth.DeviceWorkArounds;
import com.android.internal.util.FastXmlSerializer;
@@ -90,11 +91,25 @@ public class BluetoothMapMessageListing {
    public byte[] encode(boolean includeThreadId, String version)
            throws UnsupportedEncodingException {
        StringWriter sw = new StringWriter();
        XmlSerializer xmlMsgElement = new FastXmlSerializer();
        XmlSerializer xmlMsgElement = null;
        boolean isBenzCarkit = DeviceWorkArounds.addressStartsWith(
                BluetoothMapService.getRemoteDevice().getAddress(),
                DeviceWorkArounds.MERCEDES_BENZ_CARKIT);
        try {
            if (isBenzCarkit) {
                Log.d(TAG, "java_interop: Remote is Mercedes Benz, "
                        + "using Xml Workaround.");
                xmlMsgElement = Xml.newSerializer();
                xmlMsgElement.setOutput(sw);
                xmlMsgElement.text("\n");
            } else {
                xmlMsgElement = new FastXmlSerializer();
                xmlMsgElement.setOutput(sw);
                xmlMsgElement.startDocument("UTF-8", true);
            xmlMsgElement.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
                xmlMsgElement.text("\n");
                xmlMsgElement.setFeature(
                        "http://xmlpull.org/v1/doc/features.html#indent-output", true);
            }
            xmlMsgElement.startTag(null, "MAP-msg-listing");
            xmlMsgElement.attribute(null, "version", version);
            // Do the XML encoding of list
+4 −3
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@
*/
package com.android.bluetooth.map;

import com.android.bluetooth.DeviceWorkArounds;
import com.android.bluetooth.map.BluetoothMapUtils.TYPE;
import com.android.bluetooth.util.Interop;

import org.xmlpull.v1.XmlSerializer;

@@ -274,8 +274,9 @@ public class BluetoothMapMessageListingElement
        if (mSubject != null) {
            String stripped = BluetoothMapUtils.stripInvalidChars(mSubject);

            if (Interop.matchByAddress(Interop.INTEROP_MAP_ASCIIONLY,
                    BluetoothMapService.getRemoteDevice().getAddress())) {
            if (DeviceWorkArounds.addressStartsWith(BluetoothMapService
                    .getRemoteDevice().getAddress(), DeviceWorkArounds
                    .MERCEDES_BENZ_CARKIT)) {
                stripped = stripped.replaceAll("[\\P{ASCII}&\"><]", "");
                if (stripped.isEmpty()) {
                    stripped = "---";
Loading