Browse Source

init

master
Robin Thoni 9 years ago
commit
a8dbfe514d
37 changed files with 1492 additions and 0 deletions
  1. 32
    0
      .gitignore
  2. 21
    0
      SMSServer.iml
  3. 95
    0
      SMSServer/SMSServer-SMSServer.iml
  4. 29
    0
      SMSServer/build.gradle
  5. BIN
      SMSServer/libs/jetty-continuation-8.1.12.v20130726.jar
  6. BIN
      SMSServer/libs/jetty-http-8.1.12.v20130726.jar
  7. BIN
      SMSServer/libs/jetty-io-8.1.12.v20130726.jar
  8. BIN
      SMSServer/libs/jetty-server-8.1.12.v20130726.jar
  9. BIN
      SMSServer/libs/jetty-util-8.1.12.v20130726.jar
  10. BIN
      SMSServer/libs/servlet-api-3.0.jar
  11. 51
    0
      SMSServer/src/main/AndroidManifest.xml
  12. 19
    0
      SMSServer/src/main/java/com/rob57530/smsserver/BootReceiver.java
  13. 198
    0
      SMSServer/src/main/java/com/rob57530/smsserver/HttpHandler.java
  14. 169
    0
      SMSServer/src/main/java/com/rob57530/smsserver/MainActivity.java
  15. 121
    0
      SMSServer/src/main/java/com/rob57530/smsserver/Receiver.java
  16. 228
    0
      SMSServer/src/main/java/com/rob57530/smsserver/SMSServerService.java
  17. BIN
      SMSServer/src/main/res/drawable-hdpi/ic_launcher.png
  18. BIN
      SMSServer/src/main/res/drawable-mdpi/ic_launcher.png
  19. BIN
      SMSServer/src/main/res/drawable-xhdpi/ic_launcher.png
  20. BIN
      SMSServer/src/main/res/drawable-xxhdpi/ic_launcher.png
  21. BIN
      SMSServer/src/main/res/drawable/network_wireless.png
  22. 120
    0
      SMSServer/src/main/res/layout/activity_main.xml
  23. 3
    0
      SMSServer/src/main/res/menu/main.xml
  24. 8
    0
      SMSServer/src/main/res/values-sw600dp/dimens.xml
  25. 9
    0
      SMSServer/src/main/res/values-sw720dp-land/dimens.xml
  26. 11
    0
      SMSServer/src/main/res/values-v11/styles.xml
  27. 12
    0
      SMSServer/src/main/res/values-v14/styles.xml
  28. 7
    0
      SMSServer/src/main/res/values/dimens.xml
  29. 9
    0
      SMSServer/src/main/res/values/strings.xml
  30. 20
    0
      SMSServer/src/main/res/values/styles.xml
  31. 15
    0
      build.gradle
  32. BIN
      gradle/wrapper/gradle-wrapper.jar
  33. 6
    0
      gradle/wrapper/gradle-wrapper.properties
  34. 164
    0
      gradlew
  35. 90
    0
      gradlew.bat
  36. 54
    0
      import-summary.txt
  37. 1
    0
      settings.gradle

+ 32
- 0
.gitignore View File

@@ -0,0 +1,32 @@
1
+#built application files
2
+*.apk
3
+*.ap_
4
+
5
+# files for the dex VM
6
+*.dex
7
+
8
+# Java class files
9
+*.class
10
+
11
+# generated files
12
+bin/
13
+gen/
14
+
15
+# Local configuration file (sdk path, etc)
16
+local.properties
17
+
18
+# Windows thumbnail db
19
+Thumbs.db
20
+
21
+# OSX files
22
+.DS_Store
23
+
24
+# Eclipse project files
25
+.classpath
26
+.project
27
+
28
+# Android Studio
29
+.idea
30
+#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
31
+.gradle
32
+build/

+ 21
- 0
SMSServer.iml View File

@@ -0,0 +1,21 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
3
+  <component name="FacetManager">
4
+    <facet type="java-gradle" name="Java-Gradle">
5
+      <configuration>
6
+        <option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
7
+      </configuration>
8
+    </facet>
9
+  </component>
10
+  <component name="NewModuleRootManager" inherit-compiler-output="false">
11
+    <output url="file://$MODULE_DIR$/build/classes/main" />
12
+    <output-test url="file://$MODULE_DIR$/build/classes/test" />
13
+    <exclude-output />
14
+    <content url="file://$MODULE_DIR$">
15
+      <excludeFolder url="file://$MODULE_DIR$/.gradle" />
16
+    </content>
17
+    <orderEntry type="jdk" jdkName="1.7" jdkType="JavaSDK" />
18
+    <orderEntry type="sourceFolder" forTests="false" />
19
+  </component>
20
+</module>
21
+

+ 95
- 0
SMSServer/SMSServer-SMSServer.iml View File

@@ -0,0 +1,95 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
3
+  <component name="FacetManager">
4
+    <facet type="android-gradle" name="Android-Gradle">
5
+      <configuration>
6
+        <option name="GRADLE_PROJECT_PATH" value=":SMSServer" />
7
+      </configuration>
8
+    </facet>
9
+    <facet type="android" name="Android">
10
+      <configuration>
11
+        <option name="SELECTED_BUILD_VARIANT" value="debug" />
12
+        <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
13
+        <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
14
+        <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
15
+        <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
16
+        <option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
17
+        <option name="ALLOW_USER_CONFIGURATION" value="false" />
18
+        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
19
+        <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
20
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
21
+        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
22
+      </configuration>
23
+    </facet>
24
+  </component>
25
+  <component name="NewModuleRootManager" inherit-compiler-output="false">
26
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
27
+    <exclude-output />
28
+    <content url="file://$MODULE_DIR$">
29
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
30
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
31
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
32
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
33
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
34
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
35
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
36
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
37
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
38
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
39
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
40
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />
41
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
42
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
43
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
44
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
45
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
46
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
47
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
48
+      <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
49
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
50
+      <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
51
+      <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
52
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
53
+      <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
54
+      <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
55
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
56
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
57
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
58
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
59
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
60
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
61
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
62
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
63
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
64
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
65
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
66
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
67
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
68
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
69
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
70
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
71
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
72
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
73
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
74
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
75
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
76
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
77
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
78
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
79
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
80
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
81
+      <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
82
+      <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
83
+    </content>
84
+    <orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
85
+    <orderEntry type="sourceFolder" forTests="false" />
86
+    <orderEntry type="library" exported="" name="jetty-io-8.1.12.v20130726" level="project" />
87
+    <orderEntry type="library" exported="" name="jetty-server-8.1.12.v20130726" level="project" />
88
+    <orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
89
+    <orderEntry type="library" exported="" name="servlet-api-3.0" level="project" />
90
+    <orderEntry type="library" exported="" name="jetty-http-8.1.12.v20130726" level="project" />
91
+    <orderEntry type="library" exported="" name="jetty-util-8.1.12.v20130726" level="project" />
92
+    <orderEntry type="library" exported="" name="jetty-continuation-8.1.12.v20130726" level="project" />
93
+  </component>
94
+</module>
95
+

+ 29
- 0
SMSServer/build.gradle View File

@@ -0,0 +1,29 @@
1
+apply plugin: 'com.android.application'
2
+
3
+android {
4
+    compileSdkVersion 19
5
+    buildToolsVersion "21.1.2"
6
+
7
+    defaultConfig {
8
+        applicationId "com.rob57530.smsserver"
9
+        minSdkVersion 8
10
+        targetSdkVersion 19
11
+    }
12
+
13
+    buildTypes {
14
+        release {
15
+            minifyEnabled false
16
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
17
+        }
18
+    }
19
+}
20
+
21
+dependencies {
22
+    compile 'com.android.support:support-v4:19.1.0'
23
+    compile files('libs/jetty-continuation-8.1.12.v20130726.jar')
24
+    compile files('libs/jetty-http-8.1.12.v20130726.jar')
25
+    compile files('libs/jetty-io-8.1.12.v20130726.jar')
26
+    compile files('libs/jetty-server-8.1.12.v20130726.jar')
27
+    compile files('libs/jetty-util-8.1.12.v20130726.jar')
28
+    compile files('libs/servlet-api-3.0.jar')
29
+}

BIN
SMSServer/libs/jetty-continuation-8.1.12.v20130726.jar View File


BIN
SMSServer/libs/jetty-http-8.1.12.v20130726.jar View File


BIN
SMSServer/libs/jetty-io-8.1.12.v20130726.jar View File


BIN
SMSServer/libs/jetty-server-8.1.12.v20130726.jar View File


BIN
SMSServer/libs/jetty-util-8.1.12.v20130726.jar View File


BIN
SMSServer/libs/servlet-api-3.0.jar View File


+ 51
- 0
SMSServer/src/main/AndroidManifest.xml View File

@@ -0,0 +1,51 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+    package="com.rob57530.smsserver"
4
+    android:versionCode="1"
5
+    android:versionName="1.0" >
6
+
7
+    <uses-sdk
8
+        android:minSdkVersion="8"
9
+        android:targetSdkVersion="19" />
10
+
11
+    <uses-permission android:name="android.permission.INTERNET" />
12
+    <uses-permission android:name="android.permission.WRITE_SMS" />
13
+    <uses-permission android:name="android.permission.SEND_SMS" />
14
+    <uses-permission android:name="android.permission.READ_SMS" />
15
+    <uses-permission android:name="android.permission.RECEIVE_SMS" />
16
+    <uses-permission android:name="android.permission.READ_PHONE_STATE"/> 
17
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> 
18
+
19
+    <application
20
+        android:allowBackup="true"
21
+        android:icon="@drawable/ic_launcher"
22
+        android:label="@string/app_name"
23
+        android:theme="@style/AppTheme" >
24
+        <activity
25
+            android:name="com.rob57530.smsserver.MainActivity"
26
+            android:label="@string/app_name" >
27
+            <intent-filter>
28
+                <action android:name="android.intent.action.MAIN" />
29
+
30
+                <category android:name="android.intent.category.LAUNCHER" />
31
+            </intent-filter>
32
+        </activity>
33
+
34
+        <service
35
+            android:name="SMSServerService"
36
+            android:label="SMS Server Service"
37
+            android:permission="android.permission.WRITE_SMS">
38
+        </service>
39
+        <receiver android:name=".Receiver" android:exported="true" > 
40
+			<intent-filter android:priority="999">
41
+			  <action android:name="android.provider.Telephony.SMS_RECEIVED" />
42
+			</intent-filter>
43
+		</receiver>
44
+        <receiver android:name=".BootReceiver" android:exported="true" > 
45
+			<intent-filter>
46
+			  <action android:name="android.intent.action.BOOT_COMPLETED"/>
47
+			</intent-filter>
48
+		</receiver>
49
+    </application>
50
+
51
+</manifest>

+ 19
- 0
SMSServer/src/main/java/com/rob57530/smsserver/BootReceiver.java View File

@@ -0,0 +1,19 @@
1
+package com.rob57530.smsserver;
2
+
3
+import android.content.BroadcastReceiver;
4
+import android.content.Context;
5
+import android.content.Intent;
6
+import android.content.SharedPreferences;
7
+import android.preference.PreferenceManager;
8
+
9
+public class BootReceiver extends BroadcastReceiver
10
+{
11
+	@Override
12
+	public void onReceive(Context context, Intent intent)
13
+	{
14
+		SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context);
15
+		if(p.getBoolean("boot", true))
16
+			context.startService(new Intent(context, SMSServerService.class));
17
+	}
18
+
19
+}

+ 198
- 0
SMSServer/src/main/java/com/rob57530/smsserver/HttpHandler.java View File

@@ -0,0 +1,198 @@
1
+package com.rob57530.smsserver;
2
+
3
+import java.io.ByteArrayOutputStream;
4
+import java.io.IOException;
5
+import java.util.Vector;
6
+
7
+import javax.servlet.ServletException;
8
+import javax.servlet.http.HttpServletRequest;
9
+import javax.servlet.http.HttpServletResponse;
10
+
11
+import org.apache.http.HttpResponse;
12
+import org.apache.http.HttpStatus;
13
+import org.apache.http.StatusLine;
14
+import org.apache.http.client.ClientProtocolException;
15
+import org.apache.http.client.HttpClient;
16
+import org.apache.http.client.methods.HttpGet;
17
+import org.apache.http.impl.client.DefaultHttpClient;
18
+import org.eclipse.jetty.server.Request;
19
+import org.eclipse.jetty.server.handler.AbstractHandler;
20
+import org.json.JSONException;
21
+import org.json.JSONObject;
22
+
23
+import android.app.Activity;
24
+import android.app.PendingIntent;
25
+import android.content.BroadcastReceiver;
26
+import android.content.Context;
27
+import android.content.Intent;
28
+import android.content.IntentFilter;
29
+import android.os.AsyncTask;
30
+import android.telephony.SmsManager;
31
+import android.util.Base64;
32
+import android.util.Log;
33
+
34
+public class HttpHandler extends AbstractHandler
35
+{
36
+	private String m_http = null;
37
+	private Context m_context = null;
38
+	private Vector<Integer> m_ids = new Vector<Integer>();
39
+
40
+	class RequestTask extends AsyncTask<String, String, String>
41
+	{
42
+		@Override
43
+		protected String doInBackground(String... uri)
44
+		{
45
+			HttpClient httpclient = new DefaultHttpClient();
46
+			HttpResponse response;
47
+			String responseString = null;
48
+			try
49
+			{
50
+				HttpGet get = new HttpGet(uri[0]);
51
+				get.setHeader("Host", m_http);
52
+				get.setHeader("Authorization", "Basic " + Base64.encodeToString("__gates__:gatespasswd".getBytes(), Base64.NO_WRAP));
53
+
54
+				response = httpclient.execute(get);
55
+				StatusLine statusLine = response.getStatusLine();
56
+				if (statusLine.getStatusCode() == HttpStatus.SC_OK)
57
+				{
58
+					ByteArrayOutputStream out = new ByteArrayOutputStream();
59
+					response.getEntity().writeTo(out);
60
+					out.close();
61
+					responseString = out.toString();
62
+				}
63
+				else
64
+				{
65
+					response.getEntity().getContent().close();
66
+					throw new IOException(statusLine.getReasonPhrase());
67
+				}
68
+			}
69
+			catch (ClientProtocolException e)
70
+			{
71
+				e.printStackTrace();
72
+			}
73
+			catch (IOException e)
74
+			{
75
+				e.printStackTrace();
76
+			}
77
+			return responseString;
78
+		}
79
+
80
+		@Override
81
+		protected void onPostExecute(String result)
82
+		{
83
+			super.onPostExecute(result);
84
+		}
85
+	}
86
+
87
+	public void setContext(Context c)
88
+	{
89
+		m_context = c;
90
+	}
91
+
92
+	public void setHttp(String h)
93
+	{
94
+		m_http = h;
95
+	}
96
+
97
+	@Override
98
+	public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
99
+	{
100
+		response.setContentType("application/json;charset=utf-8");
101
+		response.setStatus(HttpServletResponse.SC_OK);
102
+		JSONObject root = new JSONObject();
103
+		if (target.equals("/send.php"))
104
+		{
105
+			String number = request.getParameter("to");
106
+			String text = request.getParameter("text");
107
+			int idTmp = -1;
108
+			try
109
+			{
110
+				idTmp = Integer.parseInt(request.getParameter("id"));
111
+			} 
112
+			catch(Exception e)
113
+			{
114
+				idTmp = m_ids.size();
115
+				m_ids.add(0);
116
+			}
117
+			final int id = idTmp;
118
+			if (number == null || number.length() == 0)
119
+			{
120
+				try
121
+				{
122
+					root.put("error", "Empty recipient");
123
+				}
124
+				catch (JSONException e)
125
+				{
126
+					response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
127
+				}
128
+			}
129
+			else if (text == null || text.length() == 0)
130
+			{
131
+				try
132
+				{
133
+					root.put("error", "Empty text");
134
+				}
135
+				catch (JSONException e)
136
+				{
137
+					response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
138
+				}
139
+			}
140
+			else
141
+			{
142
+				try
143
+				{
144
+					PendingIntent sent = null;
145
+					if (m_http.length() != 0 && id != -1)
146
+					{
147
+						String SENT = "SMS_SENT";
148
+						sent = PendingIntent.getBroadcast(m_context, 0, new Intent(SENT), 0);
149
+						m_context.registerReceiver(new BroadcastReceiver()
150
+						{
151
+							@Override
152
+							public void onReceive(Context arg0, Intent arg1)
153
+							{
154
+								int r = getResultCode();
155
+								if (r == Activity.RESULT_OK)
156
+									r = 1;
157
+								else if (r == SmsManager.RESULT_ERROR_GENERIC_FAILURE)
158
+									r = 3;
159
+								else if (r == SmsManager.RESULT_ERROR_NO_SERVICE)
160
+									r = 4;
161
+								else if (r == SmsManager.RESULT_ERROR_NULL_PDU)
162
+									r = 5;
163
+								else if (r == SmsManager.RESULT_ERROR_RADIO_OFF)
164
+									r = 6;
165
+								else
166
+									r = 7;
167
+								
168
+								RequestTask re = new RequestTask();
169
+								re.execute("http://" + m_http + "/sent.php?id=" + id + "&status=" + r);
170
+							}
171
+						}, new IntentFilter(SENT));
172
+					}
173
+
174
+					Log.d("SMSServerService", number);
175
+					SmsManager.getDefault().sendTextMessage(number, null, text, sent, null);
176
+					root.put("id", 0);
177
+					root.put("status", 0);
178
+				}
179
+				catch (Exception e)
180
+				{
181
+					e.printStackTrace();
182
+					try
183
+					{
184
+						root.put("error", e.getMessage());
185
+					}
186
+					catch (JSONException e1)
187
+					{
188
+						e1.printStackTrace();
189
+					}
190
+				}
191
+			}
192
+		}
193
+		else
194
+			return;
195
+		baseRequest.setHandled(true);
196
+		response.getWriter().println(root.toString());
197
+	}
198
+}

+ 169
- 0
SMSServer/src/main/java/com/rob57530/smsserver/MainActivity.java View File

@@ -0,0 +1,169 @@
1
+package com.rob57530.smsserver;
2
+
3
+import android.os.Build;
4
+import android.os.Bundle;
5
+import android.preference.PreferenceManager;
6
+import android.app.Activity;
7
+import android.app.ActivityManager;
8
+import android.app.ActivityManager.RunningServiceInfo;
9
+import android.content.Context;
10
+import android.content.Intent;
11
+import android.content.SharedPreferences;
12
+import android.content.SharedPreferences.Editor;
13
+import android.telephony.TelephonyManager;
14
+import android.view.Menu;
15
+import android.view.View;
16
+import android.widget.Button;
17
+import android.widget.CheckBox;
18
+import android.widget.CompoundButton;
19
+import android.widget.EditText;
20
+import android.widget.Toast;
21
+
22
+public class MainActivity extends Activity
23
+{
24
+	private Button m_btnStart;
25
+	private Button m_btnStop;
26
+	private EditText m_textPort;
27
+	private EditText m_textHttp;
28
+	private EditText m_textName;
29
+	private EditText m_textNumber;
30
+
31
+	@Override
32
+	protected void onCreate(Bundle savedInstanceState)
33
+	{
34
+		super.onCreate(savedInstanceState);
35
+		setContentView(R.layout.activity_main);
36
+		m_btnStart = (Button) findViewById(R.id.btnStart);
37
+		m_btnStop = (Button) findViewById(R.id.btnStop);
38
+		m_textPort = (EditText) findViewById(R.id.editTextPort);
39
+		m_textHttp = (EditText) findViewById(R.id.editTextHttp);
40
+		m_textName = (EditText) findViewById(R.id.editTextName);
41
+		m_textNumber = (EditText) findViewById(R.id.editTextNumber);
42
+		m_btnStart.setOnClickListener(new View.OnClickListener()
43
+		{
44
+			@Override
45
+			public void onClick(View v)
46
+			{
47
+				startServer();
48
+			}
49
+		});
50
+		m_btnStop.setOnClickListener(new View.OnClickListener()
51
+		{
52
+			@Override
53
+			public void onClick(View v)
54
+			{
55
+				stopServer();
56
+			}
57
+		});
58
+		m_textName.setHint(Build.MODEL);
59
+		try
60
+		{
61
+			m_textNumber.setHint(((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number());
62
+		}
63
+		catch (Exception e)
64
+		{
65
+
66
+		}
67
+
68
+		final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(this);
69
+		m_textHttp.setText(p.getString("http", m_textHttp.getHint().toString()));
70
+		m_textName.setText(p.getString("name", m_textName.getHint().toString()));
71
+		m_textPort.setText("" + p.getInt("port", 8080));
72
+		m_textNumber.setText(p.getString("number", m_textNumber.getHint().toString()));
73
+
74
+		CheckBox checkBoot = ((CheckBox) findViewById(R.id.checkBoxBoot));
75
+		checkBoot.setChecked(p.getBoolean("boot", true));
76
+		checkBoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
77
+		{
78
+			@Override
79
+			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
80
+			{
81
+				Editor e = p.edit();
82
+				e.putBoolean("boot", isChecked);
83
+				e.commit();
84
+			}
85
+		});
86
+
87
+		updateButtons();
88
+		startServer();
89
+	}
90
+
91
+	public void startServer()
92
+	{
93
+		int p = 0;
94
+		try
95
+		{
96
+			p = Integer.parseInt(m_textPort.getText().toString());
97
+		}
98
+		catch (Exception e)
99
+		{
100
+
101
+		}
102
+		String http = m_textHttp.getText().toString();
103
+		String name = m_textName.getText().toString();
104
+		String number = m_textNumber.getText().toString();
105
+
106
+		SharedPreferences pr = PreferenceManager.getDefaultSharedPreferences(this);
107
+		Editor edit = pr.edit();
108
+		edit.putString("http", http);
109
+		edit.putString("name", name);
110
+		edit.putInt("port", p);
111
+		edit.putString("number", number);
112
+		edit.commit();
113
+
114
+		try
115
+		{
116
+
117
+			if (http.length() == 0)
118
+				throw new Exception("Empty SMS Server");
119
+			if (name.length() == 0)
120
+				throw new Exception("Empty Name");
121
+			if (number.length() == 0)
122
+				throw new Exception("Empty Number");
123
+			if (p < 1 || p > 65535)
124
+				throw new Exception("Invalid Port (1 <= port <= 65535)");
125
+
126
+			startService(new Intent(MainActivity.this, SMSServerService.class));
127
+			updateButtons();
128
+
129
+		}
130
+		catch (Exception e)
131
+		{
132
+			Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
133
+		}
134
+	}
135
+
136
+	public void stopServer()
137
+	{
138
+		stopService(new Intent(MainActivity.this, SMSServerService.class));
139
+		updateButtons();
140
+	}
141
+
142
+	private boolean isServiceRunning()
143
+	{
144
+		ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
145
+		for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE))
146
+			if (SMSServerService.class.getName().equals(service.service.getClassName()))
147
+				return true;
148
+		return false;
149
+	}
150
+
151
+	private void updateButtons()
152
+	{
153
+		boolean is = isServiceRunning();
154
+		m_btnStart.setEnabled(!is);
155
+		m_btnStop.setEnabled(is);
156
+		m_textPort.setEnabled(!is);
157
+		m_textHttp.setEnabled(!is);
158
+		m_textName.setEnabled(!is);
159
+		m_textNumber.setEnabled(!is);
160
+	}
161
+
162
+	@Override
163
+	public boolean onCreateOptionsMenu(Menu menu)
164
+	{
165
+		getMenuInflater().inflate(R.menu.main, menu);
166
+		return true;
167
+	}
168
+
169
+}

+ 121
- 0
SMSServer/src/main/java/com/rob57530/smsserver/Receiver.java View File

@@ -0,0 +1,121 @@
1
+package com.rob57530.smsserver;
2
+
3
+import java.io.ByteArrayOutputStream;
4
+import java.io.IOException;
5
+import java.io.UnsupportedEncodingException;
6
+import java.net.URLEncoder;
7
+
8
+import org.apache.http.HttpResponse;
9
+import org.apache.http.HttpStatus;
10
+import org.apache.http.StatusLine;
11
+import org.apache.http.client.ClientProtocolException;
12
+import org.apache.http.client.HttpClient;
13
+import org.apache.http.client.methods.HttpGet;
14
+import org.apache.http.impl.client.DefaultHttpClient;
15
+
16
+import android.app.ActivityManager;
17
+import android.app.ActivityManager.RunningServiceInfo;
18
+import android.content.BroadcastReceiver;
19
+import android.content.Context;
20
+import android.content.Intent;
21
+import android.content.SharedPreferences;
22
+import android.os.AsyncTask;
23
+import android.preference.PreferenceManager;
24
+import android.telephony.SmsMessage;
25
+import android.util.Base64;
26
+import android.util.Log;
27
+
28
+public class Receiver extends BroadcastReceiver
29
+{
30
+
31
+	class RequestTask extends AsyncTask<String, String, String>
32
+	{
33
+		@Override
34
+		protected String doInBackground(String... uri)
35
+		{
36
+			HttpClient httpclient = new DefaultHttpClient();
37
+			HttpResponse response;
38
+			String responseString = null;
39
+			try
40
+			{
41
+				HttpGet get = new HttpGet(uri[0]);
42
+				get.setHeader("Host", uri[1]);
43
+				get.setHeader("Authorization", "Basic " + Base64.encodeToString("__gates__:gatespasswd".getBytes(), Base64.NO_WRAP));
44
+
45
+				response = httpclient.execute(get);
46
+				StatusLine statusLine = response.getStatusLine();
47
+				if (statusLine.getStatusCode() == HttpStatus.SC_OK)
48
+				{
49
+					ByteArrayOutputStream out = new ByteArrayOutputStream();
50
+					response.getEntity().writeTo(out);
51
+					out.close();
52
+					responseString = out.toString();
53
+				}
54
+				else
55
+				{
56
+					response.getEntity().getContent().close();
57
+					throw new IOException(statusLine.getReasonPhrase());
58
+				}
59
+			}
60
+			catch (ClientProtocolException e)
61
+			{
62
+				e.printStackTrace();
63
+			}
64
+			catch (IOException e)
65
+			{
66
+				e.printStackTrace();
67
+			}
68
+			return responseString;
69
+		}
70
+
71
+		@Override
72
+		protected void onPostExecute(String result)
73
+		{
74
+			super.onPostExecute(result);
75
+			Log.d("SMSServerReceiver", result);
76
+		}
77
+	}
78
+	
79
+	@Override
80
+	public void onReceive(Context context, Intent intent)
81
+	{
82
+		Log.d("SMSServerReceiver", "sms");
83
+		boolean running = false;
84
+		ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
85
+		for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE))
86
+			if (SMSServerService.class.getName().equals(service.service.getClassName()))
87
+			{
88
+				running = true;
89
+				break;
90
+			}
91
+		if(!running)
92
+			return;
93
+		Log.d("SMSServerReceiver", "sms (running)");
94
+		
95
+		SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context);
96
+		String http = p.getString("http", "");
97
+		if(http.length() == 0)
98
+			return;
99
+		
100
+		if(intent.getExtras() != null)
101
+        {
102
+            Object[] smsExtra = (Object[]) intent.getExtras().get("pdus");
103
+            if(smsExtra != null)
104
+	            for(int i=0;i<smsExtra.length;i++)
105
+	            {
106
+	            	try
107
+					{
108
+		            	SmsMessage sms = SmsMessage.createFromPdu((byte[])smsExtra[i]);
109
+		            	String body = sms.getMessageBody().toString();
110
+		            	String address = sms.getOriginatingAddress();
111
+	            		RequestTask r = new RequestTask();
112
+						r.execute("http://" + http + "/received.php?sender=" + URLEncoder.encode(address, "utf-8") + "&text=" + URLEncoder.encode(body, "utf-8"), http);
113
+					}
114
+					catch (UnsupportedEncodingException e)
115
+					{
116
+						e.printStackTrace();
117
+					}
118
+	            }
119
+        }
120
+	}
121
+}

+ 228
- 0
SMSServer/src/main/java/com/rob57530/smsserver/SMSServerService.java View File

@@ -0,0 +1,228 @@
1
+package com.rob57530.smsserver;
2
+
3
+import java.io.ByteArrayOutputStream;
4
+import java.io.IOException;
5
+import java.io.UnsupportedEncodingException;
6
+import java.net.URLEncoder;
7
+import java.util.Calendar;
8
+import java.util.Map;
9
+
10
+import org.apache.http.HttpResponse;
11
+import org.apache.http.HttpStatus;
12
+import org.apache.http.StatusLine;
13
+import org.apache.http.client.ClientProtocolException;
14
+import org.apache.http.client.HttpClient;
15
+import org.apache.http.client.methods.HttpGet;
16
+import org.apache.http.impl.client.DefaultHttpClient;
17
+import org.eclipse.jetty.server.Server;
18
+import org.eclipse.jetty.util.ajax.JSON;
19
+
20
+import android.app.Notification;
21
+import android.app.NotificationManager;
22
+import android.app.PendingIntent;
23
+import android.app.Service;
24
+import android.content.Context;
25
+import android.content.Intent;
26
+import android.content.SharedPreferences;
27
+import android.os.AsyncTask;
28
+import android.os.Handler;
29
+import android.os.IBinder;
30
+import android.preference.PreferenceManager;
31
+import android.support.v4.app.NotificationCompat;
32
+import android.util.Base64;
33
+import android.util.Log;
34
+
35
+public class SMSServerService extends Service
36
+{
37
+	private Server m_server = null;
38
+	private int m_port = 0;
39
+	private String m_http = null;
40
+	private String m_name = null;
41
+	private String m_number = null;
42
+	private int m_gateTimeout = -1;
43
+
44
+	private NotificationCompat.Builder m_builder = null;
45
+	private NotificationManager m_notificationManager = null;
46
+
47
+	private Handler m_handler = null;
48
+	private Runnable m_timer = new Runnable()
49
+	{
50
+		@Override
51
+		public void run()
52
+		{
53
+			register();
54
+		}
55
+	};
56
+
57
+	class RequestTask extends AsyncTask<String, String, String>
58
+	{
59
+		@Override
60
+		protected String doInBackground(String... uri)
61
+		{
62
+			Log.d("SMSServerService", "doinbackground");
63
+			HttpClient httpclient = new DefaultHttpClient();
64
+			HttpResponse response;
65
+			String responseString = null;
66
+			try
67
+			{
68
+				HttpGet get = new HttpGet(uri[0]);
69
+				get.setHeader("Host", m_http);
70
+				get.setHeader("Authorization", "Basic " + Base64.encodeToString("__gates__:gatespasswd".getBytes(), Base64.NO_WRAP));
71
+
72
+				response = httpclient.execute(get);
73
+				Log.d("SMSServerService", "doinbackground exec");
74
+				StatusLine statusLine = response.getStatusLine();
75
+				if (statusLine.getStatusCode() == HttpStatus.SC_OK)
76
+				{
77
+					ByteArrayOutputStream out = new ByteArrayOutputStream();
78
+					response.getEntity().writeTo(out);
79
+					out.close();
80
+					responseString = out.toString();
81
+				}
82
+				else
83
+				{
84
+					response.getEntity().getContent().close();
85
+					throw new IOException(statusLine.getReasonPhrase());
86
+				}
87
+			}
88
+			catch (ClientProtocolException e)
89
+			{
90
+				Log.d("SMSServerService", "doinbackground:" + e.toString());
91
+				e.printStackTrace();
92
+			}
93
+			catch (IOException e)
94
+			{
95
+				Log.d("SMSServerService", "doinbackground:" + e.toString());
96
+				e.printStackTrace();
97
+			}
98
+			Log.d("SMSServerService", "doinbackground end");
99
+			return responseString;
100
+		}
101
+
102
+		@Override
103
+		protected void onPostExecute(String result)
104
+		{
105
+			super.onPostExecute(result);
106
+			if (result != null)
107
+			{
108
+				@SuppressWarnings("unchecked")
109
+				Map<String, Object> root = (Map<String, Object>) JSON.parse(result);
110
+				if (root.containsKey("error"))
111
+				{
112
+					m_gateTimeout = 30;
113
+					Log.w("SMSServer", root.get("error").toString());
114
+					setText("Error: " + root.get("error").toString());
115
+				}
116
+				else
117
+				{
118
+					m_gateTimeout = ((Long) root.get("gateTimeout")).intValue();
119
+					Log.d("SMSServerService", "" + m_gateTimeout);
120
+					setText("Registered. id=" + ((Long) root.get("id")).intValue() + " timeout=" + m_gateTimeout);
121
+				}
122
+			}
123
+			else
124
+			{
125
+				m_gateTimeout = 30;
126
+				setText("Error while registering");
127
+			}
128
+			m_handler.postDelayed(m_timer, Math.max((m_gateTimeout - 20) * 1000, 10000));
129
+		}
130
+	}
131
+
132
+	private void setText(String t)
133
+	{
134
+		m_builder.setContentText(t).setOngoing(true).setWhen(Calendar.getInstance().getTimeInMillis());
135
+		Notification n = m_builder.build();
136
+		m_notificationManager.notify(0, n);
137
+		startForeground(0, n);
138
+	}
139
+
140
+	@Override
141
+	public int onStartCommand(Intent intent, int flags, int startId)
142
+	{
143
+		if (m_server == null)
144
+		{
145
+			Intent i = new Intent(getApplicationContext(), MainActivity.class);
146
+			i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
147
+			PendingIntent pi = PendingIntent.getActivity(this, 42, i, PendingIntent.FLAG_UPDATE_CURRENT);
148
+			m_builder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.network_wireless).setContentTitle("SMS Server").setContentIntent(pi);
149
+			m_notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
150
+			setText("Starting...");
151
+			SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(this);
152
+			m_port = p.getInt("port", 0);
153
+			m_http = p.getString("http", "");
154
+			m_name = p.getString("name", "");
155
+			m_number = p.getString("number", "");
156
+
157
+			try
158
+			{
159
+				if (m_name.length() == 0)
160
+					throw new Exception("Empty Name");
161
+				if (m_number.length() == 0)
162
+					throw new Exception("Empty Number");
163
+				if (m_port < 1 || m_port > 65535)
164
+					throw new Exception("Invalid Port (1 <= port <= 65535)");
165
+				m_handler = new Handler();
166
+				m_server = new Server(m_port);
167
+				HttpHandler h = new HttpHandler();
168
+				h.setContext(this);
169
+				h.setHttp(m_http);
170
+				m_server.setHandler(h);
171
+				m_server.start();
172
+				if (m_http.length() != 0)
173
+					register();
174
+			}
175
+			catch (Exception e)
176
+			{
177
+				e.printStackTrace();
178
+				setText("Error: " + e.getMessage());
179
+			}
180
+		}
181
+		return Service.START_REDELIVER_INTENT;
182
+	}
183
+
184
+	private void register()
185
+	{
186
+		try
187
+		{
188
+			setText("Registering...");
189
+			RequestTask r = new RequestTask();
190
+			r.execute("http://" + m_http + "/register.php?name=" + URLEncoder.encode(m_name, "utf-8") + "&number=" + URLEncoder.encode(m_number, "utf-8")
191
+					+ "&port=" + m_port);
192
+		}
193
+		catch (UnsupportedEncodingException e)
194
+		{
195
+			e.printStackTrace();
196
+		}
197
+	}
198
+
199
+	@Override
200
+	public void onDestroy()
201
+	{
202
+		m_handler.removeCallbacks(m_timer);
203
+		m_builder.setOngoing(false);
204
+		m_notificationManager.notify(0, m_builder.build());
205
+		stopForeground(false);
206
+		Log.d("SMSServerService", "stop");
207
+		if (m_server != null)
208
+		{
209
+			try
210
+			{
211
+				m_server.stop();
212
+			}
213
+			catch (Exception e)
214
+			{
215
+				e.printStackTrace();
216
+			}
217
+			m_server = null;
218
+		}
219
+		super.onDestroy();
220
+	}
221
+
222
+	@Override
223
+	public IBinder onBind(Intent arg0)
224
+	{
225
+		return null;
226
+	}
227
+
228
+}

BIN
SMSServer/src/main/res/drawable-hdpi/ic_launcher.png View File


BIN
SMSServer/src/main/res/drawable-mdpi/ic_launcher.png View File


BIN
SMSServer/src/main/res/drawable-xhdpi/ic_launcher.png View File


BIN
SMSServer/src/main/res/drawable-xxhdpi/ic_launcher.png View File


BIN
SMSServer/src/main/res/drawable/network_wireless.png View File


+ 120
- 0
SMSServer/src/main/res/layout/activity_main.xml View File

@@ -0,0 +1,120 @@
1
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
+    xmlns:tools="http://schemas.android.com/tools"
3
+    android:layout_width="match_parent"
4
+    android:layout_height="match_parent"
5
+    android:paddingBottom="@dimen/activity_vertical_margin"
6
+    android:paddingLeft="@dimen/activity_horizontal_margin"
7
+    android:paddingRight="@dimen/activity_horizontal_margin"
8
+    android:paddingTop="@dimen/activity_vertical_margin"
9
+    tools:context=".MainActivity" >
10
+
11
+    <Button
12
+        android:id="@+id/btnStart"
13
+        android:layout_width="wrap_content"
14
+        android:layout_height="wrap_content"
15
+        android:layout_alignParentLeft="true"
16
+        android:layout_alignParentRight="true"
17
+        android:layout_alignParentTop="true"
18
+        android:text="@string/start" />
19
+
20
+    <Button
21
+        android:id="@+id/btnStop"
22
+        android:layout_width="wrap_content"
23
+        android:layout_height="wrap_content"
24
+        android:layout_alignLeft="@+id/btnStart"
25
+        android:layout_alignRight="@+id/btnStart"
26
+        android:layout_below="@+id/btnStart"
27
+        android:text="@string/stop" />
28
+
29
+    <EditText
30
+        android:id="@+id/editTextPort"
31
+        android:layout_width="wrap_content"
32
+        android:layout_height="wrap_content"
33
+        android:layout_alignLeft="@+id/textViewPort"
34
+        android:layout_alignRight="@+id/textViewPort"
35
+        android:layout_below="@+id/textViewPort"
36
+        android:text="8080"
37
+        android:hint="8080"
38
+        android:ems="10"
39
+        android:inputType="number" />
40
+
41
+    <TextView
42
+        android:id="@+id/textViewHttp"
43
+        android:layout_width="wrap_content"
44
+        android:layout_height="wrap_content"
45
+        android:layout_alignLeft="@+id/editTextPort"
46
+        android:layout_alignRight="@+id/editTextPort"
47
+        android:layout_below="@+id/editTextPort"
48
+        android:text="SMS Server:" />
49
+
50
+    <EditText
51
+        android:id="@+id/editTextHttp"
52
+        android:layout_width="wrap_content"
53
+        android:layout_height="wrap_content"
54
+        android:layout_alignLeft="@+id/textViewHttp"
55
+        android:layout_alignRight="@+id/textViewHttp"
56
+        android:layout_below="@+id/textViewHttp"
57
+        android:text="sms.rthoni.com"
58
+        android:hint="sms.rthoni.com"
59
+        android:ems="10" >
60
+
61
+        <requestFocus />
62
+    </EditText>
63
+
64
+    <TextView
65
+        android:id="@+id/textViewName"
66
+        android:layout_width="wrap_content"
67
+        android:layout_height="wrap_content"
68
+        android:layout_alignLeft="@+id/editTextHttp"
69
+        android:layout_alignRight="@+id/editTextHttp"
70
+        android:layout_below="@+id/editTextHttp"
71
+        android:text="Name:" />
72
+
73
+    <EditText
74
+        android:id="@+id/editTextName"
75
+        android:layout_width="wrap_content"
76
+        android:layout_height="wrap_content"
77
+        android:layout_alignLeft="@+id/textViewName"
78
+        android:layout_alignRight="@+id/textViewName"
79
+        android:layout_below="@+id/textViewName"
80
+        android:ems="10" />
81
+
82
+    <TextView
83
+        android:id="@+id/textViewNumber"
84
+        android:layout_width="wrap_content"
85
+        android:layout_height="wrap_content"
86
+        android:layout_alignLeft="@+id/editTextName"
87
+        android:layout_alignRight="@+id/editTextName"
88
+        android:layout_below="@+id/editTextName"
89
+        android:text="Phone Number:" />
90
+
91
+    <EditText
92
+        android:id="@+id/editTextNumber"
93
+        android:layout_width="wrap_content"
94
+        android:layout_height="wrap_content"
95
+        android:layout_alignLeft="@+id/textViewNumber"
96
+        android:layout_alignRight="@+id/textViewNumber"
97
+        android:layout_below="@+id/textViewNumber"
98
+        android:ems="10"
99
+        android:inputType="phone" />
100
+
101
+    <CheckBox
102
+        android:id="@+id/checkBoxBoot"
103
+        android:layout_width="wrap_content"
104
+        android:layout_height="wrap_content"
105
+        android:layout_alignLeft="@+id/btnStop"
106
+        android:layout_alignRight="@+id/btnStop"
107
+        android:layout_below="@+id/btnStop"
108
+        android:checked="true"
109
+        android:text="Start at Boot" />
110
+
111
+    <TextView
112
+        android:id="@+id/textViewPort"
113
+        android:layout_width="wrap_content"
114
+        android:layout_height="wrap_content"
115
+        android:layout_alignLeft="@+id/checkBoxBoot"
116
+        android:layout_alignRight="@+id/checkBoxBoot"
117
+        android:layout_below="@+id/checkBoxBoot"
118
+        android:text="Port:" />
119
+
120
+</RelativeLayout>

+ 3
- 0
SMSServer/src/main/res/menu/main.xml View File

@@ -0,0 +1,3 @@
1
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
2
+
3
+</menu>

+ 8
- 0
SMSServer/src/main/res/values-sw600dp/dimens.xml View File

@@ -0,0 +1,8 @@
1
+<resources>
2
+
3
+    <!--
4
+         Customize dimensions originally defined in res/values/dimens.xml (such as
5
+         screen margins) for sw600dp devices (e.g. 7" tablets) here.
6
+    -->
7
+
8
+</resources>

+ 9
- 0
SMSServer/src/main/res/values-sw720dp-land/dimens.xml View File

@@ -0,0 +1,9 @@
1
+<resources>
2
+
3
+    <!--
4
+         Customize dimensions originally defined in res/values/dimens.xml (such as
5
+         screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
6
+    -->
7
+    <dimen name="activity_horizontal_margin">128dp</dimen>
8
+
9
+</resources>

+ 11
- 0
SMSServer/src/main/res/values-v11/styles.xml View File

@@ -0,0 +1,11 @@
1
+<resources>
2
+
3
+    <!--
4
+        Base application theme for API 11+. This theme completely replaces
5
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.
6
+    -->
7
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
8
+        <!-- API 11 theme customizations can go here. -->
9
+    </style>
10
+
11
+</resources>

+ 12
- 0
SMSServer/src/main/res/values-v14/styles.xml View File

@@ -0,0 +1,12 @@
1
+<resources>
2
+
3
+    <!--
4
+        Base application theme for API 14+. This theme completely replaces
5
+        AppBaseTheme from BOTH res/values/styles.xml and
6
+        res/values-v11/styles.xml on API 14+ devices.
7
+    -->
8
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
9
+        <!-- API 14 theme customizations can go here. -->
10
+    </style>
11
+
12
+</resources>

+ 7
- 0
SMSServer/src/main/res/values/dimens.xml View File

@@ -0,0 +1,7 @@
1
+<resources>
2
+
3
+    <!-- Default screen margins, per the Android Design guidelines. -->
4
+    <dimen name="activity_horizontal_margin">16dp</dimen>
5
+    <dimen name="activity_vertical_margin">16dp</dimen>
6
+
7
+</resources>

+ 9
- 0
SMSServer/src/main/res/values/strings.xml View File

@@ -0,0 +1,9 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<resources>
3
+
4
+    <string name="app_name">SMS Server</string>
5
+    <string name="action_settings">Settings</string>
6
+    <string name="start">Start Server</string>
7
+    <string name="stop">Stop Server</string>
8
+
9
+</resources>

+ 20
- 0
SMSServer/src/main/res/values/styles.xml View File

@@ -0,0 +1,20 @@
1
+<resources>
2
+
3
+    <!--
4
+        Base application theme, dependent on API level. This theme is replaced
5
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
6
+    -->
7
+    <style name="AppBaseTheme" parent="android:Theme.Light">
8
+        <!--
9
+            Theme customizations available in newer API levels can go in
10
+            res/values-vXX/styles.xml, while customizations related to
11
+            backward-compatibility can go here.
12
+        -->
13
+    </style>
14
+
15
+    <!-- Application theme. -->
16
+    <style name="AppTheme" parent="AppBaseTheme">
17
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
18
+    </style>
19
+
20
+</resources>

+ 15
- 0
build.gradle View File

@@ -0,0 +1,15 @@
1
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
2
+buildscript {
3
+    repositories {
4
+        jcenter()
5
+    }
6
+    dependencies {
7
+        classpath 'com.android.tools.build:gradle:1.0.0'
8
+    }
9
+}
10
+
11
+allprojects {
12
+    repositories {
13
+        jcenter()
14
+    }
15
+}

BIN
gradle/wrapper/gradle-wrapper.jar View File


+ 6
- 0
gradle/wrapper/gradle-wrapper.properties View File

@@ -0,0 +1,6 @@
1
+#Wed Apr 10 15:27:10 PDT 2013
2
+distributionBase=GRADLE_USER_HOME
3
+distributionPath=wrapper/dists
4
+zipStoreBase=GRADLE_USER_HOME
5
+zipStorePath=wrapper/dists
6
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip

+ 164
- 0
gradlew View File

@@ -0,0 +1,164 @@
1
+#!/usr/bin/env bash
2
+
3
+##############################################################################
4
+##
5
+##  Gradle start up script for UN*X
6
+##
7
+##############################################################################
8
+
9
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10
+DEFAULT_JVM_OPTS=""
11
+
12
+APP_NAME="Gradle"
13
+APP_BASE_NAME=`basename "$0"`
14
+
15
+# Use the maximum available, or set MAX_FD != -1 to use that value.
16
+MAX_FD="maximum"
17
+
18
+warn ( ) {
19
+    echo "$*"
20
+}
21
+
22
+die ( ) {
23
+    echo
24
+    echo "$*"
25
+    echo
26
+    exit 1
27
+}
28
+
29
+# OS specific support (must be 'true' or 'false').
30
+cygwin=false
31
+msys=false
32
+darwin=false
33
+case "`uname`" in
34
+  CYGWIN* )
35
+    cygwin=true
36
+    ;;
37
+  Darwin* )
38
+    darwin=true
39
+    ;;
40
+  MINGW* )
41
+    msys=true
42
+    ;;
43
+esac
44
+
45
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
46
+if $cygwin ; then
47
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48
+fi
49
+
50
+# Attempt to set APP_HOME
51
+# Resolve links: $0 may be a link
52
+PRG="$0"
53
+# Need this for relative symlinks.
54
+while [ -h "$PRG" ] ; do
55
+    ls=`ls -ld "$PRG"`
56
+    link=`expr "$ls" : '.*-> \(.*\)$'`
57
+    if expr "$link" : '/.*' > /dev/null; then
58
+        PRG="$link"
59
+    else
60
+        PRG=`dirname "$PRG"`"/$link"
61
+    fi
62
+done
63
+SAVED="`pwd`"
64
+cd "`dirname \"$PRG\"`/" >&-
65
+APP_HOME="`pwd -P`"
66
+cd "$SAVED" >&-
67
+
68
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69
+
70
+# Determine the Java command to use to start the JVM.
71
+if [ -n "$JAVA_HOME" ] ; then
72
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73
+        # IBM's JDK on AIX uses strange locations for the executables
74
+        JAVACMD="$JAVA_HOME/jre/sh/java"
75
+    else
76
+        JAVACMD="$JAVA_HOME/bin/java"
77
+    fi
78
+    if [ ! -x "$JAVACMD" ] ; then
79
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80
+
81
+Please set the JAVA_HOME variable in your environment to match the
82
+location of your Java installation."
83
+    fi
84
+else
85
+    JAVACMD="java"
86
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87
+
88
+Please set the JAVA_HOME variable in your environment to match the
89
+location of your Java installation."
90
+fi
91
+
92
+# Increase the maximum file descriptors if we can.
93
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94
+    MAX_FD_LIMIT=`ulimit -H -n`
95
+    if [ $? -eq 0 ] ; then
96
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97
+            MAX_FD="$MAX_FD_LIMIT"
98
+        fi
99
+        ulimit -n $MAX_FD
100
+        if [ $? -ne 0 ] ; then
101
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
102
+        fi
103
+    else
104
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105
+    fi
106
+fi
107
+
108
+# For Darwin, add options to specify how the application appears in the dock
109
+if $darwin; then
110
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111
+fi
112
+
113
+# For Cygwin, switch paths to Windows format before running java
114
+if $cygwin ; then
115
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117
+
118
+    # We build the pattern for arguments to be converted via cygpath
119
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120
+    SEP=""
121
+    for dir in $ROOTDIRSRAW ; do
122
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
123
+        SEP="|"
124
+    done
125
+    OURCYGPATTERN="(^($ROOTDIRS))"
126
+    # Add a user-defined pattern to the cygpath arguments
127
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129
+    fi
130
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
131
+    i=0
132
+    for arg in "$@" ; do
133
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
135
+
136
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
137
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138
+        else
139
+            eval `echo args$i`="\"$arg\""
140
+        fi
141
+        i=$((i+1))
142
+    done
143
+    case $i in
144
+        (0) set -- ;;
145
+        (1) set -- "$args0" ;;
146
+        (2) set -- "$args0" "$args1" ;;
147
+        (3) set -- "$args0" "$args1" "$args2" ;;
148
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154
+    esac
155
+fi
156
+
157
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158
+function splitJvmOpts() {
159
+    JVM_OPTS=("$@")
160
+}
161
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163
+
164
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

+ 90
- 0
gradlew.bat View File

@@ -0,0 +1,90 @@
1
+@if "%DEBUG%" == "" @echo off
2
+@rem ##########################################################################
3
+@rem
4
+@rem  Gradle startup script for Windows
5
+@rem
6
+@rem ##########################################################################
7
+
8
+@rem Set local scope for the variables with windows NT shell
9
+if "%OS%"=="Windows_NT" setlocal
10
+
11
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12
+set DEFAULT_JVM_OPTS=
13
+
14
+set DIRNAME=%~dp0
15
+if "%DIRNAME%" == "" set DIRNAME=.
16
+set APP_BASE_NAME=%~n0
17
+set APP_HOME=%DIRNAME%
18
+
19
+@rem Find java.exe
20
+if defined JAVA_HOME goto findJavaFromJavaHome
21
+
22
+set JAVA_EXE=java.exe
23
+%JAVA_EXE% -version >NUL 2>&1
24
+if "%ERRORLEVEL%" == "0" goto init
25
+
26
+echo.
27
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28
+echo.
29
+echo Please set the JAVA_HOME variable in your environment to match the
30
+echo location of your Java installation.
31
+
32
+goto fail
33
+
34
+:findJavaFromJavaHome
35
+set JAVA_HOME=%JAVA_HOME:"=%
36
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
+
38
+if exist "%JAVA_EXE%" goto init
39
+
40
+echo.
41
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42
+echo.
43
+echo Please set the JAVA_HOME variable in your environment to match the
44
+echo location of your Java installation.
45
+
46
+goto fail
47
+
48
+:init
49
+@rem Get command-line arguments, handling Windowz variants
50
+
51
+if not "%OS%" == "Windows_NT" goto win9xME_args
52
+if "%@eval[2+2]" == "4" goto 4NT_args
53
+
54
+:win9xME_args
55
+@rem Slurp the command line arguments.
56
+set CMD_LINE_ARGS=
57
+set _SKIP=2
58
+
59
+:win9xME_args_slurp
60
+if "x%~1" == "x" goto execute
61
+
62
+set CMD_LINE_ARGS=%*
63
+goto execute
64
+
65
+:4NT_args
66
+@rem Get arguments from the 4NT Shell from JP Software
67
+set CMD_LINE_ARGS=%$
68
+
69
+:execute
70
+@rem Setup the command line
71
+
72
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73
+
74
+@rem Execute Gradle
75
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76
+
77
+:end
78
+@rem End local scope for the variables with windows NT shell
79
+if "%ERRORLEVEL%"=="0" goto mainEnd
80
+
81
+:fail
82
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83
+rem the _cmd.exe /c_ return code!
84
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85
+exit /b 1
86
+
87
+:mainEnd
88
+if "%OS%"=="Windows_NT" endlocal
89
+
90
+:omega

+ 54
- 0
import-summary.txt View File

@@ -0,0 +1,54 @@
1
+ECLIPSE ANDROID PROJECT IMPORT SUMMARY
2
+======================================
3
+
4
+Ignored Files:
5
+--------------
6
+The following files were *not* copied into the new Gradle project; you
7
+should evaluate whether these are still needed in your project and if
8
+so manually move them:
9
+
10
+* ic_launcher-web.png
11
+* proguard-project.txt
12
+
13
+Replaced Jars with Dependencies:
14
+--------------------------------
15
+The importer recognized the following .jar files as third party
16
+libraries and replaced them with Gradle dependencies instead. This has
17
+the advantage that more explicit version information is known, and the
18
+libraries can be updated automatically. However, it is possible that
19
+the .jar file in your project was of an older version than the
20
+dependency we picked, which could render the project not compileable.
21
+You can disable the jar replacement in the import wizard and try again:
22
+
23
+android-support-v4.jar => com.android.support:support-v4:19.1.0
24
+
25
+Moved Files:
26
+------------
27
+Android Gradle projects use a different directory structure than ADT
28
+Eclipse projects. Here's how the projects were restructured:
29
+
30
+* AndroidManifest.xml => SMSServer/src/main/AndroidManifest.xml
31
+* assets/ => SMSServer/src/main/assets/
32
+* libs/jetty-continuation-8.1.12.v20130726.jar => SMSServer/libs/jetty-continuation-8.1.12.v20130726.jar
33
+* libs/jetty-http-8.1.12.v20130726.jar => SMSServer/libs/jetty-http-8.1.12.v20130726.jar
34
+* libs/jetty-io-8.1.12.v20130726.jar => SMSServer/libs/jetty-io-8.1.12.v20130726.jar
35
+* libs/jetty-server-8.1.12.v20130726.jar => SMSServer/libs/jetty-server-8.1.12.v20130726.jar
36
+* libs/jetty-util-8.1.12.v20130726.jar => SMSServer/libs/jetty-util-8.1.12.v20130726.jar
37
+* libs/servlet-api-3.0.jar => SMSServer/libs/servlet-api-3.0.jar
38
+* res/ => SMSServer/src/main/res/
39
+* src/ => SMSServer/src/main/java/
40
+
41
+Next Steps:
42
+-----------
43
+You can now build the project. The Gradle project needs network
44
+connectivity to download dependencies.
45
+
46
+Bugs:
47
+-----
48
+If for some reason your project does not build, and you determine that
49
+it is due to a bug or limitation of the Eclipse to Gradle importer,
50
+please file a bug at http://b.android.com with category
51
+Component-Tools.
52
+
53
+(This import summary is for your information only, and can be deleted
54
+after import once you are satisfied with the results.)

+ 1
- 0
settings.gradle View File

@@ -0,0 +1 @@
1
+include ':SMSServer'

Loading…
Cancel
Save