1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.cellbroadcastreceiver.tests;
18 
19 import android.app.Activity;
20 import android.os.Bundle;
21 import android.os.Handler;
22 import android.os.Message;
23 import android.util.Log;
24 import android.view.View;
25 import android.view.View.OnClickListener;
26 import android.widget.Button;
27 import android.widget.CheckBox;
28 import android.widget.EditText;
29 
30 import java.util.Random;
31 
32 /**
33  * Activity to send test cell broadcast messages from GUI.
34  */
35 public class SendTestBroadcastActivity extends Activity {
36     private static final String TAG = "SendTestBroadcastActivity";
37 
38     /** Whether to delay before sending test message. */
39     private boolean mDelayBeforeSending;
40 
41     /** Whether to send additional language alerts for GSM CMAS. */
42     private boolean mIsAdditionalLangAlert;
43 
44     /** Delay time before sending test message (when box is checked). */
45     private static final int DELAY_BEFORE_SENDING_MSEC = 5000;
46 
47     private final Handler mDelayHandler = new Handler() {
48         @Override
49         public void handleMessage(Message msg) {
50             // call the onClick() method again, passing null View.
51             // The callback will ignore mDelayBeforeSending when the View is null.
52             OnClickListener pendingButtonClick = (OnClickListener) msg.obj;
53             pendingButtonClick.onClick(null);
54         }
55     };
56 
57     /**
58      * Increment the serial number and return the previous value.
59      * @return the current value of the serial number
60      */
getSerialNumber()61     private int getSerialNumber() {
62         EditText messageIdField = (EditText) findViewById(R.id.message_id);
63         int messageId = 0;
64         try {
65             messageId = Integer.parseInt(messageIdField.getText().toString());
66         } catch (NumberFormatException ignored) {
67             Log.e(TAG, "Invalid message ID");
68         }
69         int newMessageId = (messageId + 1) % 65536;
70         if (newMessageId == 0) {
71             newMessageId = 1;
72         }
73         messageIdField.setText(String.valueOf(newMessageId));
74         return messageId;
75     }
76 
77     /**
78      * Return the value of the category field.
79      * @return the current value of the category text field
80      */
getCategory()81     private int getCategory() {
82         EditText categoryField = (EditText) findViewById(R.id.category_id);
83         return Integer.parseInt(categoryField.getText().toString());
84     }
85 
86     /**
87      * Return the value of the message body.
88      * @return the current string of the message body text field
89      */
getMessageBody()90     private String getMessageBody() {
91         EditText bodyField = (EditText) findViewById(R.id.message_body);
92         return bodyField.getText().toString();
93     }
94 
95     /**
96      * Return the value of the language code.
97      * @return the current string of the language code text field
98      */
getLanguageCode()99     private String getLanguageCode() {
100         EditText languageCodeField = (EditText) findViewById(R.id.language_code);
101         return languageCodeField.getText().toString();
102     }
103 
104     /**
105      * Initialization of the Activity after it is first created.  Must at least
106      * call {@link android.app.Activity#setContentView(int)} to
107      * describe what is to be displayed in the screen.
108      */
109     @Override
onCreate(Bundle savedInstanceState)110     protected void onCreate(Bundle savedInstanceState) {
111         super.onCreate(savedInstanceState);
112 
113         setContentView(R.layout.test_buttons);
114 
115         /* Set message ID to a random value from 1-65535. */
116         EditText messageIdField = (EditText) findViewById(R.id.message_id);
117         messageIdField.setText(String.valueOf(new Random().nextInt(65535) + 1));
118 
119         /* When category ID is non-zero, use it for the GSM/UMTS message identifier. */
120         EditText categoryIdField = (EditText) findViewById(R.id.category_id);
121         categoryIdField.setText("0");
122 
123         /* Send an ETWS earthquake broadcast message to app. */
124         Button etwsEarthquakeTypeButton = (Button) findViewById(R.id.button_etws_earthquake_type);
125         etwsEarthquakeTypeButton.setOnClickListener(new OnClickListener() {
126             public void onClick(View v) {
127                 if (mDelayBeforeSending && v != null) {
128                     Message msg = mDelayHandler.obtainMessage(0, this);
129                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
130                 } else {
131                     SendTestMessages.testSendEtwsMessageEarthquake(
132                             SendTestBroadcastActivity.this.getApplicationContext(),
133                             getSerialNumber());
134                 }
135             }
136         });
137 
138         /* Send an ETWS tsunami broadcast message to app. */
139         Button etwsTsunamiTypeButton = (Button) findViewById(R.id.button_etws_tsunami_type);
140         etwsTsunamiTypeButton.setOnClickListener(new OnClickListener() {
141             public void onClick(View v) {
142                 if (mDelayBeforeSending && v != null) {
143                     Message msg = mDelayHandler.obtainMessage(0, this);
144                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
145                 } else {
146                     SendTestMessages.testSendEtwsMessageTsunami(
147                             SendTestBroadcastActivity.this.getApplicationContext(),
148                             getSerialNumber());
149                 }
150             }
151         });
152 
153         /* Send an ETWS earthquake and tsunami broadcast message to app. */
154         Button etwsEarthquakeTsunamiTypeButton = (Button)
155                 findViewById(R.id.button_etws_earthquake_tsunami_type);
156         etwsEarthquakeTsunamiTypeButton.setOnClickListener(new OnClickListener() {
157             public void onClick(View v) {
158                 if (mDelayBeforeSending && v != null) {
159                     Message msg = mDelayHandler.obtainMessage(0, this);
160                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
161                 } else {
162                     SendTestMessages.testSendEtwsMessageEarthquakeTsunami(
163                             SendTestBroadcastActivity.this.getApplicationContext(),
164                             getSerialNumber());
165                 }
166             }
167         });
168 
169         /* Send an ETWS other emergency broadcast message to app. */
170         Button etwsOtherTypeButton = (Button) findViewById(R.id.button_etws_other_type);
171         etwsOtherTypeButton.setOnClickListener(new OnClickListener() {
172             public void onClick(View v) {
173                 if (mDelayBeforeSending && v != null) {
174                     Message msg = mDelayHandler.obtainMessage(0, this);
175                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
176                 } else {
177                     SendTestMessages.testSendEtwsMessageOther(
178                             SendTestBroadcastActivity.this.getApplicationContext(),
179                             getSerialNumber());
180                 }
181             }
182         });
183 
184         /* Send an ETWS cancel broadcast message to app. */
185         Button etwsCancelTypeButton = (Button) findViewById(R.id.button_etws_cancel_type);
186         etwsCancelTypeButton.setOnClickListener(new OnClickListener() {
187             public void onClick(View v) {
188                 if (mDelayBeforeSending && v != null) {
189                     Message msg = mDelayHandler.obtainMessage(0, this);
190                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
191                 } else {
192                     SendTestMessages.testSendEtwsMessageCancel(
193                             SendTestBroadcastActivity.this.getApplicationContext(),
194                             getSerialNumber());
195                 }
196             }
197         });
198 
199         /* Send an ETWS test broadcast message to app. */
200         Button etwsTestTypeButton = (Button) findViewById(R.id.button_etws_test_type);
201         etwsTestTypeButton.setOnClickListener(new OnClickListener() {
202             public void onClick(View v) {
203                 if (mDelayBeforeSending && v != null) {
204                     Message msg = mDelayHandler.obtainMessage(0, this);
205                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
206                 } else {
207                     SendTestMessages.testSendEtwsMessageTest(
208                             SendTestBroadcastActivity.this.getApplicationContext(),
209                             getSerialNumber());
210                 }
211             }
212         });
213 
214         /* Send a CDMA CMAS presidential alert to app. */
215         Button CdmaCmasPresAlertButton = findViewById(R.id.button_cmas_pres_alert);
216         CdmaCmasPresAlertButton.setOnClickListener(new OnClickListener() {
217             public void onClick(View v) {
218                 if (mDelayBeforeSending && v != null) {
219                     Message msg = mDelayHandler.obtainMessage(0, this);
220                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
221                 } else {
222                     SendCdmaCmasMessages.testSendCmasPresAlert(
223                             SendTestBroadcastActivity.this.getApplicationContext(),
224                             getSerialNumber(), getMessageBody(), getLanguageCode());
225                 }
226             }
227         });
228 
229         /* Send a CDMA CMAS extreme alert to app. */
230         Button CdmaCmasExtremeAlertButton = findViewById(R.id.button_cmas_extreme_alert);
231         CdmaCmasExtremeAlertButton.setOnClickListener(new OnClickListener() {
232             public void onClick(View v) {
233                 if (mDelayBeforeSending && v != null) {
234                     Message msg = mDelayHandler.obtainMessage(0, this);
235                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
236                 } else {
237                     SendCdmaCmasMessages.testSendCmasExtremeAlert(
238                             SendTestBroadcastActivity.this.getApplicationContext(),
239                             getSerialNumber(), getMessageBody(), getLanguageCode());
240                 }
241             }
242         });
243 
244         /* Send a CDMA CMAS severe alert to app. */
245         Button CdmaCmasSevereAlertButton = findViewById(R.id.button_cmas_severe_alert);
246         CdmaCmasSevereAlertButton.setOnClickListener(new OnClickListener() {
247             public void onClick(View v) {
248                 if (mDelayBeforeSending && v != null) {
249                     Message msg = mDelayHandler.obtainMessage(0, this);
250                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
251                 } else {
252                     SendCdmaCmasMessages.testSendCmasSevereAlert(
253                             SendTestBroadcastActivity.this.getApplicationContext(),
254                             getSerialNumber(), getMessageBody(), getLanguageCode());
255                 }
256             }
257         });
258 
259         /* Send a CDMA CMAS AMBER alert to app. */
260         Button CdmaCmasAmberAlertButton = findViewById(R.id.button_cmas_amber_alert);
261         CdmaCmasAmberAlertButton.setOnClickListener(new OnClickListener() {
262             public void onClick(View v) {
263                 if (mDelayBeforeSending && v != null) {
264                     Message msg = mDelayHandler.obtainMessage(0, this);
265                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
266                 } else {
267                     SendCdmaCmasMessages.testSendCmasAmberAlert(
268                             SendTestBroadcastActivity.this.getApplicationContext(),
269                             getSerialNumber(), getMessageBody(), getLanguageCode());
270                 }
271             }
272         });
273 
274         /* Send a CDMA CMAS monthly test alert to app. */
275         Button CdmaCmasMonthlyTestButton = findViewById(R.id.button_cmas_monthly_test);
276         CdmaCmasMonthlyTestButton.setOnClickListener(new OnClickListener() {
277             public void onClick(View v) {
278                 if (mDelayBeforeSending && v != null) {
279                     Message msg = mDelayHandler.obtainMessage(0, this);
280                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
281                 } else {
282                     SendCdmaCmasMessages.testSendCmasMonthlyTest(
283                             SendTestBroadcastActivity.this.getApplicationContext(),
284                             getSerialNumber(), getMessageBody(), getLanguageCode());
285                 }
286             }
287         });
288 
289         /* Send a GSM CMAS alert to app. */
290         Button GsmCmasAlertButton = findViewById(R.id.button_gsm_cmas_alert);
291         GsmCmasAlertButton.setOnClickListener(
292                 new OnClickListener() {
293                     public void onClick(View v) {
294                         if (mDelayBeforeSending && v != null) {
295                             Message msg = mDelayHandler.obtainMessage(0, this);
296                             mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
297                         } else {
298                             SendGsmCmasMessages.testSendCmasAlertWithServiceCategory(
299                                     SendTestBroadcastActivity.this.getApplicationContext(),
300                                     getCategory(),
301                                     getSerialNumber(),
302                                     getMessageBody(),
303                                     getLanguageCode(),
304                                     mIsAdditionalLangAlert);
305                         }
306                     }
307                 });
308 
309         /* Send a GSM CMAS presidential alert to app. */
310         Button GsmCmasPresAlertButton = findViewById(R.id.button_gsm_cmas_pres_alert);
311         GsmCmasPresAlertButton.setOnClickListener(
312                 new OnClickListener() {
313                     public void onClick(View v) {
314                         if (mDelayBeforeSending && v != null) {
315                             Message msg = mDelayHandler.obtainMessage(0, this);
316                             mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
317                         } else {
318                             SendGsmCmasMessages.testSendCmasPresAlert(
319                                     SendTestBroadcastActivity.this.getApplicationContext(),
320                                     getSerialNumber(),
321                                     getMessageBody(),
322                                     getLanguageCode(),
323                                     mIsAdditionalLangAlert);
324                         }
325                     }
326                 });
327 
328         /* Send a GSM CMAS extreme alert to app. */
329         Button GsmCmasExtremeAlertButton = findViewById(R.id.button_gsm_cmas_extreme_alert);
330         GsmCmasExtremeAlertButton.setOnClickListener(
331                 new OnClickListener() {
332                     public void onClick(View v) {
333                         if (mDelayBeforeSending && v != null) {
334                             Message msg = mDelayHandler.obtainMessage(0, this);
335                             mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
336                         } else {
337                             SendGsmCmasMessages.testSendCmasExtremeAlert(
338                                     SendTestBroadcastActivity.this.getApplicationContext(),
339                                     getSerialNumber(),
340                                     getMessageBody(),
341                                     getLanguageCode(),
342                                     mIsAdditionalLangAlert);
343                         }
344                     }
345                 });
346 
347         /* Send a GSM CMAS severe alert to app. */
348         Button GsmCmasSevereAlertButton = findViewById(R.id.button_gsm_cmas_severe_alert);
349         GsmCmasSevereAlertButton.setOnClickListener(
350                 new OnClickListener() {
351                     public void onClick(View v) {
352                         if (mDelayBeforeSending && v != null) {
353                             Message msg = mDelayHandler.obtainMessage(0, this);
354                             mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
355                         } else {
356                             SendGsmCmasMessages.testSendCmasSevereAlert(
357                                     SendTestBroadcastActivity.this.getApplicationContext(),
358                                     getSerialNumber(),
359                                     getMessageBody(),
360                                     getLanguageCode(),
361                                     mIsAdditionalLangAlert);
362                         }
363                     }
364                 });
365 
366         /* Send a GSM CMAS AMBER alert to app. */
367         Button GsmCmasAmberAlertButton = findViewById(R.id.button_gsm_cmas_amber_alert);
368         GsmCmasAmberAlertButton.setOnClickListener(
369                 new OnClickListener() {
370                     public void onClick(View v) {
371                         if (mDelayBeforeSending && v != null) {
372                             Message msg = mDelayHandler.obtainMessage(0, this);
373                             mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
374                         } else {
375                             SendGsmCmasMessages.testSendCmasAmberAlert(
376                                     SendTestBroadcastActivity.this.getApplicationContext(),
377                                     getSerialNumber(),
378                                     getMessageBody(),
379                                     getLanguageCode(),
380                                     mIsAdditionalLangAlert);
381                         }
382                     }
383                 });
384 
385         /* Send a GSM CMAS monthly test alert to app. */
386         Button GsmCmasMonthlyTestButton = findViewById(R.id.button_gsm_cmas_monthly_test);
387         GsmCmasMonthlyTestButton.setOnClickListener(
388                 new OnClickListener() {
389                     public void onClick(View v) {
390                         if (mDelayBeforeSending && v != null) {
391                             Message msg = mDelayHandler.obtainMessage(0, this);
392                             mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
393                         } else {
394                             SendGsmCmasMessages.testSendCmasMonthlyTest(
395                                     SendTestBroadcastActivity.this.getApplicationContext(),
396                                     getSerialNumber(),
397                                     getMessageBody(),
398                                     getLanguageCode(),
399                                     mIsAdditionalLangAlert);
400                         }
401                     }
402                 });
403 
404         /* Send a GSM CMAS exercise test alert to app. */
405         Button GsmCmasExerciseTestButton = findViewById(R.id.button_gsm_cmas_exercise_test);
406         GsmCmasExerciseTestButton.setOnClickListener(
407                 new OnClickListener() {
408                     public void onClick(View v) {
409                         if (mDelayBeforeSending && v != null) {
410                             Message msg = mDelayHandler.obtainMessage(0, this);
411                             mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
412                         } else {
413                             SendGsmCmasMessages.testSendCmasExerciseTest(
414                                     SendTestBroadcastActivity.this.getApplicationContext(),
415                                     getSerialNumber(),
416                                     getMessageBody(),
417                                     getLanguageCode(),
418                                     mIsAdditionalLangAlert);
419                         }
420                     }
421                 });
422 
423         /* Send a GSM public safety messages to app. */
424         Button GsmPublicSafetyMessagesAlertTestButton = findViewById(
425                 R.id.button_gsm_public_safety_message);
426         GsmPublicSafetyMessagesAlertTestButton.setOnClickListener(
427                 new OnClickListener() {
428                     public void onClick(View v) {
429                         if (mDelayBeforeSending && v != null) {
430                             Message msg = mDelayHandler.obtainMessage(0, this);
431                             mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
432                         } else {
433                             SendGsmCmasMessages.testSendPublicSafetyMessagesAlert(
434                                     SendTestBroadcastActivity.this.getApplicationContext(),
435                                     getSerialNumber(),
436                                     getMessageBody(),
437                                     getLanguageCode(),
438                                     mIsAdditionalLangAlert);
439                         }
440                     }
441                 });
442 
443         /* Send a GSM state/local test alert to app. */
444         Button GsmStateLocalTestAlertButton = findViewById(
445                 R.id.button_gsm_state_local_test_alert);
446         GsmStateLocalTestAlertButton.setOnClickListener(
447                 new OnClickListener() {
448                     public void onClick(View v) {
449                         if (mDelayBeforeSending && v != null) {
450                             Message msg = mDelayHandler.obtainMessage(0, this);
451                             mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
452                         } else {
453                             SendGsmCmasMessages.testSendStateLocalTestAlert(
454                                     SendTestBroadcastActivity.this.getApplicationContext(),
455                                     getSerialNumber(),
456                                     getMessageBody(),
457                                     getLanguageCode(),
458                                     mIsAdditionalLangAlert);
459                         }
460                     }
461                 });
462 
463         /* Send a GSM 7-bit broadcast message to app. */
464         Button gsm7bitTypeButton = (Button) findViewById(R.id.button_gsm_7bit_type);
465         gsm7bitTypeButton.setOnClickListener(new OnClickListener() {
466             public void onClick(View v) {
467                 if (mDelayBeforeSending && v != null) {
468                     Message msg = mDelayHandler.obtainMessage(0, this);
469                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
470                 } else {
471                     SendTestMessages.testSendMessage7bit(
472                             SendTestBroadcastActivity.this.getApplicationContext(),
473                             getSerialNumber(), getCategory());
474                 }
475             }
476         });
477 
478         /* Send a UMTS 7-bit broadcast message to app. */
479         Button gsm7bitUmtsTypeButton = (Button) findViewById(R.id.button_gsm_7bit_umts_type);
480         gsm7bitUmtsTypeButton.setOnClickListener(new OnClickListener() {
481             public void onClick(View v) {
482                 if (mDelayBeforeSending && v != null) {
483                     Message msg = mDelayHandler.obtainMessage(0, this);
484                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
485                 } else {
486                     SendTestMessages.testSendMessage7bitUmts(
487                             SendTestBroadcastActivity.this.getApplicationContext(),
488                             getSerialNumber(), getCategory());
489                 }
490             }
491         });
492 
493         /* Send a GSM 7-bit no padding broadcast message to app. */
494         Button gsm7bitNoPaddingButton = (Button) findViewById(R.id.button_gsm_7bit_nopadding_type);
495         gsm7bitNoPaddingButton.setOnClickListener(new OnClickListener() {
496             public void onClick(View v) {
497                 if (mDelayBeforeSending && v != null) {
498                     Message msg = mDelayHandler.obtainMessage(0, this);
499                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
500                 } else {
501                     SendTestMessages.testSendMessage7bitNoPadding(
502                             SendTestBroadcastActivity.this.getApplicationContext(),
503                             getSerialNumber(), getCategory());
504                 }
505             }
506         });
507 
508         /* Send a UMTS 7-bit no padding broadcast message to app. */
509         Button gsm7bitNoPaddingUmtsTypeButton =
510                 (Button) findViewById(R.id.button_gsm_7bit_nopadding_umts_type);
511         gsm7bitNoPaddingUmtsTypeButton.setOnClickListener(new OnClickListener() {
512             public void onClick(View v) {
513                 if (mDelayBeforeSending && v != null) {
514                     Message msg = mDelayHandler.obtainMessage(0, this);
515                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
516                 } else {
517                     SendTestMessages.testSendMessage7bitNoPaddingUmts(
518                             SendTestBroadcastActivity.this.getApplicationContext(),
519                             getSerialNumber(), getCategory());
520                 }
521             }
522         });
523 
524         /* Send a UMTS 7-bit multi-page broadcast message to app. */
525         Button gsm7bitMultipageButton =
526                 (Button) findViewById(R.id.button_gsm_7bit_multipage_type);
527         gsm7bitMultipageButton.setOnClickListener(new OnClickListener() {
528             public void onClick(View v) {
529                 if (mDelayBeforeSending && v != null) {
530                     Message msg = mDelayHandler.obtainMessage(0, this);
531                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
532                 } else {
533                     SendTestMessages.testSendMessage7bitMultipageGsm(
534                             SendTestBroadcastActivity.this.getApplicationContext(),
535                             getSerialNumber(),
536                             getCategory());
537                 }
538             }
539         });
540 
541         /* Send a UMTS 7-bit multi-page broadcast message to app. */
542         Button gsm7bitMultipageUmtsButton =
543                 (Button) findViewById(R.id.button_gsm_7bit_multipage_umts_type);
544         gsm7bitMultipageUmtsButton.setOnClickListener(new OnClickListener() {
545             public void onClick(View v) {
546                 if (mDelayBeforeSending && v != null) {
547                     Message msg = mDelayHandler.obtainMessage(0, this);
548                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
549                 } else {
550                     SendTestMessages.testSendMessage7bitMultipageUmts(
551                         SendTestBroadcastActivity.this.getApplicationContext(),
552                         getSerialNumber(), getCategory());
553                 }
554             }
555         });
556 
557         /* Send a GSM 7-bit broadcast message with language to app. */
558         Button gsm7bitWithLanguageButton =
559                 (Button) findViewById(R.id.button_gsm_7bit_with_language_type);
560         gsm7bitWithLanguageButton.setOnClickListener(new OnClickListener() {
561             public void onClick(View v) {
562                 if (mDelayBeforeSending && v != null) {
563                     Message msg = mDelayHandler.obtainMessage(0, this);
564                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
565                 } else {
566                     SendTestMessages.testSendMessage7bitWithLanguage(
567                             SendTestBroadcastActivity.this.getApplicationContext(),
568                             getSerialNumber(), getCategory());
569                 }
570             }
571         });
572 
573         /* Send a GSM 7-bit broadcast message with language to app. */
574         Button gsm7bitWithLanguageInBodyButton =
575                 (Button) findViewById(R.id.button_gsm_7bit_with_language_body_gsm_type);
576         gsm7bitWithLanguageInBodyButton.setOnClickListener(new OnClickListener() {
577             public void onClick(View v) {
578                 if (mDelayBeforeSending && v != null) {
579                     Message msg = mDelayHandler.obtainMessage(0, this);
580                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
581                 } else {
582                     SendTestMessages.testSendMessage7bitWithLanguageInBody(
583                             SendTestBroadcastActivity.this.getApplicationContext(),
584                             getSerialNumber(),
585                             getCategory());
586                 }
587             }
588         });
589 
590         /* Send a UMTS 7-bit broadcast message with language to app. */
591         Button gsm7bitWithLanguageUmtsButton =
592                 (Button) findViewById(R.id.button_gsm_7bit_with_language_body_umts_type);
593         gsm7bitWithLanguageUmtsButton.setOnClickListener(new OnClickListener() {
594             public void onClick(View v) {
595                 if (mDelayBeforeSending && v != null) {
596                     Message msg = mDelayHandler.obtainMessage(0, this);
597                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
598                 } else {
599                     SendTestMessages.testSendMessage7bitWithLanguageInBodyUmts(
600                             SendTestBroadcastActivity.this.getApplicationContext(),
601                             getSerialNumber(), getCategory());
602                 }
603             }
604         });
605 
606         /* Send a GSM UCS-2 broadcast message to app. */
607         Button gsmUcs2TypeButton = (Button) findViewById(R.id.button_gsm_ucs2_type);
608         gsmUcs2TypeButton.setOnClickListener(new OnClickListener() {
609             public void onClick(View v) {
610                 if (mDelayBeforeSending && v != null) {
611                     Message msg = mDelayHandler.obtainMessage(0, this);
612                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
613                 } else {
614                     SendTestMessages.testSendMessageUcs2(
615                             SendTestBroadcastActivity.this.getApplicationContext(),
616                             getSerialNumber(), getCategory());
617                 }
618             }
619         });
620 
621         /* Send a UMTS UCS-2 broadcast message to app. */
622         Button gsmUcs2UmtsTypeButton = (Button) findViewById(R.id.button_gsm_ucs2_umts_type);
623         gsmUcs2UmtsTypeButton.setOnClickListener(new OnClickListener() {
624             public void onClick(View v) {
625                 if (mDelayBeforeSending && v != null) {
626                     Message msg = mDelayHandler.obtainMessage(0, this);
627                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
628                 } else {
629                     SendTestMessages.testSendMessageUcs2Umts(
630                             SendTestBroadcastActivity.this.getApplicationContext(),
631                             getSerialNumber(), getCategory());
632                 }
633             }
634         });
635 
636         /* Send a UMTS UCS-2 multipage broadcast message to app. */
637         Button gsmUcs2MultipageUmtsTypeButton =
638                 (Button) findViewById(R.id.button_gsm_ucs2_multipage_umts_type);
639         gsmUcs2MultipageUmtsTypeButton.setOnClickListener(new OnClickListener() {
640             public void onClick(View v) {
641                 if (mDelayBeforeSending && v != null) {
642                     Message msg = mDelayHandler.obtainMessage(0, this);
643                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
644                 } else {
645                     SendTestMessages.testSendMessageUcs2MultipageUmts(
646                             SendTestBroadcastActivity.this.getApplicationContext(),
647                             getSerialNumber(), getCategory());
648                 }
649             }
650         });
651 
652         /* Send a GSM UCS-2 broadcast message with language to app. */
653         Button gsmUcs2WithLanguageTypeButton =
654                 (Button) findViewById(R.id.button_gsm_ucs2_with_language_type);
655         gsmUcs2WithLanguageTypeButton.setOnClickListener(new OnClickListener() {
656             public void onClick(View v) {
657                 if (mDelayBeforeSending && v != null) {
658                     Message msg = mDelayHandler.obtainMessage(0, this);
659                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
660                 } else {
661                     SendTestMessages.testSendMessageUcs2WithLanguageInBody(
662                             SendTestBroadcastActivity.this.getApplicationContext(),
663                             getSerialNumber(), getCategory());
664                 }
665             }
666         });
667 
668         /* Send a UMTS UCS-2 broadcast message with language to app. */
669         Button gsmUcs2WithLanguageUmtsTypeButton =
670                 (Button) findViewById(R.id.button_gsm_ucs2_with_language_umts_type);
671         gsmUcs2WithLanguageUmtsTypeButton.setOnClickListener(new OnClickListener() {
672             public void onClick(View v) {
673                 if (mDelayBeforeSending && v != null) {
674                     Message msg = mDelayHandler.obtainMessage(0, this);
675                     mDelayHandler.sendMessageDelayed(msg, DELAY_BEFORE_SENDING_MSEC);
676                 } else {
677                     SendTestMessages.testSendMessageUcs2WithLanguageUmts(
678                             SendTestBroadcastActivity.this.getApplicationContext(),
679                             getSerialNumber(), getCategory());
680                 }
681             }
682         });
683 
684         /* Update boolean to delay before sending when box is checked. */
685         final CheckBox delayCheckbox = (CheckBox) findViewById(R.id.button_delay_broadcast);
686         delayCheckbox.setOnClickListener(new OnClickListener() {
687             public void onClick(View v) {
688                 mDelayBeforeSending = delayCheckbox.isChecked();
689             }
690         });
691 
692         /* Update boolean to set channel for addtional language alerts when box is checked. */
693         final CheckBox additionalLangCheckbox =
694                 (CheckBox) findViewById(R.id.button_additional_lang_broadcast);
695         additionalLangCheckbox.setOnClickListener(
696                 new OnClickListener() {
697                     public void onClick(View v) {
698                         mIsAdditionalLangAlert = additionalLangCheckbox.isChecked();
699                     }
700                 });
701     }
702 }
703