2013-04-27 Mark Holland <mark@mark-holland.me.uk>
* assets/database/pandroid.zip: Added buffer size initial value. * layout: Added buffer size text edit. * src/pandroid/agent/Core.java: Added variable for buffer size with initial value of 256KB. Moved all preference reading/editing to HelperSharedPreferences. * src/pandroid/agent/DataBaseHandler.java: Now extends sqliteassethelper library. * src/pandroid/agent/HelperSharedPreferences: New helper class in attempt to mitigate SharedPreferences loss. * src/pandroid/agent/PandroidAgent.java: Removed SharedPreferences references and methods. * src/pandroid/agent/PandroidAgentListener.java: Rewritten all get and put preferences to use HelperSharedPreferences instead. * src/pandroid/agent/Setup.java: Added views for buffer size. * src/pandroid/agent/SMSBroadcastReceiver.java: Changed to use HelperSharedPreferences. * values: Added buffer size to all strings. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8070 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
2865d6c2a5
commit
9cd18ec26a
|
@ -1,3 +1,32 @@
|
|||
2013-04-27 Mark Holland <mark@mark-holland.me.uk>
|
||||
|
||||
* assets/database/pandroid.zip: Added buffer size initial value.
|
||||
|
||||
* layout: Added buffer size text edit.
|
||||
|
||||
* src/pandroid/agent/Core.java: Added variable for buffer size
|
||||
with initial value of 256KB. Moved all preference reading/editing
|
||||
to HelperSharedPreferences.
|
||||
|
||||
* src/pandroid/agent/DataBaseHandler.java: Now extends
|
||||
sqliteassethelper library.
|
||||
|
||||
* src/pandroid/agent/HelperSharedPreferences: New helper class in
|
||||
attempt to mitigate SharedPreferences loss.
|
||||
|
||||
* src/pandroid/agent/PandroidAgent.java: Removed SharedPreferences
|
||||
references and methods.
|
||||
|
||||
* src/pandroid/agent/PandroidAgentListener.java: Rewritten all get
|
||||
and put preferences to use HelperSharedPreferences instead.
|
||||
|
||||
* src/pandroid/agent/Setup.java: Added views for buffer size.
|
||||
|
||||
* src/pandroid/agent/SMSBroadcastReceiver.java: Changed to use
|
||||
HelperSharedPreferences.
|
||||
|
||||
* values: Added buffer size to all strings.
|
||||
|
||||
2013-04-26 Mark Holland <mark@mark-holland.me.uk>
|
||||
|
||||
* src/pandroid/agent/Core.java: Single SharedPreferences and
|
||||
|
@ -16,8 +45,8 @@
|
|||
* src/pandroid/agent/PandroidAgentTentacle.java: Changed socket to
|
||||
timeout after 1000ms.
|
||||
|
||||
* src/pandroid/agent/SMSBroadcastReceiver.java: Changed SharedPreferences
|
||||
to static version from PandroidAgent.java
|
||||
* src/pandroid/agent/SMSBroadcastReceiver.java: Changed
|
||||
SharedPreferences to static version from PandroidAgent.java
|
||||
|
||||
* Pandroid Agent v3.0_iso-8859-1.apk: Updated to include latest
|
||||
changes.
|
||||
|
@ -40,6 +69,12 @@
|
|||
|
||||
2013-04-25 Mark Holland <mark@mark-holland.me.uk>
|
||||
|
||||
* assets/database/pandroid.zip: zipped sqlite3
|
||||
database containing all default values.
|
||||
|
||||
* libs/android-sqlite-asset-helper.jar: library to facilitate
|
||||
database operations. Only temporarily being used.
|
||||
|
||||
* src/pandroid/agent/Core.java: Changed get and update
|
||||
database values methods to support new DataBaseHandler.
|
||||
|
||||
|
@ -51,12 +86,7 @@
|
|||
* src/pandroid/agent/PandroidAgentListener.java: changed
|
||||
SimIDReport to simIDReport to reflect database.
|
||||
|
||||
* assets/database/pandroid.zip: zipped sqlite3
|
||||
database containing all default values.
|
||||
|
||||
* libs/android-sqlite-asset-helper.jar: library to facilitate
|
||||
database operations. Only temporarily being used.
|
||||
|
||||
|
||||
2013-04-23 Mark Holland <mark@mark-holland.me.uk>
|
||||
|
||||
* src/pandroid/agent/Core.java: Migrated from shared
|
||||
|
|
Binary file not shown.
|
@ -95,6 +95,19 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/field6"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/bufferSize" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/bufferSize"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"
|
||||
android:singleLine="true" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/goToWebButton"
|
||||
|
|
|
@ -95,6 +95,18 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/field6"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/bufferSize" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/bufferSize"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/goToWebButton"
|
||||
|
|
|
@ -115,6 +115,8 @@
|
|||
<string name="mobileWebURL">"Mobile-Server URL:"</string>
|
||||
<string name="go_to_web">"Zur mobilen Website"</string>
|
||||
|
||||
<string name="bufferSize">XML Puffergröße(KB)</string>
|
||||
|
||||
<string name="enter">"Eingangsbereich"</string>
|
||||
<string name="back">"zurück"</string>
|
||||
<string name="yes">"ja"</string>
|
||||
|
|
|
@ -122,6 +122,8 @@
|
|||
<string name="mobileWebURL">Mobile server URL:</string>
|
||||
<string name="go_to_web">View Mobile site</string>
|
||||
|
||||
<string name="bufferSize">XML Buffer Size(KB)</string>
|
||||
|
||||
<string name="enter">enter</string>
|
||||
<string name="back">back</string>
|
||||
<string name="yes">yes</string>
|
||||
|
|
|
@ -122,6 +122,8 @@
|
|||
<string name="mobileWebURL">URL de servidor movil:</string>
|
||||
<string name="go_to_web">Ver sitio movil</string>
|
||||
|
||||
<string name="bufferSize">Tamaño de búfer XML(KB)</string>
|
||||
|
||||
<string name="enter">Intro</string>
|
||||
<string name="back">Volver</string>
|
||||
<string name="yes">si</string>
|
||||
|
|
|
@ -115,6 +115,8 @@
|
|||
<string name="mobileWebURL">"URL du serveur Mobile:"</string>
|
||||
<string name="go_to_web">"Voir le site mobile"</string>
|
||||
|
||||
<string name="bufferSize">taille du buffer XML(KB)</string>
|
||||
|
||||
<string name="enter">"Entrer..."</string>
|
||||
<string name="back">"arrière"</string>
|
||||
<string name="yes">"oui"</string>
|
||||
|
|
|
@ -115,6 +115,8 @@
|
|||
<string name="mobileWebURL">"URL del server Mobile:"</string>
|
||||
<string name="go_to_web">"Visualizza sito Mobile"</string>
|
||||
|
||||
<string name="bufferSize">Dimensione buffer XML(KB)</string>
|
||||
|
||||
<string name="enter">"Invio"</string>
|
||||
<string name="back">"indietro"</string>
|
||||
<string name="yes">"sì"</string>
|
||||
|
|
|
@ -113,6 +113,8 @@
|
|||
<string name="mobileWebURL">"モバイル·サーバーのURL:"</string>
|
||||
<string name="go_to_web">"携帯サイトを見る"</string>
|
||||
|
||||
<string name="bufferSize">XML バッファサイズ(KB)</string>
|
||||
|
||||
<string name="enter">"入力"</string>
|
||||
<string name="back">"戻る"</string>
|
||||
<string name="yes">"はい"</string>
|
||||
|
|
|
@ -115,6 +115,8 @@
|
|||
<string name="mobileWebURL">"URL do servidor móvel:"</string>
|
||||
<string name="go_to_web">"Veja o site móvel"</string>
|
||||
|
||||
<string name="bufferSize">Tamanho do buffer XML(KB)</string>
|
||||
|
||||
<string name="enter">"Enter"</string>
|
||||
<string name="back">"voltar"</string>
|
||||
<string name="yes">"SIM"</string>
|
||||
|
|
|
@ -114,6 +114,8 @@
|
|||
<string name="mobileWebURL">"Mobile服务器的URL:"</string>
|
||||
<string name="go_to_web">"查看手机网站"</string>
|
||||
|
||||
<string name="bufferSize">XML 緩衝區大小(KB)</string>
|
||||
|
||||
<string name="enter">"进入"</string>
|
||||
<string name="back">"背面"</string>
|
||||
<string name="yes">"是"</string>
|
||||
|
|
|
@ -123,6 +123,8 @@
|
|||
<string name="mobileWebURL">Mobile server URL:</string>
|
||||
<string name="go_to_web">View Mobile site</string>
|
||||
|
||||
<string name="bufferSize">XML Buffer Size(KB)</string>
|
||||
|
||||
<string name="enter">enter</string>
|
||||
<string name="back">back</string>
|
||||
<string name="yes">yes</string>
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class Core {
|
|||
static volatile public long defaultTransmitBytes = 0;
|
||||
static volatile public int defaultHelloSignal = 2;
|
||||
static volatile public int defaultRoaming = 0;
|
||||
|
||||
static volatile public long defaultBufferSize = 256;
|
||||
|
||||
static volatile public String defaultPassword = "";
|
||||
|
||||
|
@ -170,16 +170,14 @@ public class Core {
|
|||
static volatile public long transmitBytes = defaultTransmitBytes;
|
||||
static volatile public int helloSignal = defaultHelloSignal;
|
||||
static volatile public int roaming = defaultRoaming;
|
||||
static volatile public long bufferSize = defaultBufferSize;
|
||||
|
||||
static volatile public long lastContact = CONST_INVALID_CONTACT;
|
||||
static volatile public int contactError = CONST_CONTACT_ERROR;
|
||||
|
||||
|
||||
static DataBaseHandler db;
|
||||
|
||||
//Single SharedPreferences object
|
||||
static volatile public SharedPreferences agentPreferences;
|
||||
static volatile public SharedPreferences.Editor editor;
|
||||
|
||||
|
||||
public Core() {
|
||||
|
||||
|
@ -218,37 +216,38 @@ public class Core {
|
|||
con = context;
|
||||
}
|
||||
|
||||
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
}// end loadLastValues
|
||||
|
||||
|
@ -257,39 +256,40 @@ public class Core {
|
|||
con = context;
|
||||
}
|
||||
|
||||
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||
|
||||
|
||||
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);
|
||||
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);
|
||||
}// end loadConf
|
||||
|
||||
static synchronized public boolean updateConf(Context context) {
|
||||
|
@ -300,7 +300,7 @@ public class Core {
|
|||
passwordCheck, DeviceUpTimeReport, NetworkOperatorReport, NetworkTypeReport, PhoneTypeReport,
|
||||
SignalStrengthReport, ReceivedSMSReport, SentSMSReport, IncomingCallsReport, MissedCallsReport,
|
||||
OutgoingCallsReport, BytesReceivedReport, BytesSentReport, HelloSignalReport, BatteryLevelReport,
|
||||
RoamingReport, roaming, mobileWebURL, InventoryReport , NotificationCheck
|
||||
RoamingReport, roaming, mobileWebURL, InventoryReport, NotificationCheck, bufferSize
|
||||
);
|
||||
|
||||
}// end updateConf
|
||||
|
@ -315,119 +315,66 @@ public class Core {
|
|||
String _NetworkTypeReport, String _PhoneTypeReport, String _SignalStrengthReport, String _ReceivedSMSReport,
|
||||
String _SentSMSReport, String _IncomingCallsReport, String _MissedCallsReport, String _OutgoingCallsReport, String _BytesReceivedReport,
|
||||
String _BytesSentReport, String _HelloSignalReport, String _BatteryLevelReport, String _RoamingReport, int _roaming, String _mobileWebURL,
|
||||
String _InventoryReport, String _NotificationCheck) {
|
||||
String _InventoryReport, String _NotificationCheck, long _bufferSize) {
|
||||
|
||||
if (con == null) {
|
||||
con = context;
|
||||
}
|
||||
|
||||
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||
editor = PandroidAgent.getEditor();
|
||||
|
||||
editor.putString("serverAddr", _serverAddr);
|
||||
editor.putString("serverPort", _serverPort);
|
||||
editor.putInt("interval", _interval);
|
||||
editor.putString("agentName", _agentName);
|
||||
editor.putString("gpsStatus", _gpsStatus);
|
||||
editor.putString("memoryStatus", _memoryStatus);
|
||||
editor.putString("taskStatus", _taskStatus);
|
||||
editor.putString("task", _task);
|
||||
editor.putString("taskHumanName", _taskHumanName);
|
||||
editor.putString("simID", _simID);
|
||||
editor.putString("simIDReport", _simIDReport);
|
||||
editor.putLong("UpTime", _upTime);
|
||||
editor.putString("networkOperator", _networkOperator);
|
||||
editor.putInt("SMSReceived", _smsReceived);
|
||||
editor.putInt("SMSSent", _smsSent);
|
||||
editor.putString("networkType", _networkType);
|
||||
editor.putString("phoneType", _phoneType);
|
||||
editor.putInt("signalStrength", _signalStrength);
|
||||
editor.putInt("incomingCalls", _incomingCalls);
|
||||
editor.putInt("missedCalls", _missedCalls);
|
||||
editor.putInt("outgoingCalls", _outgoingCalls);
|
||||
editor.putLong("receiveBytes", _receiveBytes);
|
||||
editor.putLong("transmitBytes", _transmitBytes);
|
||||
editor.putString("password", _password);
|
||||
editor.putString("passwordCheck", _passwordCheck);
|
||||
editor.putInt("helloSignal", _helloSignal);
|
||||
editor.putInt("roaming", _roaming);
|
||||
editor.putString("DeviceUpTimeReport", _DeviceUpTimeReport);
|
||||
editor.putString("NetworkOperatorReport", _NetworkOperatorReport);
|
||||
editor.putString("NetworkTypeReport", _NetworkTypeReport);
|
||||
editor.putString("PhoneTypeReport", _PhoneTypeReport);
|
||||
editor.putString("SignalStrengthReport", _SignalStrengthReport);
|
||||
editor.putString("ReceivedSMSReport", _ReceivedSMSReport);
|
||||
editor.putString("SentSMSReport", _SentSMSReport);
|
||||
editor.putString("IncomingCallsReport", _IncomingCallsReport);
|
||||
editor.putString("MissedCallsReport", _MissedCallsReport);
|
||||
editor.putString("OutgoingCallsReport", _OutgoingCallsReport);
|
||||
editor.putString("BytesReceivedReport", _BytesReceivedReport);
|
||||
editor.putString("BytesSentReport", _BytesSentReport);
|
||||
editor.putString("HelloSignalReport", _HelloSignalReport);
|
||||
editor.putString("BatteryLevelReport", _BatteryLevelReport);
|
||||
editor.putString("RoamingReport", _RoamingReport);
|
||||
editor.putString("InventoryReport", _InventoryReport);
|
||||
editor.putString("NotificationCheck", _NotificationCheck);
|
||||
editor.putString("mobileWebURL", _mobileWebURL);
|
||||
|
||||
if (editor.commit()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
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;
|
||||
}// end updateConf
|
||||
|
||||
|
||||
public synchronized static void putSharedData(String preferenceName, String tokenName, String data, String type) {
|
||||
int mode = Activity.MODE_PRIVATE;
|
||||
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||
editor = PandroidAgent.getEditor();
|
||||
|
||||
|
||||
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;
|
||||
agentPreferences = PandroidAgent.getSharedPrefs();
|
||||
|
||||
if(type == "boolean") {
|
||||
boolean a = agentPreferences.getBoolean(tokenName, Boolean.parseBoolean(defaultValue));
|
||||
return Boolean.valueOf(a).toString();
|
||||
}
|
||||
else if(type == "float") {
|
||||
float a = agentPreferences.getFloat(tokenName, Float.parseFloat(defaultValue));
|
||||
return Float.valueOf(a).toString();
|
||||
}
|
||||
else if(type == "integer") {
|
||||
int a = agentPreferences.getInt(tokenName, Integer.parseInt(defaultValue));
|
||||
return Integer.valueOf(a).toString();
|
||||
}
|
||||
else if(type == "long") {
|
||||
long a = agentPreferences.getLong(tokenName, Long.parseLong(defaultValue));
|
||||
return Long.valueOf(a).toString();
|
||||
}
|
||||
else if(type == "string") {
|
||||
return agentPreferences.getString(tokenName, defaultValue);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// //database//
|
||||
|
|
|
@ -1,479 +1,80 @@
|
|||
package pandroid.agent;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Scanner;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteDatabase.CursorFactory;
|
||||
import android.database.sqlite.SQLiteException;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.util.Log;
|
||||
|
||||
import com.readystatesoftware.sqliteasset.SQLiteAssetException;
|
||||
import com.readystatesoftware.sqliteasset.SQLiteAssetHelper;
|
||||
|
||||
public class DataBaseHandler extends SQLiteOpenHelper {
|
||||
|
||||
private static final String TAG = SQLiteAssetHelper.class.getSimpleName();
|
||||
private static final String ASSET_DB_PATH = "databases";
|
||||
|
||||
// Contacts table name
|
||||
private static final String TABLE_NAME = "PANDROID_DATA";
|
||||
|
||||
// Contacts Table Columns names
|
||||
private static final String KEY_ID = "_ID";
|
||||
private static final String KEY_NAME = "NAME";
|
||||
private static final String KEY_VALUE = "VALUE";
|
||||
|
||||
|
||||
private final Context mContext;
|
||||
private final String mName;
|
||||
private final CursorFactory mFactory;
|
||||
private final int mNewVersion;
|
||||
|
||||
private SQLiteDatabase mDatabase = null;
|
||||
private boolean mIsInitializing = false;
|
||||
|
||||
private String mDatabasePath;
|
||||
private String mArchivePath;
|
||||
private String mUpgradePathFormat;
|
||||
|
||||
private int mForcedUpgradeVersion = 0;
|
||||
|
||||
/**
|
||||
* Create a helper object to create, open, and/or manage a database in
|
||||
* a specified location.
|
||||
* This method always returns very quickly. The database is not actually
|
||||
* created or opened until one of {@link #getWritableDatabase} or
|
||||
* {@link #getReadableDatabase} is called.
|
||||
*
|
||||
* @param context to use to open or create the database
|
||||
* @param name of the database file
|
||||
* @param storageDirectory to store the database file upon creation; caller must
|
||||
* ensure that the specified absolute path is available and can be written to
|
||||
* @param factory to use for creating cursor objects, or null for the default
|
||||
* @param version number of the database (starting at 1); if the database is older,
|
||||
* SQL file(s) contained within the application assets folder will be used to
|
||||
* upgrade the database
|
||||
*/
|
||||
public DataBaseHandler(Context context, String name, String storageDirectory, CursorFactory factory, int version) {
|
||||
super(context, name, factory, version);
|
||||
|
||||
if (version < 1) throw new IllegalArgumentException("Version must be >= 1, was " + version);
|
||||
if (name == null) throw new IllegalArgumentException("Databse name cannot be null");
|
||||
|
||||
mContext = context;
|
||||
mName = name;
|
||||
mFactory = factory;
|
||||
mNewVersion = version;
|
||||
|
||||
mArchivePath = ASSET_DB_PATH + "/" + name + ".zip";
|
||||
if (storageDirectory != null) {
|
||||
mDatabasePath = storageDirectory;
|
||||
} else {
|
||||
mDatabasePath = context.getApplicationInfo().dataDir + "/databases";
|
||||
}
|
||||
mUpgradePathFormat = ASSET_DB_PATH + "/" + name + "_upgrade_%s-%s.sql";
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a helper object to create, open, and/or manage a database in
|
||||
* the application's default private data directory.
|
||||
* This method always returns very quickly. The database is not actually
|
||||
* created or opened until one of {@link #getWritableDatabase} or
|
||||
* {@link #getReadableDatabase} is called.
|
||||
*
|
||||
* @param context to use to open or create the database
|
||||
* @param name of the database file
|
||||
* @param factory to use for creating cursor objects, or null for the default
|
||||
* @param version number of the database (starting at 1); if the database is older,
|
||||
* SQL file(s) contained within the application assets folder will be used to
|
||||
* upgrade the database
|
||||
*/
|
||||
public DataBaseHandler(Context context, String name, CursorFactory factory, int version) {
|
||||
this(context, name, null, factory, version);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create and/or open a database that will be used for reading and writing.
|
||||
* The first time this is called, the database will be extracted and copied
|
||||
* from the application's assets folder.
|
||||
*
|
||||
* <p>Once opened successfully, the database is cached, so you can
|
||||
* call this method every time you need to write to the database.
|
||||
* (Make sure to call {@link #close} when you no longer need the database.)
|
||||
* Errors such as bad permissions or a full disk may cause this method
|
||||
* to fail, but future attempts may succeed if the problem is fixed.</p>
|
||||
*
|
||||
* <p class="caution">Database upgrade may take a long time, you
|
||||
* should not call this method from the application main thread, including
|
||||
* from {@link android.content.ContentProvider#onCreate ContentProvider.onCreate()}.
|
||||
*
|
||||
* @throws SQLiteException if the database cannot be opened for writing
|
||||
* @return a read/write database object valid until {@link #close} is called
|
||||
*/
|
||||
@Override
|
||||
public synchronized SQLiteDatabase getWritableDatabase() {
|
||||
if (mDatabase != null && mDatabase.isOpen() && !mDatabase.isReadOnly()) {
|
||||
return mDatabase; // The database is already open for business
|
||||
}
|
||||
|
||||
if (mIsInitializing) {
|
||||
throw new IllegalStateException("getWritableDatabase called recursively");
|
||||
}
|
||||
|
||||
// If we have a read-only database open, someone could be using it
|
||||
// (though they shouldn't), which would cause a lock to be held on
|
||||
// the file, and our attempts to open the database read-write would
|
||||
// fail waiting for the file lock. To prevent that, we acquire the
|
||||
// lock on the read-only database, which shuts out other users.
|
||||
|
||||
boolean success = false;
|
||||
SQLiteDatabase db = null;
|
||||
//if (mDatabase != null) mDatabase.lock();
|
||||
try {
|
||||
mIsInitializing = true;
|
||||
//if (mName == null) {
|
||||
// db = SQLiteDatabase.create(null);
|
||||
//} else {
|
||||
// db = mContext.openOrCreateDatabase(mName, 0, mFactory);
|
||||
//}
|
||||
db = createOrOpenDatabase(false);
|
||||
|
||||
int version = db.getVersion();
|
||||
|
||||
// do force upgrade
|
||||
if (version != 0 && version < mForcedUpgradeVersion) {
|
||||
db = createOrOpenDatabase(true);
|
||||
db.setVersion(mNewVersion);
|
||||
version = db.getVersion();
|
||||
}
|
||||
|
||||
if (version != mNewVersion) {
|
||||
db.beginTransaction();
|
||||
try {
|
||||
if (version == 0) {
|
||||
onCreate(db);
|
||||
} else {
|
||||
if (version > mNewVersion) {
|
||||
Log.w(TAG, "Can't downgrade read-only database from version " +
|
||||
version + " to " + mNewVersion + ": " + db.getPath());
|
||||
}
|
||||
onUpgrade(db, version, mNewVersion);
|
||||
}
|
||||
db.setVersion(mNewVersion);
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
onOpen(db);
|
||||
success = true;
|
||||
return db;
|
||||
} finally {
|
||||
mIsInitializing = false;
|
||||
if (success) {
|
||||
if (mDatabase != null) {
|
||||
try { mDatabase.close(); } catch (Exception e) { }
|
||||
//mDatabase.unlock();
|
||||
}
|
||||
mDatabase = db;
|
||||
} else {
|
||||
//if (mDatabase != null) mDatabase.unlock();
|
||||
if (db != null) db.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create and/or open a database. This will be the same object returned by
|
||||
* {@link #getWritableDatabase} unless some problem, such as a full disk,
|
||||
* requires the database to be opened read-only. In that case, a read-only
|
||||
* database object will be returned. If the problem is fixed, a future call
|
||||
* to {@link #getWritableDatabase} may succeed, in which case the read-only
|
||||
* database object will be closed and the read/write object will be returned
|
||||
* in the future.
|
||||
*
|
||||
* <p class="caution">Like {@link #getWritableDatabase}, this method may
|
||||
* take a long time to return, so you should not call it from the
|
||||
* application main thread, including from
|
||||
* {@link android.content.ContentProvider#onCreate ContentProvider.onCreate()}.
|
||||
*
|
||||
* @throws SQLiteException if the database cannot be opened
|
||||
* @return a database object valid until {@link #getWritableDatabase}
|
||||
* or {@link #close} is called.
|
||||
*/
|
||||
@Override
|
||||
public synchronized SQLiteDatabase getReadableDatabase() {
|
||||
if (mDatabase != null && mDatabase.isOpen()) {
|
||||
return mDatabase; // The database is already open for business
|
||||
}
|
||||
|
||||
if (mIsInitializing) {
|
||||
throw new IllegalStateException("getReadableDatabase called recursively");
|
||||
}
|
||||
|
||||
try {
|
||||
return getWritableDatabase();
|
||||
} catch (SQLiteException e) {
|
||||
if (mName == null) throw e; // Can't open a temp database read-only!
|
||||
Log.e(TAG, "Couldn't open " + mName + " for writing (will try read-only):", e);
|
||||
}
|
||||
|
||||
SQLiteDatabase db = null;
|
||||
try {
|
||||
mIsInitializing = true;
|
||||
String path = mContext.getDatabasePath(mName).getPath();
|
||||
db = SQLiteDatabase.openDatabase(path, mFactory, SQLiteDatabase.OPEN_READONLY);
|
||||
if (db.getVersion() != mNewVersion) {
|
||||
throw new SQLiteException("Can't upgrade read-only database from version " +
|
||||
db.getVersion() + " to " + mNewVersion + ": " + path);
|
||||
}
|
||||
|
||||
onOpen(db);
|
||||
Log.w(TAG, "Opened " + mName + " in read-only mode");
|
||||
mDatabase = db;
|
||||
return mDatabase;
|
||||
} finally {
|
||||
mIsInitializing = false;
|
||||
if (db != null && db != mDatabase) db.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close any open database object.
|
||||
*/
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
if (mIsInitializing) throw new IllegalStateException("Closed during initialization");
|
||||
|
||||
if (mDatabase != null && mDatabase.isOpen()) {
|
||||
mDatabase.close();
|
||||
mDatabase = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onCreate(SQLiteDatabase db) {
|
||||
// do nothing - createOrOpenDatabase() is called in
|
||||
// getWritableDatabase() to handle database creation.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
|
||||
Log.w(TAG, "Upgrading database " + mName + " from version " + oldVersion + " to " + newVersion + "...");
|
||||
|
||||
ArrayList<String> paths = new ArrayList<String>();
|
||||
getUpgradeFilePaths(oldVersion, newVersion-1, newVersion, paths);
|
||||
|
||||
if (paths.isEmpty()) {
|
||||
Log.e(TAG, "no upgrade script path from " + oldVersion + " to " + newVersion);
|
||||
throw new SQLiteAssetException("no upgrade script path from " + oldVersion + " to " + newVersion);
|
||||
}
|
||||
|
||||
Collections.sort(paths);
|
||||
for (String path : paths) {
|
||||
try {
|
||||
Log.w(TAG, "processing upgrade: " + path);
|
||||
InputStream is = mContext.getAssets().open(path);
|
||||
String sql = convertStreamToString(is);
|
||||
if (sql != null) {
|
||||
String[] cmds = sql.split(";");
|
||||
for (String cmd : cmds) {
|
||||
//Log.d(TAG, "cmd=" + cmd);
|
||||
if (cmd.trim().length() > 0) {
|
||||
db.execSQL(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Log.w(TAG, "Successfully upgraded database " + mName + " from version " + oldVersion + " to " + newVersion);
|
||||
|
||||
}
|
||||
|
||||
public void setForcedUpgradeVersion(int version) {
|
||||
mForcedUpgradeVersion = version;
|
||||
}
|
||||
|
||||
private SQLiteDatabase createOrOpenDatabase(boolean force) throws SQLiteAssetException {
|
||||
SQLiteDatabase db = returnDatabase();
|
||||
if (db != null) {
|
||||
// database already exists
|
||||
if (force) {
|
||||
Log.w(TAG, "forcing database upgrade!");
|
||||
copyDatabaseFromAssets();
|
||||
db = returnDatabase();
|
||||
}
|
||||
return db;
|
||||
} else {
|
||||
// database does not exist, copy it from assets and return it
|
||||
copyDatabaseFromAssets();
|
||||
db = returnDatabase();
|
||||
return db;
|
||||
}
|
||||
}
|
||||
|
||||
private SQLiteDatabase returnDatabase(){
|
||||
try {
|
||||
SQLiteDatabase db = SQLiteDatabase.openDatabase(mDatabasePath + "/" + mName, mFactory, SQLiteDatabase.OPEN_READWRITE);
|
||||
Log.i(TAG, "successfully opened database " + mName);
|
||||
return db;
|
||||
} catch (SQLiteException e) {
|
||||
Log.w(TAG, "could not open database " + mName + " - " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void copyDatabaseFromAssets() throws SQLiteAssetException {
|
||||
Log.w(TAG, "copying database from assets...");
|
||||
|
||||
try {
|
||||
InputStream zipFileStream = mContext.getAssets().open(mArchivePath);
|
||||
File f = new File(mDatabasePath + "/");
|
||||
if (!f.exists()) { f.mkdir(); }
|
||||
|
||||
ZipInputStream zis = getFileFromZip(zipFileStream);
|
||||
if (zis == null) {
|
||||
throw new SQLiteAssetException("Archive is missing a SQLite database file");
|
||||
}
|
||||
writeExtractedFileToDisk(zis, new FileOutputStream(mDatabasePath + "/" + mName));
|
||||
|
||||
Log.w(TAG, "database copy complete");
|
||||
|
||||
} catch (FileNotFoundException fe) {
|
||||
SQLiteAssetException se = new SQLiteAssetException("Missing " + mArchivePath + " file in assets or target folder not writable");
|
||||
se.setStackTrace(fe.getStackTrace());
|
||||
throw se;
|
||||
} catch (IOException e) {
|
||||
SQLiteAssetException se = new SQLiteAssetException("Unable to extract " + mArchivePath + " to data directory");
|
||||
se.setStackTrace(e.getStackTrace());
|
||||
throw se;
|
||||
}
|
||||
}
|
||||
|
||||
private InputStream getUpgradeSQLStream(int oldVersion, int newVersion) {
|
||||
String path = String.format(mUpgradePathFormat, oldVersion, newVersion);
|
||||
try {
|
||||
InputStream is = mContext.getAssets().open(path);
|
||||
return is;
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, "missing database upgrade script: " + path);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void getUpgradeFilePaths(int baseVersion, int start, int end, ArrayList<String> paths) {
|
||||
|
||||
int a;
|
||||
int b;
|
||||
|
||||
InputStream is = getUpgradeSQLStream(start, end);
|
||||
if (is != null) {
|
||||
String path = String.format(mUpgradePathFormat, start, end);
|
||||
paths.add(path);
|
||||
//Log.d(TAG, "found script: " + path);
|
||||
a = start - 1;
|
||||
b = start;
|
||||
is = null;
|
||||
} else {
|
||||
a = start - 1;
|
||||
b = end;
|
||||
}
|
||||
|
||||
if (a < baseVersion) {
|
||||
return;
|
||||
} else {
|
||||
getUpgradeFilePaths(baseVersion, a, b, paths); // recursive call
|
||||
}
|
||||
}
|
||||
|
||||
private void writeExtractedFileToDisk(ZipInputStream zin, OutputStream outs) throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = zin.read(buffer))>0){
|
||||
outs.write(buffer, 0, length);
|
||||
}
|
||||
outs.flush();
|
||||
outs.close();
|
||||
zin.close();
|
||||
}
|
||||
|
||||
private ZipInputStream getFileFromZip(InputStream zipFileStream) throws FileNotFoundException, IOException {
|
||||
ZipInputStream zis = new ZipInputStream(zipFileStream);
|
||||
ZipEntry ze = null;
|
||||
while ((ze = zis.getNextEntry()) != null) {
|
||||
Log.w(TAG, "extracting file: '" + ze.getName() + "'...");
|
||||
return zis;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String convertStreamToString(InputStream is) {
|
||||
return new Scanner(is).useDelimiter("\\A").next();
|
||||
}
|
||||
|
||||
// // Getting single contact
|
||||
// Cursor getContact(int id) {
|
||||
// mDatabase = this.getReadableDatabase();
|
||||
//
|
||||
// return mDatabase.query(TABLE_NAME, new String[] { KEY_ID,
|
||||
// KEY_NAME, KEY_VALUE }, KEY_ID + "=?",
|
||||
// new String[] { String.valueOf(id) }, null, null, null, null);
|
||||
//
|
||||
// }
|
||||
|
||||
// Update single value
|
||||
public int updateValue(DataHandler dh){
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KEY_NAME, dh.get_name());
|
||||
values.put(KEY_VALUE, dh.get_value());
|
||||
|
||||
// updating row
|
||||
return db.update(TABLE_NAME, values, KEY_ID + " = ?",
|
||||
new String[] { String.valueOf(dh.get_id())});
|
||||
}
|
||||
|
||||
// Getting single contact
|
||||
DataHandler getValue(String value) {
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
DataHandler dh = null;
|
||||
|
||||
Cursor cursor = db.query(TABLE_NAME, new String[] { KEY_ID,
|
||||
KEY_NAME, KEY_VALUE }, KEY_NAME + "=?",
|
||||
new String[] { value }, null, null, null, null);
|
||||
if (cursor != null){
|
||||
cursor.moveToFirst();
|
||||
|
||||
|
||||
dh = new DataHandler(
|
||||
cursor.getString(1), cursor.getString(2));
|
||||
|
||||
}
|
||||
return dh;
|
||||
}
|
||||
|
||||
|
||||
|
||||
package pandroid.agent;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import com.readystatesoftware.sqliteasset.SQLiteAssetHelper;
|
||||
|
||||
public class DataBaseHandler extends SQLiteAssetHelper {
|
||||
|
||||
private static final String DATABASE_NAME = "pandroid";
|
||||
private static final int DATABASE_VERSION = 1;
|
||||
|
||||
// Contacts table name
|
||||
private static final String TABLE_NAME = "PANDROID_DATA";
|
||||
|
||||
// Contacts Table Columns names
|
||||
private static final String KEY_ID = "_ID";
|
||||
private static final String KEY_NAME = "NAME";
|
||||
private static final String KEY_VALUE = "VALUE";
|
||||
|
||||
public DataBaseHandler(Context context) {
|
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
|
||||
// you can use an alternate constructor to specify a database location
|
||||
// (such as a folder on the sd card)
|
||||
// you must ensure that this folder is available and you have permission
|
||||
// to write to it
|
||||
//super(context, DATABASE_NAME, context.getExternalFilesDir(null).getAbsolutePath(), null, DATABASE_VERSION);
|
||||
|
||||
}
|
||||
|
||||
// Update single value
|
||||
public int updateValue(DataHandler dh){
|
||||
int i = 0;
|
||||
|
||||
try {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KEY_NAME, dh.get_name());
|
||||
values.put(KEY_VALUE, dh.get_value());
|
||||
|
||||
// updating row
|
||||
i = db.update(TABLE_NAME, values, KEY_ID + " = ?",
|
||||
new String[] { String.valueOf(dh.get_id())});
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
// Getting single contact
|
||||
DataHandler getValue(String value) {
|
||||
DataHandler dh = null;
|
||||
try {
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
|
||||
|
||||
Cursor cursor = db.query(TABLE_NAME, new String[] { KEY_ID,
|
||||
KEY_NAME, KEY_VALUE }, KEY_NAME + "=?",
|
||||
new String[] { value }, null, null, null, null);
|
||||
if (cursor != null){
|
||||
cursor.moveToFirst();
|
||||
|
||||
|
||||
dh = new DataHandler(
|
||||
cursor.getString(1), cursor.getString(2));
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return dh;
|
||||
}
|
||||
}
|
|
@ -20,8 +20,6 @@ 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;
|
||||
|
@ -38,8 +36,7 @@ public class PandroidAgent extends TabActivity {
|
|||
int defaultInterval = 300;
|
||||
TabHost tabHost;
|
||||
|
||||
static SharedPreferences agentPreferences;
|
||||
static Editor editor;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -49,11 +46,7 @@ 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);
|
||||
|
@ -144,15 +137,7 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -63,6 +63,7 @@ import android.widget.Toast;
|
|||
public class PandroidAgentListener extends Service {
|
||||
|
||||
private NotificationManager notificationManager;
|
||||
private Notification notification;
|
||||
|
||||
Handler h = new Handler();
|
||||
String lastGpsContactDateTime = "";
|
||||
|
@ -71,36 +72,23 @@ 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();
|
||||
|
||||
|
||||
|
||||
wakeLock.release();
|
||||
stopSelf(startId);
|
||||
|
||||
|
@ -174,7 +162,7 @@ public class PandroidAgentListener extends Service {
|
|||
|
||||
Date date = new Date();
|
||||
|
||||
Core.putSharedData("PANDROID_DATA", "lastContact", Long.toString(date.getTime() / 1000), "long");
|
||||
HelperSharedPreferences.putSharedPreferencesLong(this, "lastContact", date.getTime() / 1000);
|
||||
Boolean xmlBuilt = true;
|
||||
String xml = "";
|
||||
|
||||
|
@ -224,7 +212,7 @@ public class PandroidAgentListener extends Service {
|
|||
|
||||
String[] tentacleData = {
|
||||
"-a",
|
||||
Core.getSharedData("PANDROID_DATA", "serverAddr", "", "string"),
|
||||
HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "serverAddr", ""),
|
||||
"-p",
|
||||
Core.defaultServerPort,
|
||||
"-v",
|
||||
|
@ -235,7 +223,7 @@ public class PandroidAgentListener extends Service {
|
|||
tentacleRet = new tentacle_client().tentacle_client(tentacleData);
|
||||
|
||||
if(tentacleRet == 0) {
|
||||
Core.putSharedData("PANDROID_DATA", "contactError", "0", "integer");
|
||||
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "contactError", 0);
|
||||
// Deleting the file after send it
|
||||
// move to only delete if sent successfully
|
||||
File file = new File("/data/data/pandroid.agent/files/" + destFileName);
|
||||
|
@ -247,7 +235,7 @@ public class PandroidAgentListener extends Service {
|
|||
}
|
||||
if(tentacleRet == -1){
|
||||
//file not deleted
|
||||
Core.putSharedData("PANDROID_DATA", "contactError", "1", "integer");
|
||||
HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "contactError", 1);
|
||||
contact = false;
|
||||
}
|
||||
i++;
|
||||
|
@ -269,18 +257,26 @@ public class PandroidAgentListener extends Service {
|
|||
String lastXML = buildXML();
|
||||
|
||||
String destFileName = "";
|
||||
String agentName = Core.getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||
String agentName = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "agentName", Core.defaultAgentName);
|
||||
destFileName = agentName + "." + System.currentTimeMillis() + ".data";
|
||||
|
||||
long bufferSize = 0;
|
||||
String[] buffer = getApplicationContext().fileList();
|
||||
|
||||
//Check if number of files is less than a value
|
||||
if(getApplicationContext().fileList().length < 100){
|
||||
for(int i = 1; i<buffer.length;i++){
|
||||
File file = new File("/data/data/pandroid.agent/files/" + buffer[i]);
|
||||
bufferSize += file.length();
|
||||
}
|
||||
Log.d("Buffer size:",""+bufferSize);
|
||||
|
||||
//Check if size of buffer is less than a value
|
||||
if((bufferSize/1024) < Core.bufferSize){
|
||||
writeFile(destFileName, lastXML);
|
||||
Core.putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
|
||||
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "lastXML", lastXML);
|
||||
}else{
|
||||
//buffer full
|
||||
}
|
||||
Core.putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
|
||||
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "lastXML", lastXML);
|
||||
|
||||
return lastXML;
|
||||
|
||||
|
@ -319,15 +315,15 @@ public class PandroidAgentListener extends Service {
|
|||
String gpsData = "";
|
||||
buffer += "<?xml version='1.0' encoding='iso-8859-1'?>\n";
|
||||
|
||||
String latitude = Core.getSharedData("PANDROID_DATA", "latitude", "181", "float");
|
||||
String longitude = Core.getSharedData("PANDROID_DATA", "longitude", "181", "float");
|
||||
String latitude = ""+HelperSharedPreferences.getSharedPreferencesFloat(getApplicationContext(), "latitude", 181);
|
||||
String longitude = ""+HelperSharedPreferences.getSharedPreferencesFloat(getApplicationContext(), "longitude", 181);
|
||||
|
||||
if(!latitude.equals("181.0") && !longitude.equals("181.0")) {
|
||||
gpsData = " latitude='" + latitude + "' longitude='" + longitude + "'";
|
||||
}
|
||||
|
||||
String agentName = Core.getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||
String interval = Core.getSharedData("PANDROID_DATA", "interval", Integer.toString(Core.defaultInterval), "integer");
|
||||
String agentName = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "agentName", Core.defaultAgentName);
|
||||
String interval = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "interval", Core.defaultInterval);
|
||||
|
||||
buffer += "<agent_data " +
|
||||
"description='' group='' os_name='android' os_version='"+Build.VERSION.RELEASE+"' " +
|
||||
|
@ -339,51 +335,51 @@ public class PandroidAgentListener extends Service {
|
|||
// MODULES //
|
||||
// //
|
||||
|
||||
String orientation = Core.getSharedData("PANDROID_DATA", "orientation", "361", "float");
|
||||
String proximity = Core.getSharedData("PANDROID_DATA", "proximity", "-1.0", "float");
|
||||
String batteryLevel = Core.getSharedData("PANDROID_DATA", "batteryLevel", "-1", "integer");
|
||||
String taskStatus = Core.getSharedData("PANDROID_DATA", "taskStatus", "disabled", "string");
|
||||
String taskRun = Core.getSharedData("PANDROID_DATA", "taskRun", "false", "string");
|
||||
String taskHumanName = Core.getSharedData("PANDROID_DATA", "taskHumanName", "", "string");
|
||||
String orientation = ""+HelperSharedPreferences.getSharedPreferencesFloat(getApplicationContext(), "orientation", 361);
|
||||
String proximity = ""+HelperSharedPreferences.getSharedPreferencesFloat(getApplicationContext(), "proximity", -1.0f);
|
||||
String batteryLevel = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "batteryLevel", -1);
|
||||
String taskStatus = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "taskStatus", "disabled");
|
||||
String taskRun = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "taskRun", "false");
|
||||
String taskHumanName = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "taskHumanName", "");
|
||||
taskHumanName = StringEscapeUtils.escapeHtml4(taskHumanName);
|
||||
|
||||
String task = Core.getSharedData("PANDROID_DATA", "task", "", "string");
|
||||
String memoryStatus = Core.getSharedData("PANDROID_DATA", "memoryStatus", Core.defaultMemoryStatus, "string");
|
||||
String availableRamKb = Core.getSharedData("PANDROID_DATA", "availableRamKb", "0" , "long");
|
||||
String totalRamKb = Core.getSharedData("PANDROID_DATA", "totalRamKb", "0", "long");
|
||||
String SimID = Core.getSharedData("PANDROID_DATA", "simID", Core.defaultSimID, "string");
|
||||
String upTime = Core.getSharedData("PANDROID_DATA", "upTime", ""+Core.defaultUpTime, "long");
|
||||
String networkOperator = Core.getSharedData("PANDROID_DATA", "networkOperator", Core.defaultNetworkOperator, "string");
|
||||
String SMSReceived = Core.getSharedData("PANDROID_DATA", "SMSReceived", ""+Core.defaultSMSReceived, "integer");
|
||||
String SMSSent = Core.getSharedData("PANDROID_DATA", "SMSSent", ""+Core.defaultSMSSent, "integer");
|
||||
String networkType = Core.getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
|
||||
String phoneType = Core.getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
|
||||
String signalStrength = Core.getSharedData("PANDROID_DATA", "signalStrength", ""+Core.defaultSignalStrength, "integer");
|
||||
String incomingCalls = Core.getSharedData("PANDROID_DATA", "incomingCalls", ""+Core.defaultIncomingCalls, "integer");
|
||||
String missedCalls = Core.getSharedData("PANDROID_DATA", "missedCalls", ""+Core.defaultMissedCalls, "integer");
|
||||
String outgoingCalls = Core.getSharedData("PANDROID_DATA", "outgoingCalls", ""+Core.defaultOutgoingCalls, "integer");
|
||||
String receiveBytes = Core.getSharedData("PANDROID_DATA", "receiveBytes", ""+Core.defaultReceiveBytes, "long");
|
||||
String transmitBytes = Core.getSharedData("PANDROID_DATA", "transmitBytes", ""+Core.defaultTransmitBytes, "long");
|
||||
String helloSignal = Core.getSharedData("PANDROID_DATA", "helloSignal", ""+Core.defaultHelloSignal, "integer");
|
||||
String roaming = Core.getSharedData("PANDROID_DATA", "roaming", ""+Core.defaultRoaming, "integer");
|
||||
String task = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "task", "");
|
||||
String memoryStatus = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "memoryStatus", Core.defaultMemoryStatus);
|
||||
String availableRamKb = ""+HelperSharedPreferences.getSharedPreferencesLong(getApplicationContext(), "availableRamKb", 0);
|
||||
String totalRamKb = ""+HelperSharedPreferences.getSharedPreferencesLong(getApplicationContext(), "totalRamKb", 0);
|
||||
String SimID = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "simID", Core.defaultSimID);
|
||||
String upTime = ""+HelperSharedPreferences.getSharedPreferencesLong(getApplicationContext(), "upTime", Core.defaultUpTime);
|
||||
String networkOperator = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "networkOperator", Core.defaultNetworkOperator);
|
||||
String SMSReceived = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "SMSReceived", Core.defaultSMSReceived);
|
||||
String SMSSent = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "SMSSent", Core.defaultSMSSent);
|
||||
String networkType = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "networkType", Core.defaultNetworkType);
|
||||
String phoneType = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "networkType", Core.defaultNetworkType);
|
||||
String signalStrength = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "signalStrength", Core.defaultSignalStrength);
|
||||
String incomingCalls = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "incomingCalls", Core.defaultIncomingCalls);
|
||||
String missedCalls = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "missedCalls", Core.defaultMissedCalls);
|
||||
String outgoingCalls = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "outgoingCalls", Core.defaultOutgoingCalls);
|
||||
String receiveBytes = ""+HelperSharedPreferences.getSharedPreferencesLong(getApplicationContext(), "receiveBytes", Core.defaultReceiveBytes);
|
||||
String transmitBytes = ""+HelperSharedPreferences.getSharedPreferencesLong(getApplicationContext(), "transmitBytes", Core.defaultTransmitBytes);
|
||||
String helloSignal = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "helloSignal", Core.defaultHelloSignal);
|
||||
String roaming = ""+HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "roaming", Core.defaultRoaming);
|
||||
|
||||
String simIDReport = Core.getSharedData("PANDROID_DATA", "simIDReport", Core.defaultSimIDReport, "string");
|
||||
String DeviceUpTimeReport = Core.getSharedData("PANDROID_DATA", "DeviceUpTimeReport", Core.defaultDeviceUpTimeReport, "string");
|
||||
String NetworkOperatorReport = Core.getSharedData("PANDROID_DATA", "NetworkOperatorReport", Core.defaultNetworkOperatorReport, "string");
|
||||
String NetworkTypeReport = Core.getSharedData("PANDROID_DATA", "NetworkTypeReport", Core.defaultNetworkTypeReport, "string");
|
||||
String PhoneTypeReport = Core.getSharedData("PANDROID_DATA", "PhoneTypeReport", Core.defaultPhoneTypeReport, "string");
|
||||
String SignalStrengthReport = Core.getSharedData("PANDROID_DATA", "SignalStrengthReport", Core.defaultSignalStrengthReport, "string");
|
||||
String ReceivedSMSReport = Core.getSharedData("PANDROID_DATA", "ReceivedSMSReport", Core.defaultReceivedSMSReport, "string");
|
||||
String SentSMSReport = Core.getSharedData("PANDROID_DATA", "SentSMSReport", Core.defaultSentSMSReport, "string");
|
||||
String IncomingCallsReport = Core.getSharedData("PANDROID_DATA", "IncomingCallsReport", Core.defaultIncomingCallsReport, "string");
|
||||
String MissedCallsReport = Core.getSharedData("PANDROID_DATA", "MissedCallsReport", Core.defaultMissedCallsReport, "string");
|
||||
String OutgoingCallsReport = Core.getSharedData("PANDROID_DATA", "OutgoingCallsReport", Core.defaultOutgoingCallsReport, "string");
|
||||
String BytesReceivedReport = Core.getSharedData("PANDROID_DATA", "BytesReceivedReport", Core.defaultBytesReceivedReport, "string");
|
||||
String BytesSentReport = Core.getSharedData("PANDROID_DATA", "BytesSentReport", Core.defaultBytesSentReport, "string");
|
||||
String HelloSignalReport = Core.getSharedData("PANDROID_DATA", "HelloSignalReport", Core.defaultHelloSignalReport, "string");
|
||||
String BatteryLevelReport = Core.getSharedData("PANDROID_DATA", "BatteryLevelReport", Core.defaultBatteryLevelReport, "string");
|
||||
String RoamingReport = Core.getSharedData("PANDROID_DATA", "RoamingReport", Core.defaultRoamingReport, "string");
|
||||
String InventoryReport = Core.getSharedData("PANDROID_DATA", "InventoryReport", Core.defaultInventoryReport, "string");
|
||||
String simIDReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "simIDReport", Core.defaultSimIDReport);
|
||||
String DeviceUpTimeReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "DeviceUpTimeReport", Core.defaultDeviceUpTimeReport);
|
||||
String NetworkOperatorReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "NetworkOperatorReport", Core.defaultNetworkOperatorReport);
|
||||
String NetworkTypeReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "NetworkTypeReport", Core.defaultNetworkTypeReport);
|
||||
String PhoneTypeReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "PhoneTypeReport", Core.defaultPhoneTypeReport);
|
||||
String SignalStrengthReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "SignalStrengthReport", Core.defaultSignalStrengthReport);
|
||||
String ReceivedSMSReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "ReceivedSMSReport", Core.defaultReceivedSMSReport);
|
||||
String SentSMSReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "SentSMSReport", Core.defaultSentSMSReport);
|
||||
String IncomingCallsReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "IncomingCallsReport", Core.defaultIncomingCallsReport);
|
||||
String MissedCallsReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "MissedCallsReport", Core.defaultMissedCallsReport);
|
||||
String OutgoingCallsReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "OutgoingCallsReport", Core.defaultOutgoingCallsReport);
|
||||
String BytesReceivedReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "BytesReceivedReport", Core.defaultBytesReceivedReport);
|
||||
String BytesSentReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "BytesSentReport", Core.defaultBytesSentReport);
|
||||
String HelloSignalReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "HelloSignalReport", Core.defaultHelloSignalReport);
|
||||
String BatteryLevelReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "BatteryLevelReport", Core.defaultBatteryLevelReport);
|
||||
String RoamingReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "RoamingReport", Core.defaultRoamingReport);
|
||||
String InventoryReport = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "InventoryReport", Core.defaultInventoryReport);
|
||||
|
||||
if(InventoryReport.equals("enabled"))
|
||||
{
|
||||
|
@ -568,8 +564,8 @@ public class PandroidAgentListener extends Service {
|
|||
//if(latitude != loc.getLatitude() || longitude != loc.getLongitude()) {
|
||||
lastGpsContactDateTime = getHumanDateTime(-1);
|
||||
//}
|
||||
Core.putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
|
||||
Core.putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
|
||||
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "latitude", (float) loc.getLatitude());
|
||||
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "longitude", (float) loc.getLongitude());
|
||||
}
|
||||
else {
|
||||
Criteria criteria = new Criteria();
|
||||
|
@ -589,10 +585,8 @@ public class PandroidAgentListener extends Service {
|
|||
lm.requestLocationUpdates(bestProvider, Core.defaultInterval, 1000,
|
||||
new LocationListener() {
|
||||
public void onLocationChanged(Location location) {
|
||||
Core.putSharedData("PANDROID_DATA", "latitude",
|
||||
Double.valueOf(location.getLatitude()).toString(), "float");
|
||||
Core.putSharedData("PANDROID_DATA", "longitude",
|
||||
Double.valueOf(location.getLongitude()).toString(), "float");
|
||||
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "latitude",(float) location.getLatitude());
|
||||
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "longitude",(float) location.getLongitude());
|
||||
}
|
||||
public void onStatusChanged(String s, int i, Bundle bundle) {
|
||||
|
||||
|
@ -601,8 +595,7 @@ public class PandroidAgentListener extends Service {
|
|||
// try switching to a different provider
|
||||
}
|
||||
public void onProviderDisabled(String s) {
|
||||
Core.putSharedData("PANDROID_DATA", "enabled_location_provider",
|
||||
"disabled", "string");
|
||||
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "enabled_location_provider", "disabled");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -616,7 +609,7 @@ public class PandroidAgentListener extends Service {
|
|||
int scale = batteryIntent.getIntExtra("scale", -1);
|
||||
//double level = -1;
|
||||
if (rawlevel >= 0 && scale > 0) {
|
||||
Core.putSharedData("PANDROID_DATA", "batteryLevel", Integer.valueOf((rawlevel * 100) / scale).toString(), "integer");
|
||||
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "batteryLevel", (rawlevel * 100) / scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -683,7 +676,7 @@ public class PandroidAgentListener extends Service {
|
|||
private void updateValues() {
|
||||
|
||||
batteryLevel();
|
||||
String gpsStatus = Core.getSharedData("PANDROID_DATA", "gpsStatus", Core.defaultGpsStatus, "string");
|
||||
String gpsStatus = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "gpsStatus", Core.defaultGpsStatus);
|
||||
|
||||
if(gpsStatus.equals("enabled")) {
|
||||
Log.d("PANDROID AGENT", "ENABLED");
|
||||
|
@ -691,8 +684,8 @@ public class PandroidAgentListener extends Service {
|
|||
}
|
||||
else {
|
||||
Log.d("PANDROID AGENT", "DISABLED");
|
||||
Core.putSharedData("PANDROID_DATA", "latitude", "181.0", "float");
|
||||
Core.putSharedData("PANDROID_DATA", "longitude", "181.0", "float");
|
||||
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "latitude", 181.0f);
|
||||
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "longitude", 181.0f);
|
||||
}
|
||||
|
||||
//sensors();
|
||||
|
@ -715,7 +708,7 @@ public class PandroidAgentListener extends Service {
|
|||
}
|
||||
|
||||
private void getMemoryStatus() {
|
||||
String memoryStatus = Core.getSharedData("PANDROID_DATA", "memoryStatus", Core.defaultMemoryStatus, "string");
|
||||
String memoryStatus = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "memoryStatus", Core.defaultMemoryStatus);
|
||||
long availableRamKb = 0;
|
||||
long totalRamKb = 0;
|
||||
|
||||
|
@ -741,14 +734,14 @@ public class PandroidAgentListener extends Service {
|
|||
}
|
||||
}
|
||||
|
||||
Core.putSharedData("PANDROID_DATA", "availableRamKb", "" + availableRamKb, "long");
|
||||
Core.putSharedData("PANDROID_DATA", "totalRamKb", "" + totalRamKb, "long");
|
||||
HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "availableRamKb", availableRamKb);
|
||||
HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "totalRamKb", totalRamKb);
|
||||
}// end getMemoryStatus
|
||||
|
||||
private void getTaskStatus() {
|
||||
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 taskStatus = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "taskStatus", Core.defaultTaskStatus);
|
||||
String task = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "task", Core.defaultTask);
|
||||
String taskHumanName = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "taskHumanName", Core.defaultTaskHumanName);
|
||||
String run = "false";
|
||||
|
||||
if (taskStatus.equals("enabled")) {
|
||||
|
@ -768,7 +761,7 @@ public class PandroidAgentListener extends Service {
|
|||
}
|
||||
}
|
||||
}
|
||||
Core.putSharedData("PANDROID_DATA", "taskRun", run, "string");
|
||||
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "taskRun", run);
|
||||
}//end getTaskStatus
|
||||
|
||||
/**
|
||||
|
@ -776,12 +769,12 @@ public class PandroidAgentListener extends Service {
|
|||
*/
|
||||
private void getSimID(){
|
||||
|
||||
String simID = Core.getSharedData("PANDROID_DATA", "simID", Core.defaultSimID, "string");
|
||||
String simID = HelperSharedPreferences.getSharedPreferencesString(getApplicationContext(), "simID", Core.defaultSimID);
|
||||
|
||||
String serviceName = Context.TELEPHONY_SERVICE;
|
||||
TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService(serviceName);
|
||||
simID = telephonyManager.getSimSerialNumber();
|
||||
Core.putSharedData("PANDROID_DATA", "simID", simID, "string");
|
||||
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "simID", simID);
|
||||
}
|
||||
/**
|
||||
* Retrieves the time in seconds since the device was switched on
|
||||
|
@ -790,7 +783,7 @@ public class PandroidAgentListener extends Service {
|
|||
long upTime = Core.defaultUpTime;
|
||||
upTime = SystemClock.elapsedRealtime()/1000;
|
||||
if(upTime != 0)
|
||||
Core.putSharedData("PANDROID_DATA", "upTime", ""+upTime, "long");
|
||||
HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "upTime", upTime);
|
||||
}
|
||||
/**
|
||||
* Retrieve currently registered network operator, i.e. vodafone, movistar, etc...
|
||||
|
@ -802,15 +795,15 @@ public class PandroidAgentListener extends Service {
|
|||
networkOperator = telephonyManager.getNetworkOperatorName();
|
||||
|
||||
if(networkOperator != null)
|
||||
Core.putSharedData("PANDROID_DATA", "networkOperator", networkOperator, "string");
|
||||
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "networkOperator", networkOperator);
|
||||
}
|
||||
/**
|
||||
* Retrieves the number of sent sms messages using the android messaging app only
|
||||
*/
|
||||
private void getSMSSent(){
|
||||
|
||||
String SMSSent = ""+Core.defaultSMSSent;
|
||||
SMSSent = Core.getSharedData("PANDROID_DATA", "SMSSent", ""+Core.defaultSMSSent, "integer");
|
||||
int SMSSent = Core.defaultSMSSent;
|
||||
SMSSent = HelperSharedPreferences.getSharedPreferencesInt(getApplicationContext(), "SMSSent", Core.defaultSMSSent);
|
||||
Uri allMessages = Uri.parse("content://sms/sent");
|
||||
Cursor c = getContentResolver().query(allMessages, null, null, null, null);
|
||||
int totalMessages = 0;
|
||||
|
@ -826,10 +819,10 @@ public class PandroidAgentListener extends Service {
|
|||
|
||||
c.close();
|
||||
|
||||
SMSSent =""+ totalMessages;
|
||||
SMSSent = totalMessages;
|
||||
|
||||
if(SMSSent != null)
|
||||
Core.putSharedData("PANDROID_DATA", "SMSSent", SMSSent, "integer");
|
||||
if(SMSSent != 0)
|
||||
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "SMSSent", SMSSent);
|
||||
|
||||
}// end getSMSSent
|
||||
/**
|
||||
|
@ -893,7 +886,7 @@ public class PandroidAgentListener extends Service {
|
|||
break;
|
||||
}
|
||||
if(networkType != null)
|
||||
Core.putSharedData("PANDROID_DATA", "networkType", networkType, "string");
|
||||
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "networkType", networkType);
|
||||
|
||||
}// end getNetworkType
|
||||
|
||||
|
@ -922,7 +915,7 @@ public class PandroidAgentListener extends Service {
|
|||
break;
|
||||
}
|
||||
if(phoneType != null)
|
||||
Core.putSharedData("PANDROID_DATA", "phoneType", phoneType, "string");
|
||||
HelperSharedPreferences.putSharedPreferencesString(getApplicationContext(), "phoneType", phoneType);
|
||||
}// end getPhoneType
|
||||
|
||||
/**
|
||||
|
@ -956,9 +949,9 @@ public class PandroidAgentListener extends Service {
|
|||
c.moveToNext();
|
||||
}
|
||||
|
||||
Core.putSharedData("PANDROID_DATA", "incomingCalls", ""+incoming, "integer");
|
||||
Core.putSharedData("PANDROID_DATA", "missedCalls", ""+missed, "integer");
|
||||
Core.putSharedData("PANDROID_DATA", "outgoingCalls", ""+outgoing, "integer");
|
||||
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "incomingCalls", incoming);
|
||||
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "missedCalls", missed);
|
||||
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "outgoingCalls", outgoing);
|
||||
}
|
||||
|
||||
c.close();
|
||||
|
@ -979,17 +972,17 @@ public class PandroidAgentListener extends Service {
|
|||
public void onSignalStrengthsChanged(SignalStrength signalStrength)
|
||||
{
|
||||
super.onSignalStrengthsChanged(signalStrength);
|
||||
String signalStrengthValue = ""+Core.defaultSignalStrength;
|
||||
int 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());
|
||||
}
|
||||
Core.putSharedData("PANDROID_DATA", "signalStrength", signalStrengthValue, "integer");
|
||||
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "signalStrength", signalStrengthValue);
|
||||
}
|
||||
};
|
||||
/**
|
||||
|
@ -1003,8 +996,8 @@ public class PandroidAgentListener extends Service {
|
|||
|
||||
if (receiveBytes != TrafficStats.UNSUPPORTED && transmitBytes != TrafficStats.UNSUPPORTED)
|
||||
{
|
||||
Core.putSharedData("PANDROID_DATA", "receiveBytes", ""+receiveBytes, "long" );
|
||||
Core.putSharedData("PANDROID_DATA", "transmitBytes", ""+transmitBytes, "long" );
|
||||
HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "receiveBytes", receiveBytes);
|
||||
HelperSharedPreferences.putSharedPreferencesLong(getApplicationContext(), "transmitBytes", transmitBytes);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -1016,9 +1009,9 @@ public class PandroidAgentListener extends Service {
|
|||
boolean roaming = telephone.isNetworkRoaming();
|
||||
|
||||
if(roaming)
|
||||
Core.putSharedData("PANDROID_DATA", "roaming", "1", "integer" );
|
||||
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "roaming", 1);
|
||||
else
|
||||
Core.putSharedData("PANDROID_DATA", "roaming", "0", "integer" );
|
||||
HelperSharedPreferences.putSharedPreferencesInt(getApplicationContext(), "roaming", 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1082,8 +1075,8 @@ public class PandroidAgentListener extends Service {
|
|||
|
||||
@Override
|
||||
public void onLocationChanged(Location loc) {
|
||||
Core.putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
|
||||
Core.putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
|
||||
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "latitude", (float)loc.getLatitude());
|
||||
HelperSharedPreferences.putSharedPreferencesFloat(getApplicationContext(), "longitude", (float)loc.getLongitude());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,14 +36,14 @@ import android.util.Log;
|
|||
int defaultSMSReceived = 0;
|
||||
int mode = Activity.MODE_PRIVATE;
|
||||
|
||||
SharedPreferences pref = PandroidAgent.getSharedPrefs();
|
||||
int sms = pref.getInt("SMSReceived", defaultSMSReceived);
|
||||
|
||||
int sms = HelperSharedPreferences.getSharedPreferencesInt(context, "SMSReceived", defaultSMSReceived);
|
||||
|
||||
sms++;
|
||||
|
||||
SharedPreferences.Editor editor = pref.edit();
|
||||
editor.putInt("SMSReceived", sms);
|
||||
editor.commit();
|
||||
|
||||
HelperSharedPreferences.putSharedPreferencesInt(context, "SMSReceived", sms);
|
||||
|
||||
|
||||
}//end if
|
||||
|
||||
|
|
|
@ -290,6 +290,9 @@ public class Setup extends Activity {
|
|||
|
||||
editText = (EditText) findViewById(R.id.mobileWebURLInput);
|
||||
Core.mobileWebURL = editText.getText().toString();
|
||||
|
||||
editText = (EditText) findViewById(R.id.bufferSize);
|
||||
Core.bufferSize = Long.valueOf(editText.getText().toString()).longValue();
|
||||
|
||||
checkBox = (CheckBox) findViewById(R.id.checkGpsReport);
|
||||
if (checkBox.isChecked())
|
||||
|
@ -455,6 +458,9 @@ public class Setup extends Activity {
|
|||
|
||||
editText = (EditText) findViewById(R.id.mobileWebURLInput);
|
||||
editText.setText(Core.mobileWebURL);
|
||||
|
||||
editText = (EditText) findViewById(R.id.bufferSize);
|
||||
editText.setText(Long.toString(Core.bufferSize));
|
||||
|
||||
checkBox = (CheckBox) findViewById(R.id.checkGpsReport);
|
||||
checkBox.setChecked(Core.gpsStatus.equals("enabled"));
|
||||
|
@ -739,4 +745,4 @@ public class Setup extends Activity {
|
|||
nMgr.cancel(notifyId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -18,7 +18,6 @@ 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;
|
||||
|
|
Loading…
Reference in New Issue