-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wifi wait limit and example wifi only
- Loading branch information
nlathia
committed
Jul 30, 2015
1 parent
2a20ff9
commit 826ecb0
Showing
7 changed files
with
152 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
src/com/emotionsense/demo/data/loggers/AsyncWiFiOnlyEncryptedDatabase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package com.emotionsense.demo.data.loggers; | ||
|
||
import java.util.HashMap; | ||
|
||
import android.content.Context; | ||
|
||
import com.emotionsense.demo.data.DemoApplication; | ||
import com.ubhave.datahandler.config.DataStorageConfig; | ||
import com.ubhave.datahandler.except.DataHandlerException; | ||
import com.ubhave.datahandler.loggertypes.AbstractAsyncTransferLogger; | ||
import com.ubhave.datahandler.loggertypes.AbstractDataLogger; | ||
import com.ubhave.sensormanager.ESException; | ||
|
||
public class AsyncWiFiOnlyEncryptedDatabase extends AbstractAsyncTransferLogger | ||
{ | ||
private static AsyncWiFiOnlyEncryptedDatabase instance; | ||
|
||
public static AbstractDataLogger getInstance() throws ESException, DataHandlerException | ||
{ | ||
if (instance == null) | ||
{ | ||
instance = new AsyncWiFiOnlyEncryptedDatabase(DemoApplication.getContext()); | ||
} | ||
return instance; | ||
} | ||
|
||
protected AsyncWiFiOnlyEncryptedDatabase(final Context context) throws DataHandlerException, ESException | ||
{ | ||
super(context, DataStorageConfig.STORAGE_TYPE_DB); | ||
} | ||
|
||
@Override | ||
protected String getDataPostURL() | ||
{ | ||
return RemoteServerDetails.FILE_POST_URL; | ||
} | ||
|
||
@Override | ||
protected String getPostKey() | ||
{ | ||
return RemoteServerDetails.FILE_KEY; | ||
} | ||
|
||
@Override | ||
protected String getSuccessfulPostResponse() | ||
{ | ||
return RemoteServerDetails.RESPONSE_ON_SUCCESS; | ||
} | ||
|
||
@Override | ||
protected HashMap<String, String> getPostParameters() | ||
{ | ||
// Note: any additional parameters (e.g., API key-value) that your URL | ||
// requires | ||
HashMap<String, String> params = new HashMap<String, String>(); | ||
params.put(RemoteServerDetails.API_KEY_KEY, RemoteServerDetails.API_KEY_VALUE); | ||
return params; | ||
} | ||
|
||
@Override | ||
protected long getDataLifeMillis() | ||
{ | ||
// Note: all data that is more than 1 minute old will be transferred | ||
return 1000L * 60 * 1; | ||
} | ||
|
||
@Override | ||
protected long getTransferAlarmLengthMillis() | ||
{ | ||
// Note: transfer alarm will fire every 2 minutes | ||
return 1000L * 60 * 2; | ||
} | ||
|
||
@Override | ||
protected long getWaitForWiFiMillis() | ||
{ | ||
// Note: wait for a Wi-Fi connection | ||
return Long.MAX_VALUE; | ||
} | ||
|
||
@Override | ||
protected String getFileStorageName() | ||
{ | ||
// Unused for database storage | ||
return null; | ||
} | ||
|
||
@Override | ||
protected String getUniqueUserId() | ||
{ | ||
// Note: this should not be a static string | ||
return "test-user-id"; | ||
} | ||
|
||
@Override | ||
protected String getDeviceId() | ||
{ | ||
// Note: this should not be a static string | ||
return "test-device-id"; | ||
} | ||
|
||
@Override | ||
protected boolean shouldPrintLogMessages() | ||
{ | ||
// Note: return false to turn off Log.d messages | ||
return true; | ||
} | ||
|
||
@Override | ||
protected String getEncryptionPassword() | ||
{ | ||
// Note: return non-null password to encrypt data | ||
return "password"; | ||
} | ||
} |