/** * Change the active vehicle interface to a new type using its default * resource identifier. * * To disable all vehicle interfaces, pass null to this function. * * @param vehicleInterfaceType the VI type to activate or null to disable * all VIs. */ public void setVehicleInterface( Class<? extends VehicleInterface> vehicleInterfaceType) throws VehicleServiceException { setVehicleInterface(vehicleInterfaceType, null); }
private synchronized void setUsbStatus(boolean enabled) { if(enabled) { Log.i(TAG, "Enabling the USB vehicle interface"); try { getVehicleManager().setVehicleInterface( UsbVehicleInterface.class); } catch(VehicleServiceException e) { Log.e(TAG, "Unable to add USB interface"); } } } }
@Override public void onClick(View v) { switch(v.getId()){ case R.id.start_bluetooth_search_btn : startBluetoothSearch(); break; case R.id.disconnect_btn : try { mVehicleManager.setVehicleInterface(null); } catch (VehicleServiceException e) { Log.e(TAG, "Unable to disconnect vehicle interface", e); } break; } } }
private synchronized void setBluetoothStatus(boolean enabled) { if(enabled) { Log.i(TAG, "Enabling the Bluetooth vehicle interface"); String deviceAddress = getPreferenceString( R.string.bluetooth_mac_key); if(deviceAddress == null || deviceAddress.equals( getString(R.string.bluetooth_mac_automatic_option))) { deviceAddress = null; Log.d(TAG, "No Bluetooth vehicle interface selected -- " + "starting in automatic mode"); } try { getVehicleManager().setVehicleInterface( BluetoothVehicleInterface.class, deviceAddress); } catch(VehicleServiceException e) { Log.e(TAG, "Unable to start Bluetooth interface", e); } } }
public void readStoredPreferences() { String selectedVi = getPreferences().getString( getString(R.string.vehicle_interface_key), ""); if(selectedVi.equals(getString( R.string.disabled_interface_option_value))) { try { getVehicleManager().setVehicleInterface(null); } catch(VehicleServiceException e) { } } } };
private void setNetworkStatus(boolean enabled) { Log.i(TAG, "Setting network data source to " + enabled); if(enabled) { String address = getPreferenceString(R.string.network_host_key); String port = getPreferenceString(R.string.network_port_key); String combinedAddress = address + ":" + port; if(address == null || port == null || !NetworkVehicleInterface.validateResource( combinedAddress)) { String error = "Network host URI (" + combinedAddress + ") not valid -- not starting network data source"; Log.w(TAG, error); SharedPreferences.Editor editor = getPreferences().edit(); editor.putBoolean(getString(R.string.uploading_checkbox_key), false); editor.commit(); } else { try { getVehicleManager().setVehicleInterface( NetworkVehicleInterface.class, combinedAddress); } catch(VehicleServiceException e) { Log.e(TAG, "Unable to add network interface", e); } } } } }
if(enabled) { try { getVehicleManager().setVehicleInterface(null); } catch(VehicleServiceException e) { Log.e(TAG, "Unable to remove existing vehicle interface");
mVehicleManager.setVehicleInterface( BluetoothVehicleInterface.class, null);