Merge "Bluetooth HID Device: Remove BluetoothHidDeviceAppConfiguration (2/4)" am: 8ab47567b2

am: bee508cb6d

Change-Id: Ie9aad08a93924655fee5b7f3c7abd77781985ad7
This commit is contained in:
Hansong Zhang
2017-12-06 20:50:07 +00:00
committed by android-build-merger
3 changed files with 8 additions and 98 deletions

View File

@@ -136,9 +136,8 @@ public final class BluetoothHidDevice implements BluetoothProfile {
}
@Override
public void onAppStatusChanged(BluetoothDevice pluggedDevice,
BluetoothHidDeviceAppConfiguration config, boolean registered) {
mCallback.onAppStatusChanged(pluggedDevice, config, registered);
public void onAppStatusChanged(BluetoothDevice pluggedDevice, boolean registered) {
mCallback.onAppStatusChanged(pluggedDevice, registered);
}
@Override
@@ -349,7 +348,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
* Device are only possible when application is registered. Only one
* application can be registered at time. When no longer used, application
* should be unregistered using
* {@link #unregisterApp(BluetoothHidDeviceAppConfiguration)}.
* {@link #unregisterApp()}.
* The registration status should be tracked by the application by handling callback from
* BluetoothHidDeviceCallback#onAppStatusChanged. The app registration status is not related
* to the return value of this method.
@@ -382,11 +381,9 @@ public final class BluetoothHidDevice implements BluetoothProfile {
final IBluetoothHidDevice service = mService;
if (service != null) {
try {
BluetoothHidDeviceAppConfiguration config =
new BluetoothHidDeviceAppConfiguration();
BluetoothHidDeviceCallbackWrapper cbw =
new BluetoothHidDeviceCallbackWrapper(callback);
result = service.registerApp(config, sdp, inQos, outQos, cbw);
result = service.registerApp(sdp, inQos, outQos, cbw);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -407,13 +404,9 @@ public final class BluetoothHidDevice implements BluetoothProfile {
* BluetoothHidDeviceCallback#onAppStatusChanged. The app registration status is not related
* 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.
*/
public boolean unregisterApp(BluetoothHidDeviceAppConfiguration config) {
public boolean unregisterApp() {
Log.v(TAG, "unregisterApp()");
boolean result = false;
@@ -421,7 +414,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
final IBluetoothHidDevice service = mService;
if (service != null) {
try {
result = service.unregisterApp(config);
result = service.unregisterApp();
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}

View File

@@ -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);
}
}

View File

@@ -37,21 +37,17 @@ public abstract class BluetoothHidDeviceCallback {
* {@link BluetoothHidDevice#registerApp
* (String, String, String, byte, byte[], BluetoothHidDeviceCallback)}
* or
* {@link BluetoothHidDevice#unregisterApp(BluetoothHidDeviceAppConfiguration)}
* {@link BluetoothHidDevice#unregisterApp()}
* , but can be also unsolicited in case e.g. Bluetooth was turned off in
* which case application is unregistered automatically.
*
* @param pluggedDevice {@link BluetoothDevice} object which represents host that currently has
* Virtual Cable established with device. Only valid when application is registered, can be
* <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>
* otherwise.
*/
public void onAppStatusChanged(BluetoothDevice pluggedDevice,
BluetoothHidDeviceAppConfiguration config, boolean registered) {
public void onAppStatusChanged(BluetoothDevice pluggedDevice, boolean registered) {
Log.d(TAG, "onAppStatusChanged: pluggedDevice=" + pluggedDevice + " registered="
+ registered);
}