2013-04-26 Mark Holland <mark@mark-holland.me.uk>
* src/pandroid/agent/Core.java: Single SharedPreferences and Editor objects that are retrieved when needed. getSharedData() and putSharedData() moved to this class from PandroidAgentListener. * src/pandroid/agent/PandroidAgent.java: Instantiate static SharedPreferences and Editor objects with getters for each. * src/pandroid/agent/PandroidAgentListener.java: buildXML() and contact() are now background tasks. Implemented buffer, if xml fails to send it stays in the system, next succesful conection after sends all of the unsent xml files, current buffer size = 99 files. * src/pandroid/agent/PandroidAgentTentacle.java: Changed socket to timeout after 1000ms. * src/pandroid/agent/SMSBroadcastReceiver.java: Changed SharedPreferences to static version from PandroidAgent.java * Pandroid Agent v3.0_iso-8859-1.apk: Updated to include latest changes. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8069 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
9b7201d812
commit
2865d6c2a5
|
@ -1,3 +1,27 @@
|
|||
2013-04-26 Mark Holland <mark@mark-holland.me.uk>
|
||||
|
||||
* src/pandroid/agent/Core.java: Single SharedPreferences and
|
||||
Editor objects that are retrieved when needed. getSharedData()
|
||||
and putSharedData() moved to this class from
|
||||
PandroidAgentListener.
|
||||
|
||||
* src/pandroid/agent/PandroidAgent.java: Instantiate static
|
||||
SharedPreferences and Editor objects with getters for each.
|
||||
|
||||
* src/pandroid/agent/PandroidAgentListener.java: buildXML() and
|
||||
contact() are now background tasks. Implemented buffer, if xml fails
|
||||
to send it stays in the system, next succesful conection after sends
|
||||
all of the unsent xml files, current buffer size = 99 files.
|
||||
|
||||
* src/pandroid/agent/PandroidAgentTentacle.java: Changed socket to
|
||||
timeout after 1000ms.
|
||||
|
||||
* src/pandroid/agent/SMSBroadcastReceiver.java: Changed SharedPreferences
|
||||
to static version from PandroidAgent.java
|
||||
|
||||
* Pandroid Agent v3.0_iso-8859-1.apk: Updated to include latest
|
||||
changes.
|
||||
|
||||
2013-04-25 Mark Holland <mark@mark-holland.me.uk>
|
||||
|
||||
* src/pandroid/agent/Core.java: Separate load and store
|
||||
|
|
Binary file not shown.
|
@ -177,6 +177,10 @@ public class Core {
|
|||
|
||||
static DataBaseHandler db;
|
||||
|
||||
//Single SharedPreferences object
|
||||
static volatile public SharedPreferences agentPreferences;
|
||||
static volatile public SharedPreferences.Editor editor;
|
||||
|
||||
public Core() {
|
||||
|
||||
}
|
||||
|
@ -214,9 +218,7 @@ public class Core {
|
|||
con = context;
|
||||
}
|
||||
|
||||
SharedPreferences agentPreferences = con.getSharedPreferences(
|
||||
con.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||
|
||||
latitude = agentPreferences.getFloat("latitude", CONST_INVALID_COORDS);
|
||||
longitude = agentPreferences.getFloat("longitude", CONST_INVALID_COORDS);
|
||||
|
@ -255,9 +257,7 @@ public class Core {
|
|||
con = context;
|
||||
}
|
||||
|
||||
SharedPreferences agentPreferences = con.getSharedPreferences(
|
||||
con.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||
|
||||
serverAddr = agentPreferences.getString("serverAddr", defaultServerAddr);
|
||||
serverPort = agentPreferences.getString("serverPort", defaultServerPort);
|
||||
|
@ -321,10 +321,8 @@ public class Core {
|
|||
con = context;
|
||||
}
|
||||
|
||||
SharedPreferences agentPreferences = con.getSharedPreferences(
|
||||
con.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = agentPreferences.edit();
|
||||
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||
editor = PandroidAgent.getEditor();
|
||||
|
||||
editor.putString("serverAddr", _serverAddr);
|
||||
editor.putString("serverPort", _serverPort);
|
||||
|
@ -379,203 +377,256 @@ public class Core {
|
|||
}// 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"));
|
||||
public synchronized static void putSharedData(String preferenceName, String tokenName, String data, String type) {
|
||||
int mode = Activity.MODE_PRIVATE;
|
||||
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||
editor = PandroidAgent.getEditor();
|
||||
|
||||
}// 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 _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;
|
||||
}
|
||||
|
||||
|
||||
if(type == "boolean") {
|
||||
editor.putBoolean(tokenName, Boolean.parseBoolean(data));
|
||||
}
|
||||
else if(type == "float") {
|
||||
editor.putFloat(tokenName, Float.parseFloat(data));
|
||||
}
|
||||
else if(type == "integer") {
|
||||
editor.putInt(tokenName, Integer.parseInt(data));
|
||||
}
|
||||
else if(type == "long") {
|
||||
editor.putLong(tokenName, Long.parseLong(data));
|
||||
}
|
||||
else if(type == "string") {
|
||||
editor.putString(tokenName, data);
|
||||
}
|
||||
|
||||
updateDatabaseValue(con,"serverAddr", _serverAddr);
|
||||
updateDatabaseValue(con,"serverPort", _serverPort);
|
||||
updateDatabaseValue(con,"interval", ""+_interval);
|
||||
updateDatabaseValue(con,"agentName", _agentName);
|
||||
updateDatabaseValue(con,"gpsStatus", _gpsStatus);
|
||||
updateDatabaseValue(con,"memoryStatus", _memoryStatus);
|
||||
updateDatabaseValue(con,"taskStatus", _taskStatus);
|
||||
updateDatabaseValue(con,"task", _task);
|
||||
updateDatabaseValue(con,"taskHumanName", _taskHumanName);
|
||||
updateDatabaseValue(con,"simID", _simID);
|
||||
updateDatabaseValue(con,"simIDReport", _simIDReport);
|
||||
updateDatabaseValue(con,"upTime", ""+_upTime);
|
||||
updateDatabaseValue(con,"networkOperator", _networkOperator);
|
||||
updateDatabaseValue(con,"SMSReceived", ""+_smsReceived);
|
||||
updateDatabaseValue(con,"SMSSent", ""+_smsSent);
|
||||
updateDatabaseValue(con,"networkType", _networkType);
|
||||
updateDatabaseValue(con,"phoneType", _phoneType);
|
||||
updateDatabaseValue(con,"signalStrength", ""+_signalStrength);
|
||||
updateDatabaseValue(con,"incomingCalls", ""+_incomingCalls);
|
||||
updateDatabaseValue(con,"missedCalls", ""+_missedCalls);
|
||||
updateDatabaseValue(con,"outgoingCalls", ""+_outgoingCalls);
|
||||
updateDatabaseValue(con,"receiveBytes", ""+_receiveBytes);
|
||||
updateDatabaseValue(con,"transmitBytes", ""+_transmitBytes);
|
||||
updateDatabaseValue(con,"password", _password);
|
||||
updateDatabaseValue(con,"passwordCheck", _passwordCheck);
|
||||
updateDatabaseValue(con,"helloSignal", ""+_helloSignal);
|
||||
updateDatabaseValue(con,"roaming", ""+_roaming);
|
||||
updateDatabaseValue(con,"DeviceUpTimeReport", _DeviceUpTimeReport);
|
||||
updateDatabaseValue(con,"NetworkOperatorReport", _NetworkOperatorReport);
|
||||
updateDatabaseValue(con,"NetworkTypeReport", _NetworkTypeReport);
|
||||
updateDatabaseValue(con,"PhoneTypeReport", _PhoneTypeReport);
|
||||
updateDatabaseValue(con,"SignalStrengthReport", _SignalStrengthReport);
|
||||
updateDatabaseValue(con,"ReceivedSMSReport", _ReceivedSMSReport);
|
||||
updateDatabaseValue(con,"SentSMSReport", _SentSMSReport);
|
||||
updateDatabaseValue(con,"IncomingCallsReport", _IncomingCallsReport);
|
||||
updateDatabaseValue(con,"MissedCallsReport", _MissedCallsReport);
|
||||
updateDatabaseValue(con,"OutgoingCallsReport", _OutgoingCallsReport);
|
||||
updateDatabaseValue(con,"BytesReceivedReport", _BytesReceivedReport);
|
||||
updateDatabaseValue(con,"BytesSentReport", _BytesSentReport);
|
||||
updateDatabaseValue(con,"HelloSignalReport", _HelloSignalReport);
|
||||
updateDatabaseValue(con,"BatteryLevelReport", _BatteryLevelReport);
|
||||
updateDatabaseValue(con,"RoamingReport", _RoamingReport);
|
||||
updateDatabaseValue(con,"InventoryReport", _InventoryReport);
|
||||
updateDatabaseValue(con,"NotificationCheck", _NotificationCheck);
|
||||
updateDatabaseValue(con,"mobileWebURL", _mobileWebURL);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public synchronized static String getSharedData(String preferenceName, String tokenName, String defaultValue, String type) {
|
||||
int mode = Activity.MODE_PRIVATE;
|
||||
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||
|
||||
if(type == "boolean") {
|
||||
boolean a = agentPreferences.getBoolean(tokenName, Boolean.parseBoolean(defaultValue));
|
||||
return Boolean.valueOf(a).toString();
|
||||
}
|
||||
else if(type == "float") {
|
||||
float a = agentPreferences.getFloat(tokenName, Float.parseFloat(defaultValue));
|
||||
return Float.valueOf(a).toString();
|
||||
}
|
||||
else if(type == "integer") {
|
||||
int a = agentPreferences.getInt(tokenName, Integer.parseInt(defaultValue));
|
||||
return Integer.valueOf(a).toString();
|
||||
}
|
||||
else if(type == "long") {
|
||||
long a = agentPreferences.getLong(tokenName, Long.parseLong(defaultValue));
|
||||
return Long.valueOf(a).toString();
|
||||
}
|
||||
else if(type == "string") {
|
||||
return agentPreferences.getString(tokenName, defaultValue);
|
||||
}
|
||||
|
||||
return true;
|
||||
}// end updateConf
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// //Adds a new row "name" with the value "value"
|
||||
// public static void addValue(Context context, String name, String value){
|
||||
// db = new DataBaseHandler(con);
|
||||
// //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 _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;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// updateDatabaseValue(con,"serverAddr", _serverAddr);
|
||||
// updateDatabaseValue(con,"serverPort", _serverPort);
|
||||
// updateDatabaseValue(con,"interval", ""+_interval);
|
||||
// updateDatabaseValue(con,"agentName", _agentName);
|
||||
// updateDatabaseValue(con,"gpsStatus", _gpsStatus);
|
||||
// updateDatabaseValue(con,"memoryStatus", _memoryStatus);
|
||||
// updateDatabaseValue(con,"taskStatus", _taskStatus);
|
||||
// updateDatabaseValue(con,"task", _task);
|
||||
// updateDatabaseValue(con,"taskHumanName", _taskHumanName);
|
||||
// updateDatabaseValue(con,"simID", _simID);
|
||||
// updateDatabaseValue(con,"simIDReport", _simIDReport);
|
||||
// updateDatabaseValue(con,"upTime", ""+_upTime);
|
||||
// updateDatabaseValue(con,"networkOperator", _networkOperator);
|
||||
// updateDatabaseValue(con,"SMSReceived", ""+_smsReceived);
|
||||
// updateDatabaseValue(con,"SMSSent", ""+_smsSent);
|
||||
// updateDatabaseValue(con,"networkType", _networkType);
|
||||
// updateDatabaseValue(con,"phoneType", _phoneType);
|
||||
// updateDatabaseValue(con,"signalStrength", ""+_signalStrength);
|
||||
// updateDatabaseValue(con,"incomingCalls", ""+_incomingCalls);
|
||||
// updateDatabaseValue(con,"missedCalls", ""+_missedCalls);
|
||||
// updateDatabaseValue(con,"outgoingCalls", ""+_outgoingCalls);
|
||||
// updateDatabaseValue(con,"receiveBytes", ""+_receiveBytes);
|
||||
// updateDatabaseValue(con,"transmitBytes", ""+_transmitBytes);
|
||||
// updateDatabaseValue(con,"password", _password);
|
||||
// updateDatabaseValue(con,"passwordCheck", _passwordCheck);
|
||||
// updateDatabaseValue(con,"helloSignal", ""+_helloSignal);
|
||||
// updateDatabaseValue(con,"roaming", ""+_roaming);
|
||||
// updateDatabaseValue(con,"DeviceUpTimeReport", _DeviceUpTimeReport);
|
||||
// updateDatabaseValue(con,"NetworkOperatorReport", _NetworkOperatorReport);
|
||||
// updateDatabaseValue(con,"NetworkTypeReport", _NetworkTypeReport);
|
||||
// updateDatabaseValue(con,"PhoneTypeReport", _PhoneTypeReport);
|
||||
// updateDatabaseValue(con,"SignalStrengthReport", _SignalStrengthReport);
|
||||
// updateDatabaseValue(con,"ReceivedSMSReport", _ReceivedSMSReport);
|
||||
// updateDatabaseValue(con,"SentSMSReport", _SentSMSReport);
|
||||
// updateDatabaseValue(con,"IncomingCallsReport", _IncomingCallsReport);
|
||||
// updateDatabaseValue(con,"MissedCallsReport", _MissedCallsReport);
|
||||
// updateDatabaseValue(con,"OutgoingCallsReport", _OutgoingCallsReport);
|
||||
// updateDatabaseValue(con,"BytesReceivedReport", _BytesReceivedReport);
|
||||
// updateDatabaseValue(con,"BytesSentReport", _BytesSentReport);
|
||||
// updateDatabaseValue(con,"HelloSignalReport", _HelloSignalReport);
|
||||
// updateDatabaseValue(con,"BatteryLevelReport", _BatteryLevelReport);
|
||||
// updateDatabaseValue(con,"RoamingReport", _RoamingReport);
|
||||
// updateDatabaseValue(con,"InventoryReport", _InventoryReport);
|
||||
// updateDatabaseValue(con,"NotificationCheck", _NotificationCheck);
|
||||
// updateDatabaseValue(con,"mobileWebURL", _mobileWebURL);
|
||||
//
|
||||
//
|
||||
// return true;
|
||||
// }// end updateConf
|
||||
//
|
||||
//
|
||||
//
|
||||
//// //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"
|
||||
// public static synchronized void updateDatabaseValue(Context context, String name, String value){
|
||||
// db = new DataBaseHandler(con, "pandroid", null, 1);
|
||||
// //Retrieve id of row to update
|
||||
// int id = getDataHandler(con, name).get_id();
|
||||
//
|
||||
// DataHandler dh = new DataHandler(name, value);
|
||||
// DataHandler dh = new DataHandler(id, name, value);
|
||||
//
|
||||
// db.addValue(dh);
|
||||
// db.updateValue(dh);
|
||||
// }
|
||||
//
|
||||
// //Returns the DataHandler object of the given row "name"
|
||||
// public static synchronized DataHandler getDataHandler(Context context, String name){
|
||||
// db = new DataBaseHandler(con, "pandroid", null, 1);
|
||||
//
|
||||
// return db.getValue(name);
|
||||
// }
|
||||
//
|
||||
// //Returns the value of the given row "name"
|
||||
// public static synchronized String getDatabaseValue(Context context, String name){
|
||||
// db = new DataBaseHandler(con, "pandroid", null, 1);
|
||||
//
|
||||
// return db.getValue(name).get_value();
|
||||
//
|
||||
// }
|
||||
|
||||
//Updates a given row "name" with a "value"
|
||||
public static synchronized void updateDatabaseValue(Context context, String name, String value){
|
||||
db = new DataBaseHandler(con, "pandroid", null, 1);
|
||||
//Retrieve id of row to update
|
||||
int id = getDataHandler(con, name).get_id();
|
||||
|
||||
DataHandler dh = new DataHandler(id, name, value);
|
||||
|
||||
db.updateValue(dh);
|
||||
}
|
||||
|
||||
//Returns the DataHandler object of the given row "name"
|
||||
public static synchronized DataHandler getDataHandler(Context context, String name){
|
||||
db = new DataBaseHandler(con, "pandroid", null, 1);
|
||||
|
||||
return db.getValue(name);
|
||||
}
|
||||
|
||||
//Returns the value of the given row "name"
|
||||
public static synchronized String getDatabaseValue(Context context, String name){
|
||||
db = new DataBaseHandler(con, "pandroid", null, 1);
|
||||
|
||||
return db.getValue(name).get_value();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,16 +16,21 @@ package pandroid.agent;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
//import android.app.Dialog;
|
||||
import android.app.Activity;
|
||||
import android.app.TabActivity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.widget.TabHost;
|
||||
//import android.app.Dialog;
|
||||
//import android.util.Log;
|
||||
//import android.view.WindowManager.LayoutParams;
|
||||
import android.widget.TabHost;
|
||||
|
||||
|
||||
|
||||
public class PandroidAgent extends TabActivity {
|
||||
|
||||
|
@ -33,6 +38,10 @@ public class PandroidAgent extends TabActivity {
|
|||
int defaultInterval = 300;
|
||||
TabHost tabHost;
|
||||
|
||||
static SharedPreferences agentPreferences;
|
||||
static Editor editor;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -40,9 +49,15 @@ public class PandroidAgent extends TabActivity {
|
|||
//database//
|
||||
|
||||
|
||||
Core.loadConfDatabase(this);
|
||||
Core.loadLastValuesDatabase(this);
|
||||
agentPreferences = this.getSharedPreferences(
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
editor = agentPreferences.edit();
|
||||
|
||||
//Core.loadConfDatabase(this);
|
||||
//Core.loadLastValuesDatabase(this);
|
||||
//Core.updateConf(this);
|
||||
|
||||
/*
|
||||
final Dialog dialog = new Dialog(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
|
||||
|
@ -106,13 +121,13 @@ public class PandroidAgent extends TabActivity {
|
|||
public void onPause(){
|
||||
super.onPause();
|
||||
Core.updateConf(getApplicationContext());
|
||||
Core.updateDatabase(this);
|
||||
//Core.updateDatabase(this);
|
||||
}
|
||||
|
||||
public void onDestroy(){
|
||||
super.onDestroy();
|
||||
Core.updateConf(getApplicationContext());
|
||||
Core.updateDatabase(this);
|
||||
//Core.updateDatabase(this);
|
||||
|
||||
}
|
||||
//Sets hello signal to 1(first connect since pandroid was closed)
|
||||
|
@ -127,5 +142,17 @@ public class PandroidAgent extends TabActivity {
|
|||
// Called from activity to allow tab switching
|
||||
public void switchTab(int tab){
|
||||
tabHost.setCurrentTab(tab);
|
||||
}
|
||||
}
|
||||
|
||||
public static SharedPreferences getSharedPrefs() {
|
||||
// TODO Auto-generated method stub
|
||||
return agentPreferences;
|
||||
}
|
||||
|
||||
public static Editor getEditor() {
|
||||
// TODO Auto-generated method stub
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -13,7 +13,6 @@
|
|||
// GNU General Public License for more details.
|
||||
package pandroid.agent;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -23,10 +22,10 @@ import java.text.DecimalFormat;
|
|||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.MemoryInfo;
|
||||
import android.app.ActivityManager.RunningAppProcessInfo;
|
||||
|
@ -37,7 +36,6 @@ import android.app.Service;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
|
@ -59,6 +57,8 @@ import android.telephony.PhoneStateListener;
|
|||
import android.telephony.SignalStrength;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class PandroidAgentListener extends Service {
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class PandroidAgentListener extends Service {
|
|||
} catch (Exception e) {
|
||||
Log.e("notification", e.toString());
|
||||
}
|
||||
Log.v("MARK","notif"+Core.NotificationCheck);
|
||||
|
||||
if(Core.NotificationCheck == "enabled"){
|
||||
|
||||
Notification notification = new Notification(R.drawable.icon, getText(R.string.ticker_text),
|
||||
|
@ -114,55 +114,55 @@ public class PandroidAgentListener extends Service {
|
|||
|
||||
|
||||
|
||||
private void contact(){
|
||||
Date date = new Date();
|
||||
|
||||
putSharedData("PANDROID_DATA", "contactError", "0", "integer");
|
||||
putSharedData("PANDROID_DATA", "lastContact", Long.toString(date.getTime() / 1000), "long");
|
||||
|
||||
// Keep lastXML sended if is not empty (empty means error sending it)
|
||||
String lastXML = buildXML();
|
||||
|
||||
|
||||
String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||
|
||||
String destFileName = agentName + "." + System.currentTimeMillis() + ".data";
|
||||
|
||||
writeFile(destFileName, lastXML);
|
||||
|
||||
String[] tentacleData = {
|
||||
"-a",
|
||||
getSharedData("PANDROID_DATA", "serverAddr", "", "string"),
|
||||
"-p",
|
||||
Core.defaultServerPort,
|
||||
"-v",
|
||||
"/data/data/pandroid.agent/files/" + destFileName
|
||||
};
|
||||
|
||||
int tentacleRet = new tentacle_client().tentacle_client(tentacleData);
|
||||
|
||||
// Deleting the file after send it
|
||||
File file = new File("/data/data/pandroid.agent/files/" + destFileName);
|
||||
file.delete();
|
||||
|
||||
if(tentacleRet == 0) {
|
||||
putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
|
||||
if (Core.helloSignal >= 1)
|
||||
Core.helloSignal = 0;
|
||||
Core.updateConf(getApplicationContext());
|
||||
}
|
||||
else {
|
||||
putSharedData("PANDROID_DATA", "contactError", "1", "integer");
|
||||
}
|
||||
|
||||
updateValues();
|
||||
}
|
||||
// private void contact(){
|
||||
// Date date = new Date();
|
||||
//
|
||||
// Core.putSharedData("PANDROID_DATA", "contactError", "0", "integer");
|
||||
// Core.putSharedData("PANDROID_DATA", "lastContact", Long.toString(date.getTime() / 1000), "long");
|
||||
//
|
||||
// // Keep lastXML sended if is not empty (empty means error sending it)
|
||||
// String lastXML = buildXML();
|
||||
//
|
||||
//
|
||||
// String agentName = Core.getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||
//
|
||||
// String destFileName = agentName + "." + System.currentTimeMillis() + ".data";
|
||||
//
|
||||
// writeFile(destFileName, lastXML);
|
||||
//
|
||||
// String[] tentacleData = {
|
||||
// "-a",
|
||||
// Core.getSharedData("PANDROID_DATA", "serverAddr", "", "string"),
|
||||
// "-p",
|
||||
// Core.defaultServerPort,
|
||||
// "-v",
|
||||
// "/data/data/pandroid.agent/files/" + destFileName
|
||||
// };
|
||||
//
|
||||
// int tentacleRet = new tentacle_client().tentacle_client(tentacleData);
|
||||
//
|
||||
// // Deleting the file after send it
|
||||
// File file = new File("/data/data/pandroid.agent/files/" + destFileName);
|
||||
// file.delete();
|
||||
//
|
||||
// if(tentacleRet == 0) {
|
||||
// Core.putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
|
||||
// if (Core.helloSignal >= 1)
|
||||
// Core.helloSignal = 0;
|
||||
// Core.updateConf(getApplicationContext());
|
||||
// }
|
||||
// else {
|
||||
// Core.putSharedData("PANDROID_DATA", "contactError", "1", "integer");
|
||||
// }
|
||||
//
|
||||
// updateValues();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
/*
|
||||
private void contact(){
|
||||
|
||||
/*
|
||||
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
|
||||
getString(R.string.loading),
|
||||
|
@ -174,57 +174,119 @@ public class PandroidAgentListener extends Service {
|
|||
|
||||
Date date = new Date();
|
||||
|
||||
putSharedData("PANDROID_DATA", "lastContact", Long.toString(date.getTime() / 1000), "long");
|
||||
Core.putSharedData("PANDROID_DATA", "lastContact", Long.toString(date.getTime() / 1000), "long");
|
||||
Boolean xmlBuilt = true;
|
||||
String xml = "";
|
||||
|
||||
String lastXML = "";
|
||||
new contactTask().execute(lastXML);
|
||||
try {
|
||||
xml = new buildXMLTask().execute().get();
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
xmlBuilt = false;
|
||||
} catch (ExecutionException e) {
|
||||
// TODO Auto-generated catch block
|
||||
xmlBuilt = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
new contactTask().execute(xml);
|
||||
updateValues();
|
||||
|
||||
}//end contact
|
||||
|
||||
|
||||
|
||||
private class contactTask extends AsyncTask<String, Void, Void>{
|
||||
|
||||
private class contactTask extends AsyncTask<String, Void, Integer>{
|
||||
String destFileName = "";
|
||||
|
||||
@Override
|
||||
protected void onPreExecute(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(String...params) {
|
||||
protected Integer doInBackground(String... lastXML) {
|
||||
|
||||
|
||||
//Check for files
|
||||
|
||||
String[] buffer = getApplicationContext().fileList();
|
||||
// for(int i = 0; i<buffer.length; i++){
|
||||
// Log.d("buffer", buffer[i]);
|
||||
// }
|
||||
Integer tentacleRet = null;
|
||||
//files in buffer
|
||||
boolean contact = true;
|
||||
int i = 1;
|
||||
while(getApplicationContext().fileList().length > 1 && contact) {
|
||||
|
||||
String lastXML = params[0];
|
||||
lastXML = buildXML();
|
||||
String destFileName = "";
|
||||
String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||
destFileName = agentName + "." + System.currentTimeMillis() + ".data";
|
||||
destFileName = buffer[i];
|
||||
|
||||
String[] tentacleData = {
|
||||
"-a",
|
||||
Core.getSharedData("PANDROID_DATA", "serverAddr", "", "string"),
|
||||
"-p",
|
||||
Core.defaultServerPort,
|
||||
"-v",
|
||||
"/data/data/pandroid.agent/files/" + destFileName
|
||||
};
|
||||
|
||||
|
||||
tentacleRet = new tentacle_client().tentacle_client(tentacleData);
|
||||
|
||||
if(tentacleRet == 0) {
|
||||
Core.putSharedData("PANDROID_DATA", "contactError", "0", "integer");
|
||||
// Deleting the file after send it
|
||||
// move to only delete if sent successfully
|
||||
File file = new File("/data/data/pandroid.agent/files/" + destFileName);
|
||||
file.delete();
|
||||
if (Core.helloSignal >= 1)
|
||||
Core.helloSignal = 0;
|
||||
Core.updateConf(getApplicationContext());
|
||||
|
||||
}
|
||||
if(tentacleRet == -1){
|
||||
//file not deleted
|
||||
Core.putSharedData("PANDROID_DATA", "contactError", "1", "integer");
|
||||
contact = false;
|
||||
}
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
return tentacleRet;
|
||||
|
||||
writeFile(destFileName, lastXML);
|
||||
String[] tentacleData = {
|
||||
"-a",
|
||||
getSharedData("PANDROID_DATA", "serverAddr", "", "string"),
|
||||
"-p",
|
||||
Core.defaultServerPort,
|
||||
"-v",
|
||||
"/data/data/pandroid.agent/files/" + destFileName
|
||||
};
|
||||
|
||||
int tentacleRet = new tentacle_client().tentacle_client(tentacleData);
|
||||
}//end doInBackground
|
||||
|
||||
putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
|
||||
if(tentacleRet == 0) {
|
||||
putSharedData("PANDROID_DATA", "contactError", "0", "integer");
|
||||
// Deleting the file after send it
|
||||
// move to only delete if sent successfully
|
||||
File file = new File("/data/data/pandroid.agent/files/" + destFileName);
|
||||
file.delete();
|
||||
if (Core.helloSignal >= 1)
|
||||
Core.helloSignal = 0;
|
||||
Core.updateConf(getApplicationContext());
|
||||
}
|
||||
else{
|
||||
putSharedData("PANDROID_DATA", "contactError", "1", "integer");
|
||||
}
|
||||
return null;
|
||||
|
||||
}//end doInBackground
|
||||
}
|
||||
*/
|
||||
|
||||
private class buildXMLTask extends AsyncTask<Void, Void, String>{
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... v) {
|
||||
|
||||
String lastXML = buildXML();
|
||||
|
||||
String destFileName = "";
|
||||
String agentName = Core.getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||
destFileName = agentName + "." + System.currentTimeMillis() + ".data";
|
||||
|
||||
|
||||
//Check if number of files is less than a value
|
||||
if(getApplicationContext().fileList().length < 100){
|
||||
writeFile(destFileName, lastXML);
|
||||
Core.putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
|
||||
}else{
|
||||
//buffer full
|
||||
}
|
||||
Core.putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
|
||||
|
||||
return lastXML;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// From unfinished task of buffering unsent xml files when no connection available //
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -257,15 +319,15 @@ public class PandroidAgentListener extends Service {
|
|||
String gpsData = "";
|
||||
buffer += "<?xml version='1.0' encoding='iso-8859-1'?>\n";
|
||||
|
||||
String latitude = getSharedData("PANDROID_DATA", "latitude", "181", "float");
|
||||
String longitude = getSharedData("PANDROID_DATA", "longitude", "181", "float");
|
||||
String latitude = Core.getSharedData("PANDROID_DATA", "latitude", "181", "float");
|
||||
String longitude = Core.getSharedData("PANDROID_DATA", "longitude", "181", "float");
|
||||
|
||||
if(!latitude.equals("181.0") && !longitude.equals("181.0")) {
|
||||
gpsData = " latitude='" + latitude + "' longitude='" + longitude + "'";
|
||||
}
|
||||
|
||||
String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||
String interval = getSharedData("PANDROID_DATA", "interval", Integer.toString(Core.defaultInterval), "integer");
|
||||
String agentName = Core.getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||
String interval = Core.getSharedData("PANDROID_DATA", "interval", Integer.toString(Core.defaultInterval), "integer");
|
||||
|
||||
buffer += "<agent_data " +
|
||||
"description='' group='' os_name='android' os_version='"+Build.VERSION.RELEASE+"' " +
|
||||
|
@ -277,51 +339,51 @@ public class PandroidAgentListener extends Service {
|
|||
// MODULES //
|
||||
// //
|
||||
|
||||
String orientation = getSharedData("PANDROID_DATA", "orientation", "361", "float");
|
||||
String proximity = getSharedData("PANDROID_DATA", "proximity", "-1.0", "float");
|
||||
String batteryLevel = getSharedData("PANDROID_DATA", "batteryLevel", "-1", "integer");
|
||||
String taskStatus = getSharedData("PANDROID_DATA", "taskStatus", "disabled", "string");
|
||||
String taskRun = getSharedData("PANDROID_DATA", "taskRun", "false", "string");
|
||||
String taskHumanName = getSharedData("PANDROID_DATA", "taskHumanName", "", "string");
|
||||
String orientation = Core.getSharedData("PANDROID_DATA", "orientation", "361", "float");
|
||||
String proximity = Core.getSharedData("PANDROID_DATA", "proximity", "-1.0", "float");
|
||||
String batteryLevel = Core.getSharedData("PANDROID_DATA", "batteryLevel", "-1", "integer");
|
||||
String taskStatus = Core.getSharedData("PANDROID_DATA", "taskStatus", "disabled", "string");
|
||||
String taskRun = Core.getSharedData("PANDROID_DATA", "taskRun", "false", "string");
|
||||
String taskHumanName = Core.getSharedData("PANDROID_DATA", "taskHumanName", "", "string");
|
||||
taskHumanName = StringEscapeUtils.escapeHtml4(taskHumanName);
|
||||
|
||||
String task = getSharedData("PANDROID_DATA", "task", "", "string");
|
||||
String memoryStatus = getSharedData("PANDROID_DATA", "memoryStatus", Core.defaultMemoryStatus, "string");
|
||||
String availableRamKb = getSharedData("PANDROID_DATA", "availableRamKb", "0" , "long");
|
||||
String totalRamKb = getSharedData("PANDROID_DATA", "totalRamKb", "0", "long");
|
||||
String SimID = getSharedData("PANDROID_DATA", "simID", Core.defaultSimID, "string");
|
||||
String upTime = getSharedData("PANDROID_DATA", "upTime", ""+Core.defaultUpTime, "long");
|
||||
String networkOperator = getSharedData("PANDROID_DATA", "networkOperator", Core.defaultNetworkOperator, "string");
|
||||
String SMSReceived = getSharedData("PANDROID_DATA", "SMSReceived", ""+Core.defaultSMSReceived, "integer");
|
||||
String SMSSent = getSharedData("PANDROID_DATA", "SMSSent", ""+Core.defaultSMSSent, "integer");
|
||||
String networkType = getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
|
||||
String phoneType = getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
|
||||
String signalStrength = getSharedData("PANDROID_DATA", "signalStrength", ""+Core.defaultSignalStrength, "integer");
|
||||
String incomingCalls = getSharedData("PANDROID_DATA", "incomingCalls", ""+Core.defaultIncomingCalls, "integer");
|
||||
String missedCalls = getSharedData("PANDROID_DATA", "missedCalls", ""+Core.defaultMissedCalls, "integer");
|
||||
String outgoingCalls = getSharedData("PANDROID_DATA", "outgoingCalls", ""+Core.defaultOutgoingCalls, "integer");
|
||||
String receiveBytes = getSharedData("PANDROID_DATA", "receiveBytes", ""+Core.defaultReceiveBytes, "long");
|
||||
String transmitBytes = getSharedData("PANDROID_DATA", "transmitBytes", ""+Core.defaultTransmitBytes, "long");
|
||||
String helloSignal = getSharedData("PANDROID_DATA", "helloSignal", ""+Core.defaultHelloSignal, "integer");
|
||||
String roaming = getSharedData("PANDROID_DATA", "roaming", ""+Core.defaultRoaming, "integer");
|
||||
String task = Core.getSharedData("PANDROID_DATA", "task", "", "string");
|
||||
String memoryStatus = Core.getSharedData("PANDROID_DATA", "memoryStatus", Core.defaultMemoryStatus, "string");
|
||||
String availableRamKb = Core.getSharedData("PANDROID_DATA", "availableRamKb", "0" , "long");
|
||||
String totalRamKb = Core.getSharedData("PANDROID_DATA", "totalRamKb", "0", "long");
|
||||
String SimID = Core.getSharedData("PANDROID_DATA", "simID", Core.defaultSimID, "string");
|
||||
String upTime = Core.getSharedData("PANDROID_DATA", "upTime", ""+Core.defaultUpTime, "long");
|
||||
String networkOperator = Core.getSharedData("PANDROID_DATA", "networkOperator", Core.defaultNetworkOperator, "string");
|
||||
String SMSReceived = Core.getSharedData("PANDROID_DATA", "SMSReceived", ""+Core.defaultSMSReceived, "integer");
|
||||
String SMSSent = Core.getSharedData("PANDROID_DATA", "SMSSent", ""+Core.defaultSMSSent, "integer");
|
||||
String networkType = Core.getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
|
||||
String phoneType = Core.getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
|
||||
String signalStrength = Core.getSharedData("PANDROID_DATA", "signalStrength", ""+Core.defaultSignalStrength, "integer");
|
||||
String incomingCalls = Core.getSharedData("PANDROID_DATA", "incomingCalls", ""+Core.defaultIncomingCalls, "integer");
|
||||
String missedCalls = Core.getSharedData("PANDROID_DATA", "missedCalls", ""+Core.defaultMissedCalls, "integer");
|
||||
String outgoingCalls = Core.getSharedData("PANDROID_DATA", "outgoingCalls", ""+Core.defaultOutgoingCalls, "integer");
|
||||
String receiveBytes = Core.getSharedData("PANDROID_DATA", "receiveBytes", ""+Core.defaultReceiveBytes, "long");
|
||||
String transmitBytes = Core.getSharedData("PANDROID_DATA", "transmitBytes", ""+Core.defaultTransmitBytes, "long");
|
||||
String helloSignal = Core.getSharedData("PANDROID_DATA", "helloSignal", ""+Core.defaultHelloSignal, "integer");
|
||||
String roaming = Core.getSharedData("PANDROID_DATA", "roaming", ""+Core.defaultRoaming, "integer");
|
||||
|
||||
String simIDReport = getSharedData("PANDROID_DATA", "simIDReport", Core.defaultSimIDReport, "string");
|
||||
String DeviceUpTimeReport = getSharedData("PANDROID_DATA", "DeviceUpTimeReport", Core.defaultDeviceUpTimeReport, "string");
|
||||
String NetworkOperatorReport = getSharedData("PANDROID_DATA", "NetworkOperatorReport", Core.defaultNetworkOperatorReport, "string");
|
||||
String NetworkTypeReport = getSharedData("PANDROID_DATA", "NetworkTypeReport", Core.defaultNetworkTypeReport, "string");
|
||||
String PhoneTypeReport = getSharedData("PANDROID_DATA", "PhoneTypeReport", Core.defaultPhoneTypeReport, "string");
|
||||
String SignalStrengthReport = getSharedData("PANDROID_DATA", "SignalStrengthReport", Core.defaultSignalStrengthReport, "string");
|
||||
String ReceivedSMSReport = getSharedData("PANDROID_DATA", "ReceivedSMSReport", Core.defaultReceivedSMSReport, "string");
|
||||
String SentSMSReport = getSharedData("PANDROID_DATA", "SentSMSReport", Core.defaultSentSMSReport, "string");
|
||||
String IncomingCallsReport = getSharedData("PANDROID_DATA", "IncomingCallsReport", Core.defaultIncomingCallsReport, "string");
|
||||
String MissedCallsReport = getSharedData("PANDROID_DATA", "MissedCallsReport", Core.defaultMissedCallsReport, "string");
|
||||
String OutgoingCallsReport = getSharedData("PANDROID_DATA", "OutgoingCallsReport", Core.defaultOutgoingCallsReport, "string");
|
||||
String BytesReceivedReport = getSharedData("PANDROID_DATA", "BytesReceivedReport", Core.defaultBytesReceivedReport, "string");
|
||||
String BytesSentReport = getSharedData("PANDROID_DATA", "BytesSentReport", Core.defaultBytesSentReport, "string");
|
||||
String HelloSignalReport = getSharedData("PANDROID_DATA", "HelloSignalReport", Core.defaultHelloSignalReport, "string");
|
||||
String BatteryLevelReport = getSharedData("PANDROID_DATA", "BatteryLevelReport", Core.defaultBatteryLevelReport, "string");
|
||||
String RoamingReport = getSharedData("PANDROID_DATA", "RoamingReport", Core.defaultRoamingReport, "string");
|
||||
String InventoryReport = getSharedData("PANDROID_DATA", "InventoryReport", Core.defaultInventoryReport, "string");
|
||||
String simIDReport = Core.getSharedData("PANDROID_DATA", "simIDReport", Core.defaultSimIDReport, "string");
|
||||
String DeviceUpTimeReport = Core.getSharedData("PANDROID_DATA", "DeviceUpTimeReport", Core.defaultDeviceUpTimeReport, "string");
|
||||
String NetworkOperatorReport = Core.getSharedData("PANDROID_DATA", "NetworkOperatorReport", Core.defaultNetworkOperatorReport, "string");
|
||||
String NetworkTypeReport = Core.getSharedData("PANDROID_DATA", "NetworkTypeReport", Core.defaultNetworkTypeReport, "string");
|
||||
String PhoneTypeReport = Core.getSharedData("PANDROID_DATA", "PhoneTypeReport", Core.defaultPhoneTypeReport, "string");
|
||||
String SignalStrengthReport = Core.getSharedData("PANDROID_DATA", "SignalStrengthReport", Core.defaultSignalStrengthReport, "string");
|
||||
String ReceivedSMSReport = Core.getSharedData("PANDROID_DATA", "ReceivedSMSReport", Core.defaultReceivedSMSReport, "string");
|
||||
String SentSMSReport = Core.getSharedData("PANDROID_DATA", "SentSMSReport", Core.defaultSentSMSReport, "string");
|
||||
String IncomingCallsReport = Core.getSharedData("PANDROID_DATA", "IncomingCallsReport", Core.defaultIncomingCallsReport, "string");
|
||||
String MissedCallsReport = Core.getSharedData("PANDROID_DATA", "MissedCallsReport", Core.defaultMissedCallsReport, "string");
|
||||
String OutgoingCallsReport = Core.getSharedData("PANDROID_DATA", "OutgoingCallsReport", Core.defaultOutgoingCallsReport, "string");
|
||||
String BytesReceivedReport = Core.getSharedData("PANDROID_DATA", "BytesReceivedReport", Core.defaultBytesReceivedReport, "string");
|
||||
String BytesSentReport = Core.getSharedData("PANDROID_DATA", "BytesSentReport", Core.defaultBytesSentReport, "string");
|
||||
String HelloSignalReport = Core.getSharedData("PANDROID_DATA", "HelloSignalReport", Core.defaultHelloSignalReport, "string");
|
||||
String BatteryLevelReport = Core.getSharedData("PANDROID_DATA", "BatteryLevelReport", Core.defaultBatteryLevelReport, "string");
|
||||
String RoamingReport = Core.getSharedData("PANDROID_DATA", "RoamingReport", Core.defaultRoamingReport, "string");
|
||||
String InventoryReport = Core.getSharedData("PANDROID_DATA", "InventoryReport", Core.defaultInventoryReport, "string");
|
||||
|
||||
if(InventoryReport.equals("enabled"))
|
||||
{
|
||||
|
@ -396,9 +458,9 @@ public class PandroidAgentListener extends Service {
|
|||
|
||||
//UTF-8 TEST//
|
||||
|
||||
String iso_8859_1String = "ÀÁÈÉÌÍÙÚÜàáèéìíòóùúü";
|
||||
//String iso_8859_1String = "ÀÁÈÉÌÍÙÚÜàáèéìíòóùúü";
|
||||
|
||||
buffer += buildmoduleXML("iso-8859-1Test","Testing iso-8859-1 Values", "generic_data_string", iso_8859_1String);
|
||||
//buffer += buildmoduleXML("iso-8859-1Test","Testing iso-8859-1 Values", "generic_data_string", iso_8859_1String);
|
||||
|
||||
|
||||
// End_Modules
|
||||
|
@ -506,8 +568,8 @@ public class PandroidAgentListener extends Service {
|
|||
//if(latitude != loc.getLatitude() || longitude != loc.getLongitude()) {
|
||||
lastGpsContactDateTime = getHumanDateTime(-1);
|
||||
//}
|
||||
putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
|
||||
putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
|
||||
Core.putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
|
||||
Core.putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
|
||||
}
|
||||
else {
|
||||
Criteria criteria = new Criteria();
|
||||
|
@ -527,9 +589,9 @@ public class PandroidAgentListener extends Service {
|
|||
lm.requestLocationUpdates(bestProvider, Core.defaultInterval, 1000,
|
||||
new LocationListener() {
|
||||
public void onLocationChanged(Location location) {
|
||||
putSharedData("PANDROID_DATA", "latitude",
|
||||
Core.putSharedData("PANDROID_DATA", "latitude",
|
||||
Double.valueOf(location.getLatitude()).toString(), "float");
|
||||
putSharedData("PANDROID_DATA", "longitude",
|
||||
Core.putSharedData("PANDROID_DATA", "longitude",
|
||||
Double.valueOf(location.getLongitude()).toString(), "float");
|
||||
}
|
||||
public void onStatusChanged(String s, int i, Bundle bundle) {
|
||||
|
@ -539,7 +601,7 @@ public class PandroidAgentListener extends Service {
|
|||
// try switching to a different provider
|
||||
}
|
||||
public void onProviderDisabled(String s) {
|
||||
putSharedData("PANDROID_DATA", "enabled_location_provider",
|
||||
Core.putSharedData("PANDROID_DATA", "enabled_location_provider",
|
||||
"disabled", "string");
|
||||
}
|
||||
});
|
||||
|
@ -554,7 +616,7 @@ public class PandroidAgentListener extends Service {
|
|||
int scale = batteryIntent.getIntExtra("scale", -1);
|
||||
//double level = -1;
|
||||
if (rawlevel >= 0 && scale > 0) {
|
||||
putSharedData("PANDROID_DATA", "batteryLevel", Integer.valueOf((rawlevel * 100) / scale).toString(), "integer");
|
||||
Core.putSharedData("PANDROID_DATA", "batteryLevel", Integer.valueOf((rawlevel * 100) / scale).toString(), "integer");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -563,7 +625,7 @@ public class PandroidAgentListener extends Service {
|
|||
|
||||
SensorEventListener orientationLevelReceiver = new SensorEventListener() {
|
||||
public void onSensorChanged(SensorEvent sensorEvent) {
|
||||
putSharedData("PANDROID_DATA", "orientation", Float.toString(sensorEvent.values[0]), "float");
|
||||
Core.putSharedData("PANDROID_DATA", "orientation", Float.toString(sensorEvent.values[0]), "float");
|
||||
}
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
}
|
||||
|
@ -571,7 +633,7 @@ public class PandroidAgentListener extends Service {
|
|||
|
||||
SensorEventListener proximityLevelReceiver = new SensorEventListener() {
|
||||
public void onSensorChanged(SensorEvent sensorEvent) {
|
||||
putSharedData("PANDROID_DATA", "proximity", Float.toString(sensorEvent.values[0]), "float");
|
||||
Core.putSharedData("PANDROID_DATA", "proximity", Float.toString(sensorEvent.values[0]), "float");
|
||||
}
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
}
|
||||
|
@ -621,7 +683,7 @@ public class PandroidAgentListener extends Service {
|
|||
private void updateValues() {
|
||||
|
||||
batteryLevel();
|
||||
String gpsStatus = getSharedData("PANDROID_DATA", "gpsStatus", Core.defaultGpsStatus, "string");
|
||||
String gpsStatus = Core.getSharedData("PANDROID_DATA", "gpsStatus", Core.defaultGpsStatus, "string");
|
||||
|
||||
if(gpsStatus.equals("enabled")) {
|
||||
Log.d("PANDROID AGENT", "ENABLED");
|
||||
|
@ -629,8 +691,8 @@ public class PandroidAgentListener extends Service {
|
|||
}
|
||||
else {
|
||||
Log.d("PANDROID AGENT", "DISABLED");
|
||||
putSharedData("PANDROID_DATA", "latitude", "181.0", "float");
|
||||
putSharedData("PANDROID_DATA", "longitude", "181.0", "float");
|
||||
Core.putSharedData("PANDROID_DATA", "latitude", "181.0", "float");
|
||||
Core.putSharedData("PANDROID_DATA", "longitude", "181.0", "float");
|
||||
}
|
||||
|
||||
//sensors();
|
||||
|
@ -653,7 +715,7 @@ public class PandroidAgentListener extends Service {
|
|||
}
|
||||
|
||||
private void getMemoryStatus() {
|
||||
String memoryStatus = getSharedData("PANDROID_DATA", "memoryStatus", Core.defaultMemoryStatus, "string");
|
||||
String memoryStatus = Core.getSharedData("PANDROID_DATA", "memoryStatus", Core.defaultMemoryStatus, "string");
|
||||
long availableRamKb = 0;
|
||||
long totalRamKb = 0;
|
||||
|
||||
|
@ -679,14 +741,14 @@ public class PandroidAgentListener extends Service {
|
|||
}
|
||||
}
|
||||
|
||||
putSharedData("PANDROID_DATA", "availableRamKb", "" + availableRamKb, "long");
|
||||
putSharedData("PANDROID_DATA", "totalRamKb", "" + totalRamKb, "long");
|
||||
Core.putSharedData("PANDROID_DATA", "availableRamKb", "" + availableRamKb, "long");
|
||||
Core.putSharedData("PANDROID_DATA", "totalRamKb", "" + totalRamKb, "long");
|
||||
}// end getMemoryStatus
|
||||
|
||||
private void getTaskStatus() {
|
||||
String taskStatus = getSharedData("PANDROID_DATA", "taskStatus", Core.defaultTaskStatus, "string");
|
||||
String task = getSharedData("PANDROID_DATA", "task", Core.defaultTask, "string");
|
||||
String taskHumanName = getSharedData("PANDROID_DATA", "taskHumanName", Core.defaultTaskHumanName, "string");
|
||||
String taskStatus = Core.getSharedData("PANDROID_DATA", "taskStatus", Core.defaultTaskStatus, "string");
|
||||
String task = Core.getSharedData("PANDROID_DATA", "task", Core.defaultTask, "string");
|
||||
String taskHumanName = Core.getSharedData("PANDROID_DATA", "taskHumanName", Core.defaultTaskHumanName, "string");
|
||||
String run = "false";
|
||||
|
||||
if (taskStatus.equals("enabled")) {
|
||||
|
@ -706,7 +768,7 @@ public class PandroidAgentListener extends Service {
|
|||
}
|
||||
}
|
||||
}
|
||||
putSharedData("PANDROID_DATA", "taskRun", run, "string");
|
||||
Core.putSharedData("PANDROID_DATA", "taskRun", run, "string");
|
||||
}//end getTaskStatus
|
||||
|
||||
/**
|
||||
|
@ -714,12 +776,12 @@ public class PandroidAgentListener extends Service {
|
|||
*/
|
||||
private void getSimID(){
|
||||
|
||||
String simID = getSharedData("PANDROID_DATA", "simID", Core.defaultSimID, "string");
|
||||
String simID = Core.getSharedData("PANDROID_DATA", "simID", Core.defaultSimID, "string");
|
||||
|
||||
String serviceName = Context.TELEPHONY_SERVICE;
|
||||
TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService(serviceName);
|
||||
simID = telephonyManager.getSimSerialNumber();
|
||||
putSharedData("PANDROID_DATA", "simID", simID, "string");
|
||||
Core.putSharedData("PANDROID_DATA", "simID", simID, "string");
|
||||
}
|
||||
/**
|
||||
* Retrieves the time in seconds since the device was switched on
|
||||
|
@ -728,7 +790,7 @@ public class PandroidAgentListener extends Service {
|
|||
long upTime = Core.defaultUpTime;
|
||||
upTime = SystemClock.elapsedRealtime()/1000;
|
||||
if(upTime != 0)
|
||||
putSharedData("PANDROID_DATA", "upTime", ""+upTime, "long");
|
||||
Core.putSharedData("PANDROID_DATA", "upTime", ""+upTime, "long");
|
||||
}
|
||||
/**
|
||||
* Retrieve currently registered network operator, i.e. vodafone, movistar, etc...
|
||||
|
@ -740,7 +802,7 @@ public class PandroidAgentListener extends Service {
|
|||
networkOperator = telephonyManager.getNetworkOperatorName();
|
||||
|
||||
if(networkOperator != null)
|
||||
putSharedData("PANDROID_DATA", "networkOperator", networkOperator, "string");
|
||||
Core.putSharedData("PANDROID_DATA", "networkOperator", networkOperator, "string");
|
||||
}
|
||||
/**
|
||||
* Retrieves the number of sent sms messages using the android messaging app only
|
||||
|
@ -748,7 +810,7 @@ public class PandroidAgentListener extends Service {
|
|||
private void getSMSSent(){
|
||||
|
||||
String SMSSent = ""+Core.defaultSMSSent;
|
||||
SMSSent = getSharedData("PANDROID_DATA", "SMSSent", ""+Core.defaultSMSSent, "integer");
|
||||
SMSSent = Core.getSharedData("PANDROID_DATA", "SMSSent", ""+Core.defaultSMSSent, "integer");
|
||||
Uri allMessages = Uri.parse("content://sms/sent");
|
||||
Cursor c = getContentResolver().query(allMessages, null, null, null, null);
|
||||
int totalMessages = 0;
|
||||
|
@ -767,7 +829,7 @@ public class PandroidAgentListener extends Service {
|
|||
SMSSent =""+ totalMessages;
|
||||
|
||||
if(SMSSent != null)
|
||||
putSharedData("PANDROID_DATA", "SMSSent", SMSSent, "integer");
|
||||
Core.putSharedData("PANDROID_DATA", "SMSSent", SMSSent, "integer");
|
||||
|
||||
}// end getSMSSent
|
||||
/**
|
||||
|
@ -831,7 +893,7 @@ public class PandroidAgentListener extends Service {
|
|||
break;
|
||||
}
|
||||
if(networkType != null)
|
||||
putSharedData("PANDROID_DATA", "networkType", networkType, "string");
|
||||
Core.putSharedData("PANDROID_DATA", "networkType", networkType, "string");
|
||||
|
||||
}// end getNetworkType
|
||||
|
||||
|
@ -860,7 +922,7 @@ public class PandroidAgentListener extends Service {
|
|||
break;
|
||||
}
|
||||
if(phoneType != null)
|
||||
putSharedData("PANDROID_DATA", "phoneType", phoneType, "string");
|
||||
Core.putSharedData("PANDROID_DATA", "phoneType", phoneType, "string");
|
||||
}// end getPhoneType
|
||||
|
||||
/**
|
||||
|
@ -894,9 +956,9 @@ public class PandroidAgentListener extends Service {
|
|||
c.moveToNext();
|
||||
}
|
||||
|
||||
putSharedData("PANDROID_DATA", "incomingCalls", ""+incoming, "integer");
|
||||
putSharedData("PANDROID_DATA", "missedCalls", ""+missed, "integer");
|
||||
putSharedData("PANDROID_DATA", "outgoingCalls", ""+outgoing, "integer");
|
||||
Core.putSharedData("PANDROID_DATA", "incomingCalls", ""+incoming, "integer");
|
||||
Core.putSharedData("PANDROID_DATA", "missedCalls", ""+missed, "integer");
|
||||
Core.putSharedData("PANDROID_DATA", "outgoingCalls", ""+outgoing, "integer");
|
||||
}
|
||||
|
||||
c.close();
|
||||
|
@ -927,7 +989,7 @@ public class PandroidAgentListener extends Service {
|
|||
else{
|
||||
signalStrengthValue ="" + (signalStrength.getCdmaDbm());
|
||||
}
|
||||
putSharedData("PANDROID_DATA", "signalStrength", signalStrengthValue, "integer");
|
||||
Core.putSharedData("PANDROID_DATA", "signalStrength", signalStrengthValue, "integer");
|
||||
}
|
||||
};
|
||||
/**
|
||||
|
@ -941,8 +1003,8 @@ public class PandroidAgentListener extends Service {
|
|||
|
||||
if (receiveBytes != TrafficStats.UNSUPPORTED && transmitBytes != TrafficStats.UNSUPPORTED)
|
||||
{
|
||||
putSharedData("PANDROID_DATA", "receiveBytes", ""+receiveBytes, "long" );
|
||||
putSharedData("PANDROID_DATA", "transmitBytes", ""+transmitBytes, "long" );
|
||||
Core.putSharedData("PANDROID_DATA", "receiveBytes", ""+receiveBytes, "long" );
|
||||
Core.putSharedData("PANDROID_DATA", "transmitBytes", ""+transmitBytes, "long" );
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -954,63 +1016,13 @@ public class PandroidAgentListener extends Service {
|
|||
boolean roaming = telephone.isNetworkRoaming();
|
||||
|
||||
if(roaming)
|
||||
putSharedData("PANDROID_DATA", "roaming", "1", "integer" );
|
||||
Core.putSharedData("PANDROID_DATA", "roaming", "1", "integer" );
|
||||
else
|
||||
putSharedData("PANDROID_DATA", "roaming", "0", "integer" );
|
||||
Core.putSharedData("PANDROID_DATA", "roaming", "0", "integer" );
|
||||
}
|
||||
|
||||
|
||||
private void putSharedData(String preferenceName, String tokenName, String data, String type) {
|
||||
int mode = Activity.MODE_PRIVATE;
|
||||
SharedPreferences agentPreferences = getSharedPreferences(preferenceName, mode);
|
||||
SharedPreferences.Editor editor = agentPreferences.edit();
|
||||
|
||||
|
||||
if(type == "boolean") {
|
||||
editor.putBoolean(tokenName, Boolean.parseBoolean(data));
|
||||
}
|
||||
else if(type == "float") {
|
||||
editor.putFloat(tokenName, Float.parseFloat(data));
|
||||
}
|
||||
else if(type == "integer") {
|
||||
editor.putInt(tokenName, Integer.parseInt(data));
|
||||
}
|
||||
else if(type == "long") {
|
||||
editor.putLong(tokenName, Long.parseLong(data));
|
||||
}
|
||||
else if(type == "string") {
|
||||
editor.putString(tokenName, data);
|
||||
}
|
||||
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
private String getSharedData(String preferenceName, String tokenName, String defaultValue, String type) {
|
||||
int mode = Activity.MODE_PRIVATE;
|
||||
SharedPreferences agentPreferences = getSharedPreferences(preferenceName, mode);
|
||||
|
||||
if(type == "boolean") {
|
||||
boolean a = agentPreferences.getBoolean(tokenName, Boolean.parseBoolean(defaultValue));
|
||||
return Boolean.valueOf(a).toString();
|
||||
}
|
||||
else if(type == "float") {
|
||||
float a = agentPreferences.getFloat(tokenName, Float.parseFloat(defaultValue));
|
||||
return Float.valueOf(a).toString();
|
||||
}
|
||||
else if(type == "integer") {
|
||||
int a = agentPreferences.getInt(tokenName, Integer.parseInt(defaultValue));
|
||||
return Integer.valueOf(a).toString();
|
||||
}
|
||||
else if(type == "long") {
|
||||
long a = agentPreferences.getLong(tokenName, Long.parseLong(defaultValue));
|
||||
return Long.valueOf(a).toString();
|
||||
}
|
||||
else if(type == "string") {
|
||||
return agentPreferences.getString(tokenName, defaultValue);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
private String getHumanDateTime(long unixtime){
|
||||
Calendar dateTime = Calendar.getInstance();
|
||||
|
@ -1070,8 +1082,8 @@ public class PandroidAgentListener extends Service {
|
|||
|
||||
@Override
|
||||
public void onLocationChanged(Location loc) {
|
||||
putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
|
||||
putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
|
||||
Core.putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
|
||||
Core.putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.io.File;
|
|||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
|
@ -71,9 +72,11 @@ class tentacle_client {
|
|||
|
||||
getInfo("\n*** Starting tentacle client ***\n",verbose);
|
||||
|
||||
Socket socketCliente = null;
|
||||
Socket socketCliente = new Socket();
|
||||
|
||||
try {
|
||||
socketCliente = new Socket(address, port);
|
||||
socketCliente.connect(new InetSocketAddress(address, port), 1000);
|
||||
|
||||
} catch (UnknownHostException e) {
|
||||
getError("Host don't exists");
|
||||
return -1;
|
||||
|
@ -81,6 +84,7 @@ class tentacle_client {
|
|||
getError("Could not connect: The host is down");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
DataOutputStream serverOutput = null;
|
||||
|
||||
|
@ -186,7 +190,7 @@ class tentacle_client {
|
|||
}
|
||||
|
||||
private void log (String msg) {
|
||||
|
||||
Log.e("Tentacle",msg);
|
||||
//Context context = getApplicationContext();
|
||||
//int duration = Toast.LENGTH_SHORT;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import android.util.Log;
|
|||
int defaultSMSReceived = 0;
|
||||
int mode = Activity.MODE_PRIVATE;
|
||||
|
||||
SharedPreferences pref = context.getSharedPreferences("PANDROID_DATA", mode);
|
||||
SharedPreferences pref = PandroidAgent.getSharedPrefs();
|
||||
int sms = pref.getInt("SMSReceived", defaultSMSReceived);
|
||||
|
||||
sms++;
|
||||
|
|
|
@ -94,9 +94,7 @@ public class Status extends Activity {
|
|||
private void updateLastXML() {
|
||||
|
||||
TextView xml = (TextView) this.findViewById(R.id.xml);
|
||||
SharedPreferences agentPreferences = getSharedPreferences(
|
||||
getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
SharedPreferences agentPreferences = PandroidAgent.getSharedPrefs();
|
||||
|
||||
String lastXML = agentPreferences.getString("lastXML", "[no data]");
|
||||
xml.setText("Last XML builded: \n\n" + lastXML);
|
||||
|
|
Loading…
Reference in New Issue