2012-08-22 Mark Holland <mark@mark-holland.me.uk>

* AndroidManifest.xml: Changed icon drawable to
	ic_launcher

	* res/drawable-hdpi: Added notification icon

	* res/drawable-ldpi: Added notification icon

	* res/drawable-mdpi: Added notification icon

	* res/drawable-xhdpi: Added notification icon

	* res/layout/setup.xml: Added inventory report checkbox,
	notification checkbox and stop/restart listener buttons.

	* res/layout/setupnosim.xml: Added inventory report checkbox,
	notification checkbox and stop/restart listener buttons.

	* res/values/strings.xml: Added strings for notification and
	stop/restart buttons, reflected in all locales

	* src/pandroid/agent/core.java: Added variables for notification
	and inventory report, fixed agentname, mobileurl mixup.

	* src/pandroid/agent/PandroidAgent.java: Removed splash screen, 
	Added check if app launched before and only restarts listener in
	this case. Added onPause and onDestroy methods to ensure no settings
	loss.

	* src/pandroid/agent/PandroidAgentListener.java: Added optional
	notification when pandroid alarm is enabled, removed loading toast,
	added inventory enabled check, added cancel notification method,
	changed xml format to utf-8(untested)

	* src/pandroid/agent/setup.java: Fixed mobile url, if no http:// or 
	https:// then http:// added automatically. Added stop/restart listener
	buttons, added inventory report and notification checkbox

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6902 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
markholland 2012-08-22 02:57:53 +00:00
parent 1a4ec0ee7f
commit e98005a74b
26 changed files with 360 additions and 40 deletions

View File

@ -18,7 +18,7 @@
package="pandroid.agent" package="pandroid.agent"
android:versionCode="2" android:versionCode="2"
android:versionName="1.5"> android:versionName="1.5">
<application android:icon="@drawable/icon" android:label="@string/app_name"> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
<activity <activity
android:name=".PandroidAgent" android:name=".PandroidAgent"
android:label="@string/app_name" android:label="@string/app_name"

View File

@ -1,15 +1,60 @@
2012-08-22 Mark Holland <mark@mark-holland.me.uk>
* AndroidManifest.xml: Changed icon drawable to
ic_launcher
* res/drawable-hdpi: Added notification icon
* res/drawable-ldpi: Added notification icon
* res/drawable-mdpi: Added notification icon
* res/drawable-xhdpi: Added notification icon
* res/layout/setup.xml: Added inventory report checkbox,
notification checkbox and stop/restart listener buttons.
* res/layout/setupnosim.xml: Added inventory report checkbox,
notification checkbox and stop/restart listener buttons.
* res/values/strings.xml: Added strings for notification and
stop/restart buttons, reflected in all locales
* src/pandroid/agent/core.java: Added variables for notification
and inventory report, fixed agentname, mobileurl mixup.
* src/pandroid/agent/PandroidAgent.java: Removed splash screen,
Added check if app launched before and only restarts listener in
this case. Added onPause and onDestroy methods to ensure no settings
loss.
* src/pandroid/agent/PandroidAgentListener.java: Added optional
notification when pandroid alarm is enabled, removed loading toast,
added inventory enabled check, added cancel notification method,
changed xml format to utf-8(untested)
* src/pandroid/agent/setup.java: Fixed mobile url, if no http:// or
https:// then http:// added automatically. Added stop/restart listener
buttons, added inventory report and notification checkbox
2012-08-20 Mark Holland <mark@mark-holland.me.uk>
* Pandroid Agent v3.0.apk: Added apk of pandroid so that
anyone can test it.
2012-08-19 Mark Holland <mark@mark-holland.me.uk> 2012-08-19 Mark Holland <mark@mark-holland.me.uk>
* res/layout/drawable-hdpi: Added help and about icons * res/drawable-hdpi: Added help and about icons
from sdk from sdk
* res/layout/drawable-ldpi: Added new vector images. * res/drawable-ldpi: Added new vector images.
Added help and about icons from sdk. Added help and about icons from sdk.
* res/layout/drawable-mdpi:Added help and about icons * res/drawable-mdpi:Added help and about icons
from sdk. from sdk.
* res/layout/drawable-xhdpi: Added new higher * res/drawable-xhdpi: Added new higher
resolution images. Added help and about icons from sdk resolution images. Added help and about icons from sdk
* res/layout/password_choose.xml: UI tweak * res/layout/password_choose.xml: UI tweak

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -151,6 +151,16 @@
android:textColor="#bbbbbb" android:textColor="#bbbbbb"
android:textSize="14dip" /> android:textSize="14dip" />
<CheckBox
android:id="@+id/checkInventoryReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/InventoryReport"
android:textColor="#bbbbbb"
android:textSize="14dip" />
<CheckBox <CheckBox
android:id="@+id/checkSimIDReport" android:id="@+id/checkSimIDReport"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -278,11 +288,38 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/set_password" /> android:text="@string/set_password" />
<CheckBox
android:id="@+id/checkNotification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/notificationCheck"
android:textColor="#bbbbbb"
android:textSize="14dip" />
<Button <Button
android:id="@+id/update" android:id="@+id/update"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/update" /> android:text="@string/update" />
<Button
android:id="@+id/set_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/set_password" />
<Button
android:id="@+id/stopAgent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/stopAgent" />
<Button
android:id="@+id/restartAgent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/restartAgent" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</LinearLayout> </LinearLayout>

View File

@ -118,13 +118,6 @@
android:textColor="#bbbbbb" android:textColor="#bbbbbb"
android:textSize="14dip" /> android:textSize="14dip" />
<CheckBox
android:id="@+id/checkMemoryReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/memoryReport"
android:textColor="#bbbbbb"
android:textSize="14dip" />
<CheckBox <CheckBox
android:id="@+id/checkTaskReport" android:id="@+id/checkTaskReport"
@ -151,6 +144,24 @@
android:visibility="gone" /> android:visibility="gone" />
</LinearLayout> </LinearLayout>
<CheckBox
android:id="@+id/checkMemoryReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/memoryReport"
android:textColor="#bbbbbb"
android:textSize="14dip" />
<CheckBox
android:id="@+id/checkInventoryReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/InventoryReport"
android:textColor="#bbbbbb"
android:textSize="14dip" />
<CheckBox <CheckBox
android:id="@+id/checkDeviceUpTimeReport" android:id="@+id/checkDeviceUpTimeReport"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -175,17 +186,38 @@
<Button <CheckBox
android:id="@+id/set_password" android:id="@+id/checkNotification"
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/set_password" /> android:text="@string/notificationCheck"
android:textColor="#bbbbbb"
android:textSize="14dip" />
<Button <Button
android:id="@+id/update" android:id="@+id/update"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/update" /> android:text="@string/update" />
<Button
android:id="@+id/set_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/set_password" />
<Button
android:id="@+id/stopAgent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/stopAgent" />
<Button
android:id="@+id/restartAgent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/restartAgent" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</LinearLayout> </LinearLayout>

View File

@ -140,5 +140,12 @@
<string name="BatteryLevelReport">"Bericht Akkustand"</string> <string name="BatteryLevelReport">"Bericht Akkustand"</string>
<string name="RoamingReport">"Melden, wenn Roaming"</string> <string name="RoamingReport">"Melden, wenn Roaming"</string>
<string name="notification_title">Pandroid</string>
<string name="notification_message">Agent ausgeführt wird</string>
<string name="ticker_text">Connecting…</string>
<string name="stopAgent">Stopp Agent</string>
<string name="restartAgent">Starten Agent</string>
<string name="notificationCheck">anzeigen Benachrichtigung, wenn läuft?</string>
</resources> </resources>

View File

@ -147,4 +147,12 @@
<string name="BatteryLevelReport">Report battery level</string> <string name="BatteryLevelReport">Report battery level</string>
<string name="RoamingReport">Report if roaming</string> <string name="RoamingReport">Report if roaming</string>
<string name="notification_title">Pandroid</string>
<string name="notification_message">Agent is running</string>
<string name="ticker_text">Connecting…</string>
<string name="stopAgent">Stop Agent</string>
<string name="restartAgent">Restart Agent</string>
<string name="notificationCheck">Show notification when running?</string>
</resources> </resources>

View File

@ -63,7 +63,7 @@
un señal de saludo para monotrorizar instalaciones de pandroid, un inventario con información de todos los apps instalados. También un señal de saludo para monotrorizar instalaciones de pandroid, un inventario con información de todos los apps instalados. También
datos de moviles, la ID del sim, número de SMS enviados/recibidos, número de llamadas entrantes/perdidas/recibidas, el nombre del operador datos de moviles, la ID del sim, número de SMS enviados/recibidos, número de llamadas entrantes/perdidas/recibidas, el nombre del operador
y el tipo, el tipo de movil, la potencia de señal, el número de bytes enviados/recibidos por la red movil. y el tipo, el tipo de movil, la potencia de señal, el número de bytes enviados/recibidos por la red movil.
El código fuente esta disponible.&lt;p&gt;Puedes informarte de esto y mas en Pandora FMS en &lt;a href=&quot;http://pandorafms.com&quot;&gt;http://pandoraFMS.com&lt;/a&gt;&lt;/p&gt; El código fuente esta disponible.&lt;p&gt;Puedes informarte de esto y mas en Pandora FMS en &lt;a href=&quot;http://pandorafms.org&quot;&gt;http://pandorafms.org&lt;/a&gt;&lt;/p&gt;
</string> </string>
<string name="start">Iniciar</string> <string name="start">Iniciar</string>
<string name="correct_start">Conexion con exito</string> <string name="correct_start">Conexion con exito</string>
@ -147,5 +147,12 @@
<string name="BatteryLevelReport">Reporta nivel de bateria</string> <string name="BatteryLevelReport">Reporta nivel de bateria</string>
<string name="RoamingReport">Reporta si Roaming</string> <string name="RoamingReport">Reporta si Roaming</string>
<string name="notification_title">Pandroid</string>
<string name="notification_message">Agente en ejecución</string>
<string name="ticker_text">Connectando…</string>
<string name="stopAgent">Detener Agente</string>
<string name="restartAgent">Reiniciar Agente</string>
<string name="notificationCheck">Mostrar notificación mientras en ejecución?</string>
</resources> </resources>

View File

@ -141,4 +141,11 @@
<string name="RoamingReport">"Signaler roaming"</string> <string name="RoamingReport">"Signaler roaming"</string>
<string name="notification_title">Pandroid</string>
<string name="notification_message">Agent est exécuté</string>
<string name="ticker_text">Connexion en cours…</string>
<string name="stopAgent">Cesser Agent</string>
<string name="restartAgent">Redémarrez l\'Agent</string>
<string name="notificationCheck">Afficher la notification lors de l\'exécution?</string>
</resources> </resources>

View File

@ -141,4 +141,11 @@
<string name="RoamingReport">"Segnalare se il roaming"</string> <string name="RoamingReport">"Segnalare se il roaming"</string>
<string name="notification_title">Pandroid</string>
<string name="notification_message">Agente è in esecuzione</string>
<string name="ticker_text">Connessione in corso…</string>
<string name="stopAgent">arresto Agente</string>
<string name="restartAgent">Riavviare Agente</string>
<string name="notificationCheck">Mostra notifica durante l\'esecuzione?</string>
</resources> </resources>

View File

@ -138,5 +138,11 @@
<string name="BatteryLevelReport">"バッテリーレベルを報告"</string> <string name="BatteryLevelReport">"バッテリーレベルを報告"</string>
<string name="RoamingReport">"ローミングした場合、レポート"</string> <string name="RoamingReport">"ローミングした場合、レポート"</string>
<string name="notification_title">Pandroid</string>
<string name="notification_message">エージェントが実行されている</string>
<string name="ticker_text">連絡…</string>
<string name="stopAgent">エージェントを停止します</string>
<string name="restartAgent">エージェントを再起動します。</string>
<string name="notificationCheck">実行時に通知を表示しますか?</string>
</resources> </resources>

View File

@ -140,5 +140,12 @@
<string name="BatteryLevelReport">"Relatório de nível da bateria"</string> <string name="BatteryLevelReport">"Relatório de nível da bateria"</string>
<string name="RoamingReport">"Relatar se de roaming"</string> <string name="RoamingReport">"Relatar se de roaming"</string>
<string name="notification_title">Pandroid</string>
<string name="notification_message">Agente está em execução</string>
<string name="ticker_text">Ligar…</string>
<string name="stopAgent">pare de Agente</string>
<string name="restartAgent">reinicie Agente</string>
<string name="notificationCheck">Mostrar notificação quando a correr?</string>
</resources> </resources>

View File

@ -139,5 +139,12 @@
<string name="BatteryLevelReport">"报告电池电量"</string> <string name="BatteryLevelReport">"报告电池电量"</string>
<string name="RoamingReport">"报告如果漫游"</string> <string name="RoamingReport">"报告如果漫游"</string>
<string name="notification_title">Pandroid</string>
<string name="notification_message">代理正在运行</string>
<string name="ticker_text">连…</string>
<string name="stopAgent">停止代理</string>
<string name="restartAgent">重新启动代理</string>
<string name="notificationCheck">运行时显示通知?</string>
</resources> </resources>

View File

@ -147,6 +147,13 @@
<string name="HelloSignalReport">Report Hello Signal</string> <string name="HelloSignalReport">Report Hello Signal</string>
<string name="BatteryLevelReport">Report battery level</string> <string name="BatteryLevelReport">Report battery level</string>
<string name="RoamingReport">Report if roaming</string> <string name="RoamingReport">Report if roaming</string>
<string name="InventoryReport">Report inventory of installed apps</string>
<string name="notification_title">Pandroid</string>
<string name="notification_message">Agent is running</string>
<string name="ticker_text">Connecting…</string>
<string name="stopAgent">Stop Agent</string>
<string name="restartAgent">Restart Agent</string>
<string name="notificationCheck">Show notification when running?</string>
</resources> </resources>

View File

@ -67,7 +67,8 @@ public class Core {
static volatile public String defaultBytesSentReport = "enabled"; // "disabled" or "enabled" static volatile public String defaultBytesSentReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultHelloSignalReport = "enabled"; // "disabled" or "enabled" static volatile public String defaultHelloSignalReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultRoamingReport = "enabled"; // "disabled" or "enabled" static volatile public String defaultRoamingReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultInventoryReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultNotificationCheck = "enabled"; // "disabled" or "enabled"
static volatile public boolean defaultHasSim = false; static volatile public boolean defaultHasSim = false;
// // // //
@ -111,8 +112,8 @@ public class Core {
static volatile public String serverAddr = defaultServerAddr; static volatile public String serverAddr = defaultServerAddr;
static volatile public String serverPort = defaultServerPort; static volatile public String serverPort = defaultServerPort;
static volatile public int interval = defaultInterval; static volatile public int interval = defaultInterval;
static volatile public String agentName = defaultmobileWebURL; static volatile public String agentName = defaultAgentName;
static volatile public String mobileWebURL = defaultAgentName; static volatile public String mobileWebURL = defaultmobileWebURL;
static volatile public String gpsStatus = defaultGpsStatus; static volatile public String gpsStatus = defaultGpsStatus;
static volatile public String memoryStatus = defaultMemoryStatus; static volatile public String memoryStatus = defaultMemoryStatus;
static volatile public String taskStatus = defaultTaskStatus; static volatile public String taskStatus = defaultTaskStatus;
@ -135,6 +136,8 @@ public class Core {
static volatile public String HelloSignalReport = defaultHelloSignalReport; static volatile public String HelloSignalReport = defaultHelloSignalReport;
static volatile public String BatteryLevelReport = defaultHelloSignalReport; static volatile public String BatteryLevelReport = defaultHelloSignalReport;
static volatile public String RoamingReport = defaultRoamingReport; static volatile public String RoamingReport = defaultRoamingReport;
static volatile public String InventoryReport = defaultRoamingReport;
static volatile public String NotificationCheck = defaultNotificationCheck;
static volatile public boolean hasSim = defaultHasSim; static volatile public boolean hasSim = defaultHasSim;
@ -282,7 +285,8 @@ public class Core {
HelloSignalReport = agentPreferences.getString("HelloSignalReport", defaultHelloSignalReport); HelloSignalReport = agentPreferences.getString("HelloSignalReport", defaultHelloSignalReport);
BatteryLevelReport = agentPreferences.getString("BatteryLevelReport", defaultBatteryLevelReport); BatteryLevelReport = agentPreferences.getString("BatteryLevelReport", defaultBatteryLevelReport);
RoamingReport = agentPreferences.getString("RoamingReport", defaultRoamingReport); RoamingReport = agentPreferences.getString("RoamingReport", defaultRoamingReport);
InventoryReport = agentPreferences.getString("InventoryReport", defaultInventoryReport);
NotificationCheck = agentPreferences.getString("NotificationCheck", defaultNotificationCheck);
}// end loadConf }// end loadConf
static public boolean updateConf(Context context) { static public boolean updateConf(Context context) {
@ -293,7 +297,7 @@ public class Core {
passwordCheck, DeviceUpTimeReport, NetworkOperatorReport, NetworkTypeReport, PhoneTypeReport, passwordCheck, DeviceUpTimeReport, NetworkOperatorReport, NetworkTypeReport, PhoneTypeReport,
SignalStrengthReport, ReceivedSMSReport, SentSMSReport, IncomingCallsReport, MissedCallsReport, SignalStrengthReport, ReceivedSMSReport, SentSMSReport, IncomingCallsReport, MissedCallsReport,
OutgoingCallsReport, BytesReceivedReport, BytesSentReport, HelloSignalReport, BatteryLevelReport, OutgoingCallsReport, BytesReceivedReport, BytesSentReport, HelloSignalReport, BatteryLevelReport,
RoamingReport, roaming, mobileWebURL RoamingReport, roaming, mobileWebURL, InventoryReport , NotificationCheck
); );
}// end updateConf }// end updateConf
@ -307,7 +311,8 @@ public class Core {
String _password, int _helloSignal, String _passwordCheck, String _DeviceUpTimeReport, String _NetworkOperatorReport, String _password, int _helloSignal, String _passwordCheck, String _DeviceUpTimeReport, String _NetworkOperatorReport,
String _NetworkTypeReport, String _PhoneTypeReport, String _SignalStrengthReport, String _ReceivedSMSReport, String _NetworkTypeReport, String _PhoneTypeReport, String _SignalStrengthReport, String _ReceivedSMSReport,
String _SentSMSReport, String _IncomingCallsReport, String _MissedCallsReport, String _OutgoingCallsReport, String _BytesReceivedReport, String _SentSMSReport, String _IncomingCallsReport, String _MissedCallsReport, String _OutgoingCallsReport, String _BytesReceivedReport,
String _BytesSentReport, String _HelloSignalReport, String _BatteryLevelReport, String _RoamingReport, int _roaming, String _mobileWebURL) { String _BytesSentReport, String _HelloSignalReport, String _BatteryLevelReport, String _RoamingReport, int _roaming, String _mobileWebURL,
String _InventoryReport, String _NotificationCheck) {
if (con == null) { if (con == null) {
con = context; con = context;
@ -360,6 +365,8 @@ public class Core {
editor.putString("HelloSignalReport", _HelloSignalReport); editor.putString("HelloSignalReport", _HelloSignalReport);
editor.putString("BatteryLevelReport", _BatteryLevelReport); editor.putString("BatteryLevelReport", _BatteryLevelReport);
editor.putString("RoamingReport", _RoamingReport); editor.putString("RoamingReport", _RoamingReport);
editor.putString("InventoryReport", _InventoryReport);
editor.putString("NotificationCheck", _NotificationCheck);
editor.putString("mobileWebURL", _mobileWebURL); editor.putString("mobileWebURL", _mobileWebURL);
if (editor.commit()) { if (editor.commit()) {

View File

@ -14,6 +14,8 @@
package pandroid.agent; package pandroid.agent;
import java.io.File;
import android.app.Dialog; import android.app.Dialog;
import android.app.TabActivity; import android.app.TabActivity;
import android.content.Context; import android.content.Context;
@ -21,6 +23,7 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.WindowManager.LayoutParams; import android.view.WindowManager.LayoutParams;
import android.widget.TabHost; import android.widget.TabHost;
@ -33,7 +36,7 @@ public class PandroidAgent extends TabActivity {
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
/*
final Dialog dialog = new Dialog(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen); final Dialog dialog = new Dialog(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
dialog.setContentView(R.layout.welcome); dialog.setContentView(R.layout.welcome);
dialog.setCancelable(false); dialog.setCancelable(false);
@ -50,8 +53,19 @@ public class PandroidAgent extends TabActivity {
} }
}, 3000); }, 3000);
Core.restartAgentListener(getApplicationContext()); */
//Requires The agent name to use installation id
File installation = new File(getApplicationContext().getFilesDir(), "INSTALLATION");
if(!installation.exists()){
Core.restartAgentListener(getApplicationContext());
}
else{
//Core.stopAgentListener();
Core.loadConf(this);
Core.alarmEnabled = true;
//new Intent(this, EventReceiver.class);
}
//Check whether device has a sim card, phone without a sim card present //Check whether device has a sim card, phone without a sim card present
//return SIM_STATE_ABSENT but tablets only return SIM_STATE_UNKNOWN //return SIM_STATE_ABSENT but tablets only return SIM_STATE_UNKNOWN
@ -63,9 +77,6 @@ public class PandroidAgent extends TabActivity {
Core.hasSim = Boolean.parseBoolean(hasSim); Core.hasSim = Boolean.parseBoolean(hasSim);
//Create layout with 2 tabs //Create layout with 2 tabs
tabHost = getTabHost(); tabHost = getTabHost();
@ -84,6 +95,16 @@ public class PandroidAgent extends TabActivity {
); );
} }
public void onPause(){
super.onPause();
Core.updateConf(getApplicationContext());
}
public void onDestroy(){
super.onDestroy();
Core.updateConf(getApplicationContext());
}
//Sets hello signal to 1(first connect since pandroid was closed) //Sets hello signal to 1(first connect since pandroid was closed)
public void onResume(){ public void onResume(){
super.onResume(); super.onResume();

View File

@ -13,6 +13,7 @@
// GNU General Public License for more details. // GNU General Public License for more details.
package pandroid.agent; package pandroid.agent;
import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
@ -29,6 +30,9 @@ import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo; import android.app.ActivityManager.MemoryInfo;
import android.app.ActivityManager.RunningAppProcessInfo; import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service; import android.app.Service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -55,11 +59,11 @@ import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength; import android.telephony.SignalStrength;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.Log; import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;
public class PandroidAgentListener extends Service { public class PandroidAgentListener extends Service {
private NotificationManager notificationManager;
Handler h = new Handler(); Handler h = new Handler();
String lastGpsContactDateTime = ""; String lastGpsContactDateTime = "";
boolean showLastXML = true; boolean showLastXML = true;
@ -67,6 +71,27 @@ public class PandroidAgentListener extends Service {
@Override @Override
public void onCreate() { public void onCreate() {
try {
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
} catch (Exception e) {
Log.e("notification", e.toString());
}
Log.v("MARK","notif"+Core.NotificationCheck);
if(Core.NotificationCheck == "enabled"){
Notification notification = new Notification(R.drawable.icon, getText(R.string.ticker_text),
System.currentTimeMillis());
Intent notificationIntent = new Intent(this,PandroidAgent.class);
notificationIntent.setAction("android.intent.action.MAIN");
notificationIntent.addCategory("android.intent.category.LAUNCHER");
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, Notification.FLAG_NO_CLEAR);
notification.setLatestEventInfo(this, getText(R.string.notification_title), getText(R.string.notification_message), pendingIntent);
notification.flags |= Notification.FLAG_ONGOING_EVENT;
notificationManager.notify(1, notification);
}
else{
CancelNotification(getApplicationContext(),1);
}
} }
@Override @Override
@ -89,11 +114,15 @@ public class PandroidAgentListener extends Service {
private void contact(){ private void contact(){
/*
Toast toast = Toast.makeText(getApplicationContext(), Toast toast = Toast.makeText(getApplicationContext(),
getString(R.string.loading), getString(R.string.loading),
Toast.LENGTH_SHORT); Toast.LENGTH_SHORT);
toast.setGravity(Gravity.BOTTOM,0,0); toast.setGravity(Gravity.BOTTOM,0,0);
toast.show(); toast.show();
*/
Date date = new Date(); Date date = new Date();
@ -244,6 +273,8 @@ public class PandroidAgentListener extends Service {
String HelloSignalReport = getSharedData("PANDROID_DATA", "HelloSignalReport", Core.defaultHelloSignalReport, "string"); String HelloSignalReport = getSharedData("PANDROID_DATA", "HelloSignalReport", Core.defaultHelloSignalReport, "string");
String BatteryLevelReport = getSharedData("PANDROID_DATA", "BatteryLevelReport", Core.defaultBatteryLevelReport, "string"); String BatteryLevelReport = getSharedData("PANDROID_DATA", "BatteryLevelReport", Core.defaultBatteryLevelReport, "string");
String RoamingReport = getSharedData("PANDROID_DATA", "RoamingReport", Core.defaultRoamingReport, "string"); String RoamingReport = getSharedData("PANDROID_DATA", "RoamingReport", Core.defaultRoamingReport, "string");
String InventoryReport = getSharedData("PANDROID_DATA", "InventoryReport", Core.defaultInventoryReport, "string");
if (BatteryLevelReport.equals("enabled")) if (BatteryLevelReport.equals("enabled"))
buffer += buildmoduleXML("battery_level", "The current Battery level", "generic_data", batteryLevel); buffer += buildmoduleXML("battery_level", "The current Battery level", "generic_data", batteryLevel);
@ -310,7 +341,9 @@ public class PandroidAgentListener extends Service {
if (HelloSignalReport.equals("enabled")) if (HelloSignalReport.equals("enabled"))
buffer += buildmoduleXML("helloSignal","Hello Signal", "generic_data", helloSignal); buffer += buildmoduleXML("helloSignal","Hello Signal", "generic_data", helloSignal);
buffer += buildInventoryXML(); if(InventoryReport.equals("enabled"))
Log.v("MARK",InventoryReport);
buffer += buildInventoryXML();
// End_Modules // End_Modules
@ -321,15 +354,31 @@ public class PandroidAgentListener extends Service {
}// end buildXML }// end buildXML
private void writeFile(String fileName, String textToWrite) { private void writeFile(String fileName, String textToWrite) {
try { // catches IOException below try { // catches IOException below
String filePath = fileName;
String UTF8 = "utf8";
int BUFFER_SIZE = 8192;
FileOutputStream fOut = openFileOutput(fileName, MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut, UTF8);
BufferedWriter bw = new BufferedWriter(osw,BUFFER_SIZE);
// Write the string to the file
bw.write(textToWrite);
//ensure that everything is really written out and close
bw.flush();
bw.close();
/*
FileOutputStream fOut = openFileOutput(fileName, MODE_WORLD_READABLE); FileOutputStream fOut = openFileOutput(fileName, MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut); OutputStreamWriter osw = new OutputStreamWriter(fOut);
// Write the string to the file // Write the string to the file
osw.write(textToWrite); osw.write(textToWrite);
/* ensure that everything is really written out and close */ /* ensure that everything is really written out and close */
osw.flush(); //osw.flush();
osw.close(); //osw.close();
} catch (IOException e) { } catch (IOException e) {
} }
@ -940,6 +989,12 @@ public class PandroidAgentListener extends Service {
return humanDateTime; return humanDateTime;
} }
public static void CancelNotification(Context ctx, int notifyId) {
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager nMgr = (NotificationManager) ctx.getSystemService(ns);
nMgr.cancel(notifyId);
}
/////////////////////////////////////////// ///////////////////////////////////////////

View File

@ -22,6 +22,8 @@ import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo; import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.Dialog; import android.app.Dialog;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
@ -145,12 +147,35 @@ public class Setup extends Activity {
public void onClick(View view) { public void onClick(View view) {
getDataFromView(); getDataFromView();
Core.updateConf(getApplicationContext()); Core.updateConf(getApplicationContext());
Uri uri = Uri.parse(Core.mobileWebURL);
String url = Core.mobileWebURL;
if (!url.startsWith("https://") && !url.startsWith("http://")){
url = "http://" + url;
}
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri); Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent); startActivity(intent);
} }
}); });
Button stopAgent = (Button) findViewById(R.id.stopAgent);
stopAgent.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
Core.stopAgentListener();
CancelNotification(getApplicationContext(),1);
}
});
Button restartAgent = (Button) findViewById(R.id.restartAgent);
restartAgent.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
Core.restartAgentListener(getApplicationContext());
}
});
}// end setButtonEvents }// end setButtonEvents
private void loadInBackgroundProcessInExecution() { private void loadInBackgroundProcessInExecution() {
@ -235,6 +260,13 @@ public class Setup extends Activity {
button = (Button)findViewById(R.id.goToWebButton); button = (Button)findViewById(R.id.goToWebButton);
button.setEnabled(true); button.setEnabled(true);
button = (Button)findViewById(R.id.stopAgent);
button.setEnabled(true);
button = (Button)findViewById(R.id.restartAgent);
button.setEnabled(true);
} }
}// end onPostExecute }// end onPostExecute
@ -257,7 +289,7 @@ public class Setup extends Activity {
Core.agentName = editText.getText().toString(); Core.agentName = editText.getText().toString();
editText = (EditText) findViewById(R.id.mobileWebURLInput); editText = (EditText) findViewById(R.id.mobileWebURLInput);
Core.mobileWebURL = "http://"+editText.getText().toString(); Core.mobileWebURL = editText.getText().toString();
checkBox = (CheckBox) findViewById(R.id.checkGpsReport); checkBox = (CheckBox) findViewById(R.id.checkGpsReport);
if (checkBox.isChecked()) if (checkBox.isChecked())
@ -381,12 +413,26 @@ public class Setup extends Activity {
Core.RoamingReport = "disabled"; Core.RoamingReport = "disabled";
}// end if sim card }// end if sim card
checkBox = (CheckBox) findViewById(R.id.checkInventoryReport);
if (checkBox.isChecked())
Core.InventoryReport = "enabled";
else
Core.InventoryReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkHelloSignalReport); checkBox = (CheckBox) findViewById(R.id.checkHelloSignalReport);
if (checkBox.isChecked()) if (checkBox.isChecked())
Core.HelloSignalReport = "enabled"; Core.HelloSignalReport = "enabled";
else else
Core.HelloSignalReport = "disabled"; Core.HelloSignalReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkNotification);
if (checkBox.isChecked())
Core.NotificationCheck = "enabled";
else
Core.NotificationCheck = "disabled";
Core.updateConf(getApplicationContext()); Core.updateConf(getApplicationContext());
} }
@ -467,9 +513,15 @@ public class Setup extends Activity {
checkBox.setChecked(Core.RoamingReport.equals("enabled")); checkBox.setChecked(Core.RoamingReport.equals("enabled"));
}//end if sim card }//end if sim card
checkBox = (CheckBox) findViewById(R.id.checkInventoryReport);
checkBox.setChecked(Core.InventoryReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkHelloSignalReport); checkBox = (CheckBox) findViewById(R.id.checkHelloSignalReport);
checkBox.setChecked(Core.HelloSignalReport.equals("enabled")); checkBox.setChecked(Core.HelloSignalReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkNotification);
checkBox.setChecked(Core.NotificationCheck.equals("enabled"));
} }
public void passwordChoose() { public void passwordChoose() {
@ -679,4 +731,12 @@ public class Setup extends Activity {
ParentActivity = (PandroidAgent) this.getParent(); ParentActivity = (PandroidAgent) this.getParent();
ParentActivity.switchTab(indexTabToSwitchTo); ParentActivity.switchTab(indexTabToSwitchTo);
} }
public static void CancelNotification(Context ctx, int notifyId) {
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager nMgr = (NotificationManager) ctx.getSystemService(ns);
nMgr.cancel(notifyId);
}
} }