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

Commit aae5d1ce authored by William Escande's avatar William Escande
Browse files

Hap: cleanup test

Split native interface between call to native and call from native in
order to mock one when using the other in test
Remove direct call on mock
Remove some bloated code in test

Test: atest BluetoothInstrumentationTests:.HapClient*Test
Bug: 311772251
Flag: TEST_ONLY
Change-Id: I3fbbbd6f6180bcc2e73a05a4a33ee85264cf1672
parent c047735f
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ static std::shared_timed_mutex interface_mutex;

static jobject mCallbacksObj = nullptr;
static std::shared_timed_mutex callbacks_mutex;
static jfieldID sCallbacksField;

static struct {
  jclass clazz;
@@ -299,7 +300,7 @@ public:

static HasClientCallbacksImpl sHasClientCallbacks;

static void initNative(JNIEnv* env, jobject object) {
static void initNative(JNIEnv* env, jobject obj) {
  std::unique_lock<std::shared_timed_mutex> interface_lock(interface_mutex);
  std::unique_lock<std::shared_timed_mutex> callbacks_lock(callbacks_mutex);

@@ -321,7 +322,7 @@ static void initNative(JNIEnv* env, jobject object) {
    mCallbacksObj = nullptr;
  }

  if ((mCallbacksObj = env->NewGlobalRef(object)) == nullptr) {
  if ((mCallbacksObj = env->NewGlobalRef(env->GetObjectField(obj, sCallbacksField))) == nullptr) {
    log::error("Failed to allocate Global Ref for Hearing Access Callbacks");
    return;
  }
@@ -581,6 +582,12 @@ int register_com_android_bluetooth_hap_client(JNIEnv* env) {
    return result;
  }

  jclass jniHapClientNativeInterfaceClass =
          env->FindClass("com/android/bluetooth/hap/HapClientNativeInterface");
  sCallbacksField = env->GetFieldID(jniHapClientNativeInterfaceClass, "mHapClientNativeCallback",
                                    "Lcom/android/bluetooth/hap/HapClientNativeCallback;");
  env->DeleteLocalRef(jniHapClientNativeInterfaceClass);

  const JNIJavaMethod javaMethods[] = {
          {"onConnectionStateChanged", "(I[B)V", &method_onConnectionStateChanged},
          {"onDeviceAvailable", "([BI)V", &method_onDeviceAvailable},
@@ -598,7 +605,7 @@ int register_com_android_bluetooth_hap_client(JNIEnv* env) {
          {"onPresetInfoError", "([BII)V", &method_onPresetInfoError},
          {"onGroupPresetInfoError", "(III)V", &method_onGroupPresetInfoError},
  };
  GET_JAVA_METHODS(env, "com/android/bluetooth/hap/HapClientNativeInterface", javaMethods);
  GET_JAVA_METHODS(env, "com/android/bluetooth/hap/HapClientNativeCallback", javaMethods);

  const JNIJavaMethod javaHapPresetMethods[] = {
          {"<init>", "(ILjava/lang/String;ZZ)V",
+179 −0
Original line number Diff line number Diff line
/*
 * Copyright 2024 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 com.android.bluetooth.hap;

import static com.android.bluetooth.hap.HapClientStackEvent.EVENT_TYPE_CONNECTION_STATE_CHANGED;
import static com.android.bluetooth.hap.HapClientStackEvent.EVENT_TYPE_DEVICE_AVAILABLE;
import static com.android.bluetooth.hap.HapClientStackEvent.EVENT_TYPE_DEVICE_FEATURES;
import static com.android.bluetooth.hap.HapClientStackEvent.EVENT_TYPE_ON_ACTIVE_PRESET_SELECTED;
import static com.android.bluetooth.hap.HapClientStackEvent.EVENT_TYPE_ON_ACTIVE_PRESET_SELECT_ERROR;
import static com.android.bluetooth.hap.HapClientStackEvent.EVENT_TYPE_ON_PRESET_INFO;
import static com.android.bluetooth.hap.HapClientStackEvent.EVENT_TYPE_ON_PRESET_INFO_ERROR;
import static com.android.bluetooth.hap.HapClientStackEvent.EVENT_TYPE_ON_PRESET_NAME_SET_ERROR;

import static java.util.Objects.requireNonNull;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHapPresetInfo;

import com.android.bluetooth.btservice.AdapterService;
import com.android.internal.annotations.VisibleForTesting;

import java.util.ArrayList;
import java.util.Arrays;

/** Hearing Access Profile Client Native Callback (from native to Java). */
public class HapClientNativeCallback {
    private static final String TAG = HapClientNativeCallback.class.getSimpleName();

    private final AdapterService mAdapterService;
    private final HapClientService mHapClientService;

    HapClientNativeCallback(AdapterService adapterService, HapClientService hapClientService) {
        mAdapterService = requireNonNull(adapterService);
        mHapClientService = requireNonNull(hapClientService);
    }

    private BluetoothDevice getDevice(byte[] address) {
        return mAdapterService.getDeviceFromByte(address);
    }

    @VisibleForTesting
    void onConnectionStateChanged(int state, byte[] address) {
        HapClientStackEvent event = new HapClientStackEvent(EVENT_TYPE_CONNECTION_STATE_CHANGED);
        event.device = getDevice(address);
        event.valueInt1 = state;

        mHapClientService.messageFromNative(event);
    }

    @VisibleForTesting
    void onDeviceAvailable(byte[] address, int features) {
        HapClientStackEvent event = new HapClientStackEvent(EVENT_TYPE_DEVICE_AVAILABLE);
        event.device = getDevice(address);
        event.valueInt1 = features;

        mHapClientService.messageFromNative(event);
    }

    @VisibleForTesting
    void onFeaturesUpdate(byte[] address, int features) {
        HapClientStackEvent event = new HapClientStackEvent(EVENT_TYPE_DEVICE_FEATURES);
        event.device = getDevice(address);
        event.valueInt1 = features;

        mHapClientService.messageFromNative(event);
    }

    @VisibleForTesting
    void onActivePresetSelected(byte[] address, int presetIndex) {
        HapClientStackEvent event = new HapClientStackEvent(EVENT_TYPE_ON_ACTIVE_PRESET_SELECTED);
        event.device = getDevice(address);
        event.valueInt1 = presetIndex;

        mHapClientService.messageFromNative(event);
    }

    @VisibleForTesting
    void onActivePresetGroupSelected(int groupId, int presetIndex) {
        HapClientStackEvent event = new HapClientStackEvent(EVENT_TYPE_ON_ACTIVE_PRESET_SELECTED);
        event.valueInt1 = presetIndex;
        event.valueInt2 = groupId;

        mHapClientService.messageFromNative(event);
    }

    @VisibleForTesting
    void onActivePresetSelectError(byte[] address, int resultCode) {
        HapClientStackEvent event =
                new HapClientStackEvent(EVENT_TYPE_ON_ACTIVE_PRESET_SELECT_ERROR);
        event.device = getDevice(address);
        event.valueInt1 = resultCode;

        mHapClientService.messageFromNative(event);
    }

    @VisibleForTesting
    void onActivePresetGroupSelectError(int groupId, int resultCode) {
        HapClientStackEvent event =
                new HapClientStackEvent(EVENT_TYPE_ON_ACTIVE_PRESET_SELECT_ERROR);
        event.valueInt1 = resultCode;
        event.valueInt2 = groupId;

        mHapClientService.messageFromNative(event);
    }

    @VisibleForTesting
    void onPresetInfo(byte[] address, int infoReason, BluetoothHapPresetInfo[] presets) {
        HapClientStackEvent event = new HapClientStackEvent(EVENT_TYPE_ON_PRESET_INFO);
        event.device = getDevice(address);
        event.valueInt2 = infoReason;
        event.valueList = new ArrayList<>(Arrays.asList(presets));

        mHapClientService.messageFromNative(event);
    }

    @VisibleForTesting
    void onGroupPresetInfo(int groupId, int infoReason, BluetoothHapPresetInfo[] presets) {
        HapClientStackEvent event = new HapClientStackEvent(EVENT_TYPE_ON_PRESET_INFO);
        event.valueInt2 = infoReason;
        event.valueInt3 = groupId;
        event.valueList = new ArrayList<>(Arrays.asList(presets));

        mHapClientService.messageFromNative(event);
    }

    @VisibleForTesting
    void onPresetNameSetError(byte[] address, int presetIndex, int resultCode) {
        HapClientStackEvent event = new HapClientStackEvent(EVENT_TYPE_ON_PRESET_NAME_SET_ERROR);
        event.device = getDevice(address);
        event.valueInt1 = resultCode;
        event.valueInt2 = presetIndex;

        mHapClientService.messageFromNative(event);
    }

    @VisibleForTesting
    void onGroupPresetNameSetError(int groupId, int presetIndex, int resultCode) {
        HapClientStackEvent event = new HapClientStackEvent(EVENT_TYPE_ON_PRESET_NAME_SET_ERROR);
        event.valueInt1 = resultCode;
        event.valueInt2 = presetIndex;
        event.valueInt3 = groupId;

        mHapClientService.messageFromNative(event);
    }

    @VisibleForTesting
    void onPresetInfoError(byte[] address, int presetIndex, int resultCode) {
        HapClientStackEvent event = new HapClientStackEvent(EVENT_TYPE_ON_PRESET_INFO_ERROR);
        event.device = getDevice(address);
        event.valueInt1 = resultCode;
        event.valueInt2 = presetIndex;

        mHapClientService.messageFromNative(event);
    }

    @VisibleForTesting
    void onGroupPresetInfoError(int groupId, int presetIndex, int resultCode) {
        HapClientStackEvent event = new HapClientStackEvent(EVENT_TYPE_ON_PRESET_INFO_ERROR);
        event.valueInt1 = resultCode;
        event.valueInt2 = presetIndex;
        event.valueInt3 = groupId;

        mHapClientService.messageFromNative(event);
    }
}
+19 −280
Original line number Diff line number Diff line
@@ -17,63 +17,32 @@

package com.android.bluetooth.hap;

import android.bluetooth.BluetoothAdapter;
import static java.util.Objects.requireNonNull;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHapPresetInfo;
import android.util.Log;

import com.android.bluetooth.Utils;
import com.android.internal.annotations.VisibleForTesting;

import java.util.ArrayList;
import java.util.Arrays;
import java.lang.annotation.Native;

/** Hearing Access Profile Client Native Interface to/from JNI. */
public class HapClientNativeInterface {
    private static final String TAG = HapClientNativeInterface.class.getSimpleName();

    private final BluetoothAdapter mAdapter;
    @Native private final HapClientNativeCallback mHapClientNativeCallback;

    public HapClientNativeInterface() {
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        if (mAdapter == null) {
            Log.wtf(TAG, "No Bluetooth Adapter Available");
        }
    public HapClientNativeInterface(HapClientNativeCallback hapClientNativeCallback) {
        mHapClientNativeCallback = requireNonNull(hapClientNativeCallback);
    }

    /**
     * Initiates HapClientService connection to a remote device.
     *
     * @param device the remote device
     * @return true on success, otherwise false.
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public boolean connectHapClient(BluetoothDevice device) {
    boolean connectHapClient(BluetoothDevice device) {
        return connectHapClientNative(getByteAddress(device));
    }

    /**
     * Disconnects HapClientService from a remote device.
     *
     * @param device the remote device
     * @return true on success, otherwise false.
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public boolean disconnectHapClient(BluetoothDevice device) {
    boolean disconnectHapClient(BluetoothDevice device) {
        return disconnectHapClientNative(getByteAddress(device));
    }

    /**
     * Gets a HapClientService device
     *
     * @param address the remote device address
     * @return Bluetooth Device.
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public BluetoothDevice getDevice(byte[] address) {
        return mAdapter.getRemoteDevice(address);
    }

    private byte[] getByteAddress(BluetoothDevice device) {
        if (device == null) {
            return Utils.getBytesFromAddress("00:00:00:00:00:00");
@@ -81,280 +50,50 @@ public class HapClientNativeInterface {
        return Utils.getBytesFromAddress(device.getAddress());
    }

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    void sendMessageToService(HapClientStackEvent event) {
        HapClientService service = HapClientService.getHapClientService();
        if (service != null) {
            service.messageFromNative(event);
        } else {
            Log.e(TAG, "Event ignored, service not available: " + event);
        }
    }

    /** Initializes the native interface. */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void init() {
    void init() {
        initNative();
    }

    /** Cleanup the native interface. */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void cleanup() {
    void cleanup() {
        cleanupNative();
    }

    /**
     * Selects the currently active preset for a HA device
     *
     * @param device is the device for which we want to set the active preset
     * @param presetIndex is an index of one of the available presets
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void selectActivePreset(BluetoothDevice device, int presetIndex) {
    void selectActivePreset(BluetoothDevice device, int presetIndex) {
        selectActivePresetNative(getByteAddress(device), presetIndex);
    }

    /**
     * Selects the currently active preset for a HA device group.
     *
     * @param groupId is the device group identifier for which want to set the active preset
     * @param presetIndex is an index of one of the available presets
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void groupSelectActivePreset(int groupId, int presetIndex) {
    void groupSelectActivePreset(int groupId, int presetIndex) {
        groupSelectActivePresetNative(groupId, presetIndex);
    }

    /**
     * Sets the next preset as a currently active preset for a HA device
     *
     * @param device is the device for which we want to set the active preset
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void nextActivePreset(BluetoothDevice device) {
    void nextActivePreset(BluetoothDevice device) {
        nextActivePresetNative(getByteAddress(device));
    }

    /**
     * Sets the next preset as a currently active preset for a HA device group
     *
     * @param groupId is the device group identifier for which want to set the active preset
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void groupNextActivePreset(int groupId) {
    void groupNextActivePreset(int groupId) {
        groupNextActivePresetNative(groupId);
    }

    /**
     * Sets the previous preset as a currently active preset for a HA device
     *
     * @param device is the device for which we want to set the active preset
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void previousActivePreset(BluetoothDevice device) {
    void previousActivePreset(BluetoothDevice device) {
        previousActivePresetNative(getByteAddress(device));
    }

    /**
     * Sets the previous preset as a currently active preset for a HA device group
     *
     * @param groupId is the device group identifier for which want to set the active preset
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void groupPreviousActivePreset(int groupId) {
    void groupPreviousActivePreset(int groupId) {
        groupPreviousActivePresetNative(groupId);
    }

    /**
     * Requests the preset name
     *
     * @param device is the device for which we want to get the preset name
     * @param presetIndex is an index of one of the available presets
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void getPresetInfo(BluetoothDevice device, int presetIndex) {
    void getPresetInfo(BluetoothDevice device, int presetIndex) {
        getPresetInfoNative(getByteAddress(device), presetIndex);
    }

    /**
     * Sets the preset name
     *
     * @param device is the device for which we want to get the preset name
     * @param presetIndex is an index of one of the available presets
     * @param name is a new name for a preset
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void setPresetName(BluetoothDevice device, int presetIndex, String name) {
    void setPresetName(BluetoothDevice device, int presetIndex, String name) {
        setPresetNameNative(getByteAddress(device), presetIndex, name);
    }

    /**
     * Sets the preset name
     *
     * @param groupId is the device group
     * @param presetIndex is an index of one of the available presets
     * @param name is a new name for a preset
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void groupSetPresetName(int groupId, int presetIndex, String name) {
    void groupSetPresetName(int groupId, int presetIndex, String name) {
        groupSetPresetNameNative(groupId, presetIndex, name);
    }

    // Callbacks from the native stack back into the Java framework.
    // All callbacks are routed via the Service which will disambiguate which
    // state machine the message should be routed to.

    @VisibleForTesting
    void onConnectionStateChanged(int state, byte[] address) {
        HapClientStackEvent event =
                new HapClientStackEvent(HapClientStackEvent.EVENT_TYPE_CONNECTION_STATE_CHANGED);
        event.device = getDevice(address);
        event.valueInt1 = state;

        Log.d(TAG, "onConnectionStateChanged: " + event);
        sendMessageToService(event);
    }

    @VisibleForTesting
    void onDeviceAvailable(byte[] address, int features) {
        HapClientStackEvent event =
                new HapClientStackEvent(HapClientStackEvent.EVENT_TYPE_DEVICE_AVAILABLE);
        event.device = getDevice(address);
        event.valueInt1 = features;

        Log.d(TAG, "onDeviceAvailable: " + event);
        sendMessageToService(event);
    }

    @VisibleForTesting
    void onFeaturesUpdate(byte[] address, int features) {
        HapClientStackEvent event =
                new HapClientStackEvent(HapClientStackEvent.EVENT_TYPE_DEVICE_FEATURES);
        event.device = getDevice(address);
        event.valueInt1 = features;

        Log.d(TAG, "onFeaturesUpdate: " + event);
        sendMessageToService(event);
    }

    @VisibleForTesting
    void onActivePresetSelected(byte[] address, int presetIndex) {
        HapClientStackEvent event =
                new HapClientStackEvent(HapClientStackEvent.EVENT_TYPE_ON_ACTIVE_PRESET_SELECTED);
        event.device = getDevice(address);
        event.valueInt1 = presetIndex;

        Log.d(TAG, "onActivePresetSelected: " + event);
        sendMessageToService(event);
    }

    @VisibleForTesting
    void onActivePresetGroupSelected(int groupId, int presetIndex) {
        HapClientStackEvent event =
                new HapClientStackEvent(HapClientStackEvent.EVENT_TYPE_ON_ACTIVE_PRESET_SELECTED);
        event.valueInt1 = presetIndex;
        event.valueInt2 = groupId;

        Log.d(TAG, "onActivePresetGroupSelected: " + event);
        sendMessageToService(event);
    }

    @VisibleForTesting
    void onActivePresetSelectError(byte[] address, int resultCode) {
        HapClientStackEvent event =
                new HapClientStackEvent(
                        HapClientStackEvent.EVENT_TYPE_ON_ACTIVE_PRESET_SELECT_ERROR);
        event.device = getDevice(address);
        event.valueInt1 = resultCode;

        Log.d(TAG, "onActivePresetSelectError: " + event);
        sendMessageToService(event);
    }

    @VisibleForTesting
    void onActivePresetGroupSelectError(int groupId, int resultCode) {
        HapClientStackEvent event =
                new HapClientStackEvent(
                        HapClientStackEvent.EVENT_TYPE_ON_ACTIVE_PRESET_SELECT_ERROR);
        event.valueInt1 = resultCode;
        event.valueInt2 = groupId;

        Log.d(TAG, "onActivePresetGroupSelectError: " + event);
        sendMessageToService(event);
    }

    @VisibleForTesting
    void onPresetInfo(byte[] address, int infoReason, BluetoothHapPresetInfo[] presets) {
        HapClientStackEvent event =
                new HapClientStackEvent(HapClientStackEvent.EVENT_TYPE_ON_PRESET_INFO);
        event.device = getDevice(address);
        event.valueInt2 = infoReason;
        event.valueList = new ArrayList<>(Arrays.asList(presets));

        Log.d(TAG, "onPresetInfo: " + event);
        sendMessageToService(event);
    }

    @VisibleForTesting
    void onGroupPresetInfo(int groupId, int infoReason, BluetoothHapPresetInfo[] presets) {
        HapClientStackEvent event =
                new HapClientStackEvent(HapClientStackEvent.EVENT_TYPE_ON_PRESET_INFO);
        event.valueInt2 = infoReason;
        event.valueInt3 = groupId;
        event.valueList = new ArrayList<>(Arrays.asList(presets));

        Log.d(TAG, "onGroupPresetInfo: " + event);
        sendMessageToService(event);
    }

    @VisibleForTesting
    void onPresetNameSetError(byte[] address, int presetIndex, int resultCode) {
        HapClientStackEvent event =
                new HapClientStackEvent(HapClientStackEvent.EVENT_TYPE_ON_PRESET_NAME_SET_ERROR);
        event.device = getDevice(address);
        event.valueInt1 = resultCode;
        event.valueInt2 = presetIndex;

        Log.d(TAG, "onPresetNameSetError: " + event);
        sendMessageToService(event);
    }

    @VisibleForTesting
    void onGroupPresetNameSetError(int groupId, int presetIndex, int resultCode) {
        HapClientStackEvent event =
                new HapClientStackEvent(HapClientStackEvent.EVENT_TYPE_ON_PRESET_NAME_SET_ERROR);
        event.valueInt1 = resultCode;
        event.valueInt2 = presetIndex;
        event.valueInt3 = groupId;

        Log.d(TAG, "onGroupPresetNameSetError: " + event);
        sendMessageToService(event);
    }

    @VisibleForTesting
    void onPresetInfoError(byte[] address, int presetIndex, int resultCode) {
        HapClientStackEvent event =
                new HapClientStackEvent(HapClientStackEvent.EVENT_TYPE_ON_PRESET_INFO_ERROR);
        event.device = getDevice(address);
        event.valueInt1 = resultCode;
        event.valueInt2 = presetIndex;

        Log.d(TAG, "onPresetInfoError: " + event);
        sendMessageToService(event);
    }

    @VisibleForTesting
    void onGroupPresetInfoError(int groupId, int presetIndex, int resultCode) {
        HapClientStackEvent event =
                new HapClientStackEvent(HapClientStackEvent.EVENT_TYPE_ON_PRESET_INFO_ERROR);
        event.valueInt1 = resultCode;
        event.valueInt2 = presetIndex;
        event.valueInt3 = groupId;

        Log.d(TAG, "onGroupPresetInfoError: " + event);
        sendMessageToService(event);
    }

    // Native methods that call into the JNI interface
    private native void initNative();

+11 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.Manifest.permission.BLUETOOTH_CONNECT;
import static android.Manifest.permission.BLUETOOTH_PRIVILEGED;

import static java.util.Objects.requireNonNull;
import static java.util.Objects.requireNonNullElse;

import android.bluetooth.BluetoothCsipSetCoordinator;
import android.bluetooth.BluetoothDevice;
@@ -113,14 +114,18 @@ public class HapClientService extends ProfileService {
    }

    public HapClientService(AdapterService adapterService) {
        this(adapterService, new HapClientNativeInterface());
        this(adapterService, null);
    }

    @VisibleForTesting
    HapClientService(AdapterService adapterService, HapClientNativeInterface nativeInterface) {
        super(adapterService);
        mAdapterService = requireNonNull(adapterService);
        mHapClientNativeInterface = requireNonNull(nativeInterface);
        mHapClientNativeInterface =
                requireNonNullElse(
                        nativeInterface,
                        new HapClientNativeInterface(
                                new HapClientNativeCallback(adapterService, this)));
        mDatabaseManager = requireNonNull(mAdapterService.getDatabase());

        // Start handler thread for state machines
@@ -796,6 +801,10 @@ public class HapClientService extends ProfileService {
    }

    void messageFromNative(HapClientStackEvent stackEvent) {
        if (!isAvailable()) {
            Log.e(TAG, "Event ignored, service not available: " + stackEvent);
            return;
        }
        // Decide which event should be sent to the state machine
        if (stackEvent.type == HapClientStackEvent.EVENT_TYPE_CONNECTION_STATE_CHANGED) {
            resendToStateMachine(stackEvent);
+228 −0

File changed and moved.

Preview size limit exceeded, changes collapsed.

Loading