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

Commit 8fb5e169 authored by William Escande's avatar William Escande
Browse files

MAP: toward removing StaticGuardedByInstance error

remove static getRemoteDevice method.

This will never outerlive the mapservice (plus the device is set to null
when the service close)

Bug: 344658662
Test: m Bluetooth
Flag: exempt refactor
Change-Id: I9a58d56a3cc38d3c27e1fe4e2441efc4d05b2e1a
parent 1b3f02aa
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1259,7 +1259,9 @@ public class BluetoothMapContent {
        } else {
            isHondaCarkit =
                    DeviceWorkArounds.addressStartsWith(
                            BluetoothMapService.getRemoteDevice().getAddress(),
                            BluetoothMapService.getBluetoothMapService()
                                    .getRemoteDevice()
                                    .getAddress(),
                            DeviceWorkArounds.HONDA_CARKIT);
        }
        if (isHondaCarkit || (ap.getParameterMask() & MASK_SUBJECT) != 0) {
+4 −2
Original line number Diff line number Diff line
@@ -100,7 +100,9 @@ public class BluetoothMapMessageListing {
        } else {
            isBenzCarkit =
                    DeviceWorkArounds.addressStartsWith(
                            BluetoothMapService.getRemoteDevice().getAddress(),
                            BluetoothMapService.getBluetoothMapService()
                                    .getRemoteDevice()
                                    .getAddress(),
                            DeviceWorkArounds.MERCEDES_BENZ_CARKIT);
        }
        try {
@@ -147,7 +149,7 @@ public class BluetoothMapMessageListing {
        /* Fix IOT issue to replace '&amp;' by '&', &lt; by < and '&gt; by '>' in MessageListing */
        if (!Utils.isInstrumentationTestMode()
                && DeviceWorkArounds.addressStartsWith(
                        BluetoothMapService.getRemoteDevice().getAddress(),
                        BluetoothMapService.getBluetoothMapService().getRemoteDevice().getAddress(),
                        DeviceWorkArounds.BREZZA_ZDI_CARKIT)) {
            return sw.toString()
                    .replaceAll("&amp;", "&")
+2 −2
Original line number Diff line number Diff line
@@ -267,14 +267,14 @@ public class BluetoothMapMessageListingElement
     * */
    public void encode(XmlSerializer xmlMsgElement, boolean includeThreadId)
            throws IllegalArgumentException, IllegalStateException, IOException {
        // contruct the XML tag for a single msg in the msglisting
        // construct the XML tag for a single msg in the msglisting
        xmlMsgElement.startTag(null, "msg");
        xmlMsgElement.attribute(null, "handle", BluetoothMapUtils.getMapHandle(mCpHandle, mType));
        if (mSubject != null) {
            String stripped = BluetoothMapUtils.stripInvalidChars(mSubject);

            if (DeviceWorkArounds.addressStartsWith(
                    BluetoothMapService.getRemoteDevice().getAddress(),
                    BluetoothMapService.getBluetoothMapService().getRemoteDevice().getAddress(),
                    DeviceWorkArounds.MERCEDES_BENZ_CARKIT)) {
                stripped = stripped.replaceAll("[\\P{ASCII}&\"><]", "");
                if (stripped.isEmpty()) {
+2 −2
Original line number Diff line number Diff line
@@ -519,7 +519,7 @@ public class BluetoothMapService extends ProfileService {
        return mState;
    }

    public static BluetoothDevice getRemoteDevice() {
    public BluetoothDevice getRemoteDevice() {
        return sRemoteDevice;
    }

@@ -1307,7 +1307,7 @@ public class BluetoothMapService extends ProfileService {
                    Log.v(TAG, "getClient() - no service - returning " + null);
                    return null;
                }
                BluetoothDevice client = BluetoothMapService.getRemoteDevice();
                BluetoothDevice client = service.getRemoteDevice();
                Log.v(TAG, "getClient() - returning " + client);
                return client;
            } catch (RuntimeException e) {
+2 −1
Original line number Diff line number Diff line
@@ -89,7 +89,8 @@ public class BluetoothMapbMessageSms extends BluetoothMapbMessage {
                    mSmsBody.replaceAll(
                            "END:MSG",
                            "/END\\:MSG"); // Replace any occurrences of END:MSG with \END:MSG
            String remoteAddress = BluetoothMapService.getRemoteDevice().getAddress();
            String remoteAddress =
                    BluetoothMapService.getBluetoothMapService().getRemoteDevice().getAddress();
            /* Fix IOT issue with PCM carkit where carkit is unable to parse
            message if carriage return is present in it */
            if (DeviceWorkArounds.addressStartsWith(remoteAddress, DeviceWorkArounds.PCM_CARKIT)) {
Loading