2013-04-27 Mark Holland <mark@mark-holland.me.uk>

* src/pandroid/agent/Core.java: Reverted to previous commit
	SharedPreferences.

	* src/pandroid/agent/PandroidAgent.java: Reverted to previous commit
	SharedPreferences.

	* src/pandroid/agent/PandroidAgentListener.java: Notification only
	shows when attempting to send xml, can't work out how to have it 
	persistent and not dissapear when Pandroid activity is destroyed.

	* src/pandroid/agent/SMSBroadcastReceiver.java: Reverted to previous 
	commit SharedPreferences.

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8071 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
markholland 2013-04-27 17:52:04 +00:00
parent 9cd18ec26a
commit 39d07d2090
8 changed files with 499 additions and 260 deletions

View File

@ -1,3 +1,18 @@
2013-04-27 Mark Holland <mark@mark-holland.me.uk>
* src/pandroid/agent/Core.java: Reverted to previous commit
SharedPreferences.
* src/pandroid/agent/PandroidAgent.java: Reverted to previous commit
SharedPreferences.
* src/pandroid/agent/PandroidAgentListener.java: Notification only
shows when attempting to send xml, can't work out how to have it
persistent and not dissapear when Pandroid activity is destroyed.
* src/pandroid/agent/SMSBroadcastReceiver.java: Reverted to previous
commit SharedPreferences.
2013-04-27 Mark Holland <mark@mark-holland.me.uk> 2013-04-27 Mark Holland <mark@mark-holland.me.uk>
* assets/database/pandroid.zip: Added buffer size initial value. * assets/database/pandroid.zip: Added buffer size initial value.

View File

@ -19,7 +19,7 @@ import android.app.AlarmManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
//import android.util.Log; //import android.util.Log;
@ -42,9 +42,9 @@ public class Core {
// DEFAULT CONFIGURATION MODULES // // DEFAULT CONFIGURATION MODULES //
// // // //
static volatile public String defaultServerAddr = "firefly.artica.es"; //master address static volatile public String defaultServerAddr = "192.168.1.45"; //master address
static volatile public String defaultServerPort = "41121"; static volatile public String defaultServerPort = "41121";
static volatile public int defaultInterval = 300; static volatile public int defaultInterval = 20;
static volatile public String defaultAgentName = "pandroid"; static volatile public String defaultAgentName = "pandroid";
static volatile public String defaultmobileWebURL = "firefly.artica.es/pandora_demo/mobile"; static volatile public String defaultmobileWebURL = "firefly.artica.es/pandora_demo/mobile";
static volatile public String defaultGpsStatus = "enabled"; // "disabled" or "enabled" static volatile public String defaultGpsStatus = "enabled"; // "disabled" or "enabled"
@ -98,6 +98,7 @@ public class Core {
static volatile public int defaultRoaming = 0; static volatile public int defaultRoaming = 0;
static volatile public long defaultBufferSize = 256; static volatile public long defaultBufferSize = 256;
static volatile public String defaultPassword = ""; static volatile public String defaultPassword = "";
static volatile public Context con = null; static volatile public Context con = null;
@ -179,6 +180,7 @@ public class Core {
public Core() { public Core() {
} }
@ -216,38 +218,39 @@ public class Core {
con = context; con = context;
} }
SharedPreferences agentPreferences = con.getSharedPreferences(
con.getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
latitude = HelperSharedPreferences.getSharedPreferencesFloat(con, "latitude", CONST_INVALID_COORDS); latitude = agentPreferences.getFloat("latitude", CONST_INVALID_COORDS);
longitude = HelperSharedPreferences.getSharedPreferencesFloat(con, "longitude", CONST_INVALID_COORDS); longitude = agentPreferences.getFloat("longitude", CONST_INVALID_COORDS);
batteryLevel = HelperSharedPreferences.getSharedPreferencesInt(con, "batteryLevel", CONST_INVALID_BATTERY_LEVEL); batteryLevel = agentPreferences.getInt("batteryLevel", CONST_INVALID_BATTERY_LEVEL);
orientation = HelperSharedPreferences.getSharedPreferencesFloat(con, "orientation", CONST_INVALID_ORIENTATION); orientation = agentPreferences.getFloat("orientation", CONST_INVALID_ORIENTATION);
proximity = HelperSharedPreferences.getSharedPreferencesFloat(con, "proximity", CONST_INVALID_PROXIMITY); proximity = agentPreferences.getFloat("proximity", CONST_INVALID_PROXIMITY);
taskStatus = HelperSharedPreferences.getSharedPreferencesString(con, "taskStatus", defaultTaskStatus); taskStatus = agentPreferences.getString("taskStatus", defaultTaskStatus);
task = HelperSharedPreferences.getSharedPreferencesString(con, "task", defaultTask); task = agentPreferences.getString("task", defaultTask);
taskHumanName = HelperSharedPreferences.getSharedPreferencesString(con, "taskHumanName", defaultTaskHumanName); taskHumanName = agentPreferences.getString("taskHumanName", defaultTaskHumanName);
taskRun = HelperSharedPreferences.getSharedPreferencesString(con, "taskRun", defaultTaskRun); taskRun = agentPreferences.getString("taskRun", defaultTaskRun);
memoryStatus = HelperSharedPreferences.getSharedPreferencesString(con, "memoryStatus", defaultMemoryStatus); memoryStatus = agentPreferences.getString("memoryStatus", defaultMemoryStatus);
availableRamKb = HelperSharedPreferences.getSharedPreferencesLong(con, "availableRamKb", defaultRam); availableRamKb = agentPreferences.getLong("availableRamKb", defaultRam);
totalRamKb = HelperSharedPreferences.getSharedPreferencesLong(con, "totalRamKb", defaultRam); totalRamKb = agentPreferences.getLong("totalRamKb", defaultRam);
lastContact = HelperSharedPreferences.getSharedPreferencesLong(con, "lastContact", defaultContact); lastContact = agentPreferences.getLong("lastContact", defaultContact);
contactError = HelperSharedPreferences.getSharedPreferencesInt(con, "contactError", defaultContactError); contactError = agentPreferences.getInt("contactError", defaultContactError);
simID = HelperSharedPreferences.getSharedPreferencesString(con, "simID", defaultSimID); simID = agentPreferences.getString("simID", defaultSimID);
upTime = HelperSharedPreferences.getSharedPreferencesLong(con, "upTime", Core.defaultUpTime); upTime = agentPreferences.getLong("upTime", Core.defaultUpTime);
SMSReceived = HelperSharedPreferences.getSharedPreferencesInt(con, "SMSReceived", defaultSMSReceived); SMSReceived = agentPreferences.getInt("SMSReceived", defaultSMSReceived);
SMSSent = HelperSharedPreferences.getSharedPreferencesInt(con, "SMSSent", defaultSMSSent); SMSSent = agentPreferences.getInt("SMSSent", defaultSMSSent);
networkOperator = HelperSharedPreferences.getSharedPreferencesString(con, "networkOperator", defaultNetworkOperator); networkOperator = agentPreferences.getString("networkOperator", defaultNetworkOperator);
networkType = HelperSharedPreferences.getSharedPreferencesString(con, "networkType", defaultNetworkType); networkType = agentPreferences.getString("networkType", defaultNetworkType);
phoneType = HelperSharedPreferences.getSharedPreferencesString(con, "phoneType", defaultPhoneType); phoneType = agentPreferences.getString("phoneType", defaultPhoneType);
signalStrength = HelperSharedPreferences.getSharedPreferencesInt(con, "signalStrength", defaultSignalStrength); signalStrength = agentPreferences.getInt("signalStrength", defaultSignalStrength);
incomingCalls = HelperSharedPreferences.getSharedPreferencesInt(con, "incomingCalls", defaultIncomingCalls); incomingCalls = agentPreferences.getInt("incomingCalls", defaultIncomingCalls);
missedCalls = HelperSharedPreferences.getSharedPreferencesInt(con, "missedCalls", defaultMissedCalls); missedCalls = agentPreferences.getInt("missedCalls", defaultMissedCalls);
outgoingCalls = HelperSharedPreferences.getSharedPreferencesInt(con, "outgoingCalls", defaultOutgoingCalls); outgoingCalls = agentPreferences.getInt("outgoingCalls", defaultOutgoingCalls);
receiveBytes = HelperSharedPreferences.getSharedPreferencesLong(con, "receiveBytes", defaultReceiveBytes); receiveBytes = agentPreferences.getLong("receiveBytes", defaultReceiveBytes);
transmitBytes = HelperSharedPreferences.getSharedPreferencesLong(con, "transmitBytes", defaultTransmitBytes); transmitBytes = agentPreferences.getLong("transmitBytes", defaultTransmitBytes);
helloSignal = HelperSharedPreferences.getSharedPreferencesInt(con, "helloSignal", defaultHelloSignal); helloSignal = agentPreferences.getInt("helloSignal", defaultHelloSignal);
roaming = HelperSharedPreferences.getSharedPreferencesInt(con, "roaming", defaultRoaming); roaming = agentPreferences.getInt("roaming", defaultRoaming);
bufferSize = HelperSharedPreferences.getSharedPreferencesLong(con, "bufferSize", defaultBufferSize);
}// end loadLastValues }// end loadLastValues
@ -256,40 +259,41 @@ public class Core {
con = context; con = context;
} }
SharedPreferences agentPreferences = con.getSharedPreferences(
con.getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
serverAddr = HelperSharedPreferences.getSharedPreferencesString(con, "serverAddr", defaultServerAddr); serverAddr = agentPreferences.getString("serverAddr", defaultServerAddr);
serverPort = HelperSharedPreferences.getSharedPreferencesString(con, "serverPort", defaultServerPort); serverPort = agentPreferences.getString("serverPort", defaultServerPort);
interval = HelperSharedPreferences.getSharedPreferencesInt(con, "interval", defaultInterval); interval = agentPreferences.getInt("interval", defaultInterval);
agentName = HelperSharedPreferences.getSharedPreferencesString(con, "agentName", defaultAgentName+"_"+Installation.id(context)); agentName = agentPreferences.getString("agentName", defaultAgentName+"_"+Installation.id(context));
mobileWebURL = HelperSharedPreferences.getSharedPreferencesString(con, "mobileWebURL", defaultmobileWebURL); mobileWebURL = agentPreferences.getString("mobileWebURL", defaultmobileWebURL);
gpsStatus = HelperSharedPreferences.getSharedPreferencesString(con, "gpsStatus", defaultGpsStatus); gpsStatus = agentPreferences.getString("gpsStatus", defaultGpsStatus);
memoryStatus = HelperSharedPreferences.getSharedPreferencesString(con, "memoryStatus", defaultMemoryStatus); memoryStatus = agentPreferences.getString("memoryStatus", defaultMemoryStatus);
taskStatus = HelperSharedPreferences.getSharedPreferencesString(con, "taskStatus", defaultTaskStatus); taskStatus = agentPreferences.getString("taskStatus", defaultTaskStatus);
task = HelperSharedPreferences.getSharedPreferencesString(con, "task", defaultTask); task = agentPreferences.getString("task", defaultTask);
taskHumanName = HelperSharedPreferences.getSharedPreferencesString(con, "taskHumanName", defaultTaskHumanName); taskHumanName = agentPreferences.getString("taskHumanName", defaultTaskHumanName);
taskRun = HelperSharedPreferences.getSharedPreferencesString(con, "taskRun", defaultTaskRun); taskRun = agentPreferences.getString("taskRun", defaultTaskRun);
password = HelperSharedPreferences.getSharedPreferencesString(con, "password", defaultPassword); password = agentPreferences.getString("password", defaultPassword);
passwordCheck = HelperSharedPreferences.getSharedPreferencesString(con, "passwordCheck", defaultPasswordCheck); passwordCheck = agentPreferences.getString("passwordCheck", defaultPasswordCheck);
simIDReport = HelperSharedPreferences.getSharedPreferencesString(con, "simIDReport", defaultSimIDReport); simIDReport = agentPreferences.getString("simIDReport", defaultSimIDReport);
DeviceUpTimeReport = HelperSharedPreferences.getSharedPreferencesString(con, "DeviceUpTimeReport", defaultDeviceUpTimeReport); DeviceUpTimeReport = agentPreferences.getString("DeviceUpTimeReport", defaultDeviceUpTimeReport);
NetworkOperatorReport = HelperSharedPreferences.getSharedPreferencesString(con, "NetworkOperatorReport", defaultNetworkOperatorReport); NetworkOperatorReport = agentPreferences.getString("NetworkOperatorReport", defaultNetworkOperatorReport);
NetworkTypeReport = HelperSharedPreferences.getSharedPreferencesString(con, "NetworkTypeReport", defaultNetworkTypeReport); NetworkTypeReport = agentPreferences.getString("NetworkTypeReport", defaultNetworkTypeReport);
PhoneTypeReport = HelperSharedPreferences.getSharedPreferencesString(con, "PhoneTypeReport", defaultPhoneTypeReport); PhoneTypeReport = agentPreferences.getString("PhoneTypeReport", defaultPhoneTypeReport);
SignalStrengthReport = HelperSharedPreferences.getSharedPreferencesString(con, "SignalStrengthReport", defaultSignalStrengthReport); SignalStrengthReport = agentPreferences.getString("SignalStrengthReport", defaultSignalStrengthReport);
ReceivedSMSReport = HelperSharedPreferences.getSharedPreferencesString(con, "ReceivedSMSReport", defaultReceivedSMSReport); ReceivedSMSReport = agentPreferences.getString("ReceivedSMSReport", defaultReceivedSMSReport);
SentSMSReport = HelperSharedPreferences.getSharedPreferencesString(con, "SentSMSReport", defaultSentSMSReport); SentSMSReport = agentPreferences.getString("SentSMSReport", defaultSentSMSReport);
IncomingCallsReport = HelperSharedPreferences.getSharedPreferencesString(con, "IncomingCallsReport", defaultIncomingCallsReport); IncomingCallsReport = agentPreferences.getString("IncomingCallsReport", defaultIncomingCallsReport);
MissedCallsReport = HelperSharedPreferences.getSharedPreferencesString(con, "MissedCallsReport", defaultMissedCallsReport); MissedCallsReport = agentPreferences.getString("MissedCallsReport", defaultMissedCallsReport);
OutgoingCallsReport = HelperSharedPreferences.getSharedPreferencesString(con, "OutgoingCallsReport", defaultOutgoingCallsReport); OutgoingCallsReport = agentPreferences.getString("OutgoingCallsReport", defaultOutgoingCallsReport);
BytesReceivedReport = HelperSharedPreferences.getSharedPreferencesString(con, "BytesReceivedReport", defaultBytesReceivedReport); BytesReceivedReport = agentPreferences.getString("BytesReceivedReport", defaultBytesReceivedReport);
BytesSentReport = HelperSharedPreferences.getSharedPreferencesString(con, "BytesSentReport", defaultBytesSentReport); BytesSentReport = agentPreferences.getString("BytesSentReport", defaultBytesSentReport);
HelloSignalReport = HelperSharedPreferences.getSharedPreferencesString(con, "HelloSignalReport", defaultHelloSignalReport); HelloSignalReport = agentPreferences.getString("HelloSignalReport", defaultHelloSignalReport);
BatteryLevelReport = HelperSharedPreferences.getSharedPreferencesString(con, "BatteryLevelReport", defaultBatteryLevelReport); BatteryLevelReport = agentPreferences.getString("BatteryLevelReport", defaultBatteryLevelReport);
RoamingReport = HelperSharedPreferences.getSharedPreferencesString(con, "RoamingReport", defaultRoamingReport); RoamingReport = agentPreferences.getString("RoamingReport", defaultRoamingReport);
InventoryReport = HelperSharedPreferences.getSharedPreferencesString(con, "InventoryReport", defaultInventoryReport); InventoryReport = agentPreferences.getString("InventoryReport", defaultInventoryReport);
NotificationCheck = HelperSharedPreferences.getSharedPreferencesString(con, "NotificationCheck", defaultNotificationCheck); NotificationCheck = agentPreferences.getString("NotificationCheck", defaultNotificationCheck);
bufferSize = HelperSharedPreferences.getSharedPreferencesLong(con, "bufferSize", defaultBufferSize);
}// end loadConf }// end loadConf
static synchronized public boolean updateConf(Context context) { static synchronized public boolean updateConf(Context context) {
@ -300,7 +304,7 @@ public class Core {
passwordCheck, DeviceUpTimeReport, NetworkOperatorReport, NetworkTypeReport, PhoneTypeReport, passwordCheck, DeviceUpTimeReport, NetworkOperatorReport, NetworkTypeReport, PhoneTypeReport,
SignalStrengthReport, ReceivedSMSReport, SentSMSReport, IncomingCallsReport, MissedCallsReport, SignalStrengthReport, ReceivedSMSReport, SentSMSReport, IncomingCallsReport, MissedCallsReport,
OutgoingCallsReport, BytesReceivedReport, BytesSentReport, HelloSignalReport, BatteryLevelReport, OutgoingCallsReport, BytesReceivedReport, BytesSentReport, HelloSignalReport, BatteryLevelReport,
RoamingReport, roaming, mobileWebURL, InventoryReport, NotificationCheck, bufferSize RoamingReport, roaming, mobileWebURL, InventoryReport ,NotificationCheck, bufferSize
); );
}// end updateConf }// end updateConf
@ -321,60 +325,120 @@ public class Core {
con = context; con = context;
} }
SharedPreferences agentPreferences = con.getSharedPreferences(
con.getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = agentPreferences.edit();
editor.putString("serverAddr", _serverAddr);
editor.putString("serverPort", _serverPort);
editor.putInt("interval", _interval);
editor.putString("agentName", _agentName);
editor.putString("gpsStatus", _gpsStatus);
editor.putString("memoryStatus", _memoryStatus);
editor.putString("taskStatus", _taskStatus);
editor.putString("task", _task);
editor.putString("taskHumanName", _taskHumanName);
editor.putString("simID", _simID);
editor.putString("simIDReport", _simIDReport);
editor.putLong("UpTime", _upTime);
editor.putString("networkOperator", _networkOperator);
editor.putInt("SMSReceived", _smsReceived);
editor.putInt("SMSSent", _smsSent);
editor.putString("networkType", _networkType);
editor.putString("phoneType", _phoneType);
editor.putInt("signalStrength", _signalStrength);
editor.putInt("incomingCalls", _incomingCalls);
editor.putInt("missedCalls", _missedCalls);
editor.putInt("outgoingCalls", _outgoingCalls);
editor.putLong("receiveBytes", _receiveBytes);
editor.putLong("transmitBytes", _transmitBytes);
editor.putString("password", _password);
editor.putString("passwordCheck", _passwordCheck);
editor.putInt("helloSignal", _helloSignal);
editor.putInt("roaming", _roaming);
editor.putString("DeviceUpTimeReport", _DeviceUpTimeReport);
editor.putString("NetworkOperatorReport", _NetworkOperatorReport);
editor.putString("NetworkTypeReport", _NetworkTypeReport);
editor.putString("PhoneTypeReport", _PhoneTypeReport);
editor.putString("SignalStrengthReport", _SignalStrengthReport);
editor.putString("ReceivedSMSReport", _ReceivedSMSReport);
editor.putString("SentSMSReport", _SentSMSReport);
editor.putString("IncomingCallsReport", _IncomingCallsReport);
editor.putString("MissedCallsReport", _MissedCallsReport);
editor.putString("OutgoingCallsReport", _OutgoingCallsReport);
editor.putString("BytesReceivedReport", _BytesReceivedReport);
editor.putString("BytesSentReport", _BytesSentReport);
editor.putString("HelloSignalReport", _HelloSignalReport);
editor.putString("BatteryLevelReport", _BatteryLevelReport);
editor.putString("RoamingReport", _RoamingReport);
editor.putString("InventoryReport", _InventoryReport);
editor.putString("NotificationCheck", _NotificationCheck);
editor.putString("mobileWebURL", _mobileWebURL);
editor.putLong("bufferSize", _bufferSize);
HelperSharedPreferences.putSharedPreferencesString(con, "serverAddr", _serverAddr); if (editor.commit()) {
HelperSharedPreferences.putSharedPreferencesString(con, "serverPort", _serverPort); return true;
HelperSharedPreferences.putSharedPreferencesInt(con, "interval", _interval); }
HelperSharedPreferences.putSharedPreferencesString(con, "agentName", _agentName); return false;
HelperSharedPreferences.putSharedPreferencesString(con, "gpsStatus", _gpsStatus);
HelperSharedPreferences.putSharedPreferencesString(con, "memoryStatus", _memoryStatus);
HelperSharedPreferences.putSharedPreferencesString(con, "taskStatus", _taskStatus);
HelperSharedPreferences.putSharedPreferencesString(con, "task", _task);
HelperSharedPreferences.putSharedPreferencesString(con, "taskHumanName", _taskHumanName);
HelperSharedPreferences.putSharedPreferencesString(con, "simID", _simID);
HelperSharedPreferences.putSharedPreferencesString(con, "simIDReport", _simIDReport);
HelperSharedPreferences.putSharedPreferencesLong(con, "upTime", _upTime);
HelperSharedPreferences.putSharedPreferencesString(con, "networkOperator", _networkOperator);
HelperSharedPreferences.putSharedPreferencesInt(con, "SMSReceived", _smsReceived);
HelperSharedPreferences.putSharedPreferencesInt(con, "SMSSent", _smsSent);
HelperSharedPreferences.putSharedPreferencesString(con, "networkType", _networkType);
HelperSharedPreferences.putSharedPreferencesString(con, "phoneType", _phoneType);
HelperSharedPreferences.putSharedPreferencesInt(con, "signalStrength", _signalStrength);
HelperSharedPreferences.putSharedPreferencesInt(con, "incomingCalls", _incomingCalls);
HelperSharedPreferences.putSharedPreferencesInt(con, "missedCalls", _missedCalls);
HelperSharedPreferences.putSharedPreferencesInt(con, "outgoingCalls", _outgoingCalls);
HelperSharedPreferences.putSharedPreferencesLong(con, "receiveBytes", _receiveBytes);
HelperSharedPreferences.putSharedPreferencesLong(con, "transmitBytes", _transmitBytes);
HelperSharedPreferences.putSharedPreferencesString(con, "password", _password);
HelperSharedPreferences.putSharedPreferencesString(con, "passwordCheck", _passwordCheck);
HelperSharedPreferences.putSharedPreferencesInt(con, "helloSignal", _helloSignal);
HelperSharedPreferences.putSharedPreferencesInt(con, "roaming", _roaming);
HelperSharedPreferences.putSharedPreferencesString(con, "DeviceUpTimeReport", _DeviceUpTimeReport);
HelperSharedPreferences.putSharedPreferencesString(con, "NetworkOperatorReport", _NetworkOperatorReport);
HelperSharedPreferences.putSharedPreferencesString(con, "NetworkTypeReport", _NetworkTypeReport);
HelperSharedPreferences.putSharedPreferencesString(con, "PhoneTypeReport", _PhoneTypeReport);
HelperSharedPreferences.putSharedPreferencesString(con, "SignalStrengthReport", _SignalStrengthReport);
HelperSharedPreferences.putSharedPreferencesString(con, "ReceivedSMSReport", _ReceivedSMSReport);
HelperSharedPreferences.putSharedPreferencesString(con, "SentSMSReport", _SentSMSReport);
HelperSharedPreferences.putSharedPreferencesString(con, "IncomingCallsReport", _IncomingCallsReport);
HelperSharedPreferences.putSharedPreferencesString(con, "MissedCallsReport", _MissedCallsReport);
HelperSharedPreferences.putSharedPreferencesString(con, "OutgoingCallsReport", _OutgoingCallsReport);
HelperSharedPreferences.putSharedPreferencesString(con, "BytesReceivedReport", _BytesReceivedReport);
HelperSharedPreferences.putSharedPreferencesString(con, "BytesSentReport", _BytesSentReport);
HelperSharedPreferences.putSharedPreferencesString(con, "HelloSignalReport", _HelloSignalReport);
HelperSharedPreferences.putSharedPreferencesString(con, "BatteryLevelReport", _BatteryLevelReport);
HelperSharedPreferences.putSharedPreferencesString(con, "RoamingReport", _RoamingReport);
HelperSharedPreferences.putSharedPreferencesString(con, "InventoryReport", _InventoryReport);
HelperSharedPreferences.putSharedPreferencesString(con, "NotificationCheck", _NotificationCheck);
HelperSharedPreferences.putSharedPreferencesString(con, "mobileWebURL", _mobileWebURL);
HelperSharedPreferences.putSharedPreferencesLong(con, "bufferSize", _bufferSize);
return true;
}// end updateConf }// end updateConf
public synchronized static void putSharedData(String preferenceName, String tokenName, String data, String type) {
int mode = Activity.MODE_PRIVATE;
SharedPreferences agentPreferences = con.getSharedPreferences(
con.getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
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();
}
public synchronized static String getSharedData(String preferenceName, String tokenName, String defaultValue, String type) {
int mode = Activity.MODE_PRIVATE;
SharedPreferences agentPreferences = con.getSharedPreferences(
con.getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
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// // //database//
@ -539,41 +603,5 @@ public class Core {
// return true; // return true;
// }// end updateConf // }// 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();
//
// }
} }

View File

@ -0,0 +1,139 @@
package pandroid.agent;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;
public class HelperSharedPreferences {
public static class SharedPreferencesKeys{
public static final String key1="key1";
public static final String key2="key2";
}
// public static void putSharedPreferencesInt(Context context, String key, int value){
// SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(context);
// Editor edit=preferences.edit();
// edit.putInt(key, value);
// edit.commit();
// }
//
// public static void putSharedPreferencesBoolean(Context context, String key, boolean val){
// SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(context);
// Editor edit=preferences.edit();
// edit.putBoolean(key, val);
// edit.commit();
// }
//
// public static void putSharedPreferencesString(Context context, String key, String val){
// SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(context);
// Editor edit=preferences.edit();
// edit.putString(key, val);
// edit.commit();
// }
//
// public static void putSharedPreferencesFloat(Context context, String key, float val){
// SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(context);
// Editor edit=preferences.edit();
// edit.putFloat(key, val);
// edit.commit();
// }
//
// public static void putSharedPreferencesLong(Context context, String key, long val){
// SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(context);
// Editor edit=preferences.edit();
// edit.putLong(key, val);
// edit.commit();
// }
//
// public static int getSharedPreferencesInt(Context context, String key, int _default){
// SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(context);
// return preferences.getInt(key, _default);
// }
//
// public static long getSharedPreferencesLong(Context context, String key, long _default){
// SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(context);
// return preferences.getLong(key, _default);
// }
//
// public static float getSharedPreferencesFloat(Context context, String key, float _default){
// SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(context);
// return preferences.getFloat(key, _default);
// }
//
// public static String getSharedPreferencesString(Context context, String key, String _default){
// SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(context);
// return preferences.getString(key, _default);
// }
public synchronized static void putSharedPreferencesInt(Context context, String name, int value){
DataBaseHandler db = new DataBaseHandler(context);
int id = getDataHandler(context, name).get_id();
DataHandler dh = new DataHandler(id, name, ""+value);
db.updateValue(dh);
}
public synchronized static void putSharedPreferencesLong(Context context, String name, long value){
DataBaseHandler db = new DataBaseHandler(context);
int id = getDataHandler(context, name).get_id();
DataHandler dh = new DataHandler(id, name, ""+value);
db.updateValue(dh);
}
public synchronized static void putSharedPreferencesFloat(Context context, String name, float value){
DataBaseHandler db = new DataBaseHandler(context);
int id = getDataHandler(context, name).get_id();
DataHandler dh = new DataHandler(id, name, ""+value);
db.updateValue(dh);
}
public synchronized static void putSharedPreferencesString(Context context, String name, String value){
DataBaseHandler db = new DataBaseHandler(context);
int id = getDataHandler(context, name).get_id();
DataHandler dh = new DataHandler(id, name, value);
db.updateValue(dh);
}
public synchronized static int getSharedPreferencesInt(Context context, String name, int i){
DataBaseHandler db = new DataBaseHandler(context);
return Integer.parseInt(db.getValue(name).get_value());
}
public synchronized static long getSharedPreferencesLong(Context context, String name, long l){
DataBaseHandler db = new DataBaseHandler(context);
return Long.parseLong(db.getValue(name).get_value());
}
public synchronized static float getSharedPreferencesFloat(Context context, String name, float f){
DataBaseHandler db = new DataBaseHandler(context);
return Float.parseFloat(db.getValue(name).get_value());
}
public synchronized static String getSharedPreferencesString(Context context, String name, String s){
DataBaseHandler db = new DataBaseHandler(context);
return db.getValue(name).get_value();
}
//Returns the DataHandler object of the given row "name"
public static synchronized DataHandler getDataHandler(Context context, String name){
DataBaseHandler db = new DataBaseHandler(context);
return db.getValue(name);
}
}

View File

@ -20,6 +20,8 @@ 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;
@ -36,7 +38,8 @@ public class PandroidAgent extends TabActivity {
int defaultInterval = 300; int defaultInterval = 300;
TabHost tabHost; TabHost tabHost;
static SharedPreferences agentPreferences;
static Editor editor;
@Override @Override
@ -46,7 +49,11 @@ public class PandroidAgent extends TabActivity {
//database// //database//
agentPreferences = this.getSharedPreferences(
this.getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
editor = agentPreferences.edit();
//Core.loadConfDatabase(this); //Core.loadConfDatabase(this);
//Core.loadLastValuesDatabase(this); //Core.loadLastValuesDatabase(this);
@ -137,7 +144,15 @@ public class PandroidAgent extends TabActivity {
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;
}
} }

View File

@ -63,7 +63,6 @@ import android.widget.Toast;
public class PandroidAgentListener extends Service { public class PandroidAgentListener extends Service {
private NotificationManager notificationManager; private NotificationManager notificationManager;
private Notification notification;
Handler h = new Handler(); Handler h = new Handler();
String lastGpsContactDateTime = ""; String lastGpsContactDateTime = "";
@ -72,22 +71,60 @@ public class PandroidAgentListener extends Service {
@Override @Override
public void onCreate() { public void onCreate() {
try {
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
} catch (Exception e) {
Log.e("notification", e.toString());
}
if(Core.NotificationCheck == "enabled"){
Notification notification = new Notification(R.drawable.icon, getText(R.string.ticker_text),
System.currentTimeMillis());
Intent notificationIntent = new Intent(this,PandroidAgent.class);
notificationIntent.setAction("android.intent.action.MAIN");
notificationIntent.addCategory("android.intent.category.LAUNCHER");
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, Notification.FLAG_NO_CLEAR);
notification.setLatestEventInfo(this, getText(R.string.notification_title), getText(R.string.notification_message), pendingIntent);
notification.flags |= Notification.FLAG_ONGOING_EVENT;
notificationManager.notify(1, notification);
}
else{
CancelNotification(getApplicationContext(),1);
}
} }
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock"); WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
wakeLock.acquire(); wakeLock.acquire();
updateValues(); updateValues();
contact(); contact();
try {
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
} catch (Exception e) {
Log.e("notification", e.toString());
}
Notification notification = new Notification(R.drawable.icon, getText(R.string.ticker_text),
System.currentTimeMillis());
Intent notificationIntent = new Intent(this,PandroidAgent.class);
notificationIntent.setAction("android.intent.action.MAIN");
notificationIntent.addCategory("android.intent.category.LAUNCHER");
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, Notification.FLAG_NO_CLEAR);
notification.setLatestEventInfo(this, getText(R.string.notification_title), getText(R.string.notification_message), pendingIntent);
notification.flags |= Notification.FLAG_ONGOING_EVENT;
if(Core.NotificationCheck == "enabled"){
notificationManager.notify(1, notification);
}
else{
CancelNotification(getApplicationContext(),1);
}
startForeground(42,notification);
wakeLock.release(); wakeLock.release();
stopSelf(startId); stopSelf(startId);
@ -162,7 +199,7 @@ public class PandroidAgentListener extends Service {
Date date = new Date(); Date date = new Date();
HelperSharedPreferences.putSharedPreferencesLong(this, "lastContact", date.getTime() / 1000); Core.putSharedData("PANDROID_DATA", "lastContact", Long.toString(date.getTime() / 1000), "long");
Boolean xmlBuilt = true; Boolean xmlBuilt = true;
String xml = ""; String xml = "";
@ -212,7 +249,7 @@ public class PandroidAgentListener extends Service {
String[] tentacleData = { String[] tentacleData = {
"-a", "-a",
HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "serverAddr", ""), Core.getSharedData("PANDROID_DATA", "serverAddr", "", "string"),
"-p", "-p",
Core.defaultServerPort, Core.defaultServerPort,
"-v", "-v",
@ -223,7 +260,7 @@ public class PandroidAgentListener extends Service {
tentacleRet = new tentacle_client().tentacle_client(tentacleData); tentacleRet = new tentacle_client().tentacle_client(tentacleData);
if(tentacleRet == 0) { if(tentacleRet == 0) {
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "contactError", 0); 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);
@ -235,7 +272,7 @@ public class PandroidAgentListener extends Service {
} }
if(tentacleRet == -1){ if(tentacleRet == -1){
//file not deleted //file not deleted
HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "contactError", 1); Core.putSharedData("PANDROID_DATA", "contactError", "1", "integer");
contact = false; contact = false;
} }
i++; i++;
@ -257,9 +294,10 @@ public class PandroidAgentListener extends Service {
String lastXML = buildXML(); String lastXML = buildXML();
String destFileName = ""; String destFileName = "";
String agentName = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "agentName", Core.defaultAgentName); String agentName = Core.getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
destFileName = agentName + "." + System.currentTimeMillis() + ".data"; destFileName = agentName + "." + System.currentTimeMillis() + ".data";
long bufferSize = 0; long bufferSize = 0;
String[] buffer = getApplicationContext().fileList(); String[] buffer = getApplicationContext().fileList();
@ -272,11 +310,11 @@ public class PandroidAgentListener extends Service {
//Check if size of buffer is less than a value //Check if size of buffer is less than a value
if((bufferSize/1024) < Core.bufferSize){ if((bufferSize/1024) < Core.bufferSize){
writeFile(destFileName, lastXML); writeFile(destFileName, lastXML);
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "lastXML", lastXML); Core.putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
}else{ }else{
//buffer full //buffer full
} }
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "lastXML", lastXML); Core.putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
return lastXML; return lastXML;
@ -315,15 +353,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 = ""+HelperSharedPreferences.getSharedPreferencesFloat(getApplicationContext(), "latitude", 181); String latitude = Core.getSharedData("PANDROID_DATA", "latitude", "181", "float");
String longitude = ""+HelperSharedPreferences.getSharedPreferencesFloat(getApplicationContext(), "longitude", 181); 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 = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "agentName", Core.defaultAgentName); String agentName = Core.getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
String interval = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "interval", Core.defaultInterval); 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+"' " +
@ -335,51 +373,51 @@ public class PandroidAgentListener extends Service {
// MODULES // // MODULES //
// // // //
String orientation = ""+HelperSharedPreferences.getSharedPreferencesFloat(getApplicationContext(), "orientation", 361); String orientation = Core.getSharedData("PANDROID_DATA", "orientation", "361", "float");
String proximity = ""+HelperSharedPreferences.getSharedPreferencesFloat(getApplicationContext(), "proximity", -1.0f); String proximity = Core.getSharedData("PANDROID_DATA", "proximity", "-1.0", "float");
String batteryLevel = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "batteryLevel", -1); String batteryLevel = Core.getSharedData("PANDROID_DATA", "batteryLevel", "-1", "integer");
String taskStatus = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "taskStatus", "disabled"); String taskStatus = Core.getSharedData("PANDROID_DATA", "taskStatus", "disabled", "string");
String taskRun = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "taskRun", "false"); String taskRun = Core.getSharedData("PANDROID_DATA", "taskRun", "false", "string");
String taskHumanName = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "taskHumanName", ""); String taskHumanName = Core.getSharedData("PANDROID_DATA", "taskHumanName", "", "string");
taskHumanName = StringEscapeUtils.escapeHtml4(taskHumanName); taskHumanName = StringEscapeUtils.escapeHtml4(taskHumanName);
String task = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "task", ""); String task = Core.getSharedData("PANDROID_DATA", "task", "", "string");
String memoryStatus = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "memoryStatus", Core.defaultMemoryStatus); String memoryStatus = Core.getSharedData("PANDROID_DATA", "memoryStatus", Core.defaultMemoryStatus, "string");
String availableRamKb = ""+HelperSharedPreferences.getSharedPreferencesLong(getApplicationContext(), "availableRamKb", 0); String availableRamKb = Core.getSharedData("PANDROID_DATA", "availableRamKb", "0" , "long");
String totalRamKb = ""+HelperSharedPreferences.getSharedPreferencesLong(getApplicationContext(), "totalRamKb", 0); String totalRamKb = Core.getSharedData("PANDROID_DATA", "totalRamKb", "0", "long");
String SimID = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "simID", Core.defaultSimID); String SimID = Core.getSharedData("PANDROID_DATA", "simID", Core.defaultSimID, "string");
String upTime = ""+HelperSharedPreferences.getSharedPreferencesLong(getApplicationContext(), "upTime", Core.defaultUpTime); String upTime = Core.getSharedData("PANDROID_DATA", "upTime", ""+Core.defaultUpTime, "long");
String networkOperator = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "networkOperator", Core.defaultNetworkOperator); String networkOperator = Core.getSharedData("PANDROID_DATA", "networkOperator", Core.defaultNetworkOperator, "string");
String SMSReceived = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "SMSReceived", Core.defaultSMSReceived); String SMSReceived = Core.getSharedData("PANDROID_DATA", "SMSReceived", ""+Core.defaultSMSReceived, "integer");
String SMSSent = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "SMSSent", Core.defaultSMSSent); String SMSSent = Core.getSharedData("PANDROID_DATA", "SMSSent", ""+Core.defaultSMSSent, "integer");
String networkType = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "networkType", Core.defaultNetworkType); String networkType = Core.getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
String phoneType = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "networkType", Core.defaultNetworkType); String phoneType = Core.getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
String signalStrength = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "signalStrength", Core.defaultSignalStrength); String signalStrength = Core.getSharedData("PANDROID_DATA", "signalStrength", ""+Core.defaultSignalStrength, "integer");
String incomingCalls = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "incomingCalls", Core.defaultIncomingCalls); String incomingCalls = Core.getSharedData("PANDROID_DATA", "incomingCalls", ""+Core.defaultIncomingCalls, "integer");
String missedCalls = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "missedCalls", Core.defaultMissedCalls); String missedCalls = Core.getSharedData("PANDROID_DATA", "missedCalls", ""+Core.defaultMissedCalls, "integer");
String outgoingCalls = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "outgoingCalls", Core.defaultOutgoingCalls); String outgoingCalls = Core.getSharedData("PANDROID_DATA", "outgoingCalls", ""+Core.defaultOutgoingCalls, "integer");
String receiveBytes = ""+HelperSharedPreferences.getSharedPreferencesLong(getApplicationContext(), "receiveBytes", Core.defaultReceiveBytes); String receiveBytes = Core.getSharedData("PANDROID_DATA", "receiveBytes", ""+Core.defaultReceiveBytes, "long");
String transmitBytes = ""+HelperSharedPreferences.getSharedPreferencesLong(getApplicationContext(), "transmitBytes", Core.defaultTransmitBytes); String transmitBytes = Core.getSharedData("PANDROID_DATA", "transmitBytes", ""+Core.defaultTransmitBytes, "long");
String helloSignal = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "helloSignal", Core.defaultHelloSignal); String helloSignal = Core.getSharedData("PANDROID_DATA", "helloSignal", ""+Core.defaultHelloSignal, "integer");
String roaming = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "roaming", Core.defaultRoaming); String roaming = Core.getSharedData("PANDROID_DATA", "roaming", ""+Core.defaultRoaming, "integer");
String simIDReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "simIDReport", Core.defaultSimIDReport); String simIDReport = Core.getSharedData("PANDROID_DATA", "simIDReport", Core.defaultSimIDReport, "string");
String DeviceUpTimeReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "DeviceUpTimeReport", Core.defaultDeviceUpTimeReport); String DeviceUpTimeReport = Core.getSharedData("PANDROID_DATA", "DeviceUpTimeReport", Core.defaultDeviceUpTimeReport, "string");
String NetworkOperatorReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "NetworkOperatorReport", Core.defaultNetworkOperatorReport); String NetworkOperatorReport = Core.getSharedData("PANDROID_DATA", "NetworkOperatorReport", Core.defaultNetworkOperatorReport, "string");
String NetworkTypeReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "NetworkTypeReport", Core.defaultNetworkTypeReport); String NetworkTypeReport = Core.getSharedData("PANDROID_DATA", "NetworkTypeReport", Core.defaultNetworkTypeReport, "string");
String PhoneTypeReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "PhoneTypeReport", Core.defaultPhoneTypeReport); String PhoneTypeReport = Core.getSharedData("PANDROID_DATA", "PhoneTypeReport", Core.defaultPhoneTypeReport, "string");
String SignalStrengthReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "SignalStrengthReport", Core.defaultSignalStrengthReport); String SignalStrengthReport = Core.getSharedData("PANDROID_DATA", "SignalStrengthReport", Core.defaultSignalStrengthReport, "string");
String ReceivedSMSReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "ReceivedSMSReport", Core.defaultReceivedSMSReport); String ReceivedSMSReport = Core.getSharedData("PANDROID_DATA", "ReceivedSMSReport", Core.defaultReceivedSMSReport, "string");
String SentSMSReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "SentSMSReport", Core.defaultSentSMSReport); String SentSMSReport = Core.getSharedData("PANDROID_DATA", "SentSMSReport", Core.defaultSentSMSReport, "string");
String IncomingCallsReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "IncomingCallsReport", Core.defaultIncomingCallsReport); String IncomingCallsReport = Core.getSharedData("PANDROID_DATA", "IncomingCallsReport", Core.defaultIncomingCallsReport, "string");
String MissedCallsReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "MissedCallsReport", Core.defaultMissedCallsReport); String MissedCallsReport = Core.getSharedData("PANDROID_DATA", "MissedCallsReport", Core.defaultMissedCallsReport, "string");
String OutgoingCallsReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "OutgoingCallsReport", Core.defaultOutgoingCallsReport); String OutgoingCallsReport = Core.getSharedData("PANDROID_DATA", "OutgoingCallsReport", Core.defaultOutgoingCallsReport, "string");
String BytesReceivedReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "BytesReceivedReport", Core.defaultBytesReceivedReport); String BytesReceivedReport = Core.getSharedData("PANDROID_DATA", "BytesReceivedReport", Core.defaultBytesReceivedReport, "string");
String BytesSentReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "BytesSentReport", Core.defaultBytesSentReport); String BytesSentReport = Core.getSharedData("PANDROID_DATA", "BytesSentReport", Core.defaultBytesSentReport, "string");
String HelloSignalReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "HelloSignalReport", Core.defaultHelloSignalReport); String HelloSignalReport = Core.getSharedData("PANDROID_DATA", "HelloSignalReport", Core.defaultHelloSignalReport, "string");
String BatteryLevelReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "BatteryLevelReport", Core.defaultBatteryLevelReport); String BatteryLevelReport = Core.getSharedData("PANDROID_DATA", "BatteryLevelReport", Core.defaultBatteryLevelReport, "string");
String RoamingReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "RoamingReport", Core.defaultRoamingReport); String RoamingReport = Core.getSharedData("PANDROID_DATA", "RoamingReport", Core.defaultRoamingReport, "string");
String InventoryReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "InventoryReport", Core.defaultInventoryReport); String InventoryReport = Core.getSharedData("PANDROID_DATA", "InventoryReport", Core.defaultInventoryReport, "string");
if(InventoryReport.equals("enabled")) if(InventoryReport.equals("enabled"))
{ {
@ -564,8 +602,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);
//} //}
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "latitude", (float) loc.getLatitude()); Core.putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "longitude", (float) loc.getLongitude()); Core.putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
} }
else { else {
Criteria criteria = new Criteria(); Criteria criteria = new Criteria();
@ -585,8 +623,10 @@ 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) {
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "latitude",(float) location.getLatitude()); Core.putSharedData("PANDROID_DATA", "latitude",
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "longitude",(float) location.getLongitude()); Double.valueOf(location.getLatitude()).toString(), "float");
Core.putSharedData("PANDROID_DATA", "longitude",
Double.valueOf(location.getLongitude()).toString(), "float");
} }
public void onStatusChanged(String s, int i, Bundle bundle) { public void onStatusChanged(String s, int i, Bundle bundle) {
@ -595,7 +635,8 @@ 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) {
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "enabled_location_provider", "disabled"); Core.putSharedData("PANDROID_DATA", "enabled_location_provider",
"disabled", "string");
} }
}); });
} }
@ -609,7 +650,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) {
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "batteryLevel", (rawlevel * 100) / scale); Core.putSharedData("PANDROID_DATA", "batteryLevel", Integer.valueOf((rawlevel * 100) / scale).toString(), "integer");
} }
} }
@ -676,7 +717,7 @@ public class PandroidAgentListener extends Service {
private void updateValues() { private void updateValues() {
batteryLevel(); batteryLevel();
String gpsStatus = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "gpsStatus", Core.defaultGpsStatus); 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");
@ -684,8 +725,8 @@ public class PandroidAgentListener extends Service {
} }
else { else {
Log.d("PANDROID AGENT", "DISABLED"); Log.d("PANDROID AGENT", "DISABLED");
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "latitude", 181.0f); Core.putSharedData("PANDROID_DATA", "latitude", "181.0", "float");
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "longitude", 181.0f); Core.putSharedData("PANDROID_DATA", "longitude", "181.0", "float");
} }
//sensors(); //sensors();
@ -708,7 +749,7 @@ public class PandroidAgentListener extends Service {
} }
private void getMemoryStatus() { private void getMemoryStatus() {
String memoryStatus = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "memoryStatus", Core.defaultMemoryStatus); String memoryStatus = Core.getSharedData("PANDROID_DATA", "memoryStatus", Core.defaultMemoryStatus, "string");
long availableRamKb = 0; long availableRamKb = 0;
long totalRamKb = 0; long totalRamKb = 0;
@ -734,14 +775,14 @@ public class PandroidAgentListener extends Service {
} }
} }
HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "availableRamKb", availableRamKb); Core.putSharedData("PANDROID_DATA", "availableRamKb", "" + availableRamKb, "long");
HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "totalRamKb", totalRamKb); Core.putSharedData("PANDROID_DATA", "totalRamKb", "" + totalRamKb, "long");
}// end getMemoryStatus }// end getMemoryStatus
private void getTaskStatus() { private void getTaskStatus() {
String taskStatus = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "taskStatus", Core.defaultTaskStatus); String taskStatus = Core.getSharedData("PANDROID_DATA", "taskStatus", Core.defaultTaskStatus, "string");
String task = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "task", Core.defaultTask); String task = Core.getSharedData("PANDROID_DATA", "task", Core.defaultTask, "string");
String taskHumanName = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "taskHumanName", Core.defaultTaskHumanName); String taskHumanName = Core.getSharedData("PANDROID_DATA", "taskHumanName", Core.defaultTaskHumanName, "string");
String run = "false"; String run = "false";
if (taskStatus.equals("enabled")) { if (taskStatus.equals("enabled")) {
@ -761,7 +802,7 @@ public class PandroidAgentListener extends Service {
} }
} }
} }
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "taskRun", run); Core.putSharedData("PANDROID_DATA", "taskRun", run, "string");
}//end getTaskStatus }//end getTaskStatus
/** /**
@ -769,12 +810,12 @@ public class PandroidAgentListener extends Service {
*/ */
private void getSimID(){ private void getSimID(){
String simID = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "simID", Core.defaultSimID); 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();
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "simID", simID); 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
@ -783,7 +824,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)
HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "upTime", upTime); 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...
@ -795,15 +836,15 @@ public class PandroidAgentListener extends Service {
networkOperator = telephonyManager.getNetworkOperatorName(); networkOperator = telephonyManager.getNetworkOperatorName();
if(networkOperator != null) if(networkOperator != null)
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "networkOperator", networkOperator); 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
*/ */
private void getSMSSent(){ private void getSMSSent(){
int SMSSent = Core.defaultSMSSent; String SMSSent = ""+Core.defaultSMSSent;
SMSSent = HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "SMSSent", Core.defaultSMSSent); 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;
@ -819,10 +860,10 @@ public class PandroidAgentListener extends Service {
c.close(); c.close();
SMSSent = totalMessages; SMSSent =""+ totalMessages;
if(SMSSent != 0) if(SMSSent != null)
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "SMSSent", SMSSent); Core.putSharedData("PANDROID_DATA", "SMSSent", SMSSent, "integer");
}// end getSMSSent }// end getSMSSent
/** /**
@ -886,7 +927,7 @@ public class PandroidAgentListener extends Service {
break; break;
} }
if(networkType != null) if(networkType != null)
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "networkType", networkType); Core.putSharedData("PANDROID_DATA", "networkType", networkType, "string");
}// end getNetworkType }// end getNetworkType
@ -915,7 +956,7 @@ public class PandroidAgentListener extends Service {
break; break;
} }
if(phoneType != null) if(phoneType != null)
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "phoneType", phoneType); Core.putSharedData("PANDROID_DATA", "phoneType", phoneType, "string");
}// end getPhoneType }// end getPhoneType
/** /**
@ -949,9 +990,9 @@ public class PandroidAgentListener extends Service {
c.moveToNext(); c.moveToNext();
} }
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "incomingCalls", incoming); Core.putSharedData("PANDROID_DATA", "incomingCalls", ""+incoming, "integer");
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "missedCalls", missed); Core.putSharedData("PANDROID_DATA", "missedCalls", ""+missed, "integer");
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "outgoingCalls", outgoing); Core.putSharedData("PANDROID_DATA", "outgoingCalls", ""+outgoing, "integer");
} }
c.close(); c.close();
@ -972,17 +1013,17 @@ public class PandroidAgentListener extends Service {
public void onSignalStrengthsChanged(SignalStrength signalStrength) public void onSignalStrengthsChanged(SignalStrength signalStrength)
{ {
super.onSignalStrengthsChanged(signalStrength); super.onSignalStrengthsChanged(signalStrength);
int signalStrengthValue = Core.defaultSignalStrength; String signalStrengthValue = ""+Core.defaultSignalStrength;
if (signalStrength.isGsm()) { if (signalStrength.isGsm()) {
if (signalStrength.getGsmSignalStrength() != 99) if (signalStrength.getGsmSignalStrength() != 99)
signalStrengthValue = (signalStrength.getGsmSignalStrength() * 2 - 113); signalStrengthValue =""+ (signalStrength.getGsmSignalStrength() * 2 - 113);
else else
signalStrengthValue = (signalStrength.getGsmSignalStrength()); signalStrengthValue =""+ (signalStrength.getGsmSignalStrength());
} }
else{ else{
signalStrengthValue = (signalStrength.getCdmaDbm()); signalStrengthValue ="" + (signalStrength.getCdmaDbm());
} }
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "signalStrength", signalStrengthValue); Core.putSharedData("PANDROID_DATA", "signalStrength", signalStrengthValue, "integer");
} }
}; };
/** /**
@ -996,8 +1037,8 @@ public class PandroidAgentListener extends Service {
if (receiveBytes != TrafficStats.UNSUPPORTED && transmitBytes != TrafficStats.UNSUPPORTED) if (receiveBytes != TrafficStats.UNSUPPORTED && transmitBytes != TrafficStats.UNSUPPORTED)
{ {
HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "receiveBytes", receiveBytes); Core.putSharedData("PANDROID_DATA", "receiveBytes", ""+receiveBytes, "long" );
HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "transmitBytes", transmitBytes); Core.putSharedData("PANDROID_DATA", "transmitBytes", ""+transmitBytes, "long" );
} }
} }
/** /**
@ -1009,9 +1050,9 @@ public class PandroidAgentListener extends Service {
boolean roaming = telephone.isNetworkRoaming(); boolean roaming = telephone.isNetworkRoaming();
if(roaming) if(roaming)
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "roaming", 1); Core.putSharedData("PANDROID_DATA", "roaming", "1", "integer" );
else else
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "roaming", 0); Core.putSharedData("PANDROID_DATA", "roaming", "0", "integer" );
} }
@ -1075,8 +1116,8 @@ public class PandroidAgentListener extends Service {
@Override @Override
public void onLocationChanged(Location loc) { public void onLocationChanged(Location loc) {
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "latitude", (float)loc.getLatitude()); Core.putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "longitude", (float)loc.getLongitude()); Core.putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
} }
@Override @Override

View File

@ -36,14 +36,14 @@ import android.util.Log;
int defaultSMSReceived = 0; int defaultSMSReceived = 0;
int mode = Activity.MODE_PRIVATE; int mode = Activity.MODE_PRIVATE;
SharedPreferences pref = PandroidAgent.getSharedPrefs();
int sms = HelperSharedPreferences.getSharedPreferencesInt(context, "SMSReceived", defaultSMSReceived); int sms = pref.getInt("SMSReceived", defaultSMSReceived);
sms++; sms++;
SharedPreferences.Editor editor = pref.edit();
HelperSharedPreferences.putSharedPreferencesInt(context, "SMSReceived", sms); editor.putInt("SMSReceived", sms);
editor.commit();
}//end if }//end if

View File

@ -745,4 +745,4 @@ public class Setup extends Activity {
nMgr.cancel(notifyId); nMgr.cancel(notifyId);
} }
} }

View File

@ -18,6 +18,7 @@ import java.util.Date;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
//import android.content.SharedPreferences;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;