Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74f24520 authored by Rahul Sabnis's avatar Rahul Sabnis Committed by Automerger Merge Worker
Browse files

Merge "Temporarily comment out usages of PropertyInvalidatedCache in Bluetooth...

Merge "Temporarily comment out usages of PropertyInvalidatedCache in Bluetooth code while it is pending migration to module-utils" am: 325365b7 am: 17d16a9f am: 280c0e9c am: 1f48a764

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1947703

Change-Id: I4c23485a14736907a9157cf4b25943602763b7a3
parents 7d521656 1f48a764
Loading
Loading
Loading
Loading
+63 −25
Original line number Diff line number Diff line
@@ -28,8 +28,7 @@ import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.app.PropertyInvalidatedCache;
import android.annotation.SystemApi; //import android.app.PropertyInvalidatedCache;
import android.bluetooth.BluetoothDevice.Transport;
import android.bluetooth.BluetoothProfile.ConnectionPolicy;
import android.bluetooth.annotations.RequiresBluetoothAdvertisePermission;
@@ -687,14 +686,15 @@ public final class BluetoothAdapter {
            "android.bluetooth.adapter.action.BLE_ACL_DISCONNECTED";

    /** 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 */
    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 */
    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 */
    public static final int STATE_DISCONNECTING =
            BluetoothProtoEnums.CONNECTION_STATE_DISCONNECTING;
            3; //BluetoothProtoEnums.CONNECTION_STATE_DISCONNECTING;

    /** @hide */
    public static final String BLUETOOTH_MANAGER_SERVICE = "bluetooth_manager";
@@ -1055,6 +1055,7 @@ public final class BluetoothAdapter {
        return false;
    }

    /*
    private static final String BLUETOOTH_GET_STATE_CACHE_PROPERTY = "cache_key.bluetooth.get_state";

    private final PropertyInvalidatedCache<Void, Integer> mBluetoothGetStateCache =
@@ -1070,17 +1071,22 @@ public final class BluetoothAdapter {
                    }
                }
            };
     */

    /** @hide */
    /*
    @RequiresNoPermission
    public void disableBluetoothGetStateCache() {
        mBluetoothGetStateCache.disableLocal();
    }
     */

    /** @hide */
    /*
    public static void invalidateBluetoothGetStateCache() {
        PropertyInvalidatedCache.invalidateCache(BLUETOOTH_GET_STATE_CACHE_PROPERTY);
    }
     */

    /**
     * Fetch the current bluetooth state.  If the service is down, return
@@ -1092,14 +1098,12 @@ public final class BluetoothAdapter {
        try {
            mServiceLock.readLock().lock();
            if (mService != null) {
                state = mBluetoothGetStateCache.query(null);
            }
        } catch (RuntimeException e) {
            if (e.getCause() instanceof RemoteException) {
                Log.e(TAG, "", e.getCause());
            } else {
                throw e;
                //state = mBluetoothGetStateCache.query(null);
                state = mService.getState();
            }
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
            e.rethrowFromSystemServer();
        } finally {
            mServiceLock.readLock().unlock();
        }
@@ -2078,6 +2082,7 @@ public final class BluetoothAdapter {
        }
    }

    /*
    private static final String BLUETOOTH_FILTERING_CACHE_PROPERTY =
            "cache_key.bluetooth.is_offloaded_filtering_supported";
    private final PropertyInvalidatedCache<Void, Boolean> mBluetoothFilteringCache =
@@ -2100,17 +2105,22 @@ public final class BluetoothAdapter {

                }
            };
     */

    /** @hide */
    /*
    @RequiresNoPermission
    public void disableIsOffloadedFilteringSupportedCache() {
        mBluetoothFilteringCache.disableLocal();
    }
     */

    /** @hide */
    /*
    public static void invalidateIsOffloadedFilteringSupportedCache() {
        PropertyInvalidatedCache.invalidateCache(BLUETOOTH_FILTERING_CACHE_PROPERTY);
    }
     */

    /**
     * Return true if offloaded filters are supported
@@ -2123,7 +2133,18 @@ public final class BluetoothAdapter {
        if (!getLeAccess()) {
            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;
    }

    /**
@@ -2530,15 +2551,13 @@ public final class BluetoothAdapter {
        return supportedProfiles;
    }

    /*
    private static final String BLUETOOTH_GET_ADAPTER_CONNECTION_STATE_CACHE_PROPERTY =
            "cache_key.bluetooth.get_adapter_connection_state";
    private final PropertyInvalidatedCache<Void, Integer>
            mBluetoothGetAdapterConnectionStateCache =
            new PropertyInvalidatedCache<Void, Integer> (
                8, BLUETOOTH_GET_ADAPTER_CONNECTION_STATE_CACHE_PROPERTY) {
                /**
                 * This method must not be called when mService is null.
                 */
                @Override
                @SuppressLint("AndroidFrameworkRequiresPermission")
                public Integer recompute(Void query) {
@@ -2549,18 +2568,23 @@ public final class BluetoothAdapter {
                    }
                }
            };
     */

    /** @hide */
    /*
    @RequiresNoPermission
    public void disableGetAdapterConnectionStateCache() {
        mBluetoothGetAdapterConnectionStateCache.disableLocal();
    }
     */

    /** @hide */
    /*
    public static void invalidateGetAdapterConnectionStateCache() {
        PropertyInvalidatedCache.invalidateCache(
            BLUETOOTH_GET_ADAPTER_CONNECTION_STATE_CACHE_PROPERTY);
    }
     */

    /**
     * Get the current connection state of the local Bluetooth adapter.
@@ -2584,20 +2608,18 @@ public final class BluetoothAdapter {
        try {
            mServiceLock.readLock().lock();
            if (mService != null) {
                return mBluetoothGetAdapterConnectionStateCache.query(null);
            }
        } catch (RuntimeException e) {
            if (e.getCause() instanceof RemoteException) {
                Log.e(TAG, "getConnectionState:", e.getCause());
            } else {
                throw e;
                return mService.getAdapterConnectionState();
            }
            //return mBluetoothGetAdapterConnectionStateCache.query(null);
        } catch (RemoteException e) {
            Log.e(TAG, "failed to getConnectionState, error: ", e);
        } finally {
            mServiceLock.readLock().unlock();
        }
        return BluetoothAdapter.STATE_DISCONNECTED;
    }

    /*
    private static final String BLUETOOTH_PROFILE_CACHE_PROPERTY =
            "cache_key.bluetooth.get_profile_connection_state";
    private final PropertyInvalidatedCache<Integer, Integer>
@@ -2625,17 +2647,22 @@ public final class BluetoothAdapter {
                                         query);
                }
            };
     */

    /** @hide */
    /*
    @RequiresNoPermission
    public void disableGetProfileConnectionStateCache() {
        mGetProfileConnectionStateCache.disableLocal();
    }
     */

    /** @hide */
    /*
    public static void invalidateGetProfileConnectionStateCache() {
        PropertyInvalidatedCache.invalidateCache(BLUETOOTH_PROFILE_CACHE_PROPERTY);
    }
     */

    /**
     * Get the current connection state of a profile.
@@ -2657,7 +2684,18 @@ public final class BluetoothAdapter {
        if (getState() != STATE_ON) {
            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;
    }

    /**
+12 −11
Original line number Diff line number Diff line
@@ -23,8 +23,7 @@ import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.app.PropertyInvalidatedCache;
import android.annotation.SystemApi; //import android.app.PropertyInvalidatedCache;
import android.bluetooth.annotations.RequiresBluetoothConnectPermission;
import android.bluetooth.annotations.RequiresBluetoothLocationPermission;
import android.bluetooth.annotations.RequiresBluetoothScanPermission;
@@ -1597,6 +1596,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
        return false;
    }

    /*
    private static final String BLUETOOTH_BONDING_CACHE_PROPERTY =
            "cache_key.bluetooth.get_bond_state";
    private final PropertyInvalidatedCache<BluetoothDevice, Integer> mBluetoothBondCache =
@@ -1612,16 +1612,19 @@ public final class BluetoothDevice implements Parcelable, Attributable {
                    }
                }
            };
     */

    /** @hide */
    public void disableBluetoothGetBondStateCache() {
    /* public void disableBluetoothGetBondStateCache() {
        mBluetoothBondCache.disableLocal();
    }
    } */

    /** @hide */
    /*
    public static void invalidateBluetoothGetBondStateCache() {
        PropertyInvalidatedCache.invalidateCache(BLUETOOTH_BONDING_CACHE_PROPERTY);
    }
     */

    /**
     * Get the bond state of the remote device.
@@ -1643,13 +1646,11 @@ public final class BluetoothDevice implements Parcelable, Attributable {
            return BOND_NONE;
        }
        try {
            return mBluetoothBondCache.query(this);
        } catch (RuntimeException e) {
            if (e.getCause() instanceof RemoteException) {
                Log.e(TAG, "", e);
            } else {
                throw e;
            }
            //return mBluetoothBondCache.query(this);
            return sService.getBondState(this, mAttributionSource);
        } catch (RemoteException e) {
            Log.e(TAG, "failed to ", e);
            e.rethrowFromSystemServer();
        }
        return BOND_NONE;
    }