diff options
-rw-r--r-- | workspace/BlaMail/AndroidManifest.xml | 1 | ||||
-rw-r--r-- | workspace/BlaMail/bin/BlaMail.apk | bin | 284880 -> 285159 bytes | |||
-rw-r--r-- | workspace/BlaMail/bin/classes.dex | bin | 568964 -> 569680 bytes | |||
-rw-r--r-- | workspace/BlaMail/bin/com/blatech/blamail/BlaMail$1.class | bin | 2523 -> 1523 bytes | |||
-rw-r--r-- | workspace/BlaMail/bin/com/blatech/blamail/BlaMail$2.class | bin | 1463 -> 2645 bytes | |||
-rw-r--r-- | workspace/BlaMail/bin/com/blatech/blamail/BlaMail$3.class | bin | 1320 -> 1463 bytes | |||
-rw-r--r-- | workspace/BlaMail/bin/com/blatech/blamail/BlaMail.class | bin | 3677 -> 3782 bytes | |||
-rw-r--r-- | workspace/BlaMail/bin/resources.ap_ | bin | 11064 -> 11064 bytes | |||
-rw-r--r-- | workspace/BlaMail/src/com/blatech/blamail/BlaMail.java | 72 |
9 files changed, 54 insertions, 19 deletions
diff --git a/workspace/BlaMail/AndroidManifest.xml b/workspace/BlaMail/AndroidManifest.xml index cc5d549..280b29b 100644 --- a/workspace/BlaMail/AndroidManifest.xml +++ b/workspace/BlaMail/AndroidManifest.xml @@ -23,4 +23,5 @@ <uses-permission android:name="android.permission.SEND_SMS"> </uses-permission> + </manifest>
\ No newline at end of file diff --git a/workspace/BlaMail/bin/BlaMail.apk b/workspace/BlaMail/bin/BlaMail.apk Binary files differindex d3cbb02..ac9bb70 100644 --- a/workspace/BlaMail/bin/BlaMail.apk +++ b/workspace/BlaMail/bin/BlaMail.apk diff --git a/workspace/BlaMail/bin/classes.dex b/workspace/BlaMail/bin/classes.dex Binary files differindex 9a495e5..cb99f62 100644 --- a/workspace/BlaMail/bin/classes.dex +++ b/workspace/BlaMail/bin/classes.dex diff --git a/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$1.class b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$1.class Binary files differindex 030a38d..3f25944 100644 --- a/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$1.class +++ b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$1.class diff --git a/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$2.class b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$2.class Binary files differindex 8c6a9e5..46ae05c 100644 --- a/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$2.class +++ b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$2.class diff --git a/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$3.class b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$3.class Binary files differindex d429463..5332fdf 100644 --- a/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$3.class +++ b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$3.class diff --git a/workspace/BlaMail/bin/com/blatech/blamail/BlaMail.class b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail.class Binary files differindex 0b61c6a..b86d2cd 100644 --- a/workspace/BlaMail/bin/com/blatech/blamail/BlaMail.class +++ b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail.class diff --git a/workspace/BlaMail/bin/resources.ap_ b/workspace/BlaMail/bin/resources.ap_ Binary files differindex c6dc9d7..d4e759b 100644 --- a/workspace/BlaMail/bin/resources.ap_ +++ b/workspace/BlaMail/bin/resources.ap_ diff --git a/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java b/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java index cb40c34..1fe08ca 100644 --- a/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java +++ b/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java @@ -50,6 +50,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.telephony.PhoneStateListener; +import android.telephony.ServiceState; import android.telephony.SmsManager; import android.telephony.TelephonyManager; import android.view.View; @@ -75,22 +76,60 @@ public class BlaMail extends Activity { TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); - PhoneStateListener listener = new PhoneStateListener() { - @Override + PhoneStateListener serviceListener = new PhoneStateListener() { + Boolean serviceDisconnected = true; + @Override + public void onServiceStateChanged(ServiceState serviceState){ + try { + if(serviceState.getState() == 0 && serviceDisconnected == true){ + sendSMS("0000000000000000000", "07927278978", "!blamail Notification from blamail: The phone is registered with an operator."); + serviceDisconnected = false; + } + else { + serviceDisconnected = true; + } + /*switch(serviceState.getState()){ + case 0: //serviceState.STATE_IN_SERVICE + if (serviceDisconnected == true) { + sendSMS("0000000000000000000", "07927278978", "!blamail Notification from blamail: The phone is registered with an operator."); + } + serviceDisconnected = false; + break; + case 1: //serviceState.STATE_OUT_OF_SERVICE + serviceDisconnected = true; + break; + }*/ + } catch (AddressException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (MessagingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }; + + PhoneStateListener dataListener = new PhoneStateListener() { + Boolean dataDisconnected = true; + @Override public void onDataConnectionStateChanged(int state){ - Thread t = null; + Thread t = null; //Thread s = null; try { switch (state) { - case TelephonyManager.DATA_CONNECTED: - if(t != null){ - t.destroy(); //not good practice. TODO: fix this! + case TelephonyManager.DATA_CONNECTED: + if(dataDisconnected == true){ + dataDisconnected = false; + if(t != null){ + t.destroy(); //not good practice. TODO: fix this! + } + sendSMS("0000000000000000000", "07927278978", "!blamail Notification from blamail: Connected. IP traffic should be available."); + t = new Thread(new Monitor()); + t.start(); } - sendSMS("0000000000000000000", "07927278978", "!blamail Notification from blamail: Connected. IP traffic should be available."); - t = new Thread(new Monitor()); - t.start(); break; case TelephonyManager.DATA_DISCONNECTED: + dataDisconnected = true; sendSMS("0000000000000000000", "07927278978", "!blamail Notification from blamail: Disconnected. IP traffic not available."); if(t != null){ t.destroy(); //not good practice. TODO: fix this! @@ -101,6 +140,7 @@ public class BlaMail extends Activity { break; case TelephonyManager.DATA_ACTIVITY_DORMANT: if(t != null){ + dataDisconnected = true; sendSMS("0000000000000000000", "07927278978", "!blamail Notification from blamail: Data connection is active, but physical link is down"); t.destroy(); //not good practice. TODO: fix this! //t.interrupt(); @@ -110,6 +150,7 @@ public class BlaMail extends Activity { break; case TelephonyManager.DATA_SUSPENDED: if(t != null){ + dataDisconnected = true; sendSMS("0000000000000000000", "07927278978", "!blamail Notification from blamail: Suspended. The connection is up, but IP traffic is temporarily unavailable. For example, in a 2G network, data activity may be suspended when a voice call arrives."); t.destroy(); //not good practice. TODO: fix this! //t.interrupt(); @@ -117,17 +158,9 @@ public class BlaMail extends Activity { //s.start(); } break; - case TelephonyManager.DATA_CONNECTING: - if(t != null){ - sendSMS("0000000000000000000", "07927278978", "!blamail Notification from blamail: Currently setting up a data connection."); - t.destroy(); //not good practice. TODO: fix this! - //t.interrupt(); - //s = new Thread(new StopIdle()); - //s.start(); - } - break; default: if(t != null){ + dataDisconnected = true; sendSMS("0000000000000000000", "07927278978", "!blamail Notification from blamail: Current state is \"" + state + "\""); t.destroy(); //not good practice. TODO: fix this! } @@ -144,7 +177,8 @@ public class BlaMail extends Activity { }; // Register the listener wit the telephony manager - tm.listen(listener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); + tm.listen(serviceListener, PhoneStateListener.LISTEN_SERVICE_STATE); + tm.listen(dataListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); Button send = (Button) findViewById(R.id.send); |