diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2013-08-20 22:35:01 +0200 |
---|---|---|
committer | Michael Bestas <mikeioannina@gmail.com> | 2014-02-16 18:23:23 +0200 |
commit | 9286c2ad16d479c4474937bafcffc5d0ec0838df (patch) | |
tree | df8cfc5d9ce67a7b6ed550d08072a68eba5aae79 | |
parent | 0c0ea97cc5a730947d43ba16920c89f8253fcc65 (diff) | |
download | android_development-9286c2ad16d479c4474937bafcffc5d0ec0838df.tar.gz android_development-9286c2ad16d479c4474937bafcffc5d0ec0838df.tar.bz2 android_development-9286c2ad16d479c4474937bafcffc5d0ec0838df.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.xml | 8 | ||||
-rw-r--r-- | apps/Development/res/layout/sms_tester.xml | 93 | ||||
-rw-r--r-- | apps/Development/res/values/cm_strings.xml | 27 | ||||
-rw-r--r-- | apps/Development/src/com/android/development/SMSTester.java | 95 |
4 files changed, 223 insertions, 0 deletions
diff --git a/apps/Development/AndroidManifest.xml b/apps/Development/AndroidManifest.xml index c1233a6e2..ac9ea0167 100644 --- a/apps/Development/AndroidManifest.xml +++ b/apps/Development/AndroidManifest.xml @@ -31,6 +31,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" /> @@ -188,5 +189,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..8bac5f1ef --- /dev/null +++ b/apps/Development/res/layout/sms_tester.xml @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2013-2014 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..bc18b50ee --- /dev/null +++ b/apps/Development/res/values/cm_strings.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2013-2014 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 xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- 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..b68d953a0 --- /dev/null +++ b/apps/Development/src/com/android/development/SMSTester.java @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2013-2014 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(); + } +} + |