From 0afe190af52d83c5e52fa994e53c48e33e8e3bf4 Mon Sep 17 00:00:00 2001 From: Ivan Podogov Date: Fri, 23 Dec 2016 11:52:21 +0000 Subject: [PATCH] Rename the Bluetooth profile classes for HID Device role. We already have BluetoothInputDevice class, so adding something called BluetoothHidDevice seems confusing. On the other hand, the new class is designed to connect to HID Host devices, so naming it BluetoothInputHost makes sense and goes in line with the existing BluetoothInputDevice. The same goes for the new constant HID_DEVICE that is just as confusing to have together with the INPUT_DEVICE one. This CL also renames the "connection state changed" broadcast (for the same reasons), declares it as an SDK constant, and also adds some javadoc to it. Note that BluetoothHidDeviceApp* classes remained unchanged, as those correspond to the app that implements the Device (and connects to the Host). Test: make Change-Id: I5075ca5b97db3c1dd403c2e9660eecc7380cffe2 --- Android.mk | 2 +- .../android/bluetooth/BluetoothAdapter.java | 10 ++--- ...HidDevice.java => BluetoothInputHost.java} | 43 ++++++++++++++----- .../android/bluetooth/BluetoothProfile.java | 4 +- ...idDevice.aidl => IBluetoothInputHost.aidl} | 2 +- core/res/AndroidManifest.xml | 2 + 6 files changed, 43 insertions(+), 20 deletions(-) rename core/java/android/bluetooth/{BluetoothHidDevice.java => BluetoothInputHost.java} (91%) rename core/java/android/bluetooth/{IBluetoothHidDevice.aidl => IBluetoothInputHost.aidl} (97%) diff --git a/Android.mk b/Android.mk index 3ef94ab0d54c6..5dfa58a6ba62e 100644 --- a/Android.mk +++ b/Android.mk @@ -125,7 +125,7 @@ LOCAL_SRC_FILES += \ core/java/android/bluetooth/IBluetoothSap.aidl \ core/java/android/bluetooth/IBluetoothStateChangeCallback.aidl \ core/java/android/bluetooth/IBluetoothHeadsetClient.aidl \ - core/java/android/bluetooth/IBluetoothHidDevice.aidl \ + core/java/android/bluetooth/IBluetoothInputHost.aidl \ core/java/android/bluetooth/IBluetoothHidDeviceCallback.aidl \ core/java/android/bluetooth/IBluetoothGatt.aidl \ core/java/android/bluetooth/IBluetoothGattCallback.aidl \ diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index 2b35e2bec44ba..b483054c99c7f 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -1940,8 +1940,8 @@ public final class BluetoothAdapter { } else if (profile == BluetoothProfile.MAP_CLIENT) { BluetoothMapClient mapClient = new BluetoothMapClient(context, listener); return true; - } else if (profile == BluetoothProfile.HID_DEVICE) { - BluetoothHidDevice hidd = new BluetoothHidDevice(context, listener); + } else if (profile == BluetoothProfile.INPUT_HOST) { + BluetoothInputHost iHost = new BluetoothInputHost(context, listener); return true; } else { return false; @@ -2019,9 +2019,9 @@ public final class BluetoothAdapter { BluetoothMapClient mapClient = (BluetoothMapClient)proxy; mapClient.close(); break; - case BluetoothProfile.HID_DEVICE: - BluetoothHidDevice hidd = (BluetoothHidDevice) proxy; - hidd.close(); + case BluetoothProfile.INPUT_HOST: + BluetoothInputHost iHost = (BluetoothInputHost) proxy; + iHost.close(); break; } } diff --git a/core/java/android/bluetooth/BluetoothHidDevice.java b/core/java/android/bluetooth/BluetoothInputHost.java similarity index 91% rename from core/java/android/bluetooth/BluetoothHidDevice.java rename to core/java/android/bluetooth/BluetoothInputHost.java index 3e6a078660758..129fe7ecdc39e 100644 --- a/core/java/android/bluetooth/BluetoothHidDevice.java +++ b/core/java/android/bluetooth/BluetoothInputHost.java @@ -16,6 +16,8 @@ package android.bluetooth; +import android.annotation.SdkConstant; +import android.annotation.SdkConstant.SdkConstantType; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -30,12 +32,31 @@ import java.util.List; /** * @hide */ -public final class BluetoothHidDevice implements BluetoothProfile { +public final class BluetoothInputHost implements BluetoothProfile { - private static final String TAG = BluetoothHidDevice.class.getSimpleName(); + private static final String TAG = BluetoothInputHost.class.getSimpleName(); + /** + * Intent used to broadcast the change in connection state of the Input + * Host profile. + * + *

This intent will have 3 extras: + *

+ * + *

{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of + * {@link #STATE_DISCONNECTED}, {@link #STATE_CONNECTING}, + * {@link #STATE_CONNECTED}, {@link #STATE_DISCONNECTING}. + * + *

Requires {@link android.Manifest.permission#BLUETOOTH} permission to + * receive. + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_CONNECTION_STATE_CHANGED = - "android.bluetooth.hid.profile.action.CONNECTION_STATE_CHANGED"; + "android.bluetooth.inputhost.profile.action.CONNECTION_STATE_CHANGED"; /** * Constants representing device subclass. @@ -92,7 +113,7 @@ public final class BluetoothHidDevice implements BluetoothProfile { private ServiceListener mServiceListener; - private IBluetoothHidDevice mService; + private IBluetoothInputHost mService; private BluetoothAdapter mAdapter; @@ -178,11 +199,11 @@ public final class BluetoothHidDevice implements BluetoothProfile { public void onServiceConnected(ComponentName className, IBinder service) { Log.d(TAG, "onServiceConnected()"); - mService = IBluetoothHidDevice.Stub.asInterface(service); + mService = IBluetoothInputHost.Stub.asInterface(service); if (mServiceListener != null) { - mServiceListener.onServiceConnected(BluetoothProfile.HID_DEVICE, - BluetoothHidDevice.this); + mServiceListener.onServiceConnected(BluetoothProfile.INPUT_HOST, + BluetoothInputHost.this); } } @@ -192,13 +213,13 @@ public final class BluetoothHidDevice implements BluetoothProfile { mService = null; if (mServiceListener != null) { - mServiceListener.onServiceDisconnected(BluetoothProfile.HID_DEVICE); + mServiceListener.onServiceDisconnected(BluetoothProfile.INPUT_HOST); } } }; - BluetoothHidDevice(Context context, ServiceListener listener) { - Log.v(TAG, "BluetoothHidDevice"); + BluetoothInputHost(Context context, ServiceListener listener) { + Log.v(TAG, "BluetoothInputHost"); mContext = context; mServiceListener = listener; @@ -217,7 +238,7 @@ public final class BluetoothHidDevice implements BluetoothProfile { } boolean doBind() { - Intent intent = new Intent(IBluetoothHidDevice.class.getName()); + Intent intent = new Intent(IBluetoothInputHost.class.getName()); ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0); intent.setComponent(comp); if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0, diff --git a/core/java/android/bluetooth/BluetoothProfile.java b/core/java/android/bluetooth/BluetoothProfile.java index 6a009a9ba282a..2f64c719ec100 100644 --- a/core/java/android/bluetooth/BluetoothProfile.java +++ b/core/java/android/bluetooth/BluetoothProfile.java @@ -143,10 +143,10 @@ public interface BluetoothProfile { public static final int MAP_CLIENT = 18; /** - * HID device + * Input Host * @hide */ - static public final int HID_DEVICE = 19; + static public final int INPUT_HOST = 19; /** * Max profile ID. This value should be updated whenever a new profile is added to match diff --git a/core/java/android/bluetooth/IBluetoothHidDevice.aidl b/core/java/android/bluetooth/IBluetoothInputHost.aidl similarity index 97% rename from core/java/android/bluetooth/IBluetoothHidDevice.aidl rename to core/java/android/bluetooth/IBluetoothInputHost.aidl index 15f73138e2cb7..b2c421c47c586 100644 --- a/core/java/android/bluetooth/IBluetoothHidDevice.aidl +++ b/core/java/android/bluetooth/IBluetoothInputHost.aidl @@ -23,7 +23,7 @@ import android.bluetooth.BluetoothHidDeviceAppSdpSettings; import android.bluetooth.BluetoothHidDeviceAppQosSettings; /** @hide */ -interface IBluetoothHidDevice { +interface IBluetoothInputHost { boolean registerApp(in BluetoothHidDeviceAppConfiguration config, in BluetoothHidDeviceAppSdpSettings sdp, in BluetoothHidDeviceAppQosSettings inQos, in BluetoothHidDeviceAppQosSettings outQos, in IBluetoothHidDeviceCallback callback); diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 4e98e34d9ebdc..60cf8109edf11 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -180,6 +180,8 @@ android:name="android.bluetooth.input.profile.action.PROTOCOL_MODE_CHANGED" /> +