private static URI uriFromString(String path) throws DataSourceException { try { return new URI(path); } catch(java.net.URISyntaxException e) { throw new DataSourceException("Trace file path not valid", e); } }
public TraceVehicleDataSource(SourceCallback callback, Context context, URI filename, boolean loop) throws DataSourceException { super(callback, context); if(filename == null) { throw new DataSourceException( "No filename specified for the trace source"); } mFilename = filename; mLoop = loop; Log.d(TAG, "Starting new trace data source with trace file " + mFilename); new Thread(this).start(); }
private BufferedReader openRegularFile(URI filename) throws DataSourceException { FileInputStream stream; try { stream = new FileInputStream(filename.getPath()); } catch(FileNotFoundException e) { throw new DataSourceException( "Couldn't open the trace file " + filename, e); } return readerForStream(stream); }
"can't use USB vehicle interface"; Log.w(TAG, message); throw new DataSourceException(message);
public BluetoothVehicleInterface(SourceCallback callback, Context context, String address) throws DataSourceException { super(callback, context); try { mDeviceManager = new DeviceManager(getContext()); } catch (BluetoothException e) { throw new DataSourceException( "Unable to open Bluetooth device manager", e); } IntentFilter filter = new IntentFilter( BluetoothAdapter.ACTION_DISCOVERY_FINISHED); getContext().registerReceiver(mBroadcastReceiver, filter); filter = new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED); getContext().registerReceiver(mBroadcastReceiver, filter); filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED); getContext().registerReceiver(mBroadcastReceiver, filter); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); mUsePolling = preferences.getBoolean( context.getString(R.string.bluetooth_polling_key), true); Log.d(TAG, "Bluetooth device polling is " + (mUsePolling ? "enabled" : "disabled")); setAddress(address); start(); mAcceptThread = new Thread(new SocketAccepter()); mAcceptThread.start(); }