Java Code Examples for com.eveningoutpost.dexdrip.UtilityModels.CollectionServiceStarter#isDexbridgeWixelorWifiandDexbridgeWixel()
The following examples show how to use
com.eveningoutpost.dexdrip.UtilityModels.CollectionServiceStarter#isDexbridgeWixelorWifiandDexbridgeWixel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DexCollectionService.java From xDrip-Experimental with GNU General Public License v3.0 | 6 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2){ stopSelf(); return START_NOT_STICKY; } if (CollectionServiceStarter.isBteWixelorWifiandBtWixel(getApplicationContext()) || CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())) { setFailoverTimer(); } else { stopSelf(); return START_NOT_STICKY; } lastdata = null; attemptConnection(); return START_STICKY; }
Example 2
Source File: DexCollectionService.java From xDrip-Experimental with GNU General Public License v3.0 | 6 votes |
public void setRetryTimer() { if (CollectionServiceStarter.isBteWixelorWifiandBtWixel(getApplicationContext()) || CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())) { long retry_in; if(CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())) { retry_in = (1000 * 25); }else { retry_in = (1000*65); } Log.d(TAG, "setRetryTimer: Restarting in: " + (retry_in / 1000) + " seconds"); Calendar calendar = Calendar.getInstance(); AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE); long wakeTime = calendar.getTimeInMillis() + retry_in; PendingIntent serviceIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { alarm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { alarm.setExact(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent); } else alarm.set(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent); } }
Example 3
Source File: DexCollectionService.java From xDrip-Experimental with GNU General Public License v3.0 | 6 votes |
public void setFailoverTimer() { if (CollectionServiceStarter.isBteWixelorWifiandBtWixel(getApplicationContext()) || CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())) { long retry_in = (1000 * 60 * 6); Log.d(TAG, "setFailoverTimer: Fallover Restarting in: " + (retry_in / (60 * 1000)) + " minutes"); Calendar calendar = Calendar.getInstance(); AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE); long wakeTime = calendar.getTimeInMillis() + retry_in; PendingIntent serviceIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { alarm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { alarm.setExact(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent); } else alarm.set(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent); } else { stopSelf(); } }
Example 4
Source File: DexCollectionService.java From xDrip-Experimental with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate() { foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), this); foregroundServiceStarter.start(); mContext = getApplicationContext(); dexCollectionService = this; prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); listenForChangeInSettings(); bgToSpeech = BgToSpeech.setupTTS(mContext); //keep reference to not being garbage collected if(CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())){ Log.i(TAG,"onCreate: resetting bridge_battery preference to 0"); prefs.edit().putInt("bridge_battery",0).apply(); } Log.i(TAG, "onCreate: STARTING SERVICE"); }
Example 5
Source File: BluetoothScan.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
@Override protected void onListItemClick(ListView l, View v, int position, long id) { Log.d(TAG, "Item Clicked"); final BluetoothDevice device = mLeDeviceListAdapter.getDevice(position); if (device == null || device.getName() == null) return; Toast.makeText(this, R.string.connecting_to_device, Toast.LENGTH_LONG).show(); ActiveBluetoothDevice btDevice = new Select().from(ActiveBluetoothDevice.class) .orderBy("_ID desc") .executeSingle(); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); prefs.edit().putString("last_connected_device_address", device.getAddress()).apply(); if (btDevice == null) { ActiveBluetoothDevice newBtDevice = new ActiveBluetoothDevice(); newBtDevice.name = device.getName(); newBtDevice.address = device.getAddress(); newBtDevice.save(); } else { btDevice.name = device.getName(); btDevice.address = device.getAddress(); btDevice.save(); } if(device.getName().toLowerCase().contains("dexcom")) { if(!CollectionServiceStarter.isBTShare(getApplicationContext())) { prefs.edit().putString("dex_collection_method", "DexcomShare").apply(); prefs.edit().putBoolean("calibration_notifications", false).apply(); } if(prefs.getString("share_key", "SM00000000").compareTo("SM00000000") == 0 || prefs.getString("share_key", "SM00000000").length() < 10) { requestSerialNumber(prefs); } else returnToHome(); } else if(device.getName().toLowerCase().contains("bridge")) { if(!CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())) prefs.edit().putString("dex_collection_method", "DexbridgeWixel").apply(); if(prefs.getString("dex_txid", "00000").compareTo("00000") == 0 || prefs.getString("dex_txid", "00000").length() < 5) { requestTransmitterId(prefs); } else returnToHome(); } else if(device.getName().toLowerCase().contains("drip")) { if (! (CollectionServiceStarter.isBteWixelorWifiandBtWixel(getApplicationContext()) ) || CollectionServiceStarter.isLimitter(getApplicationContext())) { prefs.edit().putString("dex_collection_method", "BluetoothWixel").apply(); } returnToHome(); } else if(device.getName().toLowerCase().contains("limitter")) { if (!CollectionServiceStarter.isLimitter(getApplicationContext())) { prefs.edit().putString("dex_collection_method", "LimiTTer").apply(); } returnToHome(); } else { returnToHome(); } }
Example 6
Source File: DexCollectionService.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
public void setSerialDataToTransmitterRawData(byte[] buffer, int len) { long timestamp = new Date().getTime(); if (CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())) { Log.i(TAG, "setSerialDataToTransmitterRawData: Dealing with Dexbridge packet!"); int DexSrc; int TransmitterID; String TxId; Calendar c = Calendar.getInstance(); long secondsNow = c.getTimeInMillis(); ByteBuffer tmpBuffer = ByteBuffer.allocate(len); tmpBuffer.order(ByteOrder.LITTLE_ENDIAN); tmpBuffer.put(buffer, 0, len); ByteBuffer txidMessage = ByteBuffer.allocate(6); txidMessage.order(ByteOrder.LITTLE_ENDIAN); if (buffer[0] == 0x07 && buffer[1] == -15) { //We have a Beacon packet. Get the TXID value and compare with dex_txid Log.i(TAG, "setSerialDataToTransmitterRawData: Received Beacon packet."); //DexSrc starts at Byte 2 of a Beacon packet. DexSrc = tmpBuffer.getInt(2); TxId = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("dex_txid", "00000"); TransmitterID = convertSrc(TxId); if (TxId.compareTo("00000") != 0 && Integer.compare(DexSrc, TransmitterID) != 0) { Log.w(TAG, "setSerialDataToTransmitterRawData: TXID wrong. Expected " + TransmitterID + " but got " + DexSrc); txidMessage.put(0, (byte) 0x06); txidMessage.put(1, (byte) 0x01); txidMessage.putInt(2, TransmitterID); sendBtMessage(txidMessage); } return; } if (buffer[0] == 0x11 && buffer[1] == 0x00) { //we have a data packet. Check to see if the TXID is what we are expecting. Log.i(TAG, "setSerialDataToTransmitterRawData: Received Data packet"); if (len >= 0x11) { //DexSrc starts at Byte 12 of a data packet. DexSrc = tmpBuffer.getInt(12); TxId = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("dex_txid", "00000"); TransmitterID = convertSrc(TxId); if (Integer.compare(DexSrc, TransmitterID) != 0) { Log.w(TAG, "TXID wrong. Expected " + TransmitterID + " but got " + DexSrc); txidMessage.put(0, (byte) 0x06); txidMessage.put(1, (byte) 0x01); txidMessage.putInt(2, TransmitterID); sendBtMessage(txidMessage); } PreferenceManager.getDefaultSharedPreferences(mContext).edit().putInt("bridge_battery", ByteBuffer.wrap(buffer).get(11)).apply(); //All is OK, so process it. //first, tell the wixel it is OK to sleep. Log.d(TAG, "setSerialDataToTransmitterRawData: Sending Data packet Ack, to put wixel to sleep"); ByteBuffer ackMessage = ByteBuffer.allocate(2); ackMessage.put(0, (byte) 0x02); ackMessage.put(1, (byte) 0xF0); sendBtMessage(ackMessage); //make sure we are not processing a packet we already have if (secondsNow - lastPacketTime < 60000) { Log.v(TAG, "setSerialDataToTransmitterRawData: Received Duplicate Packet. Exiting."); return; } else { lastPacketTime = secondsNow; } Log.v(TAG, "setSerialDataToTransmitterRawData: Creating TransmitterData at " + timestamp); processNewTransmitterData(TransmitterData.create(buffer, len, timestamp), timestamp); } } } else { processNewTransmitterData(TransmitterData.create(buffer, len, timestamp), timestamp); } }
Example 7
Source File: Home.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
private void updateCurrentBgInfo() { setupCharts(); final TextView notificationText = (TextView) findViewById(R.id.notices); notificationText.setText(""); notificationText.setTextColor(Color.parseColor("#FF0000")); boolean isBTWixel = CollectionServiceStarter.isBteWixelorWifiandBtWixel(getApplicationContext()); boolean isDexbridgeWixel = CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext()); isBTShare = CollectionServiceStarter.isBTShare(getApplicationContext()); isG5Share = CollectionServiceStarter.isBTG5(getApplicationContext()); boolean isWifiWixel = CollectionServiceStarter.isWifiWixel(getApplicationContext()); alreadyDisplayedBgInfoCommon = false; // reset flag boolean xDripViewer = XDripViewer.isxDripViewerMode(getApplicationContext()); if(xDripViewer) { updateCurrentBgInfoForxDripViewer(notificationText); } else if (isBTShare) { updateCurrentBgInfoForBtShare(notificationText); } else if (isBTWixel || isDexbridgeWixel) { updateCurrentBgInfoForBtBasedWixel(notificationText); } else if (isWifiWixel) { updateCurrentBgInfoForWifiWixel(notificationText); } if (isG5Share) { updateCurrentBgInfoCommon(notificationText); } if (mPreferences.getLong("alerts_disabled_until", 0) > new Date().getTime()) { notificationText.append("\n ALL ALERTS DISABLED"); } else if (mPreferences.getLong("low_alerts_disabled_until", 0) > new Date().getTime() && mPreferences.getLong("high_alerts_disabled_until", 0) > new Date().getTime()) { notificationText.append("\nLOW AND HIGH ALERTS DISABLED"); } else if (mPreferences.getLong("low_alerts_disabled_until", 0) > new Date().getTime()) { notificationText.append("\nLOW ALERTS DISABLED"); } else if (mPreferences.getLong("high_alerts_disabled_until", 0) > new Date().getTime()) { notificationText.append("\nHIGH ALERTS DISABLED"); } if(mPreferences.getBoolean("extra_status_line", false)) { extraStatusLineText.setText(extraStatusLine(mPreferences)); extraStatusLineText.setVisibility(View.VISIBLE); } else { extraStatusLineText.setText(""); extraStatusLineText.setVisibility(View.GONE); } NavigationDrawerFragment navigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.navigation_drawer); navigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), menu_name, this); }
Example 8
Source File: Home.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
private void displayCurrentInfo() { DecimalFormat df = new DecimalFormat("#"); df.setMaximumFractionDigits(0); boolean isDexbridge = CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext()); boolean displayBattery = mPreferences.getBoolean("display_bridge_battery",false); int bridgeBattery = mPreferences.getInt("bridge_battery", 0); if (isDexbridge && displayBattery) { if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) { this.dexbridgeBattery.setTextSize(25); } else if(BgGraphBuilder.isLargeTablet(getApplicationContext())) { this.dexbridgeBattery.setTextSize(18); } if (bridgeBattery == 0) { dexbridgeBattery.setText("xBridge Battery: Unknown, Waiting for packet"); dexbridgeBattery.setTextColor(Color.WHITE); } else { dexbridgeBattery.setText("xBridge Battery: " + bridgeBattery + "%"); } dexbridgeBattery.setTextColor(Color.parseColor("#00FF00")); if (bridgeBattery < 50 && bridgeBattery >30) dexbridgeBattery.setTextColor(Color.YELLOW); if (bridgeBattery <= 30) dexbridgeBattery.setTextColor(Color.RED); dexbridgeBattery.setVisibility(View.VISIBLE); } else { dexbridgeBattery.setText(""); dexbridgeBattery.setVisibility(View.INVISIBLE); } if ((currentBgValueText.getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) > 0) { currentBgValueText.setPaintFlags(currentBgValueText.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG)); dexbridgeBattery.setPaintFlags(dexbridgeBattery.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG)); } BgReading lastBgReading = BgReading.lastNoSenssor(); boolean predictive = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("predictive_bg", false); if (isBTShare) { predictive = false; } if (lastBgReading != null) { displayCurrentInfoFromReading(lastBgReading, predictive); } }
Example 9
Source File: NavDrawerBuilder.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
public NavDrawerBuilder(Context aContext) { context = aContext; boolean xDripViewer = XDripViewer.isxDripViewerMode(aContext); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean IUnderstand = prefs.getBoolean("I_understand", false); if (IUnderstand == false) { this.nav_drawer_options.add("Settings"); this.nav_drawer_intents.add(new Intent(context, Preferences.class)); return; } this.nav_drawer_options.add(Home.menu_name); this.nav_drawer_intents.add(new Intent(context, Home.class)); if (is_active_sensor) { this.nav_drawer_options.add("Calibration Graph"); this.nav_drawer_intents.add(new Intent(context, CalibrationGraph.class)); } if (prefs.getBoolean("show_data_tables", false)) { this.nav_drawer_options.add("BG Data Table"); this.nav_drawer_intents.add(new Intent(context, BgReadingTable.class)); this.nav_drawer_options.add("Calibration Data Table"); this.nav_drawer_intents.add(new Intent(context, CalibrationDataTable.class)); } if(!xDripViewer) { if(is_active_sensor) { if(!CollectionServiceStarter.isBTShare(context)) { if (last_two_bgReadings.size() > 1) { if (last_two_calibrations.size() > 1) { if (bGreadings_in_last_30_mins.size() >= 2) { if (time_now - last_two_calibrations.get(0).timestamp < (1000 * 60 * 60)) { //Put steps in place to discourage over calibration this.nav_drawer_options.add(CalibrationOverride.menu_name); this.nav_drawer_intents.add(new Intent(context, CalibrationOverride.class)); } else { this.nav_drawer_options.add(AddCalibration.menu_name); this.nav_drawer_intents.add(new Intent(context, AddCalibration.class)); } } else { this.nav_drawer_options.add("Cannot Calibrate right now"); this.nav_drawer_intents.add(new Intent(context, Home.class)); } } else { this.nav_drawer_options.add(DoubleCalibrationActivity.menu_name); this.nav_drawer_intents.add(new Intent(context, DoubleCalibrationActivity.class)); } } } this.nav_drawer_options.add(StopSensor.menu_name); this.nav_drawer_intents.add(new Intent(context, StopSensor.class)); } else { this.nav_drawer_options.add(StartNewSensor.menu_name); this.nav_drawer_intents.add(new Intent(context, StartNewSensor.class)); } } if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { if(CollectionServiceStarter.isBteWixelorWifiandBtWixel(context) || CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(context)|| CollectionServiceStarter.isBTShare(context) ) { this.nav_drawer_options.add(BluetoothScan.menu_name); this.nav_drawer_intents.add(new Intent(context, BluetoothScan.class)); } } if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { this.nav_drawer_options.add(SystemStatus.menu_name); this.nav_drawer_intents.add(new Intent(context, SystemStatus.class)); } boolean bg_alerts = prefs.getBoolean("bg_alerts_from_main_menu", false); if (bg_alerts) { this.nav_drawer_options.add(AlertList.menu_name); this.nav_drawer_intents.add(new Intent(context, AlertList.class)); } this.nav_drawer_options.add(SnoozeActivity.menu_name); this.nav_drawer_intents.add(new Intent(context, SnoozeActivity.class)); this.nav_drawer_options.add(StatsActivity.MENU_NAME); this.nav_drawer_intents.add(new Intent(context, StatsActivity.class)); this.nav_drawer_options.add(BGHistory.menu_name); this.nav_drawer_intents.add(new Intent(context, BGHistory.class)); this.nav_drawer_options.add("Settings"); this.nav_drawer_intents.add(new Intent(context, Preferences.class)); }