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>
|
2013-04-25 Mark Holland <mark@mark-holland.me.uk>
|
||||||
|
|
||||||
* src/pandroid/agent/Core.java: Separate load and store
|
* src/pandroid/agent/Core.java: Separate load and store
|
||||||
|
|
Binary file not shown.
|
@ -177,6 +177,10 @@ public class Core {
|
||||||
|
|
||||||
static DataBaseHandler db;
|
static DataBaseHandler db;
|
||||||
|
|
||||||
|
//Single SharedPreferences object
|
||||||
|
static volatile public SharedPreferences agentPreferences;
|
||||||
|
static volatile public SharedPreferences.Editor editor;
|
||||||
|
|
||||||
public Core() {
|
public Core() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -214,9 +218,7 @@ public class Core {
|
||||||
con = context;
|
con = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences agentPreferences = con.getSharedPreferences(
|
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||||
con.getString(R.string.const_string_preferences),
|
|
||||||
Activity.MODE_PRIVATE);
|
|
||||||
|
|
||||||
latitude = agentPreferences.getFloat("latitude", CONST_INVALID_COORDS);
|
latitude = agentPreferences.getFloat("latitude", CONST_INVALID_COORDS);
|
||||||
longitude = agentPreferences.getFloat("longitude", CONST_INVALID_COORDS);
|
longitude = agentPreferences.getFloat("longitude", CONST_INVALID_COORDS);
|
||||||
|
@ -255,9 +257,7 @@ public class Core {
|
||||||
con = context;
|
con = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences agentPreferences = con.getSharedPreferences(
|
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||||
con.getString(R.string.const_string_preferences),
|
|
||||||
Activity.MODE_PRIVATE);
|
|
||||||
|
|
||||||
serverAddr = agentPreferences.getString("serverAddr", defaultServerAddr);
|
serverAddr = agentPreferences.getString("serverAddr", defaultServerAddr);
|
||||||
serverPort = agentPreferences.getString("serverPort", defaultServerPort);
|
serverPort = agentPreferences.getString("serverPort", defaultServerPort);
|
||||||
|
@ -321,10 +321,8 @@ public class Core {
|
||||||
con = context;
|
con = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences agentPreferences = con.getSharedPreferences(
|
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||||
con.getString(R.string.const_string_preferences),
|
editor = PandroidAgent.getEditor();
|
||||||
Activity.MODE_PRIVATE);
|
|
||||||
SharedPreferences.Editor editor = agentPreferences.edit();
|
|
||||||
|
|
||||||
editor.putString("serverAddr", _serverAddr);
|
editor.putString("serverAddr", _serverAddr);
|
||||||
editor.putString("serverPort", _serverPort);
|
editor.putString("serverPort", _serverPort);
|
||||||
|
@ -379,203 +377,256 @@ public class Core {
|
||||||
}// end updateConf
|
}// end updateConf
|
||||||
|
|
||||||
|
|
||||||
//database//
|
public synchronized static void putSharedData(String preferenceName, String tokenName, String data, String type) {
|
||||||
|
int mode = Activity.MODE_PRIVATE;
|
||||||
|
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||||
|
editor = PandroidAgent.getEditor();
|
||||||
|
|
||||||
static synchronized public void loadLastValuesDatabase(Context context) {
|
|
||||||
if (con == null) {
|
if(type == "boolean") {
|
||||||
con = context;
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
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 "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// //database//
|
||||||
|
|
||||||
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);
|
// static synchronized public void loadLastValuesDatabase(Context context) {
|
||||||
|
// if (con == null) {
|
||||||
|
// con = context;
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// db.addValue(dh);
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// 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(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();
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//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 java.io.File;
|
||||||
|
|
||||||
//import android.app.Dialog;
|
import android.app.Activity;
|
||||||
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.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.Editor;
|
||||||
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.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 {
|
||||||
|
|
||||||
|
@ -33,6 +38,10 @@ public class PandroidAgent extends TabActivity {
|
||||||
int defaultInterval = 300;
|
int defaultInterval = 300;
|
||||||
TabHost tabHost;
|
TabHost tabHost;
|
||||||
|
|
||||||
|
static SharedPreferences agentPreferences;
|
||||||
|
static Editor editor;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -40,9 +49,15 @@ public class PandroidAgent extends TabActivity {
|
||||||
//database//
|
//database//
|
||||||
|
|
||||||
|
|
||||||
Core.loadConfDatabase(this);
|
agentPreferences = this.getSharedPreferences(
|
||||||
Core.loadLastValuesDatabase(this);
|
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);
|
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(){
|
public void onPause(){
|
||||||
super.onPause();
|
super.onPause();
|
||||||
Core.updateConf(getApplicationContext());
|
Core.updateConf(getApplicationContext());
|
||||||
Core.updateDatabase(this);
|
//Core.updateDatabase(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroy(){
|
public void onDestroy(){
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
Core.updateConf(getApplicationContext());
|
Core.updateConf(getApplicationContext());
|
||||||
Core.updateDatabase(this);
|
//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)
|
||||||
|
@ -128,4 +143,16 @@ public class PandroidAgent extends TabActivity {
|
||||||
public void switchTab(int tab){
|
public void switchTab(int tab){
|
||||||
tabHost.setCurrentTab(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.
|
// GNU General Public License for more details.
|
||||||
package pandroid.agent;
|
package pandroid.agent;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -23,10 +22,10 @@ import java.text.DecimalFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringEscapeUtils;
|
import org.apache.commons.lang3.StringEscapeUtils;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityManager.MemoryInfo;
|
import android.app.ActivityManager.MemoryInfo;
|
||||||
import android.app.ActivityManager.RunningAppProcessInfo;
|
import android.app.ActivityManager.RunningAppProcessInfo;
|
||||||
|
@ -37,7 +36,6 @@ import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
@ -59,6 +57,8 @@ import android.telephony.PhoneStateListener;
|
||||||
import android.telephony.SignalStrength;
|
import android.telephony.SignalStrength;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class PandroidAgentListener extends Service {
|
public class PandroidAgentListener extends Service {
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public class PandroidAgentListener extends Service {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("notification", e.toString());
|
Log.e("notification", e.toString());
|
||||||
}
|
}
|
||||||
Log.v("MARK","notif"+Core.NotificationCheck);
|
|
||||||
if(Core.NotificationCheck == "enabled"){
|
if(Core.NotificationCheck == "enabled"){
|
||||||
|
|
||||||
Notification notification = new Notification(R.drawable.icon, getText(R.string.ticker_text),
|
Notification notification = new Notification(R.drawable.icon, getText(R.string.ticker_text),
|
||||||
|
@ -114,55 +114,55 @@ public class PandroidAgentListener extends Service {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void contact(){
|
// private void contact(){
|
||||||
Date date = new Date();
|
// Date date = new Date();
|
||||||
|
//
|
||||||
putSharedData("PANDROID_DATA", "contactError", "0", "integer");
|
// Core.putSharedData("PANDROID_DATA", "contactError", "0", "integer");
|
||||||
putSharedData("PANDROID_DATA", "lastContact", Long.toString(date.getTime() / 1000), "long");
|
// Core.putSharedData("PANDROID_DATA", "lastContact", Long.toString(date.getTime() / 1000), "long");
|
||||||
|
//
|
||||||
// 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 = 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();
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
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(){
|
private void contact(){
|
||||||
|
|
||||||
/*
|
|
||||||
Toast toast = Toast.makeText(getApplicationContext(),
|
Toast toast = Toast.makeText(getApplicationContext(),
|
||||||
|
|
||||||
getString(R.string.loading),
|
getString(R.string.loading),
|
||||||
|
@ -174,41 +174,68 @@ public class PandroidAgentListener extends Service {
|
||||||
|
|
||||||
Date date = new Date();
|
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 = "";
|
try {
|
||||||
new contactTask().execute(lastXML);
|
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();
|
updateValues();
|
||||||
|
|
||||||
}//end contact
|
}//end contact
|
||||||
|
|
||||||
|
|
||||||
private class contactTask extends AsyncTask<String, Void, Void>{
|
private class contactTask extends AsyncTask<String, Void, Integer>{
|
||||||
|
String destFileName = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(String...params) {
|
protected void onPreExecute(){
|
||||||
|
|
||||||
String lastXML = params[0];
|
}
|
||||||
lastXML = buildXML();
|
|
||||||
String destFileName = "";
|
@Override
|
||||||
String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
protected Integer doInBackground(String... lastXML) {
|
||||||
destFileName = agentName + "." + System.currentTimeMillis() + ".data";
|
|
||||||
|
|
||||||
|
//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) {
|
||||||
|
|
||||||
|
destFileName = buffer[i];
|
||||||
|
|
||||||
writeFile(destFileName, lastXML);
|
|
||||||
String[] tentacleData = {
|
String[] tentacleData = {
|
||||||
"-a",
|
"-a",
|
||||||
getSharedData("PANDROID_DATA", "serverAddr", "", "string"),
|
Core.getSharedData("PANDROID_DATA", "serverAddr", "", "string"),
|
||||||
"-p",
|
"-p",
|
||||||
Core.defaultServerPort,
|
Core.defaultServerPort,
|
||||||
"-v",
|
"-v",
|
||||||
"/data/data/pandroid.agent/files/" + destFileName
|
"/data/data/pandroid.agent/files/" + destFileName
|
||||||
};
|
};
|
||||||
|
|
||||||
int tentacleRet = new tentacle_client().tentacle_client(tentacleData);
|
|
||||||
|
|
||||||
putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
|
tentacleRet = new tentacle_client().tentacle_client(tentacleData);
|
||||||
|
|
||||||
if(tentacleRet == 0) {
|
if(tentacleRet == 0) {
|
||||||
putSharedData("PANDROID_DATA", "contactError", "0", "integer");
|
Core.putSharedData("PANDROID_DATA", "contactError", "0", "integer");
|
||||||
// Deleting the file after send it
|
// Deleting the file after send it
|
||||||
// move to only delete if sent successfully
|
// move to only delete if sent successfully
|
||||||
File file = new File("/data/data/pandroid.agent/files/" + destFileName);
|
File file = new File("/data/data/pandroid.agent/files/" + destFileName);
|
||||||
|
@ -216,15 +243,50 @@ public class PandroidAgentListener extends Service {
|
||||||
if (Core.helloSignal >= 1)
|
if (Core.helloSignal >= 1)
|
||||||
Core.helloSignal = 0;
|
Core.helloSignal = 0;
|
||||||
Core.updateConf(getApplicationContext());
|
Core.updateConf(getApplicationContext());
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
if(tentacleRet == -1){
|
||||||
putSharedData("PANDROID_DATA", "contactError", "1", "integer");
|
//file not deleted
|
||||||
|
Core.putSharedData("PANDROID_DATA", "contactError", "1", "integer");
|
||||||
|
contact = false;
|
||||||
}
|
}
|
||||||
return null;
|
i++;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return tentacleRet;
|
||||||
|
|
||||||
}//end doInBackground
|
}//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 //
|
// From unfinished task of buffering unsent xml files when no connection available //
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -257,15 +319,15 @@ public class PandroidAgentListener extends Service {
|
||||||
String gpsData = "";
|
String gpsData = "";
|
||||||
buffer += "<?xml version='1.0' encoding='iso-8859-1'?>\n";
|
buffer += "<?xml version='1.0' encoding='iso-8859-1'?>\n";
|
||||||
|
|
||||||
String latitude = getSharedData("PANDROID_DATA", "latitude", "181", "float");
|
String latitude = Core.getSharedData("PANDROID_DATA", "latitude", "181", "float");
|
||||||
String longitude = getSharedData("PANDROID_DATA", "longitude", "181", "float");
|
String longitude = Core.getSharedData("PANDROID_DATA", "longitude", "181", "float");
|
||||||
|
|
||||||
if(!latitude.equals("181.0") && !longitude.equals("181.0")) {
|
if(!latitude.equals("181.0") && !longitude.equals("181.0")) {
|
||||||
gpsData = " latitude='" + latitude + "' longitude='" + longitude + "'";
|
gpsData = " latitude='" + latitude + "' longitude='" + longitude + "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
String agentName = Core.getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||||
String interval = getSharedData("PANDROID_DATA", "interval", Integer.toString(Core.defaultInterval), "integer");
|
String interval = Core.getSharedData("PANDROID_DATA", "interval", Integer.toString(Core.defaultInterval), "integer");
|
||||||
|
|
||||||
buffer += "<agent_data " +
|
buffer += "<agent_data " +
|
||||||
"description='' group='' os_name='android' os_version='"+Build.VERSION.RELEASE+"' " +
|
"description='' group='' os_name='android' os_version='"+Build.VERSION.RELEASE+"' " +
|
||||||
|
@ -277,51 +339,51 @@ public class PandroidAgentListener extends Service {
|
||||||
// MODULES //
|
// MODULES //
|
||||||
// //
|
// //
|
||||||
|
|
||||||
String orientation = getSharedData("PANDROID_DATA", "orientation", "361", "float");
|
String orientation = Core.getSharedData("PANDROID_DATA", "orientation", "361", "float");
|
||||||
String proximity = getSharedData("PANDROID_DATA", "proximity", "-1.0", "float");
|
String proximity = Core.getSharedData("PANDROID_DATA", "proximity", "-1.0", "float");
|
||||||
String batteryLevel = getSharedData("PANDROID_DATA", "batteryLevel", "-1", "integer");
|
String batteryLevel = Core.getSharedData("PANDROID_DATA", "batteryLevel", "-1", "integer");
|
||||||
String taskStatus = getSharedData("PANDROID_DATA", "taskStatus", "disabled", "string");
|
String taskStatus = Core.getSharedData("PANDROID_DATA", "taskStatus", "disabled", "string");
|
||||||
String taskRun = getSharedData("PANDROID_DATA", "taskRun", "false", "string");
|
String taskRun = Core.getSharedData("PANDROID_DATA", "taskRun", "false", "string");
|
||||||
String taskHumanName = getSharedData("PANDROID_DATA", "taskHumanName", "", "string");
|
String taskHumanName = Core.getSharedData("PANDROID_DATA", "taskHumanName", "", "string");
|
||||||
taskHumanName = StringEscapeUtils.escapeHtml4(taskHumanName);
|
taskHumanName = StringEscapeUtils.escapeHtml4(taskHumanName);
|
||||||
|
|
||||||
String task = getSharedData("PANDROID_DATA", "task", "", "string");
|
String task = Core.getSharedData("PANDROID_DATA", "task", "", "string");
|
||||||
String memoryStatus = getSharedData("PANDROID_DATA", "memoryStatus", Core.defaultMemoryStatus, "string");
|
String memoryStatus = Core.getSharedData("PANDROID_DATA", "memoryStatus", Core.defaultMemoryStatus, "string");
|
||||||
String availableRamKb = getSharedData("PANDROID_DATA", "availableRamKb", "0" , "long");
|
String availableRamKb = Core.getSharedData("PANDROID_DATA", "availableRamKb", "0" , "long");
|
||||||
String totalRamKb = getSharedData("PANDROID_DATA", "totalRamKb", "0", "long");
|
String totalRamKb = Core.getSharedData("PANDROID_DATA", "totalRamKb", "0", "long");
|
||||||
String SimID = getSharedData("PANDROID_DATA", "simID", Core.defaultSimID, "string");
|
String SimID = Core.getSharedData("PANDROID_DATA", "simID", Core.defaultSimID, "string");
|
||||||
String upTime = getSharedData("PANDROID_DATA", "upTime", ""+Core.defaultUpTime, "long");
|
String upTime = Core.getSharedData("PANDROID_DATA", "upTime", ""+Core.defaultUpTime, "long");
|
||||||
String networkOperator = getSharedData("PANDROID_DATA", "networkOperator", Core.defaultNetworkOperator, "string");
|
String networkOperator = Core.getSharedData("PANDROID_DATA", "networkOperator", Core.defaultNetworkOperator, "string");
|
||||||
String SMSReceived = getSharedData("PANDROID_DATA", "SMSReceived", ""+Core.defaultSMSReceived, "integer");
|
String SMSReceived = Core.getSharedData("PANDROID_DATA", "SMSReceived", ""+Core.defaultSMSReceived, "integer");
|
||||||
String SMSSent = getSharedData("PANDROID_DATA", "SMSSent", ""+Core.defaultSMSSent, "integer");
|
String SMSSent = Core.getSharedData("PANDROID_DATA", "SMSSent", ""+Core.defaultSMSSent, "integer");
|
||||||
String networkType = getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
|
String networkType = Core.getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
|
||||||
String phoneType = getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
|
String phoneType = Core.getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
|
||||||
String signalStrength = getSharedData("PANDROID_DATA", "signalStrength", ""+Core.defaultSignalStrength, "integer");
|
String signalStrength = Core.getSharedData("PANDROID_DATA", "signalStrength", ""+Core.defaultSignalStrength, "integer");
|
||||||
String incomingCalls = getSharedData("PANDROID_DATA", "incomingCalls", ""+Core.defaultIncomingCalls, "integer");
|
String incomingCalls = Core.getSharedData("PANDROID_DATA", "incomingCalls", ""+Core.defaultIncomingCalls, "integer");
|
||||||
String missedCalls = getSharedData("PANDROID_DATA", "missedCalls", ""+Core.defaultMissedCalls, "integer");
|
String missedCalls = Core.getSharedData("PANDROID_DATA", "missedCalls", ""+Core.defaultMissedCalls, "integer");
|
||||||
String outgoingCalls = getSharedData("PANDROID_DATA", "outgoingCalls", ""+Core.defaultOutgoingCalls, "integer");
|
String outgoingCalls = Core.getSharedData("PANDROID_DATA", "outgoingCalls", ""+Core.defaultOutgoingCalls, "integer");
|
||||||
String receiveBytes = getSharedData("PANDROID_DATA", "receiveBytes", ""+Core.defaultReceiveBytes, "long");
|
String receiveBytes = Core.getSharedData("PANDROID_DATA", "receiveBytes", ""+Core.defaultReceiveBytes, "long");
|
||||||
String transmitBytes = getSharedData("PANDROID_DATA", "transmitBytes", ""+Core.defaultTransmitBytes, "long");
|
String transmitBytes = Core.getSharedData("PANDROID_DATA", "transmitBytes", ""+Core.defaultTransmitBytes, "long");
|
||||||
String helloSignal = getSharedData("PANDROID_DATA", "helloSignal", ""+Core.defaultHelloSignal, "integer");
|
String helloSignal = Core.getSharedData("PANDROID_DATA", "helloSignal", ""+Core.defaultHelloSignal, "integer");
|
||||||
String roaming = getSharedData("PANDROID_DATA", "roaming", ""+Core.defaultRoaming, "integer");
|
String roaming = Core.getSharedData("PANDROID_DATA", "roaming", ""+Core.defaultRoaming, "integer");
|
||||||
|
|
||||||
String simIDReport = getSharedData("PANDROID_DATA", "simIDReport", Core.defaultSimIDReport, "string");
|
String simIDReport = Core.getSharedData("PANDROID_DATA", "simIDReport", Core.defaultSimIDReport, "string");
|
||||||
String DeviceUpTimeReport = getSharedData("PANDROID_DATA", "DeviceUpTimeReport", Core.defaultDeviceUpTimeReport, "string");
|
String DeviceUpTimeReport = Core.getSharedData("PANDROID_DATA", "DeviceUpTimeReport", Core.defaultDeviceUpTimeReport, "string");
|
||||||
String NetworkOperatorReport = getSharedData("PANDROID_DATA", "NetworkOperatorReport", Core.defaultNetworkOperatorReport, "string");
|
String NetworkOperatorReport = Core.getSharedData("PANDROID_DATA", "NetworkOperatorReport", Core.defaultNetworkOperatorReport, "string");
|
||||||
String NetworkTypeReport = getSharedData("PANDROID_DATA", "NetworkTypeReport", Core.defaultNetworkTypeReport, "string");
|
String NetworkTypeReport = Core.getSharedData("PANDROID_DATA", "NetworkTypeReport", Core.defaultNetworkTypeReport, "string");
|
||||||
String PhoneTypeReport = getSharedData("PANDROID_DATA", "PhoneTypeReport", Core.defaultPhoneTypeReport, "string");
|
String PhoneTypeReport = Core.getSharedData("PANDROID_DATA", "PhoneTypeReport", Core.defaultPhoneTypeReport, "string");
|
||||||
String SignalStrengthReport = getSharedData("PANDROID_DATA", "SignalStrengthReport", Core.defaultSignalStrengthReport, "string");
|
String SignalStrengthReport = Core.getSharedData("PANDROID_DATA", "SignalStrengthReport", Core.defaultSignalStrengthReport, "string");
|
||||||
String ReceivedSMSReport = getSharedData("PANDROID_DATA", "ReceivedSMSReport", Core.defaultReceivedSMSReport, "string");
|
String ReceivedSMSReport = Core.getSharedData("PANDROID_DATA", "ReceivedSMSReport", Core.defaultReceivedSMSReport, "string");
|
||||||
String SentSMSReport = getSharedData("PANDROID_DATA", "SentSMSReport", Core.defaultSentSMSReport, "string");
|
String SentSMSReport = Core.getSharedData("PANDROID_DATA", "SentSMSReport", Core.defaultSentSMSReport, "string");
|
||||||
String IncomingCallsReport = getSharedData("PANDROID_DATA", "IncomingCallsReport", Core.defaultIncomingCallsReport, "string");
|
String IncomingCallsReport = Core.getSharedData("PANDROID_DATA", "IncomingCallsReport", Core.defaultIncomingCallsReport, "string");
|
||||||
String MissedCallsReport = getSharedData("PANDROID_DATA", "MissedCallsReport", Core.defaultMissedCallsReport, "string");
|
String MissedCallsReport = Core.getSharedData("PANDROID_DATA", "MissedCallsReport", Core.defaultMissedCallsReport, "string");
|
||||||
String OutgoingCallsReport = getSharedData("PANDROID_DATA", "OutgoingCallsReport", Core.defaultOutgoingCallsReport, "string");
|
String OutgoingCallsReport = Core.getSharedData("PANDROID_DATA", "OutgoingCallsReport", Core.defaultOutgoingCallsReport, "string");
|
||||||
String BytesReceivedReport = getSharedData("PANDROID_DATA", "BytesReceivedReport", Core.defaultBytesReceivedReport, "string");
|
String BytesReceivedReport = Core.getSharedData("PANDROID_DATA", "BytesReceivedReport", Core.defaultBytesReceivedReport, "string");
|
||||||
String BytesSentReport = getSharedData("PANDROID_DATA", "BytesSentReport", Core.defaultBytesSentReport, "string");
|
String BytesSentReport = Core.getSharedData("PANDROID_DATA", "BytesSentReport", Core.defaultBytesSentReport, "string");
|
||||||
String HelloSignalReport = getSharedData("PANDROID_DATA", "HelloSignalReport", Core.defaultHelloSignalReport, "string");
|
String HelloSignalReport = Core.getSharedData("PANDROID_DATA", "HelloSignalReport", Core.defaultHelloSignalReport, "string");
|
||||||
String BatteryLevelReport = getSharedData("PANDROID_DATA", "BatteryLevelReport", Core.defaultBatteryLevelReport, "string");
|
String BatteryLevelReport = Core.getSharedData("PANDROID_DATA", "BatteryLevelReport", Core.defaultBatteryLevelReport, "string");
|
||||||
String RoamingReport = getSharedData("PANDROID_DATA", "RoamingReport", Core.defaultRoamingReport, "string");
|
String RoamingReport = Core.getSharedData("PANDROID_DATA", "RoamingReport", Core.defaultRoamingReport, "string");
|
||||||
String InventoryReport = getSharedData("PANDROID_DATA", "InventoryReport", Core.defaultInventoryReport, "string");
|
String InventoryReport = Core.getSharedData("PANDROID_DATA", "InventoryReport", Core.defaultInventoryReport, "string");
|
||||||
|
|
||||||
if(InventoryReport.equals("enabled"))
|
if(InventoryReport.equals("enabled"))
|
||||||
{
|
{
|
||||||
|
@ -396,9 +458,9 @@ public class PandroidAgentListener extends Service {
|
||||||
|
|
||||||
//UTF-8 TEST//
|
//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
|
// End_Modules
|
||||||
|
@ -506,8 +568,8 @@ public class PandroidAgentListener extends Service {
|
||||||
//if(latitude != loc.getLatitude() || longitude != loc.getLongitude()) {
|
//if(latitude != loc.getLatitude() || longitude != loc.getLongitude()) {
|
||||||
lastGpsContactDateTime = getHumanDateTime(-1);
|
lastGpsContactDateTime = getHumanDateTime(-1);
|
||||||
//}
|
//}
|
||||||
putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
|
Core.putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
|
||||||
putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
|
Core.putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Criteria criteria = new Criteria();
|
Criteria criteria = new Criteria();
|
||||||
|
@ -527,9 +589,9 @@ public class PandroidAgentListener extends Service {
|
||||||
lm.requestLocationUpdates(bestProvider, Core.defaultInterval, 1000,
|
lm.requestLocationUpdates(bestProvider, Core.defaultInterval, 1000,
|
||||||
new LocationListener() {
|
new LocationListener() {
|
||||||
public void onLocationChanged(Location location) {
|
public void onLocationChanged(Location location) {
|
||||||
putSharedData("PANDROID_DATA", "latitude",
|
Core.putSharedData("PANDROID_DATA", "latitude",
|
||||||
Double.valueOf(location.getLatitude()).toString(), "float");
|
Double.valueOf(location.getLatitude()).toString(), "float");
|
||||||
putSharedData("PANDROID_DATA", "longitude",
|
Core.putSharedData("PANDROID_DATA", "longitude",
|
||||||
Double.valueOf(location.getLongitude()).toString(), "float");
|
Double.valueOf(location.getLongitude()).toString(), "float");
|
||||||
}
|
}
|
||||||
public void onStatusChanged(String s, int i, Bundle bundle) {
|
public void onStatusChanged(String s, int i, Bundle bundle) {
|
||||||
|
@ -539,7 +601,7 @@ public class PandroidAgentListener extends Service {
|
||||||
// try switching to a different provider
|
// try switching to a different provider
|
||||||
}
|
}
|
||||||
public void onProviderDisabled(String s) {
|
public void onProviderDisabled(String s) {
|
||||||
putSharedData("PANDROID_DATA", "enabled_location_provider",
|
Core.putSharedData("PANDROID_DATA", "enabled_location_provider",
|
||||||
"disabled", "string");
|
"disabled", "string");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -554,7 +616,7 @@ public class PandroidAgentListener extends Service {
|
||||||
int scale = batteryIntent.getIntExtra("scale", -1);
|
int scale = batteryIntent.getIntExtra("scale", -1);
|
||||||
//double level = -1;
|
//double level = -1;
|
||||||
if (rawlevel >= 0 && scale > 0) {
|
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() {
|
SensorEventListener orientationLevelReceiver = new SensorEventListener() {
|
||||||
public void onSensorChanged(SensorEvent sensorEvent) {
|
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) {
|
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||||
}
|
}
|
||||||
|
@ -571,7 +633,7 @@ public class PandroidAgentListener extends Service {
|
||||||
|
|
||||||
SensorEventListener proximityLevelReceiver = new SensorEventListener() {
|
SensorEventListener proximityLevelReceiver = new SensorEventListener() {
|
||||||
public void onSensorChanged(SensorEvent sensorEvent) {
|
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) {
|
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||||
}
|
}
|
||||||
|
@ -621,7 +683,7 @@ public class PandroidAgentListener extends Service {
|
||||||
private void updateValues() {
|
private void updateValues() {
|
||||||
|
|
||||||
batteryLevel();
|
batteryLevel();
|
||||||
String gpsStatus = getSharedData("PANDROID_DATA", "gpsStatus", Core.defaultGpsStatus, "string");
|
String gpsStatus = Core.getSharedData("PANDROID_DATA", "gpsStatus", Core.defaultGpsStatus, "string");
|
||||||
|
|
||||||
if(gpsStatus.equals("enabled")) {
|
if(gpsStatus.equals("enabled")) {
|
||||||
Log.d("PANDROID AGENT", "ENABLED");
|
Log.d("PANDROID AGENT", "ENABLED");
|
||||||
|
@ -629,8 +691,8 @@ public class PandroidAgentListener extends Service {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log.d("PANDROID AGENT", "DISABLED");
|
Log.d("PANDROID AGENT", "DISABLED");
|
||||||
putSharedData("PANDROID_DATA", "latitude", "181.0", "float");
|
Core.putSharedData("PANDROID_DATA", "latitude", "181.0", "float");
|
||||||
putSharedData("PANDROID_DATA", "longitude", "181.0", "float");
|
Core.putSharedData("PANDROID_DATA", "longitude", "181.0", "float");
|
||||||
}
|
}
|
||||||
|
|
||||||
//sensors();
|
//sensors();
|
||||||
|
@ -653,7 +715,7 @@ public class PandroidAgentListener extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getMemoryStatus() {
|
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 availableRamKb = 0;
|
||||||
long totalRamKb = 0;
|
long totalRamKb = 0;
|
||||||
|
|
||||||
|
@ -679,14 +741,14 @@ public class PandroidAgentListener extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
putSharedData("PANDROID_DATA", "availableRamKb", "" + availableRamKb, "long");
|
Core.putSharedData("PANDROID_DATA", "availableRamKb", "" + availableRamKb, "long");
|
||||||
putSharedData("PANDROID_DATA", "totalRamKb", "" + totalRamKb, "long");
|
Core.putSharedData("PANDROID_DATA", "totalRamKb", "" + totalRamKb, "long");
|
||||||
}// end getMemoryStatus
|
}// end getMemoryStatus
|
||||||
|
|
||||||
private void getTaskStatus() {
|
private void getTaskStatus() {
|
||||||
String taskStatus = getSharedData("PANDROID_DATA", "taskStatus", Core.defaultTaskStatus, "string");
|
String taskStatus = Core.getSharedData("PANDROID_DATA", "taskStatus", Core.defaultTaskStatus, "string");
|
||||||
String task = getSharedData("PANDROID_DATA", "task", Core.defaultTask, "string");
|
String task = Core.getSharedData("PANDROID_DATA", "task", Core.defaultTask, "string");
|
||||||
String taskHumanName = getSharedData("PANDROID_DATA", "taskHumanName", Core.defaultTaskHumanName, "string");
|
String taskHumanName = Core.getSharedData("PANDROID_DATA", "taskHumanName", Core.defaultTaskHumanName, "string");
|
||||||
String run = "false";
|
String run = "false";
|
||||||
|
|
||||||
if (taskStatus.equals("enabled")) {
|
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
|
}//end getTaskStatus
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -714,12 +776,12 @@ public class PandroidAgentListener extends Service {
|
||||||
*/
|
*/
|
||||||
private void getSimID(){
|
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;
|
String serviceName = Context.TELEPHONY_SERVICE;
|
||||||
TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService(serviceName);
|
TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService(serviceName);
|
||||||
simID = telephonyManager.getSimSerialNumber();
|
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
|
* Retrieves the time in seconds since the device was switched on
|
||||||
|
@ -728,7 +790,7 @@ public class PandroidAgentListener extends Service {
|
||||||
long upTime = Core.defaultUpTime;
|
long upTime = Core.defaultUpTime;
|
||||||
upTime = SystemClock.elapsedRealtime()/1000;
|
upTime = SystemClock.elapsedRealtime()/1000;
|
||||||
if(upTime != 0)
|
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...
|
* Retrieve currently registered network operator, i.e. vodafone, movistar, etc...
|
||||||
|
@ -740,7 +802,7 @@ public class PandroidAgentListener extends Service {
|
||||||
networkOperator = telephonyManager.getNetworkOperatorName();
|
networkOperator = telephonyManager.getNetworkOperatorName();
|
||||||
|
|
||||||
if(networkOperator != null)
|
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
|
* 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(){
|
private void getSMSSent(){
|
||||||
|
|
||||||
String SMSSent = ""+Core.defaultSMSSent;
|
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");
|
Uri allMessages = Uri.parse("content://sms/sent");
|
||||||
Cursor c = getContentResolver().query(allMessages, null, null, null, null);
|
Cursor c = getContentResolver().query(allMessages, null, null, null, null);
|
||||||
int totalMessages = 0;
|
int totalMessages = 0;
|
||||||
|
@ -767,7 +829,7 @@ public class PandroidAgentListener extends Service {
|
||||||
SMSSent =""+ totalMessages;
|
SMSSent =""+ totalMessages;
|
||||||
|
|
||||||
if(SMSSent != null)
|
if(SMSSent != null)
|
||||||
putSharedData("PANDROID_DATA", "SMSSent", SMSSent, "integer");
|
Core.putSharedData("PANDROID_DATA", "SMSSent", SMSSent, "integer");
|
||||||
|
|
||||||
}// end getSMSSent
|
}// end getSMSSent
|
||||||
/**
|
/**
|
||||||
|
@ -831,7 +893,7 @@ public class PandroidAgentListener extends Service {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(networkType != null)
|
if(networkType != null)
|
||||||
putSharedData("PANDROID_DATA", "networkType", networkType, "string");
|
Core.putSharedData("PANDROID_DATA", "networkType", networkType, "string");
|
||||||
|
|
||||||
}// end getNetworkType
|
}// end getNetworkType
|
||||||
|
|
||||||
|
@ -860,7 +922,7 @@ public class PandroidAgentListener extends Service {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(phoneType != null)
|
if(phoneType != null)
|
||||||
putSharedData("PANDROID_DATA", "phoneType", phoneType, "string");
|
Core.putSharedData("PANDROID_DATA", "phoneType", phoneType, "string");
|
||||||
}// end getPhoneType
|
}// end getPhoneType
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -894,9 +956,9 @@ public class PandroidAgentListener extends Service {
|
||||||
c.moveToNext();
|
c.moveToNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
putSharedData("PANDROID_DATA", "incomingCalls", ""+incoming, "integer");
|
Core.putSharedData("PANDROID_DATA", "incomingCalls", ""+incoming, "integer");
|
||||||
putSharedData("PANDROID_DATA", "missedCalls", ""+missed, "integer");
|
Core.putSharedData("PANDROID_DATA", "missedCalls", ""+missed, "integer");
|
||||||
putSharedData("PANDROID_DATA", "outgoingCalls", ""+outgoing, "integer");
|
Core.putSharedData("PANDROID_DATA", "outgoingCalls", ""+outgoing, "integer");
|
||||||
}
|
}
|
||||||
|
|
||||||
c.close();
|
c.close();
|
||||||
|
@ -927,7 +989,7 @@ public class PandroidAgentListener extends Service {
|
||||||
else{
|
else{
|
||||||
signalStrengthValue ="" + (signalStrength.getCdmaDbm());
|
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)
|
if (receiveBytes != TrafficStats.UNSUPPORTED && transmitBytes != TrafficStats.UNSUPPORTED)
|
||||||
{
|
{
|
||||||
putSharedData("PANDROID_DATA", "receiveBytes", ""+receiveBytes, "long" );
|
Core.putSharedData("PANDROID_DATA", "receiveBytes", ""+receiveBytes, "long" );
|
||||||
putSharedData("PANDROID_DATA", "transmitBytes", ""+transmitBytes, "long" );
|
Core.putSharedData("PANDROID_DATA", "transmitBytes", ""+transmitBytes, "long" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -954,64 +1016,14 @@ public class PandroidAgentListener extends Service {
|
||||||
boolean roaming = telephone.isNetworkRoaming();
|
boolean roaming = telephone.isNetworkRoaming();
|
||||||
|
|
||||||
if(roaming)
|
if(roaming)
|
||||||
putSharedData("PANDROID_DATA", "roaming", "1", "integer" );
|
Core.putSharedData("PANDROID_DATA", "roaming", "1", "integer" );
|
||||||
else
|
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){
|
private String getHumanDateTime(long unixtime){
|
||||||
Calendar dateTime = Calendar.getInstance();
|
Calendar dateTime = Calendar.getInstance();
|
||||||
if(unixtime != -1) {
|
if(unixtime != -1) {
|
||||||
|
@ -1070,8 +1082,8 @@ public class PandroidAgentListener extends Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLocationChanged(Location loc) {
|
public void onLocationChanged(Location loc) {
|
||||||
putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
|
Core.putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
|
||||||
putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
|
Core.putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
@ -71,9 +72,11 @@ class tentacle_client {
|
||||||
|
|
||||||
getInfo("\n*** Starting tentacle client ***\n",verbose);
|
getInfo("\n*** Starting tentacle client ***\n",verbose);
|
||||||
|
|
||||||
Socket socketCliente = null;
|
Socket socketCliente = new Socket();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
socketCliente = new Socket(address, port);
|
socketCliente.connect(new InetSocketAddress(address, port), 1000);
|
||||||
|
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
getError("Host don't exists");
|
getError("Host don't exists");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -82,6 +85,7 @@ class tentacle_client {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DataOutputStream serverOutput = null;
|
DataOutputStream serverOutput = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -186,7 +190,7 @@ class tentacle_client {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void log (String msg) {
|
private void log (String msg) {
|
||||||
|
Log.e("Tentacle",msg);
|
||||||
//Context context = getApplicationContext();
|
//Context context = getApplicationContext();
|
||||||
//int duration = Toast.LENGTH_SHORT;
|
//int duration = Toast.LENGTH_SHORT;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import android.util.Log;
|
||||||
int defaultSMSReceived = 0;
|
int defaultSMSReceived = 0;
|
||||||
int mode = Activity.MODE_PRIVATE;
|
int mode = Activity.MODE_PRIVATE;
|
||||||
|
|
||||||
SharedPreferences pref = context.getSharedPreferences("PANDROID_DATA", mode);
|
SharedPreferences pref = PandroidAgent.getSharedPrefs();
|
||||||
int sms = pref.getInt("SMSReceived", defaultSMSReceived);
|
int sms = pref.getInt("SMSReceived", defaultSMSReceived);
|
||||||
|
|
||||||
sms++;
|
sms++;
|
||||||
|
|
|
@ -94,9 +94,7 @@ public class Status extends Activity {
|
||||||
private void updateLastXML() {
|
private void updateLastXML() {
|
||||||
|
|
||||||
TextView xml = (TextView) this.findViewById(R.id.xml);
|
TextView xml = (TextView) this.findViewById(R.id.xml);
|
||||||
SharedPreferences agentPreferences = getSharedPreferences(
|
SharedPreferences agentPreferences = PandroidAgent.getSharedPrefs();
|
||||||
getString(R.string.const_string_preferences),
|
|
||||||
Activity.MODE_PRIVATE);
|
|
||||||
|
|
||||||
String lastXML = agentPreferences.getString("lastXML", "[no data]");
|
String lastXML = agentPreferences.getString("lastXML", "[no data]");
|
||||||
xml.setText("Last XML builded: \n\n" + lastXML);
|
xml.setText("Last XML builded: \n\n" + lastXML);
|
||||||
|
|
Loading…
Reference in New Issue