diff --git a/pandora_agents/android/ChangeLog b/pandora_agents/android/ChangeLog index 853054c629..1e0b33109a 100644 --- a/pandora_agents/android/ChangeLog +++ b/pandora_agents/android/ChangeLog @@ -1,3 +1,18 @@ +2013-04-27 Mark Holland + + * 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 * assets/database/pandroid.zip: Added buffer size initial value. diff --git a/pandora_agents/android/src/pandroid/agent/Core.java b/pandora_agents/android/src/pandroid/agent/Core.java index ed186d3487..ff5898db1a 100644 --- a/pandora_agents/android/src/pandroid/agent/Core.java +++ b/pandora_agents/android/src/pandroid/agent/Core.java @@ -19,7 +19,7 @@ import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; - +import android.content.SharedPreferences; //import android.util.Log; @@ -42,9 +42,9 @@ public class Core { // 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 int defaultInterval = 300; + static volatile public int defaultInterval = 20; static volatile public String defaultAgentName = "pandroid"; static volatile public String defaultmobileWebURL = "firefly.artica.es/pandora_demo/mobile"; 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 long defaultBufferSize = 256; + static volatile public String defaultPassword = ""; static volatile public Context con = null; @@ -179,6 +180,7 @@ public class Core { + public Core() { } @@ -216,38 +218,39 @@ public class Core { con = context; } - + SharedPreferences agentPreferences = con.getSharedPreferences( + con.getString(R.string.const_string_preferences), + Activity.MODE_PRIVATE); - latitude = HelperSharedPreferences.getSharedPreferencesFloat(con, "latitude", CONST_INVALID_COORDS); - longitude = HelperSharedPreferences.getSharedPreferencesFloat(con, "longitude", CONST_INVALID_COORDS); - batteryLevel = HelperSharedPreferences.getSharedPreferencesInt(con, "batteryLevel", CONST_INVALID_BATTERY_LEVEL); - orientation = HelperSharedPreferences.getSharedPreferencesFloat(con, "orientation", CONST_INVALID_ORIENTATION); - proximity = HelperSharedPreferences.getSharedPreferencesFloat(con, "proximity", CONST_INVALID_PROXIMITY); - taskStatus = HelperSharedPreferences.getSharedPreferencesString(con, "taskStatus", defaultTaskStatus); - task = HelperSharedPreferences.getSharedPreferencesString(con, "task", defaultTask); - taskHumanName = HelperSharedPreferences.getSharedPreferencesString(con, "taskHumanName", defaultTaskHumanName); - taskRun = HelperSharedPreferences.getSharedPreferencesString(con, "taskRun", defaultTaskRun); - memoryStatus = HelperSharedPreferences.getSharedPreferencesString(con, "memoryStatus", defaultMemoryStatus); - availableRamKb = HelperSharedPreferences.getSharedPreferencesLong(con, "availableRamKb", defaultRam); - totalRamKb = HelperSharedPreferences.getSharedPreferencesLong(con, "totalRamKb", defaultRam); - lastContact = HelperSharedPreferences.getSharedPreferencesLong(con, "lastContact", defaultContact); - contactError = HelperSharedPreferences.getSharedPreferencesInt(con, "contactError", defaultContactError); - simID = HelperSharedPreferences.getSharedPreferencesString(con, "simID", defaultSimID); - upTime = HelperSharedPreferences.getSharedPreferencesLong(con, "upTime", Core.defaultUpTime); - SMSReceived = HelperSharedPreferences.getSharedPreferencesInt(con, "SMSReceived", defaultSMSReceived); - SMSSent = HelperSharedPreferences.getSharedPreferencesInt(con, "SMSSent", defaultSMSSent); - networkOperator = HelperSharedPreferences.getSharedPreferencesString(con, "networkOperator", defaultNetworkOperator); - networkType = HelperSharedPreferences.getSharedPreferencesString(con, "networkType", defaultNetworkType); - phoneType = HelperSharedPreferences.getSharedPreferencesString(con, "phoneType", defaultPhoneType); - signalStrength = HelperSharedPreferences.getSharedPreferencesInt(con, "signalStrength", defaultSignalStrength); - incomingCalls = HelperSharedPreferences.getSharedPreferencesInt(con, "incomingCalls", defaultIncomingCalls); - missedCalls = HelperSharedPreferences.getSharedPreferencesInt(con, "missedCalls", defaultMissedCalls); - outgoingCalls = HelperSharedPreferences.getSharedPreferencesInt(con, "outgoingCalls", defaultOutgoingCalls); - receiveBytes = HelperSharedPreferences.getSharedPreferencesLong(con, "receiveBytes", defaultReceiveBytes); - transmitBytes = HelperSharedPreferences.getSharedPreferencesLong(con, "transmitBytes", defaultTransmitBytes); - helloSignal = HelperSharedPreferences.getSharedPreferencesInt(con, "helloSignal", defaultHelloSignal); - roaming = HelperSharedPreferences.getSharedPreferencesInt(con, "roaming", defaultRoaming); - bufferSize = HelperSharedPreferences.getSharedPreferencesLong(con, "bufferSize", defaultBufferSize); + latitude = agentPreferences.getFloat("latitude", CONST_INVALID_COORDS); + longitude = agentPreferences.getFloat("longitude", CONST_INVALID_COORDS); + batteryLevel = agentPreferences.getInt("batteryLevel", CONST_INVALID_BATTERY_LEVEL); + orientation = agentPreferences.getFloat("orientation", CONST_INVALID_ORIENTATION); + proximity = agentPreferences.getFloat("proximity", CONST_INVALID_PROXIMITY); + taskStatus = agentPreferences.getString("taskStatus", defaultTaskStatus); + task = agentPreferences.getString("task", defaultTask); + taskHumanName = agentPreferences.getString("taskHumanName", defaultTaskHumanName); + taskRun = agentPreferences.getString("taskRun", defaultTaskRun); + memoryStatus = agentPreferences.getString("memoryStatus", defaultMemoryStatus); + availableRamKb = agentPreferences.getLong("availableRamKb", defaultRam); + totalRamKb = agentPreferences.getLong("totalRamKb", defaultRam); + lastContact = agentPreferences.getLong("lastContact", defaultContact); + contactError = agentPreferences.getInt("contactError", defaultContactError); + simID = agentPreferences.getString("simID", defaultSimID); + upTime = agentPreferences.getLong("upTime", Core.defaultUpTime); + SMSReceived = agentPreferences.getInt("SMSReceived", defaultSMSReceived); + SMSSent = agentPreferences.getInt("SMSSent", defaultSMSSent); + networkOperator = agentPreferences.getString("networkOperator", defaultNetworkOperator); + networkType = agentPreferences.getString("networkType", defaultNetworkType); + phoneType = agentPreferences.getString("phoneType", defaultPhoneType); + signalStrength = agentPreferences.getInt("signalStrength", defaultSignalStrength); + incomingCalls = agentPreferences.getInt("incomingCalls", defaultIncomingCalls); + missedCalls = agentPreferences.getInt("missedCalls", defaultMissedCalls); + outgoingCalls = agentPreferences.getInt("outgoingCalls", defaultOutgoingCalls); + receiveBytes = agentPreferences.getLong("receiveBytes", defaultReceiveBytes); + transmitBytes = agentPreferences.getLong("transmitBytes", defaultTransmitBytes); + helloSignal = agentPreferences.getInt("helloSignal", defaultHelloSignal); + roaming = agentPreferences.getInt("roaming", defaultRoaming); }// end loadLastValues @@ -256,40 +259,41 @@ public class Core { con = context; } - + SharedPreferences agentPreferences = con.getSharedPreferences( + con.getString(R.string.const_string_preferences), + Activity.MODE_PRIVATE); - serverAddr = HelperSharedPreferences.getSharedPreferencesString(con, "serverAddr", defaultServerAddr); - serverPort = HelperSharedPreferences.getSharedPreferencesString(con, "serverPort", defaultServerPort); - interval = HelperSharedPreferences.getSharedPreferencesInt(con, "interval", defaultInterval); - agentName = HelperSharedPreferences.getSharedPreferencesString(con, "agentName", defaultAgentName+"_"+Installation.id(context)); - mobileWebURL = HelperSharedPreferences.getSharedPreferencesString(con, "mobileWebURL", defaultmobileWebURL); - gpsStatus = HelperSharedPreferences.getSharedPreferencesString(con, "gpsStatus", defaultGpsStatus); - memoryStatus = HelperSharedPreferences.getSharedPreferencesString(con, "memoryStatus", defaultMemoryStatus); - taskStatus = HelperSharedPreferences.getSharedPreferencesString(con, "taskStatus", defaultTaskStatus); - task = HelperSharedPreferences.getSharedPreferencesString(con, "task", defaultTask); - taskHumanName = HelperSharedPreferences.getSharedPreferencesString(con, "taskHumanName", defaultTaskHumanName); - taskRun = HelperSharedPreferences.getSharedPreferencesString(con, "taskRun", defaultTaskRun); - password = HelperSharedPreferences.getSharedPreferencesString(con, "password", defaultPassword); - passwordCheck = HelperSharedPreferences.getSharedPreferencesString(con, "passwordCheck", defaultPasswordCheck); - simIDReport = HelperSharedPreferences.getSharedPreferencesString(con, "simIDReport", defaultSimIDReport); - DeviceUpTimeReport = HelperSharedPreferences.getSharedPreferencesString(con, "DeviceUpTimeReport", defaultDeviceUpTimeReport); - NetworkOperatorReport = HelperSharedPreferences.getSharedPreferencesString(con, "NetworkOperatorReport", defaultNetworkOperatorReport); - NetworkTypeReport = HelperSharedPreferences.getSharedPreferencesString(con, "NetworkTypeReport", defaultNetworkTypeReport); - PhoneTypeReport = HelperSharedPreferences.getSharedPreferencesString(con, "PhoneTypeReport", defaultPhoneTypeReport); - SignalStrengthReport = HelperSharedPreferences.getSharedPreferencesString(con, "SignalStrengthReport", defaultSignalStrengthReport); - ReceivedSMSReport = HelperSharedPreferences.getSharedPreferencesString(con, "ReceivedSMSReport", defaultReceivedSMSReport); - SentSMSReport = HelperSharedPreferences.getSharedPreferencesString(con, "SentSMSReport", defaultSentSMSReport); - IncomingCallsReport = HelperSharedPreferences.getSharedPreferencesString(con, "IncomingCallsReport", defaultIncomingCallsReport); - MissedCallsReport = HelperSharedPreferences.getSharedPreferencesString(con, "MissedCallsReport", defaultMissedCallsReport); - OutgoingCallsReport = HelperSharedPreferences.getSharedPreferencesString(con, "OutgoingCallsReport", defaultOutgoingCallsReport); - BytesReceivedReport = HelperSharedPreferences.getSharedPreferencesString(con, "BytesReceivedReport", defaultBytesReceivedReport); - BytesSentReport = HelperSharedPreferences.getSharedPreferencesString(con, "BytesSentReport", defaultBytesSentReport); - HelloSignalReport = HelperSharedPreferences.getSharedPreferencesString(con, "HelloSignalReport", defaultHelloSignalReport); - BatteryLevelReport = HelperSharedPreferences.getSharedPreferencesString(con, "BatteryLevelReport", defaultBatteryLevelReport); - RoamingReport = HelperSharedPreferences.getSharedPreferencesString(con, "RoamingReport", defaultRoamingReport); - InventoryReport = HelperSharedPreferences.getSharedPreferencesString(con, "InventoryReport", defaultInventoryReport); - NotificationCheck = HelperSharedPreferences.getSharedPreferencesString(con, "NotificationCheck", defaultNotificationCheck); - bufferSize = HelperSharedPreferences.getSharedPreferencesLong(con, "bufferSize", defaultBufferSize); + serverAddr = agentPreferences.getString("serverAddr", defaultServerAddr); + serverPort = agentPreferences.getString("serverPort", defaultServerPort); + interval = agentPreferences.getInt("interval", defaultInterval); + agentName = agentPreferences.getString("agentName", defaultAgentName+"_"+Installation.id(context)); + mobileWebURL = agentPreferences.getString("mobileWebURL", defaultmobileWebURL); + gpsStatus = agentPreferences.getString("gpsStatus", defaultGpsStatus); + memoryStatus = agentPreferences.getString("memoryStatus", defaultMemoryStatus); + taskStatus = agentPreferences.getString("taskStatus", defaultTaskStatus); + task = agentPreferences.getString("task", defaultTask); + taskHumanName = agentPreferences.getString("taskHumanName", defaultTaskHumanName); + taskRun = agentPreferences.getString("taskRun", defaultTaskRun); + password = agentPreferences.getString("password", defaultPassword); + passwordCheck = agentPreferences.getString("passwordCheck", defaultPasswordCheck); + simIDReport = agentPreferences.getString("simIDReport", defaultSimIDReport); + DeviceUpTimeReport = agentPreferences.getString("DeviceUpTimeReport", defaultDeviceUpTimeReport); + NetworkOperatorReport = agentPreferences.getString("NetworkOperatorReport", defaultNetworkOperatorReport); + NetworkTypeReport = agentPreferences.getString("NetworkTypeReport", defaultNetworkTypeReport); + PhoneTypeReport = agentPreferences.getString("PhoneTypeReport", defaultPhoneTypeReport); + SignalStrengthReport = agentPreferences.getString("SignalStrengthReport", defaultSignalStrengthReport); + ReceivedSMSReport = agentPreferences.getString("ReceivedSMSReport", defaultReceivedSMSReport); + SentSMSReport = agentPreferences.getString("SentSMSReport", defaultSentSMSReport); + IncomingCallsReport = agentPreferences.getString("IncomingCallsReport", defaultIncomingCallsReport); + MissedCallsReport = agentPreferences.getString("MissedCallsReport", defaultMissedCallsReport); + OutgoingCallsReport = agentPreferences.getString("OutgoingCallsReport", defaultOutgoingCallsReport); + BytesReceivedReport = agentPreferences.getString("BytesReceivedReport", defaultBytesReceivedReport); + BytesSentReport = agentPreferences.getString("BytesSentReport", defaultBytesSentReport); + HelloSignalReport = agentPreferences.getString("HelloSignalReport", defaultHelloSignalReport); + BatteryLevelReport = agentPreferences.getString("BatteryLevelReport", defaultBatteryLevelReport); + RoamingReport = agentPreferences.getString("RoamingReport", defaultRoamingReport); + InventoryReport = agentPreferences.getString("InventoryReport", defaultInventoryReport); + NotificationCheck = agentPreferences.getString("NotificationCheck", defaultNotificationCheck); }// end loadConf static synchronized public boolean updateConf(Context context) { @@ -300,7 +304,7 @@ public class Core { passwordCheck, DeviceUpTimeReport, NetworkOperatorReport, NetworkTypeReport, PhoneTypeReport, SignalStrengthReport, ReceivedSMSReport, SentSMSReport, IncomingCallsReport, MissedCallsReport, OutgoingCallsReport, BytesReceivedReport, BytesSentReport, HelloSignalReport, BatteryLevelReport, - RoamingReport, roaming, mobileWebURL, InventoryReport, NotificationCheck, bufferSize + RoamingReport, roaming, mobileWebURL, InventoryReport ,NotificationCheck, bufferSize ); }// end updateConf @@ -321,60 +325,120 @@ public class Core { 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); - HelperSharedPreferences.putSharedPreferencesString(con, "serverPort", _serverPort); - HelperSharedPreferences.putSharedPreferencesInt(con, "interval", _interval); - HelperSharedPreferences.putSharedPreferencesString(con, "agentName", _agentName); - 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; + if (editor.commit()) { + return true; + } + return false; }// 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// @@ -539,41 +603,5 @@ public class Core { // 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(); -// -// } + } diff --git a/pandora_agents/android/src/pandroid/agent/HelperSharedPreferences.java b/pandora_agents/android/src/pandroid/agent/HelperSharedPreferences.java new file mode 100644 index 0000000000..31992a4649 --- /dev/null +++ b/pandora_agents/android/src/pandroid/agent/HelperSharedPreferences.java @@ -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); + } + + + + +} diff --git a/pandora_agents/android/src/pandroid/agent/PandroidAgent.java b/pandora_agents/android/src/pandroid/agent/PandroidAgent.java index 0ae8ea1cbe..e838e3dcd8 100755 --- a/pandora_agents/android/src/pandroid/agent/PandroidAgent.java +++ b/pandora_agents/android/src/pandroid/agent/PandroidAgent.java @@ -20,6 +20,8 @@ import android.app.Activity; import android.app.TabActivity; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; import android.os.Bundle; import android.os.Handler; import android.telephony.TelephonyManager; @@ -36,7 +38,8 @@ public class PandroidAgent extends TabActivity { int defaultInterval = 300; TabHost tabHost; - + static SharedPreferences agentPreferences; + static Editor editor; @Override @@ -46,7 +49,11 @@ public class PandroidAgent extends TabActivity { //database// + agentPreferences = this.getSharedPreferences( + this.getString(R.string.const_string_preferences), + Activity.MODE_PRIVATE); + editor = agentPreferences.edit(); //Core.loadConfDatabase(this); //Core.loadLastValuesDatabase(this); @@ -137,7 +144,15 @@ public class PandroidAgent extends TabActivity { 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; + } } \ No newline at end of file diff --git a/pandora_agents/android/src/pandroid/agent/PandroidAgentListener.java b/pandora_agents/android/src/pandroid/agent/PandroidAgentListener.java index 9eb85bd57a..14cf9c5f57 100644 --- a/pandora_agents/android/src/pandroid/agent/PandroidAgentListener.java +++ b/pandora_agents/android/src/pandroid/agent/PandroidAgentListener.java @@ -63,7 +63,6 @@ import android.widget.Toast; public class PandroidAgentListener extends Service { private NotificationManager notificationManager; - private Notification notification; Handler h = new Handler(); String lastGpsContactDateTime = ""; @@ -72,22 +71,60 @@ public class PandroidAgentListener extends Service { @Override 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 public int onStartCommand(Intent intent, int flags, int startId) { PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock"); wakeLock.acquire(); - - updateValues(); 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(); stopSelf(startId); @@ -162,7 +199,7 @@ public class PandroidAgentListener extends Service { 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; String xml = ""; @@ -212,7 +249,7 @@ public class PandroidAgentListener extends Service { String[] tentacleData = { "-a", - HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "serverAddr", ""), + Core.getSharedData("PANDROID_DATA", "serverAddr", "", "string"), "-p", Core.defaultServerPort, "-v", @@ -223,7 +260,7 @@ public class PandroidAgentListener extends Service { tentacleRet = new tentacle_client().tentacle_client(tentacleData); if(tentacleRet == 0) { - HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "contactError", 0); + Core.putSharedData("PANDROID_DATA", "contactError", "0", "integer"); // Deleting the file after send it // move to only delete if sent successfully File file = new File("/data/data/pandroid.agent/files/" + destFileName); @@ -235,7 +272,7 @@ public class PandroidAgentListener extends Service { } if(tentacleRet == -1){ //file not deleted - HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "contactError", 1); + Core.putSharedData("PANDROID_DATA", "contactError", "1", "integer"); contact = false; } i++; @@ -257,9 +294,10 @@ public class PandroidAgentListener extends Service { String lastXML = buildXML(); 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"; + long bufferSize = 0; String[] buffer = getApplicationContext().fileList(); @@ -272,11 +310,11 @@ public class PandroidAgentListener extends Service { //Check if size of buffer is less than a value if((bufferSize/1024) < Core.bufferSize){ writeFile(destFileName, lastXML); - HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "lastXML", lastXML); + Core.putSharedData("PANDROID_DATA", "lastXML", lastXML, "string"); }else{ //buffer full } - HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "lastXML", lastXML); + Core.putSharedData("PANDROID_DATA", "lastXML", lastXML, "string"); return lastXML; @@ -315,15 +353,15 @@ public class PandroidAgentListener extends Service { String gpsData = ""; buffer += "\n"; - String latitude = ""+HelperSharedPreferences.getSharedPreferencesFloat(getApplicationContext(), "latitude", 181); - String longitude = ""+HelperSharedPreferences.getSharedPreferencesFloat(getApplicationContext(), "longitude", 181); + String latitude = Core.getSharedData("PANDROID_DATA", "latitude", "181", "float"); + String longitude = Core.getSharedData("PANDROID_DATA", "longitude", "181", "float"); if(!latitude.equals("181.0") && !longitude.equals("181.0")) { gpsData = " latitude='" + latitude + "' longitude='" + longitude + "'"; } - String agentName = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "agentName", Core.defaultAgentName); - String interval = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "interval", Core.defaultInterval); + String agentName = Core.getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string"); + String interval = Core.getSharedData("PANDROID_DATA", "interval", Integer.toString(Core.defaultInterval), "integer"); buffer += "= 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() { batteryLevel(); - String gpsStatus = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "gpsStatus", Core.defaultGpsStatus); + String gpsStatus = Core.getSharedData("PANDROID_DATA", "gpsStatus", Core.defaultGpsStatus, "string"); if(gpsStatus.equals("enabled")) { Log.d("PANDROID AGENT", "ENABLED"); @@ -684,8 +725,8 @@ public class PandroidAgentListener extends Service { } else { Log.d("PANDROID AGENT", "DISABLED"); - HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "latitude", 181.0f); - HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "longitude", 181.0f); + Core.putSharedData("PANDROID_DATA", "latitude", "181.0", "float"); + Core.putSharedData("PANDROID_DATA", "longitude", "181.0", "float"); } //sensors(); @@ -708,7 +749,7 @@ public class PandroidAgentListener extends Service { } 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 totalRamKb = 0; @@ -734,14 +775,14 @@ public class PandroidAgentListener extends Service { } } - HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "availableRamKb", availableRamKb); - HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "totalRamKb", totalRamKb); + Core.putSharedData("PANDROID_DATA", "availableRamKb", "" + availableRamKb, "long"); + Core.putSharedData("PANDROID_DATA", "totalRamKb", "" + totalRamKb, "long"); }// end getMemoryStatus private void getTaskStatus() { - String taskStatus = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "taskStatus", Core.defaultTaskStatus); - String task = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "task", Core.defaultTask); - String taskHumanName = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "taskHumanName", Core.defaultTaskHumanName); + String taskStatus = Core.getSharedData("PANDROID_DATA", "taskStatus", Core.defaultTaskStatus, "string"); + String task = Core.getSharedData("PANDROID_DATA", "task", Core.defaultTask, "string"); + String taskHumanName = Core.getSharedData("PANDROID_DATA", "taskHumanName", Core.defaultTaskHumanName, "string"); String run = "false"; if (taskStatus.equals("enabled")) { @@ -761,7 +802,7 @@ public class PandroidAgentListener extends Service { } } } - HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "taskRun", run); + Core.putSharedData("PANDROID_DATA", "taskRun", run, "string"); }//end getTaskStatus /** @@ -769,12 +810,12 @@ public class PandroidAgentListener extends Service { */ 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; TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService(serviceName); 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 @@ -783,7 +824,7 @@ public class PandroidAgentListener extends Service { long upTime = Core.defaultUpTime; upTime = SystemClock.elapsedRealtime()/1000; 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... @@ -795,15 +836,15 @@ public class PandroidAgentListener extends Service { networkOperator = telephonyManager.getNetworkOperatorName(); 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 */ private void getSMSSent(){ - int SMSSent = Core.defaultSMSSent; - SMSSent = HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "SMSSent", Core.defaultSMSSent); + String SMSSent = ""+Core.defaultSMSSent; + SMSSent = Core.getSharedData("PANDROID_DATA", "SMSSent", ""+Core.defaultSMSSent, "integer"); Uri allMessages = Uri.parse("content://sms/sent"); Cursor c = getContentResolver().query(allMessages, null, null, null, null); int totalMessages = 0; @@ -819,10 +860,10 @@ public class PandroidAgentListener extends Service { c.close(); - SMSSent = totalMessages; + SMSSent =""+ totalMessages; - if(SMSSent != 0) - HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "SMSSent", SMSSent); + if(SMSSent != null) + Core.putSharedData("PANDROID_DATA", "SMSSent", SMSSent, "integer"); }// end getSMSSent /** @@ -886,7 +927,7 @@ public class PandroidAgentListener extends Service { break; } if(networkType != null) - HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "networkType", networkType); + Core.putSharedData("PANDROID_DATA", "networkType", networkType, "string"); }// end getNetworkType @@ -915,7 +956,7 @@ public class PandroidAgentListener extends Service { break; } if(phoneType != null) - HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "phoneType", phoneType); + Core.putSharedData("PANDROID_DATA", "phoneType", phoneType, "string"); }// end getPhoneType /** @@ -949,9 +990,9 @@ public class PandroidAgentListener extends Service { c.moveToNext(); } - HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "incomingCalls", incoming); - HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "missedCalls", missed); - HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "outgoingCalls", outgoing); + Core.putSharedData("PANDROID_DATA", "incomingCalls", ""+incoming, "integer"); + Core.putSharedData("PANDROID_DATA", "missedCalls", ""+missed, "integer"); + Core.putSharedData("PANDROID_DATA", "outgoingCalls", ""+outgoing, "integer"); } c.close(); @@ -972,17 +1013,17 @@ public class PandroidAgentListener extends Service { public void onSignalStrengthsChanged(SignalStrength signalStrength) { super.onSignalStrengthsChanged(signalStrength); - int signalStrengthValue = Core.defaultSignalStrength; + String signalStrengthValue = ""+Core.defaultSignalStrength; if (signalStrength.isGsm()) { if (signalStrength.getGsmSignalStrength() != 99) - signalStrengthValue = (signalStrength.getGsmSignalStrength() * 2 - 113); + signalStrengthValue =""+ (signalStrength.getGsmSignalStrength() * 2 - 113); else - signalStrengthValue = (signalStrength.getGsmSignalStrength()); + signalStrengthValue =""+ (signalStrength.getGsmSignalStrength()); } 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) { - HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "receiveBytes", receiveBytes); - HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "transmitBytes", transmitBytes); + Core.putSharedData("PANDROID_DATA", "receiveBytes", ""+receiveBytes, "long" ); + Core.putSharedData("PANDROID_DATA", "transmitBytes", ""+transmitBytes, "long" ); } } /** @@ -1009,9 +1050,9 @@ public class PandroidAgentListener extends Service { boolean roaming = telephone.isNetworkRoaming(); if(roaming) - HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "roaming", 1); + Core.putSharedData("PANDROID_DATA", "roaming", "1", "integer" ); else - HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "roaming", 0); + Core.putSharedData("PANDROID_DATA", "roaming", "0", "integer" ); } @@ -1075,8 +1116,8 @@ public class PandroidAgentListener extends Service { @Override public void onLocationChanged(Location loc) { - HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "latitude", (float)loc.getLatitude()); - HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "longitude", (float)loc.getLongitude()); + Core.putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float"); + Core.putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float"); } @Override diff --git a/pandora_agents/android/src/pandroid/agent/SMSBroadcastReceiver.java b/pandora_agents/android/src/pandroid/agent/SMSBroadcastReceiver.java index 0e74f08983..f44babb676 100644 --- a/pandora_agents/android/src/pandroid/agent/SMSBroadcastReceiver.java +++ b/pandora_agents/android/src/pandroid/agent/SMSBroadcastReceiver.java @@ -36,14 +36,14 @@ import android.util.Log; int defaultSMSReceived = 0; int mode = Activity.MODE_PRIVATE; - - int sms = HelperSharedPreferences.getSharedPreferencesInt(context, "SMSReceived", defaultSMSReceived); + SharedPreferences pref = PandroidAgent.getSharedPrefs(); + int sms = pref.getInt("SMSReceived", defaultSMSReceived); sms++; - - HelperSharedPreferences.putSharedPreferencesInt(context, "SMSReceived", sms); - + SharedPreferences.Editor editor = pref.edit(); + editor.putInt("SMSReceived", sms); + editor.commit(); }//end if diff --git a/pandora_agents/android/src/pandroid/agent/Setup.java b/pandora_agents/android/src/pandroid/agent/Setup.java index fc3239f0ea..6251e45ad7 100644 --- a/pandora_agents/android/src/pandroid/agent/Setup.java +++ b/pandora_agents/android/src/pandroid/agent/Setup.java @@ -745,4 +745,4 @@ public class Setup extends Activity { nMgr.cancel(notifyId); } -} \ No newline at end of file +} diff --git a/pandora_agents/android/src/pandroid/agent/Status.java b/pandora_agents/android/src/pandroid/agent/Status.java index ab8b4546d0..4996e5bf86 100644 --- a/pandora_agents/android/src/pandroid/agent/Status.java +++ b/pandora_agents/android/src/pandroid/agent/Status.java @@ -18,6 +18,7 @@ import java.util.Date; import android.app.Activity; import android.content.Intent; +//import android.content.SharedPreferences; import android.graphics.Color; import android.os.Bundle; import android.os.Handler;