From 347ef4099e0d2b1334efd22e6ca7d5cc5464b4eb Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Tue, 3 Apr 2018 12:12:53 -0700 Subject: [PATCH] Bluetooth: Add hidden API to get current user of HID Device (1/3) Bug: 69136526 Test: test with apps using HID Device profile Change-Id: If0e49840257c877c975c2da176a08e613668cbc3 --- .../android/bluetooth/BluetoothHidDevice.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/java/android/bluetooth/BluetoothHidDevice.java b/core/java/android/bluetooth/BluetoothHidDevice.java index e017c42af98e8..4a466c6686c11 100644 --- a/core/java/android/bluetooth/BluetoothHidDevice.java +++ b/core/java/android/bluetooth/BluetoothHidDevice.java @@ -700,6 +700,28 @@ public final class BluetoothHidDevice implements BluetoothProfile { return result; } + /** + * Gets the application name of the current HidDeviceService user. + * + * @return the current user name, or empty string if cannot get the name + * {@hide} + */ + public String getUserAppName() { + final IBluetoothHidDevice service = mService; + + if (service != null) { + try { + return service.getUserAppName(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + } + + return ""; + } + /** * Initiates connection to host which is currently paired with this device. If the application * is not registered, #connect(BluetoothDevice) will fail. The connection state should be