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

Commit 271b27cf authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge changes from topic "jul9" into sc-dev

* changes:
  Obtain remote names directly from AdapterService.
  Force AttributionSource after handler dispatch.
parents 74c34d7f da7c2f35
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ import static android.os.PowerExemptionManager.TEMPORARY_ALLOW_LIST_TYPE_FOREGRO


import android.Manifest;
import android.Manifest;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.annotation.SuppressLint;
import android.app.AppGlobals;
import android.app.AppGlobals;
@@ -62,6 +63,7 @@ import android.provider.DeviceConfig;
import android.provider.Telephony;
import android.provider.Telephony;
import android.util.Log;
import android.util.Log;


import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.btservice.ProfileService;


import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParser;
@@ -113,6 +115,15 @@ public final class Utils {
        return c == 'w' || c == 'W';
        return c == 'w' || c == 'W';
    }
    }


    public static @Nullable String getName(@Nullable BluetoothDevice device) {
        final AdapterService service = AdapterService.getAdapterService();
        if (service != null && device != null) {
            return service.getRemoteName(device);
        } else {
            return null;
        }
    }

    public static String getAddressStringFromByte(byte[] address) {
    public static String getAddressStringFromByte(byte[] address) {
        if (address == null || address.length != BD_ADDR_LEN) {
        if (address == null || address.length != BD_ADDR_LEN) {
            return null;
            return null;
+1 −1
Original line number Original line Diff line number Diff line
@@ -132,7 +132,7 @@ public class A2dpSinkStateMachine extends StateMachine {
     */
     */
    public void dump(StringBuilder sb) {
    public void dump(StringBuilder sb) {
        ProfileService.println(sb, "mDevice: " + mDevice.getAddress() + "("
        ProfileService.println(sb, "mDevice: " + mDevice.getAddress() + "("
                + mDevice.getName() + ") " + this.toString());
                + Utils.getName(mDevice) + ") " + this.toString());
    }
    }


    @Override
    @Override
+1 −1
Original line number Original line Diff line number Diff line
@@ -251,7 +251,7 @@ class AvrcpControllerStateMachine extends StateMachine {
     */
     */
    public void dump(StringBuilder sb) {
    public void dump(StringBuilder sb) {
        ProfileService.println(sb, "mDevice: " + mDevice.getAddress() + "("
        ProfileService.println(sb, "mDevice: " + mDevice.getAddress() + "("
                + mDevice.getName() + ") " + this.toString());
                + Utils.getName(mDevice) + ") " + this.toString());
        ProfileService.println(sb, "isActive: " + isActive());
        ProfileService.println(sb, "isActive: " + isActive());
        ProfileService.println(sb, "Control: " + mRemoteControlConnected);
        ProfileService.println(sb, "Control: " + mRemoteControlConnected);
        ProfileService.println(sb, "Browsing: " + mBrowsingConnected);
        ProfileService.println(sb, "Browsing: " + mBrowsingConnected);
+6 −3
Original line number Original line Diff line number Diff line
@@ -21,6 +21,8 @@ import android.net.Uri;
import android.support.v4.media.MediaBrowserCompat.MediaItem;
import android.support.v4.media.MediaBrowserCompat.MediaItem;
import android.util.Log;
import android.util.Log;


import com.android.bluetooth.Utils;

import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.HashSet;
@@ -76,8 +78,9 @@ public class BrowseTree {
        } else {
        } else {
            mRootNode = new BrowseNode(new AvrcpItem.Builder().setDevice(device)
            mRootNode = new BrowseNode(new AvrcpItem.Builder().setDevice(device)
                    .setUuid(ROOT + device.getAddress().toString())
                    .setUuid(ROOT + device.getAddress().toString())
                    .setTitle(device.getName()).setBrowsable(true).build());
                    .setTitle(Utils.getName(device)).setBrowsable(true).build());
        }
        }

        mRootNode.mBrowseScope = AvrcpControllerService.BROWSE_SCOPE_PLAYER_LIST;
        mRootNode.mBrowseScope = AvrcpControllerService.BROWSE_SCOPE_PLAYER_LIST;
        mRootNode.setExpectedChildren(255);
        mRootNode.setExpectedChildren(255);


@@ -156,8 +159,8 @@ public class BrowseTree {
            AvrcpItem.Builder aid = new AvrcpItem.Builder();
            AvrcpItem.Builder aid = new AvrcpItem.Builder();
            aid.setDevice(device);
            aid.setDevice(device);
            aid.setUuid(playerKey);
            aid.setUuid(playerKey);
            aid.setDisplayableName(device.getName());
            aid.setDisplayableName(Utils.getName(device));
            aid.setTitle(device.getName());
            aid.setTitle(Utils.getName(device));
            aid.setBrowsable(true);
            aid.setBrowsable(true);
            mItem = aid.build();
            mItem = aid.build();
        }
        }
+1 −1
Original line number Original line Diff line number Diff line
@@ -1066,7 +1066,7 @@ class AdapterProperties {
        for (BluetoothDevice device : mBondedDevices) {
        for (BluetoothDevice device : mBondedDevices) {
            writer.println(
            writer.println(
                    "    " + device.getAddress() + " [" + dumpDeviceType(device.getType()) + "] "
                    "    " + device.getAddress() + " [" + dumpDeviceType(device.getType()) + "] "
                            + device.getName());
                            + Utils.getName(device));
        }
        }
    }
    }


Loading