2011-10-12 Miguel de Dios <miguel.dedios@artica.es>

* android/.classpath, android/libs/commons-lang3-3.0.1.jar: added the
	library "org.apache.commons.lang".
	
	* android/AndroidManifest.xml: added the activities Status and Setup. And
	apply theme the no titlebar to main activity.
	
	* android/res/drawable-hdpi/logo.png, android/res/drawable-hdpi/icon.png,
	android/res/drawable-mdpi/logo.png, android/res/drawable-mdpi/icon.png:
	removed the images with same size or quality for the subtypes devices.
	
	* android/res/layout/setup.xml, android/res/layout/status.xml: added the
	layouts for the new activies.
	
	* android/res/values/strings.xml: added the new strings.
	
	* android/src/pandroid/agent/Setup.java,
	android/src/pandroid/agent/Status.java: added the new activies.
	
	* android/src/pandroid/agent/Core.java: added utility class for the proyect.
	
	* android/src/pandroid/agent/PandroidAgent.java: added the lost comment
	header with the license. started to modify to show as tabactivity and other
	changes.
	
	* android/src/pandroid/agent/PandroidAgentTentacle.java: added the lost
	comment header with the license.

	* android/src/pandroid/agent/PandroidAgentListener.java: added the lost
	comment header with the license. And wip for the new data to monitorice.
	
	* android/src/pandroid/agent/EventReceiver.java: added the lost comment
	header with the license. And added some traces.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5062 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2011-10-12 18:58:48 +00:00
parent 5f209333d9
commit c569d88237
18 changed files with 1221 additions and 58 deletions

View File

@ -1,3 +1,38 @@
2011-10-12 Miguel de Dios <miguel.dedios@artica.es>
* android/.classpath, android/libs/commons-lang3-3.0.1.jar: added the
library "org.apache.commons.lang".
* android/AndroidManifest.xml: added the activities Status and Setup. And
apply theme the no titlebar to main activity.
* android/res/drawable-hdpi/logo.png, android/res/drawable-hdpi/icon.png,
android/res/drawable-mdpi/logo.png, android/res/drawable-mdpi/icon.png:
removed the images with same size or quality for the subtypes devices.
* android/res/layout/setup.xml, android/res/layout/status.xml: added the
layouts for the new activies.
* android/res/values/strings.xml: added the new strings.
* android/src/pandroid/agent/Setup.java,
android/src/pandroid/agent/Status.java: added the new activies.
* android/src/pandroid/agent/Core.java: added utility class for the proyect.
* android/src/pandroid/agent/PandroidAgent.java: added the lost comment
header with the license. started to modify to show as tabactivity and other
changes.
* android/src/pandroid/agent/PandroidAgentTentacle.java: added the lost
comment header with the license.
* android/src/pandroid/agent/PandroidAgentListener.java: added the lost
comment header with the license. And wip for the new data to monitorice.
* android/src/pandroid/agent/EventReceiver.java: added the lost comment
header with the license. And added some traces.
2011-09-29 Miguel de Dios <miguel.dedios@artica.es>
* android/default.properties, android/AndroidManifest.xml: added permission

View File

@ -3,5 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="libs/commons-lang3-3.0.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -4,23 +4,31 @@
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".PandroidAgent"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation">
<activity
android:name=".PandroidAgent"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation"
android:theme="@android:style/Theme.NoTitleBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Status" />
<activity android:name=".Setup" />
<service android:enabled="true" android:name="pandroid.agent.PandroidAgentListener" />
<receiver android:name="pandroid.agent.EventReceiver" />
</application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-feature android:name="android.hardware.sensor.light" />
<uses-feature android:name="android.hardware.location" />

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -0,0 +1,139 @@
<?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/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"
android:enabled="false"
/>
<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/update"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/update"
android:enabled="false"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -0,0 +1,179 @@
<?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/last_values_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/last_values"
android:textSize="18dip"
android:textStyle="bold"
android:layout_gravity="center_horizontal"
/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/lastContactInfo_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dip"
android:textStyle="bold"
/>
<ImageView
android:id="@+id/img_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:src="@drawable/logo"
android:layout_alignParentRight="true"
/>
<TextView
android:id="@+id/latitude_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/latitude"
android:textSize="14dip"
android:textStyle="bold"
android:layout_below="@id/lastContactInfo_label_str"
/>
<TextView
android:id="@+id/latitude_value_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/latitude_label_str"
/>
<TextView
android:id="@+id/longitude_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/longitude"
android:textSize="14dip"
android:textStyle="bold"
android:layout_below="@id/latitude_value_str"
/>
<TextView
android:id="@+id/longitude_value_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/longitude_label_str"
/>
<TextView
android:id="@+id/battery_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/battery_level"
android:textSize="14dip"
android:textStyle="bold"
android:layout_below="@id/longitude_value_str"
/>
<TextView
android:id="@+id/battery_value_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/battery_label_str"
/>
<TextView
android:id="@+id/orientation_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/orientation"
android:textSize="14dip"
android:textStyle="bold"
android:layout_below="@id/battery_value_str"
/>
<TextView
android:id="@+id/orientation_value_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/orientation_label_str"
/>
<TextView
android:id="@+id/proximity_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/proximity"
android:textSize="14dip"
android:textStyle="bold"
android:layout_below="@id/orientation_value_str"
/>
<TextView
android:id="@+id/proximity_value_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/proximity_label_str"
/>
</RelativeLayout>
<TextView
android:id="@+id/task_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/task"
android:textSize="14dip"
android:textStyle="bold"
/>
<TextView
android:id="@+id/task_value_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/memory_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/memory"
android:textSize="14dip"
android:textStyle="bold"
/>
<TextView
android:id="@+id/memory_value_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<!--
<Button
android:id="@+id/get_xml"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Get xml"
/>
<TextView
android:id="@+id/xml"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="..."
android:gravity="left"
/>
-->
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="const_string_preferences">PANDROID_DATA</string>
<string name="app_name">Pandroid Agent</string>
<string name="interval">Interval:</string>
<string name="update">Update conf.</string>
@ -9,10 +11,23 @@
<string name="confTitle">Pandroid Agent Configuration</string>
<string name="agent">Agent name:</string>
<string name="gpsReport">Report GPS data</string>
<string name="memoryReport">Report memory system</string>
<string name="taskReport">Report task</string>
<string name="gpsMode">GPS Mode</string>
<string name="gpsCurrent">Current position (high battery cost)</string>
<string name="summary">Current configuration:</string>
<string name="starStop">Restart</string>
<string name="gpsLast">Last known position</string>
<string name="loading">Loading...</string>
<string name="process">Process</string>
<string name="last_values">Last values</string>
<string name="latitude">Latitude</string>
<string name="longitude">Longitude</string>
<string name="battery_level">Battery Level</string>
<string name="orientation">Orientation</string>
<string name="proximity">Proximity</string>
<string name="incorrect_update">Unsucessful update options.</string>
<string name="correct_update">sucessful update options.</string>
<string name="task">Task</string>
<string name="memory">Memory</string>
</resources>

View File

@ -0,0 +1,186 @@
package pandroid.agent;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.telephony.TelephonyManager;
import android.util.Log;
public class Core {
//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;
//The -361 is the first invalid value between 360 and -360 values.
static final int CONST_INVALID_ORIENTATION = -361;
static final float CONST_INVALID_PROXIMITY = -1;
static final long CONST_INVALID_CONTACT = -1;
static final int CONST_CONTACT_ERROR = 0;
static volatile public String defaultServerAddr = "farscape.artica.es";
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 defaultTaskStatus = "disabled"; // "disabled" or "enabled"
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 Context con = null;
static volatile public AlarmManager am = null;
static volatile public PendingIntent sender = null;
static volatile public boolean alarmEnabled = false;
static volatile public String serverAddr = defaultServerAddr;
static volatile public String serverPort = defaultServerPort;
static volatile public int interval = defaultInterval;
static volatile public String agentName = defaultAgentName;
static volatile public String gpsStatus = defaultGpsStatus;
static volatile public String memoryStatus = defaultMemoryStatus;
static volatile public String taskStatus = defaultTaskStatus;
static volatile public String task = defaultTask;
static volatile public String taskHumanName = defaultTaskHumanName;
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 long lastContact = CONST_INVALID_CONTACT;
static volatile public int contactError = CONST_CONTACT_ERROR;
public Core() {
}
static public void startAgentListener(Context context) {
if (con == null) {
con = context;
}
loadConf(con);
Intent intentReceiver = new Intent(con, EventReceiver.class);
sender = PendingIntent.getBroadcast(con, 0, intentReceiver, 0);
am = (AlarmManager)con.getSystemService(con.ALARM_SERVICE);
alarmEnabled = true;
am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), (interval * 1000), sender);
}
static public void stopAgentListener() {
if (am != null) {
am.cancel(sender);
alarmEnabled = false;
}
}
static public void restartAgentListener(Context context) {
stopAgentListener();
startAgentListener(context);
}
static public String getSimID(Context context) {
if (con == null) {
con = context;
}
String simID = null;
String serviceName = Context.TELEPHONY_SERVICE;
TelephonyManager m_telephonyManager = (TelephonyManager) con.getSystemService(serviceName);
simID = m_telephonyManager.getSimSerialNumber();
return simID;
}
static public void loadLastValues(Context context) {
if (con == null) {
con = context;
}
SharedPreferences agentPreferences = con.getSharedPreferences(
con.getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
latitude = agentPreferences.getFloat("latitude", CONST_INVALID_COORDS);
longitude = agentPreferences.getFloat("longitude", CONST_INVALID_COORDS);
batteryLevel = agentPreferences.getInt("batteryLevel", CONST_INVALID_BATTERY_LEVEL);
orientation = agentPreferences.getFloat("orientation", CONST_INVALID_ORIENTATION);
proximity = agentPreferences.getFloat("proximity", CONST_INVALID_PROXIMITY);
taskStatus = agentPreferences.getString("taskStatus", 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);
}
static public void loadConf(Context context) {
if (con == null) {
con = context;
}
SharedPreferences agentPreferences = con.getSharedPreferences(
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);
agentName = agentPreferences.getString("agentName", Core.defaultAgentName + getSimID(con));
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);
}
static public boolean updateConf(Context context) {
return updateConf(context, serverAddr, serverPort, interval, agentName,
gpsStatus, memoryStatus, taskStatus, task, taskHumanName);
}
static public boolean updateConf(Context context, String _serverAddr,
String _serverPort, int _interval, String _agentName, String _gpsStatus,
String _memoryStatus, String _taskStatus, String _task,
String _taskHumanName) {
if (con == null) {
con = context;
}
SharedPreferences agentPreferences = con.getSharedPreferences(
con.getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = agentPreferences.edit();
editor.putString("serverAddr", _serverAddr);
editor.putString("serverPort", _serverPort);
editor.putInt("interval", _interval);
editor.putString("agentName", _agentName);
editor.putString("gpsStatus", _gpsStatus);
editor.putString("memoryStatus", _memoryStatus);
editor.putString("taskStatus", _taskStatus);
editor.putString("task", _task);
editor.putString("taskHumanName", _taskHumanName);
if (editor.commit()) {
return true;
}
return false;
}
}

View File

@ -1,13 +1,28 @@
// 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.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class EventReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
public void onReceive(Context context, Intent intent) {Log.e("EventReceiver", "onReceive");
context.startService(new Intent(context, PandroidAgentListener.class));
}

View File

@ -1,30 +1,46 @@
// 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;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Button;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.view.KeyEvent;
import android.view.inputmethod.InputMethodManager;
import android.app.TabActivity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.ComponentName;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.telephony.TelephonyManager;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TabHost;
import android.widget.TextView;
import java.util.Date;
import java.lang.Thread;
public class PandroidAgent extends Activity {
public class PandroidAgent extends TabActivity {
//public class PandroidAgent extends Activity {
Handler h = new Handler();
int defaultInterval = 300;
@ -44,8 +60,34 @@ public class PandroidAgent extends Activity {
AlarmManager am = null;
@Override
public void onCreate(Bundle savedInstanceState) {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Core.restartAgentListener(getApplicationContext());
final TabHost tabHost = getTabHost();
tabHost.addTab
(
tabHost.newTabSpec("Status")
.setIndicator("Status")
.setContent(new Intent(this, Status.class))
);
tabHost.addTab
(
tabHost.newTabSpec("Setup")
.setIndicator("Setup")
.setContent(new Intent(this, Setup.class))
);
tabHost.getTabWidget().getChildAt(0).getLayoutParams().height=45;
tabHost.getTabWidget().getChildAt(1).getLayoutParams().height=45;
if (true) return; //For disable the next code.
this.setContentView(R.layout.main);
// Customize the agent name with the unique Sim ID

View File

@ -1,38 +1,58 @@
package pandroid.agent;
// 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.
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.http.entity.StringEntity;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.Service;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.Criteria;
import android.os.Bundle;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.hardware.SensorManager;
import android.content.pm.PackageManager;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.OutputStream;
import java.util.Calendar;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
public class PandroidAgentListener extends Service {
Handler h = new Handler();
@ -42,6 +62,10 @@ public class PandroidAgentListener extends Service {
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 = "";
boolean showLastXML = true;
@ -52,6 +76,8 @@ public class PandroidAgentListener extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.e("PandroidAgentListener", "onStartCommand");
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
wakeLock.acquire();
@ -59,6 +85,7 @@ public class PandroidAgentListener extends Service {
contact();
wakeLock.release();
stopSelf(startId);
return START_NOT_STICKY;
}
@ -122,19 +149,63 @@ public class PandroidAgentListener extends Service {
String agentName = getSharedData("PANDROID_DATA", "agentName", defaultAgentName, "string");
String interval = getSharedData("PANDROID_DATA", "interval", Integer.toString(defaultInterval), "integer");
buffer += "<agent_data description='' group='' os_name='android' os_version='2.1' interval='"+ interval +"' version='3.2RC1(Build 101103)' timestamp='" + getHumanDateTime(-1) + "' agent_name='" + agentName + "' timezone_offset='0'" + gpsData +">\n";
buffer += "<agent_data " +
"description='' group='' os_name='android' os_version='2.1' " +
"interval='"+ interval +"' version='4.0(Build 111012)' " +
"timestamp='" + getHumanDateTime(-1) + "' agent_name='" + agentName + "' " +
"timezone_offset='0'" + gpsData +">\n";
// Modules
buffer += buildmoduleXML("battery_level", "The actually device battery level", "generic_data", getSharedData("PANDROID_DATA", "batteryLevel", "-1", "integer"));
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");
String taskStatus = getSharedData("PANDROID_DATA", "taskStatus", "disabled", "string");
String taskRun = getSharedData("PANDROID_DATA", "taskRun", "false", "string");
String taskHumanName = getSharedData("PANDROID_DATA", "taskHumanName", "", "string");
taskHumanName = StringEscapeUtils.escapeHtml4(taskHumanName);
Log.e("taskHumanName", taskHumanName);
String task = getSharedData("PANDROID_DATA", "task", "", "string");
String memoryStatus = getSharedData("PANDROID_DATA", "memoryStatus", defaultMemoryStatus, "string");
String availableRamKb = getSharedData("PANDROID_DATA", "availableRamKb", "0" , "long");
String totalRamKb = getSharedData("PANDROID_DATA", "totalRamKb", "0", "long");
buffer += buildmoduleXML("battery_level", "The actually device battery level", "generic_data", batteryLevel);
if(!orientation.equals("361.0")) {
buffer += buildmoduleXML("orientation", "The actually device orientation (in degrees)", "generic_data", orientation);
}
if(!proximity.equals("-1.0")) {
buffer += buildmoduleXML("proximity", "The actually device proximity detector (0/1)", "generic_data", proximity);
}
if (taskStatus.equals("enabled")) {
buffer += buildmoduleXML("taskStatus", "The Pandroid configuration watch task.", "generic_proc", "1");
buffer += buildmoduleXML("taskHumanName", "The task's human name.", "async_string", taskHumanName);
buffer += buildmoduleXML("task", "The task's package name.", "async_string", task);
if (taskRun.equals("true")) {
buffer += buildmoduleXML("taskRun", "The task is running.", "async_proc", "1");
}
else {
buffer += buildmoduleXML("taskRun", "The task is running.", "async_proc", "0");
}
}
else {
buffer += buildmoduleXML("taskStatus", "The Pandroid configuration watch task.", "generic_proc", "0");
}
if (memoryStatus.equals("enabled")) {
buffer += buildmoduleXML("memoryStatus", "The Pandroid configuration watch memory.", "async_proc", "1");
buffer += buildmoduleXML("availableRamKb", "The available ram in Kb of device.", "async_data", availableRamKb);
buffer += buildmoduleXML("totalRamKb", "The total ram in Kb of device.", "async_data", totalRamKb);
}
else {
buffer += buildmoduleXML("memoryStatus", "The Pandroid configuration watch memory.", "async_proc", "1");
}
//buffer += buildmoduleXML("last_gps_contact", "Datetime of the last geo-location contact", "generic_data", lastGpsContactDateTime);
// End_Modules
@ -146,16 +217,14 @@ public class PandroidAgentListener extends Service {
private void writeFile(String fileName, String textToWrite) {
try { // catches IOException below
FileOutputStream fOut = openFileOutput(fileName,
MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
// Write the string to the file
osw.write(textToWrite);
/* ensure that everything is
* really written out and close */
osw.flush();
osw.close();
FileOutputStream fOut = openFileOutput(fileName, MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
// Write the string to the file
osw.write(textToWrite);
/* ensure that everything is really written out and close */
osw.flush();
osw.close();
} catch (IOException e) {
}
@ -207,8 +276,8 @@ public class PandroidAgentListener extends Service {
if(loc != null) {
putSharedData("PANDROID_DATA", "latitude", new Double(loc.getLatitude()).toString(), "float");
putSharedData("PANDROID_DATA", "longitude", new Double(loc.getLongitude()).toString(), "float");
}
else {
}
else {
putSharedData("PANDROID_DATA", "latitude", "181", "float");
putSharedData("PANDROID_DATA", "longitude", "181", "float");
}
@ -301,6 +370,64 @@ public class PandroidAgentListener extends Service {
}
sensors();
getTaskStatus();
getMemoryStatus();
}
private void getMemoryStatus() {
String memoryStatus = getSharedData("PANDROID_DATA", "memoryStatus", defaultMemoryStatus, "string");
long availableRamKb = 0;
long totalRamKb = 0;
if (memoryStatus.equals("enabled")) {
MemoryInfo mi = new MemoryInfo();
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
activityManager.getMemoryInfo(mi);
availableRamKb = mi.availMem / 1024;
totalRamKb = 0;
try {
RandomAccessFile reader = new RandomAccessFile("/proc/meminfo", "r");
String line = reader.readLine();
line = line.replaceAll("[ ]+", " ");
String[] tokens = line.split(" ");
totalRamKb = Long.valueOf(tokens[1]);
}
catch (IOException ex) {
ex.printStackTrace();
}
}
putSharedData("PANDROID_DATA", "availableRamKb", "" + availableRamKb, "long");
putSharedData("PANDROID_DATA", "totalRamKb", "" + totalRamKb, "long");
}
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 run = "false";
if (taskStatus.equals("enabled")) {
if ((task.length() != 0) && (taskHumanName.length() != 0)) {
ActivityManager activityManager = (ActivityManager)getApplication().getSystemService(ACTIVITY_SERVICE);
List<RunningAppProcessInfo> runningAppProcessInfos = activityManager.getRunningAppProcesses();
PackageManager pm = getApplication().getPackageManager();
RunningAppProcessInfo runningAppProcessInfo;
for (int i = 0; i < runningAppProcessInfos.size(); i++) {
runningAppProcessInfo = runningAppProcessInfos.get(i);
if (task.equals(runningAppProcessInfo.processName)) {
run = "true";
break;
}
}
}
}
putSharedData("PANDROID_DATA", "taskRun", run, "string");
}
private void putSharedData(String preferenceName, String tokenName, String data, String type) {

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.io.BufferedReader;

View File

@ -0,0 +1,229 @@
package pandroid.agent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.Toast;
public class Setup extends Activity {
private HashMap<String, String> listProcesses;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
listProcesses = new HashMap<String, String>();
setContentView(R.layout.setup);
Core.loadConf(getApplicationContext());
loadViews();
loadInBackgroundProcessInExecution();
setButtonEvents();
}
private void setButtonEvents() {
// Set update button events
Button updateButton = (Button) findViewById(R.id.update);
updateButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
getDataFromView();
boolean result = Core.updateConf(getApplicationContext());
if (result) {
Toast toast = Toast.makeText(getApplicationContext(),
getString(R.string.correct_update),
Toast.LENGTH_SHORT);
toast.show();
}
else {
Toast toast = Toast.makeText(getApplicationContext(),
getString(R.string.incorrect_update),
Toast.LENGTH_SHORT);
toast.show();
}
Core.restartAgentListener(getApplicationContext());
}
});
}
private void loadInBackgroundProcessInExecution() {
new GetProcessInExecutionAsyncTask().execute();
}
public class GetProcessInExecutionAsyncTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
getProcess();
return null;
}
private void getProcess() {
listProcesses.clear();
ActivityManager activityManager = (ActivityManager)getApplication().getSystemService(ACTIVITY_SERVICE);
List<RunningAppProcessInfo> runningAppProcessInfos = activityManager.getRunningAppProcesses();
PackageManager pm = getApplication().getPackageManager();
RunningAppProcessInfo runningAppProcessInfo;
for (int i = 0; i < runningAppProcessInfos.size(); i++) {
runningAppProcessInfo = runningAppProcessInfos.get(i);
try {
CharSequence human_name = pm.getApplicationLabel(
pm.getApplicationInfo(runningAppProcessInfo.processName, PackageManager.GET_META_DATA));
listProcesses.put(runningAppProcessInfo.processName, human_name + "");
}
catch (NameNotFoundException e) {
listProcesses.put(runningAppProcessInfo.processName, runningAppProcessInfo.processName);
}
}
}
@Override
protected void onPostExecute(Void unused)
{
Spinner combo = (Spinner)findViewById(R.id.processes_combo);
ArrayList<String> listProcess = new ArrayList<String>(listProcesses.keySet());
ArrayList<String> listProcessHuman = new ArrayList<String>(listProcesses.values());
int position = 0;
if (Core.task.length() != 0) {
position = listProcess.indexOf(Core.task);
String text = Core.task;
if (Core.taskHumanName.length() != 0) {
text = Core.taskHumanName;
}
//If the process is not running, add in the list at the end
if (position == -1) {
listProcesses.put(Core.task, text);
//The asociative array is reordened, and need to extract th subarrays again.
listProcess = new ArrayList<String>(listProcesses.keySet());
listProcessHuman = new ArrayList<String>(listProcesses.values());
position = listProcess.indexOf(Core.task);
}
}
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(getApplicationContext(),
android.R.layout.simple_spinner_item, listProcessHuman);
combo.setAdapter(spinnerArrayAdapter);
combo.setSelection(position);
ProgressBar progressBar = (ProgressBar) findViewById(R.id.loading_task_anim);
progressBar.setVisibility(ProgressBar.GONE);
combo.setVisibility(Spinner.VISIBLE);
CheckBox checkbox = (CheckBox)findViewById(R.id.checkTaskReport);
checkbox.setEnabled(true);
Button button = (Button)findViewById(R.id.update);
button.setEnabled(true);
}
}
private void getDataFromView() {
// Init form values
EditText editText;
CheckBox checkBox;
Spinner combo;
editText = (EditText) findViewById(R.id.serverAddrInput);
Core.serverAddr = editText.getText().toString();
editText = (EditText) findViewById(R.id.serverPortInput);
Core.serverPort = editText.getText().toString();
editText = (EditText) findViewById(R.id.intervalInput);
Core.interval = new Integer(editText.getText().toString()).intValue();
editText = (EditText) findViewById(R.id.agentNameInput);
Core.agentName = editText.getText().toString();
checkBox = (CheckBox) findViewById(R.id.checkGpsReport);
if (checkBox.isChecked())
Core.gpsStatus = "enabled";
else
Core.gpsStatus = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkMemoryReport);
if (checkBox.isChecked())
Core.memoryStatus = "enabled";
else
Core.memoryStatus = "disabled";
checkBox = (CheckBox) findViewById(R.id.checkTaskReport);
if (checkBox.isChecked()) {
Core.taskStatus = "enabled";
combo = (Spinner)findViewById(R.id.processes_combo);
int position = combo.getSelectedItemPosition();
ArrayList<String> listProcess = new ArrayList<String>(listProcesses.keySet());
ArrayList<String> listProcessHuman = new ArrayList<String>(listProcesses.values());
Core.task = listProcess.get(position);
Core.taskHumanName = listProcessHuman.get(position);
}
else {
Core.taskStatus = "disabled";
Core.task = "";
Core.taskHumanName = "";
}
}
private void loadViews(){
// Init form values
EditText editText;
CheckBox checkBox;
editText = (EditText) findViewById(R.id.serverAddrInput);
editText.setText(Core.serverAddr);
editText = (EditText) findViewById(R.id.serverPortInput);
editText.setText(Core.serverPort);
editText = (EditText) findViewById(R.id.intervalInput);
editText.setText(Integer.toString(Core.interval));
editText = (EditText) findViewById(R.id.agentNameInput);
editText.setText(Core.agentName);
checkBox = (CheckBox) findViewById(R.id.checkGpsReport);
checkBox.setChecked(Core.gpsStatus.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkMemoryReport);
checkBox.setChecked(Core.memoryStatus.equals("enabled"));
checkBox = (CheckBox) findViewById(R.id.checkTaskReport);
checkBox.setChecked(Core.taskStatus.equals("enabled"));
}
}

View File

@ -0,0 +1,173 @@
package pandroid.agent;
import java.util.Date;
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class Status extends Activity {
Handler h = new Handler();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.status);
Core.loadLastValues(getApplicationContext());
showLastValues();
updateLastContactInfo();
setButtonEvents();
// Update the UI each second
h.post(new Runnable() {
@Override
public void run() {
Core.loadLastValues(getApplicationContext());
showLastValues();
updateLastContactInfo();
h.postDelayed(this, 1000);
}
});
}
private void setButtonEvents() {
// Set update button events
/*
Button getButton = (Button) findViewById(R.id.get_xml);
getButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
updateLastXML();
showLastValues();
updateLastContactInfo();
}
});
*/
}
private void updateLastXML() {
/*
TextView xml = (TextView) this.findViewById(R.id.xml);
Core.restartAgentListener(getApplicationContext());
SharedPreferences agentPreferences = getSharedPreferences(
getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
String lastXML = agentPreferences.getString("lastXML", "[no data]");
xml.setText("Last XML builded: \n\n" + lastXML);
*/
}
private void updateLastContactInfo() {
//putSharedData("PANDROID_DATA", "lastContact", "-1", "long");
long lastContact = Core.lastContact;
int contactError = Core.contactError;
Date date = new Date();
long timestamp = date.getTime() / 1000;
long timeAgo = -1;
if(lastContact != -1){
timeAgo = timestamp - lastContact;
}
int interval = Core.interval;
if(timeAgo >= interval) {
timeAgo = 0;
}
String stringAgo = "";
if(lastContact == -1) {
stringAgo = "Never.";
}
else if(timeAgo == 0) {
stringAgo = "Now.";
}
else {
stringAgo = timeAgo + " seconds ago.";
}
if(contactError == 1) {
TextView lastContactInfo = (TextView) this.findViewById(R.id.lastContactInfo_label_str);
lastContactInfo.setTextColor(Color.parseColor("#FF0000"));
lastContactInfo.setText("Contact error");
//stopAgentListener();
}
else {
TextView lastContactInfo = (TextView) this.findViewById(R.id.lastContactInfo_label_str);
lastContactInfo.setTextColor(Color.parseColor("#00FF00"));
lastContactInfo.setText("Last Contact:\n" + stringAgo);
}
}
private void showLastValues() {
TextView textView = (TextView)findViewById(R.id.latitude_value_str);
textView.setText("");
if (Core.latitude != Core.CONST_INVALID_COORDS) {
textView.setText("" + Core.latitude);
}
textView = (TextView)findViewById(R.id.longitude_value_str);
textView.setText("");
if (Core.longitude != Core.CONST_INVALID_COORDS) {
textView.setText("" + Core.longitude);
}
textView = (TextView)findViewById(R.id.battery_value_str);
textView.setText("");
if (Core.batteryLevel != Core.CONST_INVALID_BATTERY_LEVEL) {
textView.setText("" + Core.batteryLevel);
}
textView = (TextView)findViewById(R.id.orientation_value_str);
textView.setText("");
if (Core.orientation != Core.CONST_INVALID_ORIENTATION) {
textView.setText("" + Core.orientation);
}
textView = (TextView)findViewById(R.id.proximity_value_str);
textView.setText("");
if (Core.proximity != Core.CONST_INVALID_PROXIMITY) {
textView.setText("" + Core.proximity);
}
textView = (TextView)findViewById(R.id.task_value_str);
textView.setText("");
if (Core.taskStatus.equals("enabled") && Core.taskHumanName.length() != 0) {
String text = Core.taskHumanName + " ( " + Core.task + " ): ";
if (Core.taskRun.equals("true")) {
text = text + "running";
}
else {
text = text + "not running";
}
textView.setText(text);
}
textView = (TextView)findViewById(R.id.memory_value_str);
textView.setText("");
if (Core.memoryStatus.equals("enabled")) {
textView.setText("Avaliable: " + Core.availableRamKb + "Kb Total: " + Core.totalRamKb + "Kb");
}
textView = (TextView)findViewById(R.id.proximity_value_str);
if (Core.proximity != Core.CONST_INVALID_PROXIMITY) {
textView.setText("" + Core.proximity);
}
}
}