Skip to content
Snippets Groups Projects
Commit 07321c47 authored by Lennart Goedhart's avatar Lennart Goedhart
Browse files

Fix #30. Well, delete the "Wi-Fi Hack" feature to fix in ;)

parent e262ed97
No related branches found
No related tags found
No related merge requests found
...@@ -196,45 +196,9 @@ public class DexcomG4Service extends Service { ...@@ -196,45 +196,9 @@ public class DexcomG4Service extends Service {
initialRead = false; initialRead = false;
nextUploadTimer = getNextUploadTimer(dexcomReader); nextUploadTimer = getNextUploadTimer(dexcomReader);
if (prefs.getBoolean("EnableWifiHack", false)) {
doWifiHack();
}
} }
} }
private void doWifiHack() {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
//Interesting case: location with lousy wifi
//toggle it off to use cellular
//toggle back on for next try
public void run() {
Status dataUp = uploader.getStatus();
if (dataUp == Status.RUNNING) {
uploader.cancel(true);
if (wifiManager.isWifiEnabled()) {
wifiManager.setWifiEnabled(false);
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
Log.e(TAG, "Sleep after setWifiEnabled(false) interrupted", e);
}
wifiManager.setWifiEnabled(true);
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
Log.e(TAG, "Sleep after setWifiEnabled(true) interrupted", e);
}
}
}
}
}, 22500);
}
private void USBOff() { private void USBOff() {
if (mSerialDevice != null) { if (mSerialDevice != null) {
try { try {
......
...@@ -200,7 +200,7 @@ public class GetHmacAndKeyActivity extends Activity implements LoaderCallbacks<C ...@@ -200,7 +200,7 @@ public class GetHmacAndKeyActivity extends Activity implements LoaderCallbacks<C
String longSerial = cursor.getString(cursor.getColumnIndex(CNLConfigContract.ConfigEntry.COLUMN_NAME_STICK_SERIAL)); String longSerial = cursor.getString(cursor.getColumnIndex(CNLConfigContract.ConfigEntry.COLUMN_NAME_STICK_SERIAL));
String key = cursor.getString(cursor.getColumnIndex(CNLConfigContract.ConfigEntry.COLUMN_NAME_KEY)); String key = cursor.getString(cursor.getColumnIndex(CNLConfigContract.ConfigEntry.COLUMN_NAME_KEY));
deviceTableHtml += String.format("<b>Serial Number:</b> %s<br/><b>Key:</b> %s<br/>", longSerial, key ); deviceTableHtml += String.format("<b>Serial Number:</b> %s %s<br/>", longSerial, key.equals("") ? "&#x2718;" : "&#x2714;" );
cursor.moveToNext(); cursor.moveToNext();
} }
......
...@@ -1182,9 +1182,6 @@ public class MedtronicCGMService extends Service implements ...@@ -1182,9 +1182,6 @@ public class MedtronicCGMService extends Service implements
params = null; params = null;
listToUpload.clear(); listToUpload.clear();
if (prefs.getBoolean("EnableWifiHack", false)) {
doWifiHack();
}
} catch (Exception e) { } catch (Exception e) {
StringBuffer sb1 = new StringBuffer(""); StringBuffer sb1 = new StringBuffer("");
sb1.append("EXCEPTION!!!!!! " + e.getMessage() + " " sb1.append("EXCEPTION!!!!!! " + e.getMessage() + " "
...@@ -1199,43 +1196,7 @@ public class MedtronicCGMService extends Service implements ...@@ -1199,43 +1196,7 @@ public class MedtronicCGMService extends Service implements
} }
}; };
private void doWifiHack() {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
// Interesting case: location with lousy wifi
// toggle it off to use cellular
// toggle back on for next try
public void run() {
Status dataUp = uploader.getStatus();
if (dataUp == Status.RUNNING) {
uploader.cancel(true);
if (wifiManager.isWifiEnabled()) {
wifiManager.setWifiEnabled(false);
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
Log.e(TAG,
"Sleep after setWifiEnabled(false) interrupted",
e);
}
wifiManager.setWifiEnabled(true);
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
Log.e(TAG,
"Sleep after setWifiEnabled(true) interrupted",
e);
}
}
}
}
}, 22500);
}
private boolean isConnected() { private boolean isConnected() {
return mSerial.isOpened(); return mSerial.isOpened();
} }
......
...@@ -144,7 +144,7 @@ public class MedtronicCNLService extends AbstractService { ...@@ -144,7 +144,7 @@ public class MedtronicCNLService extends AbstractService {
Medtronic640gActivity.pumpStatusRecord.setDeviceName( deviceName ); Medtronic640gActivity.pumpStatusRecord.setDeviceName( deviceName );
if( hmac.equals( "" ) || key.equals("") ) { if( hmac.equals( "" ) || key.equals("") ) {
send(Message.obtain(null, Medtronic640gActivity.DexcomG4ActivityHandler.MSG_ERROR, "Before you can use the Contour Next Link, you need to register it with the app. Select 'Register USB Stick' from the menu.")); send(Message.obtain(null, Medtronic640gActivity.DexcomG4ActivityHandler.MSG_ERROR, String.format( "Before you can use the Contour Next Link, you need to register it with the app. Select '%s' from the menu.", getString(R.string.register_contour_next_link))));
return; return;
} }
...@@ -197,44 +197,9 @@ public class MedtronicCNLService extends AbstractService { ...@@ -197,44 +197,9 @@ public class MedtronicCNLService extends AbstractService {
} }
mUploader.execute(pumpRecord); mUploader.execute(pumpRecord);
if (prefs.getBoolean("EnableWifiHack", false)) {
doWifiHack();
}
} }
} }
private void doWifiHack() {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
//Interesting case: location with lousy wifi
//toggle it off to use cellular
//toggle back on for next try
public void run() {
Status dataUp = mUploader.getStatus();
if (dataUp == Status.RUNNING) {
mUploader.cancel(true);
if (mWifiManager.isWifiEnabled()) {
mWifiManager.setWifiEnabled(false);
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
Log.e(TAG, "Sleep after setWifiEnabled(false) interrupted", e);
}
mWifiManager.setWifiEnabled(true);
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
Log.e(TAG, "Sleep after setWifiEnabled(true) interrupted", e);
}
}
}
}
}, 22500);
}
private boolean isOnline() { private boolean isOnline() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo(); NetworkInfo netInfo = cm.getActiveNetworkInfo();
......
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
<item <item
android:id="@+id/registerCNL" android:id="@+id/registerCNL"
android:orderInCategory="100" android:orderInCategory="100"
android:title="Register Contour Next Link"> android:title="@string/register_contour_next_link">
</item> </item>
</menu> </menu>
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<string name="eula_title">Disclaimer</string> <string name="eula_title">Disclaimer</string>
<string name="eula_accept">Accept</string> <string name="eula_accept">Accept</string>
<string name="eula_refuse">Refuse</string> <string name="eula_refuse">Refuse</string>
<string name="version">0.1.0</string> <string name="version">0.2.0</string>
<style name="ButtonText"> <style name="ButtonText">
<item name="android:layout_width">fill_parent</item> <item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
...@@ -117,4 +117,5 @@ ...@@ -117,4 +117,5 @@
<string name="preference_api_secret">API SECRET</string> <string name="preference_api_secret">API SECRET</string>
<string name="prompt_carelink_username_password">Please enter your CareLink details.\nThey will not be stored.</string> <string name="prompt_carelink_username_password">Please enter your CareLink details.\nThey will not be stored.</string>
<string name="close">Close</string> <string name="close">Close</string>
<string name="register_contour_next_link">Register Contour Next Link</string>
</resources> </resources>
...@@ -44,15 +44,6 @@ ...@@ -44,15 +44,6 @@
android:defaultValue="YOURAPISECRET" android:defaultValue="YOURAPISECRET"
android:dialogMessage="Your Nightscout API secret"> android:dialogMessage="Your Nightscout API secret">
</EditTextPreference> </EditTextPreference>
<info.nightscout.android.utils.CustomSwitchPreference
android:title="Wifi Hack"
android:key="EnableWifiHack"
android:disableDependentsState="false"
android:defaultValue="false"
android:summaryOn="Wifi will be disabled if there is a timeout (poor wifi signal/access point), this will allow mobile data to be used instead"
android:summaryOff="The uploader won't try to disable Wifi even if there is a timeout"
>
</info.nightscout.android.utils.CustomSwitchPreference>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="Disclaimer"> <PreferenceCategory android:title="Disclaimer">
<info.nightscout.android.utils.CustomSwitchPreference <info.nightscout.android.utils.CustomSwitchPreference
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment