All pastes #908934 Raw Edit

Untitled

public text v1 · immutable
·published 2008-02-18 20:36 UTC
rendered paste body
public static Device createDevice(String address, String alias) {
        Logger.debug("address is " + address);
        Device dev = null;
        
        final int Location_Jsr179 = 2;
        final int Location_Mock = 1;
        final int Location_Bluetooth = 0;
        
        int locationProvider = 0;
        
        if (GpsUtilities.checkJsr179IsPresent()) {
            Logger.debug("dbg0");
            if ("internal".equals(address)) {
                Logger.debug("dbg1");
            // Jsr179Device requires permission, which it might not get.
            // In that event we need to abort this creation process so a new
            // device can be selected.
            // Create an internal (non bluetooth) gps device
                if (Controller.getController().getUseJsr179()) {
                    Logger.debug("dbg2");
                    locationProvider = Location_Jsr179;
                }
            }
            
        }
        else if ("Mock".equals(address)) {
            Logger.debug("dbg3");
            locationProvider = Location_Mock;
        } else {
            Logger.debug("dbg4");
            locationProvider = Location_Bluetooth;
        }

        locationProvider = 0;
        
        switch(locationProvider) {
            case Location_Jsr179:
                Logger.debug("Using JSR179: " + address);
                dev = new Jsr179Device(address, alias);
                break;
            case Location_Mock:
                Logger.debug("Using mock: " + address);
                dev = new MockGpsDevice(address, alias);
                break;
            case Location_Bluetooth:
            default:
                Logger.debug("Using default/bluetooth: " + address);
                dev = new BluetoothGPSDeviceImpl(address, alias);
                break;
        }
        
        return dev;
    }