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

Commit d6cba6bd authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

hap: Remove HAP features callback

The non-@SystemApi cannot be implemented by the app on error-prone build, but
has to be implemented in the regular build. To compile the app on both this
has to be removed.

Bug: 150670922
Tag: #feature
Test: atest CtsBluetoothTestCases:android.bluetooth.cts.BluetoothHapClientTest BluetoothInstrumentationTests
Sponsor: jpawlowski@
Change-Id: I7ee01d74726f39320f56b36895a1d80a26852014
parent 3115ab2e
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -772,17 +772,7 @@ public class HapClientService extends ProfileService {
    }

    private void notifyFeaturesAvailable(BluetoothDevice device, int features) {
        if (mCallbacks != null) {
            int n = mCallbacks.beginBroadcast();
            for (int i = 0; i < n; i++) {
                try {
                    mCallbacks.getBroadcastItem(i).onHapFeaturesAvailable(device, features);
                } catch (RemoteException e) {
                    continue;
                }
            }
            mCallbacks.finishBroadcast();
        }
        Log.d(TAG, "HAP device: " + device + ", features: " + String.format("0x%04X", features));
    }

    private void notifyActivePresetChanged(BluetoothDevice device, int presetIndex,
+0 −26
Original line number Diff line number Diff line
@@ -674,25 +674,6 @@ public class HapClientTest {
                intent.getIntExtra(BluetoothHapClient.EXTRA_HAP_FEATURES, 0x00));
    }

    /**
     * Test that native callback generates proper callback call.
     */
    @Test
    public void testStackEventOnFeaturesUpdate() {
        doReturn(new ParcelUuid[]{BluetoothUuid.HAS}).when(mAdapterService)
                .getRemoteUuids(any(BluetoothDevice.class));

        mNativeInterface.onDeviceAvailable(getByteAddress(mDevice), 0x00);
        mNativeInterface.onFeaturesUpdate(getByteAddress(mDevice), 0x03);

        try {
            verify(mCallback, after(TIMEOUT_MS).times(1)).onHapFeaturesAvailable(eq(mDevice),
                    eq(0x03));
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Test that native callback generates proper callback call.
     */
@@ -953,13 +934,6 @@ public class HapClientTest {
        evt.valueInt1 = 0x01; // features
        mService.messageFromNative(evt);

        try {
            verify(mCallback, after(TIMEOUT_MS).times(1)).onHapFeaturesAvailable(eq(device),
                    eq(evt.valueInt1));
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }

        // Inject some initial presets
        List<BluetoothHapPresetInfo> presets =
                new ArrayList<BluetoothHapPresetInfo>(Arrays.asList(
+0 −23
Original line number Diff line number Diff line
@@ -140,17 +140,6 @@ public final class BluetoothHapClient implements BluetoothProfile, AutoCloseable
                @NonNull List<BluetoothHapPresetInfo> presetInfoList,
                @Status int statusCode);

        /**
         * Invoked to inform about HA device's feature set.
         *
         * @param device remote device
         * @param hapFeatures the feature set integer with feature bits set. The inidividual bits
         * are defined by Bluetooth SIG in Hearing Access Service specification.
         *
         * @hide
         */
        void onHapFeaturesAvailable(@NonNull BluetoothDevice device, @Feature int hapFeatures);

        /**
         * Invoked to inform about the failed preset rename attempt.
         *
@@ -223,18 +212,6 @@ public final class BluetoothHapClient implements BluetoothProfile, AutoCloseable
            }
        }

        @Override
        public void onHapFeaturesAvailable(@NonNull BluetoothDevice device,
                @Feature int hapFeatures) {
            Attributable.setAttributionSource(device, mAttributionSource);
            for (Map.Entry<BluetoothHapClient.Callback, Executor> callbackExecutorEntry:
                    mCallbackExecutorMap.entrySet()) {
                BluetoothHapClient.Callback callback = callbackExecutorEntry.getKey();
                Executor executor = callbackExecutorEntry.getValue();
                executor.execute(() -> callback.onHapFeaturesAvailable(device, hapFeatures));
            }
        }

        @Override
        public void onSetPresetNameFailed(@NonNull BluetoothDevice device, int status) {
            Attributable.setAttributionSource(device, mAttributionSource);
+0 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ oneway interface IBluetoothHapClientCallback {
    void onPresetInfoChanged(in  BluetoothDevice device,
                in List<BluetoothHapPresetInfo> presetInfoList,
                in int statusCode);
    void onHapFeaturesAvailable(in BluetoothDevice device, in int hapFeatures);
    void onSetPresetNameFailed(in BluetoothDevice device, in int status);
    void onSetPresetNameForGroupFailed(in int hapGroupId, in int status);
}