2013-04-25 Mark Holland <mark@mark-holland.me.uk>
* src/pandroid/agent/Core.java: Separate load and store methods for SharedPreferences and database. * src/pandroid/agent/PandroidAgent.java: Values retrieved from database onCreate. onPause and onDestroy values are saved to database. * src/pandroid/agent/PandroidAgentListener.java: Reverted to using SharedPreferences at runtime, database used when app not in view. Added module as proof of iso-8859-1 now working. * Pandroid Agent v3.0_iso-8859-1.apk: For testing whether configuration is no longer lost after an amount of time. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8062 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
89d7e883bd
commit
b378efc27e
|
@ -1,3 +1,19 @@
|
|||
2013-04-25 Mark Holland <mark@mark-holland.me.uk>
|
||||
|
||||
* src/pandroid/agent/Core.java: Separate load and store
|
||||
methods for SharedPreferences and database.
|
||||
|
||||
* src/pandroid/agent/PandroidAgent.java: Values retrieved from
|
||||
database onCreate. onPause and onDestroy values are saved to
|
||||
database.
|
||||
|
||||
* src/pandroid/agent/PandroidAgentListener.java: Reverted to using
|
||||
SharedPreferences at runtime, database used when app not in view.
|
||||
Added module as proof of iso-8859-1 now working.
|
||||
|
||||
* Pandroid Agent v3.0_iso-8859-1.apk: For testing whether
|
||||
configuration is no longer lost after an amount of time.
|
||||
|
||||
2013-04-25 Mark Holland <mark@mark-holland.me.uk>
|
||||
|
||||
* src/pandroid/agent/Core.java: Changed get and update
|
||||
|
|
Binary file not shown.
|
@ -14,10 +14,14 @@
|
|||
|
||||
package pandroid.agent;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
//import android.util.Log;
|
||||
|
||||
public class Core {
|
||||
|
||||
|
@ -177,7 +181,7 @@ public class Core {
|
|||
|
||||
}
|
||||
|
||||
static public void startAgentListener(Context context) {
|
||||
static synchronized public void startAgentListener(Context context) {
|
||||
if (con == null) {
|
||||
con = context;
|
||||
}
|
||||
|
@ -193,98 +197,102 @@ public class Core {
|
|||
|
||||
}// end startAgentListener
|
||||
|
||||
static public void stopAgentListener() {
|
||||
static synchronized public void stopAgentListener() {
|
||||
if (am != null){
|
||||
am.cancel(sender);
|
||||
alarmEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
static public void restartAgentListener(Context context) {
|
||||
static synchronized public void restartAgentListener(Context context) {
|
||||
stopAgentListener();
|
||||
startAgentListener(context);
|
||||
}
|
||||
|
||||
static public void loadLastValues(Context context) {
|
||||
static synchronized public void loadLastValues(Context context) {
|
||||
if (con == null) {
|
||||
con = context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SharedPreferences agentPreferences = con.getSharedPreferences(
|
||||
con.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
latitude = Float.parseFloat(getValue(con, "latitude"));
|
||||
longitude = Float.parseFloat(getValue(con, "longitude"));
|
||||
batteryLevel = Integer.parseInt(getValue(con, "batteryLevel"));
|
||||
orientation = Float.parseFloat(getValue(con, "orientation"));
|
||||
proximity = Float.parseFloat(getValue(con, "proximity"));
|
||||
taskStatus = getValue(con, "taskStatus");
|
||||
task = getValue(con, "task");
|
||||
taskHumanName = getValue(con, "taskHumanName");
|
||||
taskRun = getValue(con, "taskRun");
|
||||
memoryStatus = getValue(con, "memoryStatus");
|
||||
availableRamKb = Long.parseLong(getValue(con, "availableRamKb"));
|
||||
totalRamKb = Long.parseLong(getValue(con, "totalRamKb"));
|
||||
lastContact = Long.parseLong(getValue(con, "lastContact"));
|
||||
contactError = Integer.parseInt(getValue(con, "contactError"));
|
||||
simID = getValue(con, "simID");
|
||||
upTime = Long.parseLong(getValue(con, "upTime"));
|
||||
SMSReceived = Integer.parseInt(getValue(con, "SMSReceived"));
|
||||
SMSSent = Integer.parseInt(getValue(con, "SMSSent"));
|
||||
networkOperator = getValue(con, "networkOperator");
|
||||
networkType = getValue(con, "networkType");
|
||||
phoneType = getValue(con, "phoneType");
|
||||
signalStrength = Integer.parseInt(getValue(con, "signalStrength"));
|
||||
incomingCalls = Integer.parseInt(getValue(con, "incomingCalls"));
|
||||
missedCalls = Integer.parseInt(getValue(con, "missedCalls"));
|
||||
outgoingCalls = Integer.parseInt(getValue(con, "outgoingCalls"));
|
||||
receiveBytes = Long.parseLong(getValue(con, "receiveBytes"));
|
||||
transmitBytes = Long.parseLong(getValue(con, "transmitBytes"));
|
||||
helloSignal = Integer.parseInt(getValue(con, "helloSignal"));
|
||||
roaming = Integer.parseInt(getValue(con, "roaming"));
|
||||
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
|
||||
|
||||
static public void loadConf(Context context) {
|
||||
static synchronized public void loadConf(Context context) {
|
||||
if (con == null) {
|
||||
con = context;
|
||||
}
|
||||
|
||||
|
||||
serverAddr = getValue(con, "serverAddr");
|
||||
serverPort = getValue(con, "serverPort");
|
||||
interval = Integer.parseInt(getValue(con, "interval"));
|
||||
agentName = getValue(con, "agentName");
|
||||
mobileWebURL = getValue(con, "mobileWebURL");
|
||||
gpsStatus = getValue(con, "gpsStatus");
|
||||
memoryStatus = getValue(con, "memoryStatus");
|
||||
taskStatus = getValue(con, "taskStatus");
|
||||
task = getValue(con, "task");
|
||||
taskHumanName = getValue(con, "taskHumanName");
|
||||
taskRun = getValue(con, "taskRun");
|
||||
password = getValue(con, "password");
|
||||
passwordCheck = getValue(con, "passwordCheck");
|
||||
simIDReport = getValue(con, "simIDReport");
|
||||
DeviceUpTimeReport = getValue(con, "DeviceUpTimeReport");
|
||||
NetworkOperatorReport = getValue(con, "NetworkOperatorReport");
|
||||
NetworkTypeReport = getValue(con, "NetworkTypeReport");
|
||||
PhoneTypeReport = getValue(con, "PhoneTypeReport");
|
||||
SignalStrengthReport = getValue(con, "SignalStrengthReport");
|
||||
ReceivedSMSReport = getValue(con, "ReceivedSMSReport");
|
||||
SentSMSReport = getValue(con, "SentSMSReport");
|
||||
IncomingCallsReport = getValue(con, "IncomingCallsReport");
|
||||
MissedCallsReport = getValue(con, "MissedCallsReport");
|
||||
OutgoingCallsReport = getValue(con, "OutgoingCallsReport");
|
||||
BytesReceivedReport = getValue(con, "BytesReceivedReport");
|
||||
BytesSentReport = getValue(con, "BytesSentReport");
|
||||
HelloSignalReport = getValue(con, "HelloSignalReport");
|
||||
BatteryLevelReport = getValue(con, "BatteryLevelReport");
|
||||
RoamingReport = getValue(con, "RoamingReport");
|
||||
InventoryReport = getValue(con, "InventoryReport");
|
||||
NotificationCheck = getValue(con, "NotificationCheck");
|
||||
SharedPreferences agentPreferences = con.getSharedPreferences(
|
||||
con.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
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 public boolean updateConf(Context context) {
|
||||
static synchronized public boolean updateConf(Context context) {
|
||||
return updateConf(context, serverAddr, serverPort, interval, agentName,
|
||||
gpsStatus, memoryStatus, taskStatus, task, taskHumanName, simID, simIDReport, upTime,
|
||||
networkOperator, SMSReceived, SMSSent, networkType, phoneType, signalStrength,
|
||||
|
@ -297,7 +305,175 @@ public class Core {
|
|||
|
||||
}// end updateConf
|
||||
|
||||
static public boolean updateConf(Context context, String _serverAddr,
|
||||
static synchronized public boolean updateConf(Context context, String _serverAddr,
|
||||
String _serverPort, int _interval, String _agentName, String _gpsStatus,
|
||||
String _memoryStatus, String _taskStatus, String _task,
|
||||
String _taskHumanName, String _simID, String _simIDReport, long _upTime, String _networkOperator,
|
||||
int _smsReceived, int _smsSent, String _networkType, String _phoneType, int _signalStrength,
|
||||
int _incomingCalls, int _missedCalls, int _outgoingCalls, long _receiveBytes, long _transmitBytes,
|
||||
String _password, int _helloSignal, String _passwordCheck, String _DeviceUpTimeReport, String _NetworkOperatorReport,
|
||||
String _NetworkTypeReport, String _PhoneTypeReport, String _SignalStrengthReport, String _ReceivedSMSReport,
|
||||
String _SentSMSReport, String _IncomingCallsReport, String _MissedCallsReport, String _OutgoingCallsReport, String _BytesReceivedReport,
|
||||
String _BytesSentReport, String _HelloSignalReport, String _BatteryLevelReport, String _RoamingReport, int _roaming, String _mobileWebURL,
|
||||
String _InventoryReport, String _NotificationCheck) {
|
||||
|
||||
if (con == null) {
|
||||
con = context;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (editor.commit()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}// end updateConf
|
||||
|
||||
|
||||
//database//
|
||||
|
||||
static synchronized public void loadLastValuesDatabase(Context context) {
|
||||
if (con == null) {
|
||||
con = context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
latitude = Float.parseFloat(getDatabaseValue(con, "latitude"));
|
||||
longitude = Float.parseFloat(getDatabaseValue(con, "longitude"));
|
||||
batteryLevel = Integer.parseInt(getDatabaseValue(con, "batteryLevel"));
|
||||
orientation = Float.parseFloat(getDatabaseValue(con, "orientation"));
|
||||
proximity = Float.parseFloat(getDatabaseValue(con, "proximity"));
|
||||
taskStatus = getDatabaseValue(con, "taskStatus");
|
||||
task = getDatabaseValue(con, "task");
|
||||
taskHumanName = getDatabaseValue(con, "taskHumanName");
|
||||
taskRun = getDatabaseValue(con, "taskRun");
|
||||
memoryStatus = getDatabaseValue(con, "memoryStatus");
|
||||
availableRamKb = Long.parseLong(getDatabaseValue(con, "availableRamKb"));
|
||||
totalRamKb = Long.parseLong(getDatabaseValue(con, "totalRamKb"));
|
||||
lastContact = Long.parseLong(getDatabaseValue(con, "lastContact"));
|
||||
contactError = Integer.parseInt(getDatabaseValue(con, "contactError"));
|
||||
simID = getDatabaseValue(con, "simID");
|
||||
upTime = Long.parseLong(getDatabaseValue(con, "upTime"));
|
||||
SMSReceived = Integer.parseInt(getDatabaseValue(con, "SMSReceived"));
|
||||
SMSSent = Integer.parseInt(getDatabaseValue(con, "SMSSent"));
|
||||
networkOperator = getDatabaseValue(con, "networkOperator");
|
||||
networkType = getDatabaseValue(con, "networkType");
|
||||
phoneType = getDatabaseValue(con, "phoneType");
|
||||
signalStrength = Integer.parseInt(getDatabaseValue(con, "signalStrength"));
|
||||
incomingCalls = Integer.parseInt(getDatabaseValue(con, "incomingCalls"));
|
||||
missedCalls = Integer.parseInt(getDatabaseValue(con, "missedCalls"));
|
||||
outgoingCalls = Integer.parseInt(getDatabaseValue(con, "outgoingCalls"));
|
||||
receiveBytes = Long.parseLong(getDatabaseValue(con, "receiveBytes"));
|
||||
transmitBytes = Long.parseLong(getDatabaseValue(con, "transmitBytes"));
|
||||
helloSignal = Integer.parseInt(getDatabaseValue(con, "helloSignal"));
|
||||
roaming = Integer.parseInt(getDatabaseValue(con, "roaming"));
|
||||
|
||||
}// end loadLastValues
|
||||
|
||||
static synchronized public void loadConfDatabase(Context context) {
|
||||
if (con == null) {
|
||||
con = context;
|
||||
}
|
||||
|
||||
|
||||
serverAddr = getDatabaseValue(con, "serverAddr");
|
||||
serverPort = getDatabaseValue(con, "serverPort");
|
||||
interval = Integer.parseInt(getDatabaseValue(con, "interval"));
|
||||
agentName = getDatabaseValue(con, "agentName");
|
||||
mobileWebURL = getDatabaseValue(con, "mobileWebURL");
|
||||
gpsStatus = getDatabaseValue(con, "gpsStatus");
|
||||
memoryStatus = getDatabaseValue(con, "memoryStatus");
|
||||
taskStatus = getDatabaseValue(con, "taskStatus");
|
||||
task = getDatabaseValue(con, "task");
|
||||
taskHumanName = getDatabaseValue(con, "taskHumanName");
|
||||
taskRun = getDatabaseValue(con, "taskRun");
|
||||
password = getDatabaseValue(con, "password");
|
||||
passwordCheck = getDatabaseValue(con, "passwordCheck");
|
||||
simIDReport = getDatabaseValue(con, "simIDReport");
|
||||
DeviceUpTimeReport = getDatabaseValue(con, "DeviceUpTimeReport");
|
||||
NetworkOperatorReport = getDatabaseValue(con, "NetworkOperatorReport");
|
||||
NetworkTypeReport = getDatabaseValue(con, "NetworkTypeReport");
|
||||
PhoneTypeReport = getDatabaseValue(con, "PhoneTypeReport");
|
||||
SignalStrengthReport = getDatabaseValue(con, "SignalStrengthReport");
|
||||
ReceivedSMSReport = getDatabaseValue(con, "ReceivedSMSReport");
|
||||
SentSMSReport = getDatabaseValue(con, "SentSMSReport");
|
||||
IncomingCallsReport = getDatabaseValue(con, "IncomingCallsReport");
|
||||
MissedCallsReport = getDatabaseValue(con, "MissedCallsReport");
|
||||
OutgoingCallsReport = getDatabaseValue(con, "OutgoingCallsReport");
|
||||
BytesReceivedReport = getDatabaseValue(con, "BytesReceivedReport");
|
||||
BytesSentReport = getDatabaseValue(con, "BytesSentReport");
|
||||
HelloSignalReport = getDatabaseValue(con, "HelloSignalReport");
|
||||
BatteryLevelReport = getDatabaseValue(con, "BatteryLevelReport");
|
||||
RoamingReport = getDatabaseValue(con, "RoamingReport");
|
||||
InventoryReport = getDatabaseValue(con, "InventoryReport");
|
||||
NotificationCheck = getDatabaseValue(con, "NotificationCheck");
|
||||
}// end loadConf
|
||||
|
||||
static synchronized public boolean updateDatabase(Context context) {
|
||||
return updateDatabase(context, serverAddr, serverPort, interval, agentName,
|
||||
gpsStatus, memoryStatus, taskStatus, task, taskHumanName, simID, simIDReport, upTime,
|
||||
networkOperator, SMSReceived, SMSSent, networkType, phoneType, signalStrength,
|
||||
incomingCalls, missedCalls, outgoingCalls, receiveBytes, transmitBytes, password, helloSignal,
|
||||
passwordCheck, DeviceUpTimeReport, NetworkOperatorReport, NetworkTypeReport, PhoneTypeReport,
|
||||
SignalStrengthReport, ReceivedSMSReport, SentSMSReport, IncomingCallsReport, MissedCallsReport,
|
||||
OutgoingCallsReport, BytesReceivedReport, BytesSentReport, HelloSignalReport, BatteryLevelReport,
|
||||
RoamingReport, roaming, mobileWebURL, InventoryReport , NotificationCheck
|
||||
);
|
||||
|
||||
}// end updateConf
|
||||
|
||||
static synchronized public boolean updateDatabase(Context context, String _serverAddr,
|
||||
String _serverPort, int _interval, String _agentName, String _gpsStatus,
|
||||
String _memoryStatus, String _taskStatus, String _task,
|
||||
String _taskHumanName, String _simID, String _simIDReport, long _upTime, String _networkOperator,
|
||||
|
@ -315,51 +491,51 @@ public class Core {
|
|||
|
||||
|
||||
|
||||
updateValue(con,"serverAddr", _serverAddr);
|
||||
updateValue(con,"serverPort", _serverPort);
|
||||
updateValue(con,"interval", ""+_interval);
|
||||
updateValue(con,"agentName", _agentName);
|
||||
updateValue(con,"gpsStatus", _gpsStatus);
|
||||
updateValue(con,"memoryStatus", _memoryStatus);
|
||||
updateValue(con,"taskStatus", _taskStatus);
|
||||
updateValue(con,"task", _task);
|
||||
updateValue(con,"taskHumanName", _taskHumanName);
|
||||
updateValue(con,"simID", _simID);
|
||||
updateValue(con,"simIDReport", _simIDReport);
|
||||
updateValue(con,"upTime", ""+_upTime);
|
||||
updateValue(con,"networkOperator", _networkOperator);
|
||||
updateValue(con,"SMSReceived", ""+_smsReceived);
|
||||
updateValue(con,"SMSSent", ""+_smsSent);
|
||||
updateValue(con,"networkType", _networkType);
|
||||
updateValue(con,"phoneType", _phoneType);
|
||||
updateValue(con,"signalStrength", ""+_signalStrength);
|
||||
updateValue(con,"incomingCalls", ""+_incomingCalls);
|
||||
updateValue(con,"missedCalls", ""+_missedCalls);
|
||||
updateValue(con,"outgoingCalls", ""+_outgoingCalls);
|
||||
updateValue(con,"receiveBytes", ""+_receiveBytes);
|
||||
updateValue(con,"transmitBytes", ""+_transmitBytes);
|
||||
updateValue(con,"password", _password);
|
||||
updateValue(con,"passwordCheck", _passwordCheck);
|
||||
updateValue(con,"helloSignal", ""+_helloSignal);
|
||||
updateValue(con,"roaming", ""+_roaming);
|
||||
updateValue(con,"DeviceUpTimeReport", _DeviceUpTimeReport);
|
||||
updateValue(con,"NetworkOperatorReport", _NetworkOperatorReport);
|
||||
updateValue(con,"NetworkTypeReport", _NetworkTypeReport);
|
||||
updateValue(con,"PhoneTypeReport", _PhoneTypeReport);
|
||||
updateValue(con,"SignalStrengthReport", _SignalStrengthReport);
|
||||
updateValue(con,"ReceivedSMSReport", _ReceivedSMSReport);
|
||||
updateValue(con,"SentSMSReport", _SentSMSReport);
|
||||
updateValue(con,"IncomingCallsReport", _IncomingCallsReport);
|
||||
updateValue(con,"MissedCallsReport", _MissedCallsReport);
|
||||
updateValue(con,"OutgoingCallsReport", _OutgoingCallsReport);
|
||||
updateValue(con,"BytesReceivedReport", _BytesReceivedReport);
|
||||
updateValue(con,"BytesSentReport", _BytesSentReport);
|
||||
updateValue(con,"HelloSignalReport", _HelloSignalReport);
|
||||
updateValue(con,"BatteryLevelReport", _BatteryLevelReport);
|
||||
updateValue(con,"RoamingReport", _RoamingReport);
|
||||
updateValue(con,"InventoryReport", _InventoryReport);
|
||||
updateValue(con,"NotificationCheck", _NotificationCheck);
|
||||
updateValue(con,"mobileWebURL", _mobileWebURL);
|
||||
updateDatabaseValue(con,"serverAddr", _serverAddr);
|
||||
updateDatabaseValue(con,"serverPort", _serverPort);
|
||||
updateDatabaseValue(con,"interval", ""+_interval);
|
||||
updateDatabaseValue(con,"agentName", _agentName);
|
||||
updateDatabaseValue(con,"gpsStatus", _gpsStatus);
|
||||
updateDatabaseValue(con,"memoryStatus", _memoryStatus);
|
||||
updateDatabaseValue(con,"taskStatus", _taskStatus);
|
||||
updateDatabaseValue(con,"task", _task);
|
||||
updateDatabaseValue(con,"taskHumanName", _taskHumanName);
|
||||
updateDatabaseValue(con,"simID", _simID);
|
||||
updateDatabaseValue(con,"simIDReport", _simIDReport);
|
||||
updateDatabaseValue(con,"upTime", ""+_upTime);
|
||||
updateDatabaseValue(con,"networkOperator", _networkOperator);
|
||||
updateDatabaseValue(con,"SMSReceived", ""+_smsReceived);
|
||||
updateDatabaseValue(con,"SMSSent", ""+_smsSent);
|
||||
updateDatabaseValue(con,"networkType", _networkType);
|
||||
updateDatabaseValue(con,"phoneType", _phoneType);
|
||||
updateDatabaseValue(con,"signalStrength", ""+_signalStrength);
|
||||
updateDatabaseValue(con,"incomingCalls", ""+_incomingCalls);
|
||||
updateDatabaseValue(con,"missedCalls", ""+_missedCalls);
|
||||
updateDatabaseValue(con,"outgoingCalls", ""+_outgoingCalls);
|
||||
updateDatabaseValue(con,"receiveBytes", ""+_receiveBytes);
|
||||
updateDatabaseValue(con,"transmitBytes", ""+_transmitBytes);
|
||||
updateDatabaseValue(con,"password", _password);
|
||||
updateDatabaseValue(con,"passwordCheck", _passwordCheck);
|
||||
updateDatabaseValue(con,"helloSignal", ""+_helloSignal);
|
||||
updateDatabaseValue(con,"roaming", ""+_roaming);
|
||||
updateDatabaseValue(con,"DeviceUpTimeReport", _DeviceUpTimeReport);
|
||||
updateDatabaseValue(con,"NetworkOperatorReport", _NetworkOperatorReport);
|
||||
updateDatabaseValue(con,"NetworkTypeReport", _NetworkTypeReport);
|
||||
updateDatabaseValue(con,"PhoneTypeReport", _PhoneTypeReport);
|
||||
updateDatabaseValue(con,"SignalStrengthReport", _SignalStrengthReport);
|
||||
updateDatabaseValue(con,"ReceivedSMSReport", _ReceivedSMSReport);
|
||||
updateDatabaseValue(con,"SentSMSReport", _SentSMSReport);
|
||||
updateDatabaseValue(con,"IncomingCallsReport", _IncomingCallsReport);
|
||||
updateDatabaseValue(con,"MissedCallsReport", _MissedCallsReport);
|
||||
updateDatabaseValue(con,"OutgoingCallsReport", _OutgoingCallsReport);
|
||||
updateDatabaseValue(con,"BytesReceivedReport", _BytesReceivedReport);
|
||||
updateDatabaseValue(con,"BytesSentReport", _BytesSentReport);
|
||||
updateDatabaseValue(con,"HelloSignalReport", _HelloSignalReport);
|
||||
updateDatabaseValue(con,"BatteryLevelReport", _BatteryLevelReport);
|
||||
updateDatabaseValue(con,"RoamingReport", _RoamingReport);
|
||||
updateDatabaseValue(con,"InventoryReport", _InventoryReport);
|
||||
updateDatabaseValue(con,"NotificationCheck", _NotificationCheck);
|
||||
updateDatabaseValue(con,"mobileWebURL", _mobileWebURL);
|
||||
|
||||
|
||||
return true;
|
||||
|
@ -367,89 +543,18 @@ public class Core {
|
|||
|
||||
|
||||
|
||||
/*
|
||||
//Initialize database
|
||||
public static void initDatabase(Context context){
|
||||
if (con == null) {
|
||||
con = context;
|
||||
}
|
||||
db = new DataBaseHandler(con);
|
||||
// //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);
|
||||
//
|
||||
// }
|
||||
|
||||
addValue(con,"serverAddr",defaultServerAddr);
|
||||
addValue(con,"serverPort",defaultServerPort);
|
||||
addValue(con,"interval",""+defaultInterval);
|
||||
addValue(con,"agentName",defaultAgentName+"_"+Installation.id(context));
|
||||
addValue(con,"mobileWebURL",defaultmobileWebURL);
|
||||
addValue(con,"gpsStatus",defaultGpsStatus);
|
||||
addValue(con,"memoryStatus",defaultMemoryStatus);
|
||||
addValue(con,"taskStatus",defaultTaskStatus);
|
||||
addValue(con,"task",defaultTask);
|
||||
addValue(con,"taskHumanName",defaultTaskHumanName);
|
||||
addValue(con,"simIDReport",defaultSimIDReport);
|
||||
addValue(con,"passwordCheck",defaultPasswordCheck);
|
||||
addValue(con,"DeviceUpTimeReport",defaultDeviceUpTimeReport);
|
||||
addValue(con,"NetworkOperatorReport",defaultNetworkOperatorReport);
|
||||
addValue(con,"NetworkTypeReport",defaultNetworkTypeReport);
|
||||
addValue(con,"PhoneTypeReport",defaultPhoneTypeReport);
|
||||
addValue(con,"SignalStrengthReport",defaultSignalStrengthReport);
|
||||
addValue(con,"ReceivedSMSReport",defaultReceivedSMSReport);
|
||||
addValue(con,"SentSMSReport",defaultSentSMSReport);
|
||||
addValue(con,"IncomingCallsReport",defaultIncomingCallsReport);
|
||||
addValue(con,"MissedCallsReport",defaultMissedCallsReport);
|
||||
addValue(con,"OutgoingCallsReport",defaultOutgoingCallsReport);
|
||||
addValue(con,"BytesReceivedReport",defaultBytesReceivedReport);
|
||||
addValue(con,"BytesSentReport",defaultBytesSentReport);
|
||||
addValue(con,"HelloSignalReport",defaultHelloSignalReport);
|
||||
addValue(con,"BatteryLevelReport",defaultHelloSignalReport);
|
||||
addValue(con,"RoamingReport",defaultRoamingReport);
|
||||
addValue(con,"InventoryReport",defaultRoamingReport);
|
||||
addValue(con,"NotificationCheck",defaultNotificationCheck);
|
||||
|
||||
addValue(con,"hasSim", ""+defaultHasSim);
|
||||
|
||||
addValue(con,"password",defaultPassword);
|
||||
|
||||
addValue(con,"latitude",""+CONST_INVALID_COORDS);
|
||||
addValue(con,"longitude",""+CONST_INVALID_COORDS);
|
||||
addValue(con,"batteryLevel",""+CONST_INVALID_BATTERY_LEVEL);
|
||||
addValue(con,"orientation",""+CONST_INVALID_ORIENTATION);
|
||||
addValue(con,"proximity",""+CONST_INVALID_PROXIMITY);
|
||||
addValue(con,"taskRun",defaultTaskRun);
|
||||
addValue(con,"availableRamKb",""+defaultRam);
|
||||
addValue(con,"totalRamKb",""+defaultRam);
|
||||
addValue(con,"simID",defaultSimID);
|
||||
addValue(con,"upTime",""+defaultUpTime);
|
||||
addValue(con,"SMSReceived",""+defaultSMSReceived);
|
||||
addValue(con,"SMSSent",""+defaultSMSSent);
|
||||
addValue(con,"networkOperator",defaultNetworkOperator);
|
||||
addValue(con,"networkType",defaultNetworkType);
|
||||
addValue(con,"phoneType",defaultPhoneType);
|
||||
addValue(con,"signalStrength",""+defaultSignalStrength);
|
||||
addValue(con,"incomingCalls",""+defaultIncomingCalls);
|
||||
addValue(con,"missedCalls",""+defaultMissedCalls);
|
||||
addValue(con,"outgoingCalls",""+defaultOutgoingCalls);
|
||||
addValue(con,"receiveBytes",""+defaultReceiveBytes);
|
||||
addValue(con,"transmitBytes",""+defaultTransmitBytes);
|
||||
addValue(con,"helloSignal",""+defaultHelloSignal);
|
||||
addValue(con,"roaming",""+defaultRoaming);
|
||||
|
||||
addValue(con,"lastContact",""+CONST_INVALID_CONTACT);
|
||||
addValue(con,"contactError",""+CONST_CONTACT_ERROR);
|
||||
|
||||
}
|
||||
|
||||
//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 updateValue(Context context, String name, String 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();
|
||||
|
@ -467,13 +572,10 @@ public class Core {
|
|||
}
|
||||
|
||||
//Returns the value of the given row "name"
|
||||
public static synchronized String getValue(Context context, String name){
|
||||
public static synchronized String getDatabaseValue(Context context, String name){
|
||||
db = new DataBaseHandler(con, "pandroid", null, 1);
|
||||
|
||||
return db.getValue(name).get_value();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,17 +16,16 @@ package pandroid.agent;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
//import android.app.Dialog;
|
||||
import android.app.TabActivity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
import android.widget.TabHost;
|
||||
//import android.app.Dialog;
|
||||
//import android.util.Log;
|
||||
//import android.view.WindowManager.LayoutParams;
|
||||
import android.widget.TabHost;
|
||||
|
||||
public class PandroidAgent extends TabActivity {
|
||||
|
||||
|
@ -34,14 +33,16 @@ public class PandroidAgent extends TabActivity {
|
|||
int defaultInterval = 300;
|
||||
TabHost tabHost;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//database//
|
||||
|
||||
|
||||
Core.loadConfDatabase(this);
|
||||
Core.loadLastValuesDatabase(this);
|
||||
|
||||
|
||||
/*
|
||||
final Dialog dialog = new Dialog(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
|
||||
|
@ -65,10 +66,6 @@ public class PandroidAgent extends TabActivity {
|
|||
//Requires The agent name to use installation id
|
||||
File installation = new File(getApplicationContext().getFilesDir(), "INSTALLATION");
|
||||
if(!installation.exists()){
|
||||
//Create database with default values
|
||||
//DataBaseHandler db = new DataBaseHandler(this,"pandroid", null, 1);
|
||||
|
||||
//Log.d("DATABASE",Core.db.getValue("latitude").get_value());
|
||||
Core.restartAgentListener(getApplicationContext());
|
||||
}
|
||||
else{
|
||||
|
@ -109,11 +106,13 @@ public class PandroidAgent extends TabActivity {
|
|||
public void onPause(){
|
||||
super.onPause();
|
||||
Core.updateConf(getApplicationContext());
|
||||
Core.updateDatabase(this);
|
||||
}
|
||||
|
||||
public void onDestroy(){
|
||||
super.onDestroy();
|
||||
Core.updateConf(getApplicationContext());
|
||||
Core.updateDatabase(this);
|
||||
|
||||
}
|
||||
//Sets hello signal to 1(first connect since pandroid was closed)
|
||||
|
@ -122,7 +121,6 @@ public class PandroidAgent extends TabActivity {
|
|||
|
||||
if(Core.helloSignal == 0)
|
||||
Core.helloSignal = 1;
|
||||
//dubious
|
||||
Core.updateConf(getApplicationContext());
|
||||
}
|
||||
|
||||
|
|
|
@ -123,6 +123,7 @@ public class PandroidAgentListener extends Service {
|
|||
// Keep lastXML sended if is not empty (empty means error sending it)
|
||||
String lastXML = buildXML();
|
||||
|
||||
|
||||
String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||
|
||||
String destFileName = agentName + "." + System.currentTimeMillis() + ".data";
|
||||
|
@ -158,71 +159,72 @@ public class PandroidAgentListener extends Service {
|
|||
}
|
||||
|
||||
|
||||
|
||||
// private void contact(){
|
||||
//
|
||||
// /*
|
||||
// Toast toast = Toast.makeText(getApplicationContext(),
|
||||
//
|
||||
// getString(R.string.loading),
|
||||
// Toast.LENGTH_SHORT);
|
||||
// toast.setGravity(Gravity.BOTTOM,0,0);
|
||||
// toast.show();
|
||||
// */
|
||||
//
|
||||
//
|
||||
// Date date = new Date();
|
||||
//
|
||||
// putSharedData("PANDROID_DATA", "lastContact", Long.toString(date.getTime() / 1000), "long");
|
||||
//
|
||||
// String lastXML = "";
|
||||
// new contactTask().execute(lastXML);
|
||||
// updateValues();
|
||||
//
|
||||
// }//end contact
|
||||
//
|
||||
// private class contactTask extends AsyncTask<String, Void, Void>{
|
||||
//
|
||||
// @Override
|
||||
// protected Void doInBackground(String...params) {
|
||||
//
|
||||
// String lastXML = params[0];
|
||||
// lastXML = buildXML();
|
||||
// String destFileName = "";
|
||||
// String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||
// destFileName = agentName + "." + System.currentTimeMillis() + ".data";
|
||||
//
|
||||
// writeFile(destFileName, lastXML);
|
||||
// String[] tentacleData = {
|
||||
// "-a",
|
||||
// getSharedData("PANDROID_DATA", "serverAddr", "", "string"),
|
||||
// "-p",
|
||||
// Core.defaultServerPort,
|
||||
// "-v",
|
||||
// "/data/data/pandroid.agent/files/" + destFileName
|
||||
// };
|
||||
//
|
||||
// int tentacleRet = new tentacle_client().tentacle_client(tentacleData);
|
||||
//
|
||||
// putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
|
||||
// if(tentacleRet == 0) {
|
||||
// putSharedData("PANDROID_DATA", "contactError", "0", "integer");
|
||||
// // Deleting the file after send it
|
||||
// // move to only delete if sent successfully
|
||||
// File file = new File("/data/data/pandroid.agent/files/" + destFileName);
|
||||
// file.delete();
|
||||
// if (Core.helloSignal >= 1)
|
||||
// Core.helloSignal = 0;
|
||||
// Core.updateConf(getApplicationContext());
|
||||
// }
|
||||
// else{
|
||||
// putSharedData("PANDROID_DATA", "contactError", "1", "integer");
|
||||
// }
|
||||
// return null;
|
||||
//
|
||||
// }//end doInBackground
|
||||
// }
|
||||
|
||||
/*
|
||||
private void contact(){
|
||||
|
||||
/*
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
|
||||
getString(R.string.loading),
|
||||
Toast.LENGTH_SHORT);
|
||||
toast.setGravity(Gravity.BOTTOM,0,0);
|
||||
toast.show();
|
||||
|
||||
|
||||
|
||||
Date date = new Date();
|
||||
|
||||
putSharedData("PANDROID_DATA", "lastContact", Long.toString(date.getTime() / 1000), "long");
|
||||
|
||||
String lastXML = "";
|
||||
new contactTask().execute(lastXML);
|
||||
updateValues();
|
||||
|
||||
}//end contact
|
||||
|
||||
|
||||
private class contactTask extends AsyncTask<String, Void, Void>{
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(String...params) {
|
||||
|
||||
String lastXML = params[0];
|
||||
lastXML = buildXML();
|
||||
String destFileName = "";
|
||||
String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
|
||||
destFileName = agentName + "." + System.currentTimeMillis() + ".data";
|
||||
|
||||
writeFile(destFileName, lastXML);
|
||||
String[] tentacleData = {
|
||||
"-a",
|
||||
getSharedData("PANDROID_DATA", "serverAddr", "", "string"),
|
||||
"-p",
|
||||
Core.defaultServerPort,
|
||||
"-v",
|
||||
"/data/data/pandroid.agent/files/" + destFileName
|
||||
};
|
||||
|
||||
int tentacleRet = new tentacle_client().tentacle_client(tentacleData);
|
||||
|
||||
putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
|
||||
if(tentacleRet == 0) {
|
||||
putSharedData("PANDROID_DATA", "contactError", "0", "integer");
|
||||
// Deleting the file after send it
|
||||
// move to only delete if sent successfully
|
||||
File file = new File("/data/data/pandroid.agent/files/" + destFileName);
|
||||
file.delete();
|
||||
if (Core.helloSignal >= 1)
|
||||
Core.helloSignal = 0;
|
||||
Core.updateConf(getApplicationContext());
|
||||
}
|
||||
else{
|
||||
putSharedData("PANDROID_DATA", "contactError", "1", "integer");
|
||||
}
|
||||
return null;
|
||||
|
||||
}//end doInBackground
|
||||
}
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// From unfinished task of buffering unsent xml files when no connection available //
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -392,6 +394,11 @@ public class PandroidAgentListener extends Service {
|
|||
buffer += buildmoduleXML("helloSignal","Hello Signal", "generic_data", helloSignal);
|
||||
|
||||
|
||||
//UTF-8 TEST//
|
||||
|
||||
String iso_8859_1String = "ÀÁÈÉÌÍÙÚÜàáèéìíòóùúü";
|
||||
|
||||
buffer += buildmoduleXML("iso-8859-1Test","Testing iso-8859-1 Values", "generic_data_string", iso_8859_1String);
|
||||
|
||||
|
||||
// End_Modules
|
||||
|
@ -403,7 +410,7 @@ public class PandroidAgentListener extends Service {
|
|||
}// end buildXML
|
||||
|
||||
private void writeFile(String fileName, String textToWrite) {
|
||||
try { // catches IOException below
|
||||
try { // catches IOException below
|
||||
/*
|
||||
String UTF8 = "utf8";
|
||||
int BUFFER_SIZE = 8192;
|
||||
|
@ -954,14 +961,12 @@ try { // catches IOException below
|
|||
|
||||
|
||||
private void putSharedData(String preferenceName, String tokenName, String data, String type) {
|
||||
//int mode = Activity.MODE_PRIVATE;
|
||||
//SharedPreferences agentPreferences = getSharedPreferences(preferenceName, mode);
|
||||
//SharedPreferences.Editor editor = agentPreferences.edit();
|
||||
int mode = Activity.MODE_PRIVATE;
|
||||
SharedPreferences agentPreferences = getSharedPreferences(preferenceName, mode);
|
||||
SharedPreferences.Editor editor = agentPreferences.edit();
|
||||
|
||||
Core.updateValue(this, tokenName, data);
|
||||
/*
|
||||
|
||||
if(type == "boolean") {
|
||||
Core.updateValue(this, tokenName, data)
|
||||
editor.putBoolean(tokenName, Boolean.parseBoolean(data));
|
||||
}
|
||||
else if(type == "float") {
|
||||
|
@ -978,16 +983,12 @@ try { // catches IOException below
|
|||
}
|
||||
|
||||
editor.commit();
|
||||
*/
|
||||
}
|
||||
|
||||
private String getSharedData(String preferenceName, String tokenName, String defaultValue, String type) {
|
||||
//int mode = Activity.MODE_PRIVATE;
|
||||
//SharedPreferences agentPreferences = getSharedPreferences(preferenceName, mode);
|
||||
int mode = Activity.MODE_PRIVATE;
|
||||
SharedPreferences agentPreferences = getSharedPreferences(preferenceName, mode);
|
||||
|
||||
return Core.getValue(this, tokenName);
|
||||
|
||||
/*
|
||||
if(type == "boolean") {
|
||||
boolean a = agentPreferences.getBoolean(tokenName, Boolean.parseBoolean(defaultValue));
|
||||
return Boolean.valueOf(a).toString();
|
||||
|
@ -1009,7 +1010,6 @@ try { // catches IOException below
|
|||
}
|
||||
|
||||
return "";
|
||||
*/
|
||||
}
|
||||
|
||||
private String getHumanDateTime(long unixtime){
|
||||
|
|
|
@ -146,7 +146,7 @@ public class Setup extends Activity {
|
|||
webButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
getDataFromView();
|
||||
//Core.updateConf(getApplicationContext());
|
||||
Core.updateConf(getApplicationContext());
|
||||
|
||||
String url = Core.mobileWebURL;
|
||||
if (!url.startsWith("https://") && !url.startsWith("http://")){
|
||||
|
@ -433,7 +433,7 @@ public class Setup extends Activity {
|
|||
Core.NotificationCheck = "disabled";
|
||||
|
||||
|
||||
//Core.updateConf(getApplicationContext());
|
||||
Core.updateConf(getApplicationContext());
|
||||
}
|
||||
|
||||
private void loadViews(){
|
||||
|
@ -535,7 +535,7 @@ public class Setup extends Activity {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
Core.passwordCheck = "disabled";
|
||||
//Core.updateConf(getApplicationContext());
|
||||
Core.updateConf(getApplicationContext());
|
||||
dialog.dismiss();
|
||||
createPass();
|
||||
} // end onClick
|
||||
|
@ -551,12 +551,11 @@ public class Setup extends Activity {
|
|||
Core.passwordCheck = "disabled";
|
||||
else
|
||||
Core.passwordCheck = "enabled";
|
||||
//Core.updateConf(getApplicationContext());
|
||||
Core.updateConf(getApplicationContext());
|
||||
dialog.dismiss();
|
||||
} // end onClick
|
||||
});//end clickListener
|
||||
|
||||
Core.updateConf(getApplicationContext());
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
@ -586,7 +585,7 @@ public class Setup extends Activity {
|
|||
if(TextUtils.isEmpty(createpass_password))
|
||||
{
|
||||
Core.password = Core.defaultPassword;
|
||||
//Core.updateConf(getApplicationContext());
|
||||
Core.updateConf(getApplicationContext());
|
||||
InputMethodManager im = (InputMethodManager)getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
|
||||
im.hideSoftInputFromWindow(text.getWindowToken(), 0);
|
||||
dialog.dismiss();
|
||||
|
@ -608,7 +607,7 @@ public class Setup extends Activity {
|
|||
else if(createpass_password.equals(createpass_password2))
|
||||
{
|
||||
Core.password = createpass_password;
|
||||
//Core.updateConf(getApplicationContext());
|
||||
Core.updateConf(getApplicationContext());
|
||||
//Core.restartAgentListener(getApplicationContext());
|
||||
InputMethodManager im = (InputMethodManager)getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
|
||||
im.hideSoftInputFromWindow(text.getWindowToken(), 0);
|
||||
|
@ -639,8 +638,7 @@ public class Setup extends Activity {
|
|||
} // end onClick
|
||||
|
||||
});//end clickListener
|
||||
|
||||
Core.updateConf(getApplicationContext());
|
||||
Core.updateConf(getApplicationContext());
|
||||
dialog.show();
|
||||
|
||||
}// end createPass
|
||||
|
|
Loading…
Reference in New Issue