Android Open Source - LeBlue Intercepting Le Remote Device






From Project

Back to project page LeBlue.

License

The source code is released under:

Apache License

If you think the Android project LeBlue listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package houtbecke.rs.le.interceptor;
//from ww w.  j  a  va2  s  . c o m
import java.util.UUID;

import houtbecke.rs.le.LeCharacteristicListener;
import houtbecke.rs.le.LeRemoteDevice;
import houtbecke.rs.le.LeRemoteDeviceListener;

public class InterceptingLeRemoteDevice extends BaseIntercepting implements LeRemoteDevice {

    public final LeRemoteDevice leRemoteDevice;

    public InterceptingLeRemoteDevice(LeRemoteDevice leRemoteDevice, LeInterceptor leInterceptor) {
        super(leInterceptor);
        this.leRemoteDevice = leRemoteDevice;
    }
    @Override
    public void addListener(LeRemoteDeviceListener listener) {
        synchronized(leInterceptor) {
            InterceptingLeRemoteDeviceListener iListener = new InterceptingLeRemoteDeviceListener(listener, leInterceptor);
            leInterceptor.remoteListenerAdded(this, iListener);
            leRemoteDevice.addListener(iListener);
        }
    }

    @Override
    public void removeListener(LeRemoteDeviceListener listener) {
        synchronized(leInterceptor) {
            InterceptingLeRemoteDeviceListener iListener = new InterceptingLeRemoteDeviceListener(listener, leInterceptor);
            leInterceptor.remoteListenerRemoved(this, iListener);
            leRemoteDevice.removeListener(iListener);
        }
    }

    @Override
    public String getAddress() {
        synchronized(leInterceptor) {
            String address = leRemoteDevice.getAddress();
            leInterceptor.gotAddress(this, address);
            return address;
        }
    }

    @Override
    public void connect() {
        synchronized(leInterceptor) {
            leInterceptor.connecting(this);
            leRemoteDevice.connect();
        }
    }

    @Override
    public void disconnect() {
        synchronized(leInterceptor) {
            leInterceptor.disconnecting(this);
            leRemoteDevice.disconnect();
        }
    }

    @Override
    public void close() {
        synchronized(leInterceptor) {
            leInterceptor.closing(this);
            leRemoteDevice.close();
        }
    }

    @Override
    public void startServicesDiscovery() {
        synchronized(leInterceptor) {
            leInterceptor.serviceDiscoveryStarted(this);
            leRemoteDevice.startServicesDiscovery();
        }
    }

    @Override
    public void setCharacteristicListener(LeCharacteristicListener listener, UUID... uuids) {
        synchronized(leInterceptor) {
            InterceptingLeCharacteristicListener iCharacteristicsListener = leInterceptor.getInterceptingCharacteristicsListener(listener);
            leInterceptor.characteristicListenerSet(this, iCharacteristicsListener, uuids);
            leRemoteDevice.setCharacteristicListener(iCharacteristicsListener, uuids);
        }
    }

    @Override
    public String getName() {
        synchronized(leInterceptor) {
            String name = leRemoteDevice.getName();
            leInterceptor.gotRemoteDeviceName(this, name);
            return name;
        }
    }

    @Override
    public void readRssi() {
        synchronized(leInterceptor) {
            leInterceptor.readRssi(this);
            leRemoteDevice.readRssi();
        }
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof InterceptingLeRemoteDevice)
            return leRemoteDevice.equals(((InterceptingLeRemoteDevice)o).leRemoteDevice);

        return leRemoteDevice.equals(o);
    }

    @Override
    public int hashCode() {
        return leRemoteDevice.hashCode();
    }

    @Override
    public String toString() {
        return "InterceptingLeRemoteDevice{" +
                "leRemoteDevice=" + leRemoteDevice +
                '}';
    }
}




Java Source Code List

houtbecke.rs.le.BleException.java
houtbecke.rs.le.LeCharacteristicListener.java
houtbecke.rs.le.LeDefinedUUIDs.java
houtbecke.rs.le.LeDeviceListener.java
houtbecke.rs.le.LeDeviceState.java
houtbecke.rs.le.LeDevice.java
houtbecke.rs.le.LeFormat.java
houtbecke.rs.le.LeGattCharacteristic.java
houtbecke.rs.le.LeGattDescriptorValue.java
houtbecke.rs.le.LeGattDescriptor.java
houtbecke.rs.le.LeGattService.java
houtbecke.rs.le.LeGattStatus.java
houtbecke.rs.le.LeRecord.java
houtbecke.rs.le.LeRemoteDeviceListener.java
houtbecke.rs.le.LeRemoteDevice.java
houtbecke.rs.le.LeScanRecordImpl.java
houtbecke.rs.le.LeScanRecord.java
houtbecke.rs.le.LeUtil.java
houtbecke.rs.le.dummy.DummyLeRemoteDevice.java
houtbecke.rs.le.example.MainActivity.java
houtbecke.rs.le.fourdotthree.LeDevice43.java
houtbecke.rs.le.fourdotthree.LeGattCharacteristic43.java
houtbecke.rs.le.fourdotthree.LeGattService43.java
houtbecke.rs.le.fourdotthree.LeRemoteDevice43.java
houtbecke.rs.le.interceptor.AndroidEventSinkUtil.java
houtbecke.rs.le.interceptor.BaseIntercepting.java
houtbecke.rs.le.interceptor.EventSinkUtil.java
houtbecke.rs.le.interceptor.InterceptingLeCharacteristicListener.java
houtbecke.rs.le.interceptor.InterceptingLeDeviceListener.java
houtbecke.rs.le.interceptor.InterceptingLeDevice.java
houtbecke.rs.le.interceptor.InterceptingLeGattCharacteristic.java
houtbecke.rs.le.interceptor.InterceptingLeGattService.java
houtbecke.rs.le.interceptor.InterceptingLeRemoteDeviceListener.java
houtbecke.rs.le.interceptor.InterceptingLeRemoteDevice.java
houtbecke.rs.le.interceptor.LeInterceptor.java
houtbecke.rs.le.interceptor.LeLogCatInterceptor.java
houtbecke.rs.le.interceptor.LeSessionInterceptor.java
houtbecke.rs.le.mock.LeDeviceMock.java
houtbecke.rs.le.mock.LeGattCharacteristicMock.java
houtbecke.rs.le.mock.LeGattServiceMock.java
houtbecke.rs.le.mock.LeMockController.java
houtbecke.rs.le.mock.LeRemoteDeviceMock.java
houtbecke.rs.le.mock.LeSessionController.java
houtbecke.rs.le.mock.NativeWaitNotify.java
houtbecke.rs.le.mock.SimpleWaitNotify.java
houtbecke.rs.le.mock.WaitNotify.java
houtbecke.rs.le.session.CharacteristicsMockerObject.java
houtbecke.rs.le.session.DeviceMockerObject.java
houtbecke.rs.le.session.EventSinkFiller.java
houtbecke.rs.le.session.EventSink.java
houtbecke.rs.le.session.EventSource.java
houtbecke.rs.le.session.EventType.java
houtbecke.rs.le.session.Event.java
houtbecke.rs.le.session.GattServiceMockerObject.java
houtbecke.rs.le.session.ListEventSinkSource.java
houtbecke.rs.le.session.MockedResponseObject.java
houtbecke.rs.le.session.MockedResponse.java
houtbecke.rs.le.session.MockerObject.java
houtbecke.rs.le.session.Mocker.java
houtbecke.rs.le.session.RemoteDeviceMockerObject.java
houtbecke.rs.le.session.SessionObject.java
houtbecke.rs.le.session.Session.java