summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-08-20 22:35:01 +0200
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-08-25 07:01:17 +0000
commit7074b57fe487cceaa233109db09c5643b0beb4b4 (patch)
tree85c178bba91fbc78f9d502f2a2a39b7ab9ec0873
parent3070890ec5d9fe36a8db3021b733ffc7daa1ec31 (diff)
downloadandroid_development-7074b57fe487cceaa233109db09c5643b0beb4b4.tar.gz
android_development-7074b57fe487cceaa233109db09c5643b0beb4b4.tar.bz2
android_development-7074b57fe487cceaa233109db09c5643b0beb4b4.zip
DevTools: Mock SMS (4/4)
This change brings the possibility of simulate the reception of SMS on real devices. This change includes an activity to simulate the sending of a SMS throught the mock SMS feature Ported from http://review.cyanogenmod.org/#/c/23034/ Change-Id: I0e843a6c5ac7c69b1bc1dff156e1f14301674ca9 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
-rw-r--r--apps/Development/AndroidManifest.xml8
-rw-r--r--apps/Development/res/layout/sms_tester.xml93
-rw-r--r--apps/Development/res/values/cm_strings.xml28
-rw-r--r--apps/Development/src/com/android/development/SMSTester.java95
4 files changed, 224 insertions, 0 deletions
diff --git a/apps/Development/AndroidManifest.xml b/apps/Development/AndroidManifest.xml
index 74d2f422c..81f85a18d 100644
--- a/apps/Development/AndroidManifest.xml
+++ b/apps/Development/AndroidManifest.xml
@@ -30,6 +30,7 @@
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.REBOOT" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
+ <uses-permission android:name="android.permission.SEND_MOCK_SMS" />
<uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER" />
<uses-permission android:name="android.permission.SET_ALWAYS_FINISH" />
<uses-permission android:name="android.permission.SET_ANIMATION_SCALE" />
@@ -187,5 +188,12 @@
</intent-filter>
</activity>
+ <activity android:name="SMSTester" android:label="SMS Tester">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.TEST" />
+ </intent-filter>
+ </activity>
+
</application>
</manifest>
diff --git a/apps/Development/res/layout/sms_tester.xml b/apps/Development/res/layout/sms_tester.xml
new file mode 100644
index 000000000..30ea79249
--- /dev/null
+++ b/apps/Development/res/layout/sms_tester.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2013 The CyanogenMod Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:scrollbars="vertical">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sms_mock_title"
+ android:textSize="20dp" />
+ <TextView
+ android:background="#ff33b5e5"
+ android:layout_width="match_parent"
+ android:layout_height="2dp" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sms_smsc_address_title" />
+ <EditText
+ android:id="@+id/sms_tester_mock_sms_sc"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sms_default_address"
+ android:hint="@null"
+ android:singleLine="true" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sms_sender_address_title" />
+ <EditText
+ android:id="@+id/sms_tester_mock_sms_sender"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sms_default_address"
+ android:hint="@null"
+ android:singleLine="true" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sms_message_title" />
+ <EditText
+ android:id="@+id/sms_tester_mock_sms_msg"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sms_default_msg"
+ android:hint="@null"
+ android:singleLine="false"
+ android:lines="10"
+ android:minLines="10"
+ android:gravity="top|left"
+ android:scrollbars="vertical" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <Button
+ android:id="@+id/sms_tester_mock_sms_send_msg"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/sms_send_msg" />
+ <Button
+ android:id="@+id/sms_tester_mock_sms_send_pdu"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/sms_send_pdu" />
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/apps/Development/res/values/cm_strings.xml b/apps/Development/res/values/cm_strings.xml
new file mode 100644
index 000000000..22673e9ed
--- /dev/null
+++ b/apps/Development/res/values/cm_strings.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2013 The CyanogenMod Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <!-- Mock SMS -->
+ <string name="sms_mock_title">Mock SMS</string>
+ <string name="sms_smsc_address_title">SMSC Address:</string>
+ <string name="sms_sender_address_title">Sender Address:</string>
+ <string name="sms_message_title">Message:</string>
+ <string name="sms_send_msg">Send Mock SMS Message</string>
+ <string name="sms_send_pdu">Send Mock SMS PDU</string>
+ <string name="sms_default_address" translatable="false">+01123456789</string>
+ <string name="sms_default_msg">This is a mock SMS message.</string>
+</resources>
diff --git a/apps/Development/src/com/android/development/SMSTester.java b/apps/Development/src/com/android/development/SMSTester.java
new file mode 100644
index 000000000..faef6ea8a
--- /dev/null
+++ b/apps/Development/src/com/android/development/SMSTester.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2013 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.development;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.provider.Telephony.Sms.Intents;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.android.internal.util.HexDump;
+
+public class SMSTester extends Activity {
+
+ private final String MOCK_PDU =
+ "07914151551512f2040B916105551511f100006060605130308A04D4F29C0E";
+
+ private EditText mSc;
+ private EditText mSender;
+ private EditText mMsg;
+
+ @Override
+ protected void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ setContentView(R.layout.sms_tester);
+
+ mSc = (EditText)findViewById(R.id.sms_tester_mock_sms_sc);
+ mSender = (EditText)findViewById(R.id.sms_tester_mock_sms_sender);
+ mMsg = (EditText)findViewById(R.id.sms_tester_mock_sms_msg);
+
+ Button btnMockSms = (Button)findViewById(R.id.sms_tester_mock_sms_send_msg);
+ btnMockSms.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String sc = mSc.getText().toString();
+ String sender = mSender.getText().toString();
+ String msg = mMsg.getText().toString();
+
+ Intent in = new Intent(Intents.MOCK_SMS_RECEIVED_ACTION);
+ if (!TextUtils.isEmpty(sc)) {
+ in.putExtra("scAddr", sc);
+ }
+ if (!TextUtils.isEmpty(sender)) {
+ in.putExtra("senderAddr", sender);
+ }
+ if (!TextUtils.isEmpty(msg)) {
+ in.putExtra("msg", msg);
+ }
+ sendBroadcast(in);
+ }
+ });
+ Button btnMockSmsPdu = (Button)findViewById(R.id.sms_tester_mock_sms_send_pdu);
+ btnMockSmsPdu.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ byte[][] pdus = new byte[1][];
+ pdus[0] = HexDump.hexStringToByteArray(MOCK_PDU);
+ Intent in = new Intent(Intents.MOCK_SMS_RECEIVED_ACTION);
+ in.putExtra("pdus", pdus);
+ sendBroadcast(in);
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ }
+}
+