2013-04-25 Mark Holland <mark@mark-holland.me.uk>
* src/pandroid/agent/Core.java: Separate load and store methods for SharedPreferences and database. * src/pandroid/agent/PandroidAgent.java: Values retrieved from database onCreate. onPause and onDestroy values are saved to database. * src/pandroid/agent/PandroidAgentListener.java: Reverted to using SharedPreferences at runtime, database used when app not in view. Added module as proof of iso-8859-1 now working. * Pandroid Agent v3.0_iso-8859-1.apk: For testing whether configuration is no longer lost after an amount of time. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8062 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
89d7e883bd
commit
b378efc27e
|
@ -1,3 +1,19 @@
|
||||||
|
2013-04-25 Mark Holland <mark@mark-holland.me.uk>
|
||||||
|
|
||||||
|
* src/pandroid/agent/Core.java: Separate load and store
|
||||||
|
methods for SharedPreferences and database.
|
||||||
|
|
||||||
|
* src/pandroid/agent/PandroidAgent.java: Values retrieved from
|
||||||
|
database onCreate. onPause and onDestroy values are saved to
|
||||||
|
database.
|
||||||
|
|
||||||
|
* src/pandroid/agent/PandroidAgentListener.java: Reverted to using
|
||||||
|
SharedPreferences at runtime, database used when app not in view.
|
||||||
|
Added module as proof of iso-8859-1 now working.
|
||||||
|
|
||||||
|
* Pandroid Agent v3.0_iso-8859-1.apk: For testing whether
|
||||||
|
configuration is no longer lost after an amount of time.
|
||||||
|
|
||||||
2013-04-25 Mark Holland <mark@mark-holland.me.uk>
|
2013-04-25 Mark Holland <mark@mark-holland.me.uk>
|
||||||
|
|
||||||
* src/pandroid/agent/Core.java: Changed get and update
|
* src/pandroid/agent/Core.java: Changed get and update
|
||||||
|
|
Binary file not shown.
|
@ -14,10 +14,14 @@
|
||||||
|
|
||||||
package pandroid.agent;
|
package pandroid.agent;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
//import android.util.Log;
|
||||||
|
|
||||||
public class Core {
|
public class Core {
|
||||||
|
|
||||||
|
@ -177,7 +181,7 @@ public class Core {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void startAgentListener(Context context) {
|
static synchronized public void startAgentListener(Context context) {
|
||||||
if (con == null) {
|
if (con == null) {
|
||||||
con = context;
|
con = context;
|
||||||
}
|
}
|
||||||
|
@ -193,98 +197,102 @@ public class Core {
|
||||||
|
|
||||||
}// end startAgentListener
|
}// end startAgentListener
|
||||||
|
|
||||||
static public void stopAgentListener() {
|
static synchronized public void stopAgentListener() {
|
||||||
if (am != null){
|
if (am != null){
|
||||||
am.cancel(sender);
|
am.cancel(sender);
|
||||||
alarmEnabled = false;
|
alarmEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void restartAgentListener(Context context) {
|
static synchronized public void restartAgentListener(Context context) {
|
||||||
stopAgentListener();
|
stopAgentListener();
|
||||||
startAgentListener(context);
|
startAgentListener(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void loadLastValues(Context context) {
|
static synchronized public void loadLastValues(Context context) {
|
||||||
if (con == null) {
|
if (con == null) {
|
||||||
con = context;
|
con = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SharedPreferences agentPreferences = con.getSharedPreferences(
|
||||||
|
con.getString(R.string.const_string_preferences),
|
||||||
|
Activity.MODE_PRIVATE);
|
||||||
|
|
||||||
latitude = Float.parseFloat(getValue(con, "latitude"));
|
latitude = agentPreferences.getFloat("latitude", CONST_INVALID_COORDS);
|
||||||
longitude = Float.parseFloat(getValue(con, "longitude"));
|
longitude = agentPreferences.getFloat("longitude", CONST_INVALID_COORDS);
|
||||||
batteryLevel = Integer.parseInt(getValue(con, "batteryLevel"));
|
batteryLevel = agentPreferences.getInt("batteryLevel", CONST_INVALID_BATTERY_LEVEL);
|
||||||
orientation = Float.parseFloat(getValue(con, "orientation"));
|
orientation = agentPreferences.getFloat("orientation", CONST_INVALID_ORIENTATION);
|
||||||
proximity = Float.parseFloat(getValue(con, "proximity"));
|
proximity = agentPreferences.getFloat("proximity", CONST_INVALID_PROXIMITY);
|
||||||
taskStatus = getValue(con, "taskStatus");
|
taskStatus = agentPreferences.getString("taskStatus", defaultTaskStatus);
|
||||||
task = getValue(con, "task");
|
task = agentPreferences.getString("task", defaultTask);
|
||||||
taskHumanName = getValue(con, "taskHumanName");
|
taskHumanName = agentPreferences.getString("taskHumanName", defaultTaskHumanName);
|
||||||
taskRun = getValue(con, "taskRun");
|
taskRun = agentPreferences.getString("taskRun", defaultTaskRun);
|
||||||
memoryStatus = getValue(con, "memoryStatus");
|
memoryStatus = agentPreferences.getString("memoryStatus", defaultMemoryStatus);
|
||||||
availableRamKb = Long.parseLong(getValue(con, "availableRamKb"));
|
availableRamKb = agentPreferences.getLong("availableRamKb", defaultRam);
|
||||||
totalRamKb = Long.parseLong(getValue(con, "totalRamKb"));
|
totalRamKb = agentPreferences.getLong("totalRamKb", defaultRam);
|
||||||
lastContact = Long.parseLong(getValue(con, "lastContact"));
|
lastContact = agentPreferences.getLong("lastContact", defaultContact);
|
||||||
contactError = Integer.parseInt(getValue(con, "contactError"));
|
contactError = agentPreferences.getInt("contactError", defaultContactError);
|
||||||
simID = getValue(con, "simID");
|
simID = agentPreferences.getString("simID", defaultSimID);
|
||||||
upTime = Long.parseLong(getValue(con, "upTime"));
|
upTime = agentPreferences.getLong("upTime", Core.defaultUpTime);
|
||||||
SMSReceived = Integer.parseInt(getValue(con, "SMSReceived"));
|
SMSReceived = agentPreferences.getInt("SMSReceived", defaultSMSReceived);
|
||||||
SMSSent = Integer.parseInt(getValue(con, "SMSSent"));
|
SMSSent = agentPreferences.getInt("SMSSent", defaultSMSSent);
|
||||||
networkOperator = getValue(con, "networkOperator");
|
networkOperator = agentPreferences.getString("networkOperator", defaultNetworkOperator);
|
||||||
networkType = getValue(con, "networkType");
|
networkType = agentPreferences.getString("networkType", defaultNetworkType);
|
||||||
phoneType = getValue(con, "phoneType");
|
phoneType = agentPreferences.getString("phoneType", defaultPhoneType);
|
||||||
signalStrength = Integer.parseInt(getValue(con, "signalStrength"));
|
signalStrength = agentPreferences.getInt("signalStrength", defaultSignalStrength);
|
||||||
incomingCalls = Integer.parseInt(getValue(con, "incomingCalls"));
|
incomingCalls = agentPreferences.getInt("incomingCalls", defaultIncomingCalls);
|
||||||
missedCalls = Integer.parseInt(getValue(con, "missedCalls"));
|
missedCalls = agentPreferences.getInt("missedCalls", defaultMissedCalls);
|
||||||
outgoingCalls = Integer.parseInt(getValue(con, "outgoingCalls"));
|
outgoingCalls = agentPreferences.getInt("outgoingCalls", defaultOutgoingCalls);
|
||||||
receiveBytes = Long.parseLong(getValue(con, "receiveBytes"));
|
receiveBytes = agentPreferences.getLong("receiveBytes", defaultReceiveBytes);
|
||||||
transmitBytes = Long.parseLong(getValue(con, "transmitBytes"));
|
transmitBytes = agentPreferences.getLong("transmitBytes", defaultTransmitBytes);
|
||||||
helloSignal = Integer.parseInt(getValue(con, "helloSignal"));
|
helloSignal = agentPreferences.getInt("helloSignal", defaultHelloSignal);
|
||||||
roaming = Integer.parseInt(getValue(con, "roaming"));
|
roaming = agentPreferences.getInt("roaming", defaultRoaming);
|
||||||
|
|
||||||
}// end loadLastValues
|
}// end loadLastValues
|
||||||
|
|
||||||
static public void loadConf(Context context) {
|
static synchronized public void loadConf(Context context) {
|
||||||
if (con == null) {
|
if (con == null) {
|
||||||
con = context;
|
con = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SharedPreferences agentPreferences = con.getSharedPreferences(
|
||||||
serverAddr = getValue(con, "serverAddr");
|
con.getString(R.string.const_string_preferences),
|
||||||
serverPort = getValue(con, "serverPort");
|
Activity.MODE_PRIVATE);
|
||||||
interval = Integer.parseInt(getValue(con, "interval"));
|
|
||||||
agentName = getValue(con, "agentName");
|
serverAddr = agentPreferences.getString("serverAddr", defaultServerAddr);
|
||||||
mobileWebURL = getValue(con, "mobileWebURL");
|
serverPort = agentPreferences.getString("serverPort", defaultServerPort);
|
||||||
gpsStatus = getValue(con, "gpsStatus");
|
interval = agentPreferences.getInt("interval", defaultInterval);
|
||||||
memoryStatus = getValue(con, "memoryStatus");
|
agentName = agentPreferences.getString("agentName", defaultAgentName+"_"+Installation.id(context));
|
||||||
taskStatus = getValue(con, "taskStatus");
|
mobileWebURL = agentPreferences.getString("mobileWebURL", defaultmobileWebURL);
|
||||||
task = getValue(con, "task");
|
gpsStatus = agentPreferences.getString("gpsStatus", defaultGpsStatus);
|
||||||
taskHumanName = getValue(con, "taskHumanName");
|
memoryStatus = agentPreferences.getString("memoryStatus", defaultMemoryStatus);
|
||||||
taskRun = getValue(con, "taskRun");
|
taskStatus = agentPreferences.getString("taskStatus", defaultTaskStatus);
|
||||||
password = getValue(con, "password");
|
task = agentPreferences.getString("task", defaultTask);
|
||||||
passwordCheck = getValue(con, "passwordCheck");
|
taskHumanName = agentPreferences.getString("taskHumanName", defaultTaskHumanName);
|
||||||
simIDReport = getValue(con, "simIDReport");
|
taskRun = agentPreferences.getString("taskRun", defaultTaskRun);
|
||||||
DeviceUpTimeReport = getValue(con, "DeviceUpTimeReport");
|
password = agentPreferences.getString("password", defaultPassword);
|
||||||
NetworkOperatorReport = getValue(con, "NetworkOperatorReport");
|
passwordCheck = agentPreferences.getString("passwordCheck", defaultPasswordCheck);
|
||||||
NetworkTypeReport = getValue(con, "NetworkTypeReport");
|
simIDReport = agentPreferences.getString("simIDReport", defaultSimIDReport);
|
||||||
PhoneTypeReport = getValue(con, "PhoneTypeReport");
|
DeviceUpTimeReport = agentPreferences.getString("DeviceUpTimeReport", defaultDeviceUpTimeReport);
|
||||||
SignalStrengthReport = getValue(con, "SignalStrengthReport");
|
NetworkOperatorReport = agentPreferences.getString("NetworkOperatorReport", defaultNetworkOperatorReport);
|
||||||
ReceivedSMSReport = getValue(con, "ReceivedSMSReport");
|
NetworkTypeReport = agentPreferences.getString("NetworkTypeReport", defaultNetworkTypeReport);
|
||||||
SentSMSReport = getValue(con, "SentSMSReport");
|
PhoneTypeReport = agentPreferences.getString("PhoneTypeReport", defaultPhoneTypeReport);
|
||||||
IncomingCallsReport = getValue(con, "IncomingCallsReport");
|
SignalStrengthReport = agentPreferences.getString("SignalStrengthReport", defaultSignalStrengthReport);
|
||||||
MissedCallsReport = getValue(con, "MissedCallsReport");
|
ReceivedSMSReport = agentPreferences.getString("ReceivedSMSReport", defaultReceivedSMSReport);
|
||||||
OutgoingCallsReport = getValue(con, "OutgoingCallsReport");
|
SentSMSReport = agentPreferences.getString("SentSMSReport", defaultSentSMSReport);
|
||||||
BytesReceivedReport = getValue(con, "BytesReceivedReport");
|
IncomingCallsReport = agentPreferences.getString("IncomingCallsReport", defaultIncomingCallsReport);
|
||||||
BytesSentReport = getValue(con, "BytesSentReport");
|
MissedCallsReport = agentPreferences.getString("MissedCallsReport", defaultMissedCallsReport);
|
||||||
HelloSignalReport = getValue(con, "HelloSignalReport");
|
OutgoingCallsReport = agentPreferences.getString("OutgoingCallsReport", defaultOutgoingCallsReport);
|
||||||
BatteryLevelReport = getValue(con, "BatteryLevelReport");
|
BytesReceivedReport = agentPreferences.getString("BytesReceivedReport", defaultBytesReceivedReport);
|
||||||
RoamingReport = getValue(con, "RoamingReport");
|
BytesSentReport = agentPreferences.getString("BytesSentReport", defaultBytesSentReport);
|
||||||
InventoryReport = getValue(con, "InventoryReport");
|
HelloSignalReport = agentPreferences.getString("HelloSignalReport", defaultHelloSignalReport);
|
||||||
NotificationCheck = getValue(con, "NotificationCheck");
|
BatteryLevelReport = agentPreferences.getString("BatteryLevelReport", defaultBatteryLevelReport);
|
||||||
|
RoamingReport = agentPreferences.getString("RoamingReport", defaultRoamingReport);
|
||||||
|
InventoryReport = agentPreferences.getString("InventoryReport", defaultInventoryReport);
|
||||||
|
NotificationCheck = agentPreferences.getString("NotificationCheck", defaultNotificationCheck);
|
||||||
}// end loadConf
|
}// end loadConf
|
||||||
|
|
||||||
static public boolean updateConf(Context context) {
|
static synchronized public boolean updateConf(Context context) {
|
||||||
return updateConf(context, serverAddr, serverPort, interval, agentName,
|
return updateConf(context, serverAddr, serverPort, interval, agentName,
|
||||||
gpsStatus, memoryStatus, taskStatus, task, taskHumanName, simID, simIDReport, upTime,
|
gpsStatus, memoryStatus, taskStatus, task, taskHumanName, simID, simIDReport, upTime,
|
||||||
networkOperator, SMSReceived, SMSSent, networkType, phoneType, signalStrength,
|
networkOperator, SMSReceived, SMSSent, networkType, phoneType, signalStrength,
|
||||||
|
@ -297,7 +305,175 @@ public class Core {
|
||||||
|
|
||||||
}// end updateConf
|
}// end updateConf
|
||||||
|
|
||||||
static public boolean updateConf(Context context, String _serverAddr,
|
static synchronized public boolean updateConf(Context context, String _serverAddr,
|
||||||
|
String _serverPort, int _interval, String _agentName, String _gpsStatus,
|
||||||
|
String _memoryStatus, String _taskStatus, String _task,
|
||||||
|
String _taskHumanName, String _simID, String _simIDReport, long _upTime, String _networkOperator,
|
||||||
|
int _smsReceived, int _smsSent, String _networkType, String _phoneType, int _signalStrength,
|
||||||
|
int _incomingCalls, int _missedCalls, int _outgoingCalls, long _receiveBytes, long _transmitBytes,
|
||||||
|
String _password, int _helloSignal, String _passwordCheck, String _DeviceUpTimeReport, String _NetworkOperatorReport,
|
||||||
|
String _NetworkTypeReport, String _PhoneTypeReport, String _SignalStrengthReport, String _ReceivedSMSReport,
|
||||||
|
String _SentSMSReport, String _IncomingCallsReport, String _MissedCallsReport, String _OutgoingCallsReport, String _BytesReceivedReport,
|
||||||
|
String _BytesSentReport, String _HelloSignalReport, String _BatteryLevelReport, String _RoamingReport, int _roaming, String _mobileWebURL,
|
||||||
|
String _InventoryReport, String _NotificationCheck) {
|
||||||
|
|
||||||
|
if (con == null) {
|
||||||
|
con = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedPreferences agentPreferences = con.getSharedPreferences(
|
||||||
|
con.getString(R.string.const_string_preferences),
|
||||||
|
Activity.MODE_PRIVATE);
|
||||||
|
SharedPreferences.Editor editor = agentPreferences.edit();
|
||||||
|
|
||||||
|
editor.putString("serverAddr", _serverAddr);
|
||||||
|
editor.putString("serverPort", _serverPort);
|
||||||
|
editor.putInt("interval", _interval);
|
||||||
|
editor.putString("agentName", _agentName);
|
||||||
|
editor.putString("gpsStatus", _gpsStatus);
|
||||||
|
editor.putString("memoryStatus", _memoryStatus);
|
||||||
|
editor.putString("taskStatus", _taskStatus);
|
||||||
|
editor.putString("task", _task);
|
||||||
|
editor.putString("taskHumanName", _taskHumanName);
|
||||||
|
editor.putString("simID", _simID);
|
||||||
|
editor.putString("simIDReport", _simIDReport);
|
||||||
|
editor.putLong("UpTime", _upTime);
|
||||||
|
editor.putString("networkOperator", _networkOperator);
|
||||||
|
editor.putInt("SMSReceived", _smsReceived);
|
||||||
|
editor.putInt("SMSSent", _smsSent);
|
||||||
|
editor.putString("networkType", _networkType);
|
||||||
|
editor.putString("phoneType", _phoneType);
|
||||||
|
editor.putInt("signalStrength", _signalStrength);
|
||||||
|
editor.putInt("incomingCalls", _incomingCalls);
|
||||||
|
editor.putInt("missedCalls", _missedCalls);
|
||||||
|
editor.putInt("outgoingCalls", _outgoingCalls);
|
||||||
|
editor.putLong("receiveBytes", _receiveBytes);
|
||||||
|
editor.putLong("transmitBytes", _transmitBytes);
|
||||||
|
editor.putString("password", _password);
|
||||||
|
editor.putString("passwordCheck", _passwordCheck);
|
||||||
|
editor.putInt("helloSignal", _helloSignal);
|
||||||
|
editor.putInt("roaming", _roaming);
|
||||||
|
editor.putString("DeviceUpTimeReport", _DeviceUpTimeReport);
|
||||||
|
editor.putString("NetworkOperatorReport", _NetworkOperatorReport);
|
||||||
|
editor.putString("NetworkTypeReport", _NetworkTypeReport);
|
||||||
|
editor.putString("PhoneTypeReport", _PhoneTypeReport);
|
||||||
|
editor.putString("SignalStrengthReport", _SignalStrengthReport);
|
||||||
|
editor.putString("ReceivedSMSReport", _ReceivedSMSReport);
|
||||||
|
editor.putString("SentSMSReport", _SentSMSReport);
|
||||||
|
editor.putString("IncomingCallsReport", _IncomingCallsReport);
|
||||||
|
editor.putString("MissedCallsReport", _MissedCallsReport);
|
||||||
|
editor.putString("OutgoingCallsReport", _OutgoingCallsReport);
|
||||||
|
editor.putString("BytesReceivedReport", _BytesReceivedReport);
|
||||||
|
editor.putString("BytesSentReport", _BytesSentReport);
|
||||||
|
editor.putString("HelloSignalReport", _HelloSignalReport);
|
||||||
|
editor.putString("BatteryLevelReport", _BatteryLevelReport);
|
||||||
|
editor.putString("RoamingReport", _RoamingReport);
|
||||||
|
editor.putString("InventoryReport", _InventoryReport);
|
||||||
|
editor.putString("NotificationCheck", _NotificationCheck);
|
||||||
|
editor.putString("mobileWebURL", _mobileWebURL);
|
||||||
|
|
||||||
|
if (editor.commit()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}// end updateConf
|
||||||
|
|
||||||
|
|
||||||
|
//database//
|
||||||
|
|
||||||
|
static synchronized public void loadLastValuesDatabase(Context context) {
|
||||||
|
if (con == null) {
|
||||||
|
con = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
latitude = Float.parseFloat(getDatabaseValue(con, "latitude"));
|
||||||
|
longitude = Float.parseFloat(getDatabaseValue(con, "longitude"));
|
||||||
|
batteryLevel = Integer.parseInt(getDatabaseValue(con, "batteryLevel"));
|
||||||
|
orientation = Float.parseFloat(getDatabaseValue(con, "orientation"));
|
||||||
|
proximity = Float.parseFloat(getDatabaseValue(con, "proximity"));
|
||||||
|
taskStatus = getDatabaseValue(con, "taskStatus");
|
||||||
|
task = getDatabaseValue(con, "task");
|
||||||
|
taskHumanName = getDatabaseValue(con, "taskHumanName");
|
||||||
|
taskRun = getDatabaseValue(con, "taskRun");
|
||||||
|
memoryStatus = getDatabaseValue(con, "memoryStatus");
|
||||||
|
availableRamKb = Long.parseLong(getDatabaseValue(con, "availableRamKb"));
|
||||||
|
totalRamKb = Long.parseLong(getDatabaseValue(con, "totalRamKb"));
|
||||||
|
lastContact = Long.parseLong(getDatabaseValue(con, "lastContact"));
|
||||||
|
contactError = Integer.parseInt(getDatabaseValue(con, "contactError"));
|
||||||
|
simID = getDatabaseValue(con, "simID");
|
||||||
|
upTime = Long.parseLong(getDatabaseValue(con, "upTime"));
|
||||||
|
SMSReceived = Integer.parseInt(getDatabaseValue(con, "SMSReceived"));
|
||||||
|
SMSSent = Integer.parseInt(getDatabaseValue(con, "SMSSent"));
|
||||||
|
networkOperator = getDatabaseValue(con, "networkOperator");
|
||||||
|
networkType = getDatabaseValue(con, "networkType");
|
||||||
|
phoneType = getDatabaseValue(con, "phoneType");
|
||||||
|
signalStrength = Integer.parseInt(getDatabaseValue(con, "signalStrength"));
|
||||||
|
incomingCalls = Integer.parseInt(getDatabaseValue(con, "incomingCalls"));
|
||||||
|
missedCalls = Integer.parseInt(getDatabaseValue(con, "missedCalls"));
|
||||||
|
outgoingCalls = Integer.parseInt(getDatabaseValue(con, "outgoingCalls"));
|
||||||
|
receiveBytes = Long.parseLong(getDatabaseValue(con, "receiveBytes"));
|
||||||
|
transmitBytes = Long.parseLong(getDatabaseValue(con, "transmitBytes"));
|
||||||
|
helloSignal = Integer.parseInt(getDatabaseValue(con, "helloSignal"));
|
||||||
|
roaming = Integer.parseInt(getDatabaseValue(con, "roaming"));
|
||||||
|
|
||||||
|
}// end loadLastValues
|
||||||
|
|
||||||
|
static synchronized public void loadConfDatabase(Context context) {
|
||||||
|
if (con == null) {
|
||||||
|
con = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
serverAddr = getDatabaseValue(con, "serverAddr");
|
||||||
|
serverPort = getDatabaseValue(con, "serverPort");
|
||||||
|
interval = Integer.parseInt(getDatabaseValue(con, "interval"));
|
||||||
|
agentName = getDatabaseValue(con, "agentName");
|
||||||
|
mobileWebURL = getDatabaseValue(con, "mobileWebURL");
|
||||||
|
gpsStatus = getDatabaseValue(con, "gpsStatus");
|
||||||
|
memoryStatus = getDatabaseValue(con, "memoryStatus");
|
||||||
|
taskStatus = getDatabaseValue(con, "taskStatus");
|
||||||
|
task = getDatabaseValue(con, "task");
|
||||||
|
taskHumanName = getDatabaseValue(con, "taskHumanName");
|
||||||
|
taskRun = getDatabaseValue(con, "taskRun");
|
||||||
|
password = getDatabaseValue(con, "password");
|
||||||
|
passwordCheck = getDatabaseValue(con, "passwordCheck");
|
||||||
|
simIDReport = getDatabaseValue(con, "simIDReport");
|
||||||
|
DeviceUpTimeReport = getDatabaseValue(con, "DeviceUpTimeReport");
|
||||||
|
NetworkOperatorReport = getDatabaseValue(con, "NetworkOperatorReport");
|
||||||
|
NetworkTypeReport = getDatabaseValue(con, "NetworkTypeReport");
|
||||||
|
PhoneTypeReport = getDatabaseValue(con, "PhoneTypeReport");
|
||||||
|
SignalStrengthReport = getDatabaseValue(con, "SignalStrengthReport");
|
||||||
|
ReceivedSMSReport = getDatabaseValue(con, "ReceivedSMSReport");
|
||||||
|
SentSMSReport = getDatabaseValue(con, "SentSMSReport");
|
||||||
|
IncomingCallsReport = getDatabaseValue(con, "IncomingCallsReport");
|
||||||
|
MissedCallsReport = getDatabaseValue(con, "MissedCallsReport");
|
||||||
|
OutgoingCallsReport = getDatabaseValue(con, "OutgoingCallsReport");
|
||||||
|
BytesReceivedReport = getDatabaseValue(con, "BytesReceivedReport");
|
||||||
|
BytesSentReport = getDatabaseValue(con, "BytesSentReport");
|
||||||
|
HelloSignalReport = getDatabaseValue(con, "HelloSignalReport");
|
||||||
|
BatteryLevelReport = getDatabaseValue(con, "BatteryLevelReport");
|
||||||
|
RoamingReport = getDatabaseValue(con, "RoamingReport");
|
||||||
|
InventoryReport = getDatabaseValue(con, "InventoryReport");
|
||||||
|
NotificationCheck = getDatabaseValue(con, "NotificationCheck");
|
||||||
|
}// end loadConf
|
||||||
|
|
||||||
|
static synchronized public boolean updateDatabase(Context context) {
|
||||||
|
return updateDatabase(context, serverAddr, serverPort, interval, agentName,
|
||||||
|
gpsStatus, memoryStatus, taskStatus, task, taskHumanName, simID, simIDReport, upTime,
|
||||||
|
networkOperator, SMSReceived, SMSSent, networkType, phoneType, signalStrength,
|
||||||
|
incomingCalls, missedCalls, outgoingCalls, receiveBytes, transmitBytes, password, helloSignal,
|
||||||
|
passwordCheck, DeviceUpTimeReport, NetworkOperatorReport, NetworkTypeReport, PhoneTypeReport,
|
||||||
|
SignalStrengthReport, ReceivedSMSReport, SentSMSReport, IncomingCallsReport, MissedCallsReport,
|
||||||
|
OutgoingCallsReport, BytesReceivedReport, BytesSentReport, HelloSignalReport, BatteryLevelReport,
|
||||||
|
RoamingReport, roaming, mobileWebURL, InventoryReport , NotificationCheck
|
||||||
|
);
|
||||||
|
|
||||||
|
}// end updateConf
|
||||||
|
|
||||||
|
static synchronized public boolean updateDatabase(Context context, String _serverAddr,
|
||||||
String _serverPort, int _interval, String _agentName, String _gpsStatus,
|
String _serverPort, int _interval, String _agentName, String _gpsStatus,
|
||||||
String _memoryStatus, String _taskStatus, String _task,
|
String _memoryStatus, String _taskStatus, String _task,
|
||||||
String _taskHumanName, String _simID, String _simIDReport, long _upTime, String _networkOperator,
|
String _taskHumanName, String _simID, String _simIDReport, long _upTime, String _networkOperator,
|
||||||
|
@ -315,51 +491,51 @@ public class Core {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
updateValue(con,"serverAddr", _serverAddr);
|
updateDatabaseValue(con,"serverAddr", _serverAddr);
|
||||||
updateValue(con,"serverPort", _serverPort);
|
updateDatabaseValue(con,"serverPort", _serverPort);
|
||||||
updateValue(con,"interval", ""+_interval);
|
updateDatabaseValue(con,"interval", ""+_interval);
|
||||||
updateValue(con,"agentName", _agentName);
|
updateDatabaseValue(con,"agentName", _agentName);
|
||||||
updateValue(con,"gpsStatus", _gpsStatus);
|
updateDatabaseValue(con,"gpsStatus", _gpsStatus);
|
||||||
updateValue(con,"memoryStatus", _memoryStatus);
|
updateDatabaseValue(con,"memoryStatus", _memoryStatus);
|
||||||
updateValue(con,"taskStatus", _taskStatus);
|
updateDatabaseValue(con,"taskStatus", _taskStatus);
|
||||||
updateValue(con,"task", _task);
|
updateDatabaseValue(con,"task", _task);
|
||||||
updateValue(con,"taskHumanName", _taskHumanName);
|
updateDatabaseValue(con,"taskHumanName", _taskHumanName);
|
||||||
updateValue(con,"simID", _simID);
|
updateDatabaseValue(con,"simID", _simID);
|
||||||
updateValue(con,"simIDReport", _simIDReport);
|
updateDatabaseValue(con,"simIDReport", _simIDReport);
|
||||||
updateValue(con,"upTime", ""+_upTime);
|
updateDatabaseValue(con,"upTime", ""+_upTime);
|
||||||
updateValue(con,"networkOperator", _networkOperator);
|
updateDatabaseValue(con,"networkOperator", _networkOperator);
|
||||||
updateValue(con,"SMSReceived", ""+_smsReceived);
|
updateDatabaseValue(con,"SMSReceived", ""+_smsReceived);
|
||||||
updateValue(con,"SMSSent", ""+_smsSent);
|
updateDatabaseValue(con,"SMSSent", ""+_smsSent);
|
||||||
updateValue(con,"networkType", _networkType);
|
updateDatabaseValue(con,"networkType", _networkType);
|
||||||
updateValue(con,"phoneType", _phoneType);
|
updateDatabaseValue(con,"phoneType", _phoneType);
|
||||||
updateValue(con,"signalStrength", ""+_signalStrength);
|
updateDatabaseValue(con,"signalStrength", ""+_signalStrength);
|
||||||
updateValue(con,"incomingCalls", ""+_incomingCalls);
|
updateDatabaseValue(con,"incomingCalls", ""+_incomingCalls);
|
||||||
updateValue(con,"missedCalls", ""+_missedCalls);
|
updateDatabaseValue(con,"missedCalls", ""+_missedCalls);
|
||||||
updateValue(con,"outgoingCalls", ""+_outgoingCalls);
|
updateDatabaseValue(con,"outgoingCalls", ""+_outgoingCalls);
|
||||||
updateValue(con,"receiveBytes", ""+_receiveBytes);
|
updateDatabaseValue(con,"receiveBytes", ""+_receiveBytes);
|
||||||
updateValue(con,"transmitBytes", ""+_transmitBytes);
|
updateDatabaseValue(con,"transmitBytes", ""+_transmitBytes);
|
||||||
updateValue(con,"password", _password);
|
updateDatabaseValue(con,"password", _password);
|
||||||
updateValue(con,"passwordCheck", _passwordCheck);
|
updateDatabaseValue(con,"passwordCheck", _passwordCheck);
|
||||||
updateValue(con,"helloSignal", ""+_helloSignal);
|
updateDatabaseValue(con,"helloSignal", ""+_helloSignal);
|
||||||
updateValue(con,"roaming", ""+_roaming);
|
updateDatabaseValue(con,"roaming", ""+_roaming);
|
||||||
updateValue(con,"DeviceUpTimeReport", _DeviceUpTimeReport);
|
updateDatabaseValue(con,"DeviceUpTimeReport", _DeviceUpTimeReport);
|
||||||
updateValue(con,"NetworkOperatorReport", _NetworkOperatorReport);
|
updateDatabaseValue(con,"NetworkOperatorReport", _NetworkOperatorReport);
|
||||||
updateValue(con,"NetworkTypeReport", _NetworkTypeReport);
|
updateDatabaseValue(con,"NetworkTypeReport", _NetworkTypeReport);
|
||||||
updateValue(con,"PhoneTypeReport", _PhoneTypeReport);
|
updateDatabaseValue(con,"PhoneTypeReport", _PhoneTypeReport);
|
||||||
updateValue(con,"SignalStrengthReport", _SignalStrengthReport);
|
updateDatabaseValue(con,"SignalStrengthReport", _SignalStrengthReport);
|
||||||
updateValue(con,"ReceivedSMSReport", _ReceivedSMSReport);
|
updateDatabaseValue(con,"ReceivedSMSReport", _ReceivedSMSReport);
|
||||||
updateValue(con,"SentSMSReport", _SentSMSReport);
|
updateDatabaseValue(con,"SentSMSReport", _SentSMSReport);
|
||||||
updateValue(con,"IncomingCallsReport", _IncomingCallsReport);
|
updateDatabaseValue(con,"IncomingCallsReport", _IncomingCallsReport);
|
||||||
updateValue(con,"MissedCallsReport", _MissedCallsReport);
|
updateDatabaseValue(con,"MissedCallsReport", _MissedCallsReport);
|
||||||
updateValue(con,"OutgoingCallsReport", _OutgoingCallsReport);
|
updateDatabaseValue(con,"OutgoingCallsReport", _OutgoingCallsReport);
|
||||||
updateValue(con,"BytesReceivedReport", _BytesReceivedReport);
|
updateDatabaseValue(con,"BytesReceivedReport", _BytesReceivedReport);
|
||||||
updateValue(con,"BytesSentReport", _BytesSentReport);
|
updateDatabaseValue(con,"BytesSentReport", _BytesSentReport);
|
||||||
updateValue(con,"HelloSignalReport", _HelloSignalReport);
|
updateDatabaseValue(con,"HelloSignalReport", _HelloSignalReport);
|
||||||
updateValue(con,"BatteryLevelReport", _BatteryLevelReport);
|
updateDatabaseValue(con,"BatteryLevelReport", _BatteryLevelReport);
|
||||||
updateValue(con,"RoamingReport", _RoamingReport);
|
updateDatabaseValue(con,"RoamingReport", _RoamingReport);
|
||||||
updateValue(con,"InventoryReport", _InventoryReport);
|
updateDatabaseValue(con,"InventoryReport", _InventoryReport);
|
||||||
updateValue(con,"NotificationCheck", _NotificationCheck);
|
updateDatabaseValue(con,"NotificationCheck", _NotificationCheck);
|
||||||
updateValue(con,"mobileWebURL", _mobileWebURL);
|
updateDatabaseValue(con,"mobileWebURL", _mobileWebURL);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -367,89 +543,18 @@ public class Core {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
// //Adds a new row "name" with the value "value"
|
||||||
//Initialize database
|
// public static void addValue(Context context, String name, String value){
|
||||||
public static void initDatabase(Context context){
|
// db = new DataBaseHandler(con);
|
||||||
if (con == null) {
|
//
|
||||||
con = context;
|
// DataHandler dh = new DataHandler(name, value);
|
||||||
}
|
//
|
||||||
db = new DataBaseHandler(con);
|
// db.addValue(dh);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
addValue(con,"serverAddr",defaultServerAddr);
|
|
||||||
addValue(con,"serverPort",defaultServerPort);
|
|
||||||
addValue(con,"interval",""+defaultInterval);
|
|
||||||
addValue(con,"agentName",defaultAgentName+"_"+Installation.id(context));
|
|
||||||
addValue(con,"mobileWebURL",defaultmobileWebURL);
|
|
||||||
addValue(con,"gpsStatus",defaultGpsStatus);
|
|
||||||
addValue(con,"memoryStatus",defaultMemoryStatus);
|
|
||||||
addValue(con,"taskStatus",defaultTaskStatus);
|
|
||||||
addValue(con,"task",defaultTask);
|
|
||||||
addValue(con,"taskHumanName",defaultTaskHumanName);
|
|
||||||
addValue(con,"simIDReport",defaultSimIDReport);
|
|
||||||
addValue(con,"passwordCheck",defaultPasswordCheck);
|
|
||||||
addValue(con,"DeviceUpTimeReport",defaultDeviceUpTimeReport);
|
|
||||||
addValue(con,"NetworkOperatorReport",defaultNetworkOperatorReport);
|
|
||||||
addValue(con,"NetworkTypeReport",defaultNetworkTypeReport);
|
|
||||||
addValue(con,"PhoneTypeReport",defaultPhoneTypeReport);
|
|
||||||
addValue(con,"SignalStrengthReport",defaultSignalStrengthReport);
|
|
||||||
addValue(con,"ReceivedSMSReport",defaultReceivedSMSReport);
|
|
||||||
addValue(con,"SentSMSReport",defaultSentSMSReport);
|
|
||||||
addValue(con,"IncomingCallsReport",defaultIncomingCallsReport);
|
|
||||||
addValue(con,"MissedCallsReport",defaultMissedCallsReport);
|
|
||||||
addValue(con,"OutgoingCallsReport",defaultOutgoingCallsReport);
|
|
||||||
addValue(con,"BytesReceivedReport",defaultBytesReceivedReport);
|
|
||||||
addValue(con,"BytesSentReport",defaultBytesSentReport);
|
|
||||||
addValue(con,"HelloSignalReport",defaultHelloSignalReport);
|
|
||||||
addValue(con,"BatteryLevelReport",defaultHelloSignalReport);
|
|
||||||
addValue(con,"RoamingReport",defaultRoamingReport);
|
|
||||||
addValue(con,"InventoryReport",defaultRoamingReport);
|
|
||||||
addValue(con,"NotificationCheck",defaultNotificationCheck);
|
|
||||||
|
|
||||||
addValue(con,"hasSim", ""+defaultHasSim);
|
|
||||||
|
|
||||||
addValue(con,"password",defaultPassword);
|
|
||||||
|
|
||||||
addValue(con,"latitude",""+CONST_INVALID_COORDS);
|
|
||||||
addValue(con,"longitude",""+CONST_INVALID_COORDS);
|
|
||||||
addValue(con,"batteryLevel",""+CONST_INVALID_BATTERY_LEVEL);
|
|
||||||
addValue(con,"orientation",""+CONST_INVALID_ORIENTATION);
|
|
||||||
addValue(con,"proximity",""+CONST_INVALID_PROXIMITY);
|
|
||||||
addValue(con,"taskRun",defaultTaskRun);
|
|
||||||
addValue(con,"availableRamKb",""+defaultRam);
|
|
||||||
addValue(con,"totalRamKb",""+defaultRam);
|
|
||||||
addValue(con,"simID",defaultSimID);
|
|
||||||
addValue(con,"upTime",""+defaultUpTime);
|
|
||||||
addValue(con,"SMSReceived",""+defaultSMSReceived);
|
|
||||||
addValue(con,"SMSSent",""+defaultSMSSent);
|
|
||||||
addValue(con,"networkOperator",defaultNetworkOperator);
|
|
||||||
addValue(con,"networkType",defaultNetworkType);
|
|
||||||
addValue(con,"phoneType",defaultPhoneType);
|
|
||||||
addValue(con,"signalStrength",""+defaultSignalStrength);
|
|
||||||
addValue(con,"incomingCalls",""+defaultIncomingCalls);
|
|
||||||
addValue(con,"missedCalls",""+defaultMissedCalls);
|
|
||||||
addValue(con,"outgoingCalls",""+defaultOutgoingCalls);
|
|
||||||
addValue(con,"receiveBytes",""+defaultReceiveBytes);
|
|
||||||
addValue(con,"transmitBytes",""+defaultTransmitBytes);
|
|
||||||
addValue(con,"helloSignal",""+defaultHelloSignal);
|
|
||||||
addValue(con,"roaming",""+defaultRoaming);
|
|
||||||
|
|
||||||
addValue(con,"lastContact",""+CONST_INVALID_CONTACT);
|
|
||||||
addValue(con,"contactError",""+CONST_CONTACT_ERROR);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Adds a new row "name" with the value "value"
|
|
||||||
public static void addValue(Context context, String name, String value){
|
|
||||||
db = new DataBaseHandler(con);
|
|
||||||
|
|
||||||
DataHandler dh = new DataHandler(name, value);
|
|
||||||
|
|
||||||
db.addValue(dh);
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//Updates a given row "name" with a "value"
|
//Updates a given row "name" with a "value"
|
||||||
public static synchronized void updateValue(Context context, String name, String value){
|
public static synchronized void updateDatabaseValue(Context context, String name, String value){
|
||||||
db = new DataBaseHandler(con, "pandroid", null, 1);
|
db = new DataBaseHandler(con, "pandroid", null, 1);
|
||||||
//Retrieve id of row to update
|
//Retrieve id of row to update
|
||||||
int id = getDataHandler(con, name).get_id();
|
int id = getDataHandler(con, name).get_id();
|
||||||
|
@ -467,13 +572,10 @@ public class Core {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Returns the value of the given row "name"
|
//Returns the value of the given row "name"
|
||||||
public static synchronized String getValue(Context context, String name){
|
public static synchronized String getDatabaseValue(Context context, String name){
|
||||||
db = new DataBaseHandler(con, "pandroid", null, 1);
|
db = new DataBaseHandler(con, "pandroid", null, 1);
|
||||||
|
|
||||||
return db.getValue(name).get_value();
|
return db.getValue(name).get_value();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,17 +16,16 @@ package pandroid.agent;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
//import android.app.Dialog;
|
||||||
import android.app.TabActivity;
|
import android.app.TabActivity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.TabHost;
|
|
||||||
//import android.app.Dialog;
|
|
||||||
//import android.util.Log;
|
//import android.util.Log;
|
||||||
//import android.view.WindowManager.LayoutParams;
|
//import android.view.WindowManager.LayoutParams;
|
||||||
|
import android.widget.TabHost;
|
||||||
|
|
||||||
public class PandroidAgent extends TabActivity {
|
public class PandroidAgent extends TabActivity {
|
||||||
|
|
||||||
|
@ -34,14 +33,16 @@ public class PandroidAgent extends TabActivity {
|
||||||
int defaultInterval = 300;
|
int defaultInterval = 300;
|
||||||
TabHost tabHost;
|
TabHost tabHost;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
//database//
|
||||||
|
|
||||||
|
|
||||||
|
Core.loadConfDatabase(this);
|
||||||
|
Core.loadLastValuesDatabase(this);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
final Dialog dialog = new Dialog(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
|
final Dialog dialog = new Dialog(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
|
||||||
|
@ -65,10 +66,6 @@ public class PandroidAgent extends TabActivity {
|
||||||
//Requires The agent name to use installation id
|
//Requires The agent name to use installation id
|
||||||
File installation = new File(getApplicationContext().getFilesDir(), "INSTALLATION");
|
File installation = new File(getApplicationContext().getFilesDir(), "INSTALLATION");
|
||||||
if(!installation.exists()){
|
if(!installation.exists()){
|
||||||
//Create database with default values
|
|
||||||
//DataBaseHandler db = new DataBaseHandler(this,"pandroid", null, 1);
|
|
||||||
|
|
||||||
//Log.d("DATABASE",Core.db.getValue("latitude").get_value());
|
|
||||||
Core.restartAgentListener(getApplicationContext());
|
Core.restartAgentListener(getApplicationContext());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -109,11 +106,13 @@ public class PandroidAgent extends TabActivity {
|
||||||
public void onPause(){
|
public void onPause(){
|
||||||
super.onPause();
|
super.onPause();
|
||||||
Core.updateConf(getApplicationContext());
|
Core.updateConf(getApplicationContext());
|
||||||
|
Core.updateDatabase(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroy(){
|
public void onDestroy(){
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
Core.updateConf(getApplicationContext());
|
Core.updateConf(getApplicationContext());
|
||||||
|
Core.updateDatabase(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
//Sets hello signal to 1(first connect since pandroid was closed)
|
//Sets hello signal to 1(first connect since pandroid was closed)
|
||||||
|
@ -122,7 +121,6 @@ public class PandroidAgent extends TabActivity {
|
||||||
|
|
||||||
if(Core.helloSignal == 0)
|
if(Core.helloSignal == 0)
|
||||||
Core.helloSignal = 1;
|
Core.helloSignal = 1;
|
||||||
//dubious
|
|
||||||
Core.updateConf(getApplicationContext());
|
Core.updateConf(getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,7 @@ public class PandroidAgentListener extends Service {
|
||||||
// Keep lastXML sended if is not empty (empty means error sending it)
|
// Keep lastXML sended if is not empty (empty means error sending it)
|
||||||
String lastXML = buildXML();
|
String lastXML = buildXML();
|
||||||
|
|
||||||
|
|
||||||
String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||||
|
|
||||||
String destFileName = agentName + "." + System.currentTimeMillis() + ".data";
|
String destFileName = agentName + "." + System.currentTimeMillis() + ".data";
|
||||||
|
@ -158,71 +159,72 @@ public class PandroidAgentListener extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
// private void contact(){
|
private void contact(){
|
||||||
//
|
|
||||||
// /*
|
/*
|
||||||
// Toast toast = Toast.makeText(getApplicationContext(),
|
Toast toast = Toast.makeText(getApplicationContext(),
|
||||||
//
|
|
||||||
// getString(R.string.loading),
|
getString(R.string.loading),
|
||||||
// Toast.LENGTH_SHORT);
|
Toast.LENGTH_SHORT);
|
||||||
// toast.setGravity(Gravity.BOTTOM,0,0);
|
toast.setGravity(Gravity.BOTTOM,0,0);
|
||||||
// toast.show();
|
toast.show();
|
||||||
// */
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Date date = new Date();
|
Date date = new Date();
|
||||||
//
|
|
||||||
// putSharedData("PANDROID_DATA", "lastContact", Long.toString(date.getTime() / 1000), "long");
|
putSharedData("PANDROID_DATA", "lastContact", Long.toString(date.getTime() / 1000), "long");
|
||||||
//
|
|
||||||
// String lastXML = "";
|
String lastXML = "";
|
||||||
// new contactTask().execute(lastXML);
|
new contactTask().execute(lastXML);
|
||||||
// updateValues();
|
updateValues();
|
||||||
//
|
|
||||||
// }//end contact
|
}//end contact
|
||||||
//
|
|
||||||
// private class contactTask extends AsyncTask<String, Void, Void>{
|
|
||||||
//
|
private class contactTask extends AsyncTask<String, Void, Void>{
|
||||||
// @Override
|
|
||||||
// protected Void doInBackground(String...params) {
|
@Override
|
||||||
//
|
protected Void doInBackground(String...params) {
|
||||||
// String lastXML = params[0];
|
|
||||||
// lastXML = buildXML();
|
String lastXML = params[0];
|
||||||
// String destFileName = "";
|
lastXML = buildXML();
|
||||||
// String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
String destFileName = "";
|
||||||
// destFileName = agentName + "." + System.currentTimeMillis() + ".data";
|
String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||||
//
|
destFileName = agentName + "." + System.currentTimeMillis() + ".data";
|
||||||
// writeFile(destFileName, lastXML);
|
|
||||||
// String[] tentacleData = {
|
writeFile(destFileName, lastXML);
|
||||||
// "-a",
|
String[] tentacleData = {
|
||||||
// getSharedData("PANDROID_DATA", "serverAddr", "", "string"),
|
"-a",
|
||||||
// "-p",
|
getSharedData("PANDROID_DATA", "serverAddr", "", "string"),
|
||||||
// Core.defaultServerPort,
|
"-p",
|
||||||
// "-v",
|
Core.defaultServerPort,
|
||||||
// "/data/data/pandroid.agent/files/" + destFileName
|
"-v",
|
||||||
// };
|
"/data/data/pandroid.agent/files/" + destFileName
|
||||||
//
|
};
|
||||||
// int tentacleRet = new tentacle_client().tentacle_client(tentacleData);
|
|
||||||
//
|
int tentacleRet = new tentacle_client().tentacle_client(tentacleData);
|
||||||
// putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
|
|
||||||
// if(tentacleRet == 0) {
|
putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
|
||||||
// putSharedData("PANDROID_DATA", "contactError", "0", "integer");
|
if(tentacleRet == 0) {
|
||||||
// // Deleting the file after send it
|
putSharedData("PANDROID_DATA", "contactError", "0", "integer");
|
||||||
// // move to only delete if sent successfully
|
// Deleting the file after send it
|
||||||
// File file = new File("/data/data/pandroid.agent/files/" + destFileName);
|
// move to only delete if sent successfully
|
||||||
// file.delete();
|
File file = new File("/data/data/pandroid.agent/files/" + destFileName);
|
||||||
// if (Core.helloSignal >= 1)
|
file.delete();
|
||||||
// Core.helloSignal = 0;
|
if (Core.helloSignal >= 1)
|
||||||
// Core.updateConf(getApplicationContext());
|
Core.helloSignal = 0;
|
||||||
// }
|
Core.updateConf(getApplicationContext());
|
||||||
// else{
|
}
|
||||||
// putSharedData("PANDROID_DATA", "contactError", "1", "integer");
|
else{
|
||||||
// }
|
putSharedData("PANDROID_DATA", "contactError", "1", "integer");
|
||||||
// return null;
|
}
|
||||||
//
|
return null;
|
||||||
// }//end doInBackground
|
|
||||||
// }
|
}//end doInBackground
|
||||||
|
}
|
||||||
|
*/
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// From unfinished task of buffering unsent xml files when no connection available //
|
// From unfinished task of buffering unsent xml files when no connection available //
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -392,6 +394,11 @@ public class PandroidAgentListener extends Service {
|
||||||
buffer += buildmoduleXML("helloSignal","Hello Signal", "generic_data", helloSignal);
|
buffer += buildmoduleXML("helloSignal","Hello Signal", "generic_data", helloSignal);
|
||||||
|
|
||||||
|
|
||||||
|
//UTF-8 TEST//
|
||||||
|
|
||||||
|
String iso_8859_1String = "ÀÁÈÉÌÍÙÚÜàáèéìíòóùúü";
|
||||||
|
|
||||||
|
buffer += buildmoduleXML("iso-8859-1Test","Testing iso-8859-1 Values", "generic_data_string", iso_8859_1String);
|
||||||
|
|
||||||
|
|
||||||
// End_Modules
|
// End_Modules
|
||||||
|
@ -403,7 +410,7 @@ public class PandroidAgentListener extends Service {
|
||||||
}// end buildXML
|
}// end buildXML
|
||||||
|
|
||||||
private void writeFile(String fileName, String textToWrite) {
|
private void writeFile(String fileName, String textToWrite) {
|
||||||
try { // catches IOException below
|
try { // catches IOException below
|
||||||
/*
|
/*
|
||||||
String UTF8 = "utf8";
|
String UTF8 = "utf8";
|
||||||
int BUFFER_SIZE = 8192;
|
int BUFFER_SIZE = 8192;
|
||||||
|
@ -954,14 +961,12 @@ try { // catches IOException below
|
||||||
|
|
||||||
|
|
||||||
private void putSharedData(String preferenceName, String tokenName, String data, String type) {
|
private void putSharedData(String preferenceName, String tokenName, String data, String type) {
|
||||||
//int mode = Activity.MODE_PRIVATE;
|
int mode = Activity.MODE_PRIVATE;
|
||||||
//SharedPreferences agentPreferences = getSharedPreferences(preferenceName, mode);
|
SharedPreferences agentPreferences = getSharedPreferences(preferenceName, mode);
|
||||||
//SharedPreferences.Editor editor = agentPreferences.edit();
|
SharedPreferences.Editor editor = agentPreferences.edit();
|
||||||
|
|
||||||
Core.updateValue(this, tokenName, data);
|
|
||||||
/*
|
|
||||||
if(type == "boolean") {
|
if(type == "boolean") {
|
||||||
Core.updateValue(this, tokenName, data)
|
|
||||||
editor.putBoolean(tokenName, Boolean.parseBoolean(data));
|
editor.putBoolean(tokenName, Boolean.parseBoolean(data));
|
||||||
}
|
}
|
||||||
else if(type == "float") {
|
else if(type == "float") {
|
||||||
|
@ -978,16 +983,12 @@ try { // catches IOException below
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.commit();
|
editor.commit();
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSharedData(String preferenceName, String tokenName, String defaultValue, String type) {
|
private String getSharedData(String preferenceName, String tokenName, String defaultValue, String type) {
|
||||||
//int mode = Activity.MODE_PRIVATE;
|
int mode = Activity.MODE_PRIVATE;
|
||||||
//SharedPreferences agentPreferences = getSharedPreferences(preferenceName, mode);
|
SharedPreferences agentPreferences = getSharedPreferences(preferenceName, mode);
|
||||||
|
|
||||||
return Core.getValue(this, tokenName);
|
|
||||||
|
|
||||||
/*
|
|
||||||
if(type == "boolean") {
|
if(type == "boolean") {
|
||||||
boolean a = agentPreferences.getBoolean(tokenName, Boolean.parseBoolean(defaultValue));
|
boolean a = agentPreferences.getBoolean(tokenName, Boolean.parseBoolean(defaultValue));
|
||||||
return Boolean.valueOf(a).toString();
|
return Boolean.valueOf(a).toString();
|
||||||
|
@ -1009,7 +1010,6 @@ try { // catches IOException below
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getHumanDateTime(long unixtime){
|
private String getHumanDateTime(long unixtime){
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class Setup extends Activity {
|
||||||
webButton.setOnClickListener(new OnClickListener() {
|
webButton.setOnClickListener(new OnClickListener() {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
getDataFromView();
|
getDataFromView();
|
||||||
//Core.updateConf(getApplicationContext());
|
Core.updateConf(getApplicationContext());
|
||||||
|
|
||||||
String url = Core.mobileWebURL;
|
String url = Core.mobileWebURL;
|
||||||
if (!url.startsWith("https://") && !url.startsWith("http://")){
|
if (!url.startsWith("https://") && !url.startsWith("http://")){
|
||||||
|
@ -433,7 +433,7 @@ public class Setup extends Activity {
|
||||||
Core.NotificationCheck = "disabled";
|
Core.NotificationCheck = "disabled";
|
||||||
|
|
||||||
|
|
||||||
//Core.updateConf(getApplicationContext());
|
Core.updateConf(getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadViews(){
|
private void loadViews(){
|
||||||
|
@ -535,7 +535,7 @@ public class Setup extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Core.passwordCheck = "disabled";
|
Core.passwordCheck = "disabled";
|
||||||
//Core.updateConf(getApplicationContext());
|
Core.updateConf(getApplicationContext());
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
createPass();
|
createPass();
|
||||||
} // end onClick
|
} // end onClick
|
||||||
|
@ -551,12 +551,11 @@ public class Setup extends Activity {
|
||||||
Core.passwordCheck = "disabled";
|
Core.passwordCheck = "disabled";
|
||||||
else
|
else
|
||||||
Core.passwordCheck = "enabled";
|
Core.passwordCheck = "enabled";
|
||||||
//Core.updateConf(getApplicationContext());
|
Core.updateConf(getApplicationContext());
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
} // end onClick
|
} // end onClick
|
||||||
});//end clickListener
|
});//end clickListener
|
||||||
|
|
||||||
Core.updateConf(getApplicationContext());
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,7 +585,7 @@ public class Setup extends Activity {
|
||||||
if(TextUtils.isEmpty(createpass_password))
|
if(TextUtils.isEmpty(createpass_password))
|
||||||
{
|
{
|
||||||
Core.password = Core.defaultPassword;
|
Core.password = Core.defaultPassword;
|
||||||
//Core.updateConf(getApplicationContext());
|
Core.updateConf(getApplicationContext());
|
||||||
InputMethodManager im = (InputMethodManager)getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
|
InputMethodManager im = (InputMethodManager)getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
|
||||||
im.hideSoftInputFromWindow(text.getWindowToken(), 0);
|
im.hideSoftInputFromWindow(text.getWindowToken(), 0);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
@ -608,7 +607,7 @@ public class Setup extends Activity {
|
||||||
else if(createpass_password.equals(createpass_password2))
|
else if(createpass_password.equals(createpass_password2))
|
||||||
{
|
{
|
||||||
Core.password = createpass_password;
|
Core.password = createpass_password;
|
||||||
//Core.updateConf(getApplicationContext());
|
Core.updateConf(getApplicationContext());
|
||||||
//Core.restartAgentListener(getApplicationContext());
|
//Core.restartAgentListener(getApplicationContext());
|
||||||
InputMethodManager im = (InputMethodManager)getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
|
InputMethodManager im = (InputMethodManager)getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
|
||||||
im.hideSoftInputFromWindow(text.getWindowToken(), 0);
|
im.hideSoftInputFromWindow(text.getWindowToken(), 0);
|
||||||
|
@ -639,8 +638,7 @@ public class Setup extends Activity {
|
||||||
} // end onClick
|
} // end onClick
|
||||||
|
|
||||||
});//end clickListener
|
});//end clickListener
|
||||||
|
Core.updateConf(getApplicationContext());
|
||||||
Core.updateConf(getApplicationContext());
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
}// end createPass
|
}// end createPass
|
||||||
|
|
Loading…
Reference in New Issue