@@ -22,6 +22,8 @@ public class SosService implements SosMessageListener {
2222 private Handler handler ;
2323 private SosMessageListener listener ;
2424 private String serverURL ;
25+ private String username ;
26+ private String password ;
2527 private Context context ;
2628 private SosSensor sosSensor ;
2729 private SosIpcTransceiver transceiver ;
@@ -31,20 +33,25 @@ public class SosService implements SosMessageListener {
3133 private boolean sosHttpBroadcast ;
3234
3335 /**
34- * Creates a new SOS Service
36+ * Creates a new SosService
3537 * @param context
3638 * @param sosSensor
39+ * @param sosServerURL
40+ * @param username
41+ * @param password
3742 * @param turnOn true == the service will start running immediately; false means the service will initiate but will not start sending/receiving
3843 * @param enableIpcBroadcast
3944 */
40- public SosService (Context context , SosSensor sosSensor , String sosServerURL , final boolean turnOn , final boolean enableIpcBroadcast ) {
45+ public SosService (Context context , SosSensor sosSensor , String sosServerURL , String username , String password , final boolean turnOn , final boolean enableIpcBroadcast ) {
4146 if (context == null )
4247 Log .e (SosIpcTransceiver .TAG ,"SosService should not be passed a null context" );
4348 this .context = context ;
4449 this .sosSensor = sosSensor ;
4550 if (context instanceof SosMessageListener )
4651 listener = (SosMessageListener )context ;
4752 this .serverURL = sosServerURL ;
53+ this .username = username ;
54+ this .password = password ;
4855 sosThread = new HandlerThread ("SosService" ) {
4956 @ Override
5057 protected void onLooperPrepared () {
@@ -59,6 +66,10 @@ protected void onLooperPrepared() {
5966 SosIpcTransceiver .setChannel (DEFAULT_SWE_CHANNEL );
6067 }
6168
69+ public SosService (Context context , SosSensor sosSensor , String sosServerURL , final boolean turnOn , final boolean enableIpcBroadcast ) {
70+ this (context , sosSensor , sosServerURL , null , null , turnOn , enableIpcBroadcast );
71+ }
72+
6273 /**
6374 * Toggles between on (active/running/transmitting and receiving) and off (paused)
6475 * @param on true = on/active/transmitting and receiving
@@ -120,7 +131,7 @@ private void broadcast(AbstractSosOperation operation) {
120131 if ((serverURL != null ) && sosHttpBroadcast ) {
121132 Log .d (SosIpcTransceiver .TAG ,"Broadcasting SOS operation to " +serverURL );
122133 try {
123- String result = HttpHelper .post (serverURL ,SosIpcTransceiver .toString (operation .toXML ()));
134+ String result = HttpHelper .post (serverURL , username , password , SosIpcTransceiver .toString (operation .toXML ()));
124135 AbstractSosOperation responseOperation = AbstractSosOperation .newFromXmlString (result );
125136 if (responseOperation == null ) {
126137 Log .e (SosIpcTransceiver .TAG ,"Unable to parse response from server: " +result );
0 commit comments