Android Open Source - BluetoothHidEmu Bluetooth Adapter Spoofer Moto






From Project

Back to project page BluetoothHidEmu.

License

The source code is released under:

Apache License

If you think the Android project BluetoothHidEmu 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 andraus.bluetoothhidemu.spoof;
/* ww w  . jav  a 2s  .  c  om*/
import java.io.IOException;

import andraus.bluetoothhidemu.util.DoLog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Context;

public class BluetoothAdapterSpooferMoto extends BluetoothAdapterSpoofer {

    private int mHidSdpHandle;

    BluetoothAdapterSpooferMoto(BluetoothAdapter adapter) {
        super(null, adapter);
    }
    
    /**
     * Returns current bluetooth device class number.
     * 
     * format: 0xaabbcc, where:
     * 0xaa -> service class number
     * 0xbb -> major device number
     * 0xcc -> minor device number
     * 
     * @return
     */

    @Override
    protected int getBluetoothDeviceClass() {
       
        return mAdapter.getAdapterClass();
    }

    /**
     * Spoof the bluetooth device class number. Format of <i>deviceClass</i> follows the same pattern from method
     * <i>getBluetoothDeviceClass</i>.
     * 
     * @param deviceClass
     * @return
     */
    @Override
    protected int spoofBluetoothDeviceClass(int deviceClass) {
        mOriginalDeviceClass = getBluetoothDeviceClass();
        
        return mAdapter.spoofAdapterClass(deviceClass);
    }

    /**
     * Adds a custom SDP record to enable HID emulation over bluetooth.
     * 
     * @return
     */
    @Override
    protected int addHidDeviceSdpRecord(SpoofMode mode) {
        
        if (mHidSdpHandle != 0) {
            DoLog.w(TAG, String.format("HID SDP record already present. Handle: 0x%06X",mHidSdpHandle));
            return mHidSdpHandle;
        }
        
        mHidSdpHandle = (mode == SpoofMode.HID_GENERIC) ? mAdapter.addHidKeybSdpRecord() : mAdapter.addHidBdRemoteRecord();

        return mHidSdpHandle;
    }

    /**
     * Removes a SDP record identified by <i>handle</i>. 
     * implementation.
     * 
     */
    @Override
    protected void delHidDeviceSdpRecord() {
        if (mHidSdpHandle == 0) {
            DoLog.w(TAG, "No HID SDP record handle present.");
            return;
        }
        
        mAdapter.removeServiceRecord(mHidSdpHandle);
        
        mHidSdpHandle = 0;

    }

    @Override
    public BluetoothSocket connectL2capSocket(BluetoothDevice device, int port, 
            boolean auth, boolean encrypt) throws IOException {

        return device.createl2capSocket(port, auth, encrypt);
    }
    
    @Override
    public boolean requirementsCheck() {
        // TODO implement check for frameworks support
        return true;
    }
    
}




Java Source Code List

andraus.bluetoothhidemu.BluetoothHidEmuActivity.java
andraus.bluetoothhidemu.ButtonClickListener.java
andraus.bluetoothhidemu.Constants.java
andraus.bluetoothhidemu.KeyboardKeyListener.java
andraus.bluetoothhidemu.KeyboardTextWatcher.java
andraus.bluetoothhidemu.SpecialKeyListener.java
andraus.bluetoothhidemu.TouchpadListener.java
andraus.bluetoothhidemu.settings.BluetoothAdapterStateReceiver.java
andraus.bluetoothhidemu.settings.BluetoothDeviceStateReceiver.java
andraus.bluetoothhidemu.settings.Settings.java
andraus.bluetoothhidemu.sock.BluetoothSocketThread.java
andraus.bluetoothhidemu.sock.SocketManager.java
andraus.bluetoothhidemu.sock.payload.HidConsumerPayload.java
andraus.bluetoothhidemu.sock.payload.HidKeyPair.java
andraus.bluetoothhidemu.sock.payload.HidKeyboardPayload.java
andraus.bluetoothhidemu.sock.payload.HidPayload.java
andraus.bluetoothhidemu.sock.payload.HidPointerPayload.java
andraus.bluetoothhidemu.sock.payload.HidSixaxisPayload.java
andraus.bluetoothhidemu.spoof.BluetoothAdapterSpooferFactory.java
andraus.bluetoothhidemu.spoof.BluetoothAdapterSpooferGeneric.java
andraus.bluetoothhidemu.spoof.BluetoothAdapterSpooferMotoReflect.java
andraus.bluetoothhidemu.spoof.BluetoothAdapterSpooferMoto.java
andraus.bluetoothhidemu.spoof.BluetoothAdapterSpoofer.java
andraus.bluetoothhidemu.spoof.CleanupExceptionHandler.java
andraus.bluetoothhidemu.spoof.Spoof.java
andraus.bluetoothhidemu.spoof.jni.BluetoothSocketJni.java
andraus.bluetoothhidemu.ui.GenericUiControls.java
andraus.bluetoothhidemu.ui.Ps3KeypadUiControls.java
andraus.bluetoothhidemu.ui.UiControls.java
andraus.bluetoothhidemu.util.DoLog.java
andraus.bluetoothhidemu.view.ArrowButton.java
andraus.bluetoothhidemu.view.BluetoothDeviceArrayAdapter.java
andraus.bluetoothhidemu.view.BluetoothDeviceView.java
andraus.bluetoothhidemu.view.EchoEditText.java
andraus.bluetoothhidemu.view.ViewUtils.java