Merge "Bluetooth HID Device: Remove BluetoothHidDeviceAppConfiguration (2/4)"
This commit is contained in:
@@ -136,9 +136,8 @@ public final class BluetoothHidDevice implements BluetoothProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAppStatusChanged(BluetoothDevice pluggedDevice,
|
public void onAppStatusChanged(BluetoothDevice pluggedDevice, boolean registered) {
|
||||||
BluetoothHidDeviceAppConfiguration config, boolean registered) {
|
mCallback.onAppStatusChanged(pluggedDevice, registered);
|
||||||
mCallback.onAppStatusChanged(pluggedDevice, config, registered);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -349,7 +348,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
|
|||||||
* Device are only possible when application is registered. Only one
|
* Device are only possible when application is registered. Only one
|
||||||
* application can be registered at time. When no longer used, application
|
* application can be registered at time. When no longer used, application
|
||||||
* should be unregistered using
|
* should be unregistered using
|
||||||
* {@link #unregisterApp(BluetoothHidDeviceAppConfiguration)}.
|
* {@link #unregisterApp()}.
|
||||||
* The registration status should be tracked by the application by handling callback from
|
* The registration status should be tracked by the application by handling callback from
|
||||||
* BluetoothHidDeviceCallback#onAppStatusChanged. The app registration status is not related
|
* BluetoothHidDeviceCallback#onAppStatusChanged. The app registration status is not related
|
||||||
* to the return value of this method.
|
* to the return value of this method.
|
||||||
@@ -382,11 +381,9 @@ public final class BluetoothHidDevice implements BluetoothProfile {
|
|||||||
final IBluetoothHidDevice service = mService;
|
final IBluetoothHidDevice service = mService;
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
try {
|
try {
|
||||||
BluetoothHidDeviceAppConfiguration config =
|
|
||||||
new BluetoothHidDeviceAppConfiguration();
|
|
||||||
BluetoothHidDeviceCallbackWrapper cbw =
|
BluetoothHidDeviceCallbackWrapper cbw =
|
||||||
new BluetoothHidDeviceCallbackWrapper(callback);
|
new BluetoothHidDeviceCallbackWrapper(callback);
|
||||||
result = service.registerApp(config, sdp, inQos, outQos, cbw);
|
result = service.registerApp(sdp, inQos, outQos, cbw);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, e.toString());
|
Log.e(TAG, e.toString());
|
||||||
}
|
}
|
||||||
@@ -407,13 +404,9 @@ public final class BluetoothHidDevice implements BluetoothProfile {
|
|||||||
* BluetoothHidDeviceCallback#onAppStatusChanged. The app registration status is not related
|
* BluetoothHidDeviceCallback#onAppStatusChanged. The app registration status is not related
|
||||||
* to the return value of this method.
|
* to the return value of this method.
|
||||||
*
|
*
|
||||||
* @param config {@link BluetoothHidDeviceAppConfiguration} object as obtained from {@link
|
|
||||||
* BluetoothHidDeviceCallback#onAppStatusChanged(BluetoothDevice,
|
|
||||||
* BluetoothHidDeviceAppConfiguration,
|
|
||||||
* boolean)}
|
|
||||||
* @return true if the command is successfully sent; otherwise false.
|
* @return true if the command is successfully sent; otherwise false.
|
||||||
*/
|
*/
|
||||||
public boolean unregisterApp(BluetoothHidDeviceAppConfiguration config) {
|
public boolean unregisterApp() {
|
||||||
Log.v(TAG, "unregisterApp()");
|
Log.v(TAG, "unregisterApp()");
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
@@ -421,7 +414,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
|
|||||||
final IBluetoothHidDevice service = mService;
|
final IBluetoothHidDevice service = mService;
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
try {
|
try {
|
||||||
result = service.unregisterApp(config);
|
result = service.unregisterApp();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, e.toString());
|
Log.e(TAG, e.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package android.bluetooth;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the app configuration for a Bluetooth HID Device application.
|
|
||||||
*
|
|
||||||
* The app needs a BluetoothHidDeviceAppConfiguration token to unregister
|
|
||||||
* the Bluetooth HID Device service.
|
|
||||||
*
|
|
||||||
* {@see BluetoothHidDevice}
|
|
||||||
*
|
|
||||||
* {@hide}
|
|
||||||
*/
|
|
||||||
public final class BluetoothHidDeviceAppConfiguration implements Parcelable {
|
|
||||||
private final long mHash;
|
|
||||||
|
|
||||||
BluetoothHidDeviceAppConfiguration() {
|
|
||||||
Random rnd = new Random();
|
|
||||||
mHash = rnd.nextLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
BluetoothHidDeviceAppConfiguration(long hash) {
|
|
||||||
mHash = hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (o instanceof BluetoothHidDeviceAppConfiguration) {
|
|
||||||
BluetoothHidDeviceAppConfiguration config = (BluetoothHidDeviceAppConfiguration) o;
|
|
||||||
return mHash == config.mHash;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Parcelable.Creator<BluetoothHidDeviceAppConfiguration> CREATOR =
|
|
||||||
new Parcelable.Creator<BluetoothHidDeviceAppConfiguration>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BluetoothHidDeviceAppConfiguration createFromParcel(Parcel in) {
|
|
||||||
long hash = in.readLong();
|
|
||||||
return new BluetoothHidDeviceAppConfiguration(hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BluetoothHidDeviceAppConfiguration[] newArray(int size) {
|
|
||||||
return new BluetoothHidDeviceAppConfiguration[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel out, int flags) {
|
|
||||||
out.writeLong(mHash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -37,21 +37,17 @@ public abstract class BluetoothHidDeviceCallback {
|
|||||||
* {@link BluetoothHidDevice#registerApp
|
* {@link BluetoothHidDevice#registerApp
|
||||||
* (String, String, String, byte, byte[], BluetoothHidDeviceCallback)}
|
* (String, String, String, byte, byte[], BluetoothHidDeviceCallback)}
|
||||||
* or
|
* or
|
||||||
* {@link BluetoothHidDevice#unregisterApp(BluetoothHidDeviceAppConfiguration)}
|
* {@link BluetoothHidDevice#unregisterApp()}
|
||||||
* , but can be also unsolicited in case e.g. Bluetooth was turned off in
|
* , but can be also unsolicited in case e.g. Bluetooth was turned off in
|
||||||
* which case application is unregistered automatically.
|
* which case application is unregistered automatically.
|
||||||
*
|
*
|
||||||
* @param pluggedDevice {@link BluetoothDevice} object which represents host that currently has
|
* @param pluggedDevice {@link BluetoothDevice} object which represents host that currently has
|
||||||
* Virtual Cable established with device. Only valid when application is registered, can be
|
* Virtual Cable established with device. Only valid when application is registered, can be
|
||||||
* <code>null</code>.
|
* <code>null</code>.
|
||||||
* @param config {@link BluetoothHidDeviceAppConfiguration} object which represents token
|
|
||||||
* required to unregister application using
|
|
||||||
* {@link BluetoothHidDevice#unregisterApp(BluetoothHidDeviceAppConfiguration)}.
|
|
||||||
* @param registered <code>true</code> if application is registered, <code>false</code>
|
* @param registered <code>true</code> if application is registered, <code>false</code>
|
||||||
* otherwise.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
public void onAppStatusChanged(BluetoothDevice pluggedDevice,
|
public void onAppStatusChanged(BluetoothDevice pluggedDevice, boolean registered) {
|
||||||
BluetoothHidDeviceAppConfiguration config, boolean registered) {
|
|
||||||
Log.d(TAG, "onAppStatusChanged: pluggedDevice=" + pluggedDevice + " registered="
|
Log.d(TAG, "onAppStatusChanged: pluggedDevice=" + pluggedDevice + " registered="
|
||||||
+ registered);
|
+ registered);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user