2012-07-09 Mark Holland <mark@mark-holland.me.uk>

* AndroidManifest.xml: Added Pandora FMS 
	comment to header.

	* res/layout/About.xml: Swapped hardcoded
	text for strings.

	* res/layout/help.xml: Added scrollview.

	* res/layout/password_choose.xml: View for dialog
	when choosing whether to have a password.

	* res/layout/password_create.xml: Added textviews
	with instructions.

	* res/layout/password_entry.xml: Swapped hardcoded
	text for strings.

	* res/layout/setup.xml: Added checkboxes for all
	modules.

	* res/layout/setupnosim.xml: View that only
	shows checkboxes for modules that don't need a sim
	card present.

	* res/values/strings.xml: Updated help string
	(english only). Lots of new strings, also
	added to strings-en and strings-es.

	* src/pandroid/agent/About.java: Added Pandora FMS 
	comment to header.

	* src/pandroid/agent/core.java: Added Pandora FMS 
	comment to header. Added variable for hello signal.
	Added reporting variables for all modules. Changed 
	alarm to be accessed in a static way. changed agent
	identifier from pandroid plus simID to pandroid plus
	install uid.

	* src/pandroid/agent/Help.java:	Added Pandora FMS 
	comment to header.

	* src/pandroid/agent/Installation.java: Calculates a
	unique installation uid.

	* src/pandroid/agent/PandroidAgent.java: hasSim now 
	works whether phone without sim and also tablet without
	capability for sim card. On resume sets hello signal to 1.

	* src/pandroid/agent/PandroidAgentListener.java: Removed
	unnecessary variables, all defaults come from Core.java.
	Ensure Hello signal changed to 0 after every connection.
	Variables for all module reporting, data only added to xml
	if enabled in setup.

	* src/pandroid/agent/setup.java: Added Pandora FMS 
	comment to header. Different views loaded depending
	on whether sim card is present. Added button for changing
	password. Added checkboxes for all modules. Added dialog
	for choosing whether to set a password. Added minimum
	password length and empty to remove password. Keyboard 
	dismissed upon completing dialogs.

	* src/pandroid/agent/SMSBroadcastReceiver.java: Added 
	Pandora FMS comment to header.

	* src/pandroid/agent/status.java: Added Pandora FMS 
	comment to header. Remove incorrect toast message
	when pressing start button.

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6755 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
markholland 2012-07-09 08:35:48 +00:00
parent 7cfb56e809
commit 5eb4d7f6c6
26 changed files with 1494 additions and 340 deletions

View File

@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pandroid.agent"
android:versionCode="2"

View File

@ -1,14 +1,129 @@
2012-07-09 Mark Holland <mark@mark-holland.me.uk>
* AndroidManifest.xml: Added Pandora FMS
comment to header.
* res/layout/About.xml: Swapped hardcoded
text for strings.
* res/layout/help.xml: Added scrollview.
* res/layout/password_choose.xml: View for dialog
when choosing whether to have a password.
* res/layout/password_create.xml: Added textviews
with instructions.
* res/layout/password_entry.xml: Swapped hardcoded
text for strings.
* res/layout/setup.xml: Added checkboxes for all
modules.
* res/layout/setupnosim.xml: View that only
shows checkboxes for modules that don't need a sim
card present.
* res/values/strings.xml: Updated help string
(english only). Lots of new strings, also
added to strings-en and strings-es.
* src/pandroid/agent/About.java: Added Pandora FMS
comment to header.
* src/pandroid/agent/core.java: Added Pandora FMS
comment to header. Added variable for hello signal.
Added reporting variables for all modules. Changed
alarm to be accessed in a static way. changed agent
identifier from pandroid plus simID to pandroid plus
install uid.
* src/pandroid/agent/Help.java: Added Pandora FMS
comment to header.
* src/pandroid/agent/Installation.java: Calculates a
unique installation uid.
* src/pandroid/agent/PandroidAgent.java: hasSim now
works whether phone without sim and also tablet without
capability for sim card. On resume sets hello signal to 1.
* src/pandroid/agent/PandroidAgentListener.java: Removed
unnecessary variables, all defaults come from Core.java.
Ensure Hello signal changed to 0 after every connection.
Variables for all module reporting, data only added to xml
if enabled in setup.
* src/pandroid/agent/setup.java: Added Pandora FMS
comment to header. Different views loaded depending
on whether sim card is present. Added button for changing
password. Added checkboxes for all modules. Added dialog
for choosing whether to set a password. Added minimum
password length and empty to remove password. Keyboard
dismissed upon completing dialogs.
* src/pandroid/agent/SMSBroadcastReceiver.java: Added
Pandora FMS comment to header.
* src/pandroid/agent/status.java: Added Pandora FMS
comment to header. Remove incorrect toast message
when pressing start button.
2012-07-04 Mark Holland <mark@mark-holland.me.uk>
* AndroidManifest.xml: Added permissions read_contacts
and read_sms
* res/layout/password_create.xml: Created view for
password creation dialogue
* res/layout/password_entry.xml: Created view for
password entry dialogue
* res/layout/status.xml: Converted most of data
into a table layout
* res/layout/statusnosim.xml: Created status view
only showing the data avaliable when device has
no sim card
* res/values/strings.xml: Added strings for bytes
sent/received and password dialogues
* src/pandroid/agent/core.java: added variables for
bytes sent/received, hasSim and password. Changed
signal strength to integer.
* src/pandroid/agent/PAndroidAgent.java: Added check
if sim card present. Method for switching tabs from
activities.
* src/pandroid/agent/PandroidAgentListener.java: Added
variables for bytes sent/received. Now if no sim card
present SimID, NetworkOperator, SMSSent, NetworkType,
PhoneType, SignalStrength, Calls, DataBytes modules aren't used or sent.
* src/pandroid/agent/setup.java: Added methods for
creating password and entering password when switching
to setup tab(not completed). Added checkbox for simId
and task reporting
* src/pandroid/agent/status.java: Checks if sim present
and displays view accordingly.
2012-06-26 Mark Holland <mark@mark-holland.me.uk>
* res/values/strings.xml: Added strings for
smsReceived, networkType, phoneType and calls.
Replicated in values-en and values-es.
* res/layout/setup.xml: Added checkboxes for simID
and task reporting.
* res/layout/status.xml: Added textviews for new data.
* res/values/strings.xml: Added strings for
smsReceived, networkType, phoneType and calls.
Replicated in values-en and values-es.
* src/pandroid/agent/core.java: set simID
reporting as disabled by default. Added variables
for networkOperator, networkType, phoneType,

View File

@ -1,11 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-8

View File

@ -25,15 +25,16 @@
android:layout_weight="0"
android:id="@+id/img_logo_about"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:padding="5px"
android:padding="5dp"
android:contentDescription="@string/about_desc"
android:src="@drawable/pandorafms_logo"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Copyright (c) 2011 Artica"
android:text="@string/pandroid_agent_copyright"
/>
<TextView
android:layout_width="wrap_content"

View File

@ -22,9 +22,17 @@
android:padding="10dip"
android:background="#000000"
>
<TextView
android:id="@+id/help_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/help_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</ScrollView>
</LinearLayout>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/yes_button"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="88dp"
android:text="@string/yes" />
<Button
android:id="@+id/no_button"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/yes_button"
android:layout_centerHorizontal="true"
android:layout_marginTop="26dp"
android:text="@string/no" />
<CheckBox
android:id="@+id/password_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/no_button"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:text="@string/password_checkbox" />
</RelativeLayout>
</LinearLayout>

View File

@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -31,15 +31,15 @@
<requestFocus />
</EditText>
<Button
android:id="@+id/password_create_button"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/password_create_field"
android:layout_centerHorizontal="true"
android:layout_marginTop="92dp"
android:text="Enter" />
android:text="@string/enter" />
<EditText
android:id="@+id/password_create_field_2"
@ -50,5 +50,22 @@
android:layout_marginTop="16dp"
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="@+id/password_create_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="5dp"
android:text="@string/password_set" />
<TextView
android:id="@+id/password_repeat_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/password_create_textView"
android:layout_below="@+id/password_create_field"
android:text="@string/password_repeat" />
</RelativeLayout>

View File

@ -1,17 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
@ -39,7 +40,7 @@
android:layout_below="@+id/password_entry_input"
android:layout_marginRight="38dp"
android:layout_marginTop="24dp"
android:text="Back" />
android:text="@string/back" />
<Button
android:id="@+id/password_entry_button"
@ -49,6 +50,6 @@
android:layout_alignBottom="@+id/password_back_button"
android:layout_alignLeft="@+id/password_entry_input"
android:layout_marginLeft="24dp"
android:text="Enter" />
android:text="@string/enter" />
</RelativeLayout>

View File

@ -79,6 +79,7 @@
android:layout_height="wrap_content"
android:singleLine="true"
/>
<CheckBox
android:id="@+id/checkGpsReport"
android:layout_width="wrap_content"
@ -87,6 +88,24 @@
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkBatteryLevelReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/BatteryLevelReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkTaskReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/taskReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkMemoryReport"
android:layout_width="wrap_content"
@ -103,15 +122,125 @@
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkTaskReport"
android:id="@+id/checkDeviceUpTimeReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/taskReport"
android:text="@string/uptimeReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
android:enabled="false"
/>
<CheckBox
android:id="@+id/checkNetworkOperatorReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/NetworkOperatorReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkNetworkTypeReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/NetworkTypeReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkPhoneTypeReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/PhoneTypeReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkSignalStrengthReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/SignalStrengthReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkReceivedSMSReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ReceivedSMSReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkSentSMSReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/SentSMSReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkIncomingCallsReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/IncomingCallsReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkMissedCallsReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/MissedCallsReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkOutgoingCallsReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/OutgoingCallsReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkBytesReceivedReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/BytesReceivedReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkBytesSentReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/BytesSentReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkHelloSignalReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/HelloSignalReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<TextView
android:id="@+id/field5"
android:layout_width="fill_parent"
@ -135,6 +264,12 @@
android:visibility="gone"
/>
</LinearLayout>
<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/update"
android:layout_width="fill_parent"
@ -143,6 +278,7 @@
/>
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -0,0 +1,177 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/field1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/serverAddr"
android:paddingTop="5dp"
/>
<EditText
android:id="@+id/serverAddrInput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
/>
<TextView
android:id="@+id/field2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/serverPort"
/>
<EditText
android:id="@+id/serverPortInput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:inputType="number"
/>
<TextView
android:id="@+id/field3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/interval"
/>
<EditText
android:id="@+id/intervalInput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:inputType="number"
/>
<TextView
android:id="@+id/field4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/agent"
/>
<EditText
android:id="@+id/agentNameInput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
/>
<CheckBox
android:id="@+id/checkGpsReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/gpsReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkBatteryLevelReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/BatteryLevelReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkMemoryReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/memoryReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkTaskReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/taskReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkDeviceUpTimeReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/uptimeReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<CheckBox
android:id="@+id/checkHelloSignalReport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/HelloSignalReport"
android:textSize="14dip"
android:textColor="#bbbbbb"
/>
<TextView
android:id="@+id/field5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/task"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ProgressBar
android:id="@+id/loading_task_anim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Spinner
android:id="@+id/processes_combo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
/>
</LinearLayout>
<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/update"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/update"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<resources>
<string name="const_string_preferences">PANDROID_DATA</string>
@ -46,7 +61,11 @@
<string name="last_contact_str">Last Contact:\n</string>
<string name="help_text_str">
Pandroid Agent is an Android Pandora FMS agent for Pandora FMS. &lt;p&gt;
Pandora FMS is a general purpose monitoring system. With android agent you can get GPS information of your device, know how much battery left, memory on device. This could be expanded in the future to report if a given process is running, very useful to use the agent on embedded devices on tablets to report to a central server. Also can be expanded to get information given by the user for other app and stored in the device or doing a lot of things more. Complete source code is provided.&lt;p&gt;See more about Pandora FMS at &lt;a href=&quot;http://pandorafms.org&quot;&gt;http://pandorafms.org&lt;/a&gt;&lt;/p&gt;
Pandora FMS is a general purpose monitoring system. With the android agent you can get all sorts of information from your device,
the gps location, how much battery is left, available memory on the device, monitoring if a process is acvtive, the time since the device was turned on, a HELLO signal for monitoring installations of the app
aswell as information for android phones with a sim card; the sim card ID, the number of SMS sent/received, the number of calls
incoming/missed/outgoing, the network operator and type, the phone type, the mobile signal strength, the number of bytes sent/received
over the mobile network. Complete source code is provided.&lt;p&gt;See more about Pandora FMS at &lt;a href=&quot;http://pandorafms.org&quot;&gt;http://pandorafms.org&lt;/a&gt;&lt;/p&gt;
</string>
<string name="start">Start</string>
<string name="correct_start">Connection successful</string>
@ -79,5 +98,11 @@
<string name="receive_bytes_value"/>
<string name="transmit_bytes">Bytes transmitted:</string>
<string name="transmit_bytes_value"/>
<string name="alert_dialog_password">Enter password</string>
<string name="password_no_match">Passwords do not match!</string>
<string name="password_error">error</string>
<string name="password">password</string>
<string name="password_length">password must be longer than 6 characters!</string>
<string name="password_incorrect">Wrong password!</string>
</resources>

View File

@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<resources>
<string name="const_string_preferences">PANDROID_DATA</string>
@ -79,6 +94,39 @@
<string name="receive_bytes_value"/>
<string name="transmit_bytes">Bytes transmitidos:</string>
<string name="transmit_bytes_value"/>
<string name="alert_dialog_password">Introducir contrasenya</string>
<string name="password_no_match">Las contrasenyas son diferentes!</string>
<string name="password_error">error</string>
<string name="password">contrasenya</string>
<string name="password_length">La contrasenya debe contener mas de 6 caracteres!</string>
<string name="password_incorrect">Contrasenya incorrecta</string>
<string name="password_set">Crear contrasenya</string>
<string name="password_enter">Introducir contrasenya</string>
<string name="password_repeat">Repetir contrasenya</string>
<string name="password_choose_text">Quieres poner una contrasenya?</string>
<string name="password_checkbox">No vuelkves a preguntar</string>
<string name="password_created">Contrasenya creada</string>
<string name="password_removed">Sin contrasenya</string>
<string name="set_password">Crear/Cambiar contrasenya</string>
<string name="enter">Intro</string>
<string name="back">Volver</string>
<string name="yes">si</string>
<string name="no">no</string>
<string name="BatteryLevelReport">Reporta nivel de bateria</string>
<string name="uptimeReport">Reporta tiempo encendido</string>
<string name="NetworkOperatorReport">Reporta operador de red</string>
<string name="NetworkTypeReport">Reporta tipo de red</string>
<string name="PhoneTypeReport">Reporta tipo de movil</string>
<string name="SignalStrengthReport">Reporta potencia de senyal</string>
<string name="ReceivedSMSReport">Reporta numero de SMS recibido</string>
<string name="SentSMSReport">Reporta numero de SMS enviado</string>
<string name="IncomingCallsReport">Reporta numero de llamadas recibidas</string>
<string name="MissedCallsReport">Reporta numero de llamadas perdidas</string>
<string name="OutgoingCallsReport">Reporta numero de llamadas salientes</string>
<string name="BytesReceivedReport">Reporta bytes recibidos</string>
<string name="BytesSentReport">Reporta bytes enviados</string>
<string name="HelloSignalReport">Reporta senyal de saludo</string>
</resources>

View File

@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<resources>
<string name="const_string_preferences">PANDROID_DATA</string>

View File

@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<resources>
<string name="const_string_preferences">PANDROID_DATA</string>
@ -37,6 +52,8 @@
<string name="licensed_under_gpl_str">Licensed under GPL v2</string>
<string name="develop_team_str">Developer: Sergio M. Zarzuelo, Miguel de Dios</string>
<string name="pandroid_agent_str">Pandroid Agent</string>
<string name="pandroid_agent_copyright">Copyright (c) 2011 Artica</string>
<string name="about_desc">Pandroid Agent logo</string>
<string name="help_str">Help</string>
<string name="memory_avaliable_str" formatted="false">Avaliable: &#37;iKb Total: &#37;iKb</string>
<string name="never_str">Never.</string>
@ -46,10 +63,15 @@
<string name="last_contact_str">Last Contact:\n</string>
<string name="help_text_str">
Pandroid Agent is an Android Pandora FMS agent for Pandora FMS. &lt;p&gt;
Pandora FMS is a general purpose monitoring system. With android agent you can get GPS information of your device, know how much battery left, memory on device. This could be expanded in the future to report if a given process is running, very useful to use the agent on embedded devices on tablets to report to a central server. Also can be expanded to get information given by the user for other app and stored in the device or doing a lot of things more. Complete source code is provided.&lt;p&gt;See more about Pandora FMS at &lt;a href=&quot;http://pandorafms.org&quot;&gt;http://pandorafms.org&lt;/a&gt;&lt;/p&gt;
Pandora FMS is a general purpose monitoring system. With the android agent you can get all sorts of information from your device,
the gps location, how much battery is left, available memory on the device, monitoring if a process is acvtive, the time since the device was turned on, a HELLO signal for monitoring installations of the app
aswell as information for android phones with a sim card; the sim card ID, the number of SMS sent/received, the number of calls
incoming/missed/outgoing, the network operator and type, the phone type, the mobile signal strength, the number of bytes sent/received
over the mobile network. Complete source code is provided.&lt;p&gt;See more about Pandora FMS at &lt;a href=&quot;http://pandorafms.org&quot;&gt;http://pandorafms.org&lt;/a&gt;&lt;/p&gt;
</string>
<string name="start">Start</string>
<string name="correct_start">Connection successful</string>
<string name="config_saved">Configuration saved successfully</string>
<string name="contact_stopped_str">Agent Stopped</string>
<string name="sim_id">Sim ID:</string>
<string name="sim_id_value"/>
@ -73,7 +95,7 @@
<string name="incoming_calls_value"/>
<string name="missed_calls">Missed calls:</string>
<string name="missed_calls_value"/>
<string name="outgoing_calls">outgoing calls:</string>
<string name="outgoing_calls">Outgoing calls:</string>
<string name="outgoing_calls_value"/>
<string name="receive_bytes">Bytes received:</string>
<string name="receive_bytes_value"/>
@ -84,5 +106,35 @@
<string name="password_error">error</string>
<string name="password">password</string>
<string name="password_length">password must be longer than 6 characters!</string>
<string name="password_incorrect">Wrong password</string>
<string name="password_set">Set Password(leave blank for none)</string>
<string name="password_enter">Enter Password</string>
<string name="password_repeat">Repeat Password</string>
<string name="password_choose_text">Do you want to set a password?</string>
<string name="password_checkbox">Dont ask again</string>
<string name="password_created">Password sucessfully created</string>
<string name="password_removed">No password set</string>
<string name="set_password">Create/Change password</string>
<string name="enter">enter</string>
<string name="back">back</string>
<string name="yes">yes</string>
<string name="no">no</string>
<string name="uptimeReport">Report device up time</string>
<string name="NetworkOperatorReport">Report network operator</string>
<string name="NetworkTypeReport">Report network type</string>
<string name="PhoneTypeReport">Report phone type</string>
<string name="SignalStrengthReport">Report signal strength</string>
<string name="ReceivedSMSReport">Report number of received SMS</string>
<string name="SentSMSReport">Report number of sent SMS</string>
<string name="IncomingCallsReport">Report number of incoming calls</string>
<string name="MissedCallsReport">Report number of missed calls</string>
<string name="OutgoingCallsReport">Report number of outgoing calls</string>
<string name="BytesReceivedReport">Report amount of received mobile data</string>
<string name="BytesSentReport">Report amount of sent mobile data</string>
<string name="HelloSignalReport">Report Hello Signal</string>
<string name="BatteryLevelReport">Report battery level</string>
</resources>

View File

@ -1,3 +1,17 @@
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
package pandroid.agent;
import android.app.Activity;

View File

@ -1,3 +1,17 @@
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
package pandroid.agent;
import android.app.Activity;
@ -7,10 +21,14 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
//import android.util.Log;
public class Core {
// //
// CONSTANTS //
// //
//The 181 is the first invalid value between 180 and -180 values.
static final float CONST_INVALID_COORDS = 181;
static final int CONST_INVALID_BATTERY_LEVEL = -1;
@ -20,25 +38,48 @@ public class Core {
static final long CONST_INVALID_CONTACT = -1;
static final int CONST_CONTACT_ERROR = 0;
static volatile public String defaultServerAddr = "192.168.2.20"; //master address
// //
// DEFAULT CONFIGURATION MODULES //
// //
static volatile public String defaultServerAddr = "firefly.artica.es"; //master address
static volatile public String defaultServerPort = "41121";
static volatile public int defaultInterval = 300;
static volatile public String defaultAgentName = "pandroid";
static volatile public String defaultGpsStatus = "disabled"; // "disabled" or "enabled"
static volatile public String defaultMemoryStatus = "disabled"; // "disabled" or "enabled"
static volatile public String defaultGpsStatus = "enabled"; // "disabled" or "enabled"
static volatile public String defaultBatteryLevelReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultMemoryStatus = "enabled"; // "disabled" or "enabled"
static volatile public String defaultTaskStatus = "disabled"; // "disabled" or "enabled"
static volatile public String defaultSimIDReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultPasswordCheck = "enabled"; // "disabled" or "enabled"
static volatile public String defaultDeviceUpTimeReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultNetworkOperatorReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultNetworkTypeReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultPhoneTypeReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultSignalStrengthReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultReceivedSMSReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultSentSMSReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultIncomingCallsReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultMissedCallsReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultOutgoingCallsReport = "enabled"; // "disabled" or "enabled"
static volatile public String defaultBytesReceivedReport = "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 boolean defaultHasSim = false;
// //
// DEFAULT MODULE VALUES //
// //
static volatile public String defaultTask = "";
static volatile public String defaultTaskHumanName = "";
static volatile public String defaultTaskRun = "false";
static volatile public long defaultRam = 0;
static volatile public long defaultContact = 0;
static volatile public int defaultContactError = 0;
static volatile public String defaultSimID = "";
static volatile public String defaultSimIDStatus = "disabled"; // "disabled" or "enabled"
static volatile public long defaultUpTime = 0;
static volatile public long defaultReceiveBytes = 0;
static volatile public long defaultTransmitBytes = 0;
static volatile public String defaultSimID = "";
static volatile public int defaultSMSReceived = 0;
static volatile public int defaultSMSSent = 0;
static volatile public String defaultNetworkOperator = "";
@ -48,13 +89,24 @@ public class Core {
static volatile public int defaultIncomingCalls = 0;
static volatile public int defaultMissedCalls = 0;
static volatile public int defaultOutgoingCalls = 0;
static volatile public String defaultPassword = "password";
static volatile public long defaultReceiveBytes = 0;
static volatile public long defaultTransmitBytes = 0;
static volatile public int defaultHelloSignal = 2;
//Temporary
static volatile public String defaultPassword = "";
static volatile public Context con = null;
static volatile public AlarmManager am = null;
static volatile public PendingIntent sender = null;
static volatile public boolean alarmEnabled = false;
// //
// CONFIGURATION VALUES //
// //
static volatile public String serverAddr = defaultServerAddr;
static volatile public String serverPort = defaultServerPort;
static volatile public int interval = defaultInterval;
@ -64,8 +116,40 @@ public class Core {
static volatile public String taskStatus = defaultTaskStatus;
static volatile public String task = defaultTask;
static volatile public String taskHumanName = defaultTaskHumanName;
static volatile public String simID = "";
static volatile public String simIDStatus = defaultSimIDStatus;
static volatile public String simIDReport = defaultSimIDReport;
static volatile public String passwordCheck = defaultPasswordCheck;
static volatile public String DeviceUpTimeReport = defaultDeviceUpTimeReport;
static volatile public String NetworkOperatorReport = defaultNetworkOperatorReport;
static volatile public String NetworkTypeReport = defaultNetworkTypeReport;
static volatile public String PhoneTypeReport = defaultPhoneTypeReport;
static volatile public String SignalStrengthReport = defaultSignalStrengthReport;
static volatile public String ReceivedSMSReport = defaultReceivedSMSReport;
static volatile public String SentSMSReport = defaultSentSMSReport;
static volatile public String IncomingCallsReport = defaultIncomingCallsReport;
static volatile public String MissedCallsReport = defaultMissedCallsReport;
static volatile public String OutgoingCallsReport = defaultOutgoingCallsReport;
static volatile public String BytesReceivedReport = defaultBytesReceivedReport;
static volatile public String BytesSentReport = defaultBytesSentReport;
static volatile public String HelloSignalReport = defaultHelloSignalReport;
static volatile public String BatteryLevelReport = defaultHelloSignalReport;
static volatile public boolean hasSim = defaultHasSim;
//temporary
static volatile public String password = defaultPassword;
// //
// MODULES VALUES //
// //
static volatile public float latitude = CONST_INVALID_COORDS;
static volatile public float longitude = CONST_INVALID_COORDS;
static volatile public int batteryLevel = CONST_INVALID_BATTERY_LEVEL;
static volatile public float orientation = CONST_INVALID_ORIENTATION;
static volatile public float proximity = CONST_INVALID_PROXIMITY;
static volatile public String taskRun = defaultTaskRun;
static volatile public long availableRamKb = defaultRam;
static volatile public long totalRamKb = defaultRam;
static volatile public String simID = defaultSimID;
static volatile public long upTime = defaultUpTime;
static volatile public int SMSReceived = defaultSMSReceived;
static volatile public int SMSSent = defaultSMSSent;
@ -78,25 +162,16 @@ public class Core {
static volatile public int outgoingCalls = defaultOutgoingCalls;
static volatile public long receiveBytes = defaultReceiveBytes;
static volatile public long transmitBytes = defaultTransmitBytes;
static volatile public boolean hasSim = false;
static volatile public String password = defaultPassword;
static volatile public float latitude = CONST_INVALID_COORDS;
static volatile public float longitude = CONST_INVALID_COORDS;
static volatile public int batteryLevel = CONST_INVALID_BATTERY_LEVEL;
static volatile public float orientation = CONST_INVALID_ORIENTATION;
static volatile public float proximity = CONST_INVALID_PROXIMITY;
static volatile public String taskRun = defaultTaskRun;
static volatile public long availableRamKb = defaultRam;
static volatile public long totalRamKb = defaultRam;
static volatile public int helloSignal = defaultHelloSignal;
static volatile public long lastContact = CONST_INVALID_CONTACT;
static volatile public int contactError = CONST_CONTACT_ERROR;
//log
public static final String LOG_TAG = "mark";
public Core() {
}
static public void startAgentListener(Context context) {
@ -108,15 +183,17 @@ public class Core {
Intent intentReceiver = new Intent(con, EventReceiver.class);
sender = PendingIntent.getBroadcast(con, 0, intentReceiver, 0);
am = (AlarmManager)con.getSystemService(con.ALARM_SERVICE);
am = (AlarmManager)con.getSystemService(Context.ALARM_SERVICE);
alarmEnabled = true;
am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), (interval * 1000), sender);
}
}// end startAgentListener
static public void stopAgentListener() {
if (am != null) {
if (am != null){
am.cancel(sender);
alarmEnabled = false;
}
@ -143,31 +220,33 @@ public class Core {
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", Core.defaultTaskStatus);
task = agentPreferences.getString("task", Core.defaultTask);
taskHumanName = agentPreferences.getString("taskHumanName", Core.defaultTaskHumanName);
taskRun = agentPreferences.getString("taskRun", Core.defaultTaskRun);
memoryStatus = agentPreferences.getString("memoryStatus", Core.defaultMemoryStatus);
availableRamKb = agentPreferences.getLong("availableRamKb", Core.defaultRam);
totalRamKb = agentPreferences.getLong("totalRamKb", Core.defaultRam);
lastContact = agentPreferences.getLong("lastContact", Core.defaultContact);
contactError = agentPreferences.getInt("contactError", Core.defaultContactError);
simID = agentPreferences.getString("simID", Core.defaultSimID);
simIDStatus = agentPreferences.getString("simIDStatus", Core.defaultSimIDStatus);
upTime = agentPreferences.getLong("upTime", Core.defaultUpTime);
SMSReceived = agentPreferences.getInt("SMSReceived", Core.defaultSMSReceived);
SMSSent = agentPreferences.getInt("SMSSent", Core.defaultSMSSent);
networkOperator = agentPreferences.getString("networkOperator", Core.defaultNetworkOperator);
networkType = agentPreferences.getString("networkType", Core.defaultNetworkType);
phoneType = agentPreferences.getString("phoneType", Core.defaultPhoneType);
signalStrength = agentPreferences.getInt("signalStrength", Core.defaultSignalStrength);
incomingCalls = agentPreferences.getInt("incomingCalls", Core.defaultIncomingCalls);
missedCalls = agentPreferences.getInt("missedCalls", Core.defaultMissedCalls);
outgoingCalls = agentPreferences.getInt("outgoingCalls", Core.defaultOutgoingCalls);
receiveBytes = agentPreferences.getLong("receiveBytes", Core.defaultReceiveBytes);
transmitBytes = agentPreferences.getLong("transmitBytes", Core.defaultTransmitBytes);
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);
}// end loadLastValues
static public void loadConf(Context context) {
if (con == null) {
@ -178,34 +257,60 @@ public class Core {
con.getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
serverAddr = agentPreferences.getString("serverAddr", Core.defaultServerAddr);
serverPort = agentPreferences.getString("serverPort", Core.defaultServerPort);
interval = agentPreferences.getInt("interval", Core.defaultInterval);
serverAddr = agentPreferences.getString("serverAddr", defaultServerAddr);
serverPort = agentPreferences.getString("serverPort", defaultServerPort);
interval = agentPreferences.getInt("interval", defaultInterval);
//fix agent name to mark
agentName = agentPreferences.getString("agentName", Core.defaultAgentName+"MARK");
gpsStatus = agentPreferences.getString("gpsStatus", Core.defaultGpsStatus);
memoryStatus = agentPreferences.getString("memoryStatus", Core.defaultMemoryStatus);
taskStatus = agentPreferences.getString("taskStatus", Core.defaultTaskStatus);
task = agentPreferences.getString("task", Core.defaultTask);
taskHumanName = agentPreferences.getString("taskHumanName", Core.defaultTaskHumanName);
taskRun = agentPreferences.getString("taskRun", Core.defaultTaskRun);
password = agentPreferences.getString("password", Core.defaultPassword);
Log.v(LOG_TAG, password);
}
agentName = agentPreferences.getString("agentName", defaultAgentName+"_"+Installation.id(context));
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);
}// end loadConf
static public boolean updateConf(Context context) {
return updateConf(context, serverAddr, serverPort, interval, agentName,
gpsStatus, memoryStatus, taskStatus, task, taskHumanName, simID, simIDStatus, upTime,
gpsStatus, memoryStatus, taskStatus, task, taskHumanName, simID, simIDReport, upTime,
networkOperator, SMSReceived, SMSSent, networkType, phoneType, signalStrength,
incomingCalls, missedCalls, outgoingCalls, receiveBytes, transmitBytes, password);
incomingCalls, missedCalls, outgoingCalls, receiveBytes, transmitBytes, password, helloSignal,
passwordCheck, DeviceUpTimeReport, NetworkOperatorReport, NetworkTypeReport, PhoneTypeReport,
SignalStrengthReport, ReceivedSMSReport, SentSMSReport, IncomingCallsReport, MissedCallsReport,
OutgoingCallsReport, BytesReceivedReport, BytesSentReport, HelloSignalReport, BatteryLevelReport
);
}
static 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 _simIDStatus, long _upTime, String _networkOperator,
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 _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) {
if (con == null) {
con = context;
}
@ -225,7 +330,7 @@ public class Core {
editor.putString("task", _task);
editor.putString("taskHumanName", _taskHumanName);
editor.putString("simID", _simID);
editor.putString("simIDStatus", _simIDStatus);
editor.putString("simIDReport", _simIDReport);
editor.putLong("UpTime", _upTime);
editor.putString("networkOperator", _networkOperator);
editor.putInt("SMSReceived", _smsReceived);
@ -239,10 +344,25 @@ public class Core {
editor.putLong("receiveBytes", _receiveBytes);
editor.putLong("transmitBytes", _transmitBytes);
editor.putString("password", _password);
editor.putString("passwordCheck", _passwordCheck);
editor.putInt("helloSignal", _helloSignal);
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);
if (editor.commit()) {
return true;
}
return false;
}
}// end updateConf
}

View File

@ -1,3 +1,17 @@
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
package pandroid.agent;
import android.app.Activity;
@ -12,8 +26,7 @@ public class Help extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
TextView text = (TextView) findViewById(R.id.help_text);
text.setText(Html.fromHtml(getString(R.string.help_text_str)));
text.setMovementMethod(LinkMovementMethod.getInstance());

View File

@ -0,0 +1,56 @@
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
package pandroid.agent;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.UUID;
import android.content.Context;
public class Installation {
private static String sID = null;
private static final String INSTALLATION = "INSTALLATION";
public synchronized static String id(Context context) {
if (sID == null) {
File installation = new File(context.getFilesDir(), INSTALLATION);
try {
if (!installation.exists())
writeInstallationFile(installation);
sID = readInstallationFile(installation);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return sID;
}
private static String readInstallationFile(File installation) throws IOException {
RandomAccessFile f = new RandomAccessFile(installation, "r");
byte[] bytes = new byte[(int) f.length()];
f.readFully(bytes);
f.close();
return new String(bytes);
}
private static void writeInstallationFile(File installation) throws IOException {
FileOutputStream out = new FileOutputStream(installation);
String id = UUID.randomUUID().toString();
out.write(id.getBytes());
out.close();
}
}

View File

@ -61,7 +61,7 @@ public class PandroidAgent extends TabActivity {
//String lastGpsContactDateTime = "";
Thread thread = new Thread();
//Thread thread = new Thread();
//ComponentName service = null;
//PendingIntent sender = null;
//AlarmManager am = null;
@ -72,12 +72,20 @@ public class PandroidAgent extends TabActivity {
super.onCreate(savedInstanceState);
//if removed, battery -1 and agent reverts to defaults in core
Core.restartAgentListener(getApplicationContext());
//Check whether device has a sim card, phone without a sim card present
//return SIM_STATE_ABSENT but tablets only return SIM_STATE_UNKNOWN
String serviceName = Context.TELEPHONY_SERVICE;
TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService(serviceName);
String hasSim = ""+(telephonyManager.getSimState() != TelephonyManager.SIM_STATE_UNKNOWN);
if(hasSim.equals("true"))
hasSim = ""+(telephonyManager.getSimState() != TelephonyManager.SIM_STATE_ABSENT);
Core.hasSim = Boolean.parseBoolean(hasSim);
Log.v(LOG_TAG, "HERE: "+Core.hasSim);
//Create layout with 2 tabs
tabHost = getTabHost();
tabHost.addTab
@ -98,7 +106,18 @@ public class PandroidAgent extends TabActivity {
//tabHost.getTabWidget().getChildAt(1).getLayoutParams();
}
public void switchTab(int tab){
//Sets hello signal to 1(first connect since pandroid was closed)
public void onResume(){
super.onResume();
Log.v(LOG_TAG, "hello signal: "+Core.helloSignal);
if(Core.helloSignal == 0)
Core.helloSignal = 1;
Core.updateConf(getApplicationContext());
}
// Called from activity to allow tab switching
public void switchTab(int tab){
tabHost.setCurrentTab(tab);
}
}

View File

@ -1,5 +1,3 @@
package pandroid.agent;
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
@ -12,7 +10,8 @@ package pandroid.agent;
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// GNU General Public License for more details.
package pandroid.agent;
import java.io.File;
import java.io.FileOutputStream;
@ -42,6 +41,7 @@ import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.TrafficStats;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@ -53,40 +53,20 @@ import android.os.SystemClock;
import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.net.TrafficStats;
import android.util.Log;
public class PandroidAgentListener extends Service {
//log
public static final String LOG_TAG = "mark";
Handler h = new Handler();
int defaultInterval = 300;
String defaultServerPort = "41121";
String defaultServerAddr = "10.0.2.2";
String defaultAgentName = "pandroidAgent";
String defaultGpsStatus = "disabled"; // "disabled" or "enabled"
String defaultTaskStatus = "disabled"; // "disabled" or "enabled"
String defaultMemoryStatus = "disabled"; // "disabled" or "enabled"
String defaultTask = "";
String defaultTaskHumanName = "";
String lastGpsContactDateTime = "";
String osversion = "";
String defaultSimID = "";
String defaultUpTime = "0";
String defaultNetworkOperator = "";
String defaultSMSReceived = "5";
String defaultSMSSent = "4";
String defaultNetworkType = "";
String defaultPhoneType = "";
String defaultSignalStrength = "0";
String defaultIncomingCalls = "0";
String defaultMissedCalls = "0";
String defaultOutgoingCalls = "0";
String defaultReceiveBytes = "0";
String defaultTransmitBytes = "0";
boolean showLastXML = true;
@Override
@ -117,10 +97,10 @@ public class PandroidAgentListener extends Service {
putSharedData("PANDROID_DATA", "contactError", "0", "integer");
putSharedData("PANDROID_DATA", "lastContact", Long.toString(date.getTime() / 1000), "long");
// Keep lastXML sended if is not empty (empty means error sending it)
// Keep lastXML sent if is not empty (empty means error sending it)
String lastXML = buildXML();
String agentName = getSharedData("PANDROID_DATA", "agentName", defaultAgentName, "string");
String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
String destFileName = agentName + "." + System.currentTimeMillis() + ".data";
@ -130,7 +110,7 @@ public class PandroidAgentListener extends Service {
"-a",
getSharedData("PANDROID_DATA", "serverAddr", "", "string"),
"-p",
defaultServerPort,
Core.defaultServerPort,
"-v",
"/data/data/pandroid.agent/files/" + destFileName
};
@ -143,14 +123,17 @@ public class PandroidAgentListener extends Service {
if(tentacleRet == 0) {
putSharedData("PANDROID_DATA", "lastXML", lastXML, "string");
if (Core.helloSignal >= 1)
Core.helloSignal = 0;
Core.updateConf(getApplicationContext());
}
else {
putSharedData("PANDROID_DATA", "contactError", "1", "integer");
}
updateValues();
//set has connected to true
}
}//end contact
private String buildXML(){
String buffer = "";
@ -164,8 +147,8 @@ public class PandroidAgentListener extends Service {
gpsData = " latitude='" + latitude + "' longitude='" + longitude + "'";
}
String agentName = getSharedData("PANDROID_DATA", "agentName", defaultAgentName, "string");
String interval = getSharedData("PANDROID_DATA", "interval", Integer.toString(defaultInterval), "integer");
String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string");
String interval = getSharedData("PANDROID_DATA", "interval", Integer.toString(Core.defaultInterval), "integer");
@ -178,7 +161,10 @@ public class PandroidAgentListener extends Service {
// Modules
// //
// MODULES //
// //
String orientation = getSharedData("PANDROID_DATA", "orientation", "361", "float");
String proximity = getSharedData("PANDROID_DATA", "proximity", "-1.0", "float");
String batteryLevel = getSharedData("PANDROID_DATA", "batteryLevel", "-1", "integer");
@ -188,25 +174,41 @@ public class PandroidAgentListener extends Service {
taskHumanName = StringEscapeUtils.escapeHtml4(taskHumanName);
String task = getSharedData("PANDROID_DATA", "task", "", "string");
String memoryStatus = getSharedData("PANDROID_DATA", "memoryStatus", defaultMemoryStatus, "string");
String memoryStatus = getSharedData("PANDROID_DATA", "memoryStatus", Core.defaultMemoryStatus, "string");
String availableRamKb = getSharedData("PANDROID_DATA", "availableRamKb", "0" , "long");
String totalRamKb = getSharedData("PANDROID_DATA", "totalRamKb", "0", "long");
String SimID = getSharedData("PANDROID_DATA", "simID", defaultSimID, "string");
String upTime = getSharedData("PANDROID_DATA", "upTime", defaultUpTime, "long");
String networkOperator = getSharedData("PANDROID_DATA", "networkOperator", defaultNetworkOperator, "string");
String SMSReceived = getSharedData("PANDROID_DATA", "SMSReceived", defaultSMSReceived, "integer");
String SMSSent = getSharedData("PANDROID_DATA", "SMSSent", defaultSMSSent, "integer");
String networkType = getSharedData("PANDROID_DATA", "networkType", defaultNetworkType, "string");
String phoneType = getSharedData("PANDROID_DATA", "networkType", defaultNetworkType, "string");
String signalStrength = getSharedData("PANDROID_DATA", "signalStrength", defaultSignalStrength, "integer");
String incomingCalls = getSharedData("PANDROID_DATA", "incomingCalls", defaultIncomingCalls, "integer");
String missedCalls = getSharedData("PANDROID_DATA", "missedCalls", defaultMissedCalls, "integer");
String outgoingCalls = getSharedData("PANDROID_DATA", "outgoingCalls", defaultOutgoingCalls, "integer");
String receiveBytes = getSharedData("PANDROID_DATA", "receiveBytes", defaultReceiveBytes, "long");
String transmitBytes = getSharedData("PANDROID_DATA", "transmitBytes", defaultTransmitBytes, "long");
String SimID = getSharedData("PANDROID_DATA", "simID", Core.defaultSimID, "string");
String upTime = getSharedData("PANDROID_DATA", "upTime", ""+Core.defaultUpTime, "long");
String networkOperator = getSharedData("PANDROID_DATA", "networkOperator", Core.defaultNetworkOperator, "string");
String SMSReceived = getSharedData("PANDROID_DATA", "SMSReceived", ""+Core.defaultSMSReceived, "integer");
String SMSSent = getSharedData("PANDROID_DATA", "SMSSent", ""+Core.defaultSMSSent, "integer");
String networkType = getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
String phoneType = getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string");
String signalStrength = getSharedData("PANDROID_DATA", "signalStrength", ""+Core.defaultSignalStrength, "integer");
String incomingCalls = getSharedData("PANDROID_DATA", "incomingCalls", ""+Core.defaultIncomingCalls, "integer");
String missedCalls = getSharedData("PANDROID_DATA", "missedCalls", ""+Core.defaultMissedCalls, "integer");
String outgoingCalls = getSharedData("PANDROID_DATA", "outgoingCalls", ""+Core.defaultOutgoingCalls, "integer");
String receiveBytes = getSharedData("PANDROID_DATA", "receiveBytes", ""+Core.defaultReceiveBytes, "long");
String transmitBytes = getSharedData("PANDROID_DATA", "transmitBytes", ""+Core.defaultTransmitBytes, "long");
String helloSignal = getSharedData("PANDROID_DATA", "helloSignal", ""+Core.defaultHelloSignal, "integer");
String SimIDReport = getSharedData("PANDROID_DATA", "SimIDReport", Core.defaultSimIDReport, "string");
String DeviceUpTimeReport = getSharedData("PANDROID_DATA", "DeviceUpTimeReport", Core.defaultDeviceUpTimeReport, "string");
String NetworkOperatorReport = getSharedData("PANDROID_DATA", "NetworkOperatorReport", Core.defaultNetworkOperatorReport, "string");
String NetworkTypeReport = getSharedData("PANDROID_DATA", "NetworkTypeReport", Core.defaultNetworkTypeReport, "string");
String PhoneTypeReport = getSharedData("PANDROID_DATA", "PhoneTypeReport", Core.defaultPhoneTypeReport, "string");
String SignalStrengthReport = getSharedData("PANDROID_DATA", "SignalStrengthReport", Core.defaultSignalStrengthReport, "string");
String ReceivedSMSReport = getSharedData("PANDROID_DATA", "ReceivedSMSReport", Core.defaultReceivedSMSReport, "string");
String SentSMSReport = getSharedData("PANDROID_DATA", "SentSMSReport", Core.defaultSentSMSReport, "string");
String IncomingCallsReport = getSharedData("PANDROID_DATA", "IncomingCallsReport", Core.defaultIncomingCallsReport, "string");
String MissedCallsReport = getSharedData("PANDROID_DATA", "MissedCallsReport", Core.defaultMissedCallsReport, "string");
String OutgoingCallsReport = getSharedData("PANDROID_DATA", "OutgoingCallsReport", Core.defaultOutgoingCallsReport, "string");
String BytesReceivedReport = getSharedData("PANDROID_DATA", "BytesReceivedReport", Core.defaultBytesReceivedReport, "string");
String BytesSentReport = getSharedData("PANDROID_DATA", "BytesSentReport", Core.defaultBytesSentReport, "string");
String HelloSignalReport = getSharedData("PANDROID_DATA", "HelloSignalReport", Core.defaultHelloSignalReport, "string");
String BatteryLevelReport = getSharedData("PANDROID_DATA", "BatteryLevelReport", Core.defaultBatteryLevelReport, "string");
buffer += buildmoduleXML("battery_level", "The current Battery level", "generic_data", batteryLevel);
if (BatteryLevelReport.equals("enabled"))
buffer += buildmoduleXML("battery_level", "The current Battery level", "generic_data", batteryLevel);
if(!orientation.equals("361.0")) {
buffer += buildmoduleXML("orientation", "The actually device orientation (in degrees)", "generic_data", orientation);
@ -214,8 +216,7 @@ public class PandroidAgentListener extends Service {
if(!proximity.equals("-1.0")) {
buffer += buildmoduleXML("proximity", "The actually device proximity detector (0/1)", "generic_data", proximity);
}
}
if (taskStatus.equals("enabled")) {
buffer += buildmoduleXML("taskHumanName", "The task's human name.", "async_string", taskHumanName);
@ -239,25 +240,42 @@ public class PandroidAgentListener extends Service {
}
//buffer += buildmoduleXML("last_gps_contact", "Datetime of the last geo-location contact", "generic_data", lastGpsContactDateTime);
buffer += buildmoduleXML("simID", "The Sim ID.", "generic_data_string", SimID);
buffer += buildmoduleXML("upTime","Total device uptime in seconds.", "generic_data", upTime);
buffer += buildmoduleXML("networkOperator","Currently registered network operator", "generic_data_string", networkOperator);
buffer += buildmoduleXML("SMSRecieved","Number of SMS received", "generic_data", SMSReceived);
buffer += buildmoduleXML("SMSSent","Number of SMS sent", "generic_data", SMSSent);
buffer += buildmoduleXML("networkType","Current network type", "generic_data_string", networkType);
buffer += buildmoduleXML("phoneType","Phone type", "generic_data_string", phoneType);
buffer += buildmoduleXML("signalStrength","Signal strength (dB)", "generic_data_string", signalStrength);
buffer += buildmoduleXML("incomingCalls","Incoming calls", "generic_data", incomingCalls);
buffer += buildmoduleXML("missedCalls","Missed calls", "generic_data", missedCalls);
buffer += buildmoduleXML("outgoingCalls","Outgoing calls", "generic_data", outgoingCalls);
buffer += buildmoduleXML("receiveBytes","Bytes received(mobile)", "generic_data", receiveBytes);
buffer += buildmoduleXML("transmitBytes","Bytes transmitted(mobile)", "generic_data", transmitBytes);
if (Core.hasSim){
if (SimIDReport.equals("enabled"))
buffer += buildmoduleXML("simID", "The Sim ID.", "generic_data_string", SimID);
if (DeviceUpTimeReport.equals("enabled"))
buffer += buildmoduleXML("upTime","Total device uptime in seconds.", "generic_data", upTime);
if (NetworkOperatorReport.equals("enabled"))
buffer += buildmoduleXML("networkOperator","Currently registered network operator", "generic_data_string", networkOperator);
if (NetworkTypeReport.equals("enabled"))
buffer += buildmoduleXML("networkType","Current network type", "generic_data_string", networkType);
if (PhoneTypeReport.equals("enabled"))
buffer += buildmoduleXML("phoneType","Phone type", "generic_data_string", phoneType);
if (SignalStrengthReport.equals("enabled"))
buffer += buildmoduleXML("signalStrength","Signal strength (dB)", "generic_data_string", signalStrength);
if (ReceivedSMSReport.equals("enabled"))
buffer += buildmoduleXML("SMSRecieved","Number of SMS received", "generic_data", SMSReceived);
if (SentSMSReport.equals("enabled"))
buffer += buildmoduleXML("SMSSent","Number of SMS sent", "generic_data", SMSSent);
if (IncomingCallsReport.equals("enabled"))
buffer += buildmoduleXML("incomingCalls","Incoming calls", "generic_data", incomingCalls);
if (MissedCallsReport.equals("enabled"))
buffer += buildmoduleXML("missedCalls","Missed calls", "generic_data", missedCalls);
if (OutgoingCallsReport.equals("enabled"))
buffer += buildmoduleXML("outgoingCalls","Outgoing calls", "generic_data", outgoingCalls);
if (BytesReceivedReport.equals("enabled"))
buffer += buildmoduleXML("receiveBytes","Bytes received(mobile)", "generic_data", receiveBytes);
if (BytesSentReport.equals("enabled"))
buffer += buildmoduleXML("transmitBytes","Bytes transmitted(mobile)", "generic_data", transmitBytes);
}// end if sim card
if (HelloSignalReport.equals("enabled"))
buffer += buildmoduleXML("helloSignal","Hello Signal", "generic_data", helloSignal);
// End_Modules
buffer += "</agent_data>";
//Log.v("mark",buffer);
return buffer;
}
}// end buildXML
private void writeFile(String fileName, String textToWrite) {
try { // catches IOException below
@ -308,8 +326,8 @@ public class PandroidAgentListener extends Service {
//if(latitude != loc.getLatitude() || longitude != loc.getLongitude()) {
lastGpsContactDateTime = getHumanDateTime(-1);
//}
putSharedData("PANDROID_DATA", "latitude", new Double(loc.getLatitude()).toString(), "float");
putSharedData("PANDROID_DATA", "longitude", new Double(loc.getLongitude()).toString(), "float");
putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
}
else {
Criteria criteria = new Criteria();
@ -320,13 +338,13 @@ public class PandroidAgentListener extends Service {
criteria.setCostAllowed(true);
String bestProvider = lm.getBestProvider(criteria, true);
lm.requestLocationUpdates(bestProvider, defaultInterval, 1000,
lm.requestLocationUpdates(bestProvider, Core.defaultInterval, 1000,
new LocationListener() {
public void onLocationChanged(Location location) {
putSharedData("PANDROID_DATA", "latitude",
new Double(location.getLatitude()).toString(), "float");
Double.valueOf(location.getLatitude()).toString(), "float");
putSharedData("PANDROID_DATA", "longitude",
new Double(location.getLongitude()).toString(), "float");
Double.valueOf(location.getLongitude()).toString(), "float");
}
public void onStatusChanged(String s, int i, Bundle bundle) {
@ -356,7 +374,7 @@ public class PandroidAgentListener extends Service {
int rawlevel = intent.getIntExtra("level", -1);
int scale = intent.getIntExtra("scale", -1);
if (rawlevel >= 0 && scale > 0) {
putSharedData("PANDROID_DATA", "batteryLevel", new Integer((rawlevel * 100) / scale).toString(), "integer");
putSharedData("PANDROID_DATA", "batteryLevel", Integer.valueOf((rawlevel * 100) / scale).toString(), "integer");
}
}
};
@ -427,7 +445,7 @@ public class PandroidAgentListener extends Service {
private void updateValues() {
batteryLevel();
String gpsStatus = getSharedData("PANDROID_DATA", "gpsStatus", defaultGpsStatus, "string");
String gpsStatus = getSharedData("PANDROID_DATA", "gpsStatus", Core.defaultGpsStatus, "string");
if(gpsStatus.equals("enabled")) {
Log.e("PANDROID AGENT", "ENABLED");
@ -443,6 +461,7 @@ public class PandroidAgentListener extends Service {
getTaskStatus();
getMemoryStatus();
getUpTime();
//Ignore unnecessary modules
if(Core.hasSim)
{
getSimID();
@ -457,7 +476,7 @@ public class PandroidAgentListener extends Service {
}
private void getMemoryStatus() {
String memoryStatus = getSharedData("PANDROID_DATA", "memoryStatus", defaultMemoryStatus, "string");
String memoryStatus = getSharedData("PANDROID_DATA", "memoryStatus", Core.defaultMemoryStatus, "string");
long availableRamKb = 0;
long totalRamKb = 0;
@ -484,12 +503,12 @@ public class PandroidAgentListener extends Service {
putSharedData("PANDROID_DATA", "availableRamKb", "" + availableRamKb, "long");
putSharedData("PANDROID_DATA", "totalRamKb", "" + totalRamKb, "long");
}
}// end getMemoryStatus
private void getTaskStatus() {
String taskStatus = getSharedData("PANDROID_DATA", "taskStatus", defaultTaskStatus, "string");
String task = getSharedData("PANDROID_DATA", "task", defaultTask, "string");
String taskHumanName = getSharedData("PANDROID_DATA", "taskHumanName", defaultTaskHumanName, "string");
String taskStatus = getSharedData("PANDROID_DATA", "taskStatus", Core.defaultTaskStatus, "string");
String task = getSharedData("PANDROID_DATA", "task", Core.defaultTask, "string");
String taskHumanName = getSharedData("PANDROID_DATA", "taskHumanName", Core.defaultTaskHumanName, "string");
String run = "false";
if (taskStatus.equals("enabled")) {
@ -510,56 +529,52 @@ public class PandroidAgentListener extends Service {
}
}
putSharedData("PANDROID_DATA", "taskRun", run, "string");
}//end gettaskstatus
}//end getTaskStatus
/**
* Retrieves the simID of the device if available
* Retrieves the simID of the device if available
*/
public void getSimID(){
if(Core.simIDStatus.equals("enabled")){
String simID = getSharedData("PANDROID_DATA", "simID", defaultSimID, "string");
String simID = getSharedData("PANDROID_DATA", "simID", Core.defaultSimID, "string");
String serviceName = Context.TELEPHONY_SERVICE;
TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService(serviceName);
simID = telephonyManager.getSimSerialNumber();
putSharedData("PANDROID_DATA", "simID", simID, "string");
}
else
putSharedData("PANDROID_DATA", "simID", "Reporting not enabled", "string");
}
/**
* Retrieves the time in seconds since the device was switched on
* Retrieves the time in seconds since the device was switched on
*/
public void getUpTime(){
String upTime = defaultUpTime;
long upTime = Core.defaultUpTime;
upTime = ""+SystemClock.elapsedRealtime()/1000;
upTime = SystemClock.elapsedRealtime()/1000;
//Log.v(LOG_TAG, upTime);
putSharedData("PANDROID_DATA", "upTime", upTime, "long");
if(upTime != 0)
putSharedData("PANDROID_DATA", "upTime", ""+upTime, "long");
}
/**
* Retrieve currently registered network operator, i.e. vodafone, movistar, etc...
* Retrieve currently registered network operator, i.e. vodafone, movistar, etc...
*/
public void getNetworkOperator(){
String networkOperator = defaultNetworkOperator;
String networkOperator = Core.defaultNetworkOperator;
String serviceName = Context.TELEPHONY_SERVICE;
TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService(serviceName);
networkOperator = telephonyManager.getNetworkOperatorName();
if(networkOperator != null)
Log.v(LOG_TAG, networkOperator);
putSharedData("PANDROID_DATA", "networkOperator", networkOperator, "string");
putSharedData("PANDROID_DATA", "networkOperator", networkOperator, "string");
}
/**
* Retrieves the number of sent sms messages using the android messaging app only
*/
public void getSMSSent(){
String SMSSent = defaultSMSSent;
String SMSSent = ""+Core.defaultSMSSent;
SMSSent = getSharedData("PANDROID_DATA", "SMSSent", defaultSMSSent, "integer");
SMSSent = getSharedData("PANDROID_DATA", "SMSSent", ""+Core.defaultSMSSent, "integer");
Uri allMessages = Uri.parse("content://sms/sent");
@ -581,15 +596,17 @@ public class PandroidAgentListener extends Service {
SMSSent =""+ totalMessages;
putSharedData("PANDROID_DATA", "SMSSent", SMSSent, "integer");
if(SMSSent != null)
putSharedData("PANDROID_DATA", "SMSSent", SMSSent, "integer");
}
}// end getSMSSent
/**
* Retrieve the type of data network currently connected to, i.e. edge, gprs, etc...
* Retrieve the type of data network currently connected to, i.e. edge, gprs, etc...
*/
public void getNetworkType()
{
String networkType = defaultNetworkType;
String networkType = Core.defaultNetworkType;
TelephonyManager tM = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
@ -646,15 +663,17 @@ public class PandroidAgentListener extends Service {
networkType = "HSPA+";
break;
}
putSharedData("PANDROID_DATA", "networkType", networkType, "string");
if(networkType != null)
putSharedData("PANDROID_DATA", "networkType", networkType, "string");
}
}// end getNetworkType
/**
* Retrieve the type of mobile network currently conncected to, i.e. gms, cdma, etc...
* Retrieve the type of mobile network currently conncected to, i.e. gms, cdma, etc...
*/
public void getPhoneType()
{
String phoneType = defaultPhoneType;
String phoneType = Core.defaultPhoneType;
TelephonyManager tM = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
@ -675,44 +694,15 @@ public class PandroidAgentListener extends Service {
phoneType = "SIP";
break;
}
putSharedData("PANDROID_DATA", "phoneType", phoneType, "string");
}
if(phoneType != null)
putSharedData("PANDROID_DATA", "phoneType", phoneType, "string");
}// end getPhoneType
/**
* Retrieves the number of incoming, missed and outgoing calls
*/
public void getCalls()
{
/*
Uri uri = android.provider.CallLog.Calls.CONTENT_URI;
Cursor c = getApplicationContext().getContentResolver().query(uri, null, null, null, null);
if(c != null && c.moveToFirst()) {
while (c.isAfterLast() == false) {
int _ID = c.getColumnIndex(android.provider.CallLog.Calls._ID);
int _NUMBER = c.getColumnIndex(android.provider.CallLog.Calls.NUMBER);
int _DATE = c.getColumnIndex(android.provider.CallLog.Calls.DATE);
int _DURATION = c.getColumnIndex(android.provider.CallLog.Calls.DURATION);
int _CALLTYPE = c.getColumnIndex(android.provider.CallLog.Calls.TYPE);
int _NAME = c.getColumnIndex(android.provider.CallLog.Calls.CACHED_NAME);
int _NUMBERTYPE = c.getColumnIndex(android.provider.CallLog.Calls.CACHED_NUMBER_TYPE);
int _NEW = c.getColumnIndex(android.provider.CallLog.Calls.NEW);
String id = c.getString(_ID);
String number = c.getString(_NUMBER);
String date = c.getString(_DATE);
String duration = c.getString(_DURATION);
String callType = c.getString(_CALLTYPE);
String name = c.getString(_NAME);
String numberType = c.getString(_NUMBERTYPE);
String _new = c.getString(_NEW);
Log.v(LOG_TAG, "type: "+callType);
c.moveToNext();
}
}
*/
Cursor c = getApplicationContext().getContentResolver().query(android.provider.CallLog.Calls.CONTENT_URI, null, null, null, null);
c.moveToFirst();
@ -743,19 +733,23 @@ public class PandroidAgentListener extends Service {
c.moveToNext();
}
putSharedData("PANDROID_DATA", "incomingCalls", ""+incoming, "integer");
putSharedData("PANDROID_DATA", "incomingCalls", ""+incoming, "integer");
putSharedData("PANDROID_DATA", "missedCalls", ""+missed, "integer");
putSharedData("PANDROID_DATA", "outgoingCalls", ""+outgoing, "integer");
}
}
}// end getCalls
/**
* Retrieves the current cell signal strength in dB
*/
public void getSignalStrength()
{
TelephonyManager telephone = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
signalListener phoneState = new signalListener();
telephone.listen(phoneState ,PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
private class signalListener extends PhoneStateListener
{
@Override
@ -763,7 +757,7 @@ public class PandroidAgentListener extends Service {
{
super.onSignalStrengthsChanged(signalStrength);
Log.v(LOG_TAG, "here");
String signalStrengthValue = defaultSignalStrength;
String signalStrengthValue = ""+Core.defaultSignalStrength;
if (signalStrength.isGsm()) {
if (signalStrength.getGsmSignalStrength() != 99)
signalStrengthValue =""+ (signalStrength.getGsmSignalStrength() * 2 - 113);
@ -777,6 +771,9 @@ public class PandroidAgentListener extends Service {
};
/**
* Retrieves the number of sent/received bytes using the mobile network
*/
public void getDataBytes()
{
@ -822,19 +819,19 @@ public class PandroidAgentListener extends Service {
if(type == "boolean") {
boolean a = agentPreferences.getBoolean(tokenName, Boolean.parseBoolean(defaultValue));
return new Boolean(a).toString();
return Boolean.valueOf(a).toString();
}
else if(type == "float") {
float a = agentPreferences.getFloat(tokenName, Float.parseFloat(defaultValue));
return new Float(a).toString();
return Float.valueOf(a).toString();
}
else if(type == "integer") {
int a = agentPreferences.getInt(tokenName, Integer.parseInt(defaultValue));
return new Integer(a).toString();
return Integer.valueOf(a).toString();
}
else if(type == "long") {
long a = agentPreferences.getLong(tokenName, Long.parseLong(defaultValue));
return new Long(a).toString();
return Long.valueOf(a).toString();
}
else if(type == "string") {
return agentPreferences.getString(tokenName, defaultValue);
@ -895,8 +892,8 @@ public class PandroidAgentListener extends Service {
@Override
public void onLocationChanged(Location loc) {
putSharedData("PANDROID_DATA", "latitude", new Double(loc.getLatitude()).toString(), "float");
putSharedData("PANDROID_DATA", "longitude", new Double(loc.getLongitude()).toString(), "float");
putSharedData("PANDROID_DATA", "latitude", Double.valueOf(loc.getLatitude()).toString(), "float");
putSharedData("PANDROID_DATA", "longitude", Double.valueOf(loc.getLongitude()).toString(), "float");
}
@Override

View File

@ -1,3 +1,17 @@
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
package pandroid.agent;
@ -35,9 +49,7 @@ import android.util.Log;
}//end if
}//end onRecieve
}//end class

View File

@ -1,3 +1,17 @@
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
package pandroid.agent;
import java.util.ArrayList;
@ -27,9 +41,14 @@ import android.widget.Spinner;
import android.widget.Toast;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.text.TextUtils;
import android.util.Log;
public class Setup extends Activity {
//log
public static final String LOG_TAG = "mark";
private HashMap<String, String> listProcesses;
@ -42,7 +61,10 @@ public class Setup extends Activity {
Core.loadConf(getApplicationContext());
setContentView(R.layout.setup);
if(Core.hasSim)
setContentView(R.layout.setup);
else
setContentView(R.layout.setupnosim);
loadViews();
loadInBackgroundProcessInExecution();
setButtonEvents();
@ -51,12 +73,14 @@ public class Setup extends Activity {
public void onResume() {
super.onResume();
Log.v(LOG_TAG,"password check resume"+Core.passwordCheck);
if(Core.password.equals(Core.defaultPassword))
{
createpass();
if(Core.passwordCheck.equals("enabled"))
passwordChoose();
}
else{
enterpass();
enterpass();
}
}
@ -95,7 +119,7 @@ public class Setup extends Activity {
if (result) {
Toast toast = Toast.makeText(getApplicationContext(),
getString(R.string.correct_update),
getString(R.string.config_saved),
Toast.LENGTH_SHORT);
toast.show();
}
@ -112,7 +136,19 @@ public class Setup extends Activity {
});
}
Button passwordButton = (Button) findViewById(R.id.set_password);
passwordButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
createPass();
}
});
}// end setButtonEvents
@ -194,17 +230,18 @@ public class Setup extends Activity {
combo.setVisibility(Spinner.VISIBLE);
CheckBox checkbox = (CheckBox)findViewById(R.id.checkTaskReport);
checkbox.setEnabled(true);
/*CheckBox checkbox = (CheckBox)findViewById(R.id.checkTaskReport);
checkbox.setEnabled(true);*/
Button button = (Button)findViewById(R.id.update);
button.setEnabled(true);
button = (Button)findViewById(R.id.set_password);
button.setEnabled(true);
}
}
}// end onPostExecute
@ -221,7 +258,7 @@ public class Setup extends Activity {
Core.serverPort = editText.getText().toString();
editText = (EditText) findViewById(R.id.intervalInput);
Core.interval = new Integer(editText.getText().toString()).intValue();
Core.interval = Integer.valueOf(editText.getText().toString()).intValue();
editText = (EditText) findViewById(R.id.agentNameInput);
Core.agentName = editText.getText().toString();
@ -232,16 +269,18 @@ public class Setup extends Activity {
else
Core.gpsStatus = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkBatteryLevelReport);
if (checkBox.isChecked())
Core.BatteryLevelReport = "enabled";
else
Core.BatteryLevelReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkMemoryReport);
if (checkBox.isChecked())
Core.memoryStatus = "enabled";
else
Core.memoryStatus = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkSimIDReport);
if (checkBox.isChecked())
Core.simIDStatus = "enabled";
else
Core.simIDStatus = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkTaskReport);
@ -261,6 +300,94 @@ public class Setup extends Activity {
Core.taskHumanName = "";
}
checkBox = (CheckBox) findViewById(R.id.checkDeviceUpTimeReport);
if (checkBox.isChecked())
Core.DeviceUpTimeReport = "enabled";
else
Core.DeviceUpTimeReport = "disabled";
if (Core.hasSim) {
checkBox = (CheckBox) findViewById(R.id.checkSimIDReport);
if (checkBox.isChecked())
Core.simIDReport = "enabled";
else
Core.simIDReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkNetworkOperatorReport);
if (checkBox.isChecked())
Core.NetworkOperatorReport = "enabled";
else
Core.NetworkOperatorReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkNetworkTypeReport);
if (checkBox.isChecked())
Core.NetworkTypeReport = "enabled";
else
Core.NetworkTypeReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkPhoneTypeReport);
if (checkBox.isChecked())
Core.PhoneTypeReport = "enabled";
else
Core.PhoneTypeReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkSignalStrengthReport);
if (checkBox.isChecked())
Core.SignalStrengthReport = "enabled";
else
Core.SignalStrengthReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkReceivedSMSReport);
if (checkBox.isChecked())
Core.ReceivedSMSReport = "enabled";
else
Core.ReceivedSMSReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkSentSMSReport);
if (checkBox.isChecked())
Core.SentSMSReport = "enabled";
else
Core.SentSMSReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkIncomingCallsReport);
if (checkBox.isChecked())
Core.IncomingCallsReport = "enabled";
else
Core.IncomingCallsReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkMissedCallsReport);
if (checkBox.isChecked())
Core.MissedCallsReport = "enabled";
else
Core.MissedCallsReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkOutgoingCallsReport);
if (checkBox.isChecked())
Core.OutgoingCallsReport = "enabled";
else
Core.OutgoingCallsReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkBytesReceivedReport);
if (checkBox.isChecked())
Core.BytesReceivedReport = "enabled";
else
Core.BytesReceivedReport = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkBytesSentReport);
if (checkBox.isChecked())
Core.BytesSentReport = "enabled";
else
Core.BytesSentReport = "disabled";
}// end if sim card
checkBox = (CheckBox) findViewById(R.id.checkHelloSignalReport);
if (checkBox.isChecked())
Core.HelloSignalReport = "enabled";
else
Core.HelloSignalReport = "disabled";
Core.updateConf(getApplicationContext());
}
private void loadViews(){
@ -283,21 +410,123 @@ public class Setup extends Activity {
checkBox = (CheckBox) findViewById(R.id.checkGpsReport);
checkBox.setChecked(Core.gpsStatus.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkBatteryLevelReport);
checkBox.setChecked(Core.BatteryLevelReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkMemoryReport);
checkBox.setChecked(Core.memoryStatus.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkSimIDReport);
checkBox.setChecked(Core.simIDStatus.equals("enabled"));
checkBox.setChecked(Core.memoryStatus.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkTaskReport);
checkBox.setChecked(Core.taskStatus.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkDeviceUpTimeReport);
checkBox.setChecked(Core.DeviceUpTimeReport.equals("enabled"));
if (Core.hasSim) {
checkBox = (CheckBox) findViewById(R.id.checkSimIDReport);
checkBox.setChecked(Core.simIDReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkNetworkOperatorReport);
checkBox.setChecked(Core.NetworkOperatorReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkNetworkTypeReport);
checkBox.setChecked(Core.NetworkTypeReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkPhoneTypeReport);
checkBox.setChecked(Core.PhoneTypeReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkSignalStrengthReport);
checkBox.setChecked(Core.SignalStrengthReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkReceivedSMSReport);
checkBox.setChecked(Core.ReceivedSMSReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkSentSMSReport);
checkBox.setChecked(Core.SentSMSReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkIncomingCallsReport);
checkBox.setChecked(Core.IncomingCallsReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkMissedCallsReport);
checkBox.setChecked(Core.MissedCallsReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkOutgoingCallsReport);
checkBox.setChecked(Core.OutgoingCallsReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkBytesReceivedReport);
checkBox.setChecked(Core.BytesReceivedReport.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkBytesSentReport);
checkBox.setChecked(Core.BytesSentReport.equals("enabled"));
}//end if sim card
checkBox = (CheckBox) findViewById(R.id.checkHelloSignalReport);
checkBox.setChecked(Core.HelloSignalReport.equals("enabled"));
}
public void createpass() {
public void passwordChoose() {
//set up dialog
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.password_choose);
dialog.setTitle(getString(R.string.password_choose_text));
dialog.setCancelable(false);
//CheckBox cB = (CheckBox) dialog.findViewById(R.id.password_checkbox);
//cB.setChecked(Core.passwordCheck.equals("disabled"));
Button yes = (Button) dialog.findViewById(R.id.yes_button);
yes.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Core.passwordCheck = "disabled";
Core.updateConf(getApplicationContext());
dialog.dismiss();
createPass();
} // end onClick
});//end clickListener
Button no = (Button) dialog.findViewById(R.id.no_button);
no.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
CheckBox cB = (CheckBox) dialog.findViewById(R.id.password_checkbox);
if (cB.isChecked())
Core.passwordCheck = "disabled";
else
Core.passwordCheck = "enabled";
Core.updateConf(getApplicationContext());
//Log.v(LOG_TAG,"password check"+Core.passwordCheck);
dialog.dismiss();
} // end onClick
});//end clickListener
//now that the dialog is set up, it's time to show it
dialog.show();
}
public void createPass() {
//set up dialog
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.password_create);
dialog.setTitle("Set Password");
//dialog.setTitle(getString(R.string.password_set));
dialog.setCancelable(false);
dialog.getWindow().setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
//there are a lot of settings, for dialog, check them all out!
@ -321,17 +550,49 @@ public class Setup extends Activity {
try
{
if(createpass_password.equals(createpass_password2))
if(TextUtils.isEmpty(createpass_password))
{
Core.password = Core.defaultPassword;
Core.updateConf(getApplicationContext());
InputMethodManager im = (InputMethodManager)getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
im.hideSoftInputFromWindow(text.getWindowToken(), 0);
dialog.dismiss();
Toast toast = Toast.makeText(getApplicationContext(),
getString(R.string.password_removed),
Toast.LENGTH_SHORT);
toast.show();
return;
}
else if(createpass_password.length() < 6)
{
text.setError(getString(R.string.password_length));
text2.setError(getString(R.string.password_length));
return;
}
else if(createpass_password.equals(createpass_password2))
{
Core.password = createpass_password;
Core.updateConf(getApplicationContext());
//Core.restartAgentListener(getApplicationContext());
InputMethodManager im = (InputMethodManager)getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
im.hideSoftInputFromWindow(text.getWindowToken(), 0);
dialog.dismiss();
}
else
{
Toast toast = Toast.makeText(getApplicationContext(), getString(R.string.password_no_match), Toast.LENGTH_SHORT);
Toast toast = Toast.makeText(getApplicationContext(),
getString(R.string.password_created),
Toast.LENGTH_SHORT);
toast.show();
return;
}
else
{
text2.setError(getString(R.string.password_no_match));
return;
}
}
catch(Exception x)
@ -342,20 +603,23 @@ public class Setup extends Activity {
toast.show();
finish();
}
} // end onClick
}
});
});//end clickListener
//now that the dialog is set up, it's time to show it
dialog.show();
}// end createpass
}// end createPass
public void enterpass() {
//set up dialog
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.password_entry);
dialog.setTitle("Enter Password");
dialog.setTitle(getString(R.string.password_enter));
dialog.setCancelable(false);
dialog.getWindow().setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
//there are a lot of settings, for dialog, check them all out!
@ -384,9 +648,7 @@ public class Setup extends Activity {
}
else
{
Toast toast = Toast.makeText(getApplicationContext(), getString(R.string.password_no_match), Toast.LENGTH_SHORT);
toast.show();
//finish();
text.setError(getString(R.string.password_incorrect));
}
}
@ -415,8 +677,12 @@ public class Setup extends Activity {
dialog.show();
}// end enterpass
}// end enterPass
/**
* Allows this activity to switch the parent tab
* @param indexTabToSwitchTo
*/
public void switchTabInActivity(int indexTabToSwitchTo){
PandroidAgent ParentActivity;
ParentActivity = (PandroidAgent) this.getParent();

View File

@ -1,3 +1,17 @@
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
package pandroid.agent;
import java.util.Date;
@ -15,7 +29,8 @@ import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import android.util.Log;
//import android.util.Log;
public class Status extends Activity {
Handler h = new Handler();
@ -37,7 +52,7 @@ public class Status extends Activity {
//connect automatically
//Core.restartAgentListener(getApplicationContext());
setButtonEvents();
// Update the UI each second
}
@ -45,13 +60,14 @@ public class Status extends Activity {
public void onStart(){
super.onStart();
// Update the UI each second
h.post(new Runnable() {
@Override
public void run() {
Core.loadLastValues(getApplicationContext());
showLastValues();
updateLastContactInfo();
h.postDelayed(this, 1000);
}
});
@ -161,7 +177,7 @@ public class Status extends Activity {
private void setButtonEvents() {
// Set update button events
Button updateButton = (Button) findViewById(R.id.start);
Button start = (Button) findViewById(R.id.start);
Button xml = (Button) findViewById(R.id.get_xml);
Button hidexml = (Button) findViewById(R.id.hide_xml);
Button stop = (Button) findViewById(R.id.stop);
@ -185,13 +201,13 @@ public class Status extends Activity {
}
});
updateButton.setOnClickListener(new OnClickListener() {
start.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
boolean result = Core.updateConf(getApplicationContext());
//boolean result = Core.updateConf(getApplicationContext());
/*
if (result) {
Toast toast = Toast.makeText(getApplicationContext(),
getString(R.string.correct_start),
getString(R.string.config_saved),
Toast.LENGTH_SHORT);
toast.show();
}
@ -201,7 +217,7 @@ public class Status extends Activity {
Toast.LENGTH_SHORT);
toast.show();
}
*/
Core.restartAgentListener(getApplicationContext());
}
});