Merge "Temporarily comment out usages of PropertyInvalidatedCache in Bluetooth code while it is pending migration to module-utils"
This commit is contained in:
@@ -28,8 +28,7 @@ import android.annotation.RequiresPermission;
|
|||||||
import android.annotation.SdkConstant;
|
import android.annotation.SdkConstant;
|
||||||
import android.annotation.SdkConstant.SdkConstantType;
|
import android.annotation.SdkConstant.SdkConstantType;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi; //import android.app.PropertyInvalidatedCache;
|
||||||
import android.app.PropertyInvalidatedCache;
|
|
||||||
import android.bluetooth.BluetoothDevice.Transport;
|
import android.bluetooth.BluetoothDevice.Transport;
|
||||||
import android.bluetooth.BluetoothProfile.ConnectionPolicy;
|
import android.bluetooth.BluetoothProfile.ConnectionPolicy;
|
||||||
import android.bluetooth.annotations.RequiresBluetoothAdvertisePermission;
|
import android.bluetooth.annotations.RequiresBluetoothAdvertisePermission;
|
||||||
@@ -676,14 +675,15 @@ public final class BluetoothAdapter {
|
|||||||
"android.bluetooth.adapter.action.BLE_ACL_DISCONNECTED";
|
"android.bluetooth.adapter.action.BLE_ACL_DISCONNECTED";
|
||||||
|
|
||||||
/** The profile is in disconnected state */
|
/** The profile is in disconnected state */
|
||||||
public static final int STATE_DISCONNECTED = BluetoothProtoEnums.CONNECTION_STATE_DISCONNECTED;
|
public static final int STATE_DISCONNECTED =
|
||||||
|
0; //BluetoothProtoEnums.CONNECTION_STATE_DISCONNECTED;
|
||||||
/** The profile is in connecting state */
|
/** The profile is in connecting state */
|
||||||
public static final int STATE_CONNECTING = BluetoothProtoEnums.CONNECTION_STATE_CONNECTING;
|
public static final int STATE_CONNECTING = 1; //BluetoothProtoEnums.CONNECTION_STATE_CONNECTING;
|
||||||
/** The profile is in connected state */
|
/** The profile is in connected state */
|
||||||
public static final int STATE_CONNECTED = BluetoothProtoEnums.CONNECTION_STATE_CONNECTED;
|
public static final int STATE_CONNECTED = 2; //BluetoothProtoEnums.CONNECTION_STATE_CONNECTED;
|
||||||
/** The profile is in disconnecting state */
|
/** The profile is in disconnecting state */
|
||||||
public static final int STATE_DISCONNECTING =
|
public static final int STATE_DISCONNECTING =
|
||||||
BluetoothProtoEnums.CONNECTION_STATE_DISCONNECTING;
|
3; //BluetoothProtoEnums.CONNECTION_STATE_DISCONNECTING;
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public static final String BLUETOOTH_MANAGER_SERVICE = "bluetooth_manager";
|
public static final String BLUETOOTH_MANAGER_SERVICE = "bluetooth_manager";
|
||||||
@@ -1044,6 +1044,7 @@ public final class BluetoothAdapter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private static final String BLUETOOTH_GET_STATE_CACHE_PROPERTY = "cache_key.bluetooth.get_state";
|
private static final String BLUETOOTH_GET_STATE_CACHE_PROPERTY = "cache_key.bluetooth.get_state";
|
||||||
|
|
||||||
private final PropertyInvalidatedCache<Void, Integer> mBluetoothGetStateCache =
|
private final PropertyInvalidatedCache<Void, Integer> mBluetoothGetStateCache =
|
||||||
@@ -1059,17 +1060,22 @@ public final class BluetoothAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
|
/*
|
||||||
@RequiresNoPermission
|
@RequiresNoPermission
|
||||||
public void disableBluetoothGetStateCache() {
|
public void disableBluetoothGetStateCache() {
|
||||||
mBluetoothGetStateCache.disableLocal();
|
mBluetoothGetStateCache.disableLocal();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
|
/*
|
||||||
public static void invalidateBluetoothGetStateCache() {
|
public static void invalidateBluetoothGetStateCache() {
|
||||||
PropertyInvalidatedCache.invalidateCache(BLUETOOTH_GET_STATE_CACHE_PROPERTY);
|
PropertyInvalidatedCache.invalidateCache(BLUETOOTH_GET_STATE_CACHE_PROPERTY);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the current bluetooth state. If the service is down, return
|
* Fetch the current bluetooth state. If the service is down, return
|
||||||
@@ -1081,14 +1087,12 @@ public final class BluetoothAdapter {
|
|||||||
try {
|
try {
|
||||||
mServiceLock.readLock().lock();
|
mServiceLock.readLock().lock();
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
state = mBluetoothGetStateCache.query(null);
|
//state = mBluetoothGetStateCache.query(null);
|
||||||
}
|
state = mService.getState();
|
||||||
} catch (RuntimeException e) {
|
|
||||||
if (e.getCause() instanceof RemoteException) {
|
|
||||||
Log.e(TAG, "", e.getCause());
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, "", e);
|
||||||
|
e.rethrowFromSystemServer();
|
||||||
} finally {
|
} finally {
|
||||||
mServiceLock.readLock().unlock();
|
mServiceLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
@@ -2100,6 +2104,7 @@ public final class BluetoothAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private static final String BLUETOOTH_FILTERING_CACHE_PROPERTY =
|
private static final String BLUETOOTH_FILTERING_CACHE_PROPERTY =
|
||||||
"cache_key.bluetooth.is_offloaded_filtering_supported";
|
"cache_key.bluetooth.is_offloaded_filtering_supported";
|
||||||
private final PropertyInvalidatedCache<Void, Boolean> mBluetoothFilteringCache =
|
private final PropertyInvalidatedCache<Void, Boolean> mBluetoothFilteringCache =
|
||||||
@@ -2122,17 +2127,22 @@ public final class BluetoothAdapter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
|
/*
|
||||||
@RequiresNoPermission
|
@RequiresNoPermission
|
||||||
public void disableIsOffloadedFilteringSupportedCache() {
|
public void disableIsOffloadedFilteringSupportedCache() {
|
||||||
mBluetoothFilteringCache.disableLocal();
|
mBluetoothFilteringCache.disableLocal();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
|
/*
|
||||||
public static void invalidateIsOffloadedFilteringSupportedCache() {
|
public static void invalidateIsOffloadedFilteringSupportedCache() {
|
||||||
PropertyInvalidatedCache.invalidateCache(BLUETOOTH_FILTERING_CACHE_PROPERTY);
|
PropertyInvalidatedCache.invalidateCache(BLUETOOTH_FILTERING_CACHE_PROPERTY);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if offloaded filters are supported
|
* Return true if offloaded filters are supported
|
||||||
@@ -2145,7 +2155,18 @@ public final class BluetoothAdapter {
|
|||||||
if (!getLeAccess()) {
|
if (!getLeAccess()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mBluetoothFilteringCache.query(null);
|
//return mBluetoothFilteringCache.query(null);
|
||||||
|
try {
|
||||||
|
mServiceLock.readLock().lock();
|
||||||
|
if (mService != null) {
|
||||||
|
return mService.isOffloadedFilteringSupported();
|
||||||
|
}
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, "failed to get isOffloadedFilteringSupported, error: ", e);
|
||||||
|
} finally {
|
||||||
|
mServiceLock.readLock().unlock();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2551,15 +2572,13 @@ public final class BluetoothAdapter {
|
|||||||
return supportedProfiles;
|
return supportedProfiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private static final String BLUETOOTH_GET_ADAPTER_CONNECTION_STATE_CACHE_PROPERTY =
|
private static final String BLUETOOTH_GET_ADAPTER_CONNECTION_STATE_CACHE_PROPERTY =
|
||||||
"cache_key.bluetooth.get_adapter_connection_state";
|
"cache_key.bluetooth.get_adapter_connection_state";
|
||||||
private final PropertyInvalidatedCache<Void, Integer>
|
private final PropertyInvalidatedCache<Void, Integer>
|
||||||
mBluetoothGetAdapterConnectionStateCache =
|
mBluetoothGetAdapterConnectionStateCache =
|
||||||
new PropertyInvalidatedCache<Void, Integer> (
|
new PropertyInvalidatedCache<Void, Integer> (
|
||||||
8, BLUETOOTH_GET_ADAPTER_CONNECTION_STATE_CACHE_PROPERTY) {
|
8, BLUETOOTH_GET_ADAPTER_CONNECTION_STATE_CACHE_PROPERTY) {
|
||||||
/**
|
|
||||||
* This method must not be called when mService is null.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressLint("AndroidFrameworkRequiresPermission")
|
@SuppressLint("AndroidFrameworkRequiresPermission")
|
||||||
protected Integer recompute(Void query) {
|
protected Integer recompute(Void query) {
|
||||||
@@ -2570,18 +2589,23 @@ public final class BluetoothAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
|
/*
|
||||||
@RequiresNoPermission
|
@RequiresNoPermission
|
||||||
public void disableGetAdapterConnectionStateCache() {
|
public void disableGetAdapterConnectionStateCache() {
|
||||||
mBluetoothGetAdapterConnectionStateCache.disableLocal();
|
mBluetoothGetAdapterConnectionStateCache.disableLocal();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
|
/*
|
||||||
public static void invalidateGetAdapterConnectionStateCache() {
|
public static void invalidateGetAdapterConnectionStateCache() {
|
||||||
PropertyInvalidatedCache.invalidateCache(
|
PropertyInvalidatedCache.invalidateCache(
|
||||||
BLUETOOTH_GET_ADAPTER_CONNECTION_STATE_CACHE_PROPERTY);
|
BLUETOOTH_GET_ADAPTER_CONNECTION_STATE_CACHE_PROPERTY);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current connection state of the local Bluetooth adapter.
|
* Get the current connection state of the local Bluetooth adapter.
|
||||||
@@ -2605,20 +2629,18 @@ public final class BluetoothAdapter {
|
|||||||
try {
|
try {
|
||||||
mServiceLock.readLock().lock();
|
mServiceLock.readLock().lock();
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
return mBluetoothGetAdapterConnectionStateCache.query(null);
|
return mService.getAdapterConnectionState();
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
if (e.getCause() instanceof RemoteException) {
|
|
||||||
Log.e(TAG, "getConnectionState:", e.getCause());
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
//return mBluetoothGetAdapterConnectionStateCache.query(null);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, "failed to getConnectionState, error: ", e);
|
||||||
} finally {
|
} finally {
|
||||||
mServiceLock.readLock().unlock();
|
mServiceLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
return BluetoothAdapter.STATE_DISCONNECTED;
|
return BluetoothAdapter.STATE_DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private static final String BLUETOOTH_PROFILE_CACHE_PROPERTY =
|
private static final String BLUETOOTH_PROFILE_CACHE_PROPERTY =
|
||||||
"cache_key.bluetooth.get_profile_connection_state";
|
"cache_key.bluetooth.get_profile_connection_state";
|
||||||
private final PropertyInvalidatedCache<Integer, Integer>
|
private final PropertyInvalidatedCache<Integer, Integer>
|
||||||
@@ -2646,17 +2668,22 @@ public final class BluetoothAdapter {
|
|||||||
query);
|
query);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
|
/*
|
||||||
@RequiresNoPermission
|
@RequiresNoPermission
|
||||||
public void disableGetProfileConnectionStateCache() {
|
public void disableGetProfileConnectionStateCache() {
|
||||||
mGetProfileConnectionStateCache.disableLocal();
|
mGetProfileConnectionStateCache.disableLocal();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
|
/*
|
||||||
public static void invalidateGetProfileConnectionStateCache() {
|
public static void invalidateGetProfileConnectionStateCache() {
|
||||||
PropertyInvalidatedCache.invalidateCache(BLUETOOTH_PROFILE_CACHE_PROPERTY);
|
PropertyInvalidatedCache.invalidateCache(BLUETOOTH_PROFILE_CACHE_PROPERTY);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current connection state of a profile.
|
* Get the current connection state of a profile.
|
||||||
@@ -2678,7 +2705,18 @@ public final class BluetoothAdapter {
|
|||||||
if (getState() != STATE_ON) {
|
if (getState() != STATE_ON) {
|
||||||
return BluetoothProfile.STATE_DISCONNECTED;
|
return BluetoothProfile.STATE_DISCONNECTED;
|
||||||
}
|
}
|
||||||
return mGetProfileConnectionStateCache.query(new Integer(profile));
|
try {
|
||||||
|
mServiceLock.readLock().lock();
|
||||||
|
if (mService != null) {
|
||||||
|
mService.getProfileConnectionState(profile);
|
||||||
|
}
|
||||||
|
//return mGetProfileConnectionStateCache.query(new Integer(profile));
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, "failed to getProfileConnectionState, error: ", e);
|
||||||
|
} finally {
|
||||||
|
mServiceLock.readLock().unlock();
|
||||||
|
}
|
||||||
|
return BluetoothProfile.STATE_DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ import android.annotation.RequiresPermission;
|
|||||||
import android.annotation.SdkConstant;
|
import android.annotation.SdkConstant;
|
||||||
import android.annotation.SdkConstant.SdkConstantType;
|
import android.annotation.SdkConstant.SdkConstantType;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi; //import android.app.PropertyInvalidatedCache;
|
||||||
import android.app.PropertyInvalidatedCache;
|
|
||||||
import android.bluetooth.annotations.RequiresBluetoothConnectPermission;
|
import android.bluetooth.annotations.RequiresBluetoothConnectPermission;
|
||||||
import android.bluetooth.annotations.RequiresBluetoothLocationPermission;
|
import android.bluetooth.annotations.RequiresBluetoothLocationPermission;
|
||||||
import android.bluetooth.annotations.RequiresBluetoothScanPermission;
|
import android.bluetooth.annotations.RequiresBluetoothScanPermission;
|
||||||
@@ -1597,6 +1596,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private static final String BLUETOOTH_BONDING_CACHE_PROPERTY =
|
private static final String BLUETOOTH_BONDING_CACHE_PROPERTY =
|
||||||
"cache_key.bluetooth.get_bond_state";
|
"cache_key.bluetooth.get_bond_state";
|
||||||
private final PropertyInvalidatedCache<BluetoothDevice, Integer> mBluetoothBondCache =
|
private final PropertyInvalidatedCache<BluetoothDevice, Integer> mBluetoothBondCache =
|
||||||
@@ -1612,16 +1612,19 @@ public final class BluetoothDevice implements Parcelable, Attributable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void disableBluetoothGetBondStateCache() {
|
/* public void disableBluetoothGetBondStateCache() {
|
||||||
mBluetoothBondCache.disableLocal();
|
mBluetoothBondCache.disableLocal();
|
||||||
}
|
} */
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
|
/*
|
||||||
public static void invalidateBluetoothGetBondStateCache() {
|
public static void invalidateBluetoothGetBondStateCache() {
|
||||||
PropertyInvalidatedCache.invalidateCache(BLUETOOTH_BONDING_CACHE_PROPERTY);
|
PropertyInvalidatedCache.invalidateCache(BLUETOOTH_BONDING_CACHE_PROPERTY);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the bond state of the remote device.
|
* Get the bond state of the remote device.
|
||||||
@@ -1643,13 +1646,11 @@ public final class BluetoothDevice implements Parcelable, Attributable {
|
|||||||
return BOND_NONE;
|
return BOND_NONE;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return mBluetoothBondCache.query(this);
|
//return mBluetoothBondCache.query(this);
|
||||||
} catch (RuntimeException e) {
|
return sService.getBondState(this, mAttributionSource);
|
||||||
if (e.getCause() instanceof RemoteException) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "", e);
|
Log.e(TAG, "failed to ", e);
|
||||||
} else {
|
e.rethrowFromSystemServer();
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return BOND_NONE;
|
return BOND_NONE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user